fix: prevent duplicate tray instances on relaunch#1458
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR implements single-instance app behavior by adding the ChangesSingle-Instance App Behavior
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Rust Tauri Coverage ReportCoverage Details |
59b4f49 to
9ef61ed
Compare
There was a problem hiding this comment.
Pull request overview
This PR prevents duplicate tray icon instances on Windows by enforcing a single running Tauri instance and routing subsequent launches to the already-running process, restoring the main window instead of starting a second app process.
Changes:
- Add
tauri-plugin-single-instanceand register it in the Tauri builder to prevent multiple concurrent instances. - Introduce a lifecycle hook (
on_second_instance) that restores the main window when a second launch attempt occurs. - Update lockfile to include the new plugin and its dependencies.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src-tauri/src/lifecycle.rs |
Adds on_second_instance to restore the main window when the single-instance plugin reports a second launch attempt. |
src-tauri/src/lib.rs |
Registers the single-instance plugin and wires it to the lifecycle hook to restore the existing window. |
src-tauri/Cargo.toml |
Adds the tauri-plugin-single-instance dependency. |
Cargo.lock |
Records the new dependency resolution for the single-instance plugin. |
Summary
Why
On Windows, close-to-tray keeps the first process alive. Launching the app again created a second process, which registered another tray icon and caused tray icon duplication.
This PR is stacked on #1457 so it can reuse
lifecycle::restore_main_windowwithout duplicating the macOS Dock reopen changes.Validation
cargo check --manifest-path src-tauri/Cargo.tomlcargo test --manifest-path src-tauri/Cargo.toml lifecycle::testsSummary by CodeRabbit