Skip to content

fix(tui): keep session refreshes on the selected agent - #158240

Merged
steipete merged 1 commit into
mainfrom
codex/fix-tui-session-owner-consistency
Sep 25, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/fix-tui-session-owner-consistency

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Refs #150153. Continues the bounded TUI selection work preserved in #152895; neither umbrella is closed by this PR.

What Problem This Solves

Fixes the TUI switching its session details or remembered selection to another agent when the returned conversation has the same session-key suffix.

User Impact

The selected agent, header, footer, and remembered conversation stay consistent. Existing bare-key aliases and case-sensitive provider identities remain supported; no configuration or data migration is required.

Why This Change Was Made

The request-key comparison discarded both qualified owners, while description and restore callers trusted the matching suffix. The repair retains qualified ownership and reuses the existing owner checks for returned descriptions and remembered rows. The subscription/ACK protocol and persistence owners are unchanged.

Evidence

  • Before the repair, five owner-consistency assertions failed while eight compatibility controls passed. The initial repaired owner/sibling selection passed 498 distinct cases; the final guard and focused test extraction passed all 107 affected cases without removing assertions.
  • The actual runTui() loop reproduced the mismatch with a synthetic backend: Work history stayed visible while the old description refresh adopted Main. Identical inputs after the repair retained Work. Both native runs joined and their owned terminals were closed. This proves the TUI boundary, not live Gateway transport or provider behavior.
  • Before capture: main 2aee10b0879d. After capture: this PR's production files, individually hash-bound to the inspected image. Both complete images contain only synthetic content and were delivered inline in the originating chat.
  • All selected changed checks passed, including production types, all 25 core test-type graphs, lint, formatting, import cycles, and the existing guards. Final full-owner P0–P2 review found no actionable issues.

The initial six-file run took 55.72 seconds, including 24.15 seconds of maintained worker compilation. Reported case-execution spans were 158 ms for session-key tests, 610 ms for remembered-session tests, and 534 ms for session actions. After extracting the description cases, their six cases totaled 28 ms and the remaining session-action cases totaled 520 ms. These are summed test-reporter spans, not isolated end-to-end benchmarks.

This is one internal selection correction. Broader logical identity, exact-main/Home, wire compatibility, and the original asynchronous database work remain tracked in #150153.

Visual proof

The same synthetic Work conversation and command are shown before and after.

Before: synthetic Work history with incorrect Main selection

After: synthetic Work history with Work correctly retained

Preserve qualified owners during request-key comparison and reuse existing
TUI owner checks for returned descriptions and remembered sessions. Keep
bare aliases and opaque provider identities unchanged.

Refs #150153
Refs #152895
@clawsweeper

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: M labels Sep 25, 2026
@steipete
steipete marked this pull request as ready for review September 25, 2026 18:12
@clawsweeper

clawsweeper Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 25, 2026, 2:18 PM ET / 18:18 UTC.

ClawSweeper review

What this changes

The branch makes TUI description refreshes and remembered-session restoration retain the selected agent when another agent has the same session name, with focused tests and a documentation update.

Merge readiness

✅ Ready for maintainer review

Current main still permits a session-key suffix collision during TUI refresh. This focused PR addresses a distinct remaining defect; the related umbrella branches are unmerged and do not replace it.

Priority: P1
Reviewed head: c05c1614697db67117fc3858bd1d34a4b001c26e

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused repair has direct before/after TUI evidence, relevant regression coverage, and no identified blocking defect.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): The changed TUI description and restore behavior is tied to a reported runTui session-selection run with a synthetic backend; inspected before/after terminal screenshots show Main metadata changing to the selected Work metadata under identical Work history. Live Gateway transport is outside this focused proof, and no stored-data format changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (screenshot): The changed TUI description and restore behavior is tied to a reported runTui session-selection run with a synthetic backend; inspected before/after terminal screenshots show Main metadata changing to the selected Work metadata under identical Work history. Live Gateway transport is outside this focused proof, and no stored-data format changes.
Evidence reviewed 8 items Current main retains the defect: Current main still compares qualified session keys by their request-key suffix, allowing different agents with the same suffix to match.
Introduced ownership guard: The branch compares both qualified owners and checks a returned description against the current session mutation guard before adopting its key or details.
Remembered-session boundary: Restoration now uses the existing TUI ownership matcher for listed rows; the test covers a same-suffix row belonging to another agent and a bare-key alias.
Findings None None.
Security None None.

How this fits together

The terminal UI selects an agent and conversation, then asks a Gateway or local backend for session details. Returned details and remembered selections affect the header, footer, and conversation shown to the user.

flowchart LR
A[Selected agent and session] --> B[Description request]
B --> C[Gateway or local backend]
C --> D{Same agent and conversation?}
A --> E[Remembered session lookup]
E --> D
D -->|Yes| F[Update TUI selection and details]
D -->|No| G[Keep current selection]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -2, Tests +48, Docs 0. Total +46 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 3 20 22 -2
Tests 4 127 79 +48
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 148 102 +46

Review metrics

None.

Technical review

Best possible solution:

Keep description refresh and remembered restoration bound to the selected agent and conversation while preserving bare-key aliases and opaque provider identities.

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

Yes. The inspected before capture shows Work history with Main metadata in the real TUI loop using a synthetic backend, and current main retains the matching code; I did not execute that loop during this read-only review.

Is this the best way to solve the issue?

Yes. The patch uses existing session ownership checks at the TUI boundary and preserves alias behavior without changing persistence or the wire protocol.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P1: A TUI refresh can switch visible session details to another agent during an active conversation.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The changed TUI description and restore behavior is tied to a reported runTui session-selection run with a synthetic backend; inspected before/after terminal screenshots show Main metadata changing to the selected Work metadata under identical Work history. Live Gateway transport is outside this focused proof, and no stored-data format changes.
  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. The changed TUI description and restore behavior is tied to a reported runTui session-selection run with a synthetic backend; inspected before/after terminal screenshots show Main metadata changing to the selected Work metadata under identical Work history. Live Gateway transport is outside this focused proof, and no stored-data format changes.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.

Label justifications:

  • P1: A TUI refresh can switch visible session details to another agent during an active conversation.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed TUI description and restore behavior is tied to a reported runTui session-selection run with a synthetic backend; inspected before/after terminal screenshots show Main metadata changing to the selected Work metadata under identical Work history. Live Gateway transport is outside this focused proof, and no stored-data format changes.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. The changed TUI description and restore behavior is tied to a reported runTui session-selection run with a synthetic backend; inspected before/after terminal screenshots show Main metadata changing to the selected Work metadata under identical Work history. Live Gateway transport is outside this focused proof, and no stored-data format changes.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Ayaan Zaidi: 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.

@steipete
steipete enabled auto-merge (squash) September 25, 2026 18:23
@steipete
steipete merged commit df5e316 into main Sep 25, 2026
277 of 278 checks passed
@steipete
steipete deleted the codex/fix-tui-session-owner-consistency branch September 25, 2026 18:28
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash auto-merge.

roboclaw-bot added a commit that referenced this pull request Sep 25, 2026
Backport #157564: 4bfac2b
Backport #157881: 0b234fc
Backport #158240: df5e316

Preserve native Ollama free-form schema parameters, project Twitch Disabled
to explicit deny-all, and retain TUI session ownership across delayed state.
No new policy, dependencies or version changes.

Co-authored-by: Hmache Abdellah <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: vyctorbrzezowski <[email protected]>
Co-authored-by: steipete <[email protected]>
Co-authored-by: jalehman <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 26, 2026
Preserve qualified owners during request-key comparison and reuse existing
TUI owner checks for returned descriptions and remembered sessions. Keep
bare aliases and opaque provider identities unchanged.

Refs openclaw#150153
Refs openclaw#152895
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant