Skip to content

fix(control-ui): preferences load late on signed-in chat reloads - #170649

Merged
steipete merged 4 commits into
mainfrom
steipete/coldload-bootstrap-ui-prefs
Oct 13, 2026
Merged

steipete merged 4 commits into
mainfrom
steipete/coldload-bootstrap-ui-prefs

Conversation

@steipete

@steipete steipete commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

A signed-in reload of a dashboard deep link still fetched the full editable configuration and then the viewer’s appearance/navigation preferences before applying the right display settings. The campaign census recorded a roughly 161 KB config.get response, plus a separate users.prefs.get round trip. The original reload showed 14 visual states over about 15 seconds; this change addresses the preference/config portion of that waterfall.

User Impact

Signed-in chat/dashboard reloads apply the authenticated viewer’s display preferences before hello and avoid two redundant boot RPCs. Full configuration edits and subsequent preference refreshes keep their existing behavior.

Why This Change Was Made

Extend the authenticated document’s existing bootstrap payload with a read-only display projection and the authenticated viewer’s appearance/rail preferences. The Gateway uses the existing canonical preference reader, config scope policy, and cached config schema/redaction owner. Public documents receive no authenticated seed; secret-bearing MCP arguments, environment values, headers, and certificate contents are omitted. Embedded documents remain private, no-store.

Chat reads its queue mode, web-search toggle, MCP summaries, swarm display, public session origin, and shared UI preferences from that projection. The editable config snapshot stays absent until a settings page or write needs it. Seed the existing per-connection profile read cache only for the first matching Gateway/profile connection; existing preference events, config refreshes, and reconnect paths retain ownership of subsequent refreshes. A selected bearer identity cannot adopt a different navigation-authenticated viewer’s seed. The profile preference decoder is shared between document adoption and RPC reads. Display consumers use the admitted resolved server snapshot after refresh, never an editable config draft. The config RPC and document builder now share the runtime-schema cache owner; document preparation supplies its held config instead of depending on global runtime preparation.

Boot preference inventory: shared theme/mode/accent, locale, chat visibility/send/follow-up preferences; profile theme/mode/accent, fonts, background, tab icon, and rail shortcuts. Other sidebar presentation state continues to come from its existing browser settings owner.

Measurement

The merged Team-scale benchmark and fixture were run against main at 4f8c8c58fc88 and the candidate. The local adapter supplies an authenticated inline bootstrap and a valid small config snapshot, because the stock benchmark’s 83-byte config stub has no config object and never exercises the profile preference read. Both variants use the same synthetic data and 35 ms RPC latency.

Boot census Before After
config.get requests 1 0
users.prefs.get requests 1 0
Total RPCs 86 84
RPC request + response JSON bytes 945,253 942,270
Target RPC response bytes 2,667 0

The reviewed patch rebased unchanged onto main at c1f504ab456d9e1bed594109ea7d4744be5308c0; final head is 47346e66892c35c2a2248afbe2d715f8200ae5db. The display seed is carried in the document; it is not an editable snapshot or an extra request. The synthetic config is much smaller than the measured production payload. These results establish removed round trips, not a production byte or latency estimate. On the loaded Mac, nav-to-settle was 4.57→3.63 s, forced layouts 46→48, and visual groups 5→5; timings and layout differences are noisy and no CPU/latency improvement is claimed.

Production LOC delta from git diff --stat origin/main...HEAD -- ':!*.test.ts' ':!*test-support*' ':!docs/*': +252 (343 additions, 91 deletions, 22 files; includes the generated boot manifest and three removed mock-baseline exceptions). Growth preserves the contract separating read-only display facts from complete revision-bearing editor snapshots and limits credential disclosure; the unconditional full-config boot read is removed where authenticated bootstrap coverage exists.

Evidence

  • New bootstrap regression fails on the old code: the old boot uses the system theme, empty rail, and no server locale instead of the document preferences. Candidate unit proof checks pre-hello preference selection and selected-bearer isolation.
  • New bundled browser regression: preferences apply before hello, both boot RPCs remain absent, and users.prefs.changed invalidates the document-seeded cache and adopts a changed profile theme. Passed; 29.36 s including the bundle build, test body 2.00 s.
  • Existing reconnect/cross-tab preference browser file: 8 passed; 77.06 s including the bundle build.
  • Bootstrap preference unit: 2 passed, 4.60 s. Config capability: 17 passed, 4.19 s. Shell config/write lifecycle: 45 passed, 6.39 s. Profile preference lifecycle: 15 passed, 4.43 s.
  • Gateway projection/redaction unit: passed again on the rebased repair head; Vitest wall time 51.97 s (37.29 s compiled-worker preparation). Authenticated/public HTTP boundary: 2 passed; wrapper wall time 201.16 s, dominated by a cold compiled-worker cache. The test verifies inline preferences, credential redaction, public document isolation, and private cache headers.
  • Shared schema owner regression: 30 passed (55.43 s runner wall time); config writes 21 passed / 1 existing skip (39.90 s Vitest), shared auth 12 passed (24.27 s), stale-write recovery 2 passed (43.88 s). The migrated tests preserve module exports and verify schema contents after config, registry, and explicit invalidation.
  • Formatting and git diff --check: passed. Independent Codex review: scoped clean at P0–P2. The approved four-commit patch rebased without changes or conflicts; frozen-lockfile installation passed.

Full UI suite and exact-head CI

Final head: 47346e66892c35c2a2248afbe2d715f8200ae5db, rebased onto c1f504ab456d9e1bed594109ea7d4744be5308c0. The approved patch replayed unchanged; frozen-lockfile installation passed. No new source changes were needed during this validation follow-up.

AWS Crabbox lease cbx_d8b89677b8a6 ran node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts on the final head: 761 files, 3,381 tests, 6,362 seconds. The initial result was 3,300 passed / 76 failed / 5 skipped. This fresh checkout lacked Playwright FFmpeg and WebKit, and its SSH-created directories needed the repository's canonical private-artifact permissions. These setup failures affected 39 files; they were not counted as product regressions.

After applying .github/workflows/crabbox-hydrate.yml's browser and permission preparation, all 46 initially failed files were rerun on both head and the pinned base, on the same AWS box: 138 passed / 6 failed on each revision (head 1,018 s; base 1,016 s). The six remaining assertions match exactly. Combining the full run's unaffected results with these complete-file reruns gives 3,374 passed / 6 inherited failures / 1 skipped across all 761 files. This is a full run plus explicit environment-repair reruns, not a claim that one full invocation was green.

Remaining UI failure Head and pinned-base evidence
chat-collapsed-reply-reveal.e2e Deep earlier-message reveal: screenshot timeout
chat-header-subagents.e2e Subagents batch: Details dialog never becomes visible
chat-position-rail.e2e (dark and light) Reader-position/keyboard-jump tests time out
chat-reply-preview-recovery.e2e Reconnect source-navigation click times out
control-ui-stale-build-reload.e2e Expected lazy activity chunk remains included

browser-auth-recovery.e2e failed on both revisions in the first comparison and passed on both after runner preparation; this remains recorded as an inherited intermittent failure, not a source fix. The initial full-head model-api-keys.real-gateway.e2e failure also reproduced on the pinned base at the identical CLI-logout assertion (line 149). A diagnostic-only addition retained Gateway logs before cleanup; assertions, timeouts, and product code were unchanged. The response was models.authRefresh → UNAVAILABLE because prepared model runtime publication was superseded (69 ms), not a 3-second timeout. The diagnostic stopped at this first matching base failure (158 s runner wall time), so the earlier passing replay is not treated as a fix. See the same-box diagnostic run.

The new bootstrap first-paint/refresh regression passes in the full run (1 case, 1.156 s body); the existing cross-tab/reconnect preference file passes all 8 cases. Sidebar cold-load passes both cases. The previous test-type error is absent after rebasing over its main fix.

Proof runs: full head + original base classification, canonical runner repair + all failed files on both revisions. Commands used JSON reporters to retain per-file/per-case results. No timeout was raised, assertion weakened, or test skipped to obtain these results.

Exact-head CI run 38361514754 completed with 56 passed, 22 skipped, 4 failed checks plus the aggregate CI gate. All four failing checks have matching base evidence:

  • UI shard 2: collapsed-reply reveal.
  • UI shard 6: subagent-header Details dialog.
  • UI shard 8: position rail and reply-preview recovery.
  • Compact small 16: pinned Bun chat.native-runtime-consent.test.ts > rejects first-send consent when its captured database owner is replaced. The same case fails at the same retained-session-row assertion on the pinned base, using the same AWS lease and repository-pinned Bun fork. Its baseline log was retained with the full-suite artifacts.

No CI reruns or merge were performed. The AWS lease was stopped after collecting all results. No live Team state or private captures were used in public proof.

Visual proof

Synthetic before/after captures hold hello pending to expose startup preference selection. Before uses the system’s dark theme; after already uses the saved light preference. Images are attached below.

Release-note context: signed-in chat/dashboard reloads apply display preferences from the authenticated document and avoid redundant config/profile preference boot RPCs; settings and live preference refresh behavior are preserved.

Before: system theme while hello is held

After: saved light preference before hello

@clawsweeper

clawsweeper Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T07:22:41.194038Z 47346e6 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime size: L labels Oct 13, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 661eabfd76

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@@ -455,7 +454,9 @@ export class ShellGatewayOwner {
});
const context = this.host.context;
const generation = ++this.preferenceGeneration;
this.runtimeConfigReady = runtimeConfig.ensureLoaded().then(async () => {
this.runtimeConfigReady = (
runtimeConfig.state.bootstrapConfig ? Promise.resolve() : runtimeConfig.ensureLoaded()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Revalidate bootstrap state after WebSocket admission

On an initial same-credential connection, such as trusted-proxy or no-bearer authentication, configuration can change after the HTML bootstrap is generated but before this client subscribes to Gateway events. That client misses the intervening config.changed; the startup config.refresh({ ifNeeded: true }) reuses the recently embedded payload, and this branch also skips config.get, leaving the display projection stale until another change or reload. Since the projection supplies queue mode and the chat path can send that value explicitly, this can preserve behavior that the operator already changed. Use a revision/watermark or a post-subscription catch-up before accepting the bootstrap cache as current. The same freshness mechanism should cover the document-seeded preference cache, which has the equivalent missed-event window.

AGENTS.md reference: ui/AGENTS.md:L12-L14

Useful? React with 👍 / 👎.

@steipete steipete changed the title perf(control-ui): seed display preferences from authenticated bootstrap fix(control-ui): preferences load late on signed-in chat reloads Oct 13, 2026
@steipete
steipete force-pushed the steipete/coldload-bootstrap-ui-prefs branch 3 times, most recently from afd9bc8 to c20c559 Compare October 13, 2026 06:26

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c20c5598a6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread ui/src/app/bootstrap.ts
if (snapshot.phase !== "connected" || !snapshot.client || !firstPreferencesConnection) {
return;
}
firstPreferencesConnection = false;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Wait for profile resolution before consuming the seed

When the hello snapshot lacks a self-presence row, gateway-store.ts first publishes phase: "connected" with selfUser === undefined and resolves the profile asynchronously through users.self. This line permanently consumes the one-shot on that provisional snapshot, so the later matching profile cannot seed userPreferenceReads; the bootstrap config is also rejected while identity is unresolved, causing this normal authenticated flow to issue the late config.get and users.prefs.get requests the change is intended to remove. Consume the latch only after selfUser is resolved and the profile match can be decided.

AGENTS.md reference: ui/AGENTS.md:L12-L13

Useful? React with 👍 / 👎.

return (
revision || JSON.stringify(asRecord(asRecord(snapshot?.runtimeConfig)?.mcp)?.servers ?? null)
revision ||
JSON.stringify(asRecord(asRecord(snapshot?.runtimeConfig ?? bootstrap)?.mcp)?.servers ?? null)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Key the effective-tools cache on an authoritative revision

On the new bootstrap-only path there is no snapshot revision, so this fallback hashes only the lossy MCP display projection. For example, changing a server's toolFilter from one nonempty filter to another leaves its projected value as true, while the Gateway's tools.effective result changes; after config.changed refreshes the projection, the identical key keeps the old tool list and notices until the session or connection changes. Carry an opaque config revision in the bootstrap payload or explicitly invalidate this cache on config changes.

AGENTS.md reference: ui/AGENTS.md:L12-L13

Useful? React with 👍 / 👎.

Comment on lines +72 to +76
return {
...(profileId ? { profileId } : {}),
...(display ? { config: display } : {}),
...(preferences ? { entries: preferences.entries } : {}),
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Omit empty preference projections without read authority

For an authenticated viewer with neither config.get scope nor a durable profile, such as an approvals-only operator, this always returns {}. The bootstrap treats that truthy object as an authoritative snapshot and calls applyServerUiPrefs({}); if this browser previously confirmed shared preferences for the same Gateway scope, their absence is interpreted as removal and resets them to product defaults even though the current viewer was merely unauthorized to read them. Return undefined when no config, profile identity, or preference entries were admitted.

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

@steipete
steipete force-pushed the steipete/coldload-bootstrap-ui-prefs branch from c20c559 to 47346e6 Compare October 13, 2026 07:15

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 47346e6689

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if (
runtimeConfig &&
!runtimeConfig.state.configFormDirty &&
(runtimeConfig.state.configSnapshot || !runtimeConfig.state.bootstrapConfig)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Fall back when the bootstrap refresh fails

When config.changed arrives while the client has only the bootstrap projection, this condition suppresses runtimeConfig.refresh() solely because the old projection is present. If the concurrent config.refresh() HTTP request fails or returns no admissible payload, loadApplicationConfig returns null without publishing and the old projection remains, so queue mode, shared UI preferences, and MCP display state stay stale until another event or reload. Await that refresh and fall back to the background config.get when it cannot publish a replacement.

AGENTS.md reference: ui/AGENTS.md:L12-L12

Useful? React with 👍 / 👎.

@steipete
steipete merged commit 79422aa into main Oct 13, 2026
134 of 142 checks passed
@steipete
steipete deleted the steipete/coldload-bootstrap-ui-prefs branch October 13, 2026 10:21
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 14, 2026
…nt (openclaw#170649)

A chat/dashboard reload no longer calls config.get (161 KB on Team) or users.prefs.get at boot: the authenticated bootstrap document carries a viewer-scoped preferences projection under the same config.get scope ceiling and redactConfigObject/uiHints redaction, plus the viewer's appearance and rail preferences. The config JSON-schema response cache moves to one owner shared by the document and config.get. Boot RPCs 86 -> 84.

Admin-merged over inherited failures: full UI suite 761 files, 3,374 passed, 6 failures all reproducing on the pinned base; every failing CI check reproduced on base (evidence in the PR body).
steipete added a commit that referenced this pull request Oct 16, 2026
The bootstrap preference fixture added in #170649 selects German through
the real i18n owner but did not restore its locale or document attributes.
The shared UI worker retained document.documentElement.lang=de, so a later
Workboard clock test rendered "gerade eben" instead of "just now".

Capture the incoming i18n state before fixture setup and restore it with
onTestFinished after runtime cleanup. Reuse the existing locale, storage,
and document-attribute restoration helper. Keep all bootstrap identity,
preference, clock-boundary, focus, and visibility assertions unchanged.
No production behavior changes.

Current-main proof: Workboard alone passes 2/2; bootstrap followed by
Workboard reproduces both hourly failures. The fix passes all four cases
with producer-first order explicitly pinned through the native UI runner.
The existing restoration helper's absent, empty, and explicit state cases
also pass. No CI dispatch, rerun, timeout change, retry, or weaker assertion.
Targeted UI-app test typecheck, file lint/format, whitespace checks, and
independent P2 review pass.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 17, 2026
…aw#174065)

The bootstrap preference fixture added in openclaw#170649 selects German through
the real i18n owner but did not restore its locale or document attributes.
The shared UI worker retained document.documentElement.lang=de, so a later
Workboard clock test rendered "gerade eben" instead of "just now".

Capture the incoming i18n state before fixture setup and restore it with
onTestFinished after runtime cleanup. Reuse the existing locale, storage,
and document-attribute restoration helper. Keep all bootstrap identity,
preference, clock-boundary, focus, and visibility assertions unchanged.
No production behavior changes.

Current-main proof: Workboard alone passes 2/2; bootstrap followed by
Workboard reproduces both hourly failures. The fix passes all four cases
with producer-first order explicitly pinned through the native UI runner.
The existing restoration helper's absent, empty, and explicit state cases
also pass. No CI dispatch, rerun, timeout change, retry, or weaker assertion.
Targeted UI-app test typecheck, file lint/format, whitespace checks, and
independent P2 review pass.
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 gateway Gateway runtime size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant