fix(browser): report a closed page before reattaching, and a quit browser as its own result - #1601
Merged
Merged
Conversation
…wser as its own result Second field test: the user closed the GitHub window while wait was polling. The detach event marked the page gone and the very next poll reattached a blank tab silently, so wait kept polling about:blank until its timeout instead of telling the model what happened. The closure was only reported when the browser answered "session not found" first. The first command to notice a closure now returns ErrPageClosed whichever way it was detected; only the command after that attaches a fresh tab. A browser the user quit entirely surfaces as ErrBrowserClosed instead of a raw websocket error, and wait returns both as results the model can act on, with the note that a throwaway profile's logins are gone.
Contributor
Quality GateResult: ✅ all floors passed
Config: .github/quality-gate.yml. Workflow: |
GitHub ignored the return_to of the login URL and landed on its home page, so a wait pinned to a specific path sat out its whole timeout although the user had finished. wait now accepts changed, satisfied when the page URL leaves the one it had when the wait started, and the timeout result says where the page moved from when it did move, so the model can tell a finished login from a user who is still busy.
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.
Why
Second field test of the hand-off: the user closed the GitHub window while
waitwas polling.Target.detachedFromTargetmarked the page gone, and the next poll reattached a blank tab silently (the recovery from #1600), sowaitkept pollingabout:blankuntil its timeout instead of reporting the closure. The closure was only reported on the-32001path. Verified live via/json/list: twoabout:blanktargets, no GitHub page,waitstill "waiting".What
Session.call: the first command to notice a closure returnsErrPageClosedwhichever way it was detected (event or-32001); only the command after that attaches a fresh tab. A pollingwaittherefore reports the closure on its next tick.ErrBrowserClosedwhen the reattach finds the browser itself gone (user quit Chrome), instead of a rawbrowser connection closed: websocket: close 1006error.waitreturns it as a result with the note that a throwaway profile's logins are lost (CHATCLI_BROWSER_PROFILEkeeps them).Tests
pkg/browser: after a detach event the first call isErrPageClosedwith no new target created, the second call creates exactly one and drives it; browser gone before the reattach →ErrBrowserClosed.cli/plugins:waitreturns the quit-browser message as a result.go test -racegreen on both packages; golangci-lint v2.13.2 0 issues.