Skip to content

feat: add 'restored-persisted-state' event to BaseWindow - #48069

Closed
nilayarya wants to merge 284 commits into
electron:gsoc-2025from
nilayarya:event-emitters
Closed

nilayarya wants to merge 284 commits into
electron:gsoc-2025from
nilayarya:event-emitters

Conversation

@nilayarya

@nilayarya nilayarya commented Aug 14, 2025 •

Copy link
Copy Markdown
Contributor

Description of Change

Note

This PR is part of GSoC 2025 [project] [rfc]. It should be stacked on top of #47781 and #48048

Adds a new restored-persisted-state event to BaseWindow that emits when window state restoration logic completes during initialization.

The event only fires when windowStatePersistence is enabled, saved window state exists on disk, and valid display exists for window to be restored on.

It uses EmitEventSoon to ensure the event is delivered after the JavaScript object is fully constructed.

Checklist

Release Notes

Notes: Added restored-persisted-state event to BaseWindow that emits when the persisted window state is restored.

nilayarya and others added 24 commits August 11, 2025 10:46
…electron#47764)

* feat: save window state (electron#47425)

* feat: save/restore window state

* cleanup

* remove constructor option

* refactor: apply suggestions from code review

Co-authored-by: Charles Kerr <[email protected]>

* refactor: forward declare prefservice

* refactor: remove constructor option

* refactor: save window state on move/resize instead of moved/resized

* feat: resave window state after construction

* test: add basic window save tests

* test: add work area tests

* test: asynchronous batching behavior

* docs: add windowStateRestoreOptions to BaseWindowConstructorOptions

* chore: move includes to main block

* Update spec/api-browser-window-spec.ts

Co-authored-by: David Sanders <[email protected]>

* docs: update docs/api/structures/base-window-options.md

Co-authored-by: Erick Zhao <[email protected]>

* fix: preserve original bounds during window state save in special modes

* feat: save kiosk state in window preferences

* chore: remove ts-expect-error

* test: check hasCapturableScreen before running tests

* test: remove multimonitor tests

* test: add missing hasCapturableScreen checks before tests

* docs: add blurb on saving mechanism

* feat: add debounce window of 200ms to saveWindowState

* docs: remove blurb until finalized

* style: convert constants from snake_case to camelCase

* refactor: initialize prefs_ only if window state is configured to be saved/restored

* refactor: rename window states key

* refactor: store in application-level Local State instead of browser context

* refactor: switch to more accurate function names

* fix: add dcheck for browser_process

* fix: flush window state to avoid race condition

* refactor: change stateId to name

* refactor: change windowStateRestoreOptions to windowStatePersistence

* Update docs/api/structures/base-window-options.md

Co-authored-by: David Sanders <[email protected]>

* fix: add warning when window state persistence enabled without window name

* docs: lowercase capital B for consistency

---------

Co-authored-by: Charles Kerr <[email protected]>
Co-authored-by: David Sanders <[email protected]>
Co-authored-by: Erick Zhao <[email protected]>

* feat: enforce unique window names across BaseWindow and BrowserWindow

* docs: update docs for name property

* fix: linter issue with symbol

---------

Co-authored-by: Charles Kerr <[email protected]>
Co-authored-by: David Sanders <[email protected]>
Co-authored-by: Erick Zhao <[email protected]>
@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label Aug 14, 2025
@georgexu99 georgexu99 added the GSoC 2025 Google Summer of Code 2025 label Aug 18, 2025
@nilayarya
nilayarya requested review from a team as code owners August 19, 2025 23:41
@socket-security

socket-security Bot commented Nov 19, 2025 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updated@​electron/​typescript-definitions@​9.1.2 ⏵ 9.1.581 -110082 +189 +9100
Added@​types/​node@​24.9.11001008195100
Added@​xmldom/​xmldom@​0.8.1110010010083100
Updated@​electron/​asar@​3.2.13 ⏵ 4.0.1100 +110010084 +2100
Updatedwebpack-cli@​5.1.4 ⏵ 6.0.19810010084100
Updatedexpress@​4.21.0 ⏵ 4.21.29710010086100
Updatedtypescript@​5.6.2 ⏵ 5.8.3100 +110090 +110090
Updatedmocha@​10.4.0 ⏵ 10.8.297 +110095 +197 +3100

View full report

@nilayarya nilayarya changed the title feat: add 'restored-window-state' event to BaseWindow feat: add 'restored-persisted-state' event to BaseWindow Nov 19, 2025
@nilayarya
nilayarya force-pushed the event-emitters branch 3 times, most recently from e651117 to 905cf8b Compare November 21, 2025 05:56

@ckerr ckerr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+13,877 −7,906

@nilayarya it feels like a wrong branch got selected here somewhere?

I don't think a 22K LOC diff is reviewable. Can you remove the extraneous commits?

@nilayarya

Copy link
Copy Markdown
Contributor Author

+13,877 −7,906

@nilayarya it feels like a wrong branch got selected here somewhere?

I don't think a 22K LOC diff is reviewable. Can you remove the extraneous commits?

@ckerr Sorry for the troubles. This will look right once electron/gsoc-2025 is rebased on main.

@ckerr

ckerr commented Nov 26, 2025

Copy link
Copy Markdown
Member

@ckerr Sorry for the troubles. This will look right once electron/gsoc-2025 is rebased on main.

No worries! I appreciate the PRs!

@ckerr

ckerr commented Apr 28, 2026

Copy link
Copy Markdown
Member

@nilayarya are you planning to do any more work on this PR?

@ckerr

ckerr commented Jul 27, 2026

Copy link
Copy Markdown
Member

This has a been a 22000 LOC diff for almost a year now without any cleanup work, so I'm going to close it.

This isn't due to any opinion about the PR, just that it's been unreviewable for a year. If anyone wants to open a fixed version, feel free.

@ckerr ckerr closed this Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

GSoC 2025 Google Summer of Code 2025 no-backport semver/minor backwards-compatible functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants