The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 02:00 UTC
fix(desktop): chat videos go fullscreen across the whole screen again (#25835)
Co-authored-by: Luca Lucidera <l.lucidera@dkr.srl> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Luca-Lucidera committed
Nov 9, 2026 at 15:27 UTC
c5b869f29ef71c08c1754bc9b500223e448a0f42
8 files changed
+172
apps/desktop/scripts/verify-preload-bundle.mjs
+6
@@ -103,11 +103,17 @@ const executeBundle = (source, sandboxModules) => {
103
return sandboxModules.get(moduleName);
104
};
105
106
+ // A real preload loads with the page's DOM; no page events fire while the bundle runs here.
107
+ const document = Object.assign(new EventTarget(), { fullscreenElement: null });
108
+ const window = Object.assign(new EventTarget(), { document });
109
+
110
NodeVM.runInNewContext(
111
source,
112
{
113
+ document,
114
process: sandboxProcess,
115
require: requireSandboxModule,
116
+ window,
117
},
118
{
119
filename: "desktop-preload.cjs",
apps/desktop/scripts/verify-preload-bundle.test.mjs
+12
@@ -80,6 +80,18 @@ describe("desktop preload bundle verifier", () => {
80
);
81
});
82
83
+ it("runs a preload that reads the page's DOM while loading", () => {
84
+ assert.doesNotThrow(() =>
85
+ verifyPreloadBundle(`
86
+ ${validPreload}
87
+ const report = () => document.fullscreenElement;
88
+ report();
89
+ document.addEventListener("fullscreenchange", report);
90
+ window.addEventListener("resize", report);
91
+ `),
92
+ );
93
+ });
94
+
95
it("ignores require-like text in strings and comments", () => {
96
assert.doesNotThrow(() =>
97
verifyPreloadBundle(`
apps/desktop/src/ipc/DesktopIpcHandlers.ts
+2
@@ -52,6 +52,7 @@ import {
52
pickProjectFavicon,
53
pickThemeFiles,
54
setTheme,
55
+ syncHtmlFullscreen,
56
showContextMenu,
57
} from "./methods/window.ts";
58
import {
@@ -154,6 +155,7 @@ export const installDesktopIpcHandlers = Effect.fn("desktop.ipc.installHandlers"
155
yield* ipc.handle(checkSystemPermission);
156
yield* ipc.handle(pasteAsText);
157
yield* ipc.handle(revealWindow);
158
+ yield* ipc.handle(syncHtmlFullscreen);
159
yield* ipc.handle(probeRemoteEditors);
160
yield* ipc.handle(getUpdateState);
161
yield* ipc.handle(setUpdateChannel);
apps/desktop/src/ipc/channels.ts
+1
@@ -19,6 +19,7 @@ export const TRACKPAD_SCROLL_BEGIN_CHANNEL = "desktop:trackpad-scroll-begin";
19
export const TRACKPAD_SCROLL_END_CHANNEL = "desktop:trackpad-scroll-end";
20
export const GET_WINDOW_FULLSCREEN_STATE_CHANNEL = "desktop:get-window-fullscreen-state";
21
export const WINDOW_FULLSCREEN_STATE_CHANNEL = "desktop:window-fullscreen-state";
22
+export const SYNC_HTML_FULLSCREEN_CHANNEL = "desktop:sync-html-fullscreen";
23
export const DESKTOP_APP_ACTIVATION_READY_CHANNEL = "desktop:app-activation-ready";
24
export const DESKTOP_APP_ACTIVATION_COMPLETE_CHANNEL = "desktop:app-activation-complete";
25
export const DESKTOP_APP_ACTIVATION_REQUEST_CHANNEL = "desktop:app-activation-request";
apps/desktop/src/ipc/methods/window.test.ts
+88
@@ -35,6 +35,7 @@ import {
35
pickProjectFavicon,
36
probeRemoteEditors,
37
readMedia,
38
+ syncHtmlFullscreen,
39
} from "./window.ts";
40
41
const readyWslConfig: DesktopBackendManager.DesktopBackendStartConfig = {
@@ -356,6 +357,93 @@ describe("pickProjectFavicon", () => {
357
);
358
});
359
360
+describe("syncHtmlFullscreen", () => {
361
+ const fullscreenWindow = (fullscreen: boolean, { animatedExit = false } = {}) => {
362
+ let current = fullscreen;
363
+ let exiting = false;
364
+ const queued: boolean[] = [];
365
+ const leaveListeners: Array<() => void> = [];
366
+ const leave = () => {
367
+ current = false;
368
+ for (const listener of leaveListeners) listener();
369
+ };
370
+ // Like macOS, an animated exit keeps reporting fullscreen and queues requests until it ends.
371
+ const setFullScreen = vi.fn((next: boolean) => {
372
+ if (exiting) queued.push(next);
373
+ else if (next) current = true;
374
+ else if (!current) return;
375
+ else if (animatedExit) exiting = true;
376
+ else leave();
377
+ });
378
+ const finishExit = () => {
379
+ exiting = false;
380
+ leave();
381
+ for (const next of queued.splice(0)) setFullScreen(next);
382
+ };
383
+ const window = {
384
+ webContents: { id: 1 },
385
+ isDestroyed: () => false,
386
+ isFullScreen: () => current,
387
+ setFullScreen,
388
+ on: (event: string, listener: () => void) => {
389
+ if (event === "leave-full-screen") leaveListeners.push(listener);
390
+ },
391
+ } as unknown as Electron.BrowserWindow;
392
+ const layer = Layer.mock(ElectronWindow.ElectronWindow)({ main: Effect.succeedSome(window) });
393
+ return { window, setFullScreen, finishExit, layer };
394
+ };
395
+ const fromMainRenderer = { sender: { id: 1 } };
396
+
397
+ it.effect("takes the screen for the app's own fullscreen element and gives it back", () => {
398
+ const { window, layer } = fullscreenWindow(false);
399
+ return Effect.gen(function* () {
400
+ yield* syncHtmlFullscreen.handler(true, fromMainRenderer);
401
+ assert.isTrue(window.isFullScreen());
402
+
403
+ yield* syncHtmlFullscreen.handler(false, fromMainRenderer);
404
+ assert.isFalse(window.isFullScreen());
405
+ }).pipe(Effect.provide(layer));
406
+ });
407
+
408
+ it.effect("keeps a window the user had already made fullscreen", () => {
409
+ const { window, setFullScreen, layer } = fullscreenWindow(true);
410
+ return Effect.gen(function* () {
411
+ yield* syncHtmlFullscreen.handler(true, fromMainRenderer);
412
+ yield* syncHtmlFullscreen.handler(false, fromMainRenderer);
413
+
414
+ assert.isTrue(window.isFullScreen());
415
+ assert.strictEqual(setFullScreen.mock.calls.length, 0);
416
+ }).pipe(Effect.provide(layer));
417
+ });
418
+
419
+ it.effect("hands the window back once the user leaves OS fullscreen during playback", () => {
420
+ const { window, layer } = fullscreenWindow(false);
421
+ return Effect.gen(function* () {
422
+ yield* syncHtmlFullscreen.handler(true, fromMainRenderer);
423
+ window.setFullScreen(false);
424
+ window.setFullScreen(true);
425
+ yield* syncHtmlFullscreen.handler(false, fromMainRenderer);
426
+
427
+ assert.isTrue(window.isFullScreen());
428
+ }).pipe(Effect.provide(layer));
429
+ });
430
+
431
+ it.effect("takes the screen again when the video returns during an animated exit", () => {
432
+ const { window, finishExit, layer } = fullscreenWindow(false, { animatedExit: true });
433
+ return Effect.gen(function* () {
434
+ yield* syncHtmlFullscreen.handler(true, fromMainRenderer);
435
+ yield* syncHtmlFullscreen.handler(false, fromMainRenderer);
436
+ yield* syncHtmlFullscreen.handler(true, fromMainRenderer);
437
+ finishExit();
438
+ assert.isTrue(window.isFullScreen());
439
+
440
+ yield* syncHtmlFullscreen.handler(false, fromMainRenderer);
441
+ finishExit();
442
+ assert.isFalse(window.isFullScreen());
443
+ }).pipe(Effect.provide(layer));
444
+ });
445
+});
446
+
447
it.effect.skipIf(HostProcess.Platform.defaultValue() === "win32")(
448
"finds remote editors installed without PATH launchers",
449
() =>
apps/desktop/src/ipc/methods/window.ts
+50
@@ -451,6 +451,56 @@ export const revealWindow = DesktopIpc.makeIpcMethod({
451
}),
452
});
453
454
+const htmlFullscreenStates = new WeakMap<
455
+ Electron.BrowserWindow,
456
+ { owned: boolean; leaving: boolean }
457
+>();
458
+
459
+const htmlFullscreenState = (window: Electron.BrowserWindow) => {
460
+ const existing = htmlFullscreenStates.get(window);
461
+ if (existing !== undefined) return existing;
462
+ const state = { owned: false, leaving: false };
463
+ window.on("leave-full-screen", () => {
464
+ // Leaving OS fullscreen any other way, such as F11, hands the window back to the user.
465
+ if (!state.leaving) state.owned = false;
466
+ state.leaving = false;
467
+ });
468
+ htmlFullscreenStates.set(window, state);
469
+ return state;
470
+};
471
+
472
+// The main window keeps HTML fullscreen inside itself so preview guests stay in their webview,
473
+// so the app's own fullscreen elements, such as chat videos, take the screen here.
474
+export const syncHtmlFullscreen = DesktopIpc.makeIpcMethod({
475
+ channel: IpcChannels.SYNC_HTML_FULLSCREEN_CHANNEL,
476
+ payload: Schema.Boolean,
477
+ result: Schema.Void,
478
+ handler: Effect.fn("desktop.ipc.window.syncHtmlFullscreen")(function* (fullscreen, event) {
479
+ const electronWindow = yield* ElectronWindow.ElectronWindow;
480
+ const main = yield* electronWindow.main;
481
+ if (
482
+ event === undefined ||
483
+ Option.isNone(main) ||
484
+ main.value.isDestroyed() ||
485
+ main.value.webContents.id !== event.sender.id
486
+ ) {
487
+ return;
488
+ }
489
+ const window = main.value;
490
+ const state = htmlFullscreenState(window);
491
+ if (fullscreen) {
492
+ // macOS reports fullscreen until its exit animation ends, and Electron queues the re-entry.
493
+ if (state.owned || (window.isFullScreen() && !state.leaving)) return;
494
+ state.owned = true;
495
+ window.setFullScreen(true);
496
+ } else if (state.owned) {
497
+ state.owned = false;
498
+ state.leaving = window.isFullScreen();
499
+ window.setFullScreen(false);
500
+ }
501
+ }),
502
+});
503
+
504
const PICKED_THEME_FILE_MAX_BYTES = 256 * 1024;
505
506
export const pickThemeFiles = DesktopIpc.makeIpcMethod({
apps/desktop/src/preload.ts
+12
@@ -57,6 +57,18 @@ if (clientPlatform === "darwin") {
57
window.addEventListener("resize", syncWindowControlInset);
58
}
59
60
+const syncHtmlFullscreen = () => {
61
+ const element = document.fullscreenElement;
62
+ // A preview guest's fullscreen surfaces here as its <webview>, which stays inside the window.
63
+ void ipcRenderer.invoke(
64
+ IpcChannels.SYNC_HTML_FULLSCREEN_CHANNEL,
65
+ element !== null && element.tagName !== "WEBVIEW",
66
+ );
67
+};
68
+// A reload or renderer crash never reports the old document's exit, so each document reports its start.
69
+syncHtmlFullscreen();
70
+document.addEventListener("fullscreenchange", syncHtmlFullscreen);
71
+
72
function unwrapEnsureSshEnvironmentResult(result: unknown) {
73
if (
74
typeof result === "object" &&
apps/desktop/src/window/DesktopWindow.ts
+1
@@ -417,6 +417,7 @@ export const make = Effect.gen(function* () {
417
sandbox: true,
418
webviewTag: true,
419
// Guest fullscreen propagates to the embedder; both must opt out to keep it inside the webview.
420
+ // The app's own fullscreen elements reach OS fullscreen through syncHtmlFullscreen.
421
disableHtmlFullscreenWindowResize: true,
422
},
423
});