Skip to content

fix(browser): report a closed page before reattaching, and a quit browser as its own result - #1601

Merged
diillson merged 2 commits into
mainfrom
fix/browser-page-closed-report-first
Sep 15, 2026
Merged

diillson merged 2 commits into
mainfrom
fix/browser-page-closed-report-first

Conversation

@diillson

Copy link
Copy Markdown
Owner

Why

Second field test of the hand-off: the user closed the GitHub window while wait was polling. Target.detachedFromTarget marked the page gone, and the next poll reattached a blank tab silently (the recovery from #1600), so wait kept polling about:blank until its timeout instead of reporting the closure. The closure was only reported on the -32001 path. Verified live via /json/list: two about:blank targets, no GitHub page, wait still "waiting".

What

  • Session.call: the first command to notice a closure returns ErrPageClosed whichever way it was detected (event or -32001); only the command after that attaches a fresh tab. A polling wait therefore reports the closure on its next tick.
  • New ErrBrowserClosed when the reattach finds the browser itself gone (user quit Chrome), instead of a raw browser connection closed: websocket: close 1006 error. wait returns it as a result with the note that a throwaway profile's logins are lost (CHATCLI_BROWSER_PROFILE keeps them).

Tests

  • pkg/browser: after a detach event the first call is ErrPageClosed with no new target created, the second call creates exactly one and drives it; browser gone before the reattach → ErrBrowserClosed.
  • cli/plugins: wait returns the quit-browser message as a result.
  • go test -race green on both packages; golangci-lint v2.13.2 0 issues.

…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.
@github-actions

github-actions Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Quality Gate

Result: ✅ all floors passed

Floor Status Result Δ vs main Budget
1 · Build & Static go build / vet / fmt / lint
2 · Coverage 59.7% (bootstrap) 0 ≥ baseline
3 · Patch coverage 86.3% (req ≥ 60%) ≥ 60%
4 · AI smells diff scanned
5 · Scope budget 5 files / 175 LOC (code 175 + tooling 0) warn 800·25
6 · E2E go test -race ./e2e/... ≤ 15min
7 · Commit lint conventional commits
8 · Cyclo (new code) 3 file(s) under threshold ≤ 30
9 · Secrets scan gitleaks
10 · i18n parity missing 0, unknown 0
11 · CRD drift drifted: 0
12 · License headers 0 missing
13 · API breaking 0 incompatible
14 · Binary size chatcli 96.1MB · operator 54.3MB 100MB each
15 · Provider parity 14 providers · 0 violations

Config: .github/quality-gate.yml. Workflow: .github/workflows/quality-gate.yml.

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.
@diillson
diillson merged commit 1500b8d into main Sep 15, 2026
25 checks passed
@diillson
diillson deleted the fix/browser-page-closed-report-first branch September 15, 2026 20:51
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