Skip to content

fix(tray): show the tray icon on Linux by attaching its menu - #329

Open
hiro-nikaitou wants to merge 1 commit into
tonyantony300:mainfrom
hiro-nikaitou:fix/linux-tray-menu
Open

hiro-nikaitou wants to merge 1 commit into
tonyantony300:mainfrom
hiro-nikaitou:fix/linux-tray-menu

Conversation

@hiro-nikaitou

Copy link
Copy Markdown

The Windows tray refactor split the builder in two and the Linux branch kept only
the click handler, not the menu. tray-icon 0.21.3 (pinned in
src-tauri/Cargo.lock) documents two Linux facts that make that combination
invisible:

  • TrayIconBuilder::menu / TrayIcon::new: "Linux: Sometimes the icon won't be
    visible unless a menu is set. Setting an empty Menu is enough."
  • TrayIconEvent: "Linux: Unsupported. The event is not emmited even though the
    icon is shown"

So on Linux the indicator was built with no menu at all (popup_tray_menu could
never be reached), and hosts such as KDE Plasma never displayed it. With close
hidden to the tray there was then no way back to the window.

The Linux builder now attaches the same menu the other platforms attach; the
appindicator host opens it on click, and Open restores the window.

Verification, on the base revision ccc1eb8 and on the patched tree:

  • a small script that extracts the cfg(not(any(target_os = "macos", target_os = "windows"))) builder and reports whether it attaches a menu:
    • base revision -> LINUX_MENU_ATTACHED=false
    • v0.6.2, the last release with a visible icon -> LINUX_MENU_ATTACHED=true
    • patched -> LINUX_MENU_ATTACHED=true
  • cargo fmt --manifest-path src-tauri/Cargo.toml -- --check -> exit 0 (the CI
    format:check step); it parses tray.rs, so the edit is syntactically valid
  • git diff --numstat -> 3 1 src-tauri/src/tray.rs

Not covered: nothing here compiles or runs the Linux target (libappindicator/GTK
are not available, and the branch is cfg-excluded on Windows), so the fix rests
on the crate's documented Linux behaviour plus the 0.6.2-to-0.6.9 regression
rather than on running the app on a Linux desktop.

Left alone: the Linux click handler and popup_tray_menu stay (they are dead on
Linux now) to keep this diff minimal; deleting them is an easy follow-up.

Fixes #316

Signed-off-by: hiro-nikaitou <vieteviete@proton.me>
@CLAassistant

CLAassistant commented Sep 23, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 15be4093-52b5-47b4-b47d-f49fa3de0b85

📥 Commits

Reviewing files that changed from the base of the PR and between ccc1eb8 and faf96fb.

📒 Files selected for processing (1)
  • src-tauri/src/tray.rs

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The Linux tray builder now attaches the menu during tray icon creation. The Linux tray event handler remains unchanged.

Changes

Linux tray icon

Layer / File(s) Summary
Attach the menu during tray icon creation
src-tauri/src/tray.rs
The Linux tray builder passes the menu to the tray icon builder. The existing Linux tray event handler is unchanged.

Assessment against linked issues

Objective Addressed Explanation
Make the system tray icon appear on Linux [#316] ✅

Suggested reviewers: tonyantony300

Merge Risk: ⚪ Minimal · up to faf96

No actionable defect is established. The change is mergeable after normal checks, though confirming the tray flow on a Linux appindicator desktop would validate the intended behavior.

🚥 Pre-merge checks | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Warning

Some tools did not complete. Review the errors below.

🔧 Clippy (1.98.0)

Clippy execution timed out


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.

❤️ Share

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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

system tray icon missing on Linux in v0.6.9–0.7.1

2 participants