Skip to content

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

Harden selected-text proofreading boundaries

Emre Sokullu9da12132e508
diff --git a/src/chrome/src/context-menu-storage.js b/src/chrome/src/context-menu-storage.js
index 395c1fe96..181c86a78 100644
--- a/src/chrome/src/context-menu-storage.js
+++ b/src/chrome/src/context-menu-storage.js
@@ -7,7 +7,7 @@ export const SELECTION_SHORTCUT_ACTIONS = Object.freeze({
summarize: 'Summarize this selected text clearly and concisely.',
explain: 'Explain this selected text in plain language.',
quiz: 'Quiz me on this selected text. Ask one question at a time and wait for my answer.',
- proofread: 'Proofread this selected text. Identify errors and provide a corrected version while preserving its meaning and tone.',
+ proofread: 'Proofread this selected text. First verify that the selection is complete enough to edit. Never infer or reconstruct text beyond its boundaries. If an edge is visibly cut mid-word or the passage is otherwise clearly incomplete, say so and ask the user to select the complete passage instead of supplying a corrected version. For a complete selection, tie every claimed error to exact selected wording, distinguish actual errors from optional style suggestions, and provide one complete corrected version that fixes every listed error without unrelated additions.',
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.',
});
diff --git a/src/firefox/src/context-menu-storage.js b/src/firefox/src/context-menu-storage.js
index 8af96f570..ad2e69195 100644
--- a/src/firefox/src/context-menu-storage.js
+++ b/src/firefox/src/context-menu-storage.js
@@ -7,7 +7,7 @@ export const SELECTION_SHORTCUT_ACTIONS = Object.freeze({
summarize: 'Summarize this selected text clearly and concisely.',
explain: 'Explain this selected text in plain language.',
quiz: 'Quiz me on this selected text. Ask one question at a time and wait for my answer.',
- proofread: 'Proofread this selected text. Identify errors and provide a corrected version while preserving its meaning and tone.',
+ proofread: 'Proofread this selected text. First verify that the selection is complete enough to edit. Never infer or reconstruct text beyond its boundaries. If an edge is visibly cut mid-word or the passage is otherwise clearly incomplete, say so and ask the user to select the complete passage instead of supplying a corrected version. For a complete selection, tie every claimed error to exact selected wording, distinguish actual errors from optional style suggestions, and provide one complete corrected version that fixes every listed error without unrelated additions.',
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.',
});
diff --git a/test/run.js b/test/run.js
index f72d0c637..03bb1228e 100644
--- a/test/run.js
+++ b/test/run.js
@@ -50102,6 +50102,13 @@ test('selection shortcut builds allowlisted prompts with an untrusted selection
assert.match(prompt, /<untrusted_page_content id="ctx-[^"]+">\nselected page words\n<\/untrusted_page_content>/, `${label}: ${action} should wrap only the page selection`);
}
+ const proofread = buildSelectionPrompt('A visibly cut wor', 'proofread');
+ assert.match(proofread, /Never infer or reconstruct text beyond its boundaries/, `${label}: proofreading may not invent missing source text`);
+ assert.match(proofread, /visibly cut mid-word/, `${label}: proofreading should detect an incomplete selection edge`);
+ assert.match(proofread, /tie every claimed error to exact selected wording/, `${label}: proofreading critiques must stay source-grounded`);
+ assert.match(proofread, /distinguish actual errors from optional style suggestions/, `${label}: proofreading should not present preferences as errors`);
+ assert.match(proofread, /one complete corrected version that fixes every listed error without unrelated additions/, `${label}: proofreading should reconcile its own issue list and avoid stale output`);
+
const localizedPreset = buildSelectionPrompt('这里有 Electron 和 Tauri', 'explain', '', 'zh');
assert.match(localizedPreset, /^Explain this selected text in plain language\. Respond in Chinese\./, `${label}: fixed selection actions should request the interface language`);
assert.match(localizedPreset, /This English template does not set the reply language/, `${label}: English explain/quiz templates should not override the interface language`);