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(agent): authorize navigation dialog Leave decision for go_back and go_forward
Emre Sokullue031defe23e2
diff --git a/docs/architecture.md b/docs/architecture.mdindex a342aedaf..355f44a95 100644--- a/docs/architecture.md+++ b/docs/architecture.md@@ -822,10 +822,10 @@ so a running task or an input command in flight never grants permission toaccept a confirmation. Cached dialogs from idle time are also dismissed.A `beforeunload` warning chooses Leave only for a one-use navigation permission-created immediately before the navigation tool dispatches, after its existing-permission and unsaved-change checks. The warning must come from the same-top-level source URL. The permission expires on the first accepted warning,-navigation completion/failure, cancellation, or after ten seconds. Other+created immediately before the navigate, go_back, or go_forward tool dispatches,+after its existing permission and unsaved-change checks. The warning must come+from the same top-level source URL. The permission expires on the first accepted+warning, navigation completion/failure, cancellation, or after ten seconds. Othernavigation warnings choose Stay. Dialog text is never treated as instructions.The handler runs independently of blocked page commands and is removed ondiff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.jsindex a2ee1b033..083eb2cb9 100644--- a/src/chrome/src/agent/agent.js+++ b/src/chrome/src/agent/agent.js@@ -33561,6 +33561,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d// SPAs may push several entries with an identical URL and keep their// route solely in history.state. Listen before dispatch so those entries// can be verified by the browser's navigation events.+ let releaseDialogNavigation = () => {};let navigationTerminalResult = null;let resolveNavigationTerminal;let navigationLoadingObserved = false;@@ -33568,6 +33569,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dconst navigationTerminal = new Promise(resolve => { resolveNavigationTerminal = resolve; });const finishNavigationTerminal = (result) => {if (navigationTerminalResult) return;+ releaseDialogNavigation();navigationTerminalResult = result;resolveNavigationTerminal(result);};@@ -33606,6 +33608,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dif (changeInfo.status === 'loading') navigationLoadingObserved = true;});const removeNavigationListeners = () => {+ releaseDialogNavigation();for (const [event, listener] of listenerRecords.splice(0)) {try { event.removeListener(listener); } catch {}}@@ -33621,6 +33624,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dconst delta = direction === 'back' ? -steps : steps;historyDispatchArmed = true;dispatched = true;+ releaseDialogNavigation = cdpClient.authorizeNavigationDialog(tabId, beforeUrl, earlyCdpAbortSignal);const results = await chrome.scripting.executeScript({target: { tabId },args: [delta],