Skip to content

fix: offer sign-in when a proxy refuses an open Control UI tab's reconnect - #201729

Merged
freeqaz merged 1 commit into
mainfrom
fix/control-ui-refused-reconnect-recovery
Nov 19, 2026
Merged

freeqaz merged 1 commit into
mainfrom
fix/control-ui-refused-reconnect-recovery

Conversation

@freeqaz

@freeqaz freeqaz commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Some deployments put a sign-in proxy or an access policy in front of the Gateway that answers 401 or 403 once 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:

  • The reachability probe that runs after a failed WebSocket upgrade now tells three answers apart: live, access denied (401/403) and unavailable. "Access denied" asks the recovery to run its usual check. Liveness probes still count only "live" as reachable.
  • The recovery check used to treat only a redirect as a sign-in page. It now also accepts a 401/403 on its probe when /healthz is refused as well. The Gateway answers /healthz before any authentication, so a refusal there can only come from something in front of it; a 401 from the Gateway's own token check (with /healthz still 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 with 401 this way.

Not covered: a proxy that exempts /healthz from 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 401 to /healthz and 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 401 and 403 as access denied and hands them to the recovery (404, 503, offline and unrelated servers stay unavailable and are not handed over); a liveness probe answered 401 does 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 the 401 and 403 rows 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.ts and ui/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.

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.
@clawsweeper

clawsweeper Bot commented Nov 19, 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.

@freeqaz

freeqaz commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

Screenshots from the new e2e case (mock Gateway, 1280x900, light theme). The sign-in proxy answers 401 on /healthz and the bootstrap config once the session expires, and the reconnect fails with 1006 and no reason.

Before (main): the tab only says "Reconnecting"; nothing offers sign-in.

before-1-refused-reconnect

After: the existing sign-in dialog opens; the draft stays in the composer behind it.

after-1-refused-reconnect

After signing in and "Check again": connected again, draft still there.

after-2-after-sign-in

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 19, 2026
@freeqaz

freeqaz commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 19, 2026
@clawsweeper

clawsweeper Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This 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.

  • Before: The tab keeps showing Reconnecting without offering sign-in.
  • After: The sign-in dialog appears, and the draft remains available after access is restored.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The implementation is focused and has useful regression coverage, but supplied mocked evidence does not satisfy the real-behavior proof gate.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An open tab can reconnect indefinitely after proxy access expires without explaining how to sign in while preserving the draft.
Reason: Provides a useful recovery action through an established product flow; proxies exempting health checks and redirect-based reconnect detection are explicitly outside the stated repair.

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
Reviewed head: 5868a58659d1425a28f819ab8766d493761d19ab

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Supply a redacted recording or network/log trace of the built UI using a real Gateway through a proxy that refuses reconnect, health, and bootstrap requests, then restores access with the draft preserved and sendable.
Agent review details

How this fits together

The 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]
Loading

Technical review

Best 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

  • Failed-upgrade reachability classification keeps the original intent (1793896: Distinguish reachable but busy Gateways from network failures after browsers hide rejected-upgrade HTTP status.)
  • Browser sign-in recovery keeps the original intent (e074991: One document-owned flow verifies expired website access and preserves the conversation and draft.)
  • Automatic session renewal keeps the original intent (7fcde4b: Try bounded cookie-based renewal before prompting for redirect-based expiry, and verify renewal with an authenticated probe.)
  • HTTP-failure notification ownership keeps the original intent (da60d41: Replace a single-consumer listener registry with a lifetime-bound callback.)
  • Page-activation liveness consumer keeps the original intent (00096a1: Recover lost transports promptly using actual liveness evidence without defeating connection backoff.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit e074991 adds ui/src/app/browser-auth-recovery.ts:15 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e074991f0344; files: ui/src/app/browser-auth-recovery.ts)
  • Josh Lehman: Raw commit ff4a6c7 adds ui/src/app/browser-auth-recovery.tsx:56 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: ff4a6c70d6b4; files: ui/src/app/browser-auth-recovery.tsx)
  • Daniel: Raw commit 8734317 adds ui/src/app/gateway-page-activation.ts:169 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 8734317e1671; files: ui/src/app/gateway-page-activation.ts)

PR surface

Source +23, Tests +69. Total +92 across 8 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 5 41 18 +23
Tests 3 70 1 +69
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 111 19 +92

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add P2: Restores actionable recovery for an established Control UI tab behind proxies returning 401/403, with a deployment-specific blast radius.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: Restores actionable recovery for an established Control UI tab behind proxies returning 401/403, with a deployment-specific blast radius.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 19, 2026, 4:01 AM ET / 09:01 UTC.

@freeqaz
freeqaz merged commit 3bca9ef into main Nov 19, 2026
100 of 101 checks passed
@freeqaz
freeqaz deleted the fix/control-ui-refused-reconnect-recovery branch November 19, 2026 09:05
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 20, 2026
…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.
tideclaw-bot pushed a commit that referenced this pull request Nov 23, 2026
…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)
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 P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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