Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(browser): navigating an explicit targetId that no longer resolves is an error
Dashe00567f20206
diff --git a/apps/desktop/src/main/mcp-integrations/browser-backend/__tests__/user-browser-backend.test.ts b/apps/desktop/src/main/mcp-integrations/browser-backend/__tests__/user-browser-backend.test.tsindex c31940be09..b387de3b32 100644--- a/apps/desktop/src/main/mcp-integrations/browser-backend/__tests__/user-browser-backend.test.ts+++ b/apps/desktop/src/main/mcp-integrations/browser-backend/__tests__/user-browser-backend.test.ts@@ -669,6 +669,19 @@ describe('UserBrowserBackend · 读取与动作', () => {}});+ // Review 2026-10-30 (Codex P2): navigating an explicit targetId that no longer resolves must fail.+ it('navigate 的显式 targetId 解析不了时报错,不新开页面', async () => {+ const fake = fakeControl({ version: '0.4.56', tabs: { 'client-aaaaaaaa': [{ id: 1, url: 'https://a.test/' }] } });+ const b = backend(fake.control);+ await call(b, { action: 'tabs' });+ const jobsBefore = fake.jobs.length;+ expect(await call(b, { action: 'navigate', targetId: 'gone-tab', url: 'https://b.test/' })).toMatchObject({+ ok: false,+ message: expect.stringContaining('已不存在'),+ });+ expect(fake.jobs.length).toBe(jobsBefore);+ });+// Review 2026-10-30 (Codex P1): an abbreviated profile that matches two connections must not pick one.it('缩写的 profile 匹配多个连接时拒绝,精确 id 优先', async () => {const fake = fakeControl({diff --git a/apps/desktop/src/main/mcp-integrations/browser-backend/user-browser-backend.ts b/apps/desktop/src/main/mcp-integrations/browser-backend/user-browser-backend.tsindex d209f54575..162f3c8c80 100644--- a/apps/desktop/src/main/mcp-integrations/browser-backend/user-browser-backend.ts+++ b/apps/desktop/src/main/mcp-integrations/browser-backend/user-browser-backend.ts@@ -797,6 +797,14 @@ export class UserBrowserBackend implements BrowserBackend {: undefined;if (!url) return actionFailed(req.action, 'url required', 'BROWSER_RUNTIME_INVALID_REQUEST');const existing = req.action === 'navigate' ? this.resolveTarget(req.targetId) : null;+ // An explicit target that no longer resolves (closed, mistyped, or gone after a browser restart) is+ // an error: navigating nothing and opening a new tab would let the agent think the old one moved.+ if (req.action === 'navigate' && req.targetId && !existing)+ return actionFailed(+ req.action,+ `标签页 ${req.targetId} 已不存在或已失效;用 tabs 重新选择 targetId`,+ 'BROWSER_RUNTIME_INVALID_REQUEST',+ );const picked = this.pickClient(req.action, gate.control, req.profile ?? existing?.clientId);if (!picked.ok) return picked.result;const label = typeof req.label === 'string' ? req.label : undefined;