Skip to content

feat(recording): recover crash-orphaned recordings into Recent recordings#24

Merged
joaothaira merged 1 commit into
mainfrom
feat/recover-orphaned-recordings
Jun 11, 2026
Merged

feat(recording): recover crash-orphaned recordings into Recent recordings#24
joaothaira merged 1 commit into
mainfrom
feat/recover-orphaned-recordings

Conversation

@ThairaHub

Copy link
Copy Markdown
Collaborator

Completes the crash-safety story. Streaming-to-disk (siddharthvaddem#616 upstream, siddharthvaddem#687 port) protects the bytes of an interrupted recording, but the take stayed invisible and broken:

  1. the .session.json manifest is only written on stop — a crashed take never appears in Recent recordings;
  2. the WebM Duration header is patched only at finalize — a crashed file seeks badly (Infinity/N/A duration).

Changes

  • Orphan adoption in list-recording-sessions: any recording-<id>.webm/.mp4 without a manifest and without an active writer (stream registry, native capture target paths, current session) gets a synthesized manifest with recovered: true; the webcam sidecar is attached when present. One-time — once the manifest exists it's a normal session.
  • Lazy duration repair in open-recording-session: on first open of a recovered take, the WebM Duration header is repaired on disk, then the recovered flag is dropped so later opens skip the full-file read.
  • Duration estimation (electron/recording/recoverRecording.ts): raw EBML tail scan — last Cluster Timecode + largest SimpleBlock relative offset (≈ exact for MediaRecorder's 1 ms timescale). Hand-rolled because @fix-webm-duration/parser deliberately skips Cluster internals. Handles unknown-size clusters from streamed output and falls back across false-positive ID matches. 4 unit tests.
  • Amber “Recovered” badge in Recent recordings.

Native .mp4 orphans (mac/windows helper crashes) are adopted and listed too; their duration repair is N/A (not WebM) and playability depends on how the helper died — but at least the take is discoverable now.

Verification

tsc 0 errors · biome clean · vitest 229/229 (4 new) · i18n-check 12 locales · vite build OK

🤖 Generated with Claude Code

…ings

Streaming-to-disk protects the bytes of an interrupted recording, but
the take stayed invisible: the .session.json manifest is only written
on stop, so a crashed recording never appears anywhere, and its WebM
lacks the Duration header (patched only at finalize), breaking seeking.

- list-recording-sessions adopts orphans: any recording-<id>.webm/.mp4
  with no manifest and no active writer (stream registry, native
  capture targets, current session) gets a synthesized manifest with
  recovered: true; webcam sidecar attached when present on disk.
- open-recording-session repairs the WebM Duration header once on
  first open, then drops the recovered flag so later opens skip the
  full-file read. Estimation parses the raw EBML tail (last Cluster
  Timecode + largest SimpleBlock offset) since the fix-webm-duration
  parser deliberately skips Cluster internals; handles unknown-size
  clusters from streamed MediaRecorder output. Unit-tested.
- Recovered takes show an amber badge in Recent recordings.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@joaothaira joaothaira merged commit 25b22ce into main Jun 11, 2026
4 checks passed
@joaothaira joaothaira deleted the feat/recover-orphaned-recordings branch June 11, 2026 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants