From 24a26cbe3412022d53b366fd664e1356838c02eb Mon Sep 17 00:00:00 2001 From: Timothy Date: Tue, 7 Jul 2026 13:55:05 +0200 Subject: [PATCH] fix: address #165 review findings (stale-response guard, security-test coverage, route/help-text nits) Co-Authored-By: Claude Fable 5 --- ErsatzTV.Tests/Controllers/ApiControllerSecurityTests.cs | 4 +++- ErsatzTV.Tests/Controllers/TroubleshootControllerTests.cs | 2 +- ErsatzTV/Controllers/Api/TroubleshootController.cs | 2 +- web/src/screens/LogsScreen.tsx | 6 ++++-- web/src/screens/SettingsScreen.tsx | 2 +- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ErsatzTV.Tests/Controllers/ApiControllerSecurityTests.cs b/ErsatzTV.Tests/Controllers/ApiControllerSecurityTests.cs index a0142cc13..4acfe3ca8 100644 --- a/ErsatzTV.Tests/Controllers/ApiControllerSecurityTests.cs +++ b/ErsatzTV.Tests/Controllers/ApiControllerSecurityTests.cs @@ -29,6 +29,7 @@ public class ApiControllerSecurityTests typeof(CollectionController), typeof(FFmpegProfileController), typeof(LibrariesController), + typeof(LogsController), typeof(MaintenanceController), typeof(PlayoutController), typeof(ResolutionController), @@ -37,7 +38,8 @@ public class ApiControllerSecurityTests typeof(ScriptedScheduleController), typeof(SessionController), typeof(SettingsController), - typeof(SmartCollectionController) + typeof(SmartCollectionController), + typeof(TroubleshootController) ]; foreach (Type controllerType in apiControllers) diff --git a/ErsatzTV.Tests/Controllers/TroubleshootControllerTests.cs b/ErsatzTV.Tests/Controllers/TroubleshootControllerTests.cs index 3eef07d1f..b9f51a6c3 100644 --- a/ErsatzTV.Tests/Controllers/TroubleshootControllerTests.cs +++ b/ErsatzTV.Tests/Controllers/TroubleshootControllerTests.cs @@ -42,7 +42,7 @@ public class TroubleshootControllerTests ?? throw new AssertionException("Missing action GetInfo"); var attribute = action.GetCustomAttributes().Single(); - attribute.Template.ShouldBe("/api/troubleshoot/info"); + attribute.Template.ShouldBe("api/troubleshoot/info"); attribute.Name.ShouldBe("GetTroubleshootingInfo"); } diff --git a/ErsatzTV/Controllers/Api/TroubleshootController.cs b/ErsatzTV/Controllers/Api/TroubleshootController.cs index 6e16b3719..dc8daee88 100644 --- a/ErsatzTV/Controllers/Api/TroubleshootController.cs +++ b/ErsatzTV/Controllers/Api/TroubleshootController.cs @@ -34,7 +34,7 @@ public class TroubleshootController( WriteIndented = true }; - [HttpGet("/api/troubleshoot/info", Name = "GetTroubleshootingInfo")] + [HttpGet("api/troubleshoot/info", Name = "GetTroubleshootingInfo")] [Tags("Troubleshooting")] [EndpointSummary("Get troubleshooting diagnostic info")] [EndpointGroupName("general")] diff --git a/web/src/screens/LogsScreen.tsx b/web/src/screens/LogsScreen.tsx index 86f2d2715..e1f96a25f 100644 --- a/web/src/screens/LogsScreen.tsx +++ b/web/src/screens/LogsScreen.tsx @@ -31,6 +31,7 @@ export function LogsScreen() { const [pageSize, setPageSize] = useState(50); const [state, setState] = useState({ entries: [], error: null, status: 'loading', totalCount: 0 }); const activeRef = useRef(true); + const seqRef = useRef(0); useEffect(() => { activeRef.current = true; @@ -54,14 +55,15 @@ export function LogsScreen() { // effect body) so a stale table stays visible during refetches instead of flashing to // a loading spinner on every filter keystroke or page change. const load = useCallback(() => { + const id = ++seqRef.current; getLogs({ filter, pageNum, pageSize }) .then((paged) => { - if (activeRef.current) { + if (activeRef.current && id === seqRef.current) { setState({ entries: paged.page ?? [], error: null, status: 'success', totalCount: paged.totalCount ?? 0 }); } }) .catch((error: unknown) => { - if (activeRef.current) { + if (activeRef.current && id === seqRef.current) { setState({ entries: [], error: messageFromLogsError(error), status: 'error', totalCount: 0 }); } }); diff --git a/web/src/screens/SettingsScreen.tsx b/web/src/screens/SettingsScreen.tsx index ec4869acb..0a675b0d7 100644 --- a/web/src/screens/SettingsScreen.tsx +++ b/web/src/screens/SettingsScreen.tsx @@ -854,7 +854,7 @@ function SystemPane({ Open Dashboard - + Open Classic UI