Description
Bug description
A desktop recording can successfully stream/transcribe audio to the backend but never appear in the conversation list because the backend conversation remains stuck in in_progress. The desktop client then retries reconciliation and eventually reports Session <n> could not be reconciled after 5 attempts.
This was observed in production for an affected customer, but all customer identifiers, email, UID, conversation IDs, transcript content, and generated titles are intentionally redacted here.
Customer-safe production evidence
From a production investigation of one affected desktop user:
- Platform: macOS desktop, Apple Silicon (
arm64), Omi desktop builds in the0.11.5xxrange. - User-facing symptom: audio/live transcript was present, but no conversation appeared.
- PostHog showed repeated desktop errors:
Session <n> could not be reconciled after 5 attempts. - 14-day event summary for the affected user:
Phone Mic Recording Started: 25Phone Mic Recording Stopped: 9Phone Mic Recording Error: 14Memory Extracted: 85
- The error is not isolated: the same
Session <n> could not be reconciled after 5 attemptsshape appeared for many desktop users over the last two weeks. - Firestore for the affected user contained a backend conversation with:
status = in_progresslanguage = hisource = unknown- encrypted
transcript_segmentsbytes present - roughly 19.9k transcript segment entries after decryption/accounting in local inspection
finished_atpopulated
- The immediately previous chunk from the same stream completed successfully; the next chunk stayed
in_progress.
Sanitized Cloud Logging timeline for the failed chunk:
T0 Created new stub conversation: <redacted_conversation_id>
T+7m Resuming conversation <redacted_conversation_id>. Will timeout in ~85s
T+22m Client disconnected: code=1000 reason=normal_closure
T+22m _stream_handler ended
Expected but missing for the failed chunk:
Conversation <id> timeout reached. Processing...
Sent process_conversation request to pusher: <id>
process_conversation completed conversation.id=<id>
Conversation processed by pusher: <id>
For the preceding successful chunk, all of those expected pusher processing logs were present and the conversation reached completed.
Likely root causes
1. Backend does not finalize normal single-channel desktop sessions on disconnect
In backend/routers/transcribe.py, cleanup currently processes the current conversation at session end only for is_multi_channel:
# Multi-channel: process the single conversation at session end
if is_multi_channel and current_conversation_id:
redis_db.remove_in_progress_conversation_id(uid)
_flush_speaker_assignments(current_conversation_id)
await _process_conversation(current_conversation_id)For normal desktop /v4/listen, if the websocket closes before the lifecycle timeout task processes current_conversation_id, the conversation can remain in_progress indefinitely even though it has transcript/audio content.
2. Desktop reconciliation cannot discover in_progress conversations
In desktop/macos/Desktop/Sources/ConversationFinalizationService.swift, unbound cloud reconciliation falls back to timestamp matching:
let existing = try await APIClient.shared.getConversations(
limit: 5,
includeDiscarded: true,
startDate: session.startedAt.addingTimeInterval(-5),
endDate: finishedAt.addingTimeInterval(5)
)No statuses are passed. The backend list endpoint defaults to processing,completed, so this timestamp lookup cannot see an in_progress conversation that needs finalization.
Backend default in backend/routers/conversations.py:
statuses: Optional[str] = "processing,completed"So desktop retries, never sees the stuck conversation, and eventually surfaces Session <n> could not be reconciled after 5 attempts.
Expected behavior
When a desktop user stops recording or the websocket closes normally:
- Any current conversation with transcript/photo content should be finalized/processed.
- The conversation should move from
in_progresstoprocessing/completedor a deliberate failed/discarded state. - Desktop reconciliation should be able to find and finalize an
in_progressbackend conversation for the local recording session. - Users should not lose access to a recorded conversation due to a missed timeout task.
Suggested fix
Implement both defensive layers:
Backend
On normal /v4/listen cleanup for non-multichannel sessions, if current_conversation_id exists and has content, submit it for processing just like timeout processing does.
Important details:
- Avoid deleting empty conversations that truly have no segments/photos.
- Avoid double-processing if already
processing/completed. - Remove the in-progress Redis pointer when finalizing the current conversation.
- Preserve existing pusher routing semantics.
- Keep WebSocket cleanup non-blocking/bounded enough that shutdown does not hang.
Desktop
In unbound cloud reconciliation:
- Query with statuses including
in_progress,processing, andcompleted. - If timestamp matching finds
in_progress, call exactfinalizeConversation(id:)for that conversation. - If the finalization still fails but local transcript segments exist, consider falling back to
/v1/conversations/from-segmentsrather than permanently failing the local session.
Suggested regression tests
Backend:
- Simulate
/v4/listensingle-channel session with transcript segments, then normal websocket disconnect before lifecycle timeout. Assert the current conversation is submitted for processing and no longer remainsin_progress. - Simulate an empty current conversation and verify cleanup still deletes/ignores it safely.
- Verify multi-channel behavior is unchanged.
Desktop:
- Unit-test
ConversationFinalizationServiceunbound cloud reconciliation whengetConversationsreturns anin_progresstimestamp match. Assert it callsfinalizeConversation(id:)and marks the local session completed. - Unit-test that the query includes
in_progressstatus. - Optional: test fallback to
createConversationFromSegmentswhen cloud reconciliation cannot recover but local segments are present.
Privacy note
This issue intentionally omits customer UID, email, exact conversation IDs, transcript content, generated summaries/titles, and exact raw customer log excerpts. The evidence above is sufficient to reproduce the state transition failure without exposing customer data.
Activity
Fix desktop recording finalization reconciliation (BasedHardware#8751)