Skip to content

feat: browse handoff — headless-to-headed browser switching (v0.7.4)#201

Merged
garrytan merged 5 commits intomainfrom
garrytan/browse-handoff
Mar 19, 2026
Merged

feat: browse handoff — headless-to-headed browser switching (v0.7.4)#201
garrytan merged 5 commits intomainfrom
garrytan/browse-handoff

Conversation

@garrytan
Copy link
Copy Markdown
Owner

Summary

  • Hand off to a real Chrome when the headless browser gets stuck. $B handoff "reason" opens a visible Chrome at the exact same page with all cookies and tabs. $B resume picks up with a fresh snapshot.
  • Auto-handoff hint after 3 consecutive failures — suggests using handoff instead of watching the AI retry.
  • 15 new tests — unit tests for state save/restore, failure tracking, edge cases, plus integration tests for the full flow.
  • recreateContext() refactored to shared saveState()/restoreState() helpers (DRY).
  • browser.close() timeout to prevent hangs on headed browsers (macOS).

Architecture

Launch-first-close-second: new headed browser starts before old headless closes. If headed launch fails, headless stays running — zero downtime. State transfer via cookies + localStorage + sessionStorage + URLs.

  Headless Browser (old) → saveState() → Launch Headed (new) → restoreState()
                                          ↓ success → close old
                                          ↓ failure → keep old running

Eng Review

Passed — 5 issues resolved (blast radius, display detection, DRY, failure recovery, test coverage). Scope reduced from persistent profiles to browser relaunch per review recommendation.

Test Coverage

COVERAGE: 18/18 paths tested (100%)
QUALITY:  ★★★: 17  ★★: 1
GAPS: 0

Tests: 15 new (12 unit + 3 integration)

Pre-Landing Review

No issues found.

TODOS

  • State Persistence TODO updated: saveState()/restoreState() reusable, effort reduced M → S.

Test plan

  • 476 non-browser tests pass (0 failures)
  • 12 handoff unit tests pass
  • 3 handoff integration tests pass (headed browser with cookie/tab preservation)

🤖 Generated with Claude Code

garrytan and others added 5 commits March 18, 2026 22:15
Add `handoff` and `resume` commands that let users take over a visible
Chrome when the headless browser gets stuck (CAPTCHAs, auth walls, MFA).

Architecture: launch-first-close-second for safe rollback. State transfer
via extracted saveState()/restoreState() helpers (DRY with recreateContext).
Auto-handoff hint after 3 consecutive command failures.
Covers saveState/restoreState, failure tracking, edge cases (already
headed, resume without handoff), and full integration flow with cookie
and tab preservation across headless-to-headed switch.
Add User Handoff section to browse/SKILL.md.tmpl with usage examples.
Update State Persistence TODO noting saveState/restoreState reusability.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Merge conflict resolution: main advanced to v0.8.1, bump handoff feature to v0.8.2.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@garrytan garrytan merged commit 2d97ab9 into main Mar 19, 2026
rapidstartup pushed a commit to rapidstartup/gstack that referenced this pull request Mar 29, 2026
…arrytan#201)

* feat: browse handoff — headless-to-headed browser switching

Add `handoff` and `resume` commands that let users take over a visible
Chrome when the headless browser gets stuck (CAPTCHAs, auth walls, MFA).

Architecture: launch-first-close-second for safe rollback. State transfer
via extracted saveState()/restoreState() helpers (DRY with recreateContext).
Auto-handoff hint after 3 consecutive command failures.

* test: handoff unit + integration tests (15 tests)

Covers saveState/restoreState, failure tracking, edge cases (already
headed, resume without handoff), and full integration flow with cookie
and tab preservation across headless-to-headed switch.

* docs: handoff section in browse template + TODOS update

Add User Handoff section to browse/SKILL.md.tmpl with usage examples.
Update State Persistence TODO noting saveState/restoreState reusability.

* chore: bump version and changelog (v0.7.4)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
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