Skip to content

fix(ui): recover expired sessions after reconnect - #149582

Merged
steipete merged 5 commits into
mainfrom
codex/qa-expired-session-reconnect
Sep 16, 2026
Merged

steipete merged 5 commits into
mainfrom
codex/qa-expired-session-reconnect

Conversation

@steipete

@steipete steipete commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an open incognito conversation turning into an empty, usable chat when a Gateway restart removes the session.

User Impact

The existing conversation now shows Session not found, with actions to open the main session or view sessions, after the Gateway confirms that it no longer exists. Ordinary disconnects preserve the conversation and unsent draft; omission from a filtered session list does not count as deletion. Home and explicit session-creation URLs keep their existing behavior.

Why This Change Was Made

The router already recovers interrupted session loads, but a successfully loaded route survived reconnect without checking whether its session still existed. Recovery now uses the existing exact-session resolver and rejects replies from a retired connection or navigation. Explicit revalidation keeps the established session key and its recorded connection/profile scope, skips retained resolution shortcuts, and treats interrupted discovery as retryable rather than absence.

Evidence

  • Live before: with a real OpenAI-backed incognito conversation on the isolated QA Gateway, a browser reload retained its transcript and incognito status. Restarting only that Gateway removed the session but left the existing pane blank with active composer/model controls and a publication error. A fresh page reload correctly showed Session not found.
  • Production-bundled browser regression through the observed short-link route: original source fails the missing-state assertion at both 1280×900 and 390×844; the candidate passes both. The surviving-session sibling also passes with its transcript and unsent draft retained despite an empty roster. These three cases use a synthetic mock Gateway.
  • 52 focused router, route-loader, and catalog-share tests pass. Seven added regressions fail on earlier implementations and pass here: short/slug reassignment, delayed startup, connection/profile replacement, and disconnect during exact-key revalidation. Existing coverage also protects creation routes, stale replies, and cached-row revalidation.
  • Production UI and all three affected UI test type graphs pass, along with targeted type-aware lint, stylelint, formatting, and diff checks.
  • Fresh independent review of the final source and protocol-correct test fixtures found no actionable P0–P2 findings.

Final real-profile after replay is pending: access to the QA Chrome tab was revoked, and restoration has been requested. Exact-head hosted CI passes; no real-profile live-after claim is made.

Desktop before:
Expired conversation before: empty chat and active composer

Desktop after:
Expired conversation after: Session not found and recovery actions

Mobile before and after

Before:
Mobile expired conversation before

After:
Mobile expired conversation after

CI follow-up

The first CI run found two undocumented type assertions at the router's erased-data boundary. Both now document their verified invariant: only the chat/dashboard loader produces these matched results. The exact assertion-safety ratchet, formatting, whitespace checks, and fresh independent review pass. This follow-up changes comments only; the runtime and browser evidence above remains applicable. The final integrated head passes hosted CI.

CI fixture correction

The reconnect verification exposed two progress-widget fixtures that supplied session-list responses without canonical session records. CI correctly navigated to Session not found before reaching either liveness assertion. The unchanged branch reproduces both failures in the original ten-case order; the pre-change baseline passes all ten. Declaring only the existing session keys through the mock Gateway’s canonical sessions input restores all ten passes, without supplying run state or changing product code, assertions, or timeouts. The UI E2E typecheck and fresh independent review pass. The earlier desktop SSH failure remains unexplained; the final integrated head passes its hosted real-Gateway lane.

First-connection resolution repair

The next CI run reproduced a redundant lookup on first connection: the pending startup route was classified as an interrupted established session, so it ran a second exact-session lookup after the loader had already resolved it. Recovery now distinguishes first connection from reconnect, and the loader carries a private cache-source fact so cached data that commits after the first hello is still verified. No second cache or resolution owner was added.

The original registered-router regression and unchanged real-Gateway performance test both fail before this correction. The corrected candidate passes 103 focused cases plus the unchanged real-Gateway performance case and all three reconnect browser cases; each measured desktop/narrow phase has exactly one connection and one resolution. All three affected UI type lanes, scoped typed lint, formatting, and fresh independent P2 review pass. Current head 0aee8999720e98ef8264540265af71878f4e8837 passed all 91 checks in CI 35050457882.

@clawsweeper

clawsweeper Bot commented Sep 16, 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.

@steipete
steipete marked this pull request as ready for review September 16, 2026 01:50
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui size: L maintainer Maintainer-authored PR labels Sep 16, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. 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 Sep 16, 2026
@clawsweeper

clawsweeper Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 15, 2026, 11:46 PM ET / September 16, 2026, 03:46 UTC (Revision 4).

ClawSweeper review

What this changes

The Control UI checks established conversation links after reconnect, shows recovery actions for confirmed missing sessions, and adds documentation and regression coverage.

Merge readiness

✅ Ready for maintainer review

This PR remains useful: current main recovers interrupted loads but does not verify already-open conversations after reconnect. The pinned patch has no actionable correctness findings, and the earlier merged recovery PR does not supersede it.

Priority: P2
Reviewed head: 0aee8999720e98ef8264540265af71878f4e8837

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with useful browser evidence, meaningful lifecycle regressions, and no identified blocking defect.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The supplied maintainer classification exempts this PR from the external-contributor live-proof gate. Inspected desktop/mobile captures and the registered browser scenario cover the router's missing-session presentation; the body explicitly leaves real-profile after-restart replay pending, so no live-after result is claimed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied maintainer classification exempts this PR from the external-contributor live-proof gate. Inspected desktop/mobile captures and the registered browser scenario cover the router's missing-session presentation; the body explicitly leaves real-profile after-restart replay pending, so no live-after result is claimed.
Evidence reviewed 9 items Pinned change ownership: Reviewed the merge-base-to-head changes, including the complete loader and route tests. Base-only daemon, catalog, and secrets changes are not introduced by this PR. The supplied stale test merge was not used to infer removals.
Current main still needs the repair: Current main records interrupted pending loads and clears recovery state for successful routes without checking session existence. The supplied merged #145347 explicitly preserves successful conversations and addresses a different reconnect case.
Latest release comparison: The v2026.9.4 router lacks the established-session recovery check. Its source was inspected through GitHub after the local historical blob could not be retrieved.
Findings None None.
Security None None.

How this fits together

The Control UI router turns conversation URLs and Gateway connection events into chat views. Gateway session resolution determines whether an established conversation remains available or should show recovery actions.

flowchart TD
  A[Open conversation link] --> B[Control UI router]
  C[Gateway reconnects] --> B
  B --> D[Resolve established session key]
  D --> E{Current result}
  E -->|Session exists or lookup fails| F[Keep conversation and draft]
  E -->|Session confirmed missing| G[Show session recovery actions]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +125, Tests +444, Docs +6. Total +575 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 4 155 30 +125
Tests 4 451 7 +444
Docs 1 6 0 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 612 37 +575

Review metrics

Metric Value Why it matters
Production versus test growth production +125 net lines; tests +444 net lines Production growth supports scoped reconnect verification through existing owners; most added coverage exercises timing and session-identity regressions.

Technical review

Best possible solution:

Keep session existence with the Gateway resolver and use the existing missing-session view while preserving surviving conversations, drafts, and explicit creation routes.

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

Yes: keep an incognito conversation open while its Gateway restarts and removes it. Current-main routing lacks the existence check, and the supplied investigation and browser regression demonstrate the symptom; this review did not execute it.

Is this the best way to solve the issue?

Yes: extending the existing router lifecycle and exact-session resolver is a focused repair that avoids a second state owner and preserves creation-route behavior.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This fixes a bounded conversation-recovery defect after session expiry or Gateway restart.
  • 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. Not applicable: The supplied maintainer classification exempts this PR from the external-contributor live-proof gate. Inspected desktop/mobile captures and the registered browser scenario cover the router's missing-session presentation; the body explicitly leaves real-profile after-restart replay pending, so no live-after result is claimed.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. The supplied maintainer classification exempts this PR from the external-contributor live-proof gate. Inspected desktop/mobile captures and the registered browser scenario cover the router's missing-session presentation; the body explicitly leaves real-profile after-restart replay pending, so no live-after result is claimed.

Evidence

What I checked:

  • Pinned change ownership: Reviewed the merge-base-to-head changes, including the complete loader and route tests. Base-only daemon, catalog, and secrets changes are not introduced by this PR. The supplied stale test merge was not used to infer removals. (ui/src/pages/chat/route-loader.ts:292, 0aee8999720e)
  • Current main still needs the repair: Current main records interrupted pending loads and clears recovery state for successful routes without checking session existence. The supplied merged fix(ui): recover session links interrupted by reconnect #145347 explicitly preserves successful conversations and addresses a different reconnect case. (ui/src/app-routes.ts:277, d8d7d53d58b0)
  • Latest release comparison: The v2026.9.4 router lacks the established-session recovery check. Its source was inspected through GitHub after the local historical blob could not be retrieved. (ui/src/app-routes.ts:298, 3a9d69db306c)
  • Scoped, authoritative recovery: Verification captures the connection, hello, presentation scope, and route controller; stale results cannot trigger revalidation. It queries the established key, preserves creation routes, and treats lookup failures as non-deletion. (ui/src/app-routes.ts:278, 0aee8999720e)
  • Existing Gateway resolution contract: The existing reference resolver performs exact-key discovery using current session visibility and returns a distinct missing result. The PR reuses this owner without changing permissions, persistence, or the protocol. (src/gateway/sessions-resolve.ts:217, 0aee8999720e)
  • Router dependency contract: The changed route loader directly consumes the router's cause and dependency contract. npm metadata identifies openclaw/uirouter and the published 0.1.1 source revision; that source preserves established data during same-match revalidation and supplies cause=revalidate without adding browser history. (src/router.ts, f5ce7c0d7c04)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • vyctorbrzezowski: 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 (3 earlier review cycles)
  • reviewed 2026-09-16T02:06:11.743Z sha 2f2c546 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-16T02:33:04.700Z sha 4eb0049 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-16T03:14:43.923Z sha 0aee899 :: needs maintainer review before merge. :: none

@steipete
steipete merged commit 167c310 into main Sep 16, 2026
140 checks passed
@steipete
steipete deleted the codex/qa-expired-session-reconnect branch September 16, 2026 03:58
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 16, 2026
* fix(ui): revalidate established sessions after reconnect

* chore(ui): document session route data invariants

* test(ui): declare canonical progress widget sessions

* fix(ui): avoid duplicate session discovery on first connection
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 maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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