fix(ios): hold a canceled request's locks until its runner command ends

Merged
TH
2mo ago
+471-48

Summary

On iOS, a request canceled with its signal now keeps the session and device locks until the runner reports the command finished. Before, open --relaunch or a screenshot could run while XCTest was still running the canceled command. The client still rejects at once.

  • runner-exchange.ts: after a typed request_canceled abort of a sent command, the exchange polls status/statusCommandId until the journal shows the command as terminal, then settles the charge. The polls are bounded by the command's remaining deadline, not the aborted signal. A deadline, notAccepted, or a status failure ends the drain and leaves the charge abandoned. A cancellation the transport proves unsent (dispatched: no) withdraws its charge and releases at once.
  • The journal vocabulary moves unchanged from recovery into runner-session-types.ts beside RunnerCommandAccounting; client-api.md documents the hold.

Closes #3383

Validation

Commit c8c44a01f: pnpm check:affected --run passed (3220 tests, incl. eager-closure budgets; live run below was on aa533890b). Coverage, Swift builds, and replay lanes are CI-owned; no Swift changed.

The new runner-exchange.test.ts cases cover the terminal drain, a second task waiting on the same keyed lock, abort before send, notAccepted, deadline expiry, and a caller-deadline negative case. With the fix removed, 5 of them fail.

Live on the iPhone 18 Pro simulator: a 5 s longPress aborted after 300 ms, then open --relaunch.

  • Base: simctl launch finished 16:08:24.3Z, while the runner longPress completed at 16:08:29.4Z (overlap).
  • Fix: the runner longPress completed at 16:09:17.48Z, the drain reported terminal at 17.50Z, and simctl launch ran 17.70โ€“17.97Z.

Risk: a command the runner received but has not yet journaled reads as notAccepted and releases early. That window is milliseconds.

๐Ÿค– Generated with Claude Code