Repository navigation
feat(browser): run plain Chrome during takeovers so Google accepts sign-in - #493
Merged
Merged
Conversation
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.
2 tasks done
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.
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.
Google rejects sign-in in browser sessions. Any remote debugging, through
--remote-debugging-pipeor a port, makes Chrome setnavigator.webdriverto 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.
POST /plainandPOST /cdpon its private socket. Entering plain mode closes Chrome withBrowser.closeand 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=basicstays, 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.enterPlainBrowserandrestoreCdpBrowserin the browser package drive the switch. They return false for other session types.startHumanTakeoverandendHumanTakeovergainafterLeaseandbeforeReleasehooks. The CLI's two lease owners, the native viewer host andwatch --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.request_takeoverandtakeover_waitreturnbrowserRelaunched: truefor browser sessions, and their descriptions say to list pages again.Closes #380
navigator.webdriverwith pipe and portwebdrivertrueshots/A-plain.png,shots/G-pipe-idle.png, issue comment/proccmdline in the e2e--remote-debugging-*and no page URLs,--password-store=basickept, both tabs carriedfull-suite.log,e2e/headless.mjsoutputstartHumanTakeover; CLI e2e with the native viewere2e/run4.log, relay outpute2e/headless-plain-google.pnge2e/headless-after-return.png/closein plain mode; repeated/plainand/cdp; restore after the session ended; switch longer than the lease TTL; hook that throws synchronouslyfull-suite.logtsc --noEmit, PickCheck (233 functions), gitleakslint.log,typecheck.log,pickcheck.json,gitleaks.logAfter 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-statusandisolation, fail the same way on a clean main (#490). With the installed release viewer, twonative-viewer-livetests fail (#491).test/security/security-viewer-bridge.test.tscan 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):