Repository navigation
fix: offer sign-in when a proxy refuses an open Control UI tab's reconnect - #201729
Conversation
A sign-in proxy or access policy that answers 401/403 instead of redirecting left an open Control UI tab reconnecting forever. The failed-upgrade reachability probe now tells access-denied apart from unavailable and hands a refusal to the existing browser sign-in recovery. The recovery accepts a 401/403 on its own probe as a sign-in page when /healthz, which the Gateway answers before any auth, is refused too.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Screenshots from the new e2e case (mock Gateway, 1280x900, light theme). The sign-in proxy answers Before (main): the tab only says "Reconnecting"; nothing offers sign-in. After: the existing sign-in dialog opens; the draft stays in the composer behind it. After signing in and "Check again": connected again, draft still there. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Codex review: needs maintainer review before merge. What this changesThis PR offers the existing sign-in dialog when a proxy refuses both reconnect-related health checks and the Control UI bootstrap request. Example: An established tab has an unsent draft when its proxy session expires and HTTP requests return 401.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR addresses a concrete reconnect recovery gap still present on current main; no actionable code defect was found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe browser transport classifies failed WebSocket upgrades, then passes proxy-refusal evidence to the document-owned HTTP authentication recovery flow, which verifies access and presents the existing dialog. flowchart TD
A[Failed WebSocket upgrade] --> B[Same origin health probe]
B --> C[Reachability classification]
C --> D[Browser authentication recovery]
D --> E[Authenticated bootstrap probe]
E --> F[Existing sign in dialog]
F --> G[Access restored and reconnect]
Technical reviewBest possible solution: Keep proxy-refusal classification in the existing reachability owner and sign-in decisions in the existing browser recovery owner. Do we have a high-confidence way to reproduce the issue? Current-main source collapses refused health responses into unavailable and never notifies sign-in recovery; the supplied mocked browser regression reportedly fails on main and passes with the patch, but this review ran no target code. Is this the best way to solve the issue? The patch is a focused repair: it extends the existing probe result, updates both consumers, and reuses the existing recovery flow without adding settings, persisted state, or a competing dialog. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 072117b196ae. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +23, Tests +69. Total +92 across 8 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 19, 2026, 4:01 AM ET / 09:01 UTC. |
…nclaw#201729) A sign-in proxy or access policy that answers 401/403 instead of redirecting left an open Control UI tab reconnecting forever. The failed-upgrade reachability probe now tells access-denied apart from unavailable and hands a refusal to the existing browser sign-in recovery. The recovery accepts a 401/403 on its own probe as a sign-in page when /healthz, which the Gateway answers before any auth, is refused too.
…1729) A sign-in proxy or access policy that answers 401/403 instead of redirecting left an open Control UI tab reconnecting forever. The failed-upgrade reachability probe now tells access-denied apart from unavailable and hands a refusal to the existing browser sign-in recovery. The recovery accepts a 401/403 on its own probe as a sign-in page when /healthz, which the Gateway answers before any auth, is refused too. (cherry picked from commit 3bca9ef) Companion audit: Companion closure: follows picked 944e502; pinned audit found no later path or PR fixes. Three-state same-origin health probe offers proxy sign-in only on explicit denial; preserves drafts and reconnect generation. Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit a6bc6df6fae69bc19b1a30cb38c98d77dcc022ca) (cherry picked from commit d4a7ac83176678eee4fd5e4ed2c1911888e4fb4c)



What Problem This Solves
Some deployments put a sign-in proxy or an access policy in front of the Gateway that answers
401or403once the browser session has expired, instead of redirecting to a sign-in page. An open Control UI tab then loses its WebSocket, every reconnect is refused, and the tab keeps showing "Reconnecting" forever. Nothing tells you to sign in again, and reloading the tab to find out would throw away an unsent draft.User Impact
User impact: an open tab whose reconnect is refused by a sign-in proxy or access policy now shows the same "Sign in to continue loading content" dialog the tab already shows when images or files are refused. The conversation and the unsent draft stay in place; after signing in (in a new tab) and choosing Check again, the tab reconnects and the draft can be sent.
An unreachable Gateway, a proxy that refuses only the WebSocket, and the Gateway's own credential errors behave as before.
Why This Change Was Made
The browser sign-in recovery already owns this decision for HTTP requests; the WebSocket path never reached it. Two small changes route the refused reconnect into it instead of adding a second notice:
401/403) and unavailable. "Access denied" asks the recovery to run its usual check. Liveness probes still count only "live" as reachable.401/403on its probe when/healthzis refused as well. The Gateway answers/healthzbefore any authentication, so a refusal there can only come from something in front of it; a401from the Gateway's own token check (with/healthzstill live) keeps today's result and never opens the dialog. Because the dialog needs the Control UI's own HTTP request refused too, a proxy that refuses only the WebSocket still leaves the tab as it is today. The same check also covers images and files refused with401this way.Not covered: a proxy that exempts
/healthzfrom sign-in is not detected (the tab keeps reconnecting as today). A proxy that redirects the reconnect probe is unchanged by this PR.Evidence
Screenshots (synthetic mock Gateway, bundled Control UI, 1280x900, light theme) will be added below by a maintainer:
Before: after the refused reconnect the tab shows only the "Reconnecting" badge (top of the chat and in the sidebar footer), the draft sits in the composer, and nothing offers sign-in.
After: the existing "Sign in to continue loading content" dialog with Not now and Sign in over the dimmed conversation; the draft is still in the composer behind it.
After sign-in and Check again: the dialog is gone, the badges are gone (connected), and the draft is still in the composer, ready to send.
Behavior checked with a new Control UI end-to-end case next to the existing sign-in recovery cases: an established tab with an unsent draft loses its connection, the proxy starts answering
401to/healthzand the bootstrap probe, and the next reconnect is refused. Before this change the tab stays on "Reconnecting" and the test times out waiting for the dialog. After: the sign-in dialog appears, the draft is unchanged, Sign in opens the Gateway root in a new tab, Check again closes the dialog, the tab reconnects and sends the draft.Unit tests: the failed-upgrade probe classifies
401and403as access denied and hands them to the recovery (404,503, offline and unrelated servers stay unavailable and are not handed over); a liveness probe answered401does not trigger a reconnect (a guard: main already passes it).Checks
pnpm test ui/src/api/gateway-reachability.node.test.ts --maxWorkers=1: 12/12 pass; on main's sources the401and403rows fail.pnpm test ui/src/app/gateway-page-activation.test.ts --maxWorkers=1: 37/37 pass (the new case also passes on main: it guards the liveness rule).pnpm test:ui:e2e ui/src/e2e/browser-auth-recovery.e2e.test.ts --maxWorkers=1: 5/5 pass, the new case in about 4.5 s; on main's sources the new case times out waiting for the dialog and the four existing cases pass.ui/src/e2e/route-asset-requests.e2e.test.tsandui/src/e2e/boot-module-boundaries.e2e.test.ts: pass (no new lazily loaded asset; the touched modules were already in the boot graph).pnpm tsgo:ui,pnpm tsgo:test:ui, oxlint and oxfmt on the touched files: clean.Size: production +41/-18 in 5 files (no new strings, styles, settings or stored state); tests +70/-1 in 3 files.