Skip to content

Reliability: unblock the UI thread and stop tray subprocess churn #48

Closed

Description

@ElbertePlinio

From the 2026-07-19 complementary swarm review (read-only, complementary to #47 — no overlap with its candidates).

P0 — UI-thread blocking & hot-path subprocess churn

  • list_cleanup_models is a sync Tauri command doing blocking reqwest with a 10s timeout (src-tauri/src/lib.rs:562-566, src/engine/cleanup.rs:157-163). A slow/unreachable endpoint freezes the whole UI. Fix: make it async fn + tauri::async_runtime::spawn_blocking, mirroring export_history_entry (lib.rs:353-367). Apply same treatment to run_doctor (lib.rs:439).
  • tray::sync → icon_bytes → panel_prefers_dark() spawns and waits on a gdbus process on every state emit (src-tauri/src/tray.rs:112, :22-42). Called from set_state/set_state_for_session/finish_session (engine.rs:159,202,229) — 3-4× per segment during incremental transcription. Fix: cache the dark-mode probe (refresh on a timer or settings/theme-change event) and skip set_icon when the stage icon is unchanged.

P1 — responsiveness & correctness

  • Engine::cancel blocks up to 2s on done_rx.recv_timeout from sync cancel_dictation (engine.rs:390-421, lib.rs:248-251). Move drain off the command thread (as stop does via run_pipeline) or make the command async.
  • Engine::start sleeps 250ms on the UI thread (recorder.rs:80 via sync toggle_dictation). Move recorder warm-up off the command thread.
  • Incremental fallback: 5s cap silently re-transcribes the whole recording when the final segment is slow, discarding incremental work. Characterize + make fallback policy explicit (coordinate with Architecture: deepen transcription orchestration seams #47 CAND-1 — do not move the state machine here, just fix the silent discard).

P1 — simplify

  • ms_to_sample/sample_to_ms defined 3×. Hoist to one shared location.

Validation

  • cargo test (lib + bins + src-tauri), bun run build. Manual: cancel mid-segment stays responsive; Settings model list with endpoint down does not freeze UI.

Activity

  1. ElbertePlinio commented on Jul 19, 2026

    @ElbertePlinio
    MemberAuthor

    Implemented in PR #49 (branch fix/ui-thread-and-tray-churn). All checklist items landed:

    • P0 list_cleanup_models + run_doctor are now async via spawn_blocking (invoke signature unchanged for the frontend).
    • P0 Tray theme probe cached (30s TTL, force-refresh on the frontend's explicit theme events through get_system_theme); set_icon skipped when the icon variant is unchanged — no more per-emit gdbus spawns.
    • P1 cancel_dictation returns immediately; the up-to-2s incremental drain and recorder teardown moved to a background thread.
    • P1 Recorder warm-up (250ms) is off the command path; the immediate-exit check is polled off-thread with the same error surfaced.
    • P1 Fallback policy made explicit: completed contiguous incremental segments are preserved and only the remaining tail is re-transcribed when the 5s drain cap trips; full re-transcription only when nothing can be safely salvaged (failed segment, gap, or no finished work). State machine untouched per Architecture: deepen transcription orchestration seams #47.
    • P1 ms_to_sample/sample_to_ms hoisted to engine::audio_segments.

    Validation: cargo test --workspace --locked --all-targets 83 passed; bun run check/test/test:coverage/build green; clippy clean on touched files.

    Nothing was dropped as unsafe/out-of-scope. Manual smoke still worth doing per the issue: cancel mid-segment stays responsive; Settings model list with endpoint down does not freeze the UI.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions