Repository navigation
fix(control-ui): preferences load late on signed-in chat reloads - #170649
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 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() | |||
There was a problem hiding this comment.
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 👍 / 👎.
afd9bc8 to
c20c559
Compare
There was a problem hiding this comment.
💡 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".
| if (snapshot.phase !== "connected" || !snapshot.client || !firstPreferencesConnection) { | ||
| return; | ||
| } | ||
| firstPreferencesConnection = false; |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 👍 / 👎.
| return { | ||
| ...(profileId ? { profileId } : {}), | ||
| ...(display ? { config: display } : {}), | ||
| ...(preferences ? { entries: preferences.entries } : {}), | ||
| }; |
There was a problem hiding this comment.
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 👍 / 👎.
c20c559 to
47346e6
Compare
There was a problem hiding this comment.
💡 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) |
There was a problem hiding this comment.
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 👍 / 👎.
…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).
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.
…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.
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.getresponse, plus a separateusers.prefs.getround 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
4f8c8c58fc88and 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.config.getrequestsusers.prefs.getrequestsThe reviewed patch rebased unchanged onto main at
c1f504ab456d9e1bed594109ea7d4744be5308c0; final head is47346e66892c35c2a2248afbe2d715f8200ae5db. 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
users.prefs.changedinvalidates the document-seeded cache and adopts a changed profile theme. Passed; 29.36 s including the bundle build, test body 2.00 s.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 ontoc1f504ab456d9e1bed594109ea7d4744be5308c0. The approved patch replayed unchanged; frozen-lockfile installation passed. No new source changes were needed during this validation follow-up.AWS Crabbox lease
cbx_d8b89677b8a6rannode scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.tson 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.chat-collapsed-reply-reveal.e2echat-header-subagents.e2echat-position-rail.e2e(dark and light)chat-reply-preview-recovery.e2econtrol-ui-stale-build-reload.e2ebrowser-auth-recovery.e2efailed 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-headmodel-api-keys.real-gateway.e2efailure 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 wasmodels.authRefresh→UNAVAILABLEbecause 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:
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.