Repository navigation
fix: screen and camera capture continue after cancellation - #1007
Conversation
Propagate per-invocation cancellation through gateway, MCP, consent, countdown, and native capture paths while preserving bounded concurrent dispatch. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 4ba999dd-6583-43ea-ac04-fcbe3c881113
|
Codex review: needs real behavior proof before merge. Reviewed July 17, 2026, 7:51 PM ET / 23:51 UTC. Summary Reproducibility: yes. from source: the old public event delegate shapes shown in the diff cannot accept existing one-argument handlers after this branch changes them to token-bearing delegates. The active native-capture cancellation behavior itself is not yet demonstrated in a real runtime. Review metrics: 2 noteworthy metrics.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Copy recommended automerge instructionNext step before merge
Security Review findings
Review detailsBest possible solution: Preserve the existing public event contracts and add a separately named cancellation-aware extension path, then provide redacted current-head runtime evidence for an active camera or screen cancellation and a gateway Do we have a high-confidence way to reproduce the issue? Yes from source: the old public event delegate shapes shown in the diff cannot accept existing one-argument handlers after this branch changes them to token-bearing delegates. The active native-capture cancellation behavior itself is not yet demonstrated in a real runtime. Is this the best way to solve the issue? No. Propagating cancellation is the right direction, but replacing public handler signatures is not the narrowest maintainable solution; retain them and add an additive cancellation-aware seam. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 4518dd87ed2b. Label changesLabel changes:
Label justifications:
Evidence reviewedAcceptance criteria:
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
Review history (4 earlier review cycles)
|
The cross-repository reuse pass found no existing equivalent of The blocking issue is the pre-registration MCP cancellation design. Please replace the timing probe with a bounded pending-cancel tombstone keyed by the JSON-RPC request identity:
The current test The rest of the test audit was encouraging: registry tests use the real production registry; MCP tests invoke the real JSON-RPC bridge; WindowsNodeClient tests traverse production message dispatch; capability tests prove the token reaches production handlers. This is not a mock-only suite—the single sleep-based race test is the exception. Additional items:
This is a strong architectural direction, but the fixed 100 ms guess is a merge blocker because it leaves cancellation correctness dependent on scheduling latency. |
Replace the scheduler-dependent cancellation probe with bounded tombstones and preserve cancellation outcome semantics across registration races. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 4ba999dd-6583-43ea-ac04-fcbe3c881113
Capture the real Windows node send path and verify request-form node.invoke.cancel returns a successful cancelled payload. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 4ba999dd-6583-43ea-ac04-fcbe3c881113
|
Caleb Eden + GitHub Copilot pair-programming follow-up @shanselman Thanks for flagging the scheduler-dependent MCP cancellation window. We replaced the 100 ms probe with a bounded five-second pending-cancellation tombstone. Duplicate simultaneously active IDs remain ambiguous and cancel none. Recent-completion guards prevent late cancellation from poisoning ID reuse, and repeated notifications do not extend a tombstone’s original lifetime. Because stateless MCP HTTP has no client identity, a tombstone necessarily applies to the first later matching registration; the PR now documents and tests that limitation rather than implying complete cross-client isolation. The timing-sensitive test now uses an explicit happens-before barrier and manual time beyond the old 100 ms window. Coverage also includes TTL expiry, reuse, duplicate-ID behavior, bounded cleanup, transport/caller classification, and capability short-circuiting. We also addressed the additional review items:
Validation is green: full build; Shared tests with 2,894 passed and 31 skipped; Tray tests with 1,718 passed; 56 focused registry/MCP tests; and the targeted gateway cancellation-response test. Active physical camera/screen teardown and a live upstream gateway cancellation remain unverified and are called out explicitly in the PR description. |
The tombstone redesign is sound and the prior timing/test-authenticity blocker is resolved. Atomic consumption, TTL/caps, recent-completion anti-poisoning, ID reuse, duplicate ambiguity, deterministic eviction, manual-time tests, and request-form response assertions all checked out. The new pre-registration test can no longer pass through the wrong path because it asserts the tombstone before registration and One concrete issue remains before we are comfortable calling this uniformly above 90%: Please preserve the primary exception or safely log its diagnostic type/category before cancellation wins, and add a focused regression test covering simultaneous capture failure + cancellation. Avoid exporting raw device/user content in telemetry; a safe log category or exception type is sufficient. After that narrow fix, the remaining missing physical-camera/live-gateway proof is a disclosed residual risk rather than a code blocker. The cancellation registry and tests themselves now look merge-ready. |
@calebeden, could you make the final narrow fix on #1007? In The tombstone redesign, deterministic tests, bounded cleanup, ID-reuse behavior, and wire-response assertions all passed re-review. This is the only remaining code concern keeping paired confidence from being uniformly above 90%. Please keep the change narrow and rerun the focused capture/cancellation tests plus required build/shared/tray validation. |
Keep a primary preview capture exception when cancellation races cleanup, while retaining cancellation when no capture failure exists. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 4ba999dd-6583-43ea-ac04-fcbe3c881113
|
Caleb Eden + GitHub Copilot pair-programming follow-up @shanselman Thanks for catching this. Added focused regression coverage for both branches:
Validation is green: full build; Shared tests with 2,894 passed and 31 skipped; Tray tests with 1,720 passed; and 2 focused race tests. A final dual-model review found no substantive issues and confirmed the masking concern is resolved. |
Co-authored-by: Copilot App <[email protected]> Copilot-Session: 4ba999dd-6583-43ea-ac04-fcbe3c881113
Related: #357
Additional instructions
MUST: Keep Allow edits from maintainers enabled for this PR so maintainers can help update the branch when needed.
What Problem This Solves
Fixes an issue where cancelled or timed-out screen and camera requests could continue capturing, and queued camera work could begin after its caller had already stopped waiting.
Why This Change Was Made
This revisits the cancellation work attempted in closed PR #403 on top of the bounded concurrent dispatch architecture merged in #426. It preserves #426's receive loop and eight-invocation limit, keeps cancellation tokens outside serializable request DTOs, and supports both gateway
node.invoke.canceland MCPnotifications/cancelledwithout adding transport deadline policy.Cancellation propagates through consent, countdown, queued camera admission, native capture waits, recording, and cleanup. MCP cancellation that arrives before registration is retained as a bounded five-second tombstone and consumed before capability execution, replacing the previous scheduler-dependent 100 ms probe. JSON-RPC request IDs match by decoded string or normalized arbitrary-precision numeric value while preserving string-versus-number identity. Completion remains the linearization point: once execution commits completion, later cancellation is too late.
Duplicate simultaneously active MCP IDs remain fail-safe and cancel none. Because stateless MCP HTTP has no client identity, a pre-registration tombstone consumes the first later matching ID; complete cross-client isolation would require a transport/protocol identity change and is outside this fix.
Gateway completion notifications isolate each subscriber so a faulty event handler cannot suppress later subscribers or the already-committed wire response. MCP cancellation outcome state is captured before invocation registration disposal. When camera preview failure races cancellation, the primary capture/hardware exception is preserved for diagnosis; cancellation remains the outcome when no primary capture failure exists.
User Impact
Cancelled screen recordings, camera clips, snapshots, consent waits, countdowns, and queued camera requests now stop cooperatively instead of continuing after the caller leaves. Gateway and local MCP callers receive a stable
cancelledoutcome when cancellation wins, equivalent JSON-RPC ID encodings cancel the same request, and completion observers cannot prevent gateway callers from receiving their response.Evidence
{ cancelled: true }, and response delivery when anInvokeCompletedsubscriber throws.camera.clipcall returncancelledbefore consent or hardware entry.Change Type
Scope
winnodeValidation
.\build.ps1— passed; Shared, CLI, WinNode CLI, SetupEngine, and WinUI built successfully.dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore— 2,898 passed, 31 skipped, 0 failed.dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore— 1,720 passed, 0 skipped, 0 failed.git diff --check— passed.Real Behavior Proof
OPENCLAW_TRAY_DATA_DIRandOPENCLAW_MCP_PORT; completednotifications/cancelledusing request ID\u0072equest; waited one second; sentcamera.clipusing the equivalent decoded IDrequest.204; call HTTP status200;IsError=true; result textcancelled.Yes/No/N/A): N/ASecurity Impact
Yes/No): NoYes/No): NoYes/No): NoYes/No): NoYes/No): NoYes, explain the risk and mitigation: N/ACompatibility and Migration
Yes/No): YesYes/No): NoYes/No): NoReview Conversations