Skip to content

Desktop recordings can remain stuck in_progress and fail local reconciliation #8749

Closed

Description

@Git-on-my-level

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 the 0.11.5xx range.
  • 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: 25
    • Phone Mic Recording Stopped: 9
    • Phone Mic Recording Error: 14
    • Memory Extracted: 85
  • The error is not isolated: the same Session <n> could not be reconciled after 5 attempts shape appeared for many desktop users over the last two weeks.
  • Firestore for the affected user contained a backend conversation with:
    • status = in_progress
    • language = hi
    • source = unknown
    • encrypted transcript_segments bytes present
    • roughly 19.9k transcript segment entries after decryption/accounting in local inspection
    • finished_at populated
  • 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:

  1. Any current conversation with transcript/photo content should be finalized/processed.
  2. The conversation should move from in_progress to processing/completed or a deliberate failed/discarded state.
  3. Desktop reconciliation should be able to find and finalize an in_progress backend conversation for the local recording session.
  4. 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, and completed.
  • If timestamp matching finds in_progress, call exact finalizeConversation(id:) for that conversation.
  • If the finalization still fails but local transcript segments exist, consider falling back to /v1/conversations/from-segments rather than permanently failing the local session.

Suggested regression tests

Backend:

  • Simulate /v4/listen single-channel session with transcript segments, then normal websocket disconnect before lifecycle timeout. Assert the current conversation is submitted for processing and no longer remains in_progress.
  • Simulate an empty current conversation and verify cleanup still deletes/ignores it safely.
  • Verify multi-channel behavior is unchanged.

Desktop:

  • Unit-test ConversationFinalizationService unbound cloud reconciliation when getConversations returns an in_progress timestamp match. Assert it calls finalizeConversation(id:) and marks the local session completed.
  • Unit-test that the query includes in_progress status.
  • Optional: test fallback to createConversationFromSegments when 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

  1. added
    bug
    backend
    on Jul 1, 2026
  2. added a commit that references this issue on Jul 1, 2026
    03eb3ac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendbugdesktop

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions