Skip to content

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

Count duplicate timestamp text as rendered

Claude706c5dbfc07f
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index 8a00ad3f7..b52a65763 100644
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@ -33956,7 +33956,10 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
const owner = part.parentElement;
if (owner && (typeof owner.checkVisibility !== 'function' || owner.checkVisibility({ visibilityProperty: true }))) between += part.data;
}
- for (let from = between.indexOf(shown); from >= 0; from = between.indexOf(shown, from + shown.length)) skip += 1;
+ // Compared as rendered: case and white-space as styled are folded on both sides.
+ const fold = value => value.replace(/\s+/g, ' ').toLowerCase();
+ const needle = fold(shown), haystack = fold(between);
+ for (let from = needle ? haystack.indexOf(needle) : -1; from >= 0; from = haystack.indexOf(needle, from + needle.length)) skip += 1;
} catch { skip = 0; }
}
previous = time;
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index ed61d1f39..b762ebf8b 100644
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@ -30824,7 +30824,10 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
const owner = part.parentElement;
if (owner && (typeof owner.checkVisibility !== 'function' || owner.checkVisibility({ visibilityProperty: true }))) between += part.data;
}
- for (let from = between.indexOf(shown); from >= 0; from = between.indexOf(shown, from + shown.length)) skip += 1;
+ // Compared as rendered: case and white-space as styled are folded on both sides.
+ const fold = value => value.replace(/\s+/g, ' ').toLowerCase();
+ const needle = fold(shown), haystack = fold(between);
+ for (let from = needle ? haystack.indexOf(needle) : -1; from >= 0; from = haystack.indexOf(needle, from + needle.length)) skip += 1;
} catch { skip = 0; }
}
previous = time;
diff --git a/test/native-resource-deletion-binding.mjs b/test/native-resource-deletion-binding.mjs
index 3e64c0978..17bc7dafc 100644
--- a/test/native-resource-deletion-binding.mjs
+++ b/test/native-resource-deletion-binding.mjs
@@ -388,6 +388,25 @@ for (const build of ['chrome', 'firefox']) {
} finally { await f.page.close(); }
});
+ await t.test('text that only renders like the relative time does not take the timestamp\'s place', 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
+ = '<span style="text-transform:uppercase">back in 8 dk</span> <time style="text-transform:uppercase" datetime="2026-10-18T19:22:00.000Z" title="18 Eki 2026 22:22">8 dk</time>';
+ });
+ await f.showConfirmation();
+ const detected = await f.probe('#confirm');
+ const key = found => agent._resourceMutationActionKey(1, 'click', { selector: '#confirm' }, found);
+ await f.page.evaluate(() => { document.querySelector('#record-200 .status__relative-time time').textContent = '9 dk'; });
+ assert.equal(key(await f.probe('#confirm')), key(detected), 'Only the timestamp ticked');
+ } finally { await f.page.close(); }
+ });
+
await t.test('hidden text equal to the relative time does not hide the timestamp from the key', async () => {
const f = await fixture();
try {