From fc15d234d6091d2c8232354704f47ae080a7085b Mon Sep 17 00:00:00 2001 From: Kelvin Amoaba <97001695+AmoabaKelvin@users.noreply.github.com> Date: Wed, 11 Nov 2026 23:43:04 +0000 Subject: [PATCH] perf(browser): skip picker blocking for actions without user activation --- .../command-queue/agent-browser-bridge-queue.ts | 4 ++-- .../command-queue/agent-browser-queued-command.ts | 2 +- .../commands/agent-browser-bridge-core-commands.ts | 2 +- .../commands/agent-browser-bridge-input-commands.ts | 4 ++-- .../commands/agent-browser-bridge-interaction-commands.ts | 2 +- .../commands/agent-browser-bridge-page-commands.ts | 6 +++--- .../commands/agent-browser-bridge-pointer-commands.ts | 4 ++-- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/browser/agent-browser/command-queue/agent-browser-bridge-queue.ts b/src/main/browser/agent-browser/command-queue/agent-browser-bridge-queue.ts index af816d6d81d..acd319bfb4a 100644 --- a/src/main/browser/agent-browser/command-queue/agent-browser-bridge-queue.ts +++ b/src/main/browser/agent-browser/command-queue/agent-browser-bridge-queue.ts @@ -76,8 +76,8 @@ export abstract class AgentBrowserBridgeQueue extends AgentBrowserBridgeActionEf }) } - /** Navigation delivers no user activation, so it opens no file picker to block. */ - protected enqueueNavigation( + /** Navigation, pointer moves, wheel and scrolling deliver no user activation, so they open no file picker to block. */ + protected enqueueInertAction( worktreeId: string | undefined, browserPageId: string | undefined, execute: (sessionName: string, target: ResolvedBrowserCommandTarget) => Promise, diff --git a/src/main/browser/agent-browser/command-queue/agent-browser-queued-command.ts b/src/main/browser/agent-browser/command-queue/agent-browser-queued-command.ts index 2d22a5d3052..6d1ca18a4b7 100644 --- a/src/main/browser/agent-browser/command-queue/agent-browser-queued-command.ts +++ b/src/main/browser/agent-browser/command-queue/agent-browser-queued-command.ts @@ -8,7 +8,7 @@ export type EnqueueTargetedCommandOptions = { ensureSession?: boolean /** Page actions report what they caused when an agent runs them. */ reportEffects?: boolean - // Upload catches the picker itself; navigation delivers no user activation, so it opens none. + // Upload catches the picker itself; actions without user activation cannot open one. skipFileChooserBlock?: boolean // Text mutations must not fall back to a global tab from another worktree. requireScopedTarget?: boolean diff --git a/src/main/browser/agent-browser/commands/agent-browser-bridge-core-commands.ts b/src/main/browser/agent-browser/commands/agent-browser-bridge-core-commands.ts index 5b0e7437f4f..8a7976f7b08 100644 --- a/src/main/browser/agent-browser/commands/agent-browser-bridge-core-commands.ts +++ b/src/main/browser/agent-browser/commands/agent-browser-bridge-core-commands.ts @@ -88,7 +88,7 @@ export abstract class AgentBrowserBridgeCoreCommands extends AgentBrowserBridgeQ browserPageId?: string, options: { reportEffects?: boolean } = {} ): Promise { - return this.enqueueNavigation( + return this.enqueueInertAction( worktreeId, browserPageId, async (_sessionName, target) => { diff --git a/src/main/browser/agent-browser/commands/agent-browser-bridge-input-commands.ts b/src/main/browser/agent-browser/commands/agent-browser-bridge-input-commands.ts index 6e48368c0f5..f275ccc1440 100644 --- a/src/main/browser/agent-browser/commands/agent-browser-bridge-input-commands.ts +++ b/src/main/browser/agent-browser/commands/agent-browser-bridge-input-commands.ts @@ -42,7 +42,7 @@ export abstract class AgentBrowserBridgeInputCommands extends AgentBrowserBridge worktreeId?: string, browserPageId?: string ): Promise { - return this.enqueuePageAction(worktreeId, browserPageId, async (sessionName) => { + return this.enqueueInertAction(worktreeId, browserPageId, async (sessionName) => { const args = ['scroll', direction] if (amount != null) { args.push(String(amount)) @@ -56,7 +56,7 @@ export abstract class AgentBrowserBridgeInputCommands extends AgentBrowserBridge worktreeId?: string, browserPageId?: string ): Promise { - return this.enqueuePageAction( + return this.enqueueInertAction( worktreeId, browserPageId, async (sessionName) => { diff --git a/src/main/browser/agent-browser/commands/agent-browser-bridge-interaction-commands.ts b/src/main/browser/agent-browser/commands/agent-browser-bridge-interaction-commands.ts index 692e8b7a432..6dd604ab103 100644 --- a/src/main/browser/agent-browser/commands/agent-browser-bridge-interaction-commands.ts +++ b/src/main/browser/agent-browser/commands/agent-browser-bridge-interaction-commands.ts @@ -35,7 +35,7 @@ export abstract class AgentBrowserBridgeInteractionCommands extends AgentBrowser worktreeId?: string, browserPageId?: string ): Promise { - return this.enqueuePageAction( + return this.enqueueInertAction( worktreeId, browserPageId, async (sessionName) => { diff --git a/src/main/browser/agent-browser/commands/agent-browser-bridge-page-commands.ts b/src/main/browser/agent-browser/commands/agent-browser-bridge-page-commands.ts index b43a448b5b3..788a5406d7f 100644 --- a/src/main/browser/agent-browser/commands/agent-browser-bridge-page-commands.ts +++ b/src/main/browser/agent-browser/commands/agent-browser-bridge-page-commands.ts @@ -214,20 +214,20 @@ export abstract class AgentBrowserBridgeUtilityCommands extends AgentBrowserBrid } async back(worktreeId?: string, browserPageId?: string): Promise { - return this.enqueueNavigation(worktreeId, browserPageId, async (sessionName) => { + return this.enqueueInertAction(worktreeId, browserPageId, async (sessionName) => { return (await this.execAgentBrowser(sessionName, ['back'])) as BrowserBackResult }) } async forward(worktreeId?: string, browserPageId?: string): Promise { - return this.enqueueNavigation(worktreeId, browserPageId, async (sessionName) => { + return this.enqueueInertAction(worktreeId, browserPageId, async (sessionName) => { return (await this.execAgentBrowser(sessionName, ['forward'])) as BrowserBackResult }) } async reload(worktreeId?: string, browserPageId?: string): Promise { // Reload directly because a process swap can destroy the helper session mid-command. - return this.enqueueNavigation(worktreeId, browserPageId, async (_sessionName, target) => { + return this.enqueueInertAction(worktreeId, browserPageId, async (_sessionName, target) => { const wc = this.getWebContents(target.webContentsId) if (!wc) { throw new BrowserError('browser_no_tab', 'Tab is no longer available') diff --git a/src/main/browser/agent-browser/commands/agent-browser-bridge-pointer-commands.ts b/src/main/browser/agent-browser/commands/agent-browser-bridge-pointer-commands.ts index 1650b6f8baa..eb5ec4e5d36 100644 --- a/src/main/browser/agent-browser/commands/agent-browser-bridge-pointer-commands.ts +++ b/src/main/browser/agent-browser/commands/agent-browser-bridge-pointer-commands.ts @@ -111,7 +111,7 @@ export abstract class AgentBrowserBridgePointerCommands extends AgentBrowserBrid worktreeId?: string, browserPageId?: string ): Promise { - return this.enqueuePageAction( + return this.enqueueInertAction( worktreeId, browserPageId, async (sessionName, target) => @@ -191,7 +191,7 @@ export abstract class AgentBrowserBridgePointerCommands extends AgentBrowserBrid worktreeId?: string, browserPageId?: string ): Promise { - return this.enqueuePageAction( + return this.enqueueInertAction( worktreeId, browserPageId, async (sessionName, target) =>