Skip to content

fix(ui): agent startup shows a panel error instead of loading automatically - #164532

Merged
steipete merged 1 commit into
mainfrom
fix/ui-agent-startup-pending-state
Oct 3, 2026
Merged

steipete merged 1 commit into
mainfrom
fix/ui-agent-startup-pending-state

Conversation

@steipete

@steipete steipete commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

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-failed and other errors) keep the existing error UI and repair guidance.

Why This Change Was Made

The Gateway already returns a typed, retryable UNAVAILABLE error with details.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's retryAfterMs as 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.

before

After, while pending:

after pending

After, auto-loaded with no user action:

after loaded

Screenshots come from pnpm dev:ui:mock with a new opt-in startup-pending fixture (first 4 reads per method return the pending error). Synthetic fixture data only.

Focused tests (local, --maxWorkers=1):

File Result Wall
ui/src/lib/gateway-availability.test.ts (new) pass 2.4 s
ui/src/app/router-outlet-controller.test.ts pass 4.6 s
ui/src/lib/model-catalog-store.lifecycle.test.ts pass 5.3 s
ui/src/lib/chat/chat-metadata-store.test.ts pass 3.5 s
ui/src/lib/sessions/session-roster-refresh.test.ts pass 4.4 s
ui/src/components/app-sidebar.catalog-events.test.ts pass 6.9 s
ui/src/e2e/chat-loading-deadlines.e2e.test.ts (8 tests incl. prolonged pending → auto-recovery, pending → real failure, navigation cancels retry) pass 30.5 s (14.2 s tests)

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.ts owner-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.ts and chat-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 jsdom EventTarget worker-initialization error; the CI-matching fork-pool run completed successfully.

Final head b386209d3172d08af7c1630a25a1f0f7806bf9ef: CI run 37159389143 passed. Its shared checks-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.

@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui scripts Repository scripts size: XL labels Oct 3, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 3, 2026
@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 3, 2026, 7:04 PM ET / 23:04 UTC (Revision 5).

ClawSweeper review

What this changes

The 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
Reviewed head: b386209d3172d08af7c1630a25a1f0f7806bf9ef

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A useful, coherent repair with inspected browser evidence, resolved lifecycle feedback, and successful exact-head CI.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): Inspected before/pending/loaded browser screenshots exercise the route and sidebar owners through the repository's startup-pending mock-Gateway setup; focused browser coverage asserts automatic recovery, terminal failures, and navigation cancellation. This is browser-boundary proof, not live restarting-Gateway proof. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (screenshot): Inspected before/pending/loaded browser screenshots exercise the route and sidebar owners through the repository's startup-pending mock-Gateway setup; focused browser coverage asserts automatic recovery, terminal failures, and navigation cancellation. This is browser-boundary proof, not live restarting-Gateway proof. No stored-data contract changes.
Evidence reviewed 8 items Pinned introduction and merge ownership: Reviewed the introduced delta from 120b436 to b386209. Raw test-merge records confirm the pinned base followed by the exact PR head; its metadata-store delta retains the reviewed lifecycle repairs.
Existing Gateway contract: The admission owner already marks only agent-database-inspection-pending as retryable UNAVAILABLE and supplies a 250 ms minimum. The PR consumes that existing typed contract without changing admission, authorization, or protocol.
Shared classification and pacing: The shared owner requires the typed error, UNAVAILABLE, retryable=true, and the exact pending code; server hints remain minimum waits and genuine inspection failures are excluded.
Findings None None.
Security None None.

How this fits together

The 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]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +312, Tests +584, Docs +2, Other +2. Total +900 across 40 files.

View PR surface stats
Area Files Added Removed Net
Source 26 394 82 +312
Tests 12 614 30 +584
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 1 3 1 +2
Total 40 1013 113 +900

Review metrics

Metric Value Why it matters
Net code growth Production/tooling +314; tests +534; test support +50; docs +2 Production growth is justified by extending shared startup handling and cancellation across existing read owners.

Technical review

Best 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.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Repairs a bounded post-restart Control UI recovery problem while preserving terminal error handling.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (screenshot): Inspected before/pending/loaded browser screenshots exercise the route and sidebar owners through the repository's startup-pending mock-Gateway setup; focused browser coverage asserts automatic recovery, terminal failures, and navigation cancellation. This is browser-boundary proof, not live restarting-Gateway proof. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. Inspected before/pending/loaded browser screenshots exercise the route and sidebar owners through the repository's startup-pending mock-Gateway setup; focused browser coverage asserts automatic recovery, terminal failures, and navigation cancellation. This is browser-boundary proof, not live restarting-Gateway proof. No stored-data contract changes.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. Inspected before/pending/loaded browser screenshots exercise the route and sidebar owners through the repository's startup-pending mock-Gateway setup; focused browser coverage asserts automatic recovery, terminal failures, and navigation cancellation. This is browser-boundary proof, not live restarting-Gateway proof. No stored-data contract changes.

Evidence

What I checked:

  • Pinned introduction and merge ownership: Reviewed the introduced delta from 120b436 to b386209. Raw test-merge records confirm the pinned base followed by the exact PR head; its metadata-store delta retains the reviewed lifecycle repairs. (ui/src/lib/chat/chat-metadata-store.ts:290, 320af1e561a2)
  • Existing Gateway contract: The admission owner already marks only agent-database-inspection-pending as retryable UNAVAILABLE and supplies a 250 ms minimum. The PR consumes that existing typed contract without changing admission, authorization, or protocol. (src/state/agent-database-admission.ts:37, b386209d3172)
  • Shared classification and pacing: The shared owner requires the typed error, UNAVAILABLE, retryable=true, and the exact pending code; server hints remain minimum waits and genuine inspection failures are excluded. (ui/src/lib/gateway-availability.ts:10, b386209d3172)
  • Prior finding resolved: Queued metadata demand checks its abort signal before dispatch; final unsubscribe aborts active retries, queued demand, and the scope-owned catalog controller. Regression cases cover cancellation and remount adoption, while retirement preserves a catalog needed by foreground demand. (ui/src/lib/chat/chat-metadata-store.ts:290, b386209d3172)
  • Inspected browser proof: Inspected prepared proof-image-1.png, proof-image-2.png, and proof-image-3.png from the media manifest. They show the original panel/diagnostic error, quiet startup presentation, and loaded chat/sidebar in the declared startup-pending mock-Gateway browser setup. The browser regression additionally asserts prolonged pending recovery without Retry, terminal failure visibility, and navigation cancellation. Live restarting-Gateway after-fix coverage is explicitly undisclosed as completed and remains a stated validation limitation. (ui/src/e2e/chat-loading-deadlines.e2e.test.ts:17, b386209d3172)
  • Still necessary on main and latest release: Fetched main's shared availability owner still lacks the pending classifier, and its route controller lacks startup retries. The latest release v2026.9.8 also lacks the shared handling. GitHub confirms fix(ui): show agent warm-up instead of restart error #164041 merged, but that narrower history-reader repair does not implement this PR's route/sidebar/model/metadata recovery. (ui/src/lib/gateway-availability.ts:9, 65fe6d98da24)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • RomneyDa: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (4 earlier review cycles)
  • reviewed 2026-10-03T20:55:56.171Z sha f394917 :: needs changes before merge. :: [P2] [P2] Retire queued metadata retries when the last consumer leaves
  • reviewed 2026-10-03T21:18:37.391Z sha 9ca8f43 :: needs changes before merge. :: [P2] [P2] Retire queued metadata retries when the last consumer leaves
  • reviewed 2026-10-03T22:08:35.827Z sha 971443387b52ba80c6683c95f2d1f50d461c1b05 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-03T22:49:07.491Z sha b386209 :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the fix/ui-agent-startup-pending-state branch from f394917 to 9ca8f43 Compare October 3, 2026 21:12
@steipete
steipete force-pushed the fix/ui-agent-startup-pending-state branch from 9ca8f43 to 9714433 Compare October 3, 2026 22:02
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 3, 2026
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.
@steipete
steipete force-pushed the fix/ui-agent-startup-pending-state branch from 9714433 to b386209 Compare October 3, 2026 22:43
@steipete
steipete merged commit e87ab44 into main Oct 3, 2026
113 checks passed
@steipete
steipete deleted the fix/ui-agent-startup-pending-state branch October 3, 2026 23:11
@steipete

steipete commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 4, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant