Skip to content

fix: honor "Start minimized" so the settings window stays hidden on launch - #599

Merged
tariknz merged 1 commit into
mainfrom
fix/start-minimized-window
Jun 19, 2026
Merged

fix: honor "Start minimized" so the settings window stays hidden on launch#599
tariknz merged 1 commit into
mainfrom
fix/start-minimized-window

Conversation

@tariknz

@tariknz tariknz commented Jun 19, 2026

Copy link
Copy Markdown
Owner

Description

When launching irDashies (e.g. via iRacing Manager) with Start minimized enabled, the settings/program window would still open instead of staying minimized to the system tray.

Root cause: The settings window was created unconditionally in createOverlays() (overlayManager.ts) using Electron's default show: true and no ready-to-show handler — unlike the overlay windows, which correctly use show: false + ready-to-show. The startMinimizedhide() logic lived in main.ts and only ran after await analytics.init(). That raced against Electron auto-showing the window on first paint: depending on timing (Electron version, how fast analytics.init resolves), the paint landed after the late .hide(), so the window opened anyway. It also re-entered createSettingsWindow, which .show()+.focus()'d the window right before hiding it.

This is why it appeared to regress — createSettingsWindow() was added to createOverlays ("open settings on startup", Apr 2025) before the start-minimized feature existed, so start-minimized has always been fighting an already-visible window, and any timing shift tipped it from "usually works" to "never works."

Fix: Create the settings window with show: false and reveal it on ready-to-show unless it should start hidden — the same pattern the overlay windows already use. createOverlays reads startMinimized and passes the intent through. Removed the redundant, racy post-await hide() block from main.ts. The minimize intent is now honored at creation time, so the window never paints when minimized (also eliminates a brief flash that occurred even when it "worked").

Screenshots

Before

With "Start minimized" enabled, the settings window opens on launch (instead of going to the tray).

After

With "Start minimized" enabled, the app starts with the settings window hidden in the system tray; opening it from the tray works as before.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I have discussed this change in the discord server
  • I have tested this in iRacing (either in an online session or with AI)
  • All tests pass locally via npm test
  • I have added tests that prove my fix is effective or that my feature works
  • I have run npm run lint and fixed any issues
  • I have performed a self-review of my own code
  • I have added/updated Storybook stories for visual changes
  • I have updated the README.md (if applicable)
  • I have updated defaultDashboard.ts if introducing new widgets or configurations (if applicable)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Settings window now supports starting in a hidden state when the "start minimized" preference is enabled, providing improved control over application startup behavior.

…ow opening

The settings window was created unconditionally in createOverlays() with
Electron's default show:true and no ready-to-show handler, while the
startMinimized -> hide() logic ran later in main.ts after an await. This
raced against Electron auto-showing the window on first paint, so the
window could open even with "Start minimized" enabled.

Create the settings window with show:false and reveal it on ready-to-show
unless it should start hidden (same pattern as the overlay windows), and
remove the redundant post-await hide() block from main.ts.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

OverlayManager.createSettingsWindow gains an options?: { startHidden?: boolean } parameter. The window is now created with show: false and revealed via a ready-to-show handler unless startHidden is true. createOverlays reads generalSettings.startMinimized and passes it as startHidden. The redundant startup-time conditional in main.ts is removed.

Changes

Settings Window Hidden-Start Refactor

Layer / File(s) Summary
createSettingsWindow hidden-start implementation
src/app/overlayManager.ts
Method signature extended with options?: { startHidden?: boolean }. BrowserWindow is created with show: false; a ready-to-show handler shows and focuses the window unless startHidden is true or the window is destroyed.
Call site update and main.ts cleanup
src/app/overlayManager.ts, src/main.ts
createOverlays derives startMinimized from generalSettings and passes { startHidden: startMinimized } to createSettingsWindow. The old conditional that created and minimized the settings window during app.on('ready') is deleted from main.ts.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐇 A window once popped up too soon,
Before its contents filled the room.
Now show: false holds the door,
ready-to-show reveals the score—
Unless we're hiding, then: no more! 🪟

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main bug fix: honoring the 'Start minimized' setting to keep the settings window hidden on launch.
Description check ✅ Passed The description comprehensively explains the problem, root cause, fix, and includes before/after screenshots and checklist items. It fully follows the template structure.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/start-minimized-window

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/app/overlayManager.ts (1)

843-849: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Honor startHidden when reusing an existing settings window.

The re-entry path always calls show()/focus(), so createOverlays(...startMinimized=true) can still surface an existing settings window and violate the hidden-start contract.

Suggested fix
   public createSettingsWindow(
     widgetType?: string,
     options?: { startHidden?: boolean }
   ): BrowserWindow {
+    const startHidden = options?.startHidden ?? false;
+
     if (this.currentSettingsWindow) {
+      if (this.currentSettingsWindow.isDestroyed()) {
+        this.currentSettingsWindow = undefined;
+      } else {
+        if (startHidden) {
+          return this.currentSettingsWindow;
+        }
+        if (this.currentSettingsWindow.isMinimized()) {
+          this.currentSettingsWindow.restore();
+        }
+        this.currentSettingsWindow.show();
+        this.currentSettingsWindow.focus();
+        return this.currentSettingsWindow;
+      }
-      if (this.currentSettingsWindow.isMinimized()) {
-        this.currentSettingsWindow.restore();
-      }
-      this.currentSettingsWindow.show();
-      this.currentSettingsWindow.focus();
-      return this.currentSettingsWindow;
     }
 
-    const startHidden = options?.startHidden ?? false;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/app/overlayManager.ts` around lines 843 - 849, The code block handling
the reuse of an existing settings window unconditionally calls show() and
focus() on this.currentSettingsWindow, which violates the startHidden contract.
Add a conditional check before the show() and focus() calls to verify if the
window should start hidden. Only call show() and focus() when the window is not
supposed to start hidden. The restore() call for a minimized window should still
be executed to ensure the window state is properly restored before making
visibility decisions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/app/overlayManager.ts`:
- Around line 843-849: The code block handling the reuse of an existing settings
window unconditionally calls show() and focus() on this.currentSettingsWindow,
which violates the startHidden contract. Add a conditional check before the
show() and focus() calls to verify if the window should start hidden. Only call
show() and focus() when the window is not supposed to start hidden. The
restore() call for a minimized window should still be executed to ensure the
window state is properly restored before making visibility decisions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0765af4b-453a-4123-84ba-46583470e44e

📥 Commits

Reviewing files that changed from the base of the PR and between 450a04c and 7b1e673.

📒 Files selected for processing (2)
  • src/app/overlayManager.ts
  • src/main.ts
💤 Files with no reviewable changes (1)
  • src/main.ts

@tariknz
tariknz merged commit 2dfa6c6 into main Jun 19, 2026
2 checks passed
@tariknz
tariknz deleted the fix/start-minimized-window branch June 19, 2026 20:47
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.

1 participant