Skip to content

[SampleApp] Preserve launch metadata and window placement across theme switches#569

Merged
Anna Malchow-Perryman (apman) merged 2 commits into
masterfrom
agents/save-branch-time-on-launch
Jun 29, 2026
Merged

[SampleApp] Preserve launch metadata and window placement across theme switches#569
Anna Malchow-Perryman (apman) merged 2 commits into
masterfrom
agents/save-branch-time-on-launch

Conversation

@apman

Copy link
Copy Markdown
Contributor

Summary

  • keep SampleApp title metadata stable across theme-triggered window recreation by caching launch time and launch branch once per process
  • preserve window placement when recreating MainWindow on theme changes (position, size, and window state)
  • avoid reopening on the primary display by forcing manual startup location when applying saved placement

Why

Switching themes intentionally recreates the window. Before this change, that caused:

  • title branch/time to refresh to current values instead of original launch values
  • the recreated window to jump back to the laptop/primary monitor

This PR keeps both pieces of context stable across theme switches.

Validation

  • dotnet test passed (124/124)

Notes

  • minimized state is not carried across recreation; it restores as Normal to avoid reopening minimized.

Carry over window position, size, and state when recreating MainWindow during theme changes so the app stays on the same monitor instead of returning to the primary display.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI 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.

Pull request overview

This PR improves the SampleApp’s theme-switch experience by keeping launch metadata (branch/time) stable across window recreation and restoring the window’s previous placement when MainWindow is recreated due to a theme change.

Changes:

  • Cache launch time and git branch once per process so the title doesn’t refresh on theme-triggered window recreation.
  • Capture and reapply window placement (position, size, window state) when recreating MainWindow during theme changes.
  • Force WindowStartupLocation.Manual on recreation to avoid reopening centered on the primary display.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
samples/SampleApp/MainWindow.axaml.cs Caches launch time/branch and reuses them when rebuilding the window title after theme-driven recreation.
samples/SampleApp/App.axaml.cs Captures old window placement and applies it to the newly created MainWindow to preserve monitor/size/state across theme switches.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@apman Anna Malchow-Perryman (apman) merged commit 8624a26 into master Jun 29, 2026
1 check passed
@apman Anna Malchow-Perryman (apman) deleted the agents/save-branch-time-on-launch branch June 29, 2026 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants