fix(agent-browser): preserve preview injection origin

This commit is contained in:
2026-08-27 01:55:49 +08:00
parent 2f346687b1
commit 0a4f526c2c
3 changed files with 125 additions and 2 deletions

View File

@@ -391,7 +391,7 @@ export class AgentBrowserModule {
this.attachDebugger(record, false),
OPEN_TIMEOUT_MS,
);
if (injectProjectData) await this.installPreviewData(record);
if (injectProjectData) await this.installPreviewData(record, undefined, targetUrl);
} catch (error) {
await this.closeInternal(record);
throw toFault(
@@ -796,6 +796,7 @@ export class AgentBrowserModule {
private async installPreviewData(
record: BrowserRecord,
sessionRef?: string,
targetUrl?: string,
): Promise<void> {
if (record !== this.record || record.view.webContents.isDestroyed()) {
throw new AgentBrowserFault(
@@ -814,7 +815,7 @@ export class AgentBrowserModule {
if (!sessionRef) {
const openInput: PreviewDataSessionOpenInput = {
projectPath: record.projectPath,
origin: new URL(record.url).origin,
origin: new URL(targetUrl ?? record.url).origin,
browserGeneration: record.generation,
};
const session = await previewDataSession.open(openInput);