Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(browser): wait fn gets its own deadline after earlier conditions; tabs reports an unknown profile as invalid
Dash93f92c7e3019
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 1c3f7c8348..37ce629b4e 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@@ -682,6 +682,29 @@ describe('UserBrowserBackend · 读取与动作', () => {expect(fake.jobs.length).toBe(jobsBefore);});+ // Review 2026-10-30 (Codex P2): fn gets its own full wait after the earlier conditions used up time.+ it('wait 的 fn 在前置条件耗时之后重新计时', async () => {+ let clock = 0;+ const fake = fakeControl({ version: '0.4.56' });+ let evaluations = 0;+ fake.responses.set('wait', () => {+ clock += 5000;+ return { ok: true };+ });+ fake.responses.set('evaluate', () => ({ ok: true, result: ++evaluations >= 2 }));+ const b = new UserBrowserBackend({+ getPageControl: () => fake.control,+ reconnectWaitMs: 0,+ now: () => clock,+ logger: { info: vi.fn(), warn: vi.fn() },+ } as ConstructorParameters<typeof UserBrowserBackend>[0]);+ await call(b, { action: 'tabs' });+ expect(+ await call(b, { action: 'act', targetId: 't1', request: { kind: 'wait', selector: '#x', fn: '() => ready', timeoutMs: 1000 } }),+ ).toMatchObject({ ok: true, data: { kind: 'wait', result: true } });+ expect(evaluations).toBe(2);+ });+// Review 2026-10-30 (Codex P1): a profile that disagrees with the tab's own connection must be refused.it('navigate 的 targetId 与 profile 属于不同连接时拒绝', async () => {const fake = fakeControl({@@ -713,6 +736,11 @@ describe('UserBrowserBackend · 读取与动作', () => {ok: false,message: expect.stringContaining('匹配多个'),});+ expect(await call(b, { action: 'tabs', profile: 'nope' })).toMatchObject({+ ok: false,+ errorCode: 'BROWSER_RUNTIME_INVALID_REQUEST',+ message: expect.stringContaining('未找到'),+ });expect(await call(b, { action: 'tabs', profile: 'client-aaa' })).toMatchObject({ok: false,message: expect.stringContaining('匹配多个'),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 8ba32b76bd..680ba9cd1d 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@@ -742,6 +742,12 @@ export class UserBrowserBackend implements BrowserBackend {`浏览器连接 ${req.profile} 匹配多个连接,请写得更完整;用 profiles 查看当前连接`,'BROWSER_RUNTIME_INVALID_REQUEST',);+ if (clients.length === 0 && req.profile && connected.length > 0)+ return actionFailed(+ req.action,+ `未找到浏览器连接 ${req.profile};用 profiles 查看当前连接`,+ 'BROWSER_RUNTIME_INVALID_REQUEST',+ );if (clients.length === 0)return actionFailed(req.action, DISCONNECTED_MESSAGE, 'BROWSER_RUNTIME_UNAVAILABLE');const tabs: Array<Record<string, unknown>> = [];@@ -1140,7 +1146,8 @@ export class UserBrowserBackend implements BrowserBackend {if (!job.ok) return this.failureResult(req.action, job);}if (!request.fn) return result();- const deadline = started + timeoutMs;+ // fn gets its own full wait after the other conditions, as in Cindy's dedicated browser.+ const deadline = now() + timeoutMs;for (;;) {const job = await this.pageJob(control, record, 'evaluate', { fn: request.fn });if (!job.ok) return this.failureResult(req.action, job);