Skip to content

fix(cli): let interrupted session listings exit promptly - #197758

Merged
obviyus merged 5 commits into
openclaw:mainfrom
Alix-007:alix/fix-sessions-list-interrupt-20261112
Nov 12, 2026
Merged

obviyus merged 5 commits into
openclaw:mainfrom
Alix-007:alix/fix-sessions-list-interrupt-20261112

Conversation

@Alix-007

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: openclaw sessions list acknowledges interruption while waiting on an unresponsive local Gateway's model catalog, but keeps the connection alive until the launcher forcibly kills the command.

User Impact

User impact: interrupted session listings close their Gateway connection and exit normally for SIGINT/SIGTERM, without publishing a late table/JSON result or an offline-fallback warning.

Why This Change Was Made

Pass the existing command signal to the cached catalog read. Once interrupted, skip its saved-catalog fallback and final result publication. Normal unavailable-Gateway fallback and explicit offline store reads retain their current behavior.

Evidence

Product HEAD: 1c7a491f44ba3e38ea9d84b2d521752c6c6313fd; acceptance-red BASE: b48d16bf6e98f0b9c1e110548fc46b3b35f2becd.

  • Actual CLI → real Gateway/SQLite: normal clean qaRuntime builds run node openclaw.mjs sessions list through a controlling PTY. Setup persists a real session through the canonical SQLite accessor and starts the actual Gateway. The task-owned Gateway is suspended to reproduce an unresponsive connection; /proc verifies the actual CLI's established socket before Ctrl-C/SIGTERM.
  • Same frozen red/green scenarios: both BASE cases reach the launcher's emergency SIGKILL after 2035–2043 ms. HEAD exits 130/143 within 148.61 ms; its owned socket closes within 34.18 ms. No late JSON/table/warning after the existing interruption notice; no collector watchdog or owned CLI survivor. This proves the pending connection/handshake, not a held authenticated RPC reply.
  • Three controls on both revisions: normal JSON/text exit 0 with the real stored session and synthetic model; JSON capacity is 8192. Explicit --store succeeds while the Gateway is suspended and opens no Gateway socket. Config stays unchanged; Gateway cleanup succeeds.
  • Focused regression: BASE has one intended unwanted-output failure and 26 passing controls. HEAD: 44 tests / two files pass in 324.775 s: pnpm test src/commands/sessions.test.ts src/cli/program/register.status-health-sessions.test.ts --maxWorkers=1. This includes 133.686 s canonical worker preparation and SQLite fixtures. Targeted types, typed lint, formatting, normal exact-HEAD build and independent review pass.

Reproduce with the unchanged collector: python3 sessions-read-proof-v2.py CHECKOUT FRESH_OUTPUT NODE26 EXPECTATION. Environment and observations, BASE receipt, HEAD receipt, actual output, and independent review.

Production +9/−0 lines; tests +22/−0 lines, two files. Uses the existing command/RPC lifetime; no new configuration, protocol/schema, permission, dependency or migration requirement. Upstream CI is checked after publication.

Not tested: holding a completed authenticated catalog reply, provider/model execution, production user data, Windows/macOS or production load. Native proof covers a pending real connection; regression tests separately cover cancellation rejection, fallback and public output.

@clawsweeper

clawsweeper Bot commented Nov 12, 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 commands Command implementations size: XS labels Nov 12, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 12, 2026
@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Passes command cancellation to session-list catalog requests and suppresses fallback warnings and results after interruption.

Example: Send SIGINT to openclaw sessions list --json while its local Gateway connection is unresponsive.

  • Before: The command acknowledges interruption but retains the connection until the launcher kills it.
  • After: The connection closes and the command exits 130 without printing session JSON or a fallback warning.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused, useful cancellation repair with inspected shipped-CLI evidence and no remaining findings; pending CI remains the ordinary landing gate.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): Inspected built-CLI receipts exercise real SQLite and Gateway connection interruption on Linux, show prompt signal exits and closed sockets without late results, and retain normal listing and explicit-store controls; collaborator output additionally covers a held models.list reply, and the exercised production code is unchanged at the reviewed head.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An interrupted session listing can keep its Gateway connection alive and publish output after the user asks it to stop.
Reason: Prompt cancellation restores the established command lifetime without changing normal listing output, configuration, or storage.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current CLI cancellation bug with a focused change; the previous P2 finding is resolved, no actionable findings remain, and exact-head CI is still pending.

Priority: P2
Reviewed head: 24f87946877cdd8b9fc16a810cacb6bd51ff6b2c

Before merge

None.

Findings

None.

Agent review details

How this fits together

The sessions CLI reads stored session rows, enriches their capacity from the local Gateway or saved catalog, and renders JSON or a terminal table; its existing command scope supplies cancellation.

flowchart TD
  A[Sessions CLI] --> B[Stored session rows]
  A --> C[Command cancellation signal]
  B --> D[Catalog enrichment]
  C --> D
  D --> E[Gateway or saved catalog]
  D --> F[JSON or terminal table]
Loading

Technical review

Best possible solution:

Use the existing command signal and Gateway cleanup owner, preserving ordinary offline fallback while stopping interrupted result publication.

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

Inspected contributor receipts reproduce the failure on the pinned base, and current-main source retains the same uncancelled request path; no target code was executed during this review.

Is this the best way to solve the issue?

The change repairs the caller’s missing cancellation propagation using existing owners, with a focused regression for unwanted output and no additional runtime machinery.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Gateway catalog enrichment and offline fallback keeps the original intent (8eefd33: The merged reporting repair uses the local Gateway’s prepared catalog for accurate context capacity and retains saved facts when unavailable.)
  • Final session result publication keeps the original intent (828b6be: Session listing output was bounded while preserving explicit full-output behavior; the cancellation guard leaves those normal results intact.)
  • Existing session regression coverage keeps the original intent (test(core): remove low-value tests (batch d169) #174192: Earlier test cleanup consolidated fixtures while retaining distinct reporting and storage contracts; this change extends the existing Gateway-state cases.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Pinned production change: The introduced diff forwards the existing signal to models.list, skips saved-catalog fallback on cancellation, and checks cancellation before publishing results. (src/commands/sessions.ts:298, 24f87946877c)
  • Current-main behavior and provenance: Current main still calls models.list without the command signal and unconditionally warns and loads the saved catalog on rejection; the catalog path appears to date to the merged context-reporting repair fix(status): correct stale context limits after model discovery #165991. (src/commands/sessions.ts:293, b46197029a3a)
  • Existing transport owns cleanup: callGateway rejects an already-aborted signal and, on later abort, removes listeners and stops its Gateway client before settling the request. (src/gateway/call.ts:632, 24f87946877c)
  • Previous finding resolved: The latest commit replaces the void-returning cast with an actual Error rejection and an explicitly interrupted work scope, removing the unintended destructuring TypeError. (src/commands/sessions.test.ts:291, 24f87946877c)
  • Inspected shipped CLI proof: The linked EVIDENCE.md, collector, and base/head receipts exercise the built CLI against real isolated SQLite and a suspended real Gateway: base requires launcher termination, while the fixed CLI exits 130/143, closes its socket, and emits no late result; normal text, JSON, and explicit-store controls pass. (head-receipt.json, c82e62dcab44)
  • Proof remains applicable: Production code is unchanged between the exercised product head and the reviewed head; intervening changes are confined to tests. (src/commands/sessions.ts, 24f87946877c)

Likely related people:

  • Mike: Raw commit 8eefd33 adds src/commands/sessions.ts:385 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 8eefd336a473; files: src/commands/sessions.ts)

PR surface

Source +9, Tests -1. Total +8 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 9 0 +9
Tests 1 22 23 -1
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 31 23 +8

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production versus test LOC Production +9/-0; tests +22/-23 The production growth connects existing cancellation and suppresses interrupted output; the regression extends an existing Gateway-state table.

Labels

Label changes:

  • 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.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: A bounded CLI read can retain its connection and require forced termination after interruption.
  • 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.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (4 earlier review cycles)
  • reviewed 2026-11-12T13:57:42.841Z sha 1c7a491 :: needs maintainer review before merge. :: none
  • reviewed 2026-11-12T15:04:59.424Z sha 1d2717e :: needs maintainer review before merge. :: none
  • reviewed 2026-11-12T15:41:14.079Z sha 5342ea9 :: needs maintainer review before merge. :: none
  • reviewed 2026-11-12T15:54:57.285Z sha 97fa6fa :: needs changes before merge. :: [P2] Reject the interrupted Gateway mock with a real Error

Reviewed November 12, 2026, 11:09 AM ET / 16:09 UTC (Revision 5).

@obviyus

obviyus commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

Proof on the built CLI (node openclaw.mjs sessions list), secretless node:24.22.1 container, one saved session row. A local stand-in Gateway writes a normal gateway lock and speaks the real protocol frames, but holds the models.list reply for 30 s. The signal is sent once the stand-in has received models.list.

main (b48d16b, the PR base):

$ openclaw sessions list            # SIGINT
exit=137 after 3 s   (launcher force-killed the child)
$ openclaw sessions list --json     # SIGTERM
exit=137 after 3 s   (launcher force-killed the child)
### with OPENCLAW_NO_RESPAWN=1 (no launcher parent)
$ openclaw sessions list            # SIGINT
exit=130 after 10 s
Command interrupted by SIGINT. Waiting for cleanup before exiting.
Could not read the active Gateway model catalog; showing configured or last verified capacity. Retry when the Gateway is reachable.
Session store: ...  Sessions listed: 1  [full table printed]
$ openclaw sessions list --json     # SIGTERM
exit=143 after 10 s
Command interrupted by SIGTERM. Waiting for cleanup before exiting.
Could not read the active Gateway model catalog; ...
{ "count": 1, "sessions": [ ... ] }

this PR:

$ openclaw sessions list            # SIGINT
exit=130 after 1 s
Command interrupted by SIGINT. Waiting for cleanup before exiting.
$ openclaw sessions list --json     # SIGTERM
exit=143 after 2 s
Command interrupted by SIGTERM. Waiting for cleanup before exiting.
### with OPENCLAW_NO_RESPAWN=1
SIGINT: exit=130 after 1 s, same single line, no table
SIGTERM --json: exit=143 after 1 s, same single line, no JSON

Controls, same output on main and this PR:

  • Uninterrupted, stand-in answers at once: same table, 1.2k/41k from the Gateway catalog, no warning, exit 0.
  • Lock owner alive but its Gateway port refuses connections: the catalog warning, then the table from the saved catalog, exit 0.
  • sessions list --store <db>: the same table, no Gateway call, exit 0.

Tests: folded the new case into the existing Gateway-state it.each (interrupted); net test lines vs main are 0 or less. It fails on main and passes here.

@obviyus

obviyus commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Nov 12, 2026
@obviyus

obviyus commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 12, 2026
@obviyus

obviyus commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Nov 12, 2026
@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 status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 12, 2026
@obviyus

obviyus commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. 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. and removed 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. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 12, 2026
@obviyus
obviyus merged commit 548b834 into openclaw:main Nov 12, 2026
122 of 123 checks passed
@obviyus

obviyus commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

Landed in 548b834. Thanks @Alix-007.

@Alix-007

Copy link
Copy Markdown
Contributor Author

Thanks @obviyus for checking the held catalog reply and offline controls, and folding the regression into the existing table!

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 13, 2026
…7758)

fix(sessions): stop the Gateway catalog read when sessions list is interrupted

openclaw sessions list noticed Ctrl-C or SIGTERM while waiting on the active Gateway model catalog but kept the request open. Under the normal launcher it was force-killed with exit 137; without respawn it waited for the reply and then printed the catalog warning and the full table or JSON after the interrupt. The catalog request now takes the command's abort signal, and an interrupt skips the fallback warning and output. Uninterrupted listings, an unreachable Gateway and --store reads are unchanged. No new text.

Evidence: the built CLI in a secretless node:24.22.1 container with one saved session and a stand-in Gateway that holds models.list for 30 s. On main the launcher killed the command with exit 137, and with OPENCLAW_NO_RESPAWN=1 it printed the warning and the full table or JSON after the interrupt. With this change every run exits 130 or 143 within 1-2 s and prints only the existing interrupt line. An uninterrupted list, a refused Gateway connection and --store behave the same on both. The folded regression fails on main, at -1 net test lines. Details: openclaw#197758 (comment).

Thanks @Alix-007.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S 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.

2 participants