Persist system-audio keep regions on takes - #15
Merged
Conversation
System-audio activity ranges captured during recording were only held in a renderer in-memory Map, so an app restart lost them and a later Transcribe & Cut would silence-cut regions with audible screen sound but no mic speech. Add a systemAudioSegments field to Take with defensive normalization (normalizeTakeSpeechSegments), stamp it at recording finalize, and make Transcribe & Cut prefer the persisted ranges with the in-session map as fallback for takes recorded before persistence existed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Both branches introduced TakeSpeechSegment: main for persisted transcriptSegments (bad-take detection), this branch for persisted systemAudioSegments. Keep main's stricter normalizeTakeSpeechSegments (clamps negatives, collapses whitespace) as the single definition, stamp both fields at recording finalize, and make the Remove Bad Takes protection set prefer the persisted system-audio ranges with the in-session map and waveform envelope as fallbacks. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
System-audio "keep" regions detected while a take records were only held in a renderer in-memory Map (
takeSystemAudioActivity), so they were lost on app restart. For takes withhasSystemAudio=true, re-running Transcribe & Cut after a restart would silence-cut regions that contain audible screen sound (music, demos, narration) but no mic speech.src/shared/domain/project.ts: newTakeSpeechSegmentinterface andnormalizeTakeSpeechSegments()(drops non-record entries, non-finite or inverted/zero-length ranges, coerces text to a trimmed string, sorts by start), plus asystemAudioSegments: TakeSpeechSegment[]field onTakehydrated innormalizeProjectData— legacy project files default to[]. SincesaveProjectToDiskspreads takes, the field round-trips through save/load with no serializer changes.src/renderer/app.ts: recording finalize stampssystemAudioSegmentson the pushed take from the captured activity segments;transcribeAndCutTakeprefers the persisted ranges and falls back to the in-session Map for takes recorded before persistence existed.Tests
Written first (both failed before the implementation) in
tests/unit/project-domain.test.ts:normalizeTakeSpeechSegmentsedge cases: invalid entries dropped, text coercion, sorting.normalizeProjectDataround-trip: legacy takes hydrate to[]; serialize → re-normalize preserves the ranges.Notes for reviewers
systemAudioSegments: [], matching prior behavior since recovery never had activity data.pnpm run checkexits 0 (lint, typecheck, 535 unit/integration tests, Electron e2e smoke). Caveat: thepackage:smokestep is a pre-existing silent false-pass on Node 26 (extract-zip's promise never settles inside@electron/packager, the event loop drains, and the script exits 0 without packaging). Unrelated to this change; tracked separately.🤖 Generated with Claude Code