Refactor dashboard data flow and add resilience - #1
Draft
Blackleets wants to merge 1 commit into
Draft
Blackleets wants to merge 1 commit into
Blackleets wants to merge 1 commit into
Conversation
…, toast system - Extract all data-fetching logic from page.tsx into useAegisData hook (src/hooks/useAegisData.ts) keeping activeLayers as UI state in page - Add shared type definitions in src/lib/dashboard-types.ts - Add ToastProvider + useToast system (src/components/Toast.tsx) - Wrap each panel in isolated ErrorBoundary so one crash doesn't kill the dashboard - Add skeleton loaders (animate-pulse) to MarketsPanel and IntelFeed while data loads - Add 60s edge cache on /api/markets (s-maxage=60, stale-while-revalidate=120) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XgBr67RS2ki85QqAXau36C
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
useAegisDatahook — extracts ~200 lines of data-fetching logic frompage.tsxintosrc/hooks/useAegisData.ts.activeLayersstays in the page as UI state; the hook takes it as a parameter and returns{ data, backendStatus, globalStats, spaceWeather }.src/lib/dashboard-types.tscentralisesDashboardData,DashboardEntity,GlobalStats,SpaceWeather, andActiveLayersso every component imports from one place.src/components/Toast.tsxwithToastProvider,useToast()hook, and animated dismissal via Framer Motion (ready to wire up to error events).ErrorBoundary— each panel (MarketsPanel,IntelFeed,ScmPanel,OsintPanel,LiveAlerts,AiAnalyst) is wrapped independently so a crash in one panel doesn't take down the whole dashboard.MarketsPanelandIntelFeednow show animatedanimate-pulseplaceholders while their data loads instead of rendering empty states./api/markets— changed fromno-storetos-maxage=60, stale-while-revalidate=120, reducing upstream calls given the 15-minute polling interval.Test plan
/api/marketsresponse includesCache-Control: public, s-maxage=60, stale-while-revalidate=120🤖 Generated with Claude Code
https://claude.ai/code/session_01XgBr67RS2ki85QqAXau36C
Generated by Claude Code