Repository navigation
Ensure recording and history are saved on app exit - #357
Merged
Merged
Conversation
Quitting (⌘Q, logout, a Sparkle relaunch) runs no deinit and resumes no task, so an active Record session left an unfinalized, unplayable .m4a, its live transcript was never saved, and any change in the 300 ms save debounce was lost. - AppDelegate.applicationWillTerminate calls TranscriptsModel.prepareForExit, which stops the recorder (closing the file), saves the live transcript as a recording entry, and writes the history synchronously, merging the saved file first if it hasn't been loaded yet. - History writes go through one serial queue, so an earlier detached write can no longer finish its rename after a later one and resurrect deleted entries or drop new ones. The exit flush queues behind any write in flight, so it lands last. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DS5B1RyMwLTuh8iqUWfZ7i
alexkroman
enabled auto-merge
November 24, 2026 22:49
With no output device the drain waits out its whole deadline (0.05 s of audio plus drainSlack, 2 s), so a flat 3 s bound left under a second of scheduler room and a loaded runner overshot it (3.39 s on PR #357's check job). Bound it as the sibling test does: deadline plus slack plus 2 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DS5B1RyMwLTuh8iqUWfZ7i
tapMic() lifted with micUp(), which times the finger from the wall clock. Finger down writes the press, and under the address sanitizer on a busy runner that alone outlasted the 350 ms hold threshold: the tap became a hold, its lift queued the stop, and the answer sent it, so the dictation went straight to stopping. That failed "a settled phase settles the gate only when it answers the press" on PR #357's ios-sanitizers (address) job, and a hands-free press or a status-line tap could do the same on a slow device. tapMic() now lifts at the touch's own stamp. Adds a test that jumps the model's clock past the hold threshold while the press is written: before the fix the tap sent a release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DS5B1RyMwLTuh8iqUWfZ7i
alexkroman
pushed a commit
that referenced
this pull request
Nov 25, 2026
…transcribed prepareForExit (#357) left a recording with no live transcript as a file with no Library entry; with #363 every recording keeps an entry, so this one is saved untranscribed (needsTranscription) for the Library to offer again, as a failed pass's is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
alexkroman
pushed a commit
that referenced
this pull request
Nov 25, 2026
…ging #357 Merging #357 brought the file to 401 lines and swiftlint's file_length failed check. Tightens transcribe's doc comment rather than the merged code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DS5B1V7Z9V8SZ8X1CBBS7q
alexkroman
pushed a commit
that referenced
this pull request
Nov 25, 2026
…edes #357's widened wall-clock one Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 25, 2026
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 & why
Adds graceful shutdown handling for in-flight recordings and pending history saves when the app terminates (⌘Q, logout, or Sparkle relaunch). Since
deinitdoesn't run and async tasks don't resume afterapplicationWillTerminate, this change ensures:The implementation:
prepareForExit()toTranscriptsModelto stop the recorder, save live transcript, and flush historyflushHistory()to handle immediate synchronous writes with proper mergingsaveQueue(a serialDispatchQueue) to serialize all history writes so older snapshots never land laststore,pendingSave, andisLoadedaccessible toprepareForExit()by changing their access levelprepareForExit()intoAppDelegate.applicationWillTerminate(_:)saveQueue.asyncinstead of a detached task, ensuring it participates in the serializationHow it was tested
scripts/check.shpasses (or CI will, if I'm not on a Mac)