From 95bcd60aba33e89bf4ccded9f425485e083ff805 Mon Sep 17 00:00:00 2001 From: iamtoruk Date: Sun, 19 Apr 2026 13:34:30 -0700 Subject: [PATCH] fix: preserve view on period switch and auto-refresh Period switching no longer resets optimize or compare views back to the dashboard. Auto-refresh keeps the current screen. Arrow keys now work in all views. Added period switch hints to compare status bar. Closes #107 --- src/compare.tsx | 2 ++ src/dashboard.tsx | 10 ++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/compare.tsx b/src/compare.tsx index d295468..0f1947e 100644 --- a/src/compare.tsx +++ b/src/compare.tsx @@ -121,6 +121,7 @@ function ModelSelector({ models, onSelect, onBack }: ModelSelectorProps) { [space] select [enter] compare + {'<>'} switch period [esc] back [q] quit @@ -298,6 +299,7 @@ function ComparisonResults({ modelA, modelB, rows, categories, workingStyle, onB + {'<>'} switch period [esc] back [q] quit diff --git a/src/dashboard.tsx b/src/dashboard.tsx index 69a47d8..1b72d65 100644 --- a/src/dashboard.tsx +++ b/src/dashboard.tsx @@ -544,7 +544,7 @@ function StatusBar({ width, showProvider, view, findingCount, optimizeAvailable, {!isOptimize && optimizeAvailable && findingCount != null && findingCount > 0 && ( <> o optimize ({findingCount}) )} - {!isOptimize && view !== 'compare' && compareAvailable && ( + {!isOptimize && compareAvailable && ( <> c compare )} {showProvider && (<> p provider)} @@ -664,7 +664,6 @@ function InteractiveDashboard({ initialProjects, initialPeriod, initialProvider, const switchPeriod = useCallback((np: Period) => { if (np === period) return setPeriod(np) - setView(v => v === 'compare' ? v : 'dashboard') if (debounceRef.current) clearTimeout(debounceRef.current) debounceRef.current = setTimeout(() => { reloadData(np, activeProvider) }, 600) }, [period, activeProvider, reloadData]) @@ -672,7 +671,6 @@ function InteractiveDashboard({ initialProjects, initialPeriod, initialProvider, const switchPeriodImmediate = useCallback(async (np: Period) => { if (np === period) return setPeriod(np) - setView(v => v === 'compare' ? v : 'dashboard') if (debounceRef.current) clearTimeout(debounceRef.current) await reloadData(np, activeProvider) }, [period, activeProvider, reloadData]) @@ -689,8 +687,8 @@ function InteractiveDashboard({ initialProjects, initialPeriod, initialProvider, reloadData(period, next); return } const idx = PERIODS.indexOf(period) - if (key.leftArrow && view !== 'optimize') switchPeriod(PERIODS[(idx - 1 + PERIODS.length) % PERIODS.length]!) - else if ((key.rightArrow || key.tab) && view !== 'optimize') switchPeriod(PERIODS[(idx + 1) % PERIODS.length]!) + if (key.leftArrow) switchPeriod(PERIODS[(idx - 1 + PERIODS.length) % PERIODS.length]!) + else if (key.rightArrow || key.tab) switchPeriod(PERIODS[(idx + 1) % PERIODS.length]!) else if (input === '1') switchPeriodImmediate('today') else if (input === '2') switchPeriodImmediate('week') else if (input === '3') switchPeriodImmediate('30days') @@ -711,7 +709,7 @@ function InteractiveDashboard({ initialProjects, initialPeriod, initialProvider, : Loading {PERIOD_LABELS[period]}...} - {view !== 'compare' && } + {view !== 'compare' && } ) }