refactor(apple): drop unread recorder phases and one-caller helpers from USB capture recording

Merged
TH
6h ago
+45-165

Summary

Behavior-preserving simplification of the USB capture recorder from #5201. Net production lines: โˆ’91.

  • Recorder lifecycle: the stopping, stopped and failed phases and the stop, stopped and fail events are removed. The lifecycle is local to one startAppleRecording call and nothing read those phases. Every removed apply was guarded or always allowed, so none could throw. select, fall-back and first-frame stay: a fallback happens only from starting(usb-capture), and its reason still reaches recorderFallbackReason. The unused state getter goes too.
  • HOST_RECORDERS: the backend field repeated the record key. Callers now pass the key.
  • selectAppleRecorder, nameShared, compileUsbCaptureHelper: each had one caller and is now inlined. The compile uses the same cache name, sources, timeout and signal.
  • Inventory check: one .catch(() => false) replaces two. A read that fails still counts as "not unique", and the rejection is still handled before the helper starts.
  • recovery.ts: removed a duplicate doc comment on reattachHostRecording.

Swift is unchanged: a source edit would make every host recompile the helper.

Before / after

No observable change. Recorder selection, the fallback rule, exit-code meanings, timings and output stay the same.

Value

  • Production lines: โˆ’91 (+45/โˆ’165 total, including tests).
  • recorder-state.ts: 96 โ†’ 50 lines.

Validation

Head 6868f8f: recorder-state.test.ts, recording/runtime.test.ts and apple-usb-capture-host.test.ts pass locally (35 tests). The two tests for the deleted post-first-frame phases are removed. CI owns typecheck and the other gates. No device run: the start and stop sequences are unchanged.

๐Ÿค– Generated with Claude Code


Open in [code]smith ยท Need help on this PR? Tag @codesmith-bot with what you need.