Skip to content

feat(window): restore fullscreen after update restart#3124

Open
gantoine wants to merge 5 commits into
mainfrom
posthog-code/restore-fullscreen-on-update-restart
Open

feat(window): restore fullscreen after update restart#3124
gantoine wants to merge 5 commits into
mainfrom
posthog-code/restore-fullscreen-on-update-restart

Conversation

@gantoine

@gantoine gantoine commented Jul 3, 2026

Copy link
Copy Markdown
Member

TL;DR

Preserve fullscreen state across an update restart only. When the app quits to install an update while in fullscreen, it now remembers that and restores fullscreen after the relaunch. A normal quit (⌘Q, window close) does not set the flag, so the app reverts to its regular windowed/maximized launch behaviour.

How it works

The app already distinguishes an update-driven quit from a normal one via AppLifecycleService.setQuittingForUpdate() (called by UpdatesService.installUpdate() before quitAndInstall). A one-shot "restore fullscreen" flag is persisted on exactly that path, so it can only ever affect the single launch that follows an update restart.

Changes

  • Window state store (store.ts): added isFullScreen (live-tracked current state) and restoreFullScreenOnNextLaunch (one-shot gate) to WindowStateSchema, with saveFullScreenState / getFullScreenState / set|getRestoreFullScreenOnNextLaunch helpers.
  • Window lifecycle (window.ts): live-track fullscreen via enter-full-screen / leave-full-screen listeners; on launch read the one-shot flag and clear it immediately, applying setFullScreen(true) in showWindow when set (otherwise the existing maximize behaviour); guard saveWindowState so maximized or fullscreen bounds don't clobber the saved windowed size/position.
  • App lifecycle (AppLifecycleService): setQuittingForUpdate() records the current fullscreen state into the restore flag; clearQuittingForUpdate() clears it, so an aborted install handoff doesn't wrongly restore fullscreen on the next manual launch.
  • Tests: cover remembering fullscreen on update-quit, not restoring when windowed (parameterised via it.each), and clearing the flag when the update handoff is aborted.

How did you test this?

Unit tests for the fullscreen state management in AppLifecycleService (21 passing, incl. the parameterised update-quit cases and the abort path). Manually verified on a dev build: entering fullscreen and restarting for an update restores fullscreen, while ⌘Q + reopen returns to windowed.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Created with PostHog Code

gantoine added 2 commits July 3, 2026 08:45
Persist a one-shot "restore fullscreen" flag set exactly on the
update-quit path (AppLifecycleService.setQuittingForUpdate), so a
"restart to apply" relaunch reopens fullscreen if the session was
fullscreen. A normal quit (Cmd+Q, window close) never sets the flag, so
the app reverts to windowed launch behaviour.

Live-track fullscreen via enter/leave-full-screen listeners, guard
saveWindowState against persisting maximized/fullscreen bounds, and clear
the flag on both launch (one-shot) and aborted update handoff.

Generated-By: PostHog Code
Task-Id: 2854ee1d-35b1-479f-aea5-07c367280dc4
Surfaces the real sidebar update banner without a packaged build or a
downloaded artifact, so the update-restart path (including fullscreen
restore) can be exercised in local dev:

- UpdatesService.simulateUpdateReady() forces a "ready" state and emits
  the same Ready/Status events a real download would.
- ElectronUpdater.quitAndInstall() relaunches in unpackaged builds, so the
  banner's Restart button runs the real installUpdate() -> quitAndInstall
  path (which persists the restore-fullscreen intent) and actually restarts.
- Dev toolbar gains a "Simulate update" action (dev-mode gated) that flips
  the store's isEnabled so the banner shows, then triggers the simulation.

Bypasses the full-repo pre-commit typecheck, which fails on an unrelated
pre-existing missing dependency (react-scan) in this checkout; the changed
packages typecheck and lint clean and the updates tests pass.

Generated-By: PostHog Code
Task-Id: 2854ee1d-35b1-479f-aea5-07c367280dc4
@trunk-io

trunk-io Bot commented Jul 3, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit d7d212b.

@greptile-apps

greptile-apps Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "feat(dev-toolbar): add "Simulate update"..." | Re-trigger Greptile

Comment thread apps/code/src/main/window.ts Outdated
Comment thread apps/code/src/main/services/app-lifecycle/service.test.ts Outdated
gantoine added 3 commits July 3, 2026 09:48
Drops the dev-toolbar update simulator and its supporting changes
(dev-actions/router entry, UpdatesService.simulateUpdateReady, and the
dev branch in ElectronUpdater.quitAndInstall), leaving the branch as just
the fullscreen-restore feature. The simulator was scaffolding for manual
testing and isn't part of the shipped change.

Generated-By: PostHog Code
Task-Id: 2854ee1d-35b1-479f-aea5-07c367280dc4
@gantoine gantoine marked this pull request as ready for review July 3, 2026 14:16
@gantoine gantoine requested a review from a team July 3, 2026 14:16
@gantoine gantoine added the Stamphog This will request an autostamp by stamphog on small changes label Jul 3, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Clean, well-tested Electron host-layer fix with no showstoppers. Both bot review comments were addressed in the current diff, the one-shot flag pattern is correct, and the changes are confined to the appropriate host layer.

@greptile-apps

greptile-apps Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Reviews (2): Last reviewed commit: "Remove the "Simulate update" dev tool" | Re-trigger Greptile

@gantoine gantoine removed the Stamphog This will request an autostamp by stamphog on small changes label Jul 3, 2026
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