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
Keep proofread shortcut label concise
Emre Sokullu59345140b89e
diff --git a/src/chrome/src/context-menu-storage.js b/src/chrome/src/context-menu-storage.jsindex 181c86a78..41c01742f 100644--- a/src/chrome/src/context-menu-storage.js+++ b/src/chrome/src/context-menu-storage.js@@ -11,6 +11,13 @@ export const SELECTION_SHORTCUT_ACTIONS = Object.freeze({humanize: 'Rewrite this selected text so it reads as human writing rather than AI output. Keep every claim, the language, and the author\'s intent; return only the rewritten text.',});+// Some fixed actions carry model-only guardrails that should not crowd the+// user-visible chat bubble or history title. Match the complete trusted action+// text so custom prompts that happen to start similarly remain untouched.+const SELECTION_SHORTCUT_DISPLAY_INSTRUCTIONS = Object.freeze({+ proofread: 'Proofread this selected text.',+});+// Selected-text runs carry no tools, so `load_skill` cannot rescue a writing// request mid-run: a prose skill either rides in at run start or never. Keep// this limited to explicit structured writing actions; `custom` is the@@ -168,6 +175,12 @@ export function formatSelectionPromptForDisplay(promptText) {instruction = instruction.slice(CUSTOM_QUESTION_PREFIX.length).trim();} else {instruction = stripResponseLanguageInstruction(instruction);+ for (const [actionId, displayInstruction] of Object.entries(SELECTION_SHORTCUT_DISPLAY_INSTRUCTIONS)) {+ if (instruction === SELECTION_SHORTCUT_ACTIONS[actionId]) {+ instruction = displayInstruction;+ break;+ }+ }if (instruction === GENERIC_CONTEXT_MENU_INSTRUCTION) instruction = '';}diff --git a/src/firefox/src/context-menu-storage.js b/src/firefox/src/context-menu-storage.jsindex ad2e69195..022304e43 100644--- a/src/firefox/src/context-menu-storage.js+++ b/src/firefox/src/context-menu-storage.js@@ -11,6 +11,13 @@ export const SELECTION_SHORTCUT_ACTIONS = Object.freeze({humanize: 'Rewrite this selected text so it reads as human writing rather than AI output. Keep every claim, the language, and the author\'s intent; return only the rewritten text.',});+// Some fixed actions carry model-only guardrails that should not crowd the+// user-visible chat bubble or history title. Match the complete trusted action+// text so custom prompts that happen to start similarly remain untouched.+const SELECTION_SHORTCUT_DISPLAY_INSTRUCTIONS = Object.freeze({+ proofread: 'Proofread this selected text.',+});+// Selected-text runs carry no tools, so `load_skill` cannot rescue a writing// request mid-run: a prose skill either rides in at run start or never. Keep// this limited to explicit structured writing actions; `custom` is the@@ -168,6 +175,12 @@ export function formatSelectionPromptForDisplay(promptText) {instruction = instruction.slice(CUSTOM_QUESTION_PREFIX.length).trim();} else {instruction = stripResponseLanguageInstruction(instruction);+ for (const [actionId, displayInstruction] of Object.entries(SELECTION_SHORTCUT_DISPLAY_INSTRUCTIONS)) {+ if (instruction === SELECTION_SHORTCUT_ACTIONS[actionId]) {+ instruction = displayInstruction;+ break;+ }+ }if (instruction === GENERIC_CONTEXT_MENU_INSTRUCTION) instruction = '';}diff --git a/test/run.js b/test/run.jsindex 03bb1228e..d75dc4884 100644--- a/test/run.js+++ b/test/run.js@@ -51503,6 +51503,24 @@ test('selection prompt display formatter hides untrusted wrappers from the chat`${label}: fixed actions should keep their instruction and show the selection cleanly`,);+ const proofread = buildSelectionPrompt('A visibly cut wor', 'proofread');+ const proofreadDisplay = formatSelectionPromptForDisplay(proofread);+ assert.equal(+ proofreadDisplay,+ 'Proofread this selected text.\n\nSelected text:\nA visibly cut wor',+ `${label}: proofread should keep its guardrails model-facing and use a concise display label`,+ );+ assert.doesNotMatch(proofreadDisplay, /Never infer|visibly cut mid-word|exact selected wording/, `${label}: proofread display must hide model-only guardrails`);+ assert.ok(proofreadDisplay.indexOf('A visibly cut wor') < 140, `${label}: proofread history titles should reach the selected text before truncation`);+ assert.match(proofread, /Never infer or reconstruct text beyond its boundaries/, `${label}: model prompt must retain the proofread guardrails`);++ const localizedProofread = buildSelectionPrompt('需要校对的文本', 'proofread', '', 'zh');+ assert.equal(+ formatSelectionPromptForDisplay(localizedProofread),+ 'Proofread this selected text.\n\nSelected text:\n需要校对的文本',+ `${label}: localized proofread prompts should use the same concise display label`,+ );+const generic = buildContextMenuPrompt('native fallback');assert.equal(formatSelectionPromptForDisplay(generic),