Skip to content

feat(cli): openclaw resume attaches the TUI to a recent session - #120664

Merged
steipete merged 6 commits into
mainfrom
steipete/runners-m2-resume-verb
Aug 9, 2026
Merged

steipete merged 6 commits into
mainfrom
steipete/runners-m2-resume-verb

Conversation

@steipete

@steipete steipete commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

A session started anywhere (web Control UI, a channel, a cloud worker) has no ergonomic CLI continuation path. openclaw tui --session <key> requires knowing the raw agent:<id>:<key> string; the TUI's Ctrl+P picker exists only after you're already attached. docs/plan/runners.md milestone 2 ("Session continuation ergonomics").

Why This Change Was Made

Adds the openclaw resume [query] verb (verbs, not a second noun command — per the plan's naming rulings):

  • No args: interactive picker over the same bounded recent-session window the TUI Ctrl+P picker uses (50 sessions / 7 days), or a non-TTY-safe error with guidance.
  • With query: exact key match wins; else unique substring; else unique fuzzy match (existing pi-tui fuzzyFilter); ambiguous prints candidates and exits 1.
  • On resolution, runs the existing runTui path with the resolved --session key; --url/--token/--password/--tls-fingerprint pass through identically to openclaw tui. No gateway auto-start; unreachable gateway fails with the same guidance the TUI gives.

Refactor included: the Ctrl+P picker's session-listing + label/preview building was extracted into a shared src/tui/tui-session-picker.ts owner consumed by both the TUI selector and the new command (−45 LOC in tui-command-handlers.ts), so the two pickers cannot drift.

No protocol changes; sessions.list is used as-is.

Release-note context: CLI session resume — openclaw resume [query] finds a recent Gateway session by key or name and attaches the TUI.

User Impact

openclaw resume / openclaw resume big-refactor continues any recent session from the terminal, including sessions running on cloud workers — clients attach to sessions, placement is irrelevant. New docs page: /cli/resume.

Evidence

  • node scripts/run-vitest.mjs src/cli/resume-cli.test.ts src/cli/program/register.subclis.test.ts: 2 files, 151 tests passed.
  • Resolver tests are table-driven: exact-key-beats-name, unique substring (key and display name), unique fuzzy, ambiguous → candidates + exit 1, none → guidance + exit 1.
  • Registration suite: 23 tests passed. docs:list, formatting, git diff --check clean.
  • Autoreview (codex/gpt-5.6-sol, high): clean, no accepted/actionable findings.

ClawSweeper moves

P3 plan status: applied (rows 0/1a/1b/2 updated). P1 boundary test: skipped in this PR — needs a new lightweight gateway test harness (existing helper ~370s under CLI vitest config); recorded as a named follow-up in docs/plan/runners.md milestone 2.

Round-4 P1 (exercise qualified global resume through a Gateway operation): skipped — requires the lightweight CLI-side gateway harness recorded as a named follow-up in docs/plan/runners.md milestone 2 (existing helper ~370s under the CLI vitest config). Code behavior verified: bare-global rows are excluded from resume listing; explicit agent-qualified keys pass to the TUI unchanged.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation cli CLI command changes labels Aug 8, 2026
@steipete
steipete marked this pull request as ready for review August 8, 2026 18:40
@openclaw-barnacle openclaw-barnacle Bot added size: M maintainer Maintainer-authored PR labels Aug 8, 2026
@clawsweeper clawsweeper Bot added 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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Aug 8, 2026
@clawsweeper

clawsweeper Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed August 9, 2026, 3:50 AM ET / 07:50 UTC.

ClawSweeper review

What this changes

This PR adds openclaw resume [query] to select a recent Gateway session and attach the existing terminal UI.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open: the latest head still lacks the previously requested Gateway-boundary regression for agent-qualified global sessions.

Priority: P1
Reviewed head: c92a3cb9b3db310564f74db081e22dc52545b15f

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The feature is coherently scoped and CI-backed, but the remaining P1 session-boundary proof prevents a higher rating.
Proof confidence 🌊 off-meta tidepool Not applicable: This MEMBER-authored PR is outside the external-contributor proof gate, though its mock tests do not substitute for the required Gateway-boundary regression.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This MEMBER-authored PR is outside the external-contributor proof gate, though its mock tests do not substitute for the required Gateway-boundary regression.
Evidence reviewed 5 items Current main lacks the feature: Current main has the TUI picker but no resume CLI runtime, shared picker module, or resume documentation, so this PR is not superseded.
Qualified global handoff: The branch preserves agent:&lt;id>:global for launch after listing the selected agent's global row.
Gateway boundary contract: TUI history converts the global sentinel into a request with the separately selected agent ID; this is the ownership boundary the new flow must prove.
Findings 1 actionable finding [P1] Exercise qualified global resume through a Gateway operation
Security None None.

How this fits together

The resume command lists recent sessions through the Gateway, chooses one by query or picker, then launches the TUI. The TUI converts a qualified session key into Gateway history and send requests for the selected agent.

flowchart LR
  Terminal[Interactive terminal] --> Resume[Resume command]
  Resume --> List[Gateway session list]
  List --> Select[Session selection]
  Select --> TUI[Terminal UI]
  TUI --> History[Gateway history and send]
  History --> Session[Selected agent session]
Loading

Before merge

  • Exercise qualified global resume through a Gateway operation (P1) - The added test only verifies mocked runTui arguments, while the TUI later unwraps the key to global. Add a focused Gateway/protocol regression that observes chat.history (and ideally chat.send) receive sessionKey: "global" with agentId: "work"; otherwise a lost owner at that boundary would still pass this suite.
  • Resolve merge risk (P1) - Without a Gateway-boundary regression, a future mismatch after the qualified key is unwrapped to global could load or send in the wrong agent's global session.
  • Complete next step (P2) - A bounded regression harness can mechanically prove the remaining session-ownership invariant before merge.

Findings

  • [P1] Exercise qualified global resume through a Gateway operation — src/cli/resume-cli.runtime.ts:158-166
Agent review details

Security

None.

PR surface

Source +300, Tests +249, Docs +78. Total +627 across 19 files.

View PR surface stats
Area Files Added Removed Net
Source 10 349 49 +300
Tests 5 250 1 +249
Docs 4 91 13 +78
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 19 690 63 +627

Review metrics

Metric Value Why it matters
Production vs test LOC production +349/-49; tests +250/-1 The production growth is justified by a new CLI capability and shared picker owner, but the session-ownership boundary still needs direct regression coverage.

Merge-risk options

Maintainer options:

  1. Prove global-session ownership before merge (recommended)
    Add a focused Gateway-boundary regression that observes the selected agent ID on the first global history request.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Add a focused ephemeral Gateway/protocol regression for `agent:work:global` that observes session listing and the first `chat.history` request with `agentId: "work"`; preserve existing resolver coverage.

Technical review

Best possible solution:

Add one focused ephemeral Gateway/protocol regression that observes agent:work:global reach both session listing and TUI history with agentId: "work".

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

Not applicable to a new feature; the missing proof is source-reproducible because the branch tests stop before the real TUI-to-Gateway request boundary.

Is this the best way to solve the issue?

No: the current resolver and mock tests are not the best proof for a session-ownership change; a Gateway-boundary regression is narrower and directly validates the invariant.

Full review comments:

  • [P1] Exercise qualified global resume through a Gateway operation — src/cli/resume-cli.runtime.ts:158-166
    The added test only verifies mocked runTui arguments, while the TUI later unwraps the key to global. Add a focused Gateway/protocol regression that observes chat.history (and ideally chat.send) receive sessionKey: "global" with agentId: "work"; otherwise a lost owner at that boundary would still pass this suite.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: The remaining blocker concerns routing a global session to the selected agent, where a mistake can expose the wrong session state.
  • merge-risk: 🚨 session-state: This PR converts an agent-qualified global key into a sentinel plus separate agent ID across the TUI-to-Gateway boundary.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This MEMBER-authored PR is outside the external-contributor proof gate, though its mock tests do not substitute for the required Gateway-boundary regression.

Evidence

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs src/cli/resume-cli.test.ts src/tui/tui.test.ts.
  • [P1] Run the focused Gateway/protocol harness that observes the history request payload.

What I checked:

  • Current main lacks the feature: Current main has the TUI picker but no resume CLI runtime, shared picker module, or resume documentation, so this PR is not superseded. (src/tui/tui-command-handlers.ts:399, 499d81cdbdad)
  • Qualified global handoff: The branch preserves agent:&lt;id>:global for launch after listing the selected agent's global row. (src/cli/resume-cli.runtime.ts:121, c92a3cb9b3db)
  • Gateway boundary contract: TUI history converts the global sentinel into a request with the separately selected agent ID; this is the ownership boundary the new flow must prove. (src/tui/tui-session-actions.ts:418, 499d81cdbdad)
  • Prior P1 remains unproven: The new test mocks both the Gateway client and runTui, then only checks the qualified string passed into that mock; the complementary TUI test only calls the key resolver. (src/cli/resume-cli.test.ts:182, c92a3cb9b3db)
  • Feature provenance: The current TUI ownership flow dates to Peter Steinberger's current-main refactor; this PR's six commits, including the latest purported proof commit, are also by the same author. (src/tui/tui.ts:162, 7b076155d09f)

Likely related people:

  • steipete: Current-main blame attributes the TUI session-resolution area to Peter Steinberger, who also authored the complete resume feature stack. (role: recent TUI owner and feature author; confidence: high; commits: 7b076155d09f, c92a3cb9b3db; files: src/tui/tui.ts, src/tui/tui-session-actions.ts, src/cli/resume-cli.runtime.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add the focused Gateway/protocol regression for agent:work:global.

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 (6 earlier review cycles)
  • reviewed 2026-08-08T18:46:16.688Z sha 2d17c0f :: needs changes before merge. :: [P3] Mark the runner milestone as in progress
  • reviewed 2026-08-08T22:46:41.682Z sha eb342b0 :: found issues before merge. :: [P2] Include global sessions in resume resolution | [P2] Reject non-TTY invocations before connecting
  • reviewed 2026-08-09T01:48:03.175Z sha d5094d9 :: needs changes before merge. :: [P2] Preflight TTY before resolving a queried session | [P3] Document the active Gateway fallback for --url
  • reviewed 2026-08-09T02:41:39.640Z sha ef1143d :: found issues before merge. :: [P1] Keep global sessions agent-qualified before launching the TUI | [P3] Document the full Gateway URL precedence
  • reviewed 2026-08-09T03:41:04.913Z sha a669d61 :: found issues before merge. :: [P1] Exercise qualified global resume through the Gateway boundary | [P3] State Gateway URL precedence in order
  • reviewed 2026-08-09T04:47:36.551Z sha c92a3cb :: found issues before merge. :: [P1] Exercise qualified global resume through a Gateway operation

@steipete
steipete force-pushed the steipete/runners-m2-resume-verb branch 2 times, most recently from cc4b104 to eb342b0 Compare August 8, 2026 21:51
@steipete

steipete commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed 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 Aug 8, 2026
@steipete

steipete commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete
steipete force-pushed the steipete/runners-m2-resume-verb branch from 7e13f28 to ef1143d Compare August 9, 2026 02:23
@steipete

steipete commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. and removed P2 Normal backlog priority with limited blast radius. labels Aug 9, 2026
@steipete

steipete commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete

steipete commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@steipete steipete self-assigned this Aug 9, 2026
@steipete

steipete commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete
steipete force-pushed the steipete/runners-m2-resume-verb branch 2 times, most recently from 272147e to 4f9f79a Compare August 9, 2026 09:24
@steipete
steipete force-pushed the steipete/runners-m2-resume-verb branch from 4f9f79a to 745033a Compare August 9, 2026 09:31
@steipete
steipete merged commit 917fd92 into main Aug 9, 2026
188 of 190 checks passed
@steipete
steipete deleted the steipete/runners-m2-resume-verb branch August 9, 2026 09:52
@steipete

steipete commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 10, 2026
…claw#120664)

* feat(cli): openclaw resume attaches the TUI to a recent session

Implements docs/plan/runners.md milestone 2.

* fix(cli): resume covers global sessions and preflights TTY

* fix(cli): require a terminal before resume

* fix(cli): adapt resume gateway disconnect state

* fix(cli): preserve global resume ownership

* test(cli): prove qualified global resume crosses the gateway boundary
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation maintainer Maintainer-authored PR merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant