@devries-cameron20 / t3code-1 / commits / ae45ccd2cc
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(desktop): a stalled capture no longer freezes picture-in-picture (#24057)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Batuhan1999 committed Oct 30, 2026 at 22:02 UTC ae45ccd2ccab61a8c2449ff68841898fbc3a7fb4
2 files changed +49 -7
apps/desktop/src/preview/Manager.test.ts
+42
@@ -2201,6 +2201,48 @@ describe("PreviewManager", () => {
2201 ),
2202 );
2203
2204 + effectIt.effect("shows picture-in-picture and keeps capturing after stalled captures", () =>
2205 + withManager((manager) =>
2206 + Effect.gen(function* () {
2207 + const image = {
2208 + toJPEG: () => Buffer.from("preview-frame"),
2209 + getSize: () => ({ width: 1280, height: 720 }),
2210 + };
2211 + const stalledInitial = Promise.withResolvers<typeof image>();
2212 + const stalledLoop = Promise.withResolvers<typeof image>();
2213 + const capturePage = vi
2214 + .fn<() => Promise<typeof image>>()
2215 + .mockImplementationOnce(() => stalledInitial.promise)
2216 + .mockImplementationOnce(() => stalledLoop.promise)
2217 + .mockResolvedValue(image);
2218 + fromId.mockReturnValue(makeTestPreviewWebContents(capturePage));
2219 + const { pictureInPictureWindow, send } = makeTestPictureInPictureWindow();
2220 + browserWindowConstructor.mockImplementation(function () {
2221 + return pictureInPictureWindow;
2222 + });
2223 + yield* manager.createTab("tab_pip_stalled_capture");
2224 + yield* manager.registerWebview("tab_pip_stalled_capture", 42);
2225 +
2226 + try {
2227 + const open = yield* manager
2228 + .openPictureInPicture("tab_pip_stalled_capture")
2229 + .pipe(Effect.forkChild({ startImmediately: true }));
2230 + yield* TestClock.adjust(1_000);
2231 + expect(pictureInPictureWindow.showInactive).toHaveBeenCalledOnce();
2232 + yield* Fiber.join(open);
2233 +
2234 + expect(send).not.toHaveBeenCalled();
2235 + yield* TestClock.adjust(500);
2236 + expect(send).toHaveBeenCalled();
2237 + } finally {
2238 + // Release stalled native calls after a failing assertion against unchanged base.
2239 + stalledInitial.resolve(image);
2240 + stalledLoop.resolve(image);
2241 + }
2242 + }),
2243 + ),
2244 + );
2245 +
2246 effectIt.effect("rejects picture-in-picture when its webview changes during initialization", () =>
2247 withManager((manager) =>
2248 Effect.gen(function* () {
apps/desktop/src/preview/Manager.ts
+7 -7
@@ -2426,13 +2426,13 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
2426 if (!captureSession?.consumers.has("picture-in-picture") || captureSession.scope === null)
2427 return;
2428 const wc = yield* requireWebContents(tabId);
2429 - const image = yield* attemptPromise(
2430 - {
2431 - operation: "frameCapture.capturePage",
2432 - tabId,
2433 - webContentsId: wc.id,
2434 - },
2435 - () => wc.capturePage(),
2429 + const captureContext = { operation: "frameCapture.capturePage", tabId, webContentsId: wc.id };
2430 + const image = yield* attemptPromise(captureContext, () => wc.capturePage()).pipe(
2431 + Effect.timeout(CAPTURE_PAGE_ATTEMPT_TIMEOUT_MS),
2432 + Effect.catchTags({
2433 + TimeoutError: (cause) =>
2434 + Effect.fail(new PreviewOperationError({ ...captureContext, cause })),
2435 + }),
2436 );
2437 const currentCaptureSession = yield* Effect.all(
2438 [SynchronizedRef.get(frameCaptureSessionsRef), SynchronizedRef.get(tabsRef)],