Skip to content

fix(desktop): minimizing the main window on Windows hides it to the tray - #188

Open
nondeletable wants to merge 1 commit into
amicalhq:mainfrom
nondeletable:fix/windows-minimize-to-tray
Open

nondeletable wants to merge 1 commit into
amicalhq:mainfrom
nondeletable:fix/windows-minimize-to-tray

Conversation

@nondeletable

@nondeletable nondeletable commented Oct 9, 2026 •

Copy link
Copy Markdown

Fixes #178

Summary

The main window had close and closed handlers but no minimize handler, so minimizeToTray was never read. I added one: on Windows, if the preference is on (it defaults to true), the minimized window is hidden, so it leaves the taskbar. Clicking the tray icon or "Open Console" already goes through createOrShowMainWindow(), which restores and shows it, so nothing else needed to change.

macOS is left as it was, since the issue is about Windows and minimizing to the Dock is normal there.

Validation

  • Tested by hand on Windows 11 (10.0.26200) with electron-forge start. Before: the minimized window stayed on the taskbar. After: it disappears from the taskbar and comes back from the tray icon.
  • Added 3 tests to tests/main/window-manager.test.ts (preference on, preference off, macOS). The first two fail on main.
  • pnpm test in apps/desktop: 1461 passed, 6 failed. The 6 failures are in app-launch.test.ts and shortcut-manager-unassign.test.ts and fail the same way on main on my machine (ERR_MODULE_NOT_FOUND with a file:///C:/C:/... path), so they look like a Windows path issue in those tests rather than something from this change.
  • type:check passes, prettier --check and eslint are clean for the changed files.

One note: the "Minimize to tray" switch in Preferences is still commented out, so users can't turn this off from the UI. I didn't touch it since it looked intentional, but I can re-enable it here if you'd like.

Summary by CodeRabbit

  • New Features
    • On Windows, the main window can be hidden to the tray when minimized, based on the corresponding preference. When this preference is off, minimizing leaves the window visible.
  • Bug Fixes
    • Restoring a window hidden to the tray makes it visible again and clears its minimized state. On macOS, minimizing does not query this Windows-specific preference or hide the window.

@coderabbitai

coderabbitai Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

On Windows, minimizing the main window now checks the minimizeToTray preference. When enabled and the window is still minimized, the handler hides it. Tests cover preference settings, reopening the window, and non-Windows behavior.

Changes: Main-window minimize behavior

Layer / File(s) Summary
Minimize handling and validation
apps/desktop/src/main/core/window-manager.ts, apps/desktop/tests/main/window-manager.test.ts
The minimize event invokes a handler that checks the preference on Windows and hides the window when enabled and still minimized. Tests cover both preference settings, reopening the window, and non-Windows behavior.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: haritabh-z01

Merge Risk: Minimal · up to 5f5ea

Windows users can minimize to the tray and reopen the window. No merge-blocking issue was identified.

Pre-merge checks: Passed 5

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: minimizing the main window on Windows hides it to the tray. The raw summary confirms a minimize handler in window-manager.ts that calls hideMinimizedMainWindowToTray. …
Linked Issues check Passed Issue #178 requires three coding behaviors on Windows. (1) When minimizeToTray is enabled, minimizing the main window hides it from the taskbar. (2) The app stays running and reachable from the tray i…
Out of Scope Changes check Passed The PR summary lists two changed files. apps/desktop/src/main/core/window-manager.ts adds the minimize listener and the hideMinimizedMainWindowToTray helper. This directly implements #178. apps/deskto…
Docstring Coverage Passed Docstring coverage is inconclusive: files from earlier reviews still need to be rechecked within the check's analysis limits. Not blocking.
Full details: Title check

Explanation

The title names the main change: minimizing the main window on Windows hides it to the tray. The raw summary confirms a minimize handler in window-manager.ts that calls hideMinimizedMainWindowToTray. It applies only on Windows and only when minimizeToTray is enabled. The PR objectives describe the same behavior and tie it to issue #178. The title uses the conventional fix(desktop) prefix and stays under 72 characters.

Full details: Linked Issues check

Explanation

Issue #178 requires three coding behaviors on Windows. (1) When minimizeToTray is enabled, minimizing the main window hides it from the taskbar. (2) The app stays running and reachable from the tray icon. (3) The tray "Open Console" action restores the window. At head, WindowManager.createOrShowMainWindow() registers mainWindow.on("minimize") and calls hideMinimizedMainWindowToTray(). That helper returns on non-win32 platforms. On win32 it reads getPreferences().minimizeToTray and calls window.hide() only when the window is alive and minimized. Errors are logged. For (2) and (3), tray-manager.ts at head routes both the tray click/double-click and the "Open Console" menu item to windowManager.createOrShowMainWindow(). That path restores a minimized window, then calls show() and focus() on the existing window. The commented-out Preferences switch is not a coding requirement of #178. The diff tool was unavailable, so the incremental change since the previous head was not read directly. The conclusion rests on the head file contents and the tray flow, which still satisfy the issue requirements.

Full details: Out of Scope Changes check

Explanation

The PR summary lists two changed files. apps/desktop/src/main/core/window-manager.ts adds the minimize listener and the hideMinimizedMainWindowToTray helper. This directly implements #178. apps/desktop/tests/main/window-manager.test.ts adds window-manager tests for the Windows preference-on, preference-off, and macOS cases. These tests support the implementation. The head file shows no unrelated behavior changes in the minimize path. The macOS path stays unchanged, as the PR objective states. The full-PR diff could not be read, so the changed-file list relies on the supplied summary and the head file contents. No unrelated change was demonstrated.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

apps/desktop/src/main/core/window-manager.ts

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b426d537-18de-4dd9-9bea-f6e7b3f9a0b3
Commits

Reviewing files that changed from the base of the PR and between adb8efc and 5f5ea51.

Files selected for processing: 1

  • apps/desktop/src/main/core/window-manager.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@nondeletable
nondeletable force-pushed the fix/windows-minimize-to-tray branch from adb8efc to 5f5ea51 Compare November 9, 2026 01:27
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.

Windows: minimizeToTray preference is not applied to the main window

1 participant