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

@@ -119,7 +119,9 @@ export class PiAgentBrowserTool {
});
const runKey = `${context.conversationId}:${context.runId}`;
this.diagnosticRuns.set(runKey, { projectPath: context.projectPath, owner });
if (this.requestPresentation) {
// Only a new viewport needs foreground presentation. Reusing an initialized
// page must respect the user's selected tab, including while navigating.
if (this.requestPresentation && !snapshot.bounds) {
try {
this.requestPresentation(snapshot);
snapshot = await this.browser.waitForPresentation({
@@ -139,6 +141,8 @@ export class PiAgentBrowserTool {
}
throw error;
}
} else {
this.publishState?.(snapshot);
}
return result(action, publicSnapshot(snapshot));
}