Skip to content

fix(ui): preserve local session continuity#75948

Merged
BunsDev merged 3 commits intomainfrom
meow/fix-session-continuity-63195
May 2, 2026
Merged

fix(ui): preserve local session continuity#75948
BunsDev merged 3 commits intomainfrom
meow/fix-session-continuity-63195

Conversation

@BunsDev
Copy link
Copy Markdown
Member

@BunsDev BunsDev commented May 2, 2026

Summary

  • Preserve the backing Gateway sessionId returned by chat.history in Control UI and include it on follow-up chat.send calls after refresh/reconnect.
  • Persist the TUI's last selected session per gateway/agent/scope and resume it on relaunch when no explicit --session is provided.
  • Keep session switching explicit: /session, /new, /reset, and explicit --session still choose the active session and update the remembered TUI target only after history loads.
  • Document the Control UI/TUI continuity contract and add a changelog entry.

Issue coverage

Fixes #63195.
Fixes #68162.
Fixes #73546.

Supersedes #48589 with a narrower current-main implementation that avoids the stale orphan-reattach/client-id review blockers from that PR. #63229 remains separate because its current evidence is provider/gateway timeout classification, not local client session continuity.

Validation

  • node scripts/run-vitest.mjs run --config test/vitest/vitest.unit-ui.config.ts ui/src/ui/controllers/chat.test.ts
  • pnpm test src/tui/tui-last-session.test.ts src/tui/tui-session-actions.test.ts src/tui/tui-command-handlers.test.ts src/tui/gateway-chat.test.ts
  • pnpm exec oxfmt --check --threads=1 CHANGELOG.md docs/web/tui.md docs/web/webchat.md src/tui/gateway-chat.ts src/tui/tui-backend.ts src/tui/tui-command-handlers.test.ts src/tui/tui-command-handlers.ts src/tui/tui-session-actions.test.ts src/tui/tui-session-actions.ts src/tui/tui.ts src/tui/tui-last-session.test.ts src/tui/tui-last-session.ts ui/src/ui/app-render.helpers.ts ui/src/ui/app.ts ui/src/ui/controllers/chat.test.ts ui/src/ui/controllers/chat.ts
  • git diff --check origin/main...HEAD
  • Testbox pnpm testbox:sanity (tbx_01kqkf1ryenh4y0htv4dkwqsxv): 16 changed entries, 0 tracked deletions
  • Testbox OPENCLAW_TESTBOX=1 pnpm check:changed (tbx_01kqkf1ryenh4y0htv4dkwqsxv)

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui size: M labels May 2, 2026
@BunsDev BunsDev self-assigned this May 2, 2026
@openclaw-barnacle openclaw-barnacle Bot added the maintainer Maintainer-authored PR label May 2, 2026
@clawsweeper
Copy link
Copy Markdown
Contributor

clawsweeper Bot commented May 2, 2026

Codex review: needs maintainer review before merge.

Summary
The PR preserves Control UI and TUI chat continuity across refresh, reconnect, and TUI relaunch by carrying the history-backed session id through chat.send, adding TUI last-session persistence, generated Swift protocol updates, tests, docs, and a changelog entry.

Reproducibility: yes. The target flow is reproducible by loading chat.history, then sending after refresh/reconnect or TUI relaunch; the PR adds coverage for chat.send accepting the returned session id, UI send-after-reconnect, and TUI session remembering.

Next step before merge
No repair job is needed: the latest diff has no narrow automated blocker, and the remaining action is normal exact-SHA CI and maintainer merge handling.

Security
Cleared: No concrete security or supply-chain regression was found in the PR diff.

Review details

Best possible solution:

Use this PR as the narrow canonical fix for local Control UI/TUI session continuity, keep #63229 separate, and land after exact-SHA CI and maintainer approval finish.

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

Yes. The target flow is reproducible by loading chat.history, then sending after refresh/reconnect or TUI relaunch; the PR adds coverage for chat.send accepting the returned session id, UI send-after-reconnect, and TUI session remembering.

Is this the best way to solve the issue?

Yes. The updated approach is the narrow maintainable path: make sessionId an additive Gateway protocol field, keep stored session entries authoritative, and confine client persistence to UI/TUI state rather than broad core migration.

What I checked:

  • Protected maintainer PR: GitHub metadata shows authorAssociation MEMBER and the protected maintainer label, so this workflow should not auto-close the PR. (c2818b6c0b0b)
  • Prior P1 addressed: The latest diff adds optional sessionId to ChatSendParamsSchema, resolving the earlier validation blocker where chat.send rejected the client field. (src/gateway/protocol/schema/logs-chat.ts:35, c2818b6c0b0b)
  • Gateway handler honors fallback session id: The PR threads sessionId into the chat.send handler and uses stored session entries first, then the requested id as a backing fallback for abort and transcript bookkeeping. (src/gateway/server-methods/chat.ts:1905, c2818b6c0b0b)
  • Client continuity paths: Control UI records sessionId from chat.history and includes it on follow-up sends; the TUI also passes the current backing id through GatewayChatClient.sendChat. (ui/src/ui/controllers/chat.ts:431, c2818b6c0b0b)
  • TUI relaunch persistence: The PR adds a scoped hashed TUI last-session store and restores a remembered session only when no explicit session was requested and the session still exists for the current agent. (src/tui/tui-last-session.ts:19, c2818b6c0b0b)
  • Validation state: The author reported targeted Gateway/TUI/UI tests, oxfmt, changelog attribution, diff check, and Testbox changed gate passing; GitHub check-runs for the exact head showed many required checks green with a few quality shards still in progress at inspection. (c2818b6c0b0b)

Likely related people:

  • Peter Steinberger: Recent GitHub history and local blame show Peter maintaining the Gateway chat, WebChat, protocol, and TUI-adjacent paths central to this continuity change. (role: recent maintainer; confidence: high; commits: 6147e1b91d3e, 7e41913a203a, f739edcf4c7e; files: src/gateway/server-methods/chat.ts, ui/src/ui/controllers/chat.ts, src/tui/gateway-chat.ts)
  • Vincent Koc: Recent commits on the same WebChat and Gateway chat surfaces cover bounded history reads, final reload reconciliation, attachments, and stale external route handling. (role: adjacent chat/session maintainer; confidence: medium; commits: aec83af23d49, 02908db62b30, cff991c88d04; files: src/gateway/server-methods/chat.ts, ui/src/ui/controllers/chat.ts, src/gateway/protocol/schema/logs-chat.ts)
  • Roger Deng: Recent TUI history includes reconnect watchdog work on the same user-visible continuity surface, making Roger a useful routing candidate for TUI reconnect behavior. (role: adjacent TUI reconnect maintainer; confidence: medium; commits: d4e52f454255; files: src/tui/tui.ts)

Remaining risk / open question:

  • A few exact-head GitHub check runs were still in progress when inspected, so final merge should wait for the completed exact-SHA CI state.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 1ecb2fc2c72a.

@BunsDev
Copy link
Copy Markdown
Member Author

BunsDev commented May 2, 2026

CI note after the latest force-push: the branch-local and Testbox changed gate are green, but the exact-SHA GitHub CI run is currently red on two files outside this PR diff: check:test-types reports a generic mock type error in src/agents/subagent-registry-lifecycle.test.ts, and check-dependencies reports src/plugins/plugin-lru-cache.ts as an unexpected unused file. Neither file is touched by this PR.

@BunsDev BunsDev force-pushed the meow/fix-session-continuity-63195 branch from 335b98e to afff9ad Compare May 2, 2026 04:47
@openclaw-barnacle openclaw-barnacle Bot added the gateway Gateway runtime label May 2, 2026
@BunsDev
Copy link
Copy Markdown
Member Author

BunsDev commented May 2, 2026

ClawSweeper P1 addressed in afff9adac2. The chat.send schema now accepts the history-backed sessionId, and the gateway carries that id as the backing fallback for abort/transcript bookkeeping while keeping stored session entries authoritative. Added server coverage for chat.history returning a session id and chat.send accepting it. Validation: targeted gateway/TUI tests, unit UI chat controller test, targeted oxfmt check, and Testbox OPENCLAW_TESTBOX=1 pnpm check:changed passed on tbx_01kqkg2fcmpmt1nvk6vq20qe60.

@BunsDev BunsDev force-pushed the meow/fix-session-continuity-63195 branch from afff9ad to 2307902 Compare May 2, 2026 04:49
@BunsDev
Copy link
Copy Markdown
Member Author

BunsDev commented May 2, 2026

Final branch refresh: rebased onto current main and resolved the changelog-only conflict. Final head is 2307902. Post-rebase validation: targeted gateway/TUI tests passed, unit UI chat controller test passed, targeted oxfmt check passed, check:changelog-attributions passed, and git diff --check passed. The earlier explicit Testbox OPENCLAW_TESTBOX=1 pnpm check:changed gate passed before this changelog-only rebase.

@openclaw-barnacle openclaw-barnacle Bot added the app: macos App: macos label May 2, 2026
@BunsDev
Copy link
Copy Markdown
Member Author

BunsDev commented May 2, 2026

Final CI update for c2818b6: protocol artifacts are regenerated, checks-fast-protocol is green, and the full exact-SHA CI/check set is now green. PR merge state is CLEAN.

@BunsDev BunsDev merged commit cb9d788 into main May 2, 2026
106 checks passed
@BunsDev BunsDev deleted the meow/fix-session-continuity-63195 branch May 2, 2026 05:08
lxe pushed a commit to lxe/openclaw that referenced this pull request May 6, 2026
Fixes openclaw#63195.
Closes openclaw#68162.
Closes openclaw#73546.

- Keep Control UI chat sends bound to the history-backed session id across reconnects.
- Accept chat.send sessionId at the gateway/protocol boundary and update generated Swift models.
- Resume the last selected TUI session for the same gateway/agent/scope when still present.

Validated by exact-SHA CI on PR openclaw#75948.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
Fixes openclaw#63195.
Closes openclaw#68162.
Closes openclaw#73546.

- Keep Control UI chat sends bound to the history-backed session id across reconnects.
- Accept chat.send sessionId at the gateway/protocol boundary and update generated Swift models.
- Resume the last selected TUI session for the same gateway/agent/scope when still present.

Validated by exact-SHA CI on PR openclaw#75948.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: macos App: macos app: web-ui App: web-ui docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR size: M

Projects

None yet

1 participant