Repository navigation
fix(recordings): stop captures that start late and handle system stops - #54
Merged
Merged
Conversation
…tem stops Co-Authored-By: Claude Opus 5.5 <[email protected]> A stop() during a pending startCapture() left system-audio capture running forever (Recordings, Live Captions). Live Captions now uses a generation counter so restart() cannot start two engines. SCStream now has a delegate so a vanished display or revoked permission finishes the recording and saves the file. ScreenRecorder.stop() no longer clears the stream/sink or audio files of a recording started in the meantime.
Quost
force-pushed
the
fix/recordings-stream-lifecycle
branch
from
November 24, 2026 00:56
9bfa439 to
bb066c2
Compare
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 changes
Lifecycle fixes for the three ScreenCaptureKit captures (screen recorder, meeting recordings, live captions), found in the codebase audit.
A capture could keep running forever. Recordings and live captions assigned
stream = safterawait s.startCapture(). If you pressed Stop while the capture was still starting,stop()saw no stream and stopped nothing. The stream was then assigned and kept capturing system audio, with the screen-recording indicator on. Now, once the capture has started, they check the recording is still the same one (recordingIDin Recordings, agenerationcounter in Live Captions). If it isn't, they stop the stream instead of keeping it.Live Captions restart race.
restart()(stop + start) while a previousbegin()was still waiting (model download, permission) could start two engines. Every await inbegin()now bails out if the generation changed, and shuts down an engine or stream that arrives late.The app now notices when macOS stops a capture. All three
SCStreams haddelegate: nil, so when a display was disconnected or the permission revoked, the app never found out. The recorder stayed "recording", the.movwas never finished and the temp file was lost. A smallStreamStopDelegatenow calls the normal stop path on the main actor:A HUD says "Recording stopped: the screen or the permission changed."
Recorder
stop()no longer clears the stream, sink or audio files of a new recording started while the previous one was still finishing. It only clears them if they are the same objects, and it capturesstartedand the audio files before its Task.Notes for review
LiveCaptions.swiftwith fix(security): keep MCP settings out of backups, speech on the Mac, safe uninstaller paths #53 (the on-device speech guard sits in the samebegin()). Whichever merges second needs a small rebase.Checklist
./build.shand I tried the change in the app. (CI builds it. Worth a manual try: start then stop quickly, unplug an external display while recording)swift testpasses (CI)L("…")with en, de, es and zh🤖 Generated with Claude Code