Skip to content

fix(profile): stable headless-shell profile directory for cookie persistence#609

Merged
shaun0927 merged 1 commit intodevelopfrom
fix/headless-shell-stable-profile
Apr 9, 2026
Merged

fix(profile): stable headless-shell profile directory for cookie persistence#609
shaun0927 merged 1 commit intodevelopfrom
fix/headless-shell-stable-profile

Conversation

@shaun0927
Copy link
Copy Markdown
Owner

Summary

Fixes issue #606 Root Cause A: when --headless-shell is used, profile-manager.ts was creating a new ephemeral temp directory (openchrome-<Date.now()>) on every launch, destroying all cookies between restarts.

Root Cause (A)

resolveProfile() previously handled useTempProfile and usingHeadlessShell in a single branch, giving both an ephemeral os.tmpdir()/openchrome-<Date.now()> path. Since Date.now() changes every launch, headless-shell sessions had no persistent storage for cookies, auth tokens, or session state.

Fix

  • Split the combined branch into two separate cases in resolveProfile()
  • useTempProfile continues to use an ephemeral os.tmpdir()/openchrome-<Date.now()> path (intentional)
  • usingHeadlessShell now uses a stable path: ~/.openchrome/headless-shell-profile via os.homedir() (Windows-compatible)
  • Added a new 'headless-shell' value to ProfileType to make the distinction explicit
  • Added a matching log message in launcher.ts for the new profile type
  • Updated the test that previously expected profileType === 'temp' for headless-shell to now expect profileType === 'headless-shell' and verify the stable path

Test plan

  • tests/chrome/persistent-profile.test.ts — all 47 tests pass, including updated headless-shell test
  • tests/chrome/launcher-launch.test.ts — all 9 tests pass
  • Build: npm run build exits cleanly (zero TypeScript errors)

🤖 Generated with Claude Code

…meral temp profile

Fixes issue #606 (Root Cause A): headless-shell no longer creates a new
openchrome-<Date.now()> temp directory on every launch. Instead it uses a
stable path at ~/.openchrome/headless-shell-profile so cookies persist
across restarts. Introduces the 'headless-shell' ProfileType to distinguish
this case from the intentionally ephemeral 'temp' profile type.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@shaun0927 shaun0927 merged commit 2bf1603 into develop Apr 9, 2026
9 checks passed
@shaun0927 shaun0927 deleted the fix/headless-shell-stable-profile branch April 9, 2026 01:52
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.

1 participant