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 <noreply@anthropic.com>
This commit is contained in:
Jinjing
2026-07-30 21:05:13 -07:00
committed by GitHub
co-authored by Claude Opus 5
parent aeda3c6e32
commit 0515e57c60
+4
View File
@@ -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
})