Open-source AI browser agent for Chrome and Firefox (monorepo) 🧠
JavaScript ai-agentai-agentsai-toolsbrowser-aibrowser-automationbrowser-extensionchrome-aichrome-devtoolschrome-extensionchrome-extensionsfirefox-addonfirefox-addonsfirefox-extensionfirefox-extensionsgemmagemma4minimaxoffline-aioffline-llmqwen
Confirm a number-changing wall after two readings; narrow the spent check
Claude5335bbde9bc7
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex c301218b3..df38ad501 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -8,7 +8,7 @@ This changelog was generated from the repository Git history and release tags. V### Fixed- Chat sites such as WhatsApp: a request that points at the open chat instead of naming the person, such as "send some test messages to this one" or "message this user", now sends there instead of asking "which contact, and what text?". The planner never sees the page, and its rules counted only words like "reply here" as the open chat, so it asked the same question every time without reading the page. WebBrain still reads the open chat's header itself and binds every send to that one contact, and stops if no single chat is open. The planner is also told it cannot see the page, no longer reads a note about a screenshot it is never given, and leaves the wording of described messages, such as test messages or a thank-you, to the agent. One request can now cover the open chat and someone named besides it, as in "test messages here, then thank Rustem Bey": the open chat needs no confirmation, the reviewed plan shows the named person, and that person is confirmed once on WebBrain's card before the first send to them. Words that refer back to someone named earlier still mean that person, and on mail sites the people named besides "reply here" are handled as before. On WhatsApp, where a contact is confirmed through its contact drawer, one run still confirms only one chat's contact, so the second chat of such a request needs a request of its own; the agent is now told so, instead of being sent to re-read the page and retry.-- A subscription, registration or sign-in wall in front of a news article is now recognized in any language, by a model reading the wall's text once, instead of only when it used English phrases such as "Subscribe to continue reading". A Turkish "Okumaya devam etmek için abone olun" overlay now keeps WebBrain from reading the article hidden behind it, as an English one did, while an offer to subscribe beside text you can still read is not taken for a wall. A wall inside the article is found also after a long preview, and everything after the wall's text stays withheld; the preview before it stays readable, except the short passage just before the wall's text. If a page cannot be read again after its wall was recognized, the read fails rather than return what the wall hides. A wall whose number changes on every read, such as a countdown, stays a wall while its new text is read, and a count that stops being a wall when its number changes reads as what it is once read; a wall whose other text keeps changing makes the read fail rather than leak, and the agent may read the page once more in case the wall went away.+- A subscription, registration or sign-in wall in front of a news article is now recognized in any language, by a model reading the wall's text once, instead of only when it used English phrases such as "Subscribe to continue reading". A Turkish "Okumaya devam etmek için abone olun" overlay now keeps WebBrain from reading the article hidden behind it, as an English one did, while an offer to subscribe beside text you can still read is not taken for a wall. A wall inside the article is found also after a long preview, and everything after the wall's text stays withheld; the preview before it stays readable, except the short passage just before the wall's text. If a page cannot be read again after its wall was recognized, the read fails rather than return what the wall hides. A wall whose number changes on every read, such as a countdown, stays a wall while its new text is read, and needs no more readings once two of its numbers were read as the wall, while a count that stops being a wall when its number changes reads as what it is once read; a wall whose other text keeps changing makes the read fail rather than leak, and the agent may read the page once more in case the wall went away.- A dialog asking you to prove you are human now pauses the run's page actions in any language, not only when it says "Security verification", "Verify you are human" or another English phrase. Its title is read by a model once, the decision model first; LinkedIn's Turkish "Güvenlik doğrulaması" now counts, while a cookie notice or a form dialog does not. A dialog naming a CAPTCHA product still counts without any reading. A title no model can answer stops nothing and is asked about again only after half a minute, so page actions do not each wait for it.- Finding a verification email: the service the code is for is now matched by its name or web address alone, with no English words such as "code" or "verification" set aside, so the search treats the same request in every language alike. The tool now asks the model for only the service's name or domain.- An AWS WAF puzzle page ("Let's confirm you are human" in English) is now recognized in any language, by AWS's own puzzle script on its interstitial page, instead of by its English heading. Before, the same page in another language was not recognized as a CAPTCHA unless its widget was found, and a page running only AWS's silent check is still not taken for a puzzle.diff --git a/docs/architecture.md b/docs/architecture.mdindex 3ef47381a..e3e925315 100644--- a/docs/architecture.md+++ b/docs/architecture.md@@ -599,11 +599,12 @@ and then blocks offering a control a wall would (a button, a field, a form ora link standing on its own), in `pageTextsNeeded`; the agent has them read(the decision model first, the active model within four seconds) and readsthe page again with the readings, up to three times while each read reaches-more. A text that differs only in its numbers from a text read as a wall is-that wall at once and is still reported to be read, so a countdown wall-stands between reads and a quota that stops being a wall when its number-changes reads as what it is once read; a text read as no wall is simply-unread again when its numbers change. When a text reads as+more. A text that differs only in its numbers from texts read as one wall+is that wall at once, and is still reported to be read until two texts of+its shape were read as that wall, so a countdown wall stands between reads+at the cost of one more reading, and a quota that stops being a wall when+its number changes reads as what it is once read; a shape with any other+reading carries nothing over. When a text reads asa wall and the page cannot be read again, the read fails rather than returnthe answer made without that reading; so does an answer without that wallapplied while texts are still unread, at any pass, as with a wall whose@@ -1209,7 +1210,7 @@ Jobs are stored in `chrome.storage.local` under the key `wb_scheduled_jobs` as a110+ adapters inject site-specific guidance into the first user message (and re-inject on navigation to a different matched site). Only ONE adapter fires at a time (`getActiveAdapter(url)` returns the first match). See `docs/site-adapters.md` for how to write one. Each matched adapter emits a content-free `adapter_match` trace note with its identity, revision, and whether notes were injected. High-evidence repeated tasks may additionally expose validated V2 workflow jobs; the planner selects an app-owned ID semantically, the binding is revalidated on the live pre-execution URL, and the executor receives its trusted stages/evidence contract. Required submissions need dispatch plus post-submit observation, while jobs with a trusted complete inventory may require an explicit job-bound complete-coverage marker whose count matches terminal current-task ledger rows.-Adapters may also expose narrowly scoped runtime policy. Douyin `/chat` is the first `messaging.verifyActiveRecipient` route. The structured planner resolves an anaphoric recipient to `named` only when authentic prior-user context identifies exactly one target; unresolved pronouns clarify, and words that refer back to someone named earlier never mean the open thread. `active_conversation` is reserved for a request that points at the conversation on screen itself instead of naming it ("reply here", "this one", "this user", in any language): the planner never sees the page, so it does not ask who that is. An `active_conversation` planner target must first be pinned to exactly one strong visible header identity, while planning or, where the identity needs the page's own preparation first (Gmail's collapsed reply composer, a native WhatsApp contact drawer), at the first send in the thread open when the run was authorized; ambiguous or missing evidence stops for clarification. Its `recipients` are only the people the same request also names. On a route where a conversation reaches one person, the pinned conversation is the target and stays authorized for the whole task, while each named person is kept as requested (`requestedMessaging`, shown in the reviewed plan) and confirmed on WebBrain's recipient card before the first send to them. Native WhatsApp checks a contact through its drawer once per run, for the first chat the run looks at; after the chat selection changes, the observer and the recipient probe report `native_whatsapp_contact_check_spent`, and the agent is told that the chat needs a new request instead of being sent to retry. On a recipient-set route such as mail the named people are not added to the pin, since a planner copies names as the user wrote them while a mail composer shows addresses. The pin is the thread's recipients as before: one taken while planning sends a differing set to the card, while one taken at the first send from Gmail's collapsed reply composer is whatever that composer holds then, an existing limit. The first user message's screenshot note is dropped from the planner's copy of the task with the image the planner never receives. Immediately before a send-like click, submitted field, or Enter press, the content script resolves the exact target and a lower-page layout composer, then collects only unique header evidence from the narrow, non-scrollable region above it. Enter or submitted field input in a different editable is conclusively non-message only when structural semantics positively identify a search or navigation field; an alternate reply/forward/split-pane composer remains inconclusive and therefore cannot bypass recipient verification. A distant general control likewise remains inconclusive rather than being declared safe. A semantic conversation row in a separate left rail is conclusively navigation-only, allowing recovery to the requested thread whether or not the short rail currently overflows; nested row buttons, links, and their leaf descendants plus controls outside that structure remain inconclusive. The agent requires exact normalized identity equality and returns a no-dispatch blocker on missing, inconclusive, ambiguous, or mismatched evidence, and protected Enter dispatch permits exactly one keypress per verification. Every authorized `click`, `click_ax`, `set_field({submit:true})`, and composer Enter receives a one-use binding to the exact action target, composer, URL, and identity set. Direct content dispatches and Chrome's trusted CDP mouse/key paths consume and revalidate it immediately before `el.click()`, `mousePressed`, or Enter, after any field reconciliation and combobox delays; protected `click_ax` never issues a second no-progress fallback click. Search-result text, message content, input values, generic page text, failed probes, and edited plans with stale hidden metadata cannot authorize a send. Dispatch-capable tools whose effects cannot be bound to the probed recipient (`iframe_click`, `execute_js`, WebMCP execution, and `upload_file`, whose change event may auto-send) are unavailable on this protected route. Deterministic saved-workflow replay has no planner-owned recipient target, so a workflow with any potentially dispatching step scoped to a protected messaging route stops before page actions and directs the user to run a normal Act task with a named recipient; a per-step check also covers legacy workflows whose scope metadata is incomplete.+Adapters may also expose narrowly scoped runtime policy. Douyin `/chat` is the first `messaging.verifyActiveRecipient` route. The structured planner resolves an anaphoric recipient to `named` only when authentic prior-user context identifies exactly one target; unresolved pronouns clarify, and words that refer back to someone named earlier never mean the open thread. `active_conversation` is reserved for a request that points at the conversation on screen itself instead of naming it ("reply here", "this one", "this user", in any language): the planner never sees the page, so it does not ask who that is. An `active_conversation` planner target must first be pinned to exactly one strong visible header identity, while planning or, where the identity needs the page's own preparation first (Gmail's collapsed reply composer, a native WhatsApp contact drawer), at the first send in the thread open when the run was authorized; ambiguous or missing evidence stops for clarification. Its `recipients` are only the people the same request also names. On a route where a conversation reaches one person, the pinned conversation is the target and stays authorized for the whole task, while each named person is kept as requested (`requestedMessaging`, shown in the reviewed plan) and confirmed on WebBrain's recipient card before the first send to them. Native WhatsApp checks a contact through its drawer once per run, for the first chat the run looks at; once that check is invalidated, as by a change of the chat selection, the observer and the recipient probe report `native_whatsapp_contact_check_spent`, and the agent is told that the chat needs a new request instead of being sent to retry. A chat only hidden for a moment, as behind a modal, is not a spent check. On a recipient-set route such as mail the named people are not added to the pin, since a planner copies names as the user wrote them while a mail composer shows addresses. The pin is the thread's recipients as before: one taken while planning sends a differing set to the card, while one taken at the first send from Gmail's collapsed reply composer is whatever that composer holds then, an existing limit. The first user message's screenshot note is dropped from the planner's copy of the task with the image the planner never receives. Immediately before a send-like click, submitted field, or Enter press, the content script resolves the exact target and a lower-page layout composer, then collects only unique header evidence from the narrow, non-scrollable region above it. Enter or submitted field input in a different editable is conclusively non-message only when structural semantics positively identify a search or navigation field; an alternate reply/forward/split-pane composer remains inconclusive and therefore cannot bypass recipient verification. A distant general control likewise remains inconclusive rather than being declared safe. A semantic conversation row in a separate left rail is conclusively navigation-only, allowing recovery to the requested thread whether or not the short rail currently overflows; nested row buttons, links, and their leaf descendants plus controls outside that structure remain inconclusive. The agent requires exact normalized identity equality and returns a no-dispatch blocker on missing, inconclusive, ambiguous, or mismatched evidence, and protected Enter dispatch permits exactly one keypress per verification. Every authorized `click`, `click_ax`, `set_field({submit:true})`, and composer Enter receives a one-use binding to the exact action target, composer, URL, and identity set. Direct content dispatches and Chrome's trusted CDP mouse/key paths consume and revalidate it immediately before `el.click()`, `mousePressed`, or Enter, after any field reconciliation and combobox delays; protected `click_ax` never issues a second no-progress fallback click. Search-result text, message content, input values, generic page text, failed probes, and edited plans with stale hidden metadata cannot authorize a send. Dispatch-capable tools whose effects cannot be bound to the probed recipient (`iframe_click`, `execute_js`, WebMCP execution, and `upload_file`, whose change event may auto-send) are unavailable on this protected route. Deterministic saved-workflow replay has no planner-owned recipient target, so a workflow with any potentially dispatching step scoped to a protected messaging route stops before page actions and directs the user to run a normal Act task with a named recipient; a per-step check also covers legacy workflows whose scope metadata is incomplete.### Accessibility Tree (`accessibility-tree.js`)diff --git a/src/chrome/src/cdp/cdp-client.js b/src/chrome/src/cdp/cdp-client.jsindex 19d665986..d791c42d8 100644--- a/src/chrome/src/cdp/cdp-client.js+++ b/src/chrome/src/cdp/cdp-client.js@@ -4047,24 +4047,30 @@ export class CDPClient {const gateNormalize = (value) => String(value ?? '').replace(/[\\u200b-\\u200d\\ufeff]/g, '').replace(/\\s+/g, ' ').trim();const gateSlice = (value) => gateNormalize(gateNormalize(value).slice(0, GATE_TEXT_LIMIT).replace(/^[\\udc00-\\udfff]/, '').replace(/[\\ud800-\\udbff]$/, ''));- // A text that differs only in its numbers from a text read as a- // wall, such as a countdown's next second, is that wall for now and- // is still reported to be read, as in content.js: wall readings of- // texts with digits, by the text with each run of digits as one '#'.- // A text read as no wall is simply unread again when its numbers- // change.+ // A text that differs only in its numbers from texts read as one+ // wall, such as a countdown's next second, is that wall, as in+ // content.js: at once, and still reported to be read until two texts+ // of its shape were read as that wall. Readings of texts with digits+ // by the text with each run of digits as one '#'; a shape with any+ // other reading carries nothing over.const gateDigitShape = (text) => (/\\p{Nd}/u.test(text) ? text.replace(/\\p{Nd}+/gu, '#') : '');- const gateWallShapes = new Map();+ const gateShapes = new Map();for (const [text, choice] of Object.entries(pageBlockerReadings)) {- const shape = GATE_TYPES.includes(choice) ? gateDigitShape(gateNormalize(text)) : '';- if (shape) gateWallShapes.set(shape, choice);+ const shape = gateDigitShape(gateNormalize(text));+ if (!shape) continue;+ const entry = gateShapes.get(shape) || { choice: '', walls: 0, mixed: false };+ if (!GATE_TYPES.includes(choice) || (entry.choice && entry.choice !== choice)) entry.mixed = true;+ else { entry.choice = choice; entry.walls += 1; }+ gateShapes.set(shape, entry);}const gateReading = (text) => {if (!text) return 'other';const reading = Object.prototype.hasOwnProperty.call(pageBlockerReadings, text) ? String(pageBlockerReadings[text] || '') : '';if (reading) return GATE_TYPES.includes(reading) ? reading : 'other';- const shape = gateDigitShape(text);- const provisional = shape && gateWallShapes.has(shape) ? gateWallShapes.get(shape) : null;+ const shaped = gateShapes.get(gateDigitShape(text));+ const wall = shaped && !shaped.mixed && shaped.walls > 0 ? shaped.choice : null;+ if (wall && shaped.walls >= 2) return wall;+ const provisional = wall;if (!unreadGateTexts.includes(text)) {if (unreadGateTexts.length >= 40) return provisional;unreadGateTexts.push(text);diff --git a/src/chrome/src/content/chat-observation.js b/src/chrome/src/content/chat-observation.jsindex 1d926445b..6146452cf 100644--- a/src/chrome/src/content/chat-observation.js+++ b/src/chrome/src/content/chat-observation.js@@ -744,14 +744,14 @@return !whatsappRepairAnchor.invalidated && sameWhatsappPins(whatsappRepairAnchor.pins) ? pins : null;};// A run checks one contact through its drawer: the anchor is the first- // chat the run looked at, and once WhatsApp's chat selection changed, or- // that chat's header was replaced, no chat can be checked again until the- // next run (a new owner). True when that is why no check is available.+ // chat the run looked at, and once it is invalidated, as when WhatsApp's+ // chat selection changes, no chat can be checked again until the next run+ // (a new owner). True when that is why no check is available. Anchored+ // nodes that are only hidden for now, as behind a modal, do not count.window.__wb_native_whatsapp_repair_spent = () => {- if (!whatsappOwner || !whatsappRepairAnchor) return false;+ if (!whatsappOwner || whatsappRepairAnchor?.invalidated !== true) return false;const composers = query(document, '[data-testid="conversation-compose-box-input"][contenteditable="true"][role="textbox"]');- return composers.length === 1 && whatsappNativeComposer(composers[0])- && (whatsappRepairAnchor.invalidated || !sameWhatsappPins(whatsappRepairAnchor.pins));+ return composers.length === 1 && whatsappNativeComposer(composers[0]);};window.__wb_native_whatsapp_repair_action = target => {const pins = window.__wb_get_native_whatsapp_repair();diff --git a/src/chrome/src/content/content.js b/src/chrome/src/content/content.jsindex 185ddc2bb..fe85dd3db 100644--- a/src/chrome/src/content/content.js+++ b/src/chrome/src/content/content.js@@ -3548,13 +3548,15 @@if (!text) return 'other';const known = _pageReading('page_blocker', text, null, { queue: false, maxLength: PAGE_GATE_TEXT_LIMIT });if (known) return PAGE_GATE_TYPES.has(known) ? known : 'other';- // A text that differs only in its numbers from a text read as a wall,- // such as a countdown's next second, is that wall for now, and is still- // reported to be read: a model's reading of the text itself then- // replaces this, so a quota that stops being a wall when its number- // changes reads as what it is.+ // A text that differs only in its numbers from texts read as a wall,+ // such as a countdown's next second, is that wall: at once, and still+ // reported to be read until two texts of its shape were read as that+ // wall, so a model's reading of the text itself replaces the guess and a+ // quota that stops being a wall when its number changes reads as what it+ // is.const shaped = _pageBlockerWallByShape(text);- const provisional = shaped && PAGE_GATE_TYPES.has(shaped) ? shaped : null;+ if (shaped?.confirmed && PAGE_GATE_TYPES.has(shaped.choice)) return shaped.choice;+ const provisional = shaped && PAGE_GATE_TYPES.has(shaped.choice) ? shaped.choice : null;if (!budget.seen.has(text)) {if (budget.left <= 0) return provisional;budget.left -= 1;@@ -6609,12 +6611,15 @@'draft_tool', 'conversation_tool']);const _pageReadings = new Map();const _pageReadingsUnread = new Map();- // Wall readings of overlay and article-block texts that hold digits, by the- // text with each run of digits as one '#'. A wall whose number changes on- // every read, such as a countdown, stays a wall while its new text is read- // (see pageGateReading). Only walls carry over this way: a text read as no- // wall is simply unread again when its numbers change.- const _pageBlockerWallShapes = new Map();+ // Readings of overlay and article-block texts that hold digits, by the+ // text with each run of digits as one '#': which wall the texts of a shape+ // were read as (up to four of them), and whether one was read as no wall+ // or as another wall. A text of a shape read only as one wall is that wall+ // for now and is still read (see pageGateReading); once two texts of the+ // shape were read so, a countdown's next number is that wall without+ // another read. A shape with any other reading carries nothing over, as a+ // quota that stops being a wall at another number.+ const _pageBlockerShapes = new Map();const _PAGE_BLOCKER_WALL_TYPES = new Set(['subscription', 'registration', 'login']);function _pageReadingText(value) {@@ -6625,11 +6630,13 @@return /\p{Nd}/u.test(text) ? text.replace(/\p{Nd}+/gu, '#') : '';}- // The wall reading a text gets from a text read as a wall that differs from- // it only in its numbers, or null.+ // The wall a text gets from texts read as that wall that differ from it+ // only in their numbers, { choice, confirmed }, or null.function _pageBlockerWallByShape(value) {const shape = _pageReadingDigitShape(_pageReadingText(value));- return shape ? _pageBlockerWallShapes.get(shape) || null : null;+ const entry = shape ? _pageBlockerShapes.get(shape) : null;+ if (!entry || entry.mixed || !entry.walls.size || !_PAGE_BLOCKER_WALL_TYPES.has(entry.choice)) return null;+ return { choice: entry.choice, confirmed: entry.walls.size >= 2 };}// `readings` is { question: { text: choice } }.@@ -6647,15 +6654,21 @@_pageReadings.delete(key);_pageReadings.set(key, choice);_pageReadingsUnread.delete(key);- const shape = kind === 'page_blocker' && _PAGE_BLOCKER_WALL_TYPES.has(choice) ? _pageReadingDigitShape(text) : '';+ const shape = kind === 'page_blocker' ? _pageReadingDigitShape(text) : '';if (shape) {- _pageBlockerWallShapes.delete(shape);- _pageBlockerWallShapes.set(shape, choice);+ const entry = _pageBlockerShapes.get(shape) || { choice: '', walls: new Set(), mixed: false };+ if (!_PAGE_BLOCKER_WALL_TYPES.has(choice) || (entry.choice && entry.choice !== choice)) entry.mixed = true;+ else {+ entry.choice = choice;+ if (entry.walls.size < 4) entry.walls.add(text);+ }+ _pageBlockerShapes.delete(shape);+ _pageBlockerShapes.set(shape, entry);}}}while (_pageReadings.size > 3200) _pageReadings.delete(_pageReadings.keys().next().value);- while (_pageBlockerWallShapes.size > 800) _pageBlockerWallShapes.delete(_pageBlockerWallShapes.keys().next().value);+ while (_pageBlockerShapes.size > 800) _pageBlockerShapes.delete(_pageBlockerShapes.keys().next().value);}// The reading of one text: its choice, '' when there is no text, or nulldiff --git a/src/firefox/src/content/chat-observation.js b/src/firefox/src/content/chat-observation.jsindex 1d926445b..6146452cf 100644--- a/src/firefox/src/content/chat-observation.js+++ b/src/firefox/src/content/chat-observation.js@@ -744,14 +744,14 @@return !whatsappRepairAnchor.invalidated && sameWhatsappPins(whatsappRepairAnchor.pins) ? pins : null;};// A run checks one contact through its drawer: the anchor is the first- // chat the run looked at, and once WhatsApp's chat selection changed, or- // that chat's header was replaced, no chat can be checked again until the- // next run (a new owner). True when that is why no check is available.+ // chat the run looked at, and once it is invalidated, as when WhatsApp's+ // chat selection changes, no chat can be checked again until the next run+ // (a new owner). True when that is why no check is available. Anchored+ // nodes that are only hidden for now, as behind a modal, do not count.window.__wb_native_whatsapp_repair_spent = () => {- if (!whatsappOwner || !whatsappRepairAnchor) return false;+ if (!whatsappOwner || whatsappRepairAnchor?.invalidated !== true) return false;const composers = query(document, '[data-testid="conversation-compose-box-input"][contenteditable="true"][role="textbox"]');- return composers.length === 1 && whatsappNativeComposer(composers[0])- && (whatsappRepairAnchor.invalidated || !sameWhatsappPins(whatsappRepairAnchor.pins));+ return composers.length === 1 && whatsappNativeComposer(composers[0]);};window.__wb_native_whatsapp_repair_action = target => {const pins = window.__wb_get_native_whatsapp_repair();diff --git a/src/firefox/src/content/content.js b/src/firefox/src/content/content.jsindex 51558e2ae..c2bcee124 100644--- a/src/firefox/src/content/content.js+++ b/src/firefox/src/content/content.js@@ -67,13 +67,15 @@if (!text) return 'other';const known = _pageReading('page_blocker', text, null, { queue: false, maxLength: PAGE_GATE_TEXT_LIMIT });if (known) return PAGE_GATE_TYPES.has(known) ? known : 'other';- // A text that differs only in its numbers from a text read as a wall,- // such as a countdown's next second, is that wall for now, and is still- // reported to be read: a model's reading of the text itself then- // replaces this, so a quota that stops being a wall when its number- // changes reads as what it is.+ // A text that differs only in its numbers from texts read as a wall,+ // such as a countdown's next second, is that wall: at once, and still+ // reported to be read until two texts of its shape were read as that+ // wall, so a model's reading of the text itself replaces the guess and a+ // quota that stops being a wall when its number changes reads as what it+ // is.const shaped = _pageBlockerWallByShape(text);- const provisional = shaped && PAGE_GATE_TYPES.has(shaped) ? shaped : null;+ if (shaped?.confirmed && PAGE_GATE_TYPES.has(shaped.choice)) return shaped.choice;+ const provisional = shaped && PAGE_GATE_TYPES.has(shaped.choice) ? shaped.choice : null;if (!budget.seen.has(text)) {if (budget.left <= 0) return provisional;budget.left -= 1;@@ -5915,12 +5917,15 @@'draft_tool', 'conversation_tool']);const _pageReadings = new Map();const _pageReadingsUnread = new Map();- // Wall readings of overlay and article-block texts that hold digits, by the- // text with each run of digits as one '#'. A wall whose number changes on- // every read, such as a countdown, stays a wall while its new text is read- // (see pageGateReading). Only walls carry over this way: a text read as no- // wall is simply unread again when its numbers change.- const _pageBlockerWallShapes = new Map();+ // Readings of overlay and article-block texts that hold digits, by the+ // text with each run of digits as one '#': which wall the texts of a shape+ // were read as (up to four of them), and whether one was read as no wall+ // or as another wall. A text of a shape read only as one wall is that wall+ // for now and is still read (see pageGateReading); once two texts of the+ // shape were read so, a countdown's next number is that wall without+ // another read. A shape with any other reading carries nothing over, as a+ // quota that stops being a wall at another number.+ const _pageBlockerShapes = new Map();const _PAGE_BLOCKER_WALL_TYPES = new Set(['subscription', 'registration', 'login']);function _pageReadingText(value) {@@ -5931,11 +5936,13 @@return /\p{Nd}/u.test(text) ? text.replace(/\p{Nd}+/gu, '#') : '';}- // The wall reading a text gets from a text read as a wall that differs from- // it only in its numbers, or null.+ // The wall a text gets from texts read as that wall that differ from it+ // only in their numbers, { choice, confirmed }, or null.function _pageBlockerWallByShape(value) {const shape = _pageReadingDigitShape(_pageReadingText(value));- return shape ? _pageBlockerWallShapes.get(shape) || null : null;+ const entry = shape ? _pageBlockerShapes.get(shape) : null;+ if (!entry || entry.mixed || !entry.walls.size || !_PAGE_BLOCKER_WALL_TYPES.has(entry.choice)) return null;+ return { choice: entry.choice, confirmed: entry.walls.size >= 2 };}// `readings` is { question: { text: choice } }.@@ -5953,15 +5960,21 @@_pageReadings.delete(key);_pageReadings.set(key, choice);_pageReadingsUnread.delete(key);- const shape = kind === 'page_blocker' && _PAGE_BLOCKER_WALL_TYPES.has(choice) ? _pageReadingDigitShape(text) : '';+ const shape = kind === 'page_blocker' ? _pageReadingDigitShape(text) : '';if (shape) {- _pageBlockerWallShapes.delete(shape);- _pageBlockerWallShapes.set(shape, choice);+ const entry = _pageBlockerShapes.get(shape) || { choice: '', walls: new Set(), mixed: false };+ if (!_PAGE_BLOCKER_WALL_TYPES.has(choice) || (entry.choice && entry.choice !== choice)) entry.mixed = true;+ else {+ entry.choice = choice;+ if (entry.walls.size < 4) entry.walls.add(text);+ }+ _pageBlockerShapes.delete(shape);+ _pageBlockerShapes.set(shape, entry);}}}while (_pageReadings.size > 3200) _pageReadings.delete(_pageReadings.keys().next().value);- while (_pageBlockerWallShapes.size > 800) _pageBlockerWallShapes.delete(_pageBlockerWallShapes.keys().next().value);+ while (_pageBlockerShapes.size > 800) _pageBlockerShapes.delete(_pageBlockerShapes.keys().next().value);}// The reading of one text: its choice, '' when there is no text, or nulldiff --git a/test/fixtures/run.mjs b/test/fixtures/run.mjsindex 842132a59..67099c74d 100644--- a/test/fixtures/run.mjs+++ b/test/fixtures/run.mjs@@ -1209,10 +1209,11 @@ for (const [label, browserKind] of [['Chrome', 'chrome'], ['Firefox', 'firefox']if (ticked.pageGate?.type !== 'subscription' || /SECRET_COUNTDOWN_BODY/.test(JSON.stringify(ticked))) {throw new Error(`${action} at ${n} s: the countdown wall fell before its new text was read: ${JSON.stringify({ pageGate: ticked.pageGate })}`);}- // The first read after a tick reports the new text; once read, it is known.- if (action === 'get_page_info_cdp'- && !(ticked.pageTextsNeeded || []).some(entry => new RegExp(`Kalan süre: ${n} sn`).test(entry.text))) {- throw new Error(`${action} at ${n} s: the countdown's new text was not reported to be read`);+ // At 58 s the new text is reported to be read; once two texts of+ // its shape read as the wall, a new number is not read again.+ const reported = (ticked.pageTextsNeeded || []).some(entry => /Kalan süre/.test(entry.text));+ if (action === 'get_page_info_cdp' && reported !== (n === 58)) {+ throw new Error(`${action} at ${n} s: the countdown's new text was ${reported ? '' : 'not '}reported to be read`);}if (action === 'get_accessibility_tree' && !/Abone ol/.test(ticked.pageContent || '')) {throw new Error(`${action} at ${n} s: the wall's own control is gone`);@@ -1247,6 +1248,13 @@ for (const [label, browserKind] of [['Chrome', 'chrome'], ['Firefox', 'firefox']if (corrected.pageGate || !/QUOTA_ARTICLE_BODY/.test(corrected.text || '')) {throw new Error(`a quota read as no wall stayed a wall: ${JSON.stringify({ pageGate: corrected.pageGate })}`);}+ // Its shape now has a reading as no wall, so another number is asked+ // about, not guessed.+ await page.evaluate(text => { document.querySelector('#count').textContent = text; }, quota(5));+ const another = await call(page, 'get_page_info_cdp', { __wbPageReadings: { page_blocker: quotaReadings } });+ if (another.pageGate || !(another.pageTextsNeeded || []).some(entry => /5 ücretsiz makale/.test(entry.text))) {+ throw new Error(`a quota with a reading as no wall was guessed at another number: ${JSON.stringify({ pageGate: another.pageGate })}`);+ }const counter = n => `Bu ay ${n} ücretsiz makale hakkınız kaldı.`;await setupContentHtml(page, `<!doctype html><meta property="og:type" content="article">@@ -1558,6 +1566,14 @@ test('Chrome CDP mirror keeps a wall whose number changes a wall while its new t|| !(ticked.pageTextsNeeded || []).some(entry => /Kalan süre: 58 sn/.test(entry.text))) {throw new Error(`CDP countdown wall mismatch: ${JSON.stringify({ pageGate: ticked.pageGate, needed: ticked.pageTextsNeeded })}`);}+ // Read at 58 s too, the shape is confirmed: 57 s is the wall without a read.+ await readGateTextsLikeTheAgent(() => client.readPage(1, { pageBlockerReadings: readings }), readings);+ await page.evaluate(text => { document.querySelector('#count').textContent = text; }, countdown(57));+ const confirmed = await client.readPage(1, { pageBlockerReadings: readings });+ if (confirmed.pageGate?.type !== 'subscription' || /SECRET_COUNTDOWN_BODY/.test(JSON.stringify(confirmed))+ || (confirmed.pageTextsNeeded || []).some(entry => /Kalan süre/.test(entry.text))) {+ throw new Error(`CDP confirmed countdown mismatch: ${JSON.stringify({ pageGate: confirmed.pageGate, needed: confirmed.pageTextsNeeded })}`);+ }// A quota like a wall but for its number is a wall until its own text is read.const quota = n => `Bu ay ${n} ücretsiz makale hakkınız kaldı. Kayıt olun.`;await page.setContent(`<!doctype html><meta property="og:type" content="article">diff --git a/test/native-whatsapp-contact.mjs b/test/native-whatsapp-contact.mjsindex d45329c15..f71b89e4a 100644--- a/test/native-whatsapp-contact.mjs+++ b/test/native-whatsapp-contact.mjs@@ -106,6 +106,17 @@ for (const [build, engine] of [['chrome', chromium], ['firefox', firefox]]) {const offered = await probe(ownerFor());assert.equal(offered.nativeWhatsappRepairAvailable, true, JSON.stringify(offered));assert.equal(offered.nativeWhatsappRepairSpent, undefined);+ // From review: the chat hidden for a moment, as behind a modal, is not+ // a spent check; the same chat is offered its check again afterwards.+ await page.evaluate(() => document.querySelector('#main').setAttribute('aria-hidden', 'true'));+ const hidden = await observe();+ assert.notEqual(hidden.reason, 'native_whatsapp_contact_check_spent', JSON.stringify(hidden));+ assert.notEqual(hidden.retryable, false, JSON.stringify(hidden));+ assert.equal((await probe(ownerFor())).nativeWhatsappRepairSpent, undefined);+ await page.evaluate(() => document.querySelector('#main').removeAttribute('aria-hidden'));+ const shown = await observe();+ assert.equal(shown.reason, 'native_whatsapp_contact_binding_required', JSON.stringify(shown));+ assert.ok(shown.nativeWhatsappRepair, 'the chat shown again is not offered its contact check');await page.evaluate(() => {const selected = document.querySelector('[aria-selected]');selected.setAttribute('aria-selected', 'false'); selected.setAttribute('aria-selected', 'true');diff --git a/test/quality/native-chat-mv3.mjs b/test/quality/native-chat-mv3.mjsindex 9a70c8b14..30d7182e2 100644--- a/test/quality/native-chat-mv3.mjs+++ b/test/quality/native-chat-mv3.mjs@@ -357,6 +357,15 @@ try {}) : structuredPath(dispatchPath) ? sendAttempts.filter(event => heldStructuredSend(event.data.result)) : [];if (dispatchPath === 'generic_submit') assert.equal(feedbackSkips.length, current.feedbackRecoveries || 0);else assert.ok(feedbackSkips.length <= 2, 'Browser changes held back a send more than twice.');+ // Each held send has page feedback around it: after the step before it+ // and before the next step after it. A skip for any other reason counts.+ for (const skip of structuredPath(dispatchPath) ? feedbackSkips : []) {+ const updates = run.result.updates, at = updates.indexOf(skip);+ const from = updates.slice(0, at).findLastIndex(event => event.type === 'tool_result');+ const next = updates.findIndex((event, index) => index > at && event.type === 'tool_call');+ assert.ok(updates.slice(from + 1, next < 0 ? updates.length : next).some(event => event.type === 'page_feedback'),+ 'A send was held back without page feedback around it: ' + JSON.stringify(skip.data.result).slice(0, 300));+ }const dispatches = dispatchPath === 'structured_prefill' ? sendAttempts.filter(event => event.data.result.success === true): sendAttempts.filter(event => !feedbackSkips.includes(event));assert.equal(dispatches.length, expectedCount);