minutes icon indicating copy to clipboard operation
minutes copied to clipboard

Live transcript status reports 0 lines / 0:00 on Windows during a healthy in-app (Tauri) Live session

Open mquinn614 opened this issue 6 months ago • 1 comments

Bug: live transcript status reports 0 lines / 0:00 on Windows during a healthy in-app (Tauri) Live session

Summary

On Windows, live_transcript::session_status() returns line_count: 0 and duration_secs: 0.0 throughout an otherwise-healthy in-app (Tauri) live transcript session — even while utterances are being captured, transcribed, and written to live-transcript.jsonl. Any UI that drives a timer or "is it hearing audio?" indicator off those fields shows a frozen 0:00 and can trip a false "no audio" state. macOS is unaffected.

Environment

  • OS: Windows 10/11 (x64), WebView2
  • Build: cargo tauri build --features parakeet (release desktop installer)
  • Surface: in-app Tauri live transcript (the session runs on a background thread inside the app process), TranscriptSource::Standalone

Symptoms

  • The session works end to end: events.jsonl shows recording.started (source:"live") followed by multiple live.utterance.final events, and live-transcript.jsonl contains the transcribed lines.
  • But cmd_live_transcript_status / session_status() returns line_count: 0, duration_secs: 0.0 for the whole session.
  • (The UI still shows "recording" because that flag is tracked separately by the app, which is what makes the contradiction visible: clearly recording, yet 0 lines / 0:00.)

Root cause (Windows file-locking)

session_status() → derive_session_status() gates the stats on standalone_active = lt_process_pid.is_some(), where lt_process_pid = check_pid_file(&live_transcript_pid_path()).ok().flatten():

let should_report_stats = standalone_active || recording_pid.is_some();
let (line_count, duration_secs) = if should_report_stats {
    status_metrics(live_status.as_ref(), jsonl_path, now)
} else {
    (0, 0.0)   // <-- Windows lands here
};

check_pid_file() reads the PID file with fs::read_to_string(path)?:

let pid_str = fs::read_to_string(path)?;  // fails on Windows, see below

But the live session holds that same PID file under an exclusive fs2 lock for its entire lifetime (create_pid_guard → file.try_lock_exclusive()).

  • On Unix, fs2 uses flock, which is advisory — a separate read_to_string succeeds, so check_pid_file returns Some(pid) and stats report normally.
  • On Windows, fs2 uses LockFileEx with LOCKFILE_EXCLUSIVE_LOCK, which is mandatory. A ReadFile on the locked byte range from another handle fails with ERROR_LOCK_VIOLATION, so fs::read_to_string returns Err, check_pid_file returns Err, and .ok().flatten() collapses it to None. → standalone_active = false → stats are forced to (0, 0.0).

So it's not that the session isn't running — it's that the status reader can't read the PID file while the writer holds an exclusive Windows lock on it, and the failure is silently mapped to "no active session."

This primarily bites the in-app case because the lock holder (the app's background thread) and the reader (cmd_live_transcript_status on the UI thread) are the same process polling concurrently. A separate-process CLI reader may race differently but is exposed to the same hazard.

Impact

  • Tauri Live mode timer / line-count / activity indicators freeze on Windows, which can look like a broken or non-capturing session.
  • Anything polling session_status() for line_count/duration_secs on Windows is affected. Scoring/consumers that read live-transcript.jsonl directly are not affected (the JSONL isn't locked).

Suggested fixes (pick one)

  1. Make check_pid_file tolerant of a locked-but-present PID file on Windows. If path.exists() but the read fails with a lock/sharing error, treat the PID file as present rather than absent (or fall back to the liveness signal below) instead of returning Err.
  2. Don't gate live stats on PID-file readability. derive_session_status already has a fresh, heartbeated status sidecar (LiveStatus, with updated_at + state: Healthy, written ~1×/s). Report line_count/duration_secs from a fresh LiveStatus even when the PID read fails — the recording-sidecar path already uses sidecar staleness via evaluate_recording_sidecar_status; the standalone path could do the same.
  3. Avoid the self-read entirely: have the in-app session publish its line_count/duration via an in-process channel/shared state rather than round-tripping through a file the same process holds locked.

Option 2 is the most robust and reuses machinery already present.

Repro

  1. On Windows, start an in-app (Tauri) live transcript session and speak.
  2. Confirm ~/.minutes/live-transcript.jsonl is accumulating utterances.
  3. Poll session_status() / cmd_live_transcript_status → observe line_count: 0, duration_secs: 0.0 despite the growing JSONL.

Notes

Found while building a downstream feature on top of the live transcript. The downstream UI worked around it by deriving its timer from wall-clock and its audio-activity indicator from audioLevel (which isn't PID-gated), but the underlying session_status() behavior on Windows is the real bug.

mquinn614 avatar May 27 '26 14:05 mquinn614

Fixed and shipped in v0.18.3. Your diagnosis was spot on: on Windows fs2 locks are mandatory, so the live session's own PID lock made check_pid_file's read fail and report the session as inactive, freezing status at 0:00.

The fix adds pid::inspect_pid_file, which treats a held lock as proof the owner is alive (Windows releases locks when the owning process exits), and routes every reader of a persistently-locked PID file through it. That also closes the related hazard you flagged where a concurrent recording could clobber live-transcript.jsonl, plus the CLI/Tauri stop, update guard, and background worker checks that shared the same blind spot. macOS and Linux were never affected.

Thanks for the unusually precise writeup, Quinn. It made the root cause obvious and shaped the whole fix. You're credited in the release notes and the merge commit (#259).

Upgrade path: brew upgrade minutes, the v0.18.3 desktop DMG, or npx minutes-mcp once the npm packages publish (lagging by a short window). Reopen if anything still looks off on your side.

silverstein avatar May 27 '26 18:05 silverstein