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
fix(selection): preserve proofread whitespace
Emre Sokulluac9b0e983098
diff --git a/src/chrome/src/content/selection-shortcut.js b/src/chrome/src/content/selection-shortcut.jsindex 7a8793b70..fbc02c36d 100644--- a/src/chrome/src/content/selection-shortcut.js+++ b/src/chrome/src/content/selection-shortcut.js@@ -933,7 +933,7 @@parts.cut.hidden = !((status === 'ready' || cutOffOnly) && cardState.truncated);parts.notice.hidden = !(status !== 'loading' && cardState.notice);parts.notice.textContent = status !== 'loading' ? cardState.notice : '';- if (status === 'ready') renderAnswer(parts.text, cardState.text, kind !== 'translate');+ if (status === 'ready') renderAnswer(parts.text, cardState.text, kind === 'explain');if (status === 'error') {parts.errorText.textContent = str('inlineFailed');parts.errorDetail.textContent = cardState.error;diff --git a/src/firefox/src/content/selection-shortcut.js b/src/firefox/src/content/selection-shortcut.jsindex 638970293..117359b46 100644--- a/src/firefox/src/content/selection-shortcut.js+++ b/src/firefox/src/content/selection-shortcut.js@@ -933,7 +933,7 @@parts.cut.hidden = !((status === 'ready' || cutOffOnly) && cardState.truncated);parts.notice.hidden = !(status !== 'loading' && cardState.notice);parts.notice.textContent = status !== 'loading' ? cardState.notice : '';- if (status === 'ready') renderAnswer(parts.text, cardState.text, kind !== 'translate');+ if (status === 'ready') renderAnswer(parts.text, cardState.text, kind === 'explain');if (status === 'error') {parts.errorText.textContent = str('inlineFailed');parts.errorDetail.textContent = cardState.error;diff --git a/test/fixtures/run.mjs b/test/fixtures/run.mjsindex bf6794964..704c09070 100644--- a/test/fixtures/run.mjs+++ b/test/fixtures/run.mjs@@ -2205,6 +2205,19 @@ for (const [label, sourcePath, manualOpen] of [}});+ test(`${label}: Proofread preserves whitespace-sensitive corrections`, async (page) => {+ await setupSelectionShortcut(page, sourcePath, { requiresManualOpen: manualOpen });+ const correction = 'def example():\n return {\n "answer": 42,\n }';+ await page.evaluate((text) => {+ window.__selectionInlineHandler = async () => ({ ok: true, text });+ }, correction);+ await openInlineCard(page, 'proofread');+ const state = await waitForCardStatus(page, 'ready');+ if (state.cardText !== correction) {+ throw new Error(`Proofread should preserve its whitespace: ${JSON.stringify(state.cardText)}`);+ }+ });+test(`${label}: a failed card answer offers a retry, and a follow-up waits for an answer`, async (page) => {await setupSelectionShortcut(page, sourcePath, { requiresManualOpen: manualOpen });await page.evaluate(() => {