fix: honor "Start minimized" so the settings window stays hidden on launch - #599
Conversation
…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>
📝 WalkthroughWalkthrough
ChangesSettings Window Hidden-Start Refactor
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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 winHonor
startHiddenwhen reusing an existing settings window.The re-entry path always calls
show()/focus(), socreateOverlays(...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
📒 Files selected for processing (2)
src/app/overlayManager.tssrc/main.ts
💤 Files with no reviewable changes (1)
- src/main.ts
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 defaultshow: trueand noready-to-showhandler — unlike the overlay windows, which correctly useshow: false+ready-to-show. ThestartMinimized→hide()logic lived inmain.tsand only ran afterawait analytics.init(). That raced against Electron auto-showing the window on first paint: depending on timing (Electron version, how fastanalytics.initresolves), the paint landed after the late.hide(), so the window opened anyway. It also re-enteredcreateSettingsWindow, which.show()+.focus()'d the window right before hiding it.This is why it appeared to regress —
createSettingsWindow()was added tocreateOverlays("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: falseand reveal it onready-to-showunless it should start hidden — the same pattern the overlay windows already use.createOverlaysreadsstartMinimizedand passes the intent through. Removed the redundant, racy post-awaithide()block frommain.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
Checklist
npm testnpm run lintand fixed any issues🤖 Generated with Claude Code
Summary by CodeRabbit