Skip to content

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

fix: allow visible format characters in clarify options

Emre Sokullud3e6c3bd3a64
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index da53a4bd5..08b308262 100644
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@ -33853,8 +33853,7 @@ If the user has already named or confirmed this exact recipient, do NOT ask agai
}
const rawOptions = Array.isArray(args?.options) ? args.options.slice(0, 4) : [];
const normalizedOptions = rawOptions.map(s => String(s).trim().slice(0, 200));
- const hasVisibleOptionContent = option => /[\p{L}\p{N}\p{P}\p{S}]/u.test(option)
- && !/[\p{Cf}\u2800]/u.test(option);
+ const hasVisibleOptionContent = option => /[\p{L}\p{N}\p{P}\p{S}]/u.test(option.replace(/[\p{Cf}\u2800]/gu, ''));
const options = normalizedOptions.every(hasVisibleOptionContent)
? normalizedOptions
: [];
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index c5e1c0c81..680a87b93 100644
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@ -30562,8 +30562,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
}
const rawOptions = Array.isArray(args?.options) ? args.options.slice(0, 4) : [];
const normalizedOptions = rawOptions.map(s => String(s).trim().slice(0, 200));
- const hasVisibleOptionContent = option => /[\p{L}\p{N}\p{P}\p{S}]/u.test(option)
- && !/[\p{Cf}\u2800]/u.test(option);
+ const hasVisibleOptionContent = option => /[\p{L}\p{N}\p{P}\p{S}]/u.test(option.replace(/[\p{Cf}\u2800]/gu, ''));
const options = normalizedOptions.every(hasVisibleOptionContent)
? normalizedOptions
: [];
diff --git a/test/run.js b/test/run.js
index 3ddac4fe7..05832e149 100644
--- a/test/run.js
+++ b/test/run.js
@@ -48831,6 +48831,17 @@ test('clarify result distinguishes waited timeout from user and Instant authoriz
);
assert.equal(brailleBlankOptionTimeout.authorized, false, `${AgentClass.name}: braille blank safe_first option was accepted`);
+ await agent._recordClarificationAuthorization(tabId, 'user');
+ const emojiOptionTimeout = await agent.executeTool(
+ tabId,
+ 'clarify',
+ { question: 'Continue?', options: ['πŸ‘©β€πŸ’» Continue', 'Stop'], safe_first: true },
+ (type, data) => {
+ if (type === 'clarify') agent.submitClarifyResponse(tabId, data.clarifyId, 'πŸ‘©β€πŸ’» Continue', 'timeout');
+ },
+ );
+ assert.equal(emojiOptionTimeout.authorized, true, `${AgentClass.name}: visible ZWJ emoji safe_first option was rejected`);
+
await agent._recordClarificationAuthorization(tabId, 'user');
const promotedOptionTimeout = await agent.executeTool(
tabId,