fix(desktop): recover preview automation after snapshot timeouts #8486
Closedt3dotgg(GitHub profile, opens in a new tab)wants to merge 5 commits into
main fromt3code/fix-preview-snapshot-recovery-3713opened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
- apps/desktop/src/ipc/methods/preview.ts lines 301 to 307OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -291,8 +292,16 @@291292292293 export const automationSnapshot = DesktopIpc.makeIpcMethod({293294 channel: IpcChannels.PREVIEW_AUTOMATION_SNAPSHOT_CHANNEL,294- payload: DesktopPreviewTabInputSchema,295- result: PreviewAutomationSnapshot,296- handler: Effect.fn("desktop.ipc.preview.automationSnapshot")(function* ({ tabId }) {295+ payload: DesktopPreviewAutomationSnapshotInputSchema,296+ result: DesktopPreviewAutomationSnapshotResultSchema,297+ handler: Effect.fn("desktop.ipc.preview.automationSnapshot")(function* (input) {297298 const manager = yield* PreviewManager.PreviewManager;298- return yield* manager.automationSnapshot(tabId);299+ return yield* manager.automationSnapshot(input).pipe(300+ Effect.map((snapshot) => ({ _tag: "Success" as const, snapshot })),301+ Effect.catchTag("PreviewAutomationDeadlineExceededError", (error) =>302+ Effect.succeed({303+ _tag: "Timeout" as const,304+ stage: error.stage,305+ timeoutMs: error.timeoutMs,306+ }),307+ ),
- apps/web/src/components/preview/PreviewAutomationHosts.tsx line 351Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -305,5 +331,21 @@331+ performance.now() +332+ responseBudgetMs(request.timeoutMs, PREVIEW_AUTOMATION_RESPONSE_MARGIN_MS);305333 const threadRef: ScopedThreadRef = {306334 environmentId,307335 threadId: request.threadId,308336 };309337 let tabId = request.tabId ?? null;338+ const hostTimeoutError = () =>339+ new PreviewAutomationOverlayTimeoutError({340+ requestId: request.requestId,341+ environmentId,342+ threadId: request.threadId,343+ timeoutMs: request.timeoutMs,344+ });345+ const runWithinHostBudget = <A,>(run: () => Promise<A>): Promise<A> =>346+ waitForLocalResponse(run, remainingBudgetMs(hostDeadline), hostTimeoutError).then(347+ (value) => {348+ if (remainingBudgetMs(hostDeadline) <= 0) throw hostTimeoutError();349+ return value;350+ },351+ );
- apps/desktop/src/preview/Manager.ts line 2587Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -2257,4 +2579,9 @@22572579 const cropRect = normalizeCaptureRect(args[1]);22582580 const submission = args[2] === "send" ? "send" : "attach";22592581 runFork(2260- captureAnnotationScreenshot(tabId, wc, cropRect).pipe(2582+ captureAnnotationScreenshot(2583+ cropRect,2584+ capturePage(2585+ { operation: "captureAnnotationScreenshot", tabId, webContentsId: wc.id },2586+ wc,2587+ cropRect ? { rect: cropRect } : {},
juliusmarminge closed this
Sign in to join this conversation.


Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
5ea6f13b-fc8c-4689-b890-84ec7f47dd26You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Comment `@coderabbitai help` to get the list of available commands.