Skip to content

fix(control-ui): restore operator chat deep links - #166783

Merged
steipete merged 2 commits into
mainfrom
codex/stab-chat-deeplink-reload
Oct 7, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/stab-chat-deeplink-reload

Conversation

@steipete

@steipete steipete commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Since #166049 routed every /chat/... document through the anonymous public reader, a logged-in operator using token or password auth can no longer reload a chat. Reloading, opening the same link in a new tab, or following a bookmark returns HTTP 404 with "Conversation unavailable. This conversation is not publicly available. Log in…", and the operator has to click Log in to get the app back. In-app navigation still works, which hides the regression until the first reload.

Reproduced on main 9aa7455 (dev Gateway, gateway.auth.mode=token, loopback HTTP, headless Chromium): after /#token=… login, GET /chat/main/<slug> is served by the reader, and the reader's handoff probe GET /__openclaw__/session-entry?path=…&probe=1 returns 401. The browser holds its credential in local/session storage (openclaw.device.auth.v1:<scope> / openclaw.control.token.v1:<scope>), so an HTTP request can never prove it, and the reader never forwards.

User Impact

  • Token/password operators reload, deep-link, and open chat links in new tabs straight back into the Control UI conversation, with no extra click.
  • On non-secure ingress, where anonymous publication is impossible, token/password chat links serve the Control UI shell directly, as before feat: open public threads at their regular links #166049.
  • Anonymous visitors are unchanged. Public threads still render read-only; private, missing, and revoked threads still show the same generic page; the reader still opens no WebSocket or RPC.
  • Documented ?draft= and ?dashboard=expanded parameters survive the handoff instead of 404ing.

Why This Change Was Made

The reader's only forward path was the HTTP probe. That is correct for trusted-proxy/external-login deployments, where the browser carries cookies, but token/password credentials live in the browser. After a 401, and only in token/password mode, the reader now checks whether this browser already holds a Control UI credential for this Gateway scope, and if so it navigates to the existing session-entry link. The credential is never read into a request or transmitted. session-entry already serves the app shell to unauthenticated token/password requests by design, and the shell grants no data; bootstrap and WebSocket auth keep all authority. A stale credential therefore lands on the normal login gate. Because the forward does not depend on whether the thread exists, there is no existence oracle.

The storage-key prefixes the reader needs now have one owner (src/shared/control-ui-storage.ts), which the UI settings and device-auth stores import instead of duplicating literals. The script's CSP hash is still derived from the exact script bytes. serveApp moved up one level in control-ui-session-routes.ts so the public chat route and session-entry share the same app-shell owner. The remaining initial 404 on secure ingress is intentional: removing it would need server-visible authentication state, which token mode does not have.

Evidence

Live on original reviewed head a6884e2ca7d2d8091f63dc7426a03e561a6f5d37 (dev Gateway built from that head, fresh state, real OpenAI provider, headless Chromium):

main 9aa74552   reload /chat/main/<slug> -> 404 "Conversation unavailable" (stays); new tab -> same
this head       reload -> app renders the conversation; new tab -> app renders the conversation
this head       anonymous browser, same URL -> 404 generic reader page (unchanged)

Tests (TMPDIR isolated):

gateway public-reader / session-entry / index siblings      153 passed, 13 files, 55.4 s
real HTTP + auth + SQLite sessions + built UI (e2e)         7 passed, 314.1 s
UI settings / credentials / routing / login                 290 passed, 12 files, 19.6 s
Chromium login and shell routing                            26 passed, 2 files, 39.3 s
negative control (production files restored to base)        unit: 13 expected failures; real HTTP: token and password cases fail

Focused: control-ui-public-chat.http.test.ts 10.8 s, control-ui-public-session-entry.test.ts 3.1 s, control-ui-session-entry.test.ts 7.6 s (--maxWorkers=1). Core/UI types, scoped lint, format, docs links, and the import-cycle check (0) pass. Autoreview was clean through P2.

Production +85/-39, tests +303/-21, docs +24 (docs/web/urls.md, docs/web/control-ui/security-model.md).

Maintainer correction and compatibility proof

Independent review found that paired-device storage scopes retain a Gateway URL query string. The reader now recognizes existing device records for the same scheme, host, and mount with an optional query suffix; this remains only a navigation hint. It does not send credentials, write storage, or change authentication. The new positive regression fails on the original head; a neighboring-mount query case continues to stay on the reader.

After the correction, reader-script / public-chat HTTP / session-entry tests pass: 46 tests in 3 files (45.09 s Vitest, 48.12 s wrapper). Isolated pnpm test src/gateway/control-ui-public-session-entry.test.ts --maxWorkers=1: 18 passed, 3.07 s Vitest, 4.58 s wrapper. The native changed checks pass, including core and test types, scoped lint/format, schema guards, and zero runtime import cycles. Full-candidate independent review accepted the corrected working tree; its index-only observation was resolved by staging that exact candidate. The earlier full CI success is run 37697630628, attempt 1, for the original head; the correction requires its own exact-head CI. The original live Gateway proof above is reused for unchanged routing; the query-scope correction has direct reader-script boundary proof.

The storage key bytes, version-1 record format, writers, scope normalizers, and legacy migration remain unchanged. The reader adds only read-only presence checks. The completed ClawSweeper review itself confirms no stored-data contract changes; the detailed compatibility response is here. No migration is needed.

Route token/password operators through the existing app authentication gate when reopening chat links. Preserve anonymous public-reader isolation, HTTP identity denials, mounted gateway credential scopes, dashboard presentation, and composer drafts. Fixes the document-routing regression introduced by #166049.
@clawsweeper

clawsweeper Bot commented Oct 7, 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 gateway Gateway runtime size: M labels Oct 7, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 Oct 7, 2026
@clawsweeper

clawsweeper Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

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

ClawSweeper review

What this changes

Restore authenticated operators’ chat reloads and deep links through the existing login gate, preserve draft and dashboard parameters, and share browser credential-storage key constants.

Regression provenance

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

Merge readiness

✅ Ready for maintainer review

This PR remains necessary: current main still strands token/password operators on the public reader. The query-scope correction is sound, the prior compatibility blocker is resolved, and no blocking patch defect remains.

Priority: P1
Reviewed head: becfdc11504b4ce490c663c8750402986b527a10

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, well-supported repair with preserved authentication boundaries and no remaining actionable findings.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The captured real Gateway/Chromium trace demonstrates repaired reloads and new tabs with anonymous behavior preserved on the original head. The current query-scope change is limited to navigation detection and has direct rendered-script positive/negative coverage; existing live routing proof remains applicable. Storage bytes, formats, writers, and migrations are unchanged, clearing the prior compatibility blocker.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The captured real Gateway/Chromium trace demonstrates repaired reloads and new tabs with anonymous behavior preserved on the original head. The current query-scope change is limited to navigation detection and has direct rendered-script positive/negative coverage; existing live routing proof remains applicable. Storage bytes, formats, writers, and migrations are unchanged, clearing the prior compatibility blocker.
Evidence reviewed 8 items Pinned introduction: Reviewed the merge-base-to-head introduced changes, keeping base drift separate from PR ownership. The supplied test merge is stale and was not used to claim removal of current-main behavior.
Still necessary on current main: Pinned current-main source still forwards only after a 204 probe and lacks browser-credential handoff. Its public-chat handler also still rejects draft parameters and returns the unavailable reader on non-secure ingress. The supplied latest release v2026.9.8 points to a commit dated before the October 6 public-reader change; no merged replacement fix is established.
Query-scoped navigation correction: The new reader scan accepts the exact credential scope or that scope followed by '?', preserving scheme, host, and mount isolation. Positive query-scope and neighboring-mount negative regressions exercise the rendered production script. GitHub's comparison confirms that these two files are the complete correction since the earlier reviewed head.
Findings None None.
Security None None.

How this fits together

The Gateway serves chat links as either anonymous public-reader documents or the Control UI application. Browser-held credentials guide operators back into the application, where existing bootstrap and WebSocket authentication control session access.

flowchart TD
 A[Chat link or reload] --> B[Gateway document routing]
 B --> C[Anonymous public reader]
 B --> D[Application shell]
 C --> E[Protected probe and browser credential hint]
 E --> D
 D --> F[Existing authentication and session access]
 F --> G[Operator conversation]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +46, Tests +282, Docs +24. Total +352 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 7 85 39 +46
Tests 4 303 21 +282
Docs 2 24 0 +24
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 13 412 60 +352

Review metrics

Metric Value Why it matters
Production and regression coverage production +85/-39; tests +303/-21 Production growth has a stated purpose: browser navigation recovery and shared storage keys, with regressions at script, HTTP, and real-auth boundaries.

Stored data model

Persistent data-model change detected: serialized state: src/gateway/control-ui-public-session-render.ts, unknown-data-model-change: src/gateway/control-ui-public-session-render.ts. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Technical review

Best possible solution:

Keep one application-shell owner and restore operator navigation while preserving anonymous publication checks and existing session authentication.

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

Yes: current-main source shows a token/password browser's unauthenticated HTTP probe returning 401 while the reader only forwards on 204; the captured real-browser before/after trace matches that mechanism. This review did not execute the flow.

Is this the best way to solve the issue?

Yes: the patch reuses the existing application login gate, treats stored credentials only as navigation hints, and preserves authentication and publication ownership.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against eb7a4b157452.

Labels

Label changes:

No label changes.

Label justifications:

  • P1: Current-main document routing breaks operators’ existing chat reload, bookmark, and new-tab workflow.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The captured real Gateway/Chromium trace demonstrates repaired reloads and new tabs with anonymous behavior preserved on the original head. The current query-scope change is limited to navigation detection and has direct rendered-script positive/negative coverage; existing live routing proof remains applicable. Storage bytes, formats, writers, and migrations are unchanged, clearing the prior compatibility blocker.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured real Gateway/Chromium trace demonstrates repaired reloads and new tabs with anonymous behavior preserved on the original head. The current query-scope change is limited to navigation detection and has direct rendered-script positive/negative coverage; existing live routing proof remains applicable. Storage bytes, formats, writers, and migrations are unchanged, clearing the prior compatibility blocker.

Evidence

What I checked:

  • Pinned introduction: Reviewed the merge-base-to-head introduced changes, keeping base drift separate from PR ownership. The supplied test merge is stale and was not used to claim removal of current-main behavior. (becfdc11504b)
  • Still necessary on current main: Pinned current-main source still forwards only after a 204 probe and lacks browser-credential handoff. Its public-chat handler also still rejects draft parameters and returns the unavailable reader on non-secure ingress. The supplied latest release v2026.9.8 points to a commit dated before the October 6 public-reader change; no merged replacement fix is established. (src/gateway/control-ui-public-session-render.ts:20, eb7a4b157452)
  • Query-scoped navigation correction: The new reader scan accepts the exact credential scope or that scope followed by '?', preserving scheme, host, and mount isolation. Positive query-scope and neighboring-mount negative regressions exercise the rendered production script. GitHub's comparison confirms that these two files are the complete correction since the earlier reviewed head. (src/gateway/control-ui-public-session-render.ts:29, becfdc11504b)
  • Authentication boundary preserved: Credential presence affects navigation only: the reader sends no stored credential, makes no storage writes, and does not override a 403 probe. The existing session-entry owner retains session authorization and passes live-authority checks through document preparation to final delivery. Non-secure token/password routing serves only the application shell. (src/gateway/control-ui-session-entry.ts:57, becfdc11504b)
  • Existing-state compatibility clears prior blocker: Verified identical token and device-auth key bytes, unchanged scope normalizers, version-1 parsers, writers, and legacy migration. Only constants move and read-only navigation checks are added; no stored-data contract changes or migration are required. This independently supports the compatibility response at fix(control-ui): restore operator chat deep links #166783 (comment). (src/shared/control-ui-storage.ts:1, becfdc11504b)
  • Behavior proof and accepted limitation: The captured PR body, source identity cbd5eecfd877a644bb2952cfd0df01012fd388e249222a8f82e11bf5bb4d39e4, records a real dev Gateway, fresh state, real provider, and Chromium: reload/new-tab failures before the repair become rendered conversations afterward, while an anonymous browser retains the generic reader. This proof belongs to a6884e2; the current correction has rendered-script boundary proof and reported negative control. The maintainer-authored body explicitly accepts the initial secure-ingress 404 before browser handoff. Prepared screenshots were inspected but depict the related public-reader feature, not this repair. (a6884e2ca7d2)

Likely related people:

  • steipete: 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 (1 earlier review cycle)
  • reviewed 2026-10-07T22:44:39.622Z sha a6884e2 :: blocked before merge. :: none

@steipete

steipete commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

The requested existing-state compatibility proof for reviewed head a6884e2ca7d2d8091f63dc7426a03e561a6f5d37 is covered by the unchanged storage contract:

  • ui/src/app/settings.ts only replaces the local token-key prefix with the shared constant. The prefix bytes remain openclaw.control.token.v1:; the scope normalizer, token reader/writer, and legacy-key cleanup are unchanged.
  • ui/src/lib/nodes/index.ts only imports the same two device-auth key constants. The legacy key remains openclaw.device.auth.v1, the scoped prefix remains openclaw.device.auth.v1:, and the version-1 record parser, writer, and existing legacy-to-scoped migration are unchanged.
  • control-ui-public-session-render.ts adds read-only presence checks against those existing keys. It performs no storage write or migration and sends no stored credential. The added reader tests seed the existing version-1 device record and scoped session-token format, including root/mounted gateways, mismatched scopes, malformed records, blocked storage, and denied probes. The PR body records the passing UI credential/settings suites and real browser reload/new-tab proof.

The review's own “Existing-state compatibility” evidence reaches the same conclusion: “No stored-data contract changes.” The serialized-state classifier therefore does not identify a data-model change requiring a migration. No schema, persistence format, or upgrade behavior is added by this patch; no migration change is needed.

Preserve existing Gateway query-scoped paired-device credentials as a navigation-only hint. Keep other mounts and schemes isolated, and leave all authentication and storage writers unchanged.
@steipete

steipete commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Please review the current head becfdc11504b4ce490c663c8750402986b527a10. It includes the small query-scoped paired-device navigation correction found during independent review. The regression fails before the correction; all 46 focused reader/HTTP/session-entry tests and native changed checks pass afterward. The PR body now separates the original live proof from the correction's boundary proof and includes the unchanged-storage compatibility evidence requested in the completed review.

@clawsweeper

clawsweeper Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@steipete
steipete merged commit a1ca0cd into main Oct 7, 2026
120 checks passed
@steipete
steipete deleted the codex/stab-chat-deeplink-reload branch October 7, 2026 23:51
@steipete

steipete commented Oct 7, 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 8, 2026
* fix(control-ui): restore operator chat deep links

Route token/password operators through the existing app authentication gate when reopening chat links. Preserve anonymous public-reader isolation, HTTP identity denials, mounted gateway credential scopes, dashboard presentation, and composer drafts. Fixes the document-routing regression introduced by openclaw#166049.

* fix(control-ui): recognize query-scoped device handoffs

Preserve existing Gateway query-scoped paired-device credentials as a navigation-only hint. Keep other mounts and schemes isolated, and leave all authentication and storage writers unchanged.
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 P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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