fix: robust recovery from audio stream death, IBus boot race, and tray crashes#4
Conversation
…y crashes Three recurring failures fixed: 1. IBus boot race: voiceio starts before ibus-daemon is ready, falls back to clipboard typer which fails on Wayland. Now waits up to 15s for IBus daemon and re-probes typers. 2. Audio stream silently dies (ALSA underrun, PipeWire restart, device disconnect) and all subsequent recordings capture only silence. Health watchdog now detects 5 failure modes (closed/inactive/stopped/stale heartbeat) with exponential backoff recovery. Pre-flight check reopens dead stream before recording starts. 3. Tray indicator subprocess dies and loses D-Bus registration. Watchdog now detects and restarts it automatically. Also: - IBus typer auto-pastes via ydotool in non-IBus apps (terminals like Ghostty) by querying engine focus state over the Unix socket - Streaming worker thread catches typer errors instead of crashing - Pre-recording mic signal check warns if audio is all zeros (muted mic)
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThe changes introduce a comprehensive health monitoring and recovery system across multiple components. AudioRecorder gains heartbeat tracking and stream health diagnostics. The main app monitors audio stream and tray subprocess liveness with automatic recovery mechanisms. IBus integration is enhanced with focus detection and clipboard paste simulation on focus loss. Tray subprocess management adds liveness checks and restart capability. Streaming error handling is improved with wrapped transcription calls. Changes
Sequence DiagramsequenceDiagram
participant App
participant Recorder
participant Tray
participant IBus
Note over App,IBus: Startup Phase
App->>Recorder: _check_health()
Recorder-->>App: stream_health() → (ok, reason)
alt Stream unhealthy
App->>Recorder: reopen_stream()
Recorder-->>App: stream reopened
end
App->>Tray: is_alive()
Tray-->>App: subprocess status
alt Tray dead
App->>Tray: restart(toggle_callback)
Tray-->>App: True/False
end
Note over App,IBus: Background Monitoring
loop Health Check Interval
App->>Recorder: stream_health()
Recorder-->>App: (ok, reason)
App->>IBus: _wait_for_ibus() if needed
alt IBus not ready
IBus-->>App: None (waiting)
else IBus ready
IBus-->>App: TyperBackend
end
end
Note over App,IBus: Typing Operations
App->>IBus: type_text()
IBus->>IBus: _engine_has_focus()?
alt Focus lost
IBus->>IBus: _simulate_paste()
IBus-->>App: paste executed
else Focus present
IBus-->>App: text typed
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Test plan
Summary by CodeRabbit
New Features
Bug Fixes
Tests