Skip to content

feat: import menubar patterns from gitify (hideOnClose, contextMenu, globalShortcut, helpers) - #13

Merged
afonsojramos merged 12 commits into
mainfrom
gitify-menubar-patterns
May 11, 2026
Merged

feat: import menubar patterns from gitify (hideOnClose, contextMenu, globalShortcut, helpers)#13
afonsojramos merged 12 commits into
mainfrom
gitify-menubar-patterns

Conversation

@afonsojramos

Copy link
Copy Markdown
Member

Summary

Imports patterns that gitify-app/gitify currently reaches around the library to implement, plus fixes a leaky abstraction that forced gitify to access a private field.

Fixes

  • fix(06dd7cf): switch the library's window cleanup listener from 'close' to 'closed'. Consumer 'close' handlers can now read mb.window and event.preventDefault() without racing our cleanup — removing the need for gitify's _browserWindow workaround.
  • fix(45aab90): the right-click context-menu popup now reads the current menu lazily, so setContextMenu() swaps and clears take effect without stale closures.

Features

  • feat(f5a0d0e): hideOnClose option intercepts close, defers the hide via setImmediate (Wayland half-closed-surface workaround), and passes through during before-quit / destroy(). escapeToHide option hides the window on Escape via before-input-event.
  • feat(f4856b7): ignoreDoubleClickEvents (default true on macOS) calls tray.setIgnoreDoubleClickEvents to prevent tray-icon flicker.
  • feat(528631d): contextMenu option. On Linux uses setContextMenu and re-publishes on every show/hide to defeat the libappindicator/SNI cache. On macOS/Windows pops up via tray.popUpContextMenu on right-click so left-click stays bound to the window toggle.
  • feat(4d08ff7): setGlobalShortcut(accelerator), toggleWindow(), and recenterOnTray() helpers. globalShortcut is unregistered automatically on destroy().
  • refactor(66b9e76): align setContextMenu signature with Electron's Tray.setContextMenu(menu: Menu | null).

Docs / chore

  • docs(64a10a8): README documents every new option and method.
  • style(1949587): formatter pass on the touched files.

Notes

  • Zero new runtime dependencies.
  • 62 unit tests pass (was 39); typecheck and lint clean.
  • The 'close''closed' change is a behavior change for anyone who registered a 'close' listener on mb.window and depended on it firing before our cleanup. None of the prior tests covered that path; gitify's usage benefits from the new ordering.

Test plan

  • bun run test (62/62 passing locally)
  • bun run typecheck
  • bun run lint:check
  • bun run test:e2e on macOS
  • Smoke-test on a Linux desktop (Ubuntu/GNOME for SNI; KDE if available)
  • Smoke-test on Windows
  • Drop into gitify via bun link and confirm the _browserWindow workaround in their close handler can be removed

@afonsojramos
afonsojramos merged commit 2b7fe42 into main May 11, 2026
26 checks passed
@afonsojramos
afonsojramos deleted the gitify-menubar-patterns branch June 4, 2026 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant