feat(window): persist main window size/position across launches - #97
Conversation
The main window always opened at a fixed 1400x900, forcing a manual resize every session. Save the window geometry (normal bounds + maximized flag) to the existing desktop prefs store on close, and restore it in createWindow. Saved bounds are validated by a pure sanitizer against the current display layout before use, so stale state degrades safely instead of producing an off-screen or absurd window: - garbage/partial config -> 1400x900 centered defaults - size clamped between the 800x600 window minimums and the largest display's workArea - position kept only when the window overlaps a display by at least 100x50 px (unplugged monitor / resolution change -> re-center); negative multi-monitor coordinates remain valid - maximized sessions save getNormalBounds() and re-maximize on restore; fullscreen deliberately restores windowed No new dependency; reuses get/setDesktopConfig (atomic write, fail-soft) in soundfont-manager.ts. The store file is already in the reset-app-settings delete-set, so a config reset also resets bounds. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: gionnibgud <gionnibgud@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughWindow geometry is now persisted in desktop configuration, sanitized against current display work areas, restored during Electron window creation, constrained by minimum dimensions, and saved on close with maximized state. ChangesWindow bounds persistence
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant DesktopConfig
participant ElectronScreen
participant sanitizeWindowBounds
participant MainWindow
DesktopConfig->>sanitizeWindowBounds: provide saved bounds
ElectronScreen->>sanitizeWindowBounds: provide current display work areas
sanitizeWindowBounds->>MainWindow: return validated window geometry
MainWindow->>DesktopConfig: save normal bounds and maximized state on close
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@src/main/main.ts`:
- Around line 486-491: Wrap the setDesktopConfig call in the mainWindow close
handler with try/catch so synchronous configuration write or rename failures do
not escape the listener during shutdown. Preserve the existing destroyed-window
guard and normal window-bounds persistence, and handle the caught error using
the surrounding module’s established error-reporting approach.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 8bd7026d-afdf-48b9-a144-b8af1bee6f71
📒 Files selected for processing (4)
src/main/main.tssrc/main/soundfont-manager.tssrc/main/window-bounds.tstests/window-bounds.test.js
The close listener called setDesktopConfig synchronously with no error handling; a disk-full or permissions failure during the write would throw unhandled inside the close handler, risking a shutdown crash. Wrap the write in try/catch and log a warning instead. Flagged by CodeRabbit on PR #97. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: gionnibgud <gionnibgud@gmail.com>
|
Is there an option to start fullscreen, with no menu at the top? It's not jarring, it's annoying to have to manually fullscreen every time. |
Why
The main window always opens at a fixed 1400×900, forcing a manual resize every session. This persists the window geometry so the app reopens the way you left it.
What
getNormalBounds()+isMaximized()written to the existing desktop prefs store (slopsmith-desktop.json, atomic write, fail-soft) — no new dependency.createWindow(): saved bounds pass through a pure sanitizer (src/main/window-bounds.ts) validated against the current display layout before use.Guardrails
Testing
tests/window-bounds.test.js, node --test, no electron import).npm run typecheckclean; full suite passes (the only failure on a clean checkout is the pre-existing JUCE-submodule-dependent test).🤖 Generated with Claude Code
Summary by CodeRabbit