Skip to content

Open-source AI browser agent for Chrome and Firefox (monorepo) 🧠

Fix the second review: provisional number walls, a spent WhatsApp check

Claude653e92b35f97
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5a0727180..c301218b3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,8 +7,8 @@ This changelog was generated from the repository Git history and release tags. V
## [Unreleased]
### 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 checked as before, by the card when the recipients differ from the thread's. 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.
-- 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, keeps the reading it got, while an offer whose count changes is read again; a wall whose other text keeps changing makes the read fail rather than leak.
+- 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 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.md
index 2bcd38396..3ef47381a 100644
--- a/docs/architecture.md
+++ b/docs/architecture.md
@@ -599,9 +599,11 @@ and then blocks offering a control a wall would (a button, a field, a form or
a link standing on its own), in `pageTextsNeeded`; the agent has them read
(the decision model first, the active model within four seconds) and reads
the page again with the readings, up to three times while each read reaches
-more. A wall reading of a text with digits also reaches a text that differs
-from it only in its numbers, so a countdown wall keeps its reading; a text
-read as no wall is read again when its numbers change. When a text reads as
+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
a wall and the page cannot be read again, the read fails rather than return
the answer made without that reading; so does an answer without that wall
applied while texts are still unread, at any pass, as with a wall whose
@@ -1207,7 +1209,7 @@ Jobs are stored in `chrome.storage.local` under the key `wb_scheduled_jobs` as a
110+ 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. On a recipient-set route such as mail the pin stays the thread's own recipients and the named people are not added, since a planner copies names as the user wrote them while a mail composer shows addresses; a send whose set differs from the pin goes to the card. 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; 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.
### Accessibility Tree (`accessibility-tree.js`)
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index 0ad8d611b..318a1bec2 100644
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@ -12202,9 +12202,11 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
// not). Otherwise a read that cannot be repeated keeps the answer before it.
async _rereadWithPageBlockerReadings(tabId, name, response, dispatch) {
if ((name !== 'read_page' && name !== 'get_accessibility_tree') || !response || typeof response !== 'object') return response;
- const wallUnapplied = { success: false, error: 'This page shows a subscription, registration or sign-in wall '
+ // A wall can also go away during the read, as an overlay a subscriber's
+ // page removes does, so a fresh read may succeed.
+ const wallUnapplied = { success: false, error: 'This page showed a subscription, registration or sign-in wall '
+ 'that WebBrain could not apply, as when its text changes on every read, so nothing behind it was returned. '
- + 'Report the wall instead of reading past it.' };
+ + 'Read the page again once; if the wall is still there, report it instead of reading past it.' };
const isWall = entry => entry?.kind === 'page_blocker'
&& ['subscription', 'registration', 'login'].includes(this._pageTextReading('page_blocker', entry.text));
let current = response;
@@ -27355,6 +27357,10 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
const missingLinkedInComposer = policy.adapterName === 'linkedin'
&& probe?.success === true && probe?.composerAvailable === false;
const inconclusive = probe?.success !== true || probe?.conclusive !== true || probe?.messageSend !== true;
+ // A native WhatsApp run that can no longer check any contact's drawer
+ // says so, instead of sending the agent to re-read and retry in vain.
+ const contactCheckSpent = inconclusive && probe?.nativeWhatsappRepairSpent === true
+ && probe?.reasonCode === 'native_whatsapp_contact_check_spent' && typeof probe?.error === 'string';
// Human-readable view of who the page actually addresses, so a mismatch
// block can name the exact observed recipient.
const observedRecipientLabel = (() => {
@@ -27374,11 +27380,11 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
noDispatch: true,
dispatched: false,
messageRecipientGuard: true,
- ...((missingLinkedInComposer || (!inconclusive && target)) ? { retryable: false } : {}),
+ ...((missingLinkedInComposer || (!inconclusive && target) || contactCheckSpent) ? { retryable: false } : {}),
reasonCode: inconclusive
? (probe?.reasonCode || 'message_send_classification_inconclusive')
: (target ? 'active_recipient_unverified' : 'authorized_recipient_missing'),
- error: missingLinkedInComposer
+ error: contactCheckSpent ? String(probe.error || '') : missingLinkedInComposer
? (probe?.reasonCode === 'message_commit_without_composer'
? 'Message send blocked: this control commits a message (for example "Send" / "Send without a note") but no active composer or recipient could be verified. Changing click targeting methods will not help. Open the intended conversation so its composer and recipient are visible, or report that the message could not be sent.'
: 'Message send blocked: no message composer is visible, so this send cannot be verified. Changing click targeting methods will not resolve this classification failure. Re-read the page to find a supported navigation or composer-opening control; if none is available, report the blocker instead of repeating the click.')
diff --git a/src/chrome/src/agent/planner.js b/src/chrome/src/agent/planner.js
index 853ff88c5..ed540355e 100644
--- a/src/chrome/src/agent/planner.js
+++ b/src/chrome/src/agent/planner.js
@@ -1260,7 +1260,7 @@ function appendPlanExecutionMetadata(lines, plan) {
// at, once that conversation is pinned (Agent._activeConversationPin).
const alsoNamed = plan.requested_messaging?.target_kind === 'named' ? plan.requested_messaging.recipients || [] : [];
if (alsoNamed.length) {
- lines.push(`- Also named, each confirmed on WebBrain's card before the first send to them: ${alsoNamed.map(recipient => `${recipient.role}:${recipient.identity}`).join(', ')}`);
+ lines.push(`- Also named, each verified before any send to them: ${alsoNamed.map(recipient => `${recipient.role}:${recipient.identity}`).join(', ')}`);
}
} else if (plan.messaging?.target_kind === 'active_conversation') {
const also = (plan.messaging.recipients || []).map(recipient => `${recipient.role}:${recipient.identity}`).join(', ');
diff --git a/src/chrome/src/cdp/cdp-client.js b/src/chrome/src/cdp/cdp-client.js
index 9ab998ff3..19d665986 100644
--- a/src/chrome/src/cdp/cdp-client.js
+++ b/src/chrome/src/cdp/cdp-client.js
@@ -4047,10 +4047,12 @@ 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 wall whose number changed since it was read, such as a
- // countdown, keeps its reading: wall readings of texts with digits
- // by the text with each run of digits as one '#'. A text read as no
- // wall is read again when its numbers change.
+ // 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.
const gateDigitShape = (text) => (/\\p{Nd}/u.test(text) ? text.replace(/\\p{Nd}+/gu, '#') : '');
const gateWallShapes = new Map();
for (const [text, choice] of Object.entries(pageBlockerReadings)) {
@@ -4062,12 +4064,12 @@ export class CDPClient {
const reading = Object.prototype.hasOwnProperty.call(pageBlockerReadings, text) ? String(pageBlockerReadings[text] || '') : '';
if (reading) return GATE_TYPES.includes(reading) ? reading : 'other';
const shape = gateDigitShape(text);
- if (shape && gateWallShapes.has(shape)) return gateWallShapes.get(shape);
+ const provisional = shape && gateWallShapes.has(shape) ? gateWallShapes.get(shape) : null;
if (!unreadGateTexts.includes(text)) {
- if (unreadGateTexts.length >= 40) return null;
+ if (unreadGateTexts.length >= 40) return provisional;
unreadGateTexts.push(text);
}
- return null;
+ return provisional;
};
const gateHasBlockChildren = (el, depth = 0) => {
for (const child of el.children) {
diff --git a/src/chrome/src/content/chat-observation.js b/src/chrome/src/content/chat-observation.js
index 2490ea93a..1d926445b 100644
--- a/src/chrome/src/content/chat-observation.js
+++ b/src/chrome/src/content/chat-observation.js
@@ -743,6 +743,16 @@
if (!whatsappRepairAnchor) whatsappRepairAnchor = { pins, invalidated: false };
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.
+ window.__wb_native_whatsapp_repair_spent = () => {
+ if (!whatsappOwner || !whatsappRepairAnchor) 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));
+ };
window.__wb_native_whatsapp_repair_action = target => {
const pins = window.__wb_get_native_whatsapp_repair();
if (!pins || !target?.isConnected) return false;
@@ -1514,6 +1524,12 @@
: 'Inspect this current chat\'s exact native profile. ')
+ 'Its native username and numeric name/avatar peer must match the current header, composer and live transcript. After opening that profile, call chat_observe again before concluding the binding remains unavailable. A header label or route alone does not establish recipient identity. Do not send or reuse a previous chat while this binding is unavailable.' };
}
+ // The run's one contact check is spent (it needs no composer found
+ // here: the native composer is no longer tied to a checked chat).
+ if (window.__wb_native_whatsapp_repair_spent()) {
+ return { success: false, schema: SCHEMA, reason: 'native_whatsapp_contact_check_spent', retryable: false,
+ error: 'This run can no longer confirm a WhatsApp contact: its contact check belongs to the first chat it looked at, and WhatsApp\'s chat selection or that chat\'s header changed since. Nothing was sent. Report what was sent and that a message to this chat needs a new request; do not retry it in this run.' };
+ }
if (composer && window.__wb_get_native_whatsapp_repair()?.composer === composer) {
const nativeWhatsappRepair = whatsappRepairGuidance();
return {
diff --git a/src/chrome/src/content/content.js b/src/chrome/src/content/content.js
index cc5e20d1a..185ddc2bb 100644
--- a/src/chrome/src/content/content.js
+++ b/src/chrome/src/content/content.js
@@ -3548,16 +3548,20 @@
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 wall whose number changed since it was read, such as a countdown.
+ // 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.
const shaped = _pageBlockerWallByShape(text);
- if (shaped && PAGE_GATE_TYPES.has(shaped)) return shaped;
+ const provisional = shaped && PAGE_GATE_TYPES.has(shaped) ? shaped : null;
if (!budget.seen.has(text)) {
- if (budget.left <= 0) return null;
+ if (budget.left <= 0) return provisional;
budget.left -= 1;
budget.seen.add(text);
}
_pageReading('page_blocker', text, null, { maxLength: PAGE_GATE_TEXT_LIMIT });
- return null;
+ return provisional;
}
// Whether an element lays its children out as blocks, so its text splits
@@ -6607,8 +6611,9 @@
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, keeps its reading. Only walls carry over
- // this way: a text read as no wall is read again when its numbers change.
+ // 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();
const _PAGE_BLOCKER_WALL_TYPES = new Set(['subscription', 'registration', 'login']);
@@ -7588,10 +7593,16 @@
nativeWhatsappRepair: true, identityCandidates: [] };
}
if (nativeLayoutContext?.service !== 'whatsapp') {
+ // No check left in this run: say so, rather than send the agent
+ // after a header click that cannot help.
+ const spent = !repair && window.__wb_native_whatsapp_repair_spent?.() === true;
return { success: true, messageSend: observationOnly ? false : null, conclusive: false,
composerAvailable: true, nativeWhatsappRepairAvailable: !!repair,
- reasonCode: 'native_whatsapp_contact_binding_required', identityCandidates: [],
- error: 'Native WhatsApp contact identity needs a fresh guarded header click, its contact drawer phone, and closing that same drawer. No message or editor write was authorized.' };
+ ...(spent ? { nativeWhatsappRepairSpent: true } : {}),
+ reasonCode: spent ? 'native_whatsapp_contact_check_spent' : 'native_whatsapp_contact_binding_required', identityCandidates: [],
+ error: spent
+ ? 'This run can no longer confirm a WhatsApp contact: its contact check belongs to the first chat it looked at, and WhatsApp\'s chat selection or that chat\'s header changed since. Nothing was sent. Report what was sent and that a message to this chat needs a new request; do not retry it in this run.'
+ : 'Native WhatsApp contact identity needs a fresh guarded header click, its contact drawer phone, and closing that same drawer. No message or editor write was authorized.' };
}
}
const layoutComposer = layoutCandidate
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index d35da0b43..a265e5fdf 100644
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@ -10835,9 +10835,11 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
// not). Otherwise a read that cannot be repeated keeps the answer before it.
async _rereadWithPageBlockerReadings(tabId, name, response, dispatch) {
if ((name !== 'read_page' && name !== 'get_accessibility_tree') || !response || typeof response !== 'object') return response;
- const wallUnapplied = { success: false, error: 'This page shows a subscription, registration or sign-in wall '
+ // A wall can also go away during the read, as an overlay a subscriber's
+ // page removes does, so a fresh read may succeed.
+ const wallUnapplied = { success: false, error: 'This page showed a subscription, registration or sign-in wall '
+ 'that WebBrain could not apply, as when its text changes on every read, so nothing behind it was returned. '
- + 'Report the wall instead of reading past it.' };
+ + 'Read the page again once; if the wall is still there, report it instead of reading past it.' };
const isWall = entry => entry?.kind === 'page_blocker'
&& ['subscription', 'registration', 'login'].includes(this._pageTextReading('page_blocker', entry.text));
let current = response;
@@ -24780,6 +24782,10 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
const missingLinkedInComposer = policy.adapterName === 'linkedin'
&& probe?.success === true && probe?.composerAvailable === false;
const inconclusive = probe?.success !== true || probe?.conclusive !== true || probe?.messageSend !== true;
+ // A native WhatsApp run that can no longer check any contact's drawer
+ // says so, instead of sending the agent to re-read and retry in vain.
+ const contactCheckSpent = inconclusive && probe?.nativeWhatsappRepairSpent === true
+ && probe?.reasonCode === 'native_whatsapp_contact_check_spent' && typeof probe?.error === 'string';
// Human-readable view of who the page actually addresses, so a mismatch
// block can name the exact observed recipient.
const observedRecipientLabel = (() => {
@@ -24799,11 +24805,11 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
noDispatch: true,
dispatched: false,
messageRecipientGuard: true,
- ...((missingLinkedInComposer || (!inconclusive && target)) ? { retryable: false } : {}),
+ ...((missingLinkedInComposer || (!inconclusive && target) || contactCheckSpent) ? { retryable: false } : {}),
reasonCode: inconclusive
? (probe?.reasonCode || 'message_send_classification_inconclusive')
: (target ? 'active_recipient_unverified' : 'authorized_recipient_missing'),
- error: missingLinkedInComposer
+ error: contactCheckSpent ? String(probe.error || '') : missingLinkedInComposer
? (probe?.reasonCode === 'message_commit_without_composer'
? 'Message send blocked: this control commits a message (for example "Send" / "Send without a note") but no active composer or recipient could be verified. Changing click targeting methods will not help. Open the intended conversation so its composer and recipient are visible, or report that the message could not be sent.'
: 'Message send blocked: no message composer is visible, so this send cannot be verified. Changing click targeting methods will not resolve this classification failure. Re-read the page to find a supported navigation or composer-opening control; if none is available, report the blocker instead of repeating the click.')
diff --git a/src/firefox/src/agent/planner.js b/src/firefox/src/agent/planner.js
index 853ff88c5..ed540355e 100644
--- a/src/firefox/src/agent/planner.js
+++ b/src/firefox/src/agent/planner.js
@@ -1260,7 +1260,7 @@ function appendPlanExecutionMetadata(lines, plan) {
// at, once that conversation is pinned (Agent._activeConversationPin).
const alsoNamed = plan.requested_messaging?.target_kind === 'named' ? plan.requested_messaging.recipients || [] : [];
if (alsoNamed.length) {
- lines.push(`- Also named, each confirmed on WebBrain's card before the first send to them: ${alsoNamed.map(recipient => `${recipient.role}:${recipient.identity}`).join(', ')}`);
+ lines.push(`- Also named, each verified before any send to them: ${alsoNamed.map(recipient => `${recipient.role}:${recipient.identity}`).join(', ')}`);
}
} else if (plan.messaging?.target_kind === 'active_conversation') {
const also = (plan.messaging.recipients || []).map(recipient => `${recipient.role}:${recipient.identity}`).join(', ');
diff --git a/src/firefox/src/content/chat-observation.js b/src/firefox/src/content/chat-observation.js
index 2490ea93a..1d926445b 100644
--- a/src/firefox/src/content/chat-observation.js
+++ b/src/firefox/src/content/chat-observation.js
@@ -743,6 +743,16 @@
if (!whatsappRepairAnchor) whatsappRepairAnchor = { pins, invalidated: false };
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.
+ window.__wb_native_whatsapp_repair_spent = () => {
+ if (!whatsappOwner || !whatsappRepairAnchor) 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));
+ };
window.__wb_native_whatsapp_repair_action = target => {
const pins = window.__wb_get_native_whatsapp_repair();
if (!pins || !target?.isConnected) return false;
@@ -1514,6 +1524,12 @@
: 'Inspect this current chat\'s exact native profile. ')
+ 'Its native username and numeric name/avatar peer must match the current header, composer and live transcript. After opening that profile, call chat_observe again before concluding the binding remains unavailable. A header label or route alone does not establish recipient identity. Do not send or reuse a previous chat while this binding is unavailable.' };
}
+ // The run's one contact check is spent (it needs no composer found
+ // here: the native composer is no longer tied to a checked chat).
+ if (window.__wb_native_whatsapp_repair_spent()) {
+ return { success: false, schema: SCHEMA, reason: 'native_whatsapp_contact_check_spent', retryable: false,
+ error: 'This run can no longer confirm a WhatsApp contact: its contact check belongs to the first chat it looked at, and WhatsApp\'s chat selection or that chat\'s header changed since. Nothing was sent. Report what was sent and that a message to this chat needs a new request; do not retry it in this run.' };
+ }
if (composer && window.__wb_get_native_whatsapp_repair()?.composer === composer) {
const nativeWhatsappRepair = whatsappRepairGuidance();
return {
diff --git a/src/firefox/src/content/content.js b/src/firefox/src/content/content.js
index 4438932c9..51558e2ae 100644
--- a/src/firefox/src/content/content.js
+++ b/src/firefox/src/content/content.js
@@ -67,16 +67,20 @@
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 wall whose number changed since it was read, such as a countdown.
+ // 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.
const shaped = _pageBlockerWallByShape(text);
- if (shaped && PAGE_GATE_TYPES.has(shaped)) return shaped;
+ const provisional = shaped && PAGE_GATE_TYPES.has(shaped) ? shaped : null;
if (!budget.seen.has(text)) {
- if (budget.left <= 0) return null;
+ if (budget.left <= 0) return provisional;
budget.left -= 1;
budget.seen.add(text);
}
_pageReading('page_blocker', text, null, { maxLength: PAGE_GATE_TEXT_LIMIT });
- return null;
+ return provisional;
}
// Whether an element lays its children out as blocks, so its text splits
@@ -5913,8 +5917,9 @@
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, keeps its reading. Only walls carry over
- // this way: a text read as no wall is read again when its numbers change.
+ // 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();
const _PAGE_BLOCKER_WALL_TYPES = new Set(['subscription', 'registration', 'login']);
@@ -6785,10 +6790,16 @@
nativeWhatsappRepair: true, identityCandidates: [] };
}
if (nativeLayoutContext?.service !== 'whatsapp') {
+ // No check left in this run: say so, rather than send the agent
+ // after a header click that cannot help.
+ const spent = !repair && window.__wb_native_whatsapp_repair_spent?.() === true;
return { success: true, messageSend: observationOnly ? false : null, conclusive: false,
composerAvailable: true, nativeWhatsappRepairAvailable: !!repair,
- reasonCode: 'native_whatsapp_contact_binding_required', identityCandidates: [],
- error: 'Native WhatsApp contact identity needs a fresh guarded header click, its contact drawer phone, and closing that same drawer. No message or editor write was authorized.' };
+ ...(spent ? { nativeWhatsappRepairSpent: true } : {}),
+ reasonCode: spent ? 'native_whatsapp_contact_check_spent' : 'native_whatsapp_contact_binding_required', identityCandidates: [],
+ error: spent
+ ? 'This run can no longer confirm a WhatsApp contact: its contact check belongs to the first chat it looked at, and WhatsApp\'s chat selection or that chat\'s header changed since. Nothing was sent. Report what was sent and that a message to this chat needs a new request; do not retry it in this run.'
+ : 'Native WhatsApp contact identity needs a fresh guarded header click, its contact drawer phone, and closing that same drawer. No message or editor write was authorized.' };
}
}
const layoutComposer = layoutCandidate
diff --git a/test/fixtures/run.mjs b/test/fixtures/run.mjs
index bfaaae716..842132a59 100644
--- a/test/fixtures/run.mjs
+++ b/test/fixtures/run.mjs
@@ -1185,37 +1185,69 @@ for (const [label, browserKind] of [['Chrome', 'chrome'], ['Firefox', 'firefox']
// From review: a wall whose number changes on every read, such as a
// countdown, was read as a wall each time but never met that reading
- // again. Its reading now carries over a changed number; a text read as no
- // wall is still read again when its number changes.
- test(`${label}: a wall whose number changes on every read keeps its reading, and a counter read as no wall is read again`, async (page) => {
+ // again. A text that differs from a wall only in its numbers is now that
+ // wall at once and is still read: a quota that stops being a wall when its
+ // number changes reads as what it is once a model has read it. A text read
+ // as no wall is read again when its number changes.
+ test(`${label}: a wall whose number changes stays a wall while its new text is read, and a changed counter is read again`, async (page) => {
const countdown = n => `Okumaya devam etmek için abone olun. Kalan süre: ${n} sn`;
await setupContentHtml(page, `<!doctype html><meta property="og:type" content="article">
<article><h1>Geri sayım</h1><p>SECRET_COUNTDOWN_BODY sunucuda çizilmiştir.</p></article>
<div role="dialog" aria-modal="true" style="position:fixed;inset:0;background:#fff">
<p id="count">${countdown(59)}</p><button>Abone ol</button></div>`, browserKind);
const readings = {};
- const readAll = (action, params = {}) => readGateTextsLikeTheAgent(
- () => call(page, action, { ...params, __wbPageReadings: { page_blocker: readings } }), readings);
- const first = await readAll('get_page_info_cdp');
+ const readOnce = (action, params = {}) => call(page, action, { ...params, __wbPageReadings: { page_blocker: readings } });
+ const first = await readGateTextsLikeTheAgent(() => readOnce('get_page_info_cdp'), readings);
if (first.pageGate?.type !== 'subscription' || /SECRET_COUNTDOWN_BODY/.test(JSON.stringify(first))) {
throw new Error(`countdown wall was not applied: ${JSON.stringify({ pageGate: first.pageGate })}`);
}
for (const n of [58, 9]) {
await page.evaluate(text => { document.querySelector('#count').textContent = text; }, countdown(n));
for (const [action, params] of [['get_page_info_cdp', {}], ['get_accessibility_tree', { filter: 'visible', maxDepth: 6 }]]) {
- const ticked = await call(page, action, { ...params, __wbPageReadings: { page_blocker: readings } });
+ // Before any model reads the new text, the wall already stands.
+ const ticked = await readOnce(action, params);
if (ticked.pageGate?.type !== 'subscription' || /SECRET_COUNTDOWN_BODY/.test(JSON.stringify(ticked))) {
- throw new Error(`${action} at ${n} s: the countdown wall lost its reading: ${JSON.stringify({ pageGate: ticked.pageGate })}`);
+ throw new Error(`${action} at ${n} s: the countdown wall fell before its new text was read: ${JSON.stringify({ pageGate: ticked.pageGate })}`);
}
- if ((ticked.pageTextsNeeded || []).some(entry => /Kalan süre/.test(entry.text))) {
- throw new Error(`${action} at ${n} s: the countdown wall was asked again`);
+ // 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`);
}
if (action === 'get_accessibility_tree' && !/Abone ol/.test(ticked.pageContent || '')) {
throw new Error(`${action} at ${n} s: the wall's own control is gone`);
}
+ const read = await readGateTextsLikeTheAgent(() => readOnce(action, params), readings);
+ if (read.pageGate?.type !== 'subscription' || /SECRET_COUNTDOWN_BODY/.test(JSON.stringify(read))) {
+ throw new Error(`${action} at ${n} s: the read countdown wall fell: ${JSON.stringify({ pageGate: read.pageGate })}`);
+ }
}
}
+ // A quota read as a wall at 0, shown again with another number: a wall
+ // until a model reads the new text, then what that reading says.
+ const quota = n => `Bu ay ${n} ücretsiz makale hakkınız kaldı. Kayıt olun.`;
+ await setupContentHtml(page, `<!doctype html><meta property="og:type" content="article">
+ <article><h1>Kota</h1><p>QUOTA_ARTICLE_BODY bu ay okunabilir.</p></article>
+ <div role="dialog" aria-modal="true" style="position:fixed;inset:0;background:#fff">
+ <p id="count">${quota(3)}</p><button>Kapat</button></div>`, browserKind);
+ const quotaText = (await call(page, 'get_page_info_cdp', {})).pageTextsNeeded
+ ?.find(entry => /ücretsiz makale/.test(entry.text))?.text || '';
+ if (!quotaText) throw new Error('the quota text was not reported');
+ const quotaReadings = { [quotaText.replace('3', '0')]: 'registration' };
+ const provisional = await call(page, 'get_page_info_cdp', { __wbPageReadings: { page_blocker: quotaReadings } });
+ if (provisional.pageGate?.type !== 'registration' || /QUOTA_ARTICLE_BODY/.test(JSON.stringify(provisional))) {
+ throw new Error(`a text like a wall but for its number was not that wall at once: ${JSON.stringify({ pageGate: provisional.pageGate })}`);
+ }
+ if (!(provisional.pageTextsNeeded || []).some(entry => entry.text === quotaText)) {
+ throw new Error('a text taken for a wall by its numbers was not reported to be read');
+ }
+ quotaReadings[quotaText] = 'other';
+ const corrected = await call(page, 'get_page_info_cdp', { __wbPageReadings: { page_blocker: quotaReadings } });
+ 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 })}`);
+ }
+
const counter = n => `Bu ay ${n} ücretsiz makale hakkınız kaldı.`;
await setupContentHtml(page, `<!doctype html><meta property="og:type" content="article">
<article><h1>Sayaç</h1><p>READABLE_COUNTER_BODY herkes okuyabilir.</p></article>
@@ -1507,7 +1539,7 @@ test('Chrome CDP mirror keys a wall text cut at its length limit as the agent do
}
});
-test('Chrome CDP mirror keeps the reading of a wall whose number changes on every read', async (page) => {
+test('Chrome CDP mirror keeps a wall whose number changes a wall while its new text is read', async (page) => {
const countdown = n => `Okumaya devam etmek için abone olun. Kalan süre: ${n} sn`;
await page.setContent(`<!doctype html><meta property="og:type" content="article">
<article><h1>Geri sayım</h1><p>SECRET_COUNTDOWN_BODY sunucuda çizilmiştir.</p></article>
@@ -1523,8 +1555,26 @@ test('Chrome CDP mirror keeps the reading of a wall whose number changes on ever
await page.evaluate(text => { document.querySelector('#count').textContent = text; }, countdown(58));
const ticked = await client.readPage(1, { pageBlockerReadings: readings });
if (ticked.pageGate?.type !== 'subscription' || /SECRET_COUNTDOWN_BODY/.test(JSON.stringify(ticked))
- || (ticked.pageTextsNeeded || []).some(entry => /Kalan süre/.test(entry.text))) {
- throw new Error(`CDP countdown wall lost its reading: ${JSON.stringify({ pageGate: ticked.pageGate, needed: ticked.pageTextsNeeded })}`);
+ || !(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 })}`);
+ }
+ // 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">
+ <article><h1>Kota</h1><p>QUOTA_ARTICLE_BODY bu ay okunabilir.</p></article>
+ <div role="dialog" aria-modal="true" style="position:fixed;inset:0;background:#fff">
+ <p id="count">${quota(3)}</p><button>Kapat</button></div>`);
+ const quotaText = (await client.readPage(1, {})).pageTextsNeeded?.find(entry => /ücretsiz makale/.test(entry.text))?.text || '';
+ const quotaReadings = { [quotaText.replace('3', '0')]: 'registration' };
+ const provisional = await client.readPage(1, { pageBlockerReadings: quotaReadings });
+ if (!quotaText || provisional.pageGate?.type !== 'registration' || /QUOTA_ARTICLE_BODY/.test(JSON.stringify(provisional))
+ || !(provisional.pageTextsNeeded || []).some(entry => entry.text === quotaText)) {
+ throw new Error(`CDP provisional quota wall mismatch: ${JSON.stringify({ pageGate: provisional.pageGate, needed: provisional.pageTextsNeeded })}`);
+ }
+ quotaReadings[quotaText] = 'other';
+ const corrected = await client.readPage(1, { pageBlockerReadings: quotaReadings });
+ if (corrected.pageGate || !/QUOTA_ARTICLE_BODY/.test(JSON.stringify(corrected))) {
+ throw new Error(`CDP quota read as no wall stayed a wall: ${JSON.stringify({ pageGate: corrected.pageGate })}`);
}
// A counter read as no wall is read again when its number changes.
const counter = n => `Bu ay ${n} ücretsiz makale hakkınız kaldı.`;
diff --git a/test/native-whatsapp-contact.mjs b/test/native-whatsapp-contact.mjs
index 62f55646c..d45329c15 100644
--- a/test/native-whatsapp-contact.mjs
+++ b/test/native-whatsapp-contact.mjs
@@ -92,6 +92,40 @@ for (const [build, engine] of [['chrome', chromium], ['firefox', firefox]]) {
});
});
+ // From review: a run's contact check belongs to the first chat it looked
+ // at, so once the chat selection changed the agent was sent after a header
+ // click that could not help, with "re-read and retry". It is told plainly
+ // instead, and the next run can check a contact again.
+ test(`${build}: once the chat selection changed, a run says it can no longer check a contact`, async () => {
+ await fixture(async ({ page, call, observe, ownerFor, setOwner }) => {
+ const before = await observe();
+ assert.equal(before.reason, 'native_whatsapp_contact_binding_required', JSON.stringify(before));
+ assert.ok(before.nativeWhatsappRepair, 'the open chat offers its contact check');
+ const probe = owner => call('probe_message_recipient_guard', { tool: 'observe_active_conversation', args: {},
+ adapterName: 'generic-messaging', _nativeChatOwner: owner });
+ const offered = await probe(ownerFor());
+ assert.equal(offered.nativeWhatsappRepairAvailable, true, JSON.stringify(offered));
+ assert.equal(offered.nativeWhatsappRepairSpent, undefined);
+ await page.evaluate(() => {
+ const selected = document.querySelector('[aria-selected]');
+ selected.setAttribute('aria-selected', 'false'); selected.setAttribute('aria-selected', 'true');
+ });
+ const after = await observe();
+ assert.equal(after.reason, 'native_whatsapp_contact_check_spent', JSON.stringify(after));
+ assert.equal(after.retryable, false);
+ assert.match(after.error, /can no longer confirm a WhatsApp contact[\s\S]*needs a new request/);
+ const spent = await probe(ownerFor());
+ assert.equal(spent.nativeWhatsappRepairSpent, true, JSON.stringify(spent));
+ assert.equal(spent.reasonCode, 'native_whatsapp_contact_check_spent');
+ assert.equal(spent.conclusive, false);
+ // The next run checks a contact again.
+ setOwner(ownerFor('owned-run-2'));
+ const next = await observe();
+ assert.equal(next.reason, 'native_whatsapp_contact_binding_required', JSON.stringify(next));
+ assert.ok(next.nativeWhatsappRepair, 'a new run cannot check a contact');
+ });
+ });
+
test(`${build}: native grouped incoming messages need a continuous explicit sender anchor`, async () => {
await fixture(async ({ page, bind, observe }) => {
await bind();
diff --git a/test/quality/native-chat-mv3.mjs b/test/quality/native-chat-mv3.mjs
index 2042247dc..9a70c8b14 100644
--- a/test/quality/native-chat-mv3.mjs
+++ b/test/quality/native-chat-mv3.mjs
@@ -341,12 +341,22 @@ try {
&& result.chatWorkflow.pendingOutbound === false && !result.chatWorkflow.userInput));
const sendAttempts = actualResults.filter(event => event.data.name === (structuredPath(dispatchPath) ? 'chat_send'
: dispatchPath === 'generic_submit' ? 'set_field' : 'click_ax'));
+ // A send held back because the browser changed during it sends nothing:
+ // these paths run in tabs of one browser, and a tab that closes resizes
+ // the others, which page feedback reports. The model reads the chat again
+ // and sends once more; exactly-once delivery is checked above by the
+ // page's own replies and outgoing bubbles, not by counting attempts.
+ const heldStructuredSend = result => result?.success !== true && result?.deliveryVerified !== true
+ && ((result?.skipped === true && result.noDispatch === true && result.dispatched === false && !result.outcomeUnknown)
+ || (result?.reason === 'native_chat_submit_blocked_before_dispatch' && result.submissionDispatched === false
+ && result.submissionBlockReason === 'page_feedback_pending'));
const feedbackSkips = dispatchPath === 'generic_submit' ? sendAttempts.filter(event => {
const result = event.data.result;
return result.pageFeedbackPending === true && result.noDispatch === true
&& result.dispatched === false && !result.outcomeUnknown;
- }) : [];
- assert.equal(feedbackSkips.length, current.feedbackRecoveries || 0);
+ }) : 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.');
const dispatches = dispatchPath === 'structured_prefill' ? sendAttempts.filter(event => event.data.result.success === true)
: sendAttempts.filter(event => !feedbackSkips.includes(event));
assert.equal(dispatches.length, expectedCount);
@@ -371,7 +381,7 @@ try {
if (structuredPath(dispatchPath)) assert.ok(dispatches.every(event => event.data.result.deliveryVerified === true));
}
if (dispatchPath === 'structured_prefill') {
- assert.equal(sendAttempts.length, 7);
+ assert.equal(sendAttempts.length, 7 + feedbackSkips.length);
assert.equal(sendAttempts[0].data.result.reason, 'composer_not_empty');
assert.equal(sendAttempts[0].data.result.noDispatch, true);
const drafts = actualResults.filter(event => event.data.name === 'set_field');
diff --git a/test/quality/whatsapp-contact-mv3.mjs b/test/quality/whatsapp-contact-mv3.mjs
index 396b3ad1e..9410ae07d 100644
--- a/test/quality/whatsapp-contact-mv3.mjs
+++ b/test/quality/whatsapp-contact-mv3.mjs
@@ -419,7 +419,10 @@ const server = http.createServer(async (request, response) => {
if (scenario === 'peer_switch') {
// Native selection feedback may suppress the prepared send before
// its handler is called; either boundary must retain no dispatch.
- assert.ok(last.result?.noDispatch === true || last.result?.reason === 'chat_root_unverified', last.content);
+ // The run's one contact check is spent once the selection changed,
+ // and the observation before the send says so, final.
+ assert.ok(last.result?.noDispatch === true || last.result?.reason === 'chat_root_unverified'
+ || (last.result?.reason === 'native_whatsapp_contact_check_spent' && last.result?.retryable === false), last.content);
name = 'done'; args = { outcome: 'partial', summary: 'The native contact changed; no reply was dispatched.' };
}
else { assert.notEqual(last.result?.dispatched, false, last.content); stage = 'verified'; name = 'chat_observe'; }
diff --git a/test/run.js b/test/run.js
index e96ede5fb..7a75dd08d 100644
--- a/test/run.js
+++ b/test/run.js
@@ -18578,7 +18578,7 @@ test('a wall whose text changes on every read fails the read instead of returnin
assert.equal(reads, 3, `${build}: the page was not read again with each new wall text`);
assert.equal(result.success, false, `${build}: the article behind a changing wall was returned`);
assert.doesNotMatch(JSON.stringify(result), /SECRET/, `${build}: text behind the wall leaked`);
- assert.match(result.error, /wall that WebBrain could not apply, as when its text changes on every read/);
+ assert.match(result.error, /wall that WebBrain could not apply, as when its text changes on every read[\s\S]*Read the page again once; if the wall is still there, report it/);
// The same wall applied on the last read is returned as the page shows it.
const applied = new AgentClass({});
stubPageTextReadings(applied, (kind, item) => (kind === 'page_blocker'
@@ -109135,6 +109135,21 @@ test('a WhatsApp chat pinned at its first send keeps the person named besides it
const other = await dispatch(2);
assert.equal(other?.reasonCode, 'active_recipient_unverified', `${label}: another chat was sent to without a card`);
assert.deepEqual(other.recipientConfirmation.requested, ['Rustem Bey']);
+ // A chat whose contact this run can no longer check is reported as such,
+ // not as something to re-read and retry.
+ const spentError = 'This run can no longer confirm a WhatsApp contact: its contact check belongs to the first chat it looked at.';
+ probe = { success: true, conclusive: false, messageSend: null, composerAvailable: true, nativeWhatsappRepairAvailable: false,
+ nativeWhatsappRepairSpent: true, reasonCode: 'native_whatsapp_contact_check_spent', identityCandidates: [], error: spentError };
+ const spent = await dispatch(3);
+ assert.equal(spent?.reasonCode, 'native_whatsapp_contact_check_spent', JSON.stringify(spent));
+ assert.equal(spent.retryable, false, `${label}: a spent contact check was offered as retryable`);
+ assert.equal(spent.error, spentError);
+ probe = { success: true, conclusive: false, messageSend: null, composerAvailable: true, nativeWhatsappRepairAvailable: true,
+ reasonCode: 'native_whatsapp_contact_binding_required', identityCandidates: [], error: 'drawer needed' };
+ const needsDrawer = await dispatch(4);
+ assert.equal(needsDrawer?.reasonCode, 'native_whatsapp_contact_binding_required');
+ assert.notEqual(needsDrawer.retryable, false, `${label}: a contact check still available was made final`);
+ assert.match(needsDrawer.error, /could not conclusively resolve/);
}
});
@@ -109188,7 +109203,7 @@ test('a reviewed plan shows the person named besides the open conversation and a
() => { }, null, null, '', { tabUrl: 'https://web.whatsapp.com/', tabTitle: 'WhatsApp' }, 'try', 'act', { locale: 'en' });
const where = `${AgentClass.name} ${edited ? 'edited' : 'unedited'}`;
assert.equal(gate.proceed, true, `${where}: the reviewed plan did not run: ${gate.message || gate.reason}`);
- assert.match(reviewed?.verbose || '', /- Message targets: to:Mehmet\n- Also named, each confirmed on WebBrain's card before the first send to them: to:Rustem Bey/,
+ assert.match(reviewed?.verbose || '', /- Message targets: to:Mehmet\n- Also named, each verified before any send to them: to:Rustem Bey/,
`${where}: the reviewed plan does not show the person named besides the open chat`);
if (edited) {
// An edited plan carries no send target at all, as before.