Repository navigation
feat(browser): browser_info waits for text to appear or go - #955
Merged
Merged
Conversation
omartelo
force-pushed
the
feat/browser-wait-for
branch
from
October 28, 2026 12:18
9d562e4 to
02dc21f
Compare
browser_info takes wait_for and wait_gone: a case-sensitive substring of the page's visible text (document.body.innerText, the whole page). The read polls every 100 ms for up to 20 s, then answers the page anyway, with a line saying the wait timed out, so the agent stops re-reading in a loop after a click that starts a fetch. browser.Info now takes BrowserInfoOptions instead of SessionIDOptions; the three tests calling Service.Read follow that contract change.
On Windows the TempDir cleanup registered inside mkTmp ran before Service.Cleanup closed Chrome, and failed on a file Chrome still held.
omartelo
force-pushed
the
feat/browser-wait-for
branch
from
October 28, 2026 13:05
02dc21f to
df9ef63
Compare
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.
Summary
After a click that starts a fetch, an agent re-reads the session browser with
browser_infountil the result shows.browser_infonow takes two optional parameters so it can wait once instead:wait_for: text that should appearwait_gone: text that should disappearBoth are a case-sensitive substring of the page's visible text (
document.body.innerText, the whole page, not only the viewport). The read polls every 100 ms (textPoll) for up to 20 s (maxTextWait, which leaves the page read its ownpageWaitunder the client's 60 sopenCall). On timeout it answers the page anyway with await: timed out, this is the page as it standsline, not an error. A read failing mid-wait (the page between two documents after a navigating click) counts as not yet; a Chrome that died ends the wait and the page read reports it. Without the parameters, behavior is unchanged. No new MCP tool;browser_infostays read-only. The CLI'slich browser infotakes no flags today, so it does not mirror these.The timeout line is English and outside the i18n catalog, like every other page-answer line (
url:,downloaded:, ...).Contract
browser.Infotakes the newapi.BrowserInfoOptions(id,waitFor,waitGone) instead ofSessionIDOptions;BrowserPageInfogainswaitTimedOut.api/testdata/contract.goldenupdated.PagegainsHasText. The three existing test calls toService.Read(session_downloads_test.go,downloads_live_test.go) change only their options type: the contract changed.Test plan
internal/browser/wait_test.go(fake page): text appears on the third read, text goes on the second, case-sensitive miss times out within the shortened bound and still answers the page, no params reads no text, a Chrome dying mid-wait stops the wait.internal/browser/wait_live_test.go(skips without a Chromium-family browser): a page writesSavedoverLoading300 ms after load, below the fold;wait_forandwait_goneboth see it, and a case-mismatched wait times out with the page answered. 10/10 with-race.internal/cli: the timeout line sits after the title.gofmt -l .,go vet ./...,go test ./...green;native/gofmt,go vet ./...,go build ./...green.