Repository navigation
Conversation
|
@MarshallOfSound It is still there :(, I'll see if I can fix it. |
|
I have submitted a patch to upstream Chromium to fix the tray icon disappearing problem: |
|
I saw we updated the Tray documentation - is there anything else that Linux developers/users would need to modify in their app for these Tray changes, or should they work out of the box? |
Existing apps will just work without any modification, this PR only fixes limitations of previous implementation without changing existing behaviors. |
nornagon
left a comment
There was a problem hiding this comment.
overall lgtm, hope we can get some movement on the chromium review upstream!
| * Tray icon requires support of [StatusNotifierItem](https://www.freedesktop.org/wiki/Specifications/StatusNotifierItem/) | ||
| in user's desktop environment. |
There was a problem hiding this comment.
| * Tray icon requires support of [StatusNotifierItem](https://www.freedesktop.org/wiki/Specifications/StatusNotifierItem/) | |
| in user's desktop environment. | |
| * The user's desktop environment must support [StatusNotifierItem](https://www.freedesktop.org/wiki/Specifications/StatusNotifierItem/) | |
| in order to display a tray icon. |
| * The `click` event is emitted when the tray icon receives activation from | ||
| user, however the StatusNotifierItem spec does not specify which action would | ||
| cause an activation, for some environments it is left mouse click, but for | ||
| some it might be double left mouse click. |
There was a problem hiding this comment.
| * The `click` event is emitted when the tray icon receives activation from | |
| user, however the StatusNotifierItem spec does not specify which action would | |
| cause an activation, for some environments it is left mouse click, but for | |
| some it might be double left mouse click. | |
| * The `click` event is emitted when the tray icon receives activation from the | |
| user. However, the StatusNotifierItem spec does not specify which interactions | |
| cause an activation. For some environments, a left mouse click causes an | |
| activation, but for others it might be double left mouse click, or some other | |
| interaction. |
| Note that on Linux this event is emitted when the tray icon receives an | ||
| activation, which might not necessarily be left mouse click. |
There was a problem hiding this comment.
| Note that on Linux this event is emitted when the tray icon receives an | |
| activation, which might not necessarily be left mouse click. | |
| Note that on Linux this event is emitted when the tray icon receives an | |
| activation, which might not necessarily be a left mouse click. |
|
Release Notes Persisted
|
PwrSnap showed no tray icon on Ubuntu/GNOME. The `Tray` was created, and
then every affordance hung off it was wired to an API Electron declares
macOS/Windows-only: `popUpContextMenu()` and the `right-click` event
(so the menu could never be raised), and `getBounds()` (so
`positionTrayWindow` had no rectangle for the popover). `setContextMenu`
— the only menu API with no platform annotation, and the one Linux
path — was never called. The tray had no menu at all there.
Linux now uses the native menu as its ONLY tray surface, and does not
build the popover BrowserWindow. That is forced, not chosen: on top of
the two `Tray` limits above, `BrowserWindow.setPosition` is documented
"Not supported on Wayland (Linux)" and `setContentSize` "may not work"
there — and `setContentSize` is the single call the whole resize-to-fit
popover design rests on.
Measured on a real Linux Electron 41.10.7 under xvfb, with no session
bus and again under `dbus-run-session` with no SNI host:
new Tray(<path>) ok (even with no DBUS_SESSION_BUS_ADDRESS)
tray.setContextMenu(m) ok, and safe to repeat
tray.getBounds() {x: 0, y: 0, width: 0, height: 0}
tray.setTitle("● REC") returns, shows nothing
Also in this change:
- The menu is re-published on every input that can change a label —
recording phase, hotkey ownership, the dev seeder's items. Electron
requires `setContextMenu` again for MenuItem changes to take effect,
and the Linux menu is a persistent D-Bus object rather than a template
read at right-click time. Nothing time-varying may go in it, so the
recording row carries no `mm:ss` clock on a persistent menu (the phase
is set once; there is no tick to rebuild off).
- The publish is non-fatal. `installTray` runs un-awaited inside
`app.whenReady().then(...)` and `setTrayHotkeys` runs on every settings
write, so a throw would cost the boot or a settings patch.
- A 48px `tray-icon-linux.png` with no @nx siblings.
`StatusIconLinuxDbus` publishes the scale-1 bitmap, and siblings are
representations of one 16pt image: `toBitmap()` measures 1024 bytes
(16×16×4) for the `tray-icon.png` set vs 9216 (48×48×4) for the new
file, so HiDPI panels were upscaling 16px.
- A `gdbus NameHasOwner org.kde.StatusNotifierWatcher` probe logged at
startup with the per-desktop remedy. A StatusNotifierItem registration
with no host raises no error and fires no event, so "no tray icon" was
otherwise undiagnosable. It reports `unknown` rather than `absent`
whenever it cannot reach a verdict, so a healthy session is never told
to install a GNOME extension it already has. It never gates the tray —
a host that starts later is picked up by Chromium's NameOwnerChanged.
- There is NO libayatana-appindicator3 dependency to declare: Electron
stopped routing the tray through libappindicator in Electron 22
(electron/electron#36333) and speaks SNI over D-Bus itself. What a
user needs is an SNI host — native on KDE, preinstalled on Ubuntu
GNOME, an extension on vanilla GNOME, a bar's tray module on wlroots.
- `Tray.setTitle` is now routed through a darwin-only guard. Measured
inert off macOS, so this fixes no crash; it stops the code implying
the recording dot and timed countdown are visible on three platforms
when they are visible on one.
- `disposeTray` resets the hotkey status resolver, not just the
spellings — `activeTrayAccelerator` reads the two together.
- `buildTrayContextMenuTemplate` passes its `platform` argument into
`recordingBackendCapabilities` instead of letting it read
`process.platform`, so the function is testable for one platform from
a CI host running another. Runtime behavior is unchanged.
macOS and Windows are untouched, and the tests assert they never call
`setContextMenu`: on an NSStatusItem that hands left-click to the menu
and suppresses the `click` event the popover is toggled from.
New docs/linux-tray-support.md carries the support matrix, the GNOME
extension instructions, the measurements and the container probe recipe;
AGENTS.md gains the enforcement section.
Co-Authored-By: Claude Opus 5 <[email protected]>
PwrSnap showed no tray icon on Ubuntu/GNOME. The `Tray` was created, and
then every affordance hung off it was wired to an API Electron declares
macOS/Windows-only: `popUpContextMenu()` and the `right-click` event
(so the menu could never be raised), and `getBounds()` (so
`positionTrayWindow` had no rectangle for the popover). `setContextMenu`
— the only menu API with no platform annotation, and the one Linux
path — was never called. The tray had no menu at all there.
Linux now uses the native menu as its ONLY tray surface, and does not
build the popover BrowserWindow. That is forced, not chosen: on top of
the two `Tray` limits above, `BrowserWindow.setPosition` is documented
"Not supported on Wayland (Linux)" and `setContentSize` "may not work"
there — and `setContentSize` is the single call the whole resize-to-fit
popover design rests on.
Measured on a real Linux Electron 41.10.7 under xvfb, with no session
bus and again under `dbus-run-session` with no SNI host:
new Tray(<path>) ok (even with no DBUS_SESSION_BUS_ADDRESS)
tray.setContextMenu(m) ok, and safe to repeat
tray.getBounds() {x: 0, y: 0, width: 0, height: 0}
tray.setTitle("● REC") returns, shows nothing
Also in this change:
- The menu is re-published on every input that can change a label —
recording phase, hotkey ownership, the dev seeder's items. Electron
requires `setContextMenu` again for MenuItem changes to take effect,
and the Linux menu is a persistent D-Bus object rather than a template
read at right-click time. Nothing time-varying may go in it, so the
recording row carries no `mm:ss` clock on a persistent menu (the phase
is set once; there is no tick to rebuild off).
- The publish is non-fatal. `installTray` runs un-awaited inside
`app.whenReady().then(...)` and `setTrayHotkeys` runs on every settings
write, so a throw would cost the boot or a settings patch.
- A 48px `tray-icon-linux.png` with no @nx siblings.
`StatusIconLinuxDbus` publishes the scale-1 bitmap, and siblings are
representations of one 16pt image: `toBitmap()` measures 1024 bytes
(16×16×4) for the `tray-icon.png` set vs 9216 (48×48×4) for the new
file, so HiDPI panels were upscaling 16px.
- A `gdbus NameHasOwner org.kde.StatusNotifierWatcher` probe logged at
startup with the per-desktop remedy. A StatusNotifierItem registration
with no host raises no error and fires no event, so "no tray icon" was
otherwise undiagnosable. It reports `unknown` rather than `absent`
whenever it cannot reach a verdict, so a healthy session is never told
to install a GNOME extension it already has. It never gates the tray —
a host that starts later is picked up by Chromium's NameOwnerChanged.
- There is NO libayatana-appindicator3 dependency to declare: Electron
stopped routing the tray through libappindicator in Electron 22
(electron/electron#36333) and speaks SNI over D-Bus itself. What a
user needs is an SNI host — native on KDE, preinstalled on Ubuntu
GNOME, an extension on vanilla GNOME, a bar's tray module on wlroots.
- `Tray.setTitle` is now routed through a darwin-only guard. Measured
inert off macOS, so this fixes no crash; it stops the code implying
the recording dot and timed countdown are visible on three platforms
when they are visible on one.
- `disposeTray` resets the hotkey status resolver, not just the
spellings — `activeTrayAccelerator` reads the two together.
- `buildTrayContextMenuTemplate` passes its `platform` argument into
`recordingBackendCapabilities` instead of letting it read
`process.platform`, so the function is testable for one platform from
a CI host running another. Runtime behavior is unchanged.
macOS and Windows are untouched, and the tests assert they never call
`setContextMenu`: on an NSStatusItem that hands left-click to the menu
and suppresses the `click` event the popover is toggled from.
New docs/linux-tray-support.md carries the support matrix, the GNOME
extension instructions, the measurements and the container probe recipe;
AGENTS.md gains the enforcement section.
Co-Authored-By: Claude Opus 5 <[email protected]>
PwrSnap showed no tray icon on Ubuntu/GNOME. The `Tray` was created, and
then every affordance hung off it was wired to an API Electron declares
macOS/Windows-only: `popUpContextMenu()` and the `right-click` event
(so the menu could never be raised), and `getBounds()` (so
`positionTrayWindow` had no rectangle for the popover). `setContextMenu`
— the only menu API with no platform annotation, and the one Linux
path — was never called. The tray had no menu at all there.
Linux now uses the native menu as its ONLY tray surface, and does not
build the popover BrowserWindow. That is forced, not chosen: on top of
the two `Tray` limits above, `BrowserWindow.setPosition` is documented
"Not supported on Wayland (Linux)" and `setContentSize` "may not work"
there — and `setContentSize` is the single call the whole resize-to-fit
popover design rests on.
Measured on a real Linux Electron 41.10.7 under xvfb, with no session
bus and again under `dbus-run-session` with no SNI host:
new Tray(<path>) ok (even with no DBUS_SESSION_BUS_ADDRESS)
tray.setContextMenu(m) ok, and safe to repeat
tray.getBounds() {x: 0, y: 0, width: 0, height: 0}
tray.setTitle("● REC") returns, shows nothing
Also in this change:
- The menu is re-published on every input that can change a label —
recording phase, hotkey ownership, the dev seeder's items. Electron
requires `setContextMenu` again for MenuItem changes to take effect,
and the Linux menu is a persistent D-Bus object rather than a template
read at right-click time. Nothing time-varying may go in it, so the
recording row carries no `mm:ss` clock on a persistent menu (the phase
is set once; there is no tick to rebuild off).
- The publish is non-fatal. `installTray` runs un-awaited inside
`app.whenReady().then(...)` and `setTrayHotkeys` runs on every settings
write, so a throw would cost the boot or a settings patch.
- A 48px `tray-icon-linux.png` with no @nx siblings.
`StatusIconLinuxDbus` publishes the scale-1 bitmap, and siblings are
representations of one 16pt image: `toBitmap()` measures 1024 bytes
(16×16×4) for the `tray-icon.png` set vs 9216 (48×48×4) for the new
file, so HiDPI panels were upscaling 16px.
- A `gdbus NameHasOwner org.kde.StatusNotifierWatcher` probe logged at
startup with the per-desktop remedy. A StatusNotifierItem registration
with no host raises no error and fires no event, so "no tray icon" was
otherwise undiagnosable. It reports `unknown` rather than `absent`
whenever it cannot reach a verdict, so a healthy session is never told
to install a GNOME extension it already has. It never gates the tray —
a host that starts later is picked up by Chromium's NameOwnerChanged.
- There is NO libayatana-appindicator3 dependency to declare: Electron
stopped routing the tray through libappindicator in Electron 22
(electron/electron#36333) and speaks SNI over D-Bus itself. What a
user needs is an SNI host — native on KDE, preinstalled on Ubuntu
GNOME, an extension on vanilla GNOME, a bar's tray module on wlroots.
- `Tray.setTitle` is now routed through a darwin-only guard. Measured
inert off macOS, so this fixes no crash; it stops the code implying
the recording dot and timed countdown are visible on three platforms
when they are visible on one.
- `disposeTray` resets the hotkey status resolver, not just the
spellings — `activeTrayAccelerator` reads the two together.
- `buildTrayContextMenuTemplate` passes its `platform` argument into
`recordingBackendCapabilities` instead of letting it read
`process.platform`, so the function is testable for one platform from
a CI host running another. Runtime behavior is unchanged.
macOS and Windows are untouched, and the tests assert they never call
`setContextMenu`: on an NSStatusItem that hands left-click to the menu
and suppresses the `click` event the popover is toggled from.
New docs/linux-tray-support.md carries the support matrix, the GNOME
extension instructions, the measurements and the container probe recipe;
AGENTS.md gains the enforcement section.
Co-Authored-By: Claude Opus 5 <[email protected]>
#594) * fix(desktop): make the Linux tray a native menu so the indicator works PwrSnap showed no tray icon on Ubuntu/GNOME. The `Tray` was created, and then every affordance hung off it was wired to an API Electron declares macOS/Windows-only: `popUpContextMenu()` and the `right-click` event (so the menu could never be raised), and `getBounds()` (so `positionTrayWindow` had no rectangle for the popover). `setContextMenu` — the only menu API with no platform annotation, and the one Linux path — was never called. The tray had no menu at all there. Linux now uses the native menu as its ONLY tray surface, and does not build the popover BrowserWindow. That is forced, not chosen: on top of the two `Tray` limits above, `BrowserWindow.setPosition` is documented "Not supported on Wayland (Linux)" and `setContentSize` "may not work" there — and `setContentSize` is the single call the whole resize-to-fit popover design rests on. Measured on a real Linux Electron 41.10.7 under xvfb, with no session bus and again under `dbus-run-session` with no SNI host: new Tray(<path>) ok (even with no DBUS_SESSION_BUS_ADDRESS) tray.setContextMenu(m) ok, and safe to repeat tray.getBounds() {x: 0, y: 0, width: 0, height: 0} tray.setTitle("● REC") returns, shows nothing Also in this change: - The menu is re-published on every input that can change a label — recording phase, hotkey ownership, the dev seeder's items. Electron requires `setContextMenu` again for MenuItem changes to take effect, and the Linux menu is a persistent D-Bus object rather than a template read at right-click time. Nothing time-varying may go in it, so the recording row carries no `mm:ss` clock on a persistent menu (the phase is set once; there is no tick to rebuild off). - The publish is non-fatal. `installTray` runs un-awaited inside `app.whenReady().then(...)` and `setTrayHotkeys` runs on every settings write, so a throw would cost the boot or a settings patch. - A 48px `tray-icon-linux.png` with no @nx siblings. `StatusIconLinuxDbus` publishes the scale-1 bitmap, and siblings are representations of one 16pt image: `toBitmap()` measures 1024 bytes (16×16×4) for the `tray-icon.png` set vs 9216 (48×48×4) for the new file, so HiDPI panels were upscaling 16px. - A `gdbus NameHasOwner org.kde.StatusNotifierWatcher` probe logged at startup with the per-desktop remedy. A StatusNotifierItem registration with no host raises no error and fires no event, so "no tray icon" was otherwise undiagnosable. It reports `unknown` rather than `absent` whenever it cannot reach a verdict, so a healthy session is never told to install a GNOME extension it already has. It never gates the tray — a host that starts later is picked up by Chromium's NameOwnerChanged. - There is NO libayatana-appindicator3 dependency to declare: Electron stopped routing the tray through libappindicator in Electron 22 (electron/electron#36333) and speaks SNI over D-Bus itself. What a user needs is an SNI host — native on KDE, preinstalled on Ubuntu GNOME, an extension on vanilla GNOME, a bar's tray module on wlroots. - `Tray.setTitle` is now routed through a darwin-only guard. Measured inert off macOS, so this fixes no crash; it stops the code implying the recording dot and timed countdown are visible on three platforms when they are visible on one. - `disposeTray` resets the hotkey status resolver, not just the spellings — `activeTrayAccelerator` reads the two together. - `buildTrayContextMenuTemplate` passes its `platform` argument into `recordingBackendCapabilities` instead of letting it read `process.platform`, so the function is testable for one platform from a CI host running another. Runtime behavior is unchanged. macOS and Windows are untouched, and the tests assert they never call `setContextMenu`: on an NSStatusItem that hands left-click to the menu and suppresses the `click` event the popover is toggled from. New docs/linux-tray-support.md carries the support matrix, the GNOME extension instructions, the measurements and the container probe recipe; AGENTS.md gains the enforcement section. Co-Authored-By: Claude Opus 5 <[email protected]> * test(desktop): compare the tray icon path with join, not a "/" literal The new Linux tray spec asserted `"/fake/app/build/tray-icon-linux.png"` as a literal. `resolveTrayIconPath` builds it with `node:path`, which picks its separator from the REAL platform at import time and ignores the `process.platform` the suite fakes — so the assertion passed locally and on the macOS runner, then failed on the Windows one with `\fake\app\build\tray-icon-linux.png`. Compare against the same `join` production uses. The filename is what the assertion is actually about. Co-Authored-By: Claude Opus 5 <[email protected]> * fix(desktop): pass the tray NativeImage, and publish the menu only on change Review of #594 found two real defects in it. 1. Passing the icon PATH on Linux turned a missing icon resource into an ABORTED BOOT. Measured on Electron 41.10.7 under Linux: new Tray(<NativeImage>) + setContextMenu ok new Tray(<path>) + setContextMenu ok — identical new Tray(<missing path>) THROWS new Tray(<empty NativeImage>) ok — blank icon `installTray` runs un-awaited inside `app.whenReady().then(...)`, so that throw takes the focus sink and the selector pre-warm with it. And `icon.isEmpty()` already detected the case and logged a warning one line above. The path form was justified as belt-and-braces against Electron's supposed Linux preference for a real file; it is measurably equivalent, so it bought nothing and cost a boot. Always the NativeImage now, on every platform. That warning also promised a "falling back to setTitle text" that does not exist — `setTrayTitleIfSupported` gates setTitle to darwin, and no caller sets a persistent title on any platform. It now says the tray will render blank, which is what happens. 2. `refreshNativeTrayMenu` re-exported the menu unconditionally, and `setTrayHotkeys` is wired to `onSettingsChanged` — which fires on EVERY settings and secret write. So a theme toggle replaced the DBusMenu. Not just waste: `setContextMenu` replaces the exported object, and some SNI hosts close an open menu when that happens, the same hazard the recording-clock comment cites for per-second republishes. It now compares a signature of the template (labels, accelerators, enabled flags, type, recursing into submenus) and publishes only on a difference. A failed export deliberately does not record the signature, so the next refresh retries instead of freezing the tray at the last menu that did publish. The same gate removes a double export at boot: subscribeToRecordingState invokes its handler synchronously on subscribe, which already reached refreshNativeTrayMenu before the native-menu arm's own call. Also from the review: - The stdout cap in the gdbus probe gated the append instead of clamping the result, so one arbitrarily large chunk was buffered whole — the case the bound exists for. - One `logTrayInstalled` helper instead of the log call duplicated across both exits of installTray. - Tests pin that Linux skips the tray resize channel (the diff claimed it in a comment and only the renderer half was covered), that Tray gets a NativeImage, that a missing icon still installs a working menu, and all five change-detection behaviors including the failed-export retry. Two findings are documented rather than changed. A StatusNotifierItem "activate" still does nothing on Linux: Electron does emit `click` there, but both candidate responses are wrong on some host, and `popUpContextMenu` is macOS/Windows-only so "show the menu" is not available — that needs measurement on real desktops, not a guess. And `formatElapsed` duplicates the renderer HUD's mm:ss formatter, which predates this branch and spans the main/renderer boundary. Co-Authored-By: Claude Opus 5 <[email protected]> * docs(desktop): measure the Linux tray against a real SNI host The doc said the container recipe cannot show whether the icon draws and that only a real desktop session can. A headless sway + waybar session in the same container IS a real StatusNotifierItem host, so this adds that recipe and what it measured against this branch's real build on Electron 41.10.7: - the icon draws in waybar's tray, and IconPixmap is one 48x48 image - GetLayout exports Quick Capture (with its accelerator), Record Video, Open Library, Settings and Quit, and dbusmenu Event clicks dispatch them - the host probe logs statusNotifierHost=present Two corrections come out of the same run: - The "all Electron apps share one indicator id" limitation does not reproduce at this pin. The item's Id is PwrSnap_status_icon_1, not chrome_status_icon_1, so electron/electron#40936 is noted as something to re-check on a bump rather than a standing limitation. - The "activate does nothing" note now carries the measurement it said was missing on Electron's side: Activate AND SecondaryActivate both emit click, ContextMenu emits nothing, and the item exports ItemIsMenu=false. And one new limitation: under Wayland a tray action cannot raise a PwrSnap window that is already open. Electron's item does not implement ProvideXdgActivationToken (UnknownMethod), so a menu click carries no activation token; on sway "Open Library" left focus on Settings. Claude-Session: https://claude.ai/code/session_01Gdx6F1J8cpHue5h47y1d8y * fix(desktop): no per-second countdown on the Linux tray menu Review follow-ups on the native Linux menu. - The recording lead-in row read "Cancel recording start (N)" on every platform. `countdown` is emitted once a second, so on the persistent Linux menu each new count was a setContextMenu republish that could replace the menu under the user's cursor mid-countdown - the same reason the elapsed clock is already dropped there. Linux now shows the bare label; macOS and Windows keep the count (they rebuild on right-click). - trayMenuSignature compared only label, enabled, accelerator and type, so a change to sublabel, toolTip, role, visible or checked would have been deduped away and never republished. It now covers all of them. Claude-Session: https://claude.ai/code/session_01Gdx6F1J8cpHue5h47y1d8y --------- Co-authored-by: Claude Opus 5 <[email protected]>
Description of Change
This PR rewrites Tray's implementation on Linux with
StatusIconLinuxDbus, which communicates with the desktop environment with dbus directly instead of relying on libappindicator.Close #36283.
Close #36274.
Close #28956.
Close #28131.
Close #27527.
Close #14941.
Close #14635.
Release Notes
Notes: Fix
clickevent and tooltip ofTraynot working on Linux.