fix(usage-analysis): prevent blank page on cold start and improve error handling#661
Merged
fix(usage-analysis): prevent blank page on cold start and improve error handling#661
Conversation
…or handling Fixes #658 — Usage Analysis tab could show nothing (stuck on loading spinner or blank page) when: - Background stats calculation failed with no feedback to the webview - sanitizeStats dropped fields needed for rendering (locale, matrix, missed potential, workspace paths, suppressed tools) - bootstrap() had no error handling (blank page if toolkit import fails) - No timeout for the loading state (spinner forever) Changes: - extension.ts: send updateStatsError to webview on calculation failure; guard against stale async results posting into a recreated panel - webview/usage/main.ts: sanitizeStats now validates and passes through all fields; handle updateStatsError and null sanitization with error message + refresh button; bootstrap wraps in .catch() with fallback; 30s non-fatal loading timeout with refresh hint Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…essions Starting with Copilot 1.117+, chat sessions are stored under workspaceStorage/<hash>/GitHub.copilot/chatSessions/ instead of the older GitHub.copilot-chat/chatSessions/ path. Users on the unified Copilot extension (e.g. v0.45.x) had zero session data discovered. Add GitHub.copilot and github.copilot (case-sensitive variant) to: - workspaceStorage candidate list in discover() - globalStorage recursive scan - isCopilotChatSessionPath() path predicate - Module doc comment discovery scope list Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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
Fixes #658 — Usage Analysis tab could show nothing (stuck on loading spinner or blank page) on cold start.
Root Cause Analysis
Investigated the full data flow from
showUsageAnalysis()→calculateUsageAnalysisStats()→postMessage→sanitizeStats()→renderLayout()and identified multiple resilience gaps in the cold-start path (first time opening Usage Analysis with no cached stats):Error = spinner forever: If
calculateUsageAnalysisStatsfailed,.catch()only logged the error — no message was sent to the webview, leaving the user stuck on "⏳ Loading usage analysis…" indefinitely.sanitizeStatsdropped fields: The sanitization function only returned{today, last30Days, month, lastUpdated, backendConfigured}, strippinglocale,customizationMatrix,missedPotential,currentWorkspacePaths, andsuppressedUnknownTools. On cold start (wherewindow.__INITIAL_USAGE__is null), fallbacks to initial data don't help — the customization matrix shows "no workspaces", suppressed tools reappear, etc.Null sanitization = silent failure: If
sanitizeStatsreturned null, the message handler did nothing — no error, no retry, no feedback.bootstrap()had no error handling:void bootstrap()with no.catch()— if the toolkit import or anything else threw, the user saw a completely blank page.Stale async results: The panel could be closed and reopened while a calculation was still in flight, allowing stale results to post into a new panel.
Changes
vscode-extension/src/extension.tsupdateStatsErrormessage to the webview when background calculation failsvscode-extension/src/webview/usage/main.tssanitizeStats: Now validates and passes through all fields (with shape-level validation for nested objects likecustomizationMatrixandmissedPotential)updateStatsErrorand null sanitization result with user-friendly error + refresh buttonbootstrap(): Wrapped in.catch()with fallback error UI (plain HTML, not toolkit-dependent)Testing
npm run compilepasses (type-check + lint + build)