← Back to Pull requests

refactor(desktop): move root diagnostics below AppShell #5892

Closed
unknown closed this pull request without merging on Oct 02, 2026 01:56 UTC
View on GitHub
unknown unknown commented on Sep 30, 2026 17:53 UTC
Author

Summary

Refs #4582 — M5, diagnostics and startup notices.

AppShell reached Desktop diagnostics directly in three places: the error toast's report action (diagnostics.copyReport) and the previous-shutdown notice (takePreviousMainProcessInterruption / copyPreviousMainProcessInterruption), whose ref and effect lived in AppShellContent. Move both into a features/diagnostics slice:

  • DiagnosticReportToastProvider is the renderer's toast layer and builds the report action from the injected copyToastReport service. AppShell supplies only the three labels, which stay in the shared shell catalog beside the Error Boundary and command-palette copy that use the same words.

  • PreviousMainProcessInterruptionNotice owns the read, the shown-once guard and the toast. It is mounted beside the always-mounted ConversationLifecycle and still waits for appearance hydration. Its copy moves out of shell-remaining-copy.ts unchanged.

  • platform/desktop/create-diagnostics-services.ts is the only adapter, and feature-services composition is its only production importer. It forwards only the fields the toast carried, as AppShell did.
  • AppShell loses its three diagnostics bridge paths (9 → 6), one useEffect (hook gate 28 hooks / 43 → 42 call sites), one useRef and 262 non-trivia tokens. The renderer architecture ratchet rejects those bridge paths if they come back to app-shell.tsx.

    Not in this PR: the Error Boundary's crash report, the command palette's manual report (app-shell-command-actions.ts, which #5712 is rewriting) and About's manual report still call the bridge from legacy files. None of them runs in AppShell's render body.

    Verification

  • Desktop: 3,103/3,103 (Node 24, build:test + test:dist), including 8 new tests in diagnostics-owner.test.ts: the notice reads nothing before ready, shows once and copies its report; shows nothing after a clean shutdown; a locale change while the read is pending shows one notice, in the current locale; error toasts offer the report and copy it through the injected service; a failed copy shows the supplied labels; the adapter forwards only the fields present and delegates the previous-run calls; each owner is mounted once and the adapter is the only Desktop path.

  • Mutations: removing the shown-once guard, the cancellation check, the ready gate or the adapter's empty-field filtering each fails one of those tests; the restored implementation passes.

  • Desktop typecheck (preload, main, renderer, storybook), lint, format:check, Knip (desktop, ui), check:asf-headers, check:locale-hygiene --base, windows:inventory, check:app-shell-hooks, check:renderer-architecture --base c838e1fa7 --strict-base and the Astryx surface inventory (regenerated for the three new files) pass.

  • Electron: rename-focus.spec.ts and zh-tw-locale.spec.ts pass (2/2) on a local build, so the app boots with the new provider tree and survives a runtime locale switch. No Electron test exercises the report action or the notice; this PR adds none, per e2e/AGENTS.md.

  • Not run: a packaged build or a manual interrupted-shutdown reproduction. The Desktop side of the notice is covered by the existing main-process-diagnostics.test.ts.
  • AI use

  • No generative tool made a substantive contribution

  • Generative tooling made a substantive contribution
  • Tool(s) and scope: Claude Opus 5.5 (in Claude Code) implemented this ownership move, its tests, documentation and validation under human direction. The commit carries Generated-by: Claude Opus 5.5.

    Checklist

  • Tests cover the change and fail without it

  • Lint, format, typecheck and the affected suites pass locally
  • Does this PR entail a change in behavior?

  • Yes — described under Summary above

  • No
  • Diff: 474 lines (+355 / -119) across 5 files Reviewer: hqhq1025 Review duration: 1923m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.46) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.46 · 474 lines diff across 5 files
    0.46
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.369
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #5892"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 45.7% (MEDIUM) · Higher = larger blast radius
    45.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 18.1% · Safe to merge
    18.1%
    Repository