Skip to content

fix(gateway): preserve chat metadata across UI prefs - #125636

Merged
steipete merged 1 commit into
mainfrom
steipete/infallible-raman-47f5c6
Aug 18, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/infallible-raman-47f5c6

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where a display-only synchronized UI preference update could make chat metadata reject the still-current published model owner. New-session model selection then became unavailable even though direct model and command reads remained healthy.

Why This Change Was Made

Chat metadata now reads the lifecycle-published prepared model owner without requiring full-config equality. The existing replacement gate still fences real model/config owner turnover, so readers continue to fail closed while a genuine replacement is publishing. UI-side suppression and globally weakening prepared config matching were rejected because both would move or broaden the fix beyond the lifecycle owner boundary.

User Impact

Model selection remains available after changing synchronized display preferences. No Gateway restart or provider reconfiguration is required.

Evidence

  • node scripts/run-vitest.mjs src/gateway/server-chat-metadata-lifecycle.integration.test.ts src/gateway/server-methods/chat-metadata-runtime.test.ts — 30/30 tests passed on the rebased head.
  • node scripts/check-changed.mjs -- src/gateway/server-chat-metadata-lifecycle.integration.test.ts src/gateway/server-methods/chat-metadata-runtime.ts completed formatting, typechecks, lint, dead-code, dependency, and schema checks before the 10-minute outer harness limit. Its remaining runtime-sidecar-loader, import-cycle, webhook-auth body-order, pairing-store group-auth, and pairing account-scope guards were rerun individually and passed.
  • .claude/skills/autoreview/scripts/autoreview --mode branch --base origin/main — clean; no accepted/actionable findings.
  • node --import tsx scripts/build-all.mts qaRuntime and pnpm ui:build passed. A broader local pnpm build attempt ended during declaration invocation 8/9 without a compiler diagnostic on a heavily loaded host; exact-head CI provides the authoritative full-build result.
  • Real isolated Gateway + Control UI proof: Proof Model Alpha was available before a real config.patch committed ui.prefs.chatShowThinking=false; after config.get, one config publication event, and a fresh chat metadata/startup read, the model remained available and Models unavailable never appeared. The isolated state and processes were removed afterward.
  • Production LOC: +7/-7 (net 0). Tests: +55/-4.
  • AI-assisted: yes.

Initial model availability:

Initial model available

Final model availability after the synchronized preference commit:

Final model available

interaction.webm

@clawsweeper

clawsweeper Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S maintainer Maintainer-authored PR labels Aug 18, 2026
@steipete
steipete marked this pull request as ready for review August 18, 2026 05:43
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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. labels Aug 18, 2026
@clawsweeper

clawsweeper Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 18, 2026, 1:50 AM ET / 05:50 UTC.

ClawSweeper review

What this changes

The PR changes Gateway chat metadata to retain the lifecycle-published model owner when only synchronized UI display preferences change.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

No blocking findings. Current main still requires exact config equality for chat metadata’s owner lookup, so this maintainer-authored PR remains necessary to preserve model selection across display-only UI preference updates.

Priority: P1
Reviewed head: 3d1f3a0ee640e1f54b7710679f2c88e7e41e1676

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is narrow, source-aligned, and covered by a focused lifecycle regression test; exact-head CI remains in progress.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR includes claimed isolated Gateway and Control UI proof; the external-contributor proof gate does not apply.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR includes claimed isolated Gateway and Control UI proof; the external-contributor proof gate does not apply.
Evidence reviewed 6 items Current-main failure mechanism: Current main passes the current config with readOnly=true to the exact-match accessor, so a display-only config difference can make the still-published owner unavailable.
Owner contract: The existing published-owner accessor intentionally returns the lifecycle owner without config matching or catalog materialization.
Replacement safety: A genuine config replacement synchronously creates a replacement gate; published snapshots return undefined until the new owner commits, then the publication event is emitted.
Findings None None.
Security None None.

How this fits together

Gateway chat startup metadata reads a lifecycle-published model catalog to provide selectable models to the Control UI. Config publications replace that catalog owner, while display preferences should not make an otherwise current owner disappear.

flowchart LR
  A[Control UI preference update] --> B[Gateway config state]
  B --> C[Published model owner]
  C --> D[Chat metadata lifecycle]
  D --> E[Control UI model selection]
Loading

Before merge

  • Complete next step (P2) - This maintainer-authored, protected PR should proceed through normal exact-head CI and maintainer review rather than a repair lane.
Agent review details

Security

None.

PR surface

Source 0, Tests +51. Total +51 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 7 7 0
Tests 1 55 4 +51
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 62 11 +51

Review metrics

Metric Value Why it matters
Production vs test LOC production +7/-7 (net 0); tests +55/-4 (net +51) The repair replaces the owner lookup without production growth and adds focused lifecycle regression coverage.

Stored data model

Persistent data-model change detected: unknown-data-model-change: src/gateway/server-chat-metadata-lifecycle.integration.test.ts, unknown-data-model-change: src/gateway/server-methods/chat-metadata-runtime.ts, vector/embedding metadata: src/gateway/server-chat-metadata-lifecycle.integration.test.ts, vector/embedding metadata: src/gateway/server-methods/chat-metadata-runtime.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Keep chat metadata on the published owner accessor and retain the existing replacement gate as the sole fence for real model or config turnover.

Do we have a high-confidence way to reproduce the issue?

Yes—source shows the exact-config lookup rejects the published owner after a UI-only config change, and the added integration scenario covers that state.

Is this the best way to solve the issue?

Yes—the published-owner accessor is the narrow lifecycle-owner fix, while existing publication invalidation still fences actual owner replacement.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against fc2529e22971.

Labels

Label justifications:

  • P1: A normal synchronized UI preference update can make new-session model selection unavailable.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR includes claimed isolated Gateway and Control UI proof; the external-contributor proof gate does not apply.

Evidence

What I checked:

Likely related people:

  • steipete: The current metadata runtime, prepared-catalog accessor, and publication-listener lines trace to the same recent lifecycle implementation. (role: current lifecycle implementation author; confidence: high; commits: 974a52f64f53; files: src/gateway/server-methods/chat-metadata-runtime.ts, src/agents/prepared-model-catalog.ts, src/gateway/server-chat-metadata-lifecycle.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Wait for the remaining exact-head checks before merge.

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.

@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof for 3d1f3a0ee640e1f54b7710679f2c88e7e41e1676.

Root cause: synchronized ui.prefs writes are planned as no-op config changes, so the Gateway process and its published prepared-model owner remain current. Chat metadata nevertheless used the strict full-config owner accessor. A display-only preference difference therefore hid that valid owner and made metadata unavailable while direct model and command reads remained healthy.

Architectural owner and canonical fix: the Gateway chat-metadata lifecycle now reads getPublishedPreparedModelCatalogOwnerSnapshot, matching the lifecycle-published ownership contract. The existing prepared-model replacement gate remains the sole fence for genuine model/config owner turnover and continues to fail closed. UI-side suppression and globally weakening prepared-config matching were rejected. Removed paths: none.

Local proof:

  • node scripts/run-vitest.mjs src/gateway/server-chat-metadata-lifecycle.integration.test.ts src/gateway/server-methods/chat-metadata-runtime.test.ts — 2 files, 30/30 tests passed on the rebased head.
  • git diff --check origin/main...HEAD — passed.
  • node scripts/check-changed.mjs -- src/gateway/server-chat-metadata-lifecycle.integration.test.ts src/gateway/server-methods/chat-metadata-runtime.ts completed formatting, typechecks, lint, dead-code, dependency, and schema checks before its 10-minute outer harness limit. The trailing runtime-sidecar-loader, import-cycle, webhook-auth body-order, pairing-store group-auth, and pairing account-scope guards were rerun individually and passed.
  • node --import tsx scripts/build-all.mts qaRuntime — passed.
  • pnpm ui:build — passed.
  • .claude/skills/autoreview/scripts/autoreview --mode branch --base origin/main --parallel-tests "node scripts/run-vitest.mjs src/gateway/server-chat-metadata-lifecycle.integration.test.ts src/gateway/server-methods/chat-metadata-runtime.test.ts" — clean, no accepted/actionable findings; the parallel focused tests passed 30/30.

Sibling coverage: the focused suites cover early and late prepared-owner publication, chat-metadata/models-list availability convergence, auth publication and revocation, startup projection, and lifecycle refresh behavior around the repaired owner boundary.

Observed behavior: in a real isolated Gateway + Control UI run, Proof Model Alpha was available before a real config.patch committed ui.prefs.chatShowThinking=false. After config.get, one config publication event, and a fresh chat metadata/startup read, the model remained available and Models unavailable never appeared. Sanitized initial/final screenshots and the 9.92-second recording are embedded in the PR body; isolated state and processes were removed.

LOC: production +7/-7 (net 0); tests +55/-4 (net +51).

Exact-head CI: node scripts/watch-pr-ci.mjs 125636 3d1f3a0ee640e1f54b7710679f2c88e7e41e1676 completed GREEN with zero pending checks. Relevant ready-event runs completed successfully: CI 32103975747, CodeQL 32103975684, CodeQL Critical Quality 32103975677, OpenGrep 32103975679, Dependency Guard 32103975836, Security Sensitive Guard 32103975881, and PR context/evidence 32103975862.

Latest ClawSweeper review: no findings. Its only optional rank-up move was to wait for the remaining exact-head checks; satisfied by the green runs above.

Known proof gap: one broad local pnpm build attempt ended during declaration invocation 8/9 without a compiler diagnostic on a heavily loaded host. Exact-head CI's successful build-artifacts check in run 32103975747 is the authoritative full-build proof.

@steipete
steipete merged commit 1c3e512 into main Aug 18, 2026
283 checks passed
@steipete
steipete deleted the steipete/infallible-raman-47f5c6 branch August 18, 2026 06:00
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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