From 672481bd6ecce54b1b81e4927821135022c9c22b Mon Sep 17 00:00:00 2001 From: esmaeelE Date: Sat, 14 Nov 2026 18:28:46 +0330 Subject: [PATCH 1/2] Markets ticker: show offline state when financial feed disabled Clicking the Markets tab toggled a bar that rendered null when /stocks was empty (FINANCIAL_ENABLED unset), so the tap appeared dead. Render an explicit offline hint instead. --- frontend/src/components/GlobalTicker.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/GlobalTicker.tsx b/frontend/src/components/GlobalTicker.tsx index 64c817d2..c69ff82b 100644 --- a/frontend/src/components/GlobalTicker.tsx +++ b/frontend/src/components/GlobalTicker.tsx @@ -10,7 +10,15 @@ export default function GlobalTicker() { const entries = Object.entries(stocks || {}); const fallback = financial_source === 'yfinance'; - if (entries.length === 0) return null; + if (entries.length === 0) { + return ( +
+ + MARKETS OFFLINE — set FINANCIAL_ENABLED=true or FINNHUB_API_KEY on the backend + +
+ ); + } // Render a single ticker item const renderItem = ([ticker, info]: [string, any], index: number) => { From 949c1b6770914cc6ccc7f690b35786a6851a11bf Mon Sep 17 00:00:00 2001 From: esmaeelE Date: Tue, 17 Nov 2026 11:56:14 +0330 Subject: [PATCH 2/2] Markets ticker: no offline flash while loading, default view unchanged MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Address review feedback on #709: - GlobalTicker: return null while stocks is still undefined so users with finance enabled never see a flash of the offline state before the first /api/live-data/slow response arrives. {} (feed off) still renders the bar. - Fresh installs: ticker starts closed when the backend reports no market data, so the bar only appears after an explicit MARKETS click. Only an unambiguous stored 'false' counts as a past user choice (older builds auto-wrote 'true' on every load); auto state is no longer persisted to localStorage. - Shorter, quieter offline text (no amber): 'MARKETS OFFLINE · see FINANCIAL_ENABLED in backend/.env'. - Drop unused imports in GlobalTicker (useState, TrendingUp, ChevronUp). Verified: eslint 0 errors; tsc --noEmit adds no new errors (178 pre-existing, all in *.test.ts fixtures); vitest 128 files / 1125 tests pass. --- frontend/src/app/page.tsx | 35 ++++++++++++++++++++++-- frontend/src/components/GlobalTicker.tsx | 16 +++++++---- 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/frontend/src/app/page.tsx b/frontend/src/app/page.tsx index 44117846..eb8f9e6f 100644 --- a/frontend/src/app/page.tsx +++ b/frontend/src/app/page.tsx @@ -115,6 +115,18 @@ export default function Dashboard() { const [leftOpen, setLeftOpen] = useState(true); const [rightOpen, setRightOpen] = useState(true); const [tickerOpen, setTickerOpen] = useState(true); + // True once the user has explicitly toggled the ticker (button or + // shortcut) or carried a "closed" preference from a previous session. + // Until then the open state follows whether the backend has market data, + // so fresh installs (FINANCIAL_ENABLED=false) keep the empty bottom edge + // and the offline hint only appears after a deliberate MARKETS click. + const tickerUserSetRef = useRef(false); + const { stocks: marketStocks } = useDataKeys(['stocks'] as const); + + const toggleTickerByUser = () => { + tickerUserSetRef.current = true; + setTickerOpen((p) => !p); + }; // Persist UI panel states useEffect(() => { @@ -123,9 +135,23 @@ export default function Dashboard() { const tk = localStorage.getItem('sb_ticker_open'); if (l !== null) setLeftOpen(l === 'true'); if (r !== null) setRightOpen(r === 'true'); - if (tk !== null) setTickerOpen(tk === 'true'); + // Only a stored "false" is an unambiguous past user choice (older + // builds auto-wrote "true" on every load); treat that as explicit and + // let "true"/absent follow the data-driven default below. + if (tk !== null) { + tickerUserSetRef.current = tk === 'false'; + setTickerOpen(tk === 'true'); + } }, []); + // Data-driven default: open only when market data exists, and only while + // the user hasn't expressed a preference. stocks === undefined means the + // first /api/live-data/slow response hasn't arrived yet — wait for it. + useEffect(() => { + if (tickerUserSetRef.current || marketStocks === undefined) return; + setTickerOpen(Object.keys(marketStocks).length > 0); + }, [marketStocks]); + useEffect(() => { localStorage.setItem('sb_left_open', leftOpen.toString()); }, [leftOpen]); @@ -135,6 +161,9 @@ export default function Dashboard() { }, [rightOpen]); useEffect(() => { + // Only persist explicit user choices — auto-open/close driven by + // market data must not overwrite (or masquerade as) a preference. + if (!tickerUserSetRef.current) return; localStorage.setItem('sb_ticker_open', tickerOpen.toString()); }, [tickerOpen]); @@ -329,7 +358,7 @@ export default function Dashboard() { useKeyboardShortcuts({ toggleLeft: () => setLeftOpen((p) => !p), toggleRight: () => setRightOpen((p) => !p), - toggleMarkets: () => setTickerOpen((p) => !p), + toggleMarkets: toggleTickerByUser, openSettings: () => setSettingsOpen(true), openLegend: () => setLegendOpen((p) => !p), openShortcuts: () => setShortcutsOpen((p) => !p), @@ -1274,7 +1303,7 @@ export default function Dashboard() { transition={{ type: 'spring', damping: 30, stiffness: 250 }} >