Skip to content

Close local transcription sessions on completion#7192

Open
kodjima33 wants to merge 1 commit into
mainfrom
fix/issue-6955
Open

Close local transcription sessions on completion#7192
kodjima33 wants to merge 1 commit into
mainfrom
fix/issue-6955

Conversation

@kodjima33
Copy link
Copy Markdown
Collaborator

Summary

  • mark local transcription rows as fully completed after successful upload
  • set conversationStatus to completed and fill finishedAt when missing
  • keep backend sync fields unchanged

Fixes #6955

Verification

  • Mac mini: cd ~/projects/omi/desktop/Desktop && swift build 2>&1 | tail -5
  • Build complete on Mac mini

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 6, 2026

Greptile Summary

This PR fixes locally-originated transcription sessions that were left with a stale conversationStatus of .inProgress and a potentially-null finishedAt after a successful backend upload. The change is confined to markSessionCompleted and touches only three fields on the session record.

  • Sets conversationStatus = .completed after upload succeeds, replacing the previous .inProgress default that was never updated on the upload path.
  • Fills finishedAt with a ?? coalesce guard so sessions that never received a finishSession call (crash-recovery path) get a non-nil timestamp.
  • Captures a single completedAt = Date() value and reuses it for both fields, ensuring finishedAt (fallback) and updatedAt share the same instant.

Confidence Score: 4/5

Safe 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

Filename Overview
desktop/Desktop/Sources/Rewind/Core/TranscriptionStorage.swift Adds conversationStatus = .completed and a finishedAt fallback to markSessionCompleted; normal-flow is correct, but crash-recovery path sets finishedAt to upload time rather than recording-end time, potentially inflating durationSeconds

Reviews (1): Last reviewed commit: "Close local transcription sessions on co..." | Re-trigger Greptile

Comment on lines +110 to +113
let completedAt = Date()
record.status = .completed
record.conversationStatus = .completed
record.finishedAt = record.finishedAt ?? completedAt
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

Suggested change
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

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.

Desktop: local markSessionCompleted leaves transcription_sessions in a partially-open state

1 participant