Skip to content

fix(tray): populate Linux right-click menu via setContextMenu#2856

Open
BlueManCZ wants to merge 2 commits intogitify-app:mainfrom
BlueManCZ:fix/linux-tray-menu
Open

fix(tray): populate Linux right-click menu via setContextMenu#2856
BlueManCZ wants to merge 2 commits intogitify-app:mainfrom
BlueManCZ:fix/linux-tray-menu

Conversation

@BlueManCZ
Copy link
Copy Markdown
Contributor

@BlueManCZ BlueManCZ commented May 8, 2026

Summary

Right-clicking the tray icon on Linux opened an empty menu (or nothing at all on some DEs) because the existing right-clickpopUpContextMenu handler doesn't reach libappindicator / StatusNotifierItem (D-Bus). On that path, Electron only emits the right-click event when no context menu is set — setContextMenu instead hands the menu to the host indicator so it renders natively on right-click.

Left-click behavior is unchanged on every platform — menubar's own click handler still toggles the popup. Note that some tray providers (e.g. KStatusNotifier-backed indicators on GNOME) require a double-click to trigger the icon's primary action by design; that's a property of the provider, not something this PR alters either way.

The macOS / Windows code path is intentionally untouched: setContextMenu intercepts left-click on macOS and would break the menubar window toggle, so those platforms keep the existing right-click + popUpContextMenu handler.

This mirrors the approach we took in zoidsh/meru#498.

Toggle Gitify menu entry

Adds a Toggle Gitify item at the top of the right-click menu that hides the popup if it's visible and shows it otherwise. This gives users a guaranteed single-click path to the popup even on tray providers where icon activation needs a double-click. Static label (rather than dynamic Show/Hide) keeps things simple on Linux — no need to rebuild and re-call setContextMenu for label changes to propagate over D-Bus.

Test plan

  • Linux: right-click tray icon → menu shows Toggle Gitify / Check for updates / Developer / Visit Website / Quit Gitify (previously empty).
  • Linux: right-click → Toggle Gitify shows the popup; right-click → Toggle Gitify again hides it.
  • Linux: click (or double-click, depending on the tray provider) tray icon → toggles the Gitify popup as before.
  • macOS: right-click tray icon → menu still appears via popUpContextMenu; left-click still toggles popup; Toggle Gitify works.
  • Windows: right-click tray icon → menu still appears; left-click still toggles popup; Toggle Gitify works.
  • pnpm test passes (5 new tests across startup.test.ts and menu.test.ts).

May close #1612, #2096 — both threads include the empty/unresponsive right-click menu reported here.

🤖 Generated with Claude Code

On Linux, trays go through libappindicator / StatusNotifierItem
(D-Bus). Electron only emits 'right-click' on that path when no
context menu is set, so the popUpContextMenu call inside our JS
handler showed an empty menu (or nothing) depending on the
desktop environment. Hand the menu to the host indicator
instead so it renders natively on right-click.

Keep the existing right-click + popUpContextMenu path on
macOS / Windows — setContextMenu intercepts left-click on
macOS and would break the menubar window toggle.

Refs gitify-app#1612, gitify-app#2096.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@github-actions github-actions Bot added the bug Something isn't working label May 8, 2026
Some Linux tray providers (e.g. KStatusNotifier-backed indicators
on GNOME) require a double-click on the icon to trigger the
primary action. A "Toggle Gitify" menu item gives users a
guaranteed single-click path to show or hide the popup
regardless of the provider's activation behavior.

Static label keeps the menu cheap on Linux — no need to rebuild
and re-call setContextMenu on visibility changes for a Show/Hide
label flip to propagate over D-Bus.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@setchy
Copy link
Copy Markdown
Member

setchy commented May 8, 2026

Can you help me better understand the Toggle Gitify option....

@BlueManCZ
Copy link
Copy Markdown
Contributor Author

It's just Show/Hide for the Gitify window. Applications usually have this in tray menu, I thought Gitify may have this as well.

@setchy
Copy link
Copy Markdown
Member

setchy commented May 8, 2026

It's just Show/Hide for the Gitify window. Applications usually have this in tray menu, I thought Gitify may have this as well.

Gotcha

Is this a common context menu in each Linux app? What would the experience be like if this was left out?

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

Labels

bug Something isn't working

Development

Successfully merging this pull request may close these issues.

Unable to open Gitify on Pop!_OS 22.04

2 participants