fix(browser): preserve chat focus during agent browsing
This commit is contained in:
@@ -615,7 +615,7 @@ export class AgentBrowserModule {
|
||||
}
|
||||
|
||||
async readEvents(input: AgentBrowserReadEventsInput): Promise<AgentBrowserCdpEventPage> {
|
||||
let record = this.requirePresented(input.projectPath);
|
||||
let record = this.requireViewport(input.projectPath);
|
||||
const after = normalizeNonNegativeInteger(input.after, 0, 'after');
|
||||
const limit = normalizeIntegerRange(input.limit, 100, 1, 200, 'limit');
|
||||
const waitMs = normalizeIntegerRange(input.waitMs, 0, 0, MAX_WAIT_MS, 'waitMs');
|
||||
@@ -645,13 +645,13 @@ export class AgentBrowserModule {
|
||||
|| current !== record
|
||||
|| current.eventBuffer.cursor !== cursorBeforeWait;
|
||||
});
|
||||
record = this.requirePresented(input.projectPath);
|
||||
record = this.requireViewport(input.projectPath);
|
||||
page = record.eventBuffer.read(page.nextCursor, input.methods, limit);
|
||||
return page;
|
||||
}
|
||||
|
||||
async readPayload(input: AgentBrowserReadPayloadInput): Promise<AgentBrowserPayloadChunk> {
|
||||
this.requirePresented(input.projectPath);
|
||||
this.requireViewport(input.projectPath);
|
||||
return this.payloadStore.read(input.handle, input.offset, input.maxBytes);
|
||||
}
|
||||
|
||||
@@ -1589,7 +1589,7 @@ export class AgentBrowserModule {
|
||||
}
|
||||
|
||||
private requireAttached(projectPath: string): BrowserRecord {
|
||||
const record = this.requirePresented(projectPath);
|
||||
const record = this.requireViewport(projectPath);
|
||||
if (record.state === 'suspended_devtools') {
|
||||
throw new AgentBrowserFault(
|
||||
'DEVTOOLS_CONFLICT',
|
||||
@@ -1617,12 +1617,14 @@ export class AgentBrowserModule {
|
||||
return record;
|
||||
}
|
||||
|
||||
private requirePresented(projectPath: string): BrowserRecord {
|
||||
private requireViewport(projectPath: string): BrowserRecord {
|
||||
const record = this.requireRecord(projectPath);
|
||||
if (!record.visible || !record.bounds) {
|
||||
// Switching to chat hides the native view without ending its debugging session.
|
||||
// A new view still needs its first real viewport before tools can operate.
|
||||
if (!record.bounds) {
|
||||
throw new AgentBrowserFault(
|
||||
'VIEWPORT_NOT_READY',
|
||||
'开发浏览器已收起,智能体调试已暂停。',
|
||||
'开发浏览器显示区域尚未准备好。',
|
||||
true,
|
||||
record.generation,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user