Skip to content

Persist window state across application sessions#19

Merged
ptheofan merged 2 commits into
mainfrom
claude/fix-issue-18-8dhzA
May 14, 2026
Merged

Persist window state across application sessions#19
ptheofan merged 2 commits into
mainfrom
claude/fix-issue-18-8dhzA

Conversation

@ptheofan
Copy link
Copy Markdown
Owner

Summary

Add window state persistence to remember and restore window size, position, and maximized state across application sessions.

Key Changes

  • WindowManager enhancements:

    • Added constructor accepting optional PreferencesService dependency
    • Integrated window state restoration on window creation using saved preferences
    • Added event listeners for resize, move, maximize, and unmaximize events
    • Implemented debounced window state persistence (500ms) to avoid excessive writes during resize/move operations
    • Added cleanup of pending save timers on window close and manager destruction
  • Window state validation:

    • Implemented isPositionOnScreen() to validate saved window positions against connected displays
    • Automatically drops off-screen positions (e.g., when external monitors disconnect) while preserving window dimensions
    • Falls back to default window dimensions when no preferences service is available
  • Type definitions:

    • Added WindowState interface to track width, height, x, y coordinates, and maximized state
    • Updated AppPreferences to include windowState field
    • Added DEFAULT_WINDOW_STATE constant for first-launch defaults
  • Test coverage:

    • Added comprehensive tests for window state persistence scenarios
    • Tests cover saved position/size restoration, off-screen position handling, maximized state restoration, and cleanup behavior
    • Updated mocks to support window state testing (screen API, maximize/getNormalBounds methods)

Implementation Details

  • Window state is persisted using getNormalBounds() which reports un-maximized bounds, ensuring sensible dimensions are always saved even while maximized
  • Debouncing prevents excessive preference updates during rapid resize/move events
  • The implementation gracefully handles missing preferences service for backward compatibility
  • Pending save operations are properly cleaned up to prevent memory leaks

https://claude.ai/code/session_014dsDoT4P7fxxWTuxNjAHmk

claude added 2 commits May 14, 2026 09:03
Closes #18. Window bounds and maximized state are now saved to
preferences on resize/move/maximize/close and restored when a new
window is opened. An off-screen saved position (e.g. a disconnected
display) is discarded while keeping the saved size.

https://claude.ai/code/session_014dsDoT4P7fxxWTuxNjAHmk
Fixes the CI typecheck failure: the new required windowState field was
missing from the mock AppPreferences objects in ShellHandler and
ThemeHandler tests.

https://claude.ai/code/session_014dsDoT4P7fxxWTuxNjAHmk
@ptheofan ptheofan merged commit 94404aa into main May 14, 2026
4 checks passed
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.

2 participants