fix(control-center): unblock web UI cold start and remove homepage render bottlenecks#97
Open
hehefa wants to merge 1 commit into
Open
fix(control-center): unblock web UI cold start and remove homepage render bottlenecks#97hehefa wants to merge 1 commit into
hehefa wants to merge 1 commit into
Conversation
TianyiDataScience
left a comment
Owner
There was a problem hiding this comment.
Thanks for the focused fix and the clear write-up. I walked through the diff against the current server/runtime code, and the overall direction looks sensible: start the UI before the first monitor pass, make the cold-start homepage path degrade gracefully, and keep /healthz from reporting a false hard failure during warm-up.
I haven’t pulled the branch into the automation workspace yet, so the remaining step on my side is a quick verification pass on the exact patch before merge. Leaving a note now so this PR isn’t sitting without maintainer context.
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.
WebUI fix summary — 2026-04-15
Problem
The OpenClaw Control Center web UI was timing out on
GET /and failingnpm run smoke:ui.Observed behavior:
/healthzreportedstaleduring cold start because it depended on a monitor snapshot that could take tens of seconds to refresh.Root cause
The homepage render path was doing too much synchronous work during cold start:
Startup ordering blocked UI availability
src/index.tsawaitedrunMonitorOnce(adapter)before starting the UI server.Homepage render blocked on live runtime reads
readReadModelSnapshotWithLiveSessions()could synchronously wait on live session loading.loadCachedSessionPreview()synchronously built preview data from session histories.Homepage still had a hidden heavy path after the first fixes
buildGlobalVisibilityViewModel()calledcountRecentToolCalls().listSessionConversations()again and scanned recent session histories for up to 20 sessions.Cold-start health checks were too strict
/healthzmarked the appstalebefore the first background monitor pass finished.Fixes applied
1) Start UI before monitor
File:
src/index.tsChanged startup flow so that when
UI_MODE=true:runMonitorOnce(adapter)runs in the background.Result:
2) Make live sessions non-blocking on first render
File:
src/ui/server.tsAdded:
HTML_LIVE_SESSIONS_BLOCKING_TIMEOUT_MS = 250Changed behavior:
loadCachedLiveSessions()now kicks off a background refresh and can return cached/empty fallback data immediately.readReadModelSnapshotWithLiveSessions()races live session loading against a short timeout and falls back to the snapshot if live data is not ready yet.Result:
3) Make session preview background-refreshable
File:
src/ui/server.tsAdded:
renderSessionPreviewInFlightChanged behavior:
loadCachedSessionPreview()no longer forces a synchronous rebuild on first request.Result:
4) Remove duplicate recent tool-call history scan from homepage critical path
File:
src/ui/server.tsChanged behavior:
recentToolCallsCountfrom already-availabletaskSignalItems.buildGlobalVisibilityViewModel()receivestoolCallsCountdirectly instead of forcing another recent-session conversation scan.Result:
GET /timeouts.5) Add startup grace period for healthz
File:
src/runtime/healthz.tsAdded:
HEALTHZ_STARTUP_GRACE_MS = 60_000Changed behavior:
stalesnapshot/monitor freshness is downgraded towarn.Result:
/healthznow reports a warm-up state instead of a false hard failure.6) Update brittle source-based test
File:
test/ui-render-smoke.test.tsChanged a hard-coded source assertion to match the new non-blocking live-session logic and assert the blocking-timeout constant.
Result:
Validation
Manual validation
HTTP 2000.227srender time during verificationAutomated validation
npm test -- --test-reporter=specnpm run smoke:uiHealth validation
/healthzno longer hard-fails during initial warm-up.warninstead ofstale/503 when background monitor work has not completed yet.Diff summary
Files changed:
src/index.tssrc/runtime/healthz.tssrc/ui/server.tstest/ui-render-smoke.test.tsApproximate diff:
Suggested commit message
Suggested PR summary
This patch fixes Control Center WebUI timeouts by removing heavy synchronous work from the homepage critical path. The UI now starts before the first monitor sweep, live session and session preview reads degrade gracefully on cold start, duplicate recent tool-call history scans are removed from overview rendering, and
/healthznow reports a startup warm-up state instead of a false stale failure.