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
Do not read the text inside a stabilized <time datetime> element as the post's identity
Claude5685697db667
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.jsindex 50cba94b7..770393993 100644--- a/src/chrome/src/agent/agent.js+++ b/src/chrome/src/agent/agent.js@@ -33936,7 +33936,11 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d}return text;};- const stableTexts = nodes => [...new Set(nodes.map(stableText).filter(value => value.length <= 25000))];+ // A node inside a <time datetime> is part of the timestamp that node already+ // stands for, so it adds no text of its own (<time><span>8 min</span></time>).+ const stableTexts = nodes => [...new Set(nodes+ .filter(node => !node.parentElement?.closest('time[datetime]'))+ .map(stableText).filter(value => value.length <= 25000))];const nativeResourceProofs = () => {if (args.__wbNativeResourceAdapter !== 'mastodon') return [];const signedIn = nativeSignedInAccount();diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.jsindex 5aaf74b87..febd6b348 100644--- a/src/firefox/src/agent/agent.js+++ b/src/firefox/src/agent/agent.js@@ -30804,7 +30804,11 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d}return text;};- const stableTexts = nodes => [...new Set(nodes.map(stableText).filter(value => value.length <= 25000))];+ // A node inside a <time datetime> is part of the timestamp that node already+ // stands for, so it adds no text of its own (<time><span>8 min</span></time>).+ const stableTexts = nodes => [...new Set(nodes+ .filter(node => !node.parentElement?.closest('time[datetime]'))+ .map(stableText).filter(value => value.length <= 25000))];const nativeResourceProofs = () => {if (args.__wbNativeResourceAdapter !== 'mastodon') return [];const signedIn = nativeSignedInAccount();diff --git a/test/native-resource-deletion-binding.mjs b/test/native-resource-deletion-binding.mjsindex 2f99c7ba5..0ffead0ab 100644--- a/test/native-resource-deletion-binding.mjs+++ b/test/native-resource-deletion-binding.mjs@@ -341,6 +341,42 @@ for (const build of ['chrome', 'firefox']) {} finally { await f.page.close(); }});+ await t.test('a relative time with nested markup ticking over keeps the same post', async () => {+ const f = await fixture();+ try {+ const request = `Delete only ${resource}.`;+ const provider = { chat() {} }, agent = new Agent({ getActive: () => provider });+ agent.conversations.set(1, [{ role: 'system', content: 'system' }, { role: 'user', content: request }]);+ agent._startPlanExecutionGuard(1, 'act', { requestKind: 'execute', requiresStateChange: true, requiresSubmission: true });+ await f.page.evaluate(() => {+ document.querySelector('#record-200 .status__relative-time').innerHTML+ = '<time datetime="2026-10-18T19:22:00.000Z" title="18 Eki 2026 22:22"><span>8 dk</span></time>';+ });+ await f.showConfirmation();+ const detected = await f.probe('#confirm');+ assert.equal(detected.actionResource.url, resource);+ const tick = text => f.page.evaluate(value => {+ document.querySelector('#record-200 .status__relative-time time span').textContent = value;+ }, text);+ let probes = 0;+ agent._detectLikelySubmitAction = async () => { await tick(`${9 + probes++} dk`); return f.probe('#confirm'); };+ installModelStub(agent);+ const result = await agent._resourceMutationPreSubmitBlock(1, 'click', { selector: '#confirm' }, detected, provider);+ assert.equal(result?.actionGuard?.reason || null, null, JSON.stringify(result?.actionGuard));+ assert.ok(probes >= 1, 'The post was probed again after it ticked over');+ assert.equal(await f.page.evaluate(() => qaDeletes), 0, 'Preflight never dispatches deletion.');+ // What the post says, and the moment it was posted, still bind it.+ const key = found => agent._resourceMutationActionKey(1, 'click', { selector: '#confirm' }, found);+ await f.page.evaluate(() => { document.querySelector('#record-200 .status__content__text--visible p').textContent = 'Edited post'; });+ assert.notEqual(key(await f.probe('#confirm')), key(detected), 'Edited text is another post');+ await f.page.evaluate(() => {+ document.querySelector('#record-200 .status__content__text--visible p').textContent = 'Exact owned post 200';+ document.querySelector('#record-200 .status__relative-time time').setAttribute('datetime', '2026-10-18T18:00:00.000Z');+ });+ assert.notEqual(key(await f.probe('#confirm')), key(detected), 'Another moment is another post');+ } finally { await f.page.close(); }+ });+for (const variant of ['stable-confirmation', 'stable-direct', 'flip-before-authorization', 'flip-during-authorization']) {await t.test(`${variant} is revalidated by production mutation preflight`, async () => {const f = await fixture();