Skip to content

fix(tui): hide stale overlays after remembered session restore - #125086

Merged
steipete merged 1 commit into
mainfrom
steipete/tui-session-identity-verification-510236
Aug 17, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/tui-session-identity-verification-510236

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Closes #125013

What Problem This Solves

Fixes an issue where TUI startup could restore a remembered session while leaving a plugin-approval or task-suggestion overlay from the initial/default session visible. The header and transcript would show the restored session, but the overlay still belonged to the previous session.

Why This Change Was Made

Session identity now has one canonical owner inside TUI state. Agent, session-key, session-ID, and generation reads and mutations flow through that state; remembered-session restoration uses the same session-change notification path as interactive switching. The only notification-free assignment is the documented bootstrap selection before overlay controllers exist.

AI-assisted: yes. I reviewed the complete owner boundary, mutation paths, regression behavior, and generated changes.

User Impact

Operators who relaunch the TUI into a remembered session no longer see or act on stale session-scoped approvals or task suggestions from the initial session. Interactive switching, reset/new-session transitions, reconnect handling, and session event identity behavior remain unchanged.

Evidence

  • Regression proof: the focused real-PTY test fails when remembered restore bypasses the canonical setter, showing picker-target in the visible session while the stale workspace skill approval overlay remains; it passes with the fix.
  • node scripts/run-vitest.mjs run --config test/vitest/vitest.tui-pty.config.ts src/tui/tui-session-identity-pty.e2e.test.ts — 1 test passed on the rebased head.
  • node scripts/run-vitest.mjs run src/tui — 44 files / 1,184 tests passed on the rebased head.
  • Source-blind behavior validation — the remembered-session and stale-overlay contract passed on the running PTY surface.
  • Codex autoreview (--mode branch --base origin/main) — clean, no accepted/actionable findings.
  • node scripts/check-changed.mjs -- <touched files> — passed on Testbox tbx_01m072sstjfnjmsqgq8tte6t51.
  • The rebased runtime frame is byte-identical to the published “after” evidence.
  • Production LOC: +56/-52 (net +4), the explicit runtime identity-owner contract. Test and test-support LOC: +87/-15 (net +72).
  • No file split was needed; existing grandfathered max-lines suppressions and baseline entries remain unchanged.

Before / after

Before: the TUI has restored picker-target, but still presents the default session's workspace-skill approval.

Before: stale default-session approval remains over the restored TUI session

After: the restored session owns the viewport and the stale overlay is gone.

After: restored TUI session with no stale approval overlay

Final rebased-head proof

Verified commit: 446491c69e09ca9dab5b6216dac165e9315bba1d

  • Testbox changed-check lease: tbx_01m072sstjfnjmsqgq8tte6t51
  • Full TUI suite: 44 files / 1,184 tests
  • Focused real-PTY regression: 1/1 passed
  • Source-blind behavior validation: passed
  • Branch-mode Codex autoreview: clean

Centralize TUI session identity in state so remembered-session restores use the same invalidation path as interactive switches. Fixes #125013.
@clawsweeper

clawsweeper Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added size: M maintainer Maintainer-authored PR labels Aug 17, 2026
@steipete
steipete marked this pull request as ready for review August 17, 2026 05:42
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 17, 2026
@clawsweeper

clawsweeper Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 17, 2026, 1:49 AM ET / 05:49 UTC.

ClawSweeper review

What this changes

The PR centralizes TUI session identity and makes remembered-session restoration notify approval and task-suggestion overlays when the visible session changes.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open. Current main still restores a remembered session by bypassing its notifying session setter, while this branch moves all post-bootstrap session changes through the canonical state owner and adds a visible PTY regression. The protected maintainer label and incomplete exact-head checks leave normal human merge handling in place.

Priority: P2
Reviewed head: 446491c69e09ca9dab5b6216dac165e9315bba1d

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A coherent owner-boundary repair with direct visible PTY coverage and supporting before/after evidence.
Proof confidence 🦞 diamond lobster (5/6) Not applicable: This maintainer-authored PR is not subject to the external-contributor proof gate; its body nevertheless provides before/after terminal captures and a focused fake-backend PTY regression run.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is not subject to the external-contributor proof gate; its body nevertheless provides before/after terminal captures and a focused fake-backend PTY regression run.
Evidence reviewed 6 items Current-main bypass: Current main defines notifying state setters for session identity, but remembered restore writes the captured session variable directly at line 1108, so neither overlay controller is told about the change.
Canonical repair path: The branch retains an intentional notification-free bootstrap assignment, then restores remembered sessions through the state setter; that setter calls the shared overlay notification after controllers are constructed.
Sibling overlay behavior: Both controller siblings already own the active-session invariant: plugin approvals close a mismatched active overlay and task suggestions do the same before presenting the next matching item.
Findings None None.
Security None None.

How this fits together

The TUI restores a remembered session during startup, then loads history and session-scoped approval or task-suggestion overlays. Session identity changes must invalidate overlays from the prior session before the terminal UI presents the restored session.

flowchart LR
  A[Remembered session] --> B[TUI startup]
  B --> C[Session identity state]
  C --> D[Approval overlay]
  C --> E[Task suggestion overlay]
  C --> F[History and header]
  D --> G[Visible terminal UI]
  E --> G
  F --> G
Loading

Before merge

  • Resolve merge risk (P1) - Exact-head checks are still in progress; landing should wait for the normal green gate, although GitHub currently reports the branch as mergeable despite base drift.
Agent review details

Security

None.

PR surface

Source +13, Tests +63. Total +76 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 80 67 +13
Tests 2 63 0 +63
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 143 67 +76

Review metrics

Metric Value Why it matters
Production versus test delta production +56/-52 (net +4); tests and test support +87/-15 (net +72) The small production increase creates one explicit identity owner while the larger test delta supplies a visible PTY regression and fixture support.

Stored data model

Persistent data-model change detected: serialized state: src/tui/tui.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Preserve the single post-bootstrap session-transition path so startup restoration and interactive switching both invalidate session-scoped overlays before rendering the restored session.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Preserve the single post-bootstrap session-transition path so startup restoration and interactive switching both invalidate session-scoped overlays before rendering the restored session.

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

Yes, source-reproducible with high confidence: persist a target session, emit a pending approval for the default session before connection, and start the fake-backend PTY. Current main restores the target through a direct assignment, leaving the already-open default-session overlay intact; this read-only review did not execute the test.

Is this the best way to solve the issue?

Yes. Reusing the existing session-state setters keeps approval and task-suggestion invalidation at their controller boundary; directly closing overlays inside remembered restore would duplicate that policy and miss a sibling surface.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against d6be4f355203.

Labels

Label changes:

  • add P2: This fixes misleading session-scoped terminal UI actions without evidence of data loss, a crash loop, or a release-blocking setup failure.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is not subject to the external-contributor proof gate; its body nevertheless provides before/after terminal captures and a focused fake-backend PTY regression run.

Label justifications:

  • P2: This fixes misleading session-scoped terminal UI actions without evidence of data loss, a crash loop, or a release-blocking setup failure.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR is not subject to the external-contributor proof gate; its body nevertheless provides before/after terminal captures and a focused fake-backend PTY regression run.

Evidence

What I checked:

  • Current-main bypass: Current main defines notifying state setters for session identity, but remembered restore writes the captured session variable directly at line 1108, so neither overlay controller is told about the change. (src/tui/tui.ts:1108, d6be4f355203)
  • Canonical repair path: The branch retains an intentional notification-free bootstrap assignment, then restores remembered sessions through the state setter; that setter calls the shared overlay notification after controllers are constructed. (src/tui/tui.ts:1113, 446491c69e09)
  • Sibling overlay behavior: Both controller siblings already own the active-session invariant: plugin approvals close a mismatched active overlay and task suggestions do the same before presenting the next matching item. (src/tui/tui-plugin-approvals.ts:502, 446491c69e09)
  • Boundary regression coverage: The new fake-backend PTY test persists the target session, emits a default-session approval before connection, waits for restored history, and asserts that the rendered frame no longer contains the stale approval. (src/tui/tui-session-identity-pty.e2e.test.ts:19, 446491c69e09)
  • History provenance: Blame assigns the current-main restore block, including the direct assignment, to the release-backfill commit that carried the present TUI file; this supports routing but does not establish the original regression commit. (src/tui/tui.ts:1108, 305e38f5d9ce)
  • Current-main comparison: No TUI commit landed between the PR base and current main, and the PR diff cleanly applies its four-file repair against the current main snapshot. (src/tui/tui.ts:1108, d6be4f355203)

Likely related people:

  • Patrick Erichsen: Current-main blame and file history associate the carried remembered-session restore path with this recent TUI source commit; the original historical introduction is not locally available. (role: recent TUI contributor; confidence: medium; commits: 305e38f5d9ce; files: src/tui/tui.ts)

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.

@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof for exact head 446491c69e09ca9dab5b6216dac165e9315bba1d:

  • Exact-head pull-request CI: green, run 31998862374.
  • git diff --check origin/main...HEAD: passed; worktree clean.
  • Testbox changed checks: passed on lease tbx_01m072sstjfnjmsqgq8tte6t51.
  • Full TUI suite: 44 files / 1,184 tests passed.
  • Focused real-PTY regression: 1/1 passed.
  • Source-blind behavior validation: passed.
  • Branch-mode Codex autoreview: clean, with no accepted/actionable findings.
  • Visual before/after evidence is included in the PR body.
  • ClawSweeper: 5/6, no findings and no Rank-up moves: list. Its only before-merge item was exact-head CI, now green.

Proof gaps: none known.

@steipete
steipete merged commit 7b4981b into main Aug 17, 2026
285 checks passed
@steipete
steipete deleted the steipete/tui-session-identity-verification-510236 branch August 17, 2026 06:14
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 18, 2026
Centralize TUI session identity in state so remembered-session restores use the same invalidation path as interactive switches. Fixes openclaw#125013.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🦞 diamond lobster Very strong PR readiness with only minor 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.

[Bug]: TUI keeps stale approval overlay after restoring remembered session

1 participant