refactor(main): dedupe window restore+focus into a shared focusWindow helper#230
Open
PaulHorn wants to merge 1 commit into
Open
refactor(main): dedupe window restore+focus into a shared focusWindow helper#230PaulHorn wants to merge 1 commit into
PaulHorn wants to merge 1 commit into
Conversation
… helper The un-minimize-then-focus idiom was duplicated across three call sites: singleInstance.focusRunningInstanceWindow, deliverOpenPath in index.ts, and the notification-click handler. #224 introduced a tested helper for the second-instance case but left the two pre-existing inline copies. Extract focusWindow(win) in singleInstance.ts and route all three through it, so there is a single place that decides how the app surfaces an existing window. No behavior change; adds direct unit tests for the helper.
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.
What
Extracts a small
focusWindow(win)helper insrc/main/singleInstance.tsand routes the three places that surface an existing window through it.Why
The un-minimize-then-focus idiom —
— was duplicated across three call sites:
singleInstance.focusRunningInstanceWindow(second-instance event)deliverOpenPathinindex.ts(open-path)ipc/notifications.tsPR #224 introduced the tested
focusRunningInstanceWindowhelper for the single-instance case but left the two pre-existing inline copies in place. This consolidates all three so there's a single place that decides how the app brings an existing window to the foreground.How
focusWindow(win: BrowserWindow)insingleInstance.ts.focusRunningInstanceWindownow picks the first live window and delegates tofocusWindow.deliverOpenPathand the notification handler callfocusWindow(each keeps its own surrounding guard —try/catchand!isDestroyed()respectively).Notes
findMainWindow, the notification's owner window, first-live); only the shared restore+focus tail is unified.Tests
focusWindow(focuses; restores-then-focuses when minimized).tsc --noEmitclean · fullvitestsuite green (529 incl. 8 insingleInstance.test.ts).