Skip to content

feat(browser): run plain Chrome during takeovers so Google accepts sign-in - #493

Merged
ElbertePlinio merged 12 commits into
mainfrom
fix/380-signin-plain-chrome
Oct 31, 2026
Merged

ElbertePlinio merged 12 commits into
mainfrom
fix/380-signin-plain-chrome

Conversation

@ElbertePlinio

@ElbertePlinio ElbertePlinio commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

Google rejects sign-in in browser sessions. Any remote debugging, through --remote-debugging-pipe or a port, makes Chrome set navigator.webdriver to true, and Google refuses the browser at the identifier step. Every other session flag is accepted.

Every takeover on a browser session now runs the same profile as a plain Chrome while the person has control, then returns it to DevTools. No flag is needed.

  • The browser supervisor gains plain and CDP modes, switched through POST /plain and POST /cdp on its private socket. Entering plain mode closes Chrome with Browser.close and starts it again with the same flags minus --remote-debugging-pipe, plus --restore-last-session, so the tabs come back without page URLs on the command line. --password-store=basic stays, so the cookies stay readable. Returning stops the plain Chrome with SIGTERM and reopens the profile under the pipe with --restore-last-session. The supervisor, its socket and the relay lease stay up throughout, so the session record, status, profile lock and teardown do not change.
  • enterPlainBrowser and restoreCdpBrowser in the browser package drive the switch. They return false for other session types.
  • startHumanTakeover and endHumanTakeover gain afterLease and beforeRelease hooks. The CLI's two lease owners, the native viewer host and watch --control, switch after the lease is taken and before it is released. The viewer host keeps the lease heartbeat running until the switch back ends.
  • While plain, the supervisor watches the lease file with core's staleness rule (owner dead or lease expired) and returns to CDP by itself, so a crashed lease owner cannot leave the session without DevTools. A relaunched CDP Chrome that does not answer is killed after its budget.
  • The takeover renews the lease while the switch runs, before its heartbeat starts.
  • request_takeover and takeover_wait return browserRelaunched: true for browser sessions, and their descriptions say to list pages again.
  • The README describes the flow and the fallback through a desktop session.

Closes #380

Requirement Verification Scenario and edge cases Result Evidence
Find the signal Bisect on fresh profiles with an address that does not exist Plain Chrome; all flags but the pipe; plain plus an idle pipe; session as today; navigator.webdriver with pipe and port Only remote debugging is rejected; it sets webdriver true shots/A-plain.png, shots/G-pipe-idle.png, issue comment
Plain launch, same profile, no pipe, other flags kept Supervisor tests; real-Chrome integration test; /proc cmdline in the e2e Named profile; tabs restored through the session file; plain Chrome fails to start No --remote-debugging-* and no page URLs, --password-store=basic kept, both tabs carried full-suite.log, e2e/headless.mjs output
Takeover switches before the person gets input Hook order tests; headless e2e through startHumanTakeover; CLI e2e with the native viewer Viewer and VNC transports; a throwing hook releases the lease; agent input during takeover Plain mode in about 1 s; agent click and DevTools call refused with the human-control error e2e/run4.log, relay output
Google accepts the browser during a takeover Headless e2e: the person submits an address on Google sign-in Tab opened by the agent before the takeover "Couldn't find this account", the accepted path e2e/headless-plain-google.png
Return to CDP keeps cookies, Google session and tabs Real-account check by the owner; integration test; e2e Cookie set before plain; two tabs; Gmail, Docs and myaccount 7 min and 70 min later Signed in under CDP; tabs restored; DevTools relay reconnects without a restart Issue comment; e2e/headless-after-return.png
Fallback documented README review Profile reuse after the fallback Command keeps the password store flags README
Failure paths Supervisor tests Person closes plain Chrome; lease gone, expired, dead owner or reused pid; CDP relaunch that ignores SIGTERM; /close in plain mode; repeated /plain and /cdp; restore after the session ended; switch longer than the lease TTL; hook that throws synchronously All pass full-suite.log
Lint, typecheck, PickCheck, secrets oxlint, tsc --noEmit, PickCheck (233 functions), gitleaks Branch range against main Clean lint.log, typecheck.log, pickcheck.json, gitleaks.log

After the review fixes, the full suite passed 3623 of 3629 tests locally, with the viewer built from this checkout on PATH. The two failures, session-status and isolation, fail the same way on a clean main (#490). With the installed release viewer, two native-viewer-live tests fail (#491). test/security/security-viewer-bridge.test.ts can fail on a host where a local IDE probes loopback ports (#492); that file is untouched here.

Right after the switch back, a restored tab can list with no URL for a second or two. It shows its URL once Chrome finishes restoring it.

If the lease owner crashes, agent input can land during Chrome's relaunch, about one second after the lease turns stale. Nobody holds control then, and DevTools connections wait until CDP is back. Both reviewers accepted this.

Evidence paths are under ~/.pickforge/investigations/380/ on the author's machine. Screenshots from the real-account check stay there because they show account data.

Review (council; the Kimi seat did not run because its weekly limit was reached):

Round Revision GPT-6.1 Sol Fable 5.1
1 70b3ca5 7/10: agent input before recovery after lease expiry; no lease renewal during the first switch 8/10: hung CDP relaunch; lease rule differs from core; silent failed restore; URLs on argv; stop helper target
2 091e412 8/10: synchronous hook throw skipped cleanup; P1 window accepted 9/10: all fixed, no new findings
3 28430ce 10/10, no findings not needed

Add afterLease and beforeRelease hooks to the desktop takeover. The two
lease owners, the native viewer host and watch --control, use them to
open plain Chrome before input and to restore CDP before the lease is
released. request_takeover and takeover_wait report browserRelaunched
for browser sessions. Refs #380.
The supervisor now switches a browser session between CDP Chrome and a
plain Chrome with no remote debugging, so Google accepts sign-in (#380).
POST /plain closes Chrome with Browser.close and reopens the profile with
every flag but remote debugging and the open pages. POST /cdp stops the
plain Chrome with SIGTERM and reopens the profile under CDP with
--restore-last-session.

The socket, endpoint file and relay lease stay across both relaunches.
Websocket upgrades wait until CDP is back. A person closing the plain
Chrome leaves the supervisor up. When the human lease file is gone or
expired, the supervisor returns to CDP by itself. The endpoint file now
carries the mode.

enterPlainBrowser and restoreCdpBrowser call the supervisor for a
running browser session and wait for the published mode.
Back-to-back single-command clients could reach the supervisor before the previous client released the slot, which failed under full-suite load.
restoreCdpBrowser resolved false whenever the supervisor was gone after a
failed switch, so callers took it for an ended session and stayed silent.
It now resolves false only when the session record no longer says running,
and throws otherwise.
…argv

- Return to CDP the moment lab-core calls the human lease stale: a dead or
  reused owner process, or a passed expiry, with no grace.
- Kill a relaunched CDP browser that ignores SIGTERM after it did not
  answer, so the supervisor ends instead of holding upgrades forever.
- Start the plain browser with --restore-last-session after Browser.close,
  so page URLs no longer show in its command line.
- Stop the browser that stopForRelaunch was given.
@ElbertePlinio
ElbertePlinio merged commit a026be7 into main Oct 31, 2026
10 checks passed
@ElbertePlinio
ElbertePlinio deleted the fix/380-signin-plain-chrome branch October 31, 2026 18:59
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.

browser: open sign-in takeovers as a plain Chrome so Google accepts them

1 participant