fix(ios): hold a canceled request's locks until its runner command ends
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 typedrequest_canceledabort of a sent command, the exchange pollsstatus/statusCommandIduntil 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.tsbesideRunnerCommandAccounting;client-api.mddocuments 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 launchfinished 16:08:24.3Z, while the runnerlongPresscompleted at 16:08:29.4Z (overlap). - Fix: the runner
longPresscompleted at 16:09:17.48Z, the drain reportedterminalat 17.50Z, andsimctl launchran 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