Repository navigation
Finish desktop startup resilience on finalized hardening stack #206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
187f8c3
Add bounded startup diagnostics
Occumed79 821f188
Add application startup recovery boundary
Occumed79 fa4b1b3
Add desktop startup recovery styling
Occumed79 bc660fb
Add startup resilience smoke guard
Occumed79 5ab0189
Integrate startup recovery with finalized runtime ownership
Occumed79 4cc6d53
Register startup hardening smoke test
Occumed79 fe0c44c
Gate startup resilience in Validate
Occumed79 f209ee8
Update P2 smoke for boundary-wrapped startup recovery
Occumed79 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import assert from "node:assert/strict"; | ||
| import { readFileSync } from "node:fs"; | ||
| import { fileURLToPath } from "node:url"; | ||
| import path from "node:path"; | ||
|
|
||
| const scriptDirectory = path.dirname(fileURLToPath(import.meta.url)); | ||
| const projectRoot = path.resolve(scriptDirectory, ".."); | ||
|
|
||
| function source(relativePath: string): string { | ||
| return readFileSync(path.join(projectRoot, relativePath), "utf8"); | ||
| } | ||
|
|
||
| const main = source("src/main.tsx"); | ||
| const diagnostics = source("src/startupDiagnostics.ts"); | ||
| const boundary = source("src/AppErrorBoundary.tsx"); | ||
| const css = source("src/startup-hardening.css"); | ||
|
|
||
| assert.match(main, /AppErrorBoundary/, "the application must render inside an error boundary"); | ||
| assert.match(main, /ApplicationFailureScreen/, "asynchronous boot failures must render a recovery screen"); | ||
| assert.match(main, /installGlobalBootDiagnostics\(\)/, "startup diagnostics must install before rendering"); | ||
| assert.match(main, /aria-busy/, "the root must expose startup busy state"); | ||
| assert.match(main, /requestIdleCallback/, "optional runtimes must defer until idle time"); | ||
| assert.match(main, /timeout: 1600/, "idle loading must include a bounded fallback"); | ||
| assert.match(main, /boot\(\)\.catch/, "asynchronous boot failures must be handled"); | ||
| assert.match(main, /markApplicationInteractive/, "the first interactive frame must be recorded"); | ||
| assert.match(main, /markOptionalRuntimesComplete/, "optional runtime completion must be recorded"); | ||
| assert.match(main, /import "\.\/startup-hardening\.css";/, "recovery styles must load"); | ||
| assert.doesNotMatch(main, /import\("\.\/dualMapTransitionRuntime"\)/, "startup resilience must not restore the renderer-blocking transition runtime"); | ||
|
|
||
| assert.match(diagnostics, /__NETWORK_MAP_BOOT__/, "boot diagnostics must be externally inspectable"); | ||
| assert.match(diagnostics, /runtimeRecords/, "optional runtime timing and state must be recorded"); | ||
| assert.match(diagnostics, /unhandledrejection/, "unhandled promise rejections must be captured"); | ||
| assert.match(diagnostics, /window-error/, "global runtime errors must be captured"); | ||
| assert.match(diagnostics, /duplicate/, "repeated identical failures must be deduplicated"); | ||
| assert.doesNotMatch(diagnostics, /setInterval\s*\(/, "startup diagnostics must not poll"); | ||
|
|
||
| assert.match(boundary, /componentDidCatch/, "React render failures must be recorded"); | ||
| assert.match(boundary, /role="alert"/, "the recovery screen must be announced to assistive technology"); | ||
| assert.match(boundary, /Reload application/, "the recovery screen must provide a deterministic reload action"); | ||
| assert.match(boundary, /Copy diagnostics/, "diagnostics must be easy to capture"); | ||
|
|
||
| assert.match(css, /min-height: 100vh/, "the recovery screen must fill the desktop viewport"); | ||
| assert.match(css, /max-height: calc\(100vh - 64px\)/, "recovery content must remain viewport constrained"); | ||
| assert.match(css, /@media \(forced-colors: active\)/, "recovery controls must support forced-colors mode"); | ||
|
|
||
| console.log("Startup hardening smoke test passed."); |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| import React from "react"; | ||
| import { recordBootFailure } from "./startupDiagnostics"; | ||
|
|
||
| type FailureScreenProps = { | ||
| title: string; | ||
| message: string; | ||
| onRetry?: () => void; | ||
| }; | ||
|
|
||
| type AppErrorBoundaryProps = { | ||
| children?: React.ReactNode; | ||
| }; | ||
|
|
||
| export function ApplicationFailureScreen({ title, message, onRetry }: FailureScreenProps) { | ||
| const copyDiagnostics = async (): Promise<void> => { | ||
| const diagnostics = window.__NETWORK_MAP_BOOT__?.snapshot(); | ||
| const payload = JSON.stringify(diagnostics || { message }, null, 2); | ||
| try { | ||
| await navigator.clipboard.writeText(payload); | ||
| } catch { | ||
| // Clipboard access is optional; technical details remain visible below. | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <main className="app-fatal-state" role="alert" aria-live="assertive"> | ||
| <section className="app-fatal-card"> | ||
| <p className="app-fatal-kicker">Network Map recovery</p> | ||
| <h1>{title}</h1> | ||
| <p>{message}</p> | ||
| <div className="app-fatal-actions"> | ||
| {onRetry ? <button type="button" onClick={onRetry}>Try again</button> : null} | ||
| <button type="button" onClick={() => window.location.reload()}>Reload application</button> | ||
| <button type="button" className="secondary" onClick={() => void copyDiagnostics()}>Copy diagnostics</button> | ||
| </div> | ||
| <details> | ||
| <summary>Technical details</summary> | ||
| <pre>{JSON.stringify(window.__NETWORK_MAP_BOOT__?.snapshot() || { message }, null, 2)}</pre> | ||
| </details> | ||
| </section> | ||
| </main> | ||
| ); | ||
| } | ||
|
|
||
| type ErrorBoundaryState = { | ||
| error: Error | null; | ||
| }; | ||
|
|
||
| export default class AppErrorBoundary extends React.Component<AppErrorBoundaryProps, ErrorBoundaryState> { | ||
| state: ErrorBoundaryState = { error: null }; | ||
|
|
||
| static getDerivedStateFromError(error: Error): ErrorBoundaryState { | ||
| return { error }; | ||
| } | ||
|
|
||
| componentDidCatch(error: Error, info: React.ErrorInfo): void { | ||
| recordBootFailure( | ||
| "react-render", | ||
| `${error.message}${info.componentStack ? `\n${info.componentStack}` : ""}`, | ||
| true, | ||
| ); | ||
| } | ||
|
|
||
| private retry = (): void => { | ||
| this.setState({ error: null }); | ||
| }; | ||
|
|
||
| render(): React.ReactNode { | ||
| if (this.state.error) { | ||
| return ( | ||
| <ApplicationFailureScreen | ||
| title="The map interface could not finish loading" | ||
| message="The application entered recovery mode instead of leaving a frozen or blank screen." | ||
| onRetry={this.retry} | ||
| /> | ||
| ); | ||
| } | ||
| return this.props.children; | ||
| } | ||
| } |
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Render recovery UI when
#rootis absent.This branch records the failure and throws before
boot().catch()at Line 193. The application therefore leaves a blank page for the exact root-validation failure that this startup hardening adds.Create a temporary recovery host in the document and render
ApplicationFailureScreeninto it instead of throwing.🤖 Prompt for AI Agents