Repository navigation
fix(cli): stop image output after accepted interrupts - #191176
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 forwards CLI cancellation to image providers and discards late results before output writes begin. Example: Run image edit with --output portrait.png, then press Ctrl+C while the provider is responding.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a current image CLI cancellation defect with a focused change and no actionable findings; normal CI gates remain pending. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe inference CLI resolves image options and agent configuration, calls the shared generation runtime, and publishes returned image buffers through the existing atomic file writer. flowchart LR
A[Image CLI command] --> B[Image generation runtime]
C[CLI work scope] --> B
B --> D[Provider adapter]
D --> E[Cancellation check]
C --> E
E --> F[Atomic output writer]
Technical reviewBest possible solution: Merge the focused cancellation fix once the normal exact-head CI gates pass, retaining the existing atomic writer and already-started-write behavior. Do we have a high-confidence way to reproduce the issue? The supplied built-CLI comparison reproduces overwrites after acknowledged SIGINT, and current-main source retains the same missing cancellation boundary; no target code was executed during this review. Is this the best way to solve the issue? This is the smallest complete fix: reuse the CLI-owned signal for cooperative provider cancellation and reject noncooperating late results before entering the existing output writer. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 35b1636f135b. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +6, Tests 0, Docs 0. Total +6 across 3 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes: No label changes. Label justifications:
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 2, 2026, 11:00 AM ET / 16:00 UTC (Revision 2). |
Independent built-CLI proofCandidate: Linux arm64, secretless Real commands: The local LiteLLM-compatible HTTP fixture fully receives the actual image-generation or multipart edit request, then holds its response. The driver sends SIGINT to the CLI foreground process group and waits for the CLI's own acknowledgement, "Command interrupted by SIGINT. Waiting for cleanup before exiting." Only after that acknowledgement does the fixture release its successful image response. This is a request/acknowledgement barrier, not a cancellation timer or a private lifecycle injection.
All cancelled commands exit 130. Both main repeats nevertheless overwrite the file after accepting cancellation. Both candidate repeats preserve the original bytes, even though the fixture releases its response after the acknowledgement. The cooperative HTTP cancellation and the late-result publication guard are both exercised: the runtime proof checks the real HTTP path; the focused regression returns a successful image from a provider after its work scope has begun closing. SHA-256: Focused checks: 109 tests passed in Simplification: reused the existing edit-options fixture for its normal/cancelled variants, removed duplicated cancellation setup and the test-line allocation. Production +6/-0, tests +56/-56 (net 0), docs +1/-1 against the merge base. No new configuration, API, SDK surface or compatibility reader. Original fix and contributor credit retained: @zhangguiping-xydt. Scope: interrupts accepted before output publication begins; this does not roll back an output write already underway. Normal generation/editing and the returned image bytes are unchanged. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed in 1dc0ebf. Thanks @zhangguiping-xydt. Cancelling image generation with Ctrl-C no longer overwrites the existing file. |
fix(cli): keep the existing image file when generation is cancelled with Ctrl-C When an image generation or edit was cancelled with Ctrl-C (SIGINT), the CLI acknowledged the cancel but still wrote the late response over the existing output file. The output is no longer written after an accepted cancel, so the original file is kept. Uninterrupted runs write as before. Evidence: built CLI in secretless Node 24.22.1 Docker with a delayed local image endpoint. Main overwrote existing generation and edit outputs twice after acknowledging SIGINT; with this change the original file hashes were kept twice. Uninterrupted controls wrote the expected PNG. Details: openclaw#191176 (comment). Thanks @zhangguiping-xydt. Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit 1dc0ebf) Co-authored-by: Ayaan Zaidi <[email protected]> Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit cf6b1de3f68c8778acd13ca68c74d67da56a0a38) (cherry picked from commit d52c35543570add20491bebaf3598cdcc2ef09dd)
What Problem This Solves
openclaw infer image generateandimage editcan create or overwrite an output file after the CLI has accepted Ctrl+C.User Impact
Cancelling image generation/editing now discards late provider results before output writes begin. Already-started writes retain their existing atomic publication behavior. Normal output, model selection and image bytes are unchanged.
Why This Change Was Made
Pass the existing CLI work-scope signal to image generation and check it before dispatch and after the provider returns, before publishing outputs. No new lifecycle owner, configuration or API. Original fix by @zhangguiping-xydt; their commits are retained.
Evidence
Independent built-CLI before/after proof and hashes.
Built main
f33f9c1c53f911816103cb6e04b67d52be4369a2and candidate production in secretless Linux/Node 24.22.1 isolation. A local LiteLLM-compatible HTTP fixture receives a real generation/edit request, holds its response until the CLI acknowledges SIGINT, then releases the image. Both commands start with an existing destination.The runtime proof uses the actual built CLI and HTTP adapter, not a private helper or paid provider. The focused test separately returns a result after its work scope closes, protecting the noncooperating-provider boundary.
Merge Danger
Two-way door: a revert fully restores previous behavior; no persisted-state migration or public contract changes. Blast radius is local image generation/editing cancellation before output publication. This does not roll back a write already underway.