Close local transcription sessions on completion#7192
Conversation
Greptile SummaryThis PR fixes locally-originated transcription sessions that were left with a stale
Confidence Score: 4/5Safe to merge; the change correctly closes out the local record after a successful upload, and the only imprecision is limited to the crash-recovery fallback path. The happy path (where finishSession was called before markSessionCompleted) is unambiguously correct. The sole rough edge is the crash-recovery fallback: when finishedAt is nil, the coalesce assigns the upload-completion timestamp rather than actual recording-end time, causing durationSeconds to over-report. This is a minor accuracy concern on an already-degraded code path and does not affect data integrity or backend sync. desktop/Desktop/Sources/Rewind/Core/TranscriptionStorage.swift — specifically markSessionCompleted and how finishedAt interacts with TranscriptionSessionWithSegments.durationSeconds in crash-recovery scenarios. Important Files Changed
Reviews (1): Last reviewed commit: "Close local transcription sessions on co..." | Re-trigger Greptile |
| let completedAt = Date() | ||
| record.status = .completed | ||
| record.conversationStatus = .completed | ||
| record.finishedAt = record.finishedAt ?? completedAt |
There was a problem hiding this comment.
In the crash-recovery fallback,
finishedAt is set to completedAt — the moment the upload finished — rather than when recording actually stopped. TranscriptionSessionWithSegments.durationSeconds subtracts startedAt from finishedAt, so for any session recovered without a prior finishSession call (e.g. the app crashed mid-recording), the reported duration will include dead time between the crash and the eventual retry. Keeping nil preserves the nil-safe guard in durationSeconds instead of silently inflating it. If you do want a non-nil value for UI purposes, documenting the approximation in a comment would help future readers.
| let completedAt = Date() | |
| record.status = .completed | |
| record.conversationStatus = .completed | |
| record.finishedAt = record.finishedAt ?? completedAt | |
| let completedAt = Date() | |
| record.status = .completed | |
| record.conversationStatus = .completed | |
| // Note: finishedAt should have been set by finishSession; if nil (crash-recovery path), | |
| // we fall back to the upload completion time, which over-estimates recording duration. | |
| record.finishedAt = record.finishedAt ?? completedAt |
Summary
Fixes #6955
Verification
cd ~/projects/omi/desktop/Desktop && swift build 2>&1 | tail -5