fix(apple-runner): recycle lost-listener runner and restart on ready-session early exit
KH
4d ago+305+305+012345678901234567890123456789-74-74-01234567890123456789
Summary
Fixes #5276. When the iOS runner app dies (listener socket closed) while xcodebuild stays alive, isRunnerSessionServing previously only checked session state and xcodebuild PID, reusing the dead runner and failing with xcodebuild exited early.
packages/apple-runner/src/runner-session.ts: refuse to reuse sessions withlistenerWatch?.lostviastopInvalidatedSession.packages/apple-runner/src/runner-error-classification.ts&runner-lifecycle.ts: allowxcodebuild_exited_earlyto restart before send when the session was alreadyreadyat entry.packages/apple-runner/src/runner-session-types.ts: movednormalizeRunnerLogicalLeaseContextto keep files under 1000 lines.
Before / after
- Before: a command after SpringBoard kills the runner app reuses the session with
listenerWatch.lost = trueand fails withCOMMAND_FAILED(xcodebuild_exited_early). - After:
ensureRunnerSessioninvalidates and stops the lost-listener session to start a fresh runner; an already-ready session that hitsxcodebuild_exited_earlybefore send restarts and replays.
Validation
Tested at 1024e4694d on 59a640c08d:
vitest runonrunner-error-classification,runner-lifecycle-readiness-preflight,runner-session-lifecycle: 3 files, 83 tests passed.tsc -b tsconfig.typecheck.json examples/sdk/tsconfig.json: passed.oxlint . --deny-warnings: 0 warnings, 0 errors.
CI obligations: full unit, Apple smoke, and repo-guard lanes. Risks: none known.