fix: Chrome numbered-profile cookie discovery + headed window stability on macOS 26#2139
Open
chrisreedbates wants to merge 2 commits into
Open
Conversation
…ty on macOS 26 Bug 1 — Headed Chromium window closes immediately on macOS 26 (Sequoia): macOS 26 tightened window activation policy. Chromium windows spawned by a non-app process (Bun server) close immediately unless properly registered via NSApplicationActivateIgnoringOtherApps. Two fixes: 1. Add --disable-features=MacControlledWindowBehavior to headed launch args on darwin. This flag suppresses the new OS-level window-hiding behavior while Playwright's NSApp startup sequence handles activation normally. No-op on macOS < 26 and non-macOS platforms. 2. Fix raiseHeadedWindowMacOS() — it tried to activate "Google Chrome for Testing" via osascript, but launchHeaded() patches the Info.plist to rename it to "GStack Browser". The activation silently failed, leaving the window unraised. Now tries "GStack Browser" first with fallback to the original name. Bug 2 — cookie-import-browser fails when no Default profile exists: Chrome on macOS 26 and some multi-profile installations never create a Default directory. Every account lands in a numbered profile (Profile 4, Profile 12, etc.). cookie-import-browser.ts only looked for Default/Cookies, so it threw "Chrome is not installed" even though cookies were present. Fix: when getBrowserMatch() can't find Default, call findFirstNumberedProfile() which scans for Profile N directories, sorts by number (lowest first so the primary account wins), and returns the first one with a Cookies file. The fallback is only triggered when the caller explicitly requested "Default" — an explicit non-default profile name still fails fast as before. Also adds tests for: numbered-profile fallback on Linux Chromium, lowest-number wins when multiple numbered profiles exist, listDomains falling back correctly. Closes garrytan#2138
|
Merging to
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 |
…S 26 The --disable-features=MacControlledWindowBehavior flag added to launchHeaded() was missing from the handoff() code path (headless -> headed re-launch). The handoff() method builds its own launchArgs array independently, so macOS 26 users who trigger a headless-to-headed handoff would still see the window-close bug even after the launchHeaded() fix. Apply the same darwin guard to the handoff() launchArgs so all headed launch paths suppress the new OS-level window-hiding behavior on Sequoia.
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.
Summary
Fixes two bugs reported in issue #2138, both affecting macOS 26 (Sequoia).
Bug 1 — Headed Chromium window closes immediately on macOS 26
Root cause (two interacting issues):
macOS 26 tightened window activation policy. Chromium windows spawned by a
non-app process (the Bun server) are subject to a new OS-level window-hiding
behavior that causes them to close within seconds unless properly registered
via
NSApplicationActivateIgnoringOtherApps.raiseHeadedWindowMacOS()incli.tstried to activate "Google Chrome forTesting" via osascript, but
launchHeaded()patches the Info.plist to renamethe app to "GStack Browser". The activation silently failed, leaving the window
unraised and subject to the OS hiding it.
Fixes in
browse/src/browser-manager.tsandbrowse/src/cli.ts:--disable-features=MacControlledWindowBehaviorto headed launch args ondarwin. This flag suppresses the new OS-level window-hiding behavior introduced
in macOS 26 while Playwright's NSApp startup sequence handles activation. No-op
on macOS < 26 and all non-macOS platforms.
raiseHeadedWindowMacOS()to try "GStack Browser" first (post-patch name)with fallback to "Google Chrome for Testing" (pre-patch / patch skipped).
Bug 2 —
cookie-import-browserfails when no Default profile existsRoot cause: Chrome on macOS 26 and some multi-profile installations never
create a
Defaultdirectory. Every account lands in a numbered profile (Profile 4,Profile 12, etc.).cookie-import-browser.tsonly looked forDefault/Cookies, throwing "Chrome is not installed" even when cookies existed.Fix in
browse/src/cookie-import-browser.ts:getBrowserMatch()can't findDefault, call newfindFirstNumberedProfile()which scans forProfile Ndirectories, sorts bynumber (lowest first so the primary account wins), and returns the first one
with a Cookies file.
importCookies('chrome', [...], 'Profile 4'))still fail fast as before — the fallback only fires for the default
'Default'case.Test plan
$B connecton macOS 26: headed Chromium window stays open and$B screenshotsucceeds (no "Cannot take screenshot with 0 width")$B disconnecton macOS 26 reports clean shutdown, not "server wasunresponsive — force cleaned"
cookie-import-browser chromeon a Mac with only numbered profiles (noDefaultdirectory): succeeds and imports cookies from the lowest-numberedprofile
cookie-import-browser chromeon a standard install withDefaultprofile: still works (no regression)
bun test browse/test/cookie-import-browser.test.tsFiles changed
browse/src/cookie-import-browser.ts—getBrowserMatch+ newfindFirstNumberedProfilebrowse/src/browser-manager.ts— macOS 26--disable-featuresflag inlaunchHeadedandhandoffbrowse/src/cli.ts— fixraiseHeadedWindowMacOSto try both app namesbrowse/test/cookie-import-browser.test.ts— 3 new tests for numbered-profile fallbackCloses #2138
Local test evidence (macOS 26 / Darwin 25.5.0)
Environment: macOS 26 Sequoia (Darwin 25.5.0), running inside Claude Code VSCode extension.
Test session: After applying the
--disable-features=MacControlledWindowBehaviorfix, launcheda headed Chromium window via
$B connectand left it running for 10+ minutes. The windowremained open and interactive for the entire session. 23 Google Search Console indexing requests
were submitted successfully through the headed window with no crashes or premature closures.
Before this fix: The window closed within seconds of opening every time.
Second problem found:
handoff()path missing the macOS 26 flagAfter the main fix was verified working, a code audit found that
handoff()inbrowser-manager.ts(the headless-to-headed re-launch path, lines ~1560-1600) buildsits own
launchArgsarray independently fromlaunchHeaded()and was NOT including--disable-features=MacControlledWindowBehavior.A user who triggers a handoff (e.g., via the gstack extension "hand off to user" UI flow)
on macOS 26 would have seen the same immediate window-close bug, even after the
launchHeaded()fix.Fix applied in commit
5c7058bb: Added the sameif (process.platform === 'darwin')guard tothe
handoff()launchArgs block, immediately after the initiallaunchArgsarray is built:Build verified:
bun run buildpasses cleanly after the change.Note: the fix commit
5c7058bbis local only — push access togarrytan/gstackwas denied(403). The fix is in the local worktree at
/tmp/gstack-pr/browse/src/browser-manager.tsand needs to be pushed by a repo collaborator.