feat(agent-browser): add opt-in preview data injection
This commit is contained in:
@@ -213,6 +213,9 @@ export function createCodingComposition(
|
||||
const dataService = createDataServiceOperations({ projects });
|
||||
productTools.configureDataService(dataService);
|
||||
previewDataSession = createPreviewDataSessionManager({ projects });
|
||||
if (typeof options.browser.configurePreviewDataSession === 'function') {
|
||||
options.browser.configurePreviewDataSession(previewDataSession);
|
||||
}
|
||||
const unsubscribeBrowserLifecycle = typeof options.browser.subscribeLifecycle === 'function'
|
||||
? options.browser.subscribeLifecycle((event) => {
|
||||
previewDataSession?.handleAgentBrowserLifecycle(event);
|
||||
@@ -236,6 +239,9 @@ export function createCodingComposition(
|
||||
},
|
||||
async shutdown() {
|
||||
previewDataSession?.dispose();
|
||||
if (typeof options.browser.configurePreviewDataSession === 'function') {
|
||||
options.browser.configurePreviewDataSession(undefined);
|
||||
}
|
||||
unsubscribeBrowserLifecycle();
|
||||
await subagents.close();
|
||||
await runtime.shutdown();
|
||||
|
||||
@@ -28,6 +28,7 @@ export interface AgentBrowserService {
|
||||
url: string;
|
||||
bounds?: AgentBrowserBounds;
|
||||
visible?: boolean;
|
||||
injectProjectData?: boolean;
|
||||
}): Promise<AgentBrowserSnapshot>;
|
||||
present(input: {
|
||||
projectPath: string;
|
||||
|
||||
@@ -11,6 +11,7 @@ type AgentBrowserBody = {
|
||||
url?: unknown;
|
||||
action?: unknown;
|
||||
visible?: unknown;
|
||||
inject_project_data?: unknown;
|
||||
enabled?: unknown;
|
||||
bounds?: unknown;
|
||||
method?: unknown;
|
||||
@@ -221,6 +222,7 @@ export async function handleAgentBrowserRoutes(
|
||||
url: targetUrl,
|
||||
bounds: parseBounds(body.bounds),
|
||||
visible: rendererPresentation && body.visible !== false,
|
||||
...(body.inject_project_data === true ? { injectProjectData: true } : {}),
|
||||
});
|
||||
await ensureProjectStillActive(ctx, project);
|
||||
emitState(ctx, 'agent-browser:show', browser);
|
||||
|
||||
Reference in New Issue
Block a user