fix(linux): guard pill click-through against tao unrealized-window panic
Problem
The app crashes on every launch on Linux with:
tao-0.34.5/src/platform_impl/linux/event_loop.rs:449:18:
called `Option::unwrap()` on a `None` value
panic in a function that cannot unwind -> abort
Root cause
The dictate pill window is built hidden at startup (visible(false)). The pill component initializes in the hidden state, so on mount it immediately emit('dictate:hide') (app/src/components/DictateWindow/DictateWindow.tsx). The Rust dictate:hide handler then calls set_ignore_cursor_events(true).
On Linux/GTK a window that has never been shown has no realized GDK window, so deep inside tao window.window() is None and .unwrap() aborts the process. macOS/Windows don't hit this because their windows realize differently.
Fix
The click-through park is a macOS NSWindow workaround anyway (per the existing comment); on Linux plain hide() + off-screen park is sufficient. Gate the set_ignore_cursor_events(true) call off on Linux.
It's the only set_ignore_cursor_events(true) call in the tree; the (false) calls take tao's safe branch and don't panic.
Testing
just dev on Pop!_OS 24.04 (Wayland, NVIDIA): app now launches cleanly and stays running, no panic, GPU detected as CUDA.
Summary by CodeRabbit
- Bug Fixes
- Improved window behavior when hiding dictation on Linux by avoiding a crash related to cursor-event handling.
- Non-Linux platforms continue to use the click-through behavior as before.
No actionable comments were generated in the recent review. π
βΉοΈ Recent review info
βοΈ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 7fca8a8c-5e35-46c3-9b9f-70bd34ca45c4
π₯ Commits
Reviewing files that changed from the base of the PR and between cabef1bfe091a8e280ae5acc356869b3bcf041a8 and 94a5dc6ac33b51cc1c3b4179829bbc80c039e377.
π Files selected for processing (1)
tauri/src-tauri/src/main.rs
π Walkthrough
Walkthrough
A #[cfg(not(target_os = "linux"))] compile-time guard was added around the set_ignore_cursor_events(true) call in the dictate:hide event handler in main.rs to prevent a runtime panic on Linux when the GDK window is not yet realized.
Changes
Linux panic fix in dictate:hide
| Layer / File(s) | Summary |
|---|---|
cfg guard for cursor events tauri/src-tauri/src/main.rs |
Wraps the click-through/ignore-cursor-events logic with #[cfg(not(target_os = "linux"))] so set_ignore_cursor_events(true) is excluded from Linux builds. |
Estimated code review effort
π― 1 (Trivial) | β±οΈ ~2 minutes
Poem
π On Linux the window's not ready to see, A cursor event caused a panic for me. So I wrapped it in cfg, nice and tight, Now Linux hops forward without a fright! No panic, no crash β what a beautiful sight. β¨
π₯ Pre-merge checks | β 5
β Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | β Passed | Check skipped - CodeRabbitβs high-level summary is enabled. |
| Title check | β Passed | The title accurately summarizes the Linux guard added to prevent the tao unrealized-window panic. |
| Docstring Coverage | β Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
| Linked Issues check | β Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | β Passed | Check skipped because no linked issues were found for this pull request. |
β¨ Finishing Touches
π§ͺ Generate unit tests (beta)
- [ ] Create PR with unit tests
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 @coderabbitai help to get the list of available commands.
Thanks for this, @awestwell. The same fix landed on main via #906 (the set_ignore_cursor_events calls on the dictate pill are skipped on Linux with #[cfg(not(target_os = "linux"))] guards, which avoids the tao unrealized-window panic), which took the same approach, so we're closing this one as superseded. It ships in 0.6.0, now cut and waiting on an Apple notarization block.