Skip to content

fix(browse): use launchPersistentContext for working extension support + cookie persistence#440

Open
yinanli1917-cloud wants to merge 1 commit intogarrytan:mainfrom
yinanli1917-cloud:fix/browse-extensions-persistent-context
Open

fix(browse): use launchPersistentContext for working extension support + cookie persistence#440
yinanli1917-cloud wants to merge 1 commit intogarrytan:mainfrom
yinanli1917-cloud:fix/browse-extensions-persistent-context

Conversation

@yinanli1917-cloud
Copy link
Contributor

Fixes #432

Summary

  • Fix: extensions now actually work. The original BROWSE_EXTENSIONS_DIR support (PR feat(browse): support Chrome extensions via BROWSE_EXTENSIONS_DIR #315) used browser.newContext(), which creates an isolated context where extensions are invisible. Switched to launchPersistentContext() so extensions run in the default browser context — content scripts, service workers, and declarativeNetRequest rules all function correctly.
  • Fix: no more popup window. Replaced --window-position=-9999,-9999 (which macOS ignores for newPage() windows) with --headless=new on the full Chromium binary. Zero visible windows.
  • Feature: cookie persistence across restarts. Cookies are saved to ~/.gstack/browse-cookies.json on shutdown + every 5 min, and restored on next server start. cookie-import-browser becomes a one-time operation — imported cookies survive all daemon restarts and binary updates.

What changed

File Change
browse/src/browser-manager.ts launchPersistentContext() when extensions set; --headless=new; ignoreDefaultArgs to strip --disable-extensions, --enable-automation, --disable-component-extensions-with-background-pages; restoreCookies() method
browse/src/server.ts persistStorage() on shutdown + 5-min interval; cookie restore on startup
browse/src/config.ts storageFile path (~/.gstack/browse-cookies.json)
BROWSER.md Document extension support and cookie persistence

Test plan

  • 375/375 browse unit tests pass
  • MV3 extension with content scripts, service workers, and declarativeNetRequest rules — verified all execute correctly in persistent context
  • No visible Chromium window on macOS
  • Cookie set → server stop → server restart → cookie present
  • navigator.webdriver returns false
  • Fresh clone tested independently by a separate user session

🤖 Generated with Claude Code

…t + cookie persistence

The original extension support used browser.newContext() which creates an isolated
context where extensions are invisible. Extensions only run in the default browser
context.

- Use launchPersistentContext() when BROWSE_EXTENSIONS_DIR is set
- Use --headless=new instead of off-screen window positioning (no popup)
- Strip --disable-extensions, --enable-automation via ignoreDefaultArgs
- Add cookie persistence to ~/.gstack/browse-cookies.json
- Document in BROWSER.md

375/375 browse unit tests pass.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@yinanli1917-cloud yinanli1917-cloud force-pushed the fix/browse-extensions-persistent-context branch from b0b82ce to a0fc6e2 Compare March 24, 2026 09:22
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.

bug(browse): BROWSE_EXTENSIONS_DIR causes visible Chromium window on macOS

1 participant