Skip to content

fix(devices): stop pending list and preview reads when interrupted - #197110

Merged
obviyus merged 4 commits into
openclaw:mainfrom
Alix-007:alix/fix-devices-read-cancellation-20261111
Nov 11, 2026
Merged

obviyus merged 4 commits into
openclaw:mainfrom
Alix-007:alix/fix-devices-read-cancellation-20261111

Conversation

@Alix-007

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: interrupting a pending devices list or implicit approval preview acknowledges Ctrl-C but leaves its Gateway read alive until the CLI launcher kills it.

User Impact

User impact: Pending read-only device commands now stop their connection/request and exit with the normal SIGINT/SIGTERM status. Implicit approval remains preview-only. Already-admitted device mutations still return their operation receipt before exiting. No new configuration, protocol, schema, default, permission or migration choices.

Why This Change Was Made

Forward the current async-work signal only at the public list and preview read owners. Check cancellation before dispatch, before local fallback, and before publishing output. Leave mutation calls and their preparatory reads on the existing response-custody path.

Evidence

Product head: 55a85add8f781458f054a661a52043616cef8d69; acceptance-red base: 83872e599d5720c0bc97d313283a2bc245046699.

  • Actual CLI / PTY / WebSocket: the frozen collector runs the normally built CLI with its normal launcher/respawn policy. A compatible synthetic loopback peer holds connect or device.pair.list; Ctrl-C is sent through the controlling PTY, and SIGTERM to the owned process group. All 11/11 expected outcomes pass on each version.
  • Acceptance red → green: six held read/preview cases acknowledge interruption on BASE, then require the CLI's own emergency SIGKILL after 2047.09–2054.92 ms; the harness watchdog never fires. HEAD naturally exits 130/143, at most 158.87 ms after interruption, with peer closure at most 49.05 ms, no late successful list/preview JSON, and no surviving owned process before cleanup. HEAD emits the normal cancellation JSON, rather than a success payload.
  • Legal controls: ordinary lists exit 0 with exact empty-list JSON; approval preview exits its documented 1 with the selected request and sends no approval RPC. An ordinary remove returns its receipt; an already-admitted remove interrupted before the peer releases its delayed response still prints that receipt exactly once and exits 130. No real Gateway state mutation is claimed.
  • Checks: node scripts/run-vitest.mjs src/cli/devices-cli.test.ts src/cli/devices-cli.gateway.test.ts --maxWorkers=1: 69 passed, 54.286 seconds command wall time. Targeted types, lint, format, staged test-line budget, changed-source mock inspection, normal CLI build and fresh independent adversarial review pass; findings: None. The 69 tests include the existing Gateway integration surface and cancellation/fallback/mutation-custody controls. Canonical worker preparation and CLI fixture startup account for the command exceeding 30 seconds; no test timeout was increased.

Inspect the frozen collector, paired receipts, actual outputs, checks and independent review. Evidence assets are outside the product branch.

Replay, scope and limitations
python3 devices-read-cancel-proof-v3.py CHECKOUT NEW_OUTPUT NODE26 EXPECTATION

frozen Python collector 0e19d3a84fabf6c495fb6a7af2d0a469ada670ccecf9761349c30dc2b756a1d5 and compatible peer 9da73ac2f99d3afcea3fff7d80bce9c401920d5fc62c4c216c921424de9eb383; checkout and expectation selectors only. Use clean normally built BASE/HEAD checkouts, a fresh output directory, and red / green respectively.

Four files: production +36/-19, tests +51/-0 (net 51 LF) and an exact own-regression allocation. The existing private device RPC wrapper moves to a small sibling to keep the oversized runtime within its line-count growth ratchet; its existing timeout/scope/transport policy is preserved. The complete device CLI decision surface was inspected: list, implicit/latest preview, local fallback, explicit approval/admin retry, clear, token rotation/revocation, remove, reject and rename. Only read-only public list/preview acquires cancellation; mutation receipt custody stays unchanged. Existing mock factories and their ledger are unchanged; full repository mock checking is left to CI.

Cleanup: The collector waits for the owned CLI process group to be empty and observes peer disconnect before stopping its task-owned protocol peer. Config bytes are checked unchanged. It uses allowlisted child environments and isolated HOME/config/state/workspace; no real provider, model, channel, device or user data is used. Fixtures remain inspectable.

Not tested: real Gateway device storage/authentication/mutation effects, real devices, Windows/macOS, external channels/providers, and the full repository CI matrix.

@clawsweeper

clawsweeper Bot commented Nov 11, 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 cli CLI command changes size: S labels Nov 11, 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 11, 2026
@clawsweeper

clawsweeper Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR cancels interrupted device list and approval-preview reads and suppresses output after cancellation.

Example: Press Ctrl-C while openclaw devices list --json awaits a Gateway response.

  • Before: The command acknowledges interruption but retains its connection until forcibly killed.
  • After: The command closes its connection, exits 130, and prints no late result or cancellation error.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Focused, correct, and proven through shipped entry points; the final diff retains no automated regression specifically covering device-read cancellation.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): The complete current-head collaborator logs exercise built device list and preview commands through a real PTY, real authenticated Gateway, and real WebSocket proxy withholding actual responses; cancellation closes sockets, exits 130, suppresses late output, and preserves ordinary read, fallback, and explicit-approval controls.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An interrupted pending JSON device list or approval preview remains alive until the launcher forcibly terminates it.
Reason: The change restores expected interruption behavior, follows an established read-only CLI pattern, and has collaborator-supported current-head runtime evidence.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current device CLI cancellation bug with a focused change and current-head runtime evidence; no introduced correctness or security defect was found.

Priority: P2
Reviewed head: ae221ff7776eb3a3f5987d76008226d1284be380

Before merge

None.

Findings

None.

Agent review details

How this fits together

Device CLI commands use the shared Gateway RPC transport; list and preview reads now receive the command scope's cancellation signal, while mutation calls retain response custody.

flowchart LR
  A[Device CLI command] --> B[List or preview read]
  C[Command cancellation scope] --> B
  B --> D[Shared Gateway RPC transport]
  D --> E[Gateway device list]
  B --> F[Existing local fallback]
  B --> G[Output unless canceled]
Loading

Technical review

Best possible solution:

Keep cancellation at the public read owners, reuse shared transport teardown, and preserve mutation receipt handling.

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

Current-main source omits cancellation propagation, and supplied base/head PTY logs demonstrate the failure and repair through the real CLI and Gateway; this review ran no target code.

Is this the best way to solve the issue?

The smallest complete fix forwards the existing command signal into list/preview reads and suppresses their canceled outcomes, using the existing transport teardown and leaving mutation calls unchanged.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Device Gateway transport wrapper keeps the original intent (3856b4f: Consolidate CLI RPC transport while preserving caller-specific timeout, scopes, and authentication policy.)
  • Read-only shared-state access keeps the original intent (ab9b40d: Prevent one-shot node/device RPC commands from becoming competing writable shared-state owners.)
  • Quiet read cancellation keeps the original intent (3031a32: Read-only commands should print no reply or error after Ctrl-C, while write-capable calls retain their receipts.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Vincent Koc: Raw commit fe25ed2 adds src/cli/devices-cli.runtime.ts:659 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: fe25ed214ef5; files: src/cli/devices-cli.runtime.ts)
  • Ayaan Zaidi: Raw commit 3031a32 adds src/cli/gateway-cli/register.ts:71 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 3031a32908b4; files: src/cli/gateway-cli/register.ts)

PR surface

Source +31. Total +31 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 51 20 +31
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 51 20 +31

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.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • remove rating: 🦞 diamond lobster: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P2: Interrupted JSON device reads retain a pending connection until forced termination; the affected terminal workflow has limited blast radius.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rank-up moves

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

  • Add one focused command-boundary cancellation regression that fails on the base and protects quiet list/preview completion on the head.

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 (1 earlier review cycle)
  • reviewed 2026-11-11T07:49:24.517Z sha 55a85ad :: needs maintainer review before merge. :: none

Reviewed November 11, 2026, 3:29 AM ET / 08:29 UTC (Revision 2).

@obviyus

obviyus commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@obviyus

obviyus commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

Proof for head ae221ff (main merged in, plus two commits on top of the contributor commit).

What changed on top of the contributor commit:

  • Removed the extra abort checks in the fallback path and the callers. Only the read-only list call takes the signal (devices list and the devices approve preview). An explicit approve and reject are unchanged.
  • The helper move to devices-cli-gateway.ts stays. devices-cli.runtime.ts is on the max-lines ratchet list and cannot grow.
  • Added readUnlessAborted next to the helper. Before it, an interrupted read still printed [openclaw] The CLI command failed. (and a CLI stopping (SIGINT) JSON error with --json) after Ctrl-C. It follows the pattern from fix(cli): gateway usage-cost and stability print nothing after Ctrl+C #197019: Ctrl-C owns the exit, so nothing is printed. No new text.
  • Tests: the new tests and the test-lines allocation file are removed (net 0). devices-cli.test.ts and devices-cli.lazy.test.ts pass (46 tests).

Setup: node:24.22.1 container with no secrets. Main (6ff8c86) and this head were each built with pnpm build and each run twice. Each run starts a real openclaw.mjs gateway run (token auth). A real pending request comes from a headless openclaw node run on the LAN address. A stand-in WebSocket proxy sits in front and withholds the Gateway's device.pair.list response. The CLI runs in a real PTY (Python pty.fork); Ctrl-C is written to the PTY about 1 s after the response is withheld.

PTY case (Ctrl-C while the read is pending) main run 1 / run 2 this PR run 1 / run 2
devices list --json not exited; force-killed (SIGKILL) about 2.1 s later, socket closed only then (1006) exit 130 in 0.02 / 0.03 s, socket closed normally (1005), no output after the interrupt notice
devices approve --json (preview) not exited; force-killed about 2.1 s later, socket closed only then (1006) exit 130 in 0.03 / 0.03 s, socket closed normally (1005), no output after the interrupt notice
devices list / devices approve with the TTY spinner the spinner handles Ctrl-C: Canceled, exit 0 same

Controls, same on main and this PR in every run: an uninterrupted devices list gives the same table (only the Age column differs). The unreachable-Gateway local fallback prints the existing notice and the same pending table. devices approve <requestId> returns Approved <device> (<request>). No leftover CLI processes.

Run logs
[main-1] list-sigint: Ctrl-C sent at 1.91s while device.pair.list response is held
[main-1] list-sigint: exit=0 0.01s after Ctrl-C
[main-1] list-sigint: output after Ctrl-C (spinner frames dropped): 't◇  Canceled'
[main-1] list-sigint: proxy log: [proxy +0.00s] listening 19300 -> 19200 | [proxy +1.69s] client connected / | [proxy +1.71s] holding response for device.pair.list id=2:c4d13fcb-7f81-413a-9a60-a769d378fd5a | [proxy +1.73s] gateway answered device.pair.list id=2:c4d13fcb-7f81-413a-9a60-a769d378fd5a ok=true; withheld | [proxy +2.90s] client socket closed code=1006 | [proxy +2.90s] gateway socket closed code=1005
[main-1] list-json-sigint: Ctrl-C sent at 1.83s while device.pair.list response is held
[main-1] list-json-sigint: exit=-9 2.09s after Ctrl-C
[main-1] list-json-sigint: output after Ctrl-C (spinner frames dropped): '^CCommand interrupted by SIGINT. Waiting for cleanup before exiting.'
[main-1] list-json-sigint: proxy log: [proxy +0.00s] listening 19300 -> 19200 | [proxy +1.68s] client connected / | [proxy +1.69s] holding response for device.pair.list id=2:6c88edec-142c-4ebc-9cee-efb179860ac2 | [proxy +1.69s] gateway answered device.pair.list id=2:6c88edec-142c-4ebc-9cee-efb179860ac2 ok=true; withheld | [proxy +4.90s] client socket closed code=1006 | [proxy +4.90s] gateway socket closed code=1005
[main-1] approve-preview-sigint: Ctrl-C sent at 1.76s while device.pair.list response is held
[main-1] approve-preview-sigint: exit=0 0.01s after Ctrl-C
[main-1] approve-preview-sigint: output after Ctrl-C (spinner frames dropped): 't◇  Canceled'
[main-1] approve-preview-sigint: proxy log: [proxy +0.00s] listening 19300 -> 19200 | [proxy +1.74s] client connected / | [proxy +1.75s] holding response for device.pair.list id=2:6be1c83c-4864-4cf1-a4a8-c8f6d91a4199 | [proxy +1.75s] gateway answered device.pair.list id=2:6be1c83c-4864-4cf1-a4a8-c8f6d91a4199 ok=true; withheld | [proxy +2.79s] client socket closed code=1006 | [proxy +2.79s] gateway socket closed code=1005
[main-1] approve-preview-json-sigint: Ctrl-C sent at 1.72s while device.pair.list response is held
[main-1] approve-preview-json-sigint: exit=-9 2.15s after Ctrl-C
[main-1] approve-preview-json-sigint: output after Ctrl-C (spinner frames dropped): '^CCommand interrupted by SIGINT. Waiting for cleanup before exiting.'
[main-1] approve-preview-json-sigint: proxy log: [proxy +0.00s] listening 19300 -> 19200 | [proxy +1.71s] client connected / | [proxy +1.72s] holding response for device.pair.list id=2:08414cda-9d18-4f1b-871c-c6259f4bb11b | [proxy +1.72s] gateway answered device.pair.list id=2:08414cda-9d18-4f1b-871c-c6259f4bb11b ok=true; withheld | [proxy +4.87s] client socket closed code=1006 | [proxy +4.87s] gateway socket closed code=1005
[main-1] control list --json: exit=0 pending=1 paired=0
[main-1] control list (text): exit=0 lines=8
[main-1] control unreachable-Gateway fallback: exit=0 notice=True pending=True
[main-1] control approve accepted: exit=0 ['Approved 2a0c0d28d9e8a2cbb1a419f0aa295511cab1de90a668f3f7f55c225540cd0704 (ecf0e2de-c887-4da9-8b43-b92f8332f0c7)']
[main-1] leftover openclaw processes: 0
[main-2] list-sigint: Ctrl-C sent at 1.85s while device.pair.list response is held
[main-2] list-sigint: exit=0 0.01s after Ctrl-C
[main-2] list-sigint: output after Ctrl-C (spinner frames dropped): 't◇  Canceled'
[main-2] list-sigint: proxy log: [proxy +0.00s] listening 19300 -> 19200 | [proxy +1.65s] client connected / | [proxy +1.67s] holding response for device.pair.list id=2:3d1a4b70-388a-4378-8b98-d38c840d34bd | [proxy +1.69s] gateway answered device.pair.list id=2:3d1a4b70-388a-4378-8b98-d38c840d34bd ok=true; withheld | [proxy +2.84s] client socket closed code=1006 | [proxy +2.84s] gateway socket closed code=1005
[main-2] list-json-sigint: Ctrl-C sent at 1.65s while device.pair.list response is held
[main-2] list-json-sigint: exit=-9 2.14s after Ctrl-C
[main-2] list-json-sigint: output after Ctrl-C (spinner frames dropped): '^CCommand interrupted by SIGINT. Waiting for cleanup before exiting.'
[main-2] list-json-sigint: proxy log: [proxy +0.00s] listening 19300 -> 19200 | [proxy +1.61s] client connected / | [proxy +1.62s] holding response for device.pair.list id=2:8fe3113a-0139-4288-92a0-1e1796b709be | [proxy +1.62s] gateway answered device.pair.list id=2:8fe3113a-0139-4288-92a0-1e1796b709be ok=true; withheld | [proxy +4.77s] client socket closed code=1006 | [proxy +4.77s] gateway socket closed code=1005
[main-2] approve-preview-sigint: Ctrl-C sent at 1.79s while device.pair.list response is held
[main-2] approve-preview-sigint: exit=0 0.02s after Ctrl-C
[main-2] approve-preview-sigint: output after Ctrl-C (spinner frames dropped): 't◇  Canceled'
[main-2] approve-preview-sigint: proxy log: [proxy +0.00s] listening 19300 -> 19200 | [proxy +1.79s] client connected / | [proxy +1.80s] holding response for device.pair.list id=2:7ab42df6-22bc-4c9f-bab1-5e0df26f17a8 | [proxy +1.80s] gateway answered device.pair.list id=2:7ab42df6-22bc-4c9f-bab1-5e0df26f17a8 ok=true; withheld | [proxy +2.94s] client socket closed code=1006 | [proxy +2.94s] gateway socket closed code=1005
[main-2] approve-preview-json-sigint: Ctrl-C sent at 1.84s while device.pair.list response is held
[main-2] approve-preview-json-sigint: exit=-9 2.10s after Ctrl-C
[main-2] approve-preview-json-sigint: output after Ctrl-C (spinner frames dropped): '^CCommand interrupted by SIGINT. Waiting for cleanup before exiting.'
[main-2] approve-preview-json-sigint: proxy log: [proxy +0.00s] listening 19300 -> 19200 | [proxy +1.76s] client connected / | [proxy +1.76s] holding response for device.pair.list id=2:0e630af6-198e-494c-9dfc-997699f93e01 | [proxy +1.77s] gateway answered device.pair.list id=2:0e630af6-198e-494c-9dfc-997699f93e01 ok=true; withheld | [proxy +5.06s] client socket closed code=1006 | [proxy +5.07s] gateway socket closed code=1005
[main-2] control list --json: exit=0 pending=1 paired=0
[main-2] control list (text): exit=0 lines=8
[main-2] control unreachable-Gateway fallback: exit=0 notice=True pending=True
[main-2] control approve accepted: exit=0 ['Approved 157c1e6942c2d9108e780964efb1c12d17c588990521b7e0f6597ae47468f0e6 (439fd054-c7b1-4596-9d97-8a62fce70166)']
[main-2] leftover openclaw processes: 0
[cand-1] list-sigint: Ctrl-C sent at 1.89s while device.pair.list response is held
[cand-1] list-sigint: exit=0 0.01s after Ctrl-C
[cand-1] list-sigint: output after Ctrl-C (spinner frames dropped): 't◇  Canceled'
[cand-1] list-sigint: proxy log: [proxy +0.00s] listening 19300 -> 19200 | [proxy +1.62s] client connected / | [proxy +1.64s] holding response for device.pair.list id=2:4ae52d3e-47dc-4f75-8d4a-542e6435773b | [proxy +1.66s] gateway answered device.pair.list id=2:4ae52d3e-47dc-4f75-8d4a-542e6435773b ok=true; withheld | [proxy +2.88s] client socket closed code=1006 | [proxy +2.88s] gateway socket closed code=1005
[cand-1] list-json-sigint: Ctrl-C sent at 1.96s while device.pair.list response is held
[cand-1] list-json-sigint: exit=130 0.02s after Ctrl-C
[cand-1] list-json-sigint: output after Ctrl-C (spinner frames dropped): '^CCommand interrupted by SIGINT. Waiting for cleanup before exiting. \x1b[<u\x1b[>4;0m'
[cand-1] list-json-sigint: proxy log: [proxy +0.00s] listening 19300 -> 19200 | [proxy +1.80s] client connected / | [proxy +1.81s] holding response for device.pair.list id=2:29637459-b120-47c0-b498-b4887594eba4 | [proxy +1.81s] gateway answered device.pair.list id=2:29637459-b120-47c0-b498-b4887594eba4 ok=true; withheld | [proxy +3.08s] client socket closed code=1005 | [proxy +3.08s] gateway socket closed code=1005
[cand-1] approve-preview-sigint: Ctrl-C sent at 1.88s while device.pair.list response is held
[cand-1] approve-preview-sigint: exit=0 0.02s after Ctrl-C
[cand-1] approve-preview-sigint: output after Ctrl-C (spinner frames dropped): 't◇  Canceled'
[cand-1] approve-preview-sigint: proxy log: [proxy +0.00s] listening 19300 -> 19200 | [proxy +1.74s] client connected / | [proxy +1.75s] holding response for device.pair.list id=2:520abf08-b8bf-42d4-be58-875b50b7cfcf | [proxy +1.75s] gateway answered device.pair.list id=2:520abf08-b8bf-42d4-be58-875b50b7cfcf ok=true; withheld | [proxy +2.96s] client socket closed code=1006 | [proxy +2.96s] gateway socket closed code=1005
[cand-1] approve-preview-json-sigint: Ctrl-C sent at 1.92s while device.pair.list response is held
[cand-1] approve-preview-json-sigint: exit=130 0.03s after Ctrl-C
[cand-1] approve-preview-json-sigint: output after Ctrl-C (spinner frames dropped): '^CCommand interrupted by SIGINT. Waiting for cleanup before exiting. \x1b[<u\x1b[>4;0m'
[cand-1] approve-preview-json-sigint: proxy log: [proxy +0.00s] listening 19300 -> 19200 | [proxy +1.78s] client connected / | [proxy +1.78s] holding response for device.pair.list id=2:dbe16ca4-8b09-439f-bac8-e0c35828529c | [proxy +1.79s] gateway answered device.pair.list id=2:dbe16ca4-8b09-439f-bac8-e0c35828529c ok=true; withheld | [proxy +3.00s] client socket closed code=1005 | [proxy +3.01s] gateway socket closed code=1005
[cand-1] control list --json: exit=0 pending=1 paired=0
[cand-1] control list (text): exit=0 lines=8
[cand-1] control unreachable-Gateway fallback: exit=0 notice=True pending=True
[cand-1] control approve accepted: exit=0 ['Approved 0835676bb2b16f9074ab4d6d536488b5131ba0495bccd4c4189f672bd85dfd97 (752b7558-5c01-4948-939b-3fdfac315ce4)']
[cand-1] leftover openclaw processes: 0
[cand-2] list-sigint: Ctrl-C sent at 1.70s while device.pair.list response is held
[cand-2] list-sigint: exit=0 0.02s after Ctrl-C
[cand-2] list-sigint: output after Ctrl-C (spinner frames dropped): '.◇  Canceled'
[cand-2] list-sigint: proxy log: [proxy +0.00s] listening 19300 -> 19200 | [proxy +1.64s] client connected / | [proxy +1.65s] holding response for device.pair.list id=2:a9a778cb-94f4-46b0-8f76-dac1d2b871a4 | [proxy +1.66s] gateway answered device.pair.list id=2:a9a778cb-94f4-46b0-8f76-dac1d2b871a4 ok=true; withheld | [proxy +2.74s] client socket closed code=1006 | [proxy +2.75s] gateway socket closed code=1005
[cand-2] list-json-sigint: Ctrl-C sent at 1.81s while device.pair.list response is held
[cand-2] list-json-sigint: exit=130 0.03s after Ctrl-C
[cand-2] list-json-sigint: output after Ctrl-C (spinner frames dropped): '^CCommand interrupted by SIGINT. Waiting for cleanup before exiting. \x1b[<u\x1b[>4;0m'
[cand-2] list-json-sigint: proxy log: [proxy +0.00s] listening 19300 -> 19200 | [proxy +1.66s] client connected / | [proxy +1.67s] holding response for device.pair.list id=2:44d05a48-3e22-46e5-9b6b-ac0ebdaf093e | [proxy +1.67s] gateway answered device.pair.list id=2:44d05a48-3e22-46e5-9b6b-ac0ebdaf093e ok=true; withheld | [proxy +2.87s] client socket closed code=1005 | [proxy +2.87s] gateway socket closed code=1005
[cand-2] approve-preview-sigint: Ctrl-C sent at 1.81s while device.pair.list response is held
[cand-2] approve-preview-sigint: exit=0 0.02s after Ctrl-C
[cand-2] approve-preview-sigint: output after Ctrl-C (spinner frames dropped): 't◇  Canceled'
[cand-2] approve-preview-sigint: proxy log: [proxy +0.00s] listening 19300 -> 19200 | [proxy +1.71s] client connected / | [proxy +1.72s] holding response for device.pair.list id=2:2de38d6f-0d88-444c-92d1-4cd5176bc689 | [proxy +1.73s] gateway answered device.pair.list id=2:2de38d6f-0d88-444c-92d1-4cd5176bc689 ok=true; withheld | [proxy +2.92s] client socket closed code=1006 | [proxy +2.92s] gateway socket closed code=1005
[cand-2] approve-preview-json-sigint: Ctrl-C sent at 1.98s while device.pair.list response is held
[cand-2] approve-preview-json-sigint: exit=130 0.03s after Ctrl-C
[cand-2] approve-preview-json-sigint: output after Ctrl-C (spinner frames dropped): '^CCommand interrupted by SIGINT. Waiting for cleanup before exiting. \x1b[<u\x1b[>4;0m'
[cand-2] approve-preview-json-sigint: proxy log: [proxy +0.00s] listening 19300 -> 19200 | [proxy +1.61s] client connected / | [proxy +1.62s] holding response for device.pair.list id=2:0d11c858-a35a-4631-8b06-985ad053faf6 | [proxy +1.62s] gateway answered device.pair.list id=2:0d11c858-a35a-4631-8b06-985ad053faf6 ok=true; withheld | [proxy +2.96s] client socket closed code=1005 | [proxy +2.96s] gateway socket closed code=1005
[cand-2] control list --json: exit=0 pending=1 paired=0
[cand-2] control list (text): exit=0 lines=8
[cand-2] control unreachable-Gateway fallback: exit=0 notice=True pending=True
[cand-2] control approve accepted: exit=0 ['Approved 42994c2180113ee70d852a02d49401a89d5ec67a33ec942069b6c20653a2d85f (c7882e33-5afa-4ba8-8195-06031b55bf9f)']
[cand-2] leftover openclaw processes: 0

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. 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. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 11, 2026
@obviyus
obviyus merged commit f94477b into openclaw:main Nov 11, 2026
113 checks passed
@obviyus

obviyus commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator

Landed in f94477b. Thanks @Alix-007.

@Alix-007

Copy link
Copy Markdown
Contributor Author

Thanks @obviyus for trimming the abort handling, keeping interrupted reads quiet, and validating the full pairing flow!

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 12, 2026
…penclaw#197110)

fix(devices): stop pending devices reads promptly on Ctrl+C

A Ctrl+C during a pending openclaw devices list or the devices approve preview did not reach the Gateway read, so the CLI kept the socket open until it was force-killed about 2 seconds later, and could still print a failure afterwards. The read-only list and approval-preview calls now pass the command's existing abort signal and print nothing once aborted. Explicit approve and reject calls are unchanged. The gateway-call helper moves to devices-cli-gateway.ts because devices-cli.runtime.ts is held by the max-lines ratchet. No text changes.

Evidence: a real Gateway with a real pending pairing request from a headless openclaw node run, a WebSocket proxy holding the device.pair.list response and Ctrl+C sent in a real PTY, two runs each. On main devices list --json and the devices approve --json preview were force-killed about 2.1 s after Ctrl+C with the socket closing only then; with this change both exit 130 within 0.03 s with a normal close and no further output. Without --json the spinner already handles Ctrl+C on both. An uninterrupted list, the unreachable-Gateway fallback and devices approve <id> behave the same on both. Net 0 test lines. Details: openclaw#197110 (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

cli CLI command changes P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary 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