Menu

#396 feat(tray): open dashboard when app is re-activated externally

closed
nobody
None
2026-07-07
2026-07-07
Anonymous
No

Originally created by: Akarsh-Hegde

Summary

  • Add a Tauri RunEvent::Reopen handler so activating Meridian externally (Spotlight, dock click, open -a Meridian) actually opens something instead of being a silent no-op while the tray is running.
  • Onboarded → dashboard window. Not onboarded → setup wizard (resumes a partial onboard).
  • Cold-start behavior unchanged: the setup hook still auto-opens the wizard on first launch.

Why

The tray runs as ActivationPolicy::Accessory — no dock icon most of the time — and Tauri drops the reopen event on the floor without a handler. Users hitting ⌘Space → "Meridian" ⏎ saw nothing happen.

Test plan

  • [ ] Fresh ~/.meridian (no onboarded file) → Spotlight-launch Meridian on an already-running tray → setup wizard opens.
  • [ ] With onboarded present → Spotlight-launch Meridian → dashboard window opens (or focuses if already open).
  • [ ] Dock click while dashboard is open → dashboard focuses.
  • [ ] cargo check + cargo clippy clean on tray/src-tauri/.

🤖 Generated with Claude Code

Related

Tickets: #416

Discussion

  • Anonymous

    Anonymous - 2026-07-07

    Originally posted by: coderabbitai[bot]

    [!IMPORTANT]

    Review skipped

    Auto reviews are disabled on base/target branches other than the default branch.

    Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.


    ⚙️ Run configuration

    Configuration used: Organization UI

    Review profile: ASSERTIVE

    Plan: Pro Plus

    Run ID: 342f3756-3ac2-4508-a69c-2ed88cb8101a

    You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

    Use the checkbox below for a quick retry:
    - [ ] 🔍 Trigger review

    ✨ Finishing Touches
    🧪 Generate unit tests (beta) - [ ] Create PR with unit tests - [ ] Commit unit tests in branch `feat/reopen-opens-dashboard`

    Comment @coderabbitai help to get the list of available commands.

     
  • Anonymous

    Anonymous - 2026-07-07

    Originally posted by: adityaharishch

    Reviewed the diff (tray/src-tauri/src/lib.rs, tray/src-tauri/src/tray.rs). Overall this is a small, well-scoped change and it's structurally sound — no blockers.

    What checks out:

    • RunEvent::Reopen (macOS applicationShouldHandleReopen) is fired only by dock-icon click / open -a / Spotlight re-activation — it is a distinct event from the tray status-item click (TrayIconEvent), so there's no risk of this firing when the user clicks the menu-bar icon and popping the dashboard/wizard over the popover.
    • Window reuse is correct: both tray::open_native_dashboard (tray.rs:87-124) and tray::open_wizard_window (tray.rs:163-178) already get_webview_window(...) + show()/set_focus() before building a new one, so the new Reopen handler can't spawn a duplicate dashboard/setup window even on repeat activations.
    • Correctly reuses the existing openers rather than reimplementing window creation — open_native_dashboard was widened from fn to pub(crate) fn (tray.rs:87) specifically to make this possible, which is the right move (single source of truth, per the module's own doc comment about the tray-menu path needing "the same fix").

    Minor, non-blocking:

    • lib.rs:414 (Reopen handler) reads ~/.meridian/onboarded inline via std::env::var("HOME"), which is now the third copy of this exact check — commands/setup.rs:38-40 (is_first_run) and the existing first-launch auto-open at lib.rs:407-418 both do the same thing. Not introduced by this PR (the pattern already existed pre-change), but this would've been a good spot to factor into a small shared helper (e.g. fn is_onboarded() -> bool) since the PR is already touching this exact logic. Not worth blocking on.
    • The Reopen match ignores has_visible_windows (destructured as { .. }). Harmless given the reuse behavior in the openers above (a second Reopen while the dashboard is already frontmost just re-shows/re-focuses it), but if has_visible_windows is ever relevant to future logic here it's currently unused — worth a comment noting it's intentionally ignored, for the next person who touches this.
    • No .context(...) needed since there are no fallible calls here beyond the pre-existing unwrap_or_default() on HOME, which matches existing precedent elsewhere in the file (install.rs) — fine.

    Overall: looks correct and safe to merge. The event choice, window-reuse guarantees, and onboarding-vs-dashboard routing all check out.

     
  • Anonymous

    Anonymous - 2026-07-07

    Originally posted by: Akarsh-Hegde

    Follow-up commit adds test coverage and fixes a compile break:

    • Linux CI compile fix: RunEvent::Reopen is a #[cfg(target_os = "macos")] enum variant — it doesn't exist on other targets. The un-gated if let would fail to compile on ubuntu-latest, where CI builds the whole workspace (the tray is a member). The macOS-only pre-push hook can't catch this. The arm is now #[cfg(target_os = "macos")]-gated.
    • Unit tests: extracted is_onboarded(home) + reopen_target(onboarded) -> ReopenTarget (platform-independent, so the tests run in Linux CI) and added coverage for both routing arms + the onboarded-marker filesystem check.

    The OS-integration half (macOS actually delivering the reopen event on Spotlight/dock activation) still needs a manual check — there's no WebDriver path for a menu-bar app on macOS.

     
  • Anonymous

    Anonymous - 2026-07-07

    Originally posted by: Akarsh-Hegde

    Thanks for the thorough pass — both minor notes addressed:

    • Duplicated ~/.meridian/onboarded check → factored out in a follow-up (4560f56d): the reopen handler now calls a shared is_onboarded(home) helper (with a companion reopen_target(onboarded) -> ReopenTarget), both unit-tested. commands::setup::is_first_run is its documented inverse. (That follow-up also fixed a real one: RunEvent::Reopen is #[cfg(target_os = "macos")], so the un-gated if let would fail to compile on the Linux CI runner — now cfg-gated. Detail in the earlier comment.)
    • has_visible_windows ignored → added a comment (31064f71) explaining it's intentional: both openers reuse an existing window via get_webview_window + show/focus, so a reopen just re-focuses; the flag would only matter for distinct visible-vs-minimised behaviour we don't want.

    Nothing else outstanding on your review.

     
  • Anonymous

    Anonymous - 2026-07-07

    Ticket changed by: Akarsh-Hegde

    • status: open --> closed
     

Log in to post a comment.