fix(browser): stop page text reads from returning another page's text after a navigation (#196659)
Root cause: `extensions/browser/src/browser/pw-tools-core.activity.ts:46` (main c5f6eed452) returns `locator.innerText(...)` without checking that the tab still shows the document the read started on; Playwright locators wait for their selector and re-resolve after a navigation, so a read that overlaps a navigation or reload finishes on the next page.
Fixes #196658
## What Problem This Solves
When an agent reads page text and the tab navigates or reloads while the read is waiting (a meta refresh, a redirect, a script calling `location.assign`), the browser tool returns the new page's text as the answer for the page the agent asked about. The model only sees the text, so it acts on content from a different page.
## User Impact
User impact: a page text read that overlaps a navigation now fails with the existing browser error `Frame changed while its browser snapshot was being captured; retry.` instead of returning another page's text. Reading again returns the current page with its real URL. Reads on pages that stay put, including pages that fill in their content in place, are unchanged.
## Why This Change Was Made
The text reader now runs inside the frame guard that snapshots already use: it watches the main frame for a navigation or detach while the read runs and rejects the result if one happened. This replaces the earlier version of this PR, which read the CDP frame tree twice per read, added a new error message and bound the read to the route's tab URL; the guard needs no extra CDP sessions and no route change.
Accepted limits: same-document URL changes during a read (`pushState`, hash changes) also reject, as they do for snapshots; child-frame navigations are not watched; a navigation that commits after the text is read but before the route looks up the tab URL can still pair the text with the newer URL in the response details.
Thanks @martins-oss for the report, the diagnosis and the original fix.
## Evidence
Real Gateway (built `dist/`), managed headless Chromium, a local page that meta-refreshes from `/a` to `/b` 1.5 s after loading; each read is `browser.request GET /text` with `selector: "#total"` on the `/a` tab. On `main` the read returns page B's text; on this head it returns the existing retry error, the next read on the same tab returns page B with URL `/b`, and stable and in-place-update pages read unchanged. Proof lines: https://github.com/openclaw/openclaw/pull/196659#issuecomment-6998919063
The new unit regression in `pw-tools-core.activity.test.ts` fails on `main` (`promise resolved "{ text: 'Next page', truncated: false }" instead of rejecting`) and passes here.
Merge danger: two-way door; a revert restores the old behavior and nothing is written. Blast radius: browser text reads (`browser` tool text action, `/text` route) only.
Co-authored-by: Ayaan Zaidi <hi@obviy.us>
Current
·
C2
·2026-11
fix(browser): stop page text reads from returning another page's text…
Find Your Interest
- My LiveJournal Anniversary
- Everyone Hates AI. Half of Them Use It.
- Last Week (Month) in AI #347 - Nvidia's spy, Anthropic's $1.4T IPO, AI's blue wave
- Github and Open-source Is a Boon for the Underprivileged
- Github and Open-source Is a Boon for the Underprivileged
- AI Engineer Interview Questions: What I Ask After the Right Answer
- Smartwatch blood pressure monitoring was okay. AI is making it better.
- New Data From Google: See How Ads Impact Web Performance
- wsf-xlii
- Apple’s new health AI app is a study, not your doctor
Current
·
C2
·2026-11






