fix: open browser popup links in managed tabs

Links requesting a new window were silently blocked. Open them in managed browser tabs with the existing session restrictions, clean up script-closed tabs, and follow click-created tabs in subsequent direct and MCP browser tools.

Validation: 232 targeted tests and Windows Electron E2E passed; typecheck and lint passed. The full suite retains six failures outside the popup path.

Release note: Browser links that open a new page now open in a managed tab, and AI browser actions follow the new page after a click.
This commit is contained in:
mesalogo
2026-09-15 23:55:52 +08:00
parent 625182c3dc
commit f1d7197480
11 changed files with 450 additions and 20 deletions
+9
View File
@@ -1712,6 +1712,15 @@ export class KnowledgeMcpGateway {
browserSignal
)
browserSignal.throwIfAborted()
const openedTabId = browserTools.getBoundTabId()
if (openedTabId !== lease.tabId && capability.browserUsageLease === lease) {
const replacement = this.browserService!.acquireTabUsage(
capability.browserConversationId!, openedTabId, capability.requestId
)
capability.browserTabId = openedTabId
capability.browserUsageLease = replacement
lease.release()
}
return {
content: result.parts.map((part) =>
part.type === 'text'