Skip to content

feat(desktop): keep PearPass running in system tray when window is closed - #562

Open
andrey-dru-me1 wants to merge 1 commit into
tetherto:mainfrom
andrey-dru-me1:feature/background-mode
Open

feat(desktop): keep PearPass running in system tray when window is closed#562
andrey-dru-me1 wants to merge 1 commit into
tetherto:mainfrom
andrey-dru-me1:feature/background-mode

Conversation

@andrey-dru-me1

@andrey-dru-me1 andrey-dru-me1 commented Jun 14, 2026

Copy link
Copy Markdown

Closes #561

Keep PearPass running in the tray when the window is closed, so the browser-extension connection stays alive without a visible window taking up space.

  • Intercept window close: hide to tray instead of quitting
  • Tray icon with Show/Quit context menu
  • Settings toggle persisted via devicePreferences.json
  • macOS dock show/hide on tray interaction
  • Refactor devicePreferences to generic boolean-key pattern

Requirements

  • The browser extension must remain connected even when no PearPass window is visible.
  • Closing the window (red X) must not terminate the app process.
  • Users need an explicit "Quit" action in the tray to fully exit.
  • The behavior must be opt-in via a setting (off by default).

Changes

  • electron/main.cjs — added Tray creation, window-close interception (win.on('close')), forceQuit flag, backgroundModeEnabled state, and IPC handlers for show/hide/quitting.
  • electron/preload.cjs — exposed backgroundModeEnabled to the renderer.
  • src/utils/devicePreferences.cjs — generalized from a single loggingEnabled key to a DEFAULTS map with coerce() for any future boolean preferences. Added backgroundModeEnabled: false default.
  • src/utils/devicePreferences.test.js — updated tests for the new generic key pattern.
  • src/pages/SettingsView/content/AppPreferencesContent/ — added a "Keep running in background" toggle that reads/writes backgroundModeEnabled via the preload bridge.
  • src/types/electron.d.ts — added backgroundModeEnabled to the ElectronAPI type.
  • src/constants/localStorage.js — added BACKGROUND_MODE_ENABLED constant.
  • Snapshot updates (7 files) reflecting the toggle addition.

Testing Notes

  • Manually tested on macOS with the toggle on/off, verifying close-to-tray behavior, tray menu Show/Quit, and dock icon visibility.
  • Unit tests for devicePreferences updated and passing.
  • Verified browser extension stays connected when window is in tray.

Things reviewers should pay attention to

  • The forceQuit flag pattern to distinguish close-vs-quit on macOS — check that app.quit() and app.exit() are used in the right places.
  • The coerce() function in devicePreferences — this changes the write path for loggingEnabled too. Existing users upgrading will get their loggingEnabled re-written as a boolean (already the case) but now via the generic function.
  • Windows/Linux tray behavior is untested — isMac guards are in place, but dual-platform behavior should be verified.

Screenshots/Recordings

image image

Dependencies

  • No external dependencies. Depends on Electron's built-in Tray and Menu modules.

Keep PearPass running in the tray when the window is closed
to maintain the browser extension connection without keeping
a visible window open.

- Intercept window close: hide to tray instead of quitting
- Tray icon with Show/Quit context menu
- Settings toggle persisted via devicePreferences.json
- macOS dock show/hide on tray interaction
- Refactor devicePreferences to generic boolean-key pattern
@kdihalas

kdihalas commented Jul 6, 2026

Copy link
Copy Markdown

@andrey-dru-me1 i verified this on Linux and works just fine

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.

Feature Request: Background mode (Minimize to Tray) to prevent browser extension disconnects

2 participants