Repository navigation
fix(ui): agent startup shows a panel error instead of loading automatically - #164532
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 3, 2026, 7:04 PM ET / 23:04 UTC (Revision 5). ClawSweeper reviewWhat this changesThe Control UI shows a quiet startup status and automatically retries route, sidebar, model, and chat metadata reads while an agent prepares its database. Merge readiness✅ Ready for maintainer review This PR remains useful: current main lacks automatic recovery across the affected read owners. The earlier lifecycle finding is resolved, and this review found no blocking correctness defect. Priority: P2 Review scores
Verification
How this fits togetherThe Control UI reads session and model information through the Gateway WebSocket. Its route and data owners translate temporary database-preparation refusals into loading states, then populate chat and sidebar views when reads succeed. flowchart TD
A[Chat navigation and sidebar demand] --> B[Control UI read owners]
B --> C[Gateway responses]
C --> D{Database preparation pending}
D -->|Yes| E[Quiet startup status and paced retry]
E --> B
D -->|Ready| F[Loaded chat and sidebar]
D -->|Failed| G[Diagnostic and repair guidance]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +312, Tests +584, Docs +2, Other +2. Total +900 across 40 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep temporary preparation in the existing read owners with automatic recovery, consumer-scoped cancellation, and visible diagnostics for terminal failures. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main's route and shared availability paths do not recover from the existing typed preparation refusal. The submitted browser fixture demonstrates that trigger; this reviewer did not execute a current-main reproduction. Is this the best way to solve the issue? Yes. Shared classification and pacing extend existing route and data owners, preserve terminal failures, and avoid competing Gateway readiness policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 65fe6d98da24. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
f394917 to
9ca8f43
Compare
9ca8f43 to
9714433
Compare
After a Gateway restart, agent database inspection can keep session reads UNAVAILABLE (agent-database-inspection-pending) for minutes. The chat route fell into the generic "Panel failed to load" error and the sidebar showed the raw diagnostic plus the doctor repair hint twice, with no automatic recovery. The shared gateway-availability owner now classifies the pending state and the read backoff. The router outlet renders a muted "Starting up" status and revalidates the route until it loads; sidebar lists, the session catalog, models.list, and chat metadata retry quietly without a deadline while pending and cancel with their consumers. Real inspection failures keep the existing error and repair guidance.
9714433 to
b386209
Compare
|
Merged via squash.
|
…nclaw#164532) After a Gateway restart, agent database inspection can keep session reads UNAVAILABLE (agent-database-inspection-pending) for minutes. The chat route fell into the generic "Panel failed to load" error and the sidebar showed the raw diagnostic plus the doctor repair hint twice, with no automatic recovery. The shared gateway-availability owner now classifies the pending state and the read backoff. The router outlet renders a muted "Starting up" status and revalidates the route until it loads; sidebar lists, the session catalog, models.list, and chat metadata retry quietly without a deadline while pending and cancel with their consumers. Real inspection failures keep the existing error and repair guidance.
What Problem This Solves
Fixes: after a Gateway restart, the Control UI shows "Panel failed to load" plus two red sidebar cards with the raw doctor repair hint while an agent's database is still being prepared, and the chat never recovers without a manual Retry.
User Impact
User impact: during normal post-restart agent preparation (which can take a few minutes on large stores), the chat pane shows a small muted "Starting up — The agent is getting ready. This view will load automatically." status and the sidebar shows one quiet "Starting up…" line. Both load automatically as soon as the agent is ready. Real preparation failures (
agent-database-inspection-failedand other errors) keep the existing error UI and repair guidance.Why This Change Was Made
The Gateway already returns a typed, retryable
UNAVAILABLEerror withdetails.code = "agent-database-inspection-pending"during this window, but only chat-history loading (#164041) recognized it. The route loader, sidebar lists, session catalog,models.list, and chat metadata all treated it as a hard failure.The classifier and read backoff now live in one shared owner (
ui/src/lib/gateway-availability.ts), and each read owner uses it: the router outlet renders the calm status and revalidates the route; session lists and the catalog retry through their existing refresh coordinators; model catalog and chat metadata retry without consuming their ordinary deadlines. Pending retries honor the server'sretryAfterMsas a minimum, back off to 5 s, have no overall deadline (startup can legitimately take minutes), and cancel on navigation, disconnect, or when the last consumer goes away. No Gateway, protocol, or error-shape changes; there is no browser-visible "agent ready" event, so recovery is polling.Evidence
Before (mock Gateway, pending agent database): generic panel error and raw diagnostic card.
After, while pending:
After, auto-loaded with no user action:
Screenshots come from
pnpm dev:ui:mockwith a new opt-instartup-pendingfixture (first 4 reads per method return the pending error). Synthetic fixture data only.Focused tests (local,
--maxWorkers=1):ui/src/lib/gateway-availability.test.ts(new)ui/src/app/router-outlet-controller.test.tsui/src/lib/model-catalog-store.lifecycle.test.tsui/src/lib/chat/chat-metadata-store.test.tsui/src/lib/sessions/session-roster-refresh.test.tsui/src/components/app-sidebar.catalog-events.test.tsui/src/e2e/chat-loading-deadlines.e2e.test.ts(8 tests incl. prolonged pending → auto-recovery, pending → real failure, navigation cancels retry)New timing tests use fake timers or Playwright's virtual clock; no real sleeps. Also green:
pnpm tsgo:ui, UI test-type shards,pnpm ui:i18n:verify, oxlint/stylelint on changed files,pnpm lint:scripts,oxfmt --check,git diff --check. Independent Codex autoreview: scoped-clean. Gap: not yet exercised against a live restarting Gateway; the full backend declaration build was not run locally (CI covers it).Observed live on a production Gateway 2026-10-03: sessions RPCs returned the pending error for ~3 min after a deploy restart, then recovered; the UI stayed on the error panel until manual Retry.
Final validation after rebase and lifecycle fixes
The rebase preserves main's refactored metadata request cleanup and keeps its retired startup-deadline API removed. Final unsubscribe now retires queued metadata demand before dispatch while allowing remount adoption. Catalog cancellation belongs to the metadata scope, so retiring a refresh preserves a catalog read needed by foreground demand. These repairs resolve the ClawSweeper P2 and the earlier
chat-state.test.tsowner-transition timeouts.The later
checks-ui (3/3)failure came from three fake-clock advances that still expected the former 250 ms retry delay. They now advance through the shared 500 ms first retry and 1,000 ms second retry, preserving all assertions and production behavior. Both affected suites (chat-gateway.test.tsandchat-history-observation.test.ts) passed all 102 tests: Node 22.21 s wall; Bun with CI's fork pool 23.80 s wall, both with--maxWorkers=1. The first local Bun thread-pool attempt failed before the observation suite started with a jsdomEventTargetworker-initialization error; the CI-matching fork-pool run completed successfully.Final head
b386209d3172d08af7c1630a25a1f0f7806bf9ef: CI run 37159389143 passed. Its sharedchecks-ui (3/3)job took 236 CI seconds, including setup and the rest of the shard. ClawSweeper reviewed this exact head with no actionable findings. The coordinator verified a P2-scoped-clean Codex review of the lifecycle fixes; a fresh P2-scoped-clean Codex review covered the final test-clock delta. The live restarting-Gateway proof gap remains as stated above.