Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions apps/desktop/src/ipc/methods/preview.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,41 @@ describe("preview IPC methods", () => {
},
),
);

effectIt.effect("forwards review mode while legacy snapshot calls stay full", () =>
Effect.gen(function* () {
const automationSnapshot = vi.fn(() =>
Effect.succeed({
url: "https://example.com",
title: "Example",
loading: false,
visibleText: "",
interactiveElements: [],
accessibilityTree: null,
consoleEntries: [],
networkEntries: [],
actionTimeline: [],
screenshot: {
mimeType: "image/png" as const,
data: "cG5n",
width: 1,
height: 1,
},
}),
);
const manager = { automationSnapshot } as never;

yield* PreviewIpc.automationSnapshot
.handler({ tabId: "tab-1", mode: "review" })
.pipe(Effect.provideService(PreviewManager.PreviewManager, manager));
yield* PreviewIpc.automationSnapshot
.handler({ tabId: "tab-1" })
.pipe(Effect.provideService(PreviewManager.PreviewManager, manager));

expect(automationSnapshot.mock.calls).toEqual([
["tab-1", "review"],
["tab-1", "full"],
]);
}),
);
});
7 changes: 4 additions & 3 deletions apps/desktop/src/ipc/methods/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
DesktopPreviewAutomationEvaluateInputSchema,
DesktopPreviewAutomationPressInputSchema,
DesktopPreviewAutomationScrollInputSchema,
DesktopPreviewAutomationSnapshotInputSchema,
DesktopPreviewAutomationTypeInputSchema,
DesktopPreviewAutomationWaitForInputSchema,
DesktopPreviewConfigInputSchema,
Expand Down Expand Up @@ -276,11 +277,11 @@ export const automationStatus = DesktopIpc.makeIpcMethod({

export const automationSnapshot = DesktopIpc.makeIpcMethod({
channel: IpcChannels.PREVIEW_AUTOMATION_SNAPSHOT_CHANNEL,
payload: DesktopPreviewTabInputSchema,
payload: DesktopPreviewAutomationSnapshotInputSchema,
result: PreviewAutomationSnapshot,
handler: Effect.fn("desktop.ipc.preview.automationSnapshot")(function* ({ tabId }) {
handler: Effect.fn("desktop.ipc.preview.automationSnapshot")(function* ({ tabId, mode }) {
const manager = yield* PreviewManager.PreviewManager;
return yield* manager.automationSnapshot(tabId);
return yield* manager.automationSnapshot(tabId, mode === "review" ? "review" : "full");
}),
});

Expand Down
7 changes: 5 additions & 2 deletions apps/desktop/src/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,11 @@ contextBridge.exposeInMainWorld("desktopBridge", {
automation: {
status: (tabId) =>
ipcRenderer.invoke(IpcChannels.PREVIEW_AUTOMATION_STATUS_CHANNEL, { tabId }),
snapshot: (tabId) =>
ipcRenderer.invoke(IpcChannels.PREVIEW_AUTOMATION_SNAPSHOT_CHANNEL, { tabId }),
snapshot: (tabId, options) =>
ipcRenderer.invoke(
IpcChannels.PREVIEW_AUTOMATION_SNAPSHOT_CHANNEL,
options?.mode === "review" ? { tabId, mode: "review" } : { tabId },
),
click: (tabId, input) =>
ipcRenderer.invoke(IpcChannels.PREVIEW_AUTOMATION_CLICK_CHANNEL, { tabId, input }),
type: (tabId, input) =>
Expand Down
Loading
Loading