From 0515e57c60cfb18ee136ab4e74de185abbcdc725 Mon Sep 17 00:00:00 2001 From: Jinjing <6427696+AmethystLiang@users.noreply.github.com> Date: Thu, 30 Jul 2026 21:05:13 -0700 Subject: [PATCH] fix(browser): clear grab mode operation queue on teardown (#11679) A pending grab mode chain could outlive its guest: registerBrowserHandlers() and browser:unregisterGuest cleared grabModeIntentByPageId but left grabModeOperationByPageId intact. An in-flight executeJavaScript against a destroyed guest would then block every later operation queued behind it for that page, including after a workspace restart or browserPageId reuse. Addresses review feedback on #11661. Co-authored-by: Claude Opus 5 --- src/main/ipc/browser.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/ipc/browser.ts b/src/main/ipc/browser.ts index 246e821a25a..fb67b002234 100644 --- a/src/main/ipc/browser.ts +++ b/src/main/ipc/browser.ts @@ -194,6 +194,8 @@ function isTrustedBrowserRenderer(sender: Electron.WebContents): boolean { export function registerBrowserHandlers(): void { grabModeIntentByPageId.clear() + // Why: a stale in-flight chain from a prior registration would block new operations forever. + grabModeOperationByPageId.clear() ipcMain.removeHandler('browser:registerGuest') ipcMain.removeHandler('browser:unregisterGuest') ipcMain.removeHandler('browser:openDevTools') @@ -264,6 +266,8 @@ export function registerBrowserHandlers(): void { } browserManager.unregisterGuest(args.browserPageId) grabModeIntentByPageId.delete(args.browserPageId) + // Why: don't let a reused browserPageId queue behind the destroyed guest's pending chain. + grabModeOperationByPageId.delete(args.browserPageId) return true })