Repository navigation
fix(devices): stop pending list and preview reads when interrupted - #197110
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR cancels interrupted device list and approval-preview reads and suppresses output after cancellation. Example: Press Ctrl-C while
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete 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 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherDevice 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]
Technical reviewBest 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
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +31. Total +31 across 2 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed November 11, 2026, 3:29 AM ET / 08:29 UTC (Revision 2). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Proof for head ae221ff (main merged in, plus two commits on top of the contributor commit). What changed on top of the contributor commit:
Setup:
Controls, same on main and this PR in every run: an uninterrupted Run logs |
|
Thanks @obviyus for trimming the abort handling, keeping interrupted reads quiet, and validating the full pairing flow! |
…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]>
What Problem This Solves
Fixes: interrupting a pending
devices listor 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.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.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
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/greenrespectively.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.