fix(browser): preserve chat focus during agent browsing

This commit is contained in:
2026-09-27 15:23:23 +08:00
parent 220e89992b
commit a52e747a00
10 changed files with 323 additions and 16 deletions

View File

@@ -1280,7 +1280,9 @@ describe('AgentBrowserModule', () => {
await expect(module.sendCdp({
projectPath,
method: 'Runtime.evaluate',
})).rejects.toMatchObject({ code: 'VIEWPORT_NOT_READY' });
})).resolves.toMatchObject({ kind: 'inline' });
await expect(module.readEvents({ projectPath, after: 0 })).resolves.toBeDefined();
await module.navigate({ projectPath, action: 'reload' });
const reopened = await module.open({
projectId: 'clock',
projectPath,
@@ -1288,10 +1290,18 @@ describe('AgentBrowserModule', () => {
visible: true,
});
expect(reopened).toMatchObject({
browserId: first.browserId,
generation: first.generation,
visible: false,
bounds: { x: 1, y: 2, width: 640, height: 480 },
});
expect(adapter.views[0].visible).toBe(false);
expect(adapter.views).toHaveLength(1);
await module.close(projectPath);
await expect(module.sendCdp({
projectPath,
method: 'Runtime.evaluate',
})).rejects.toMatchObject({ code: 'BROWSER_NOT_OPEN' });
});
it('waits for the matching browser generation to be presented without polling', async () => {