fix(windows): prevent crash on activate after onboarding wizard closes - #35
Open
espinosacodes wants to merge 1 commit into
Open
fix(windows): prevent crash on activate after onboarding wizard closes#35espinosacodes wants to merge 1 commit into
espinosacodes wants to merge 1 commit into
Conversation
The 'closed' handlers that prune this.windows are wired once, in
setupWindowEventHandlers(), over the windows that exist at startup
(main, chat, llmResponse, settings). The onboarding wizard is created
later in showOnboarding() and inserted into the same Map, so it never
receives one — its entry outlives the destroyed BrowserWindow.
The next 'activate' event then iterates the Map and calls isVisible()
on the destroyed window:
TypeError: Object has been destroyed
at main.js:1552
at ApplicationController.onActivate (main.js:1551)
Repro: launch with first-run onboarding, close the wizard, click the
dock icon.
- window.manager.js: attach a 'closed' handler when the onboarding
window is created, so it is removed from the Map like the rest.
- main.js: guard the onActivate iteration with isDestroyed(), matching
the pattern already used throughout window.manager.js.
|
@espinosacodes is attempting to deploy a commit to the csrsoftwares' projects Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Closing the first-run onboarding wizard and then re-activating the app (clicking the dock icon) crashes the main process:
Repro: launch with first-run onboarding (no
GEMINI_API_KEYconfigured), close the wizard, click the dock icon.Cause
setupWindowEventHandlers()wires theclosedhandler — the one that prunes the Map viathis.windows.delete(type)— by iteratingthis.windowsonce, at startup. At that moment the Map holds onlymain,chat,llmResponse, andsettings.The onboarding wizard is created later, in
showOnboarding(), and inserted into that same Map:Since it missed the one-time wiring, its entry outlives the destroyed
BrowserWindow. The nextactivateevent iterates the Map and callsisVisible()on the stale entry.main.js:1551is the other half: it's an unguarded iteration, whereaswindow.manager.jsconsistently guards withisDestroyed()(lines 211, 573, 598, 639, 680, 1012, …).Fix
window.manager.js— attach aclosedhandler when the onboarding window is created, so it's pruned like every other window. This is the root cause.main.js— guard theonActivateiteration (and themainWindowcheck above it) withisDestroyed(), matching the prevailing pattern.Notes
getWindowStats()inwindow.manager.jshas the same unguarded iteration (isVisible()/isFocused()/getPosition()) and would crash the same way once any post-startup window is destroyed. Left out to keep this PR to the reported crash — happy to include it if you'd prefer.setupWindowEventHandlers()runs inherits this bug. Moving theclosedwiring intocreateWindow()would fix the class rather than the instance; that felt like a larger refactor than this fix warrants, but say the word.Verification
App boots clean with the change (0 errors through onboarding display). The crashing path itself is GUI-driven (close wizard → dock activate), so it was verified by inspection against the stack trace rather than automated.