refactor: add iOS runner lifecycle protocol#658
Conversation
Size Report
Startup median (7 runs, lower is better):
Top changed chunks:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eddeb43127
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
|
|
||
| func execute(command: Command) throws -> Response { | ||
| commandJournal.accept(command: command) |
There was a problem hiding this comment.
Don't let status probes evict the command they query
Because every request is journaled before dispatch, status probes are stored and pruned like normal commands. When the journal is already at its 64-entry limit, a status request appends its own generated commandId and pruneIfNeeded() removes the oldest entry before commandJournal.status(statusCommandId) runs, so querying that oldest retained command returns notAccepted solely because of the probe. Avoid journaling status commands or defer pruning until after the lookup so lifecycle recovery does not consume its own history slot.
Useful? React with 👍 / 👎.
|
Summary
Refactors the iOS runner command path to carry lifecycle ids through the existing protocol without changing daemon retry or preflight policy. Lifecycle-tracked runner commands now get a
commandId, the Swift runner records accepted/started/completed/failed state in an in-memory journal, and a new read-onlystatuscommand can query that lifecycle state bystatusCommandId.Closes #656
Helpful cases versus the previous behavior:
statusand seecompletedwith cached response JSON when the response is small enough to retain, instead of treating the result as an ambiguous timeout.failedwith error code/message/hint instead of collapsing everything into transport failure.accepted/startedfromunknownonce follow-up transport/retry wiring can query status before resend.This is intentionally a pure refactor for now: eager
uptime, existing retries, and all command behavior remain in place so performance policy can be changed separately after the protocol is merged.Review hardening included in this PR:
statusprobes are not journaled and do not get their own generatedcommandId, so polling cannot evict the command being queried and carries onlystatusCommandId.statusreads the locked journal directly instead of dispatching through the XCTest main-thread command path.Responseobject; response JSON is omitted for snapshots and when encoded JSON exceeds 16 KiB.commandIdvalues are normalized by assigning a generated runner id; caller-supplied ids are preserved.Known follow-ups:
statusbefore retrying after transport failure. The later reliability/performance change should add status-before-resend ordering and keep the originalcommandIdin the retry-owning scope.Touched-file scope: focused on the iOS runner protocol/client/session path and protocol fixtures/tests.
Validation
Passed:
pnpm formatpnpm typecheckpnpm exec vitest run src/platforms/ios/__tests__/runner-client.test.tspnpm exec vitest run src/platforms/ios/__tests__/runner-client.test.ts src/platforms/ios/__tests__/runner-session.test.tspnpm exec vitest run src/platforms/ios/__tests__/runner-session.test.ts src/platforms/ios/__tests__/runner-client.test.ts src/platforms/ios/__tests__/runner-command-retry.test.ts src/platforms/ios/__tests__/runner-provider.test.tspnpm exec vitest run test/integration/provider-scenarios/ios-lifecycle.test.ts test/integration/provider-scenarios/ios-alert-settings.test.ts test/integration/provider-scenarios/ios-record-trace.test.ts test/integration/provider-scenarios/macos-recording.test.ts test/integration/provider-scenarios/tvos-remote.test.ts test/integration/provider-scenarios/transcript.test.tspnpm build:xcuitestKnown gap: broad
pnpm check:unitwas attempted but failed in unrelated environment/tooling suites, including local serverlisten EPERM, mocked tool timeouts, platform helper failures, and OCR/script typecheck failures.