@devries-cameron20 / t3code Mirror · read-only / commits / 284ce8fe2f
Fork 0

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 23, 01:45 UTC

fix(desktop): keep PDF preview reloads inside the guest (#21733)

Farès SIONI committed Oct 19, 2026 at 22:28 UTC 284ce8fe2ff99076657707fd754e538403d88d76
2 files changed +22 -1
apps/desktop/src/preview/GuestInput.test.ts
+15
@@ -19,6 +19,8 @@ const makeGuest = ({
19 focusedFrame: focused ? {} : null,
20 insertText: vi.fn(async () => {}),
21 sendInputEvent: vi.fn(),
22 + reload: vi.fn(),
23 + reloadIgnoringCache: vi.fn(),
24 };
25 return {
26 webContents,
@@ -34,6 +36,19 @@ const makeGuest = ({
36 };
37
38 describe("preview guest input", () => {
39 + it.each([undefined, false, true])(
40 + "reloads only the guest with ignoreCache=%s",
41 + async (ignoreCache) => {
42 + const guest = makeGuest({ focused: false });
43 + await expect(
44 + guest.send("Page.reload", ignoreCache === undefined ? {} : { ignoreCache }),
45 + ).resolves.toEqual({});
46 + expect(guest.webContents.reload).toHaveBeenCalledTimes(ignoreCache ? 0 : 1);
47 + expect(guest.webContents.reloadIgnoringCache).toHaveBeenCalledTimes(ignoreCache ? 1 : 0);
48 + expect(guest.sendCommand).not.toHaveBeenCalled();
49 + },
50 + );
51 +
52 it("types into an unfocused guest's own page, not the app's focused field", async () => {
53 const guest = makeGuest({ focused: false });
54 await guest.send("Input.insertText", { text: "pairing-code" });
apps/desktop/src/preview/GuestInput.ts
+7 -1
@@ -115,13 +115,19 @@ const evaluate = async (debuggee: Electron.Debugger, expression: string) => {
115 return reply.result?.value;
116 };
117
118 -/** Sends one command to the guest's page, keeping key and text input inside it. */
118 +/** Sends one command to the guest's page, keeping reloads and input inside it. */
119 export const sendPageCommand = async (
120 webContents: Electron.WebContents,
121 debuggee: Electron.Debugger,
122 method: string,
123 params: Record<string, unknown>,
124 ): Promise<unknown> => {
125 + // Electron's debugger routes Page.reload on a webview to its embedder window.
126 + if (method === "Page.reload") {
127 + if (params["ignoreCache"] === true) webContents.reloadIgnoringCache();
128 + else webContents.reload();
129 + return {};
130 + }
131 if (!FOCUS_ROUTED_INPUT.has(method) || webContents.focusedFrame) {
132 return debuggee.sendCommand(method, params);
133 }