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 21, 23:30 UTC
fix(desktop): Cmd+F now searches the page in the integrated browser (#22960)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>
Arman Arutiunov committed
Nov 11, 2026 at 10:14 UTC
e93f6ea36178f18b4cd38a9ec4939151c086f440
20 files changed
+599
-25
apps/desktop/src/ipc/channels.ts
+3
@@ -94,6 +94,8 @@ export const PREVIEW_SET_ZOOM_FACTOR_CHANNEL = "desktop:preview-set-zoom-factor"
94
export const PREVIEW_HARD_RELOAD_CHANNEL = "desktop:preview-hard-reload";
95
export const PREVIEW_SET_COLOR_SCHEME_CHANNEL = "desktop:preview-set-color-scheme";
96
export const PREVIEW_SET_AUDIO_MUTED_CHANNEL = "desktop:preview-set-audio-muted";
97
+export const PREVIEW_FIND_IN_PAGE_CHANNEL = "desktop:preview-find-in-page";
98
+export const PREVIEW_STOP_FIND_IN_PAGE_CHANNEL = "desktop:preview-stop-find-in-page";
99
export const PREVIEW_SET_SHOWN_CHANNEL = "desktop:preview-set-shown";
100
export const PREVIEW_OPEN_DEVTOOLS_CHANNEL = "desktop:preview-open-devtools";
101
export const PREVIEW_CLEAR_COOKIES_CHANNEL = "desktop:preview-clear-cookies";
@@ -118,6 +120,7 @@ export const PREVIEW_RECORDING_SAVE_CHANNEL = "desktop:preview-recording-save";
120
export const PREVIEW_STATE_CHANGE_CHANNEL = "desktop:preview-state-change";
121
export const PREVIEW_POINTER_EVENT_CHANNEL = "desktop:preview-pointer-event";
122
export const PREVIEW_OPEN_LINK_CHANNEL = "desktop:preview-open-link";
123
+export const PREVIEW_FIND_RESULT_CHANNEL = "desktop:preview-find-result";
124
125
export const MAC_PERMISSION_HELPER_CHANNEL = "desktop:mac-permission-helper";
126
apps/desktop/src/ipc/methods/preview.ts
+26
@@ -5,6 +5,7 @@ import {
5
DesktopPreviewPickElementInputSchema,
6
DesktopPreviewArtifactInputSchema,
7
DesktopPreviewConfigInputSchema,
8
+ DesktopPreviewFindInPageInputSchema,
9
DesktopPreviewNavigateInputSchema,
10
DesktopPreviewRecordingArtifactSchema,
11
DesktopPreviewRecordingSaveInputSchema,
@@ -59,6 +60,9 @@ export const installPreviewEventForwarding = Effect.fn(
60
yield* manager.subscribeOpenLinks((event) =>
61
electronWindow.sendAll(IpcChannels.PREVIEW_OPEN_LINK_CHANNEL, event),
62
);
63
+ yield* manager.subscribeFindResults((event) =>
64
+ electronWindow.sendAll(IpcChannels.PREVIEW_FIND_RESULT_CHANNEL, event),
65
+ );
66
});
67
68
const setForwardedShortcuts = DesktopIpc.makeIpcMethod({
@@ -116,6 +120,21 @@ const navigate = DesktopIpc.makeIpcMethod({
120
}),
121
});
122
123
+const findInPage = DesktopIpc.makeIpcMethod({
124
+ channel: IpcChannels.PREVIEW_FIND_IN_PAGE_CHANNEL,
125
+ payload: DesktopPreviewFindInPageInputSchema,
126
+ result: Schema.Void,
127
+ handler: Effect.fn("desktop.ipc.preview.findInPage")(function* ({
128
+ tabId,
129
+ text,
130
+ forward,
131
+ newSession,
132
+ }) {
133
+ const manager = yield* PreviewManager.PreviewManager;
134
+ yield* manager.findInPage(tabId, text, { forward, newSession });
135
+ }),
136
+});
137
+
138
const tabMethod = (
139
channel: string,
140
name: string,
@@ -169,6 +188,11 @@ const hardReload = tabMethod(
188
"desktop.ipc.preview.hardReload",
189
(manager, tabId) => manager.hardReload(tabId),
190
);
191
+const stopFindInPage = tabMethod(
192
+ IpcChannels.PREVIEW_STOP_FIND_IN_PAGE_CHANNEL,
193
+ "desktop.ipc.preview.stopFindInPage",
194
+ (manager, tabId) => manager.stopFindInPage(tabId),
195
+);
196
const setZoomFactor = DesktopIpc.makeIpcMethod({
197
channel: IpcChannels.PREVIEW_SET_ZOOM_FACTOR_CHANNEL,
198
payload: DesktopPreviewSetZoomFactorInputSchema,
@@ -452,6 +476,8 @@ export const methods = [
476
zoomOut,
477
resetZoom,
478
hardReload,
479
+ findInPage,
480
+ stopFindInPage,
481
setColorScheme,
482
setZoomFactor,
483
setAudioMuted,
apps/desktop/src/preload.ts
+19
@@ -1,6 +1,7 @@
1
import type {
2
DesktopBridge,
3
DesktopPreviewAnnotationVoiceEvent,
4
+ DesktopPreviewFindResultEvent,
5
DesktopPreviewOpenLinkEvent,
6
DesktopPreviewPointerEvent,
7
DesktopPreviewRecordingInputEvent,
@@ -369,6 +370,15 @@ contextBridge.exposeInMainWorld("desktopBridge", {
370
ipcRenderer.invoke(IpcChannels.PREVIEW_SET_COLOR_SCHEME_CHANNEL, { tabId, colorScheme }),
371
setAudioMuted: (tabId, audioMuted) =>
372
ipcRenderer.invoke(IpcChannels.PREVIEW_SET_AUDIO_MUTED_CHANNEL, { tabId, audioMuted }),
373
+ findInPage: (tabId, text, { forward, newSession }) =>
374
+ ipcRenderer.invoke(IpcChannels.PREVIEW_FIND_IN_PAGE_CHANNEL, {
375
+ tabId,
376
+ text,
377
+ forward,
378
+ newSession,
379
+ }),
380
+ stopFindInPage: (tabId) =>
381
+ ipcRenderer.invoke(IpcChannels.PREVIEW_STOP_FIND_IN_PAGE_CHANNEL, { tabId }),
382
setShown: (tabId, shown) =>
383
ipcRenderer.invoke(IpcChannels.PREVIEW_SET_SHOWN_CHANNEL, { tabId, shown }),
384
openDevTools: (tabId) =>
@@ -469,5 +479,14 @@ contextBridge.exposeInMainWorld("desktopBridge", {
479
return () =>
480
ipcRenderer.removeListener(IpcChannels.PREVIEW_OPEN_LINK_CHANNEL, wrappedListener);
481
},
482
+ onFindResult: (listener) => {
483
+ const wrappedListener = (_event: Electron.IpcRendererEvent, findEvent: unknown) => {
484
+ if (typeof findEvent !== "object" || findEvent === null) return;
485
+ listener(findEvent as DesktopPreviewFindResultEvent);
486
+ };
487
+ ipcRenderer.on(IpcChannels.PREVIEW_FIND_RESULT_CHANNEL, wrappedListener);
488
+ return () =>
489
+ ipcRenderer.removeListener(IpcChannels.PREVIEW_FIND_RESULT_CHANNEL, wrappedListener);
490
+ },
491
},
492
} satisfies DesktopBridge);
apps/desktop/src/preview/GuestProtocol.ts
+1
@@ -6,6 +6,7 @@ export const ANNOTATION_THEME_CHANNEL = "preview:annotation-theme";
6
export const ANNOTATION_SEND_ENABLED_CHANNEL = "preview:annotation-send-enabled";
7
export const HUMAN_INPUT_CHANNEL = "preview:human-input";
8
export const MOUSE_NAVIGATE_CHANNEL = "preview:mouse-navigate";
9
+export const PAGE_UNHANDLED_SHORTCUT_CHANNEL = "preview:page-unhandled-shortcut";
10
export const RECORDING_CURSOR_CHANNEL = "preview:recording-cursor";
11
export const RECORDING_POINTER_CHANNEL = "preview:recording-pointer";
12
export const RECORDING_KEY_CHANNEL = "preview:recording-key";
apps/desktop/src/preview/Manager.test.ts
+130
@@ -2,6 +2,7 @@ import { it as effectIt } from "@effect/vitest";
2
import * as NodeCrypto from "@effect/platform-node/NodeCrypto";
3
import * as NodeServices from "@effect/platform-node/NodeServices";
4
import type {
5
+ DesktopPreviewFindResultEvent,
6
DesktopPreviewRecordingInputEvent,
7
PreviewAnnotationPayload,
8
PreviewAnnotationRect,
@@ -812,6 +813,135 @@ describe("PreviewManager", () => {
813
),
814
);
815
816
+ effectIt.effect.each([
817
+ ["darwin", true],
818
+ ["linux", false],
819
+ ["win32", false],
820
+ ] as const)(
821
+ "lets the page and its iframes claim the find shortcut before the host opens find on %s",
822
+ ([platform, usesMeta]) =>
823
+ withManager(
824
+ (manager) =>
825
+ Effect.gen(function* () {
826
+ const preview = makeFaviconWebContents();
827
+ const send = vi.fn();
828
+ const mainFrame = { processId: 1, routingId: 1 };
829
+ Object.assign(preview.webContents, {
830
+ hostWebContents: { isDestroyed: () => false, send },
831
+ mainFrame,
832
+ focusedFrame: mainFrame,
833
+ });
834
+ fromId.mockReturnValue(preview.webContents);
835
+ yield* manager.createTab("tab_page_find");
836
+ yield* manager.registerWebview("tab_page_find", 42);
837
+ yield* manager.setForwardedShortcuts([
838
+ { command: "preview.find", shortcut: parseKeybindingShortcut("mod+f")! },
839
+ ]);
840
+ const beforeInput = preview.listeners.get("before-input-event")!;
841
+ const findKey = {
842
+ type: "keyDown",
843
+ key: "f",
844
+ code: "KeyF",
845
+ meta: usesMeta,
846
+ control: !usesMeta,
847
+ };
848
+ const preventDefault = vi.fn();
849
+
850
+ beforeInput(
851
+ { preventDefault } as never,
852
+ { ...findKey, shift: false, alt: false } as never,
853
+ );
854
+ expect(preventDefault).not.toHaveBeenCalled();
855
+ expect(send).not.toHaveBeenCalled();
856
+
857
+ const ipcOn = (preview.webContents as Electron.WebContents).ipc.on as ReturnType<
858
+ typeof vi.fn
859
+ >;
860
+ const pageUnhandledShortcut = ipcOn.mock.calls.find(
861
+ ([channel]) => channel === "preview:page-unhandled-shortcut",
862
+ )![1];
863
+ pageUnhandledShortcut(
864
+ {},
865
+ {
866
+ key: "f",
867
+ code: "KeyF",
868
+ metaKey: usesMeta,
869
+ ctrlKey: !usesMeta,
870
+ shiftKey: false,
871
+ altKey: false,
872
+ },
873
+ );
874
+ expect(send).toHaveBeenCalledExactlyOnceWith("desktop:menu-action", "preview.find");
875
+
876
+ Object.assign(preview.webContents, { focusedFrame: { processId: 1, routingId: 2 } });
877
+ beforeInput(
878
+ { preventDefault } as never,
879
+ { ...findKey, shift: false, alt: false } as never,
880
+ );
881
+ expect(preventDefault).not.toHaveBeenCalled();
882
+ expect(send).toHaveBeenCalledOnce();
883
+
884
+ Object.assign(preview.webContents, { focusedFrame: mainFrame });
885
+ yield* manager.setForwardedShortcuts([
886
+ { command: "preview.find", shortcut: parseKeybindingShortcut("ctrl+alt+8")! },
887
+ ]);
888
+ pageUnhandledShortcut(
889
+ {},
890
+ {
891
+ key: "[",
892
+ code: "Digit8",
893
+ metaKey: false,
894
+ ctrlKey: true,
895
+ shiftKey: false,
896
+ altKey: true,
897
+ },
898
+ );
899
+ expect(send).toHaveBeenCalledTimes(usesMeta ? 2 : 1);
900
+ }),
901
+ platform,
902
+ ),
903
+ );
904
+
905
+ effectIt.effect("searches the guest page and reports its match counts", () =>
906
+ withManager((manager) =>
907
+ Effect.gen(function* () {
908
+ const preview = makeFaviconWebContents();
909
+ const findInPage = vi.fn();
910
+ const stopFindInPage = vi.fn();
911
+ Object.assign(preview.webContents, { findInPage, stopFindInPage });
912
+ fromId.mockReturnValue(preview.webContents);
913
+ yield* manager.createTab("tab_find");
914
+ yield* manager.registerWebview("tab_find", 42);
915
+ const reported = yield* Deferred.make<DesktopPreviewFindResultEvent>();
916
+ yield* manager.subscribeFindResults((event) => Deferred.succeed(reported, event));
917
+
918
+ yield* manager.findInPage("tab_find", "needle", { forward: true, newSession: true });
919
+ expect(findInPage).toHaveBeenCalledExactlyOnceWith("needle", {
920
+ forward: true,
921
+ findNext: true,
922
+ });
923
+
924
+ preview.listeners.get("found-in-page")!(
925
+ {} as never,
926
+ {
927
+ requestId: 1,
928
+ activeMatchOrdinal: 2,
929
+ matches: 5,
930
+ finalUpdate: true,
931
+ } as never,
932
+ );
933
+ expect(yield* Deferred.await(reported)).toEqual({
934
+ tabId: "tab_find",
935
+ activeMatchOrdinal: 2,
936
+ matches: 5,
937
+ });
938
+
939
+ yield* manager.stopFindInPage("tab_find");
940
+ expect(stopFindInPage).toHaveBeenCalledExactlyOnceWith("clearSelection");
941
+ }),
942
+ ),
943
+ );
944
+
945
effectIt.effect("isolates failed state listeners and continues delivery", () => {
946
const loggedErrors: Array<unknown> = [];
947
const logger = Logger.make(({ message }) => {
apps/desktop/src/preview/Manager.ts
+113
-21
@@ -12,6 +12,7 @@ import type {
12
DesktopPreviewAnnotationVoiceState,
13
DesktopPreviewColorScheme,
14
DesktopPreviewFavicon,
15
+ DesktopPreviewFindResultEvent,
16
DesktopPreviewOpenLinkEvent,
17
DesktopPreviewPointerEvent,
18
PreviewAnnotationPayload,
@@ -80,6 +81,7 @@ import {
81
ELEMENT_PICKED_CHANNEL,
82
HUMAN_INPUT_CHANNEL,
83
MOUSE_NAVIGATE_CHANNEL,
84
+ PAGE_UNHANDLED_SHORTCUT_CHANNEL,
85
RECORDING_CURSOR_CHANNEL,
86
RECORDING_INPUT_CHANNEL,
87
RECORDING_CONTROLLER_CHANNEL,
@@ -437,6 +439,23 @@ type PointerEventListener = (event: DesktopPreviewPointerEvent) => Effect.Effect
439
440
type OpenLinkListener = (event: DesktopPreviewOpenLinkEvent) => Effect.Effect<void>;
441
442
+type FindResultListener = (event: DesktopPreviewFindResultEvent) => Effect.Effect<void>;
443
+
444
+const PAGE_FIRST_FORWARDED_COMMANDS: ReadonlySet<PreviewForwardedShortcut["command"]> = new Set([
445
+ "preview.find",
446
+]);
447
+
448
+const decodePageShortcutKeys = Schema.decodeUnknownOption(
449
+ Schema.Struct({
450
+ key: Schema.String,
451
+ code: Schema.String,
452
+ metaKey: Schema.Boolean,
453
+ ctrlKey: Schema.Boolean,
454
+ shiftKey: Schema.Boolean,
455
+ altKey: Schema.Boolean,
456
+ }),
457
+);
458
+
459
// about:blank inherits relaxed guest preferences; external editor schemes must reach the OS handler.
460
const POPUP_PROTOCOLS = new Set(["http:", "https:"]);
461
@@ -557,6 +576,7 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
576
const listenersRef = yield* Ref.make<ReadonlySet<Listener>>(new Set());
577
const pointerEventListenersRef = yield* Ref.make<ReadonlySet<PointerEventListener>>(new Set());
578
const openLinkListenersRef = yield* Ref.make<ReadonlySet<OpenLinkListener>>(new Set());
579
+ const findResultListenersRef = yield* Ref.make<ReadonlySet<FindResultListener>>(new Set());
580
const recordingInputListenersRef = yield* Ref.make<ReadonlySet<RecordingInputListener>>(
581
new Set(),
582
);
@@ -822,7 +842,7 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
842
});
843
844
const deliverEvent = (
825
- eventKind: "state-change" | "recording-input" | "pointer-event" | "open-link",
845
+ eventKind: "state-change" | "recording-input" | "pointer-event" | "open-link" | "find-result",
846
tabId: string,
847
delivery: () => Effect.Effect<void>,
848
) =>
@@ -1425,6 +1445,17 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
1445
}),
1446
);
1447
};
1448
+ // Chromium splits one search across several updates (the ordinal and the
1449
+ // final count can land separately), so every update is forwarded.
1450
+ const foundInPage = (_event: unknown, result: Electron.Result): void => {
1451
+ runFork(
1452
+ emitFindResult({
1453
+ tabId,
1454
+ activeMatchOrdinal: result.activeMatchOrdinal,
1455
+ matches: result.matches,
1456
+ }),
1457
+ );
1458
+ };
1459
const humanInput = (_event: unknown, rawSignal?: unknown): void => {
1460
runFork(handleHumanInput(rawSignal));
1461
};
@@ -1461,6 +1492,20 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
1492
syncMenuShortcuts(window.webContents, input);
1493
});
1494
};
1495
+ const findForwardedShortcut = (keys: Parameters<typeof matchesKeybindingShortcut>[0]) =>
1496
+ !(
1497
+ hostPlatform !== "darwin" &&
1498
+ keys.ctrlKey &&
1499
+ keys.altKey &&
1500
+ /^(?:[^a-zA-Z0-9]|Dead)$/u.test(keys.key)
1501
+ ) &&
1502
+ forwardedShortcuts.find(({ shortcut }) =>
1503
+ matchesKeybindingShortcut(
1504
+ keys,
1505
+ shortcut,
1506
+ hostPlatform === "darwin" ? "MacIntel" : hostPlatform,
1507
+ ),
1508
+ );
1509
const beforeInput = (event: Electron.Event, input: Electron.Input): void => {
1510
syncMenuShortcuts(wc, input);
1511
const host = wc.hostWebContents;
@@ -1470,27 +1515,18 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
1515
host &&
1516
!host.isDestroyed() &&
1517
holdsKeyboardFocus(wc) &&
1473
- !(
1474
- hostPlatform !== "darwin" &&
1475
- input.control &&
1476
- input.alt &&
1477
- /^(?:[^a-zA-Z0-9]|Dead)$/u.test(input.key)
1478
- ) &&
1479
- forwardedShortcuts.find(({ shortcut }) =>
1480
- matchesKeybindingShortcut(
1481
- {
1482
- key: input.key,
1483
- code: input.code,
1484
- metaKey: input.meta,
1485
- ctrlKey: input.control,
1486
- shiftKey: input.shift,
1487
- altKey: input.alt,
1488
- },
1489
- shortcut,
1490
- hostPlatform === "darwin" ? "MacIntel" : hostPlatform,
1491
- ),
1492
- );
1518
+ findForwardedShortcut({
1519
+ key: input.key,
1520
+ code: input.code,
1521
+ metaKey: input.meta,
1522
+ ctrlKey: input.control,
1523
+ shiftKey: input.shift,
1524
+ altKey: input.alt,
1525
+ });
1526
if (forwarded && host) {
1527
+ // The page keeps these keys. Only the main-frame preload can report one it
1528
+ // left unhandled, so a focused iframe (e.g. Google Docs' input) keeps its own find.
1529
+ if (PAGE_FIRST_FORWARDED_COMMANDS.has(forwarded.command)) return;
1530
event.preventDefault();
1531
if (!input.isAutoRepeat) {
1532
if (
@@ -1515,6 +1551,15 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
1551
return;
1552
}
1553
};
1554
+ const pageUnhandledShortcut = (_event: unknown, rawKeys?: unknown): void => {
1555
+ const host = wc.hostWebContents;
1556
+ if (!host || host.isDestroyed() || !holdsKeyboardFocus(wc)) return;
1557
+ const keys = decodePageShortcutKeys(rawKeys);
1558
+ if (Option.isNone(keys)) return;
1559
+ const forwarded = findForwardedShortcut(keys.value);
1560
+ if (!forwarded || !PAGE_FIRST_FORWARDED_COMMANDS.has(forwarded.command)) return;
1561
+ host.send(MENU_ACTION_CHANNEL, forwarded.command);
1562
+ };
1563
yield* Scope.addFinalizer(
1564
scope,
1565
attempt({ operation: "detachListeners", tabId, webContentsId: wc.id }, () => {
@@ -1529,11 +1574,13 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
1574
wc.off("dom-ready", restoreRecordingCursor);
1575
wc.off("did-fail-load", failed as never);
1576
wc.off("audio-state-changed", audioStateChanged);
1577
+ wc.off("found-in-page", foundInPage as never);
1578
wc.off("did-create-window", windowCreated);
1579
wc.off("before-input-event", beforeInput);
1580
wc.ipc.off(HUMAN_INPUT_CHANNEL, humanInput);
1581
wc.ipc.off(RECORDING_INPUT_CHANNEL, recordingInput);
1582
wc.ipc.off(MOUSE_NAVIGATE_CHANNEL, mouseNavigate);
1583
+ wc.ipc.off(PAGE_UNHANDLED_SHORTCUT_CHANNEL, pageUnhandledShortcut);
1584
detachPasskeys();
1585
}).pipe(Effect.ignore),
1586
);
@@ -1550,9 +1597,11 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
1597
wc.on("dom-ready", restoreRecordingCursor);
1598
wc.on("did-fail-load", failed as never);
1599
wc.on("audio-state-changed", audioStateChanged);
1600
+ wc.on("found-in-page", foundInPage as never);
1601
wc.ipc.on(HUMAN_INPUT_CHANNEL, humanInput);
1602
wc.ipc.on(RECORDING_INPUT_CHANNEL, recordingInput);
1603
wc.ipc.on(MOUSE_NAVIGATE_CHANNEL, mouseNavigate);
1604
+ wc.ipc.on(PAGE_UNHANDLED_SHORTCUT_CHANNEL, pageUnhandledShortcut);
1605
detachPasskeys = passkeys.attachGuest(wc);
1606
wc.setWindowOpenHandler((details) => {
1607
const action = previewWindowOpenAction(details);
@@ -2052,6 +2101,22 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
2101
const refresh = (tabId: string) => withWebContents("refresh", tabId, (wc) => wc.reload());
2102
const hardReload = (tabId: string) =>
2103
withWebContents("hardReload", tabId, (wc) => wc.reloadIgnoringCache());
2104
+ const findInPage = (
2105
+ tabId: string,
2106
+ text: string,
2107
+ options: { readonly forward: boolean; readonly newSession: boolean },
2108
+ ) =>
2109
+ withWebContents("findInPage", tabId, (wc) => {
2110
+ // Electron's `findNext` means "begin a new session", not "go to the next match".
2111
+ wc.findInPage(text, { forward: options.forward, findNext: options.newSession });
2112
+ });
2113
+ const stopFindInPage = (tabId: string) =>
2114
+ withWebContents("stopFindInPage", tabId, (wc) => wc.stopFindInPage("clearSelection")).pipe(
2115
+ Effect.catchTags({
2116
+ PreviewTabNotFoundError: () => Effect.void,
2117
+ PreviewWebContentsNotFoundError: () => Effect.void,
2118
+ }),
2119
+ );
2120
2121
const openDevTools = Effect.fn("PreviewManager.openDevTools")(function* (tabId: string) {
2122
const wc = yield* requireWebContents(tabId);
@@ -3345,6 +3410,16 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
3410
{ discard: true },
3411
);
3412
});
3413
+ const emitFindResult = Effect.fn("PreviewManager.emitFindResult")(function* (
3414
+ event: DesktopPreviewFindResultEvent,
3415
+ ) {
3416
+ const listeners = yield* Ref.get(findResultListenersRef);
3417
+ yield* Effect.forEach(
3418
+ listeners,
3419
+ (listener) => deliverEvent("find-result", event.tabId, () => listener(event)),
3420
+ { discard: true },
3421
+ );
3422
+ });
3423
const subscribe = <A>(
3424
ref: Ref.Ref<ReadonlySet<A>>,
3425
listener: A,
@@ -3367,6 +3442,7 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
3442
Ref.set(listenersRef, new Set()),
3443
Ref.set(pointerEventListenersRef, new Set()),
3444
Ref.set(openLinkListenersRef, new Set()),
3445
+ Ref.set(findResultListenersRef, new Set()),
3446
Ref.set(recordingInputListenersRef, new Set()),
3447
],
3448
{ discard: true },
@@ -3381,6 +3457,7 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
3457
closeTab,
3458
copyArtifactToClipboard,
3459
createTab,
3460
+ findInPage,
3461
goBack,
3462
goForward,
3463
hardReload,
@@ -3410,10 +3487,13 @@ const makeNativeOperations = Effect.fn("PreviewManager.makeOperations")(function
3487
}),
3488
startRecording,
3489
closePictureInPicture,
3490
+ stopFindInPage,
3491
stopRecording,
3492
subscribePointerEvents: (listener: PointerEventListener) =>
3493
subscribe(pointerEventListenersRef, listener),
3494
subscribeOpenLinks: (listener: OpenLinkListener) => subscribe(openLinkListenersRef, listener),
3495
+ subscribeFindResults: (listener: FindResultListener) =>
3496
+ subscribe(findResultListenersRef, listener),
3497
subscribeRecordingInputs: (listener: RecordingInputListener) =>
3498
subscribe(recordingInputListenersRef, listener),
3499
subscribeStateChanges: (listener: Listener) => subscribe(listenersRef, listener),
@@ -3595,6 +3675,12 @@ export class PreviewManager extends Context.Service<
3675
readonly resetZoom: (tabId: string) => Effect.Effect<void, PreviewManagerError>;
3676
readonly reapplyZoom: () => Effect.Effect<void>;
3677
readonly hardReload: (tabId: string) => Effect.Effect<void, PreviewManagerError>;
3678
+ readonly findInPage: (
3679
+ tabId: string,
3680
+ text: string,
3681
+ options: { readonly forward: boolean; readonly newSession: boolean },
3682
+ ) => Effect.Effect<void, PreviewManagerError>;
3683
+ readonly stopFindInPage: (tabId: string) => Effect.Effect<void, PreviewManagerError>;
3684
readonly setColorScheme: (
3685
tabId: string,
3686
colorScheme: DesktopPreviewColorScheme,
@@ -3659,6 +3745,9 @@ export class PreviewManager extends Context.Service<
3745
readonly subscribeOpenLinks: (
3746
listener: OpenLinkListener,
3747
) => Effect.Effect<void, never, Scope.Scope>;
3748
+ readonly subscribeFindResults: (
3749
+ listener: FindResultListener,
3750
+ ) => Effect.Effect<void, never, Scope.Scope>;
3751
readonly subscribeRecordingInputs: (
3752
listener: RecordingInputListener,
3753
) => Effect.Effect<void, never, Scope.Scope>;
@@ -3760,6 +3849,8 @@ export const make = Effect.gen(function* PreviewManagerMake() {
3849
resetZoom: operations.resetZoom,
3850
reapplyZoom: operations.reapplyZoom,
3851
hardReload: operations.hardReload,
3852
+ findInPage: operations.findInPage,
3853
+ stopFindInPage: operations.stopFindInPage,
3854
setColorScheme: operations.setColorScheme,
3855
setZoomFactor: operations.setZoomFactor,
3856
setAudioMuted: operations.setAudioMuted,
@@ -3808,6 +3899,7 @@ export const make = Effect.gen(function* PreviewManagerMake() {
3899
subscribeStateChanges: operations.subscribeStateChanges,
3900
subscribePointerEvents: operations.subscribePointerEvents,
3901
subscribeOpenLinks: operations.subscribeOpenLinks,
3902
+ subscribeFindResults: operations.subscribeFindResults,
3903
subscribeRecordingInputs: operations.subscribeRecordingInputs,
3904
});
3905
}).pipe(Effect.withSpan("PreviewManager.make"));
apps/desktop/src/preview/PickPreload.ts
+21
@@ -33,6 +33,7 @@ import {
33
ELEMENT_PICKED_CHANNEL,
34
HUMAN_INPUT_CHANNEL,
35
MOUSE_NAVIGATE_CHANNEL,
36
+ PAGE_UNHANDLED_SHORTCUT_CHANNEL,
37
RECORDING_CURSOR_CHANNEL,
38
RECORDING_POINTER_CHANNEL,
39
RECORDING_KEY_CHANNEL,
@@ -204,6 +205,26 @@ const reportHumanKeyInput = (event: KeyboardEvent): void => {
205
window.addEventListener("pointerdown", reportHumanPointerInput, true);
206
window.addEventListener("keydown", reportHumanKeyInput, true);
207
208
+// Capture runs before a page can stop the event; the task delay lets every page
209
+// listener call preventDefault before the host is told the key went unhandled.
210
+const reportUnhandledShortcut = (event: KeyboardEvent): void => {
211
+ if (!event.isTrusted || event.repeat || event.isComposing) return;
212
+ if (!event.metaKey && !event.ctrlKey && !event.altKey && !/^F\d{1,2}$/u.test(event.key)) return;
213
+ setTimeout(() => {
214
+ if (event.defaultPrevented) return;
215
+ ipcRenderer.send(PAGE_UNHANDLED_SHORTCUT_CHANNEL, {
216
+ key: event.key,
217
+ code: event.code,
218
+ metaKey: event.metaKey,
219
+ ctrlKey: event.ctrlKey,
220
+ shiftKey: event.shiftKey,
221
+ altKey: event.altKey,
222
+ });
223
+ }, 0);
224
+};
225
+
226
+window.addEventListener("keydown", reportUnhandledShortcut, true);
227
+
228
const MOUSE_BUTTON_BACK = 3;
229
const MOUSE_BUTTON_FORWARD = 4;
230
apps/web/src/components/CommandPalette.tsx
+29
-1
@@ -80,6 +80,8 @@ import {
80
UserPlusIcon,
81
} from "lucide-react";
82
import { openThreadFind } from "./chat/threadFindStore";
83
+import { dispatchPreviewAction } from "./preview/previewActionBus";
84
+import { previewBridge } from "./preview/previewBridge";
85
import {
86
useDeferredValue,
87
useEffect,
@@ -164,7 +166,11 @@ import {
166
useCommandPaletteMount,
167
useCommandPaletteStore,
168
} from "../commandPaletteStore";
167
-import { PULL_REQUESTS_PANEL_REF, useRightPanelStore } from "../rightPanelStore";
169
+import {
170
+ PULL_REQUESTS_PANEL_REF,
171
+ selectActiveRightPanel,
172
+ useRightPanelStore,
173
+} from "../rightPanelStore";
174
import { getLatestThreadForProject, sortThreads } from "@t3tools/client-runtime/state/thread-sort";
175
import {
176
cn,
@@ -676,6 +682,14 @@ function OpenCommandPaletteDialog(props: {
682
const activeThreadKey = activeThread
683
? scopedThreadKey(scopeThreadRef(activeThread.environmentId, activeThread.id))
684
: null;
685
+ const previewPanelThreadRef = activeThread
686
+ ? scopeThreadRef(activeThread.environmentId, activeThread.id)
687
+ : activeDraftThread
688
+ ? scopeThreadRef(activeDraftThread.environmentId, activeDraftThread.threadId)
689
+ : null;
690
+ const activeThreadPreviewOpen = useRightPanelStore(
691
+ (state) => selectActiveRightPanel(state.byThreadKey, previewPanelThreadRef) === "preview",
692
+ );
693
const supportsThreadFind =
694
environments.find((environment) => environment.environmentId === activeThread?.environmentId)
695
?.serverConfig?.threadFind === true;
@@ -1343,6 +1357,20 @@ function OpenCommandPaletteDialog(props: {
1357
});
1358
}
1359
1360
+ if (activeThreadPreviewOpen && previewBridge) {
1361
+ actionItems.push({
1362
+ kind: "action",
1363
+ value: "find-in-browser-page",
1364
+ title: "Find on page in browser",
1365
+ searchTerms: ["find", "search", "browser", "preview", "page"],
1366
+ icon: <TextSearchIcon className={ITEM_ICON_CLASS} />,
1367
+ shortcutCommand: "preview.find",
1368
+ run: async () => {
1369
+ dispatchPreviewAction("find");
1370
+ },
1371
+ });
1372
+ }
1373
+
1374
const promptLinkTarget = paletteRouteTarget
1375
? paletteRouteTarget.kind === "server"
1376
? paletteRouteTarget.threadRef
apps/web/src/components/ReopenClosedViewShortcut.tsx
+1
@@ -50,6 +50,7 @@ const PREVIEW_FORWARDED_COMMANDS = [
50
"rightPanel.toggle",
51
"rightPanel.toggleMaximized",
52
"preview.focusUrl",
53
+ "preview.find",
54
] as const;
55
56
const isGlobalPullRequests = (ref: ScopedThreadRef) =>
apps/web/src/components/preview/PreviewFindBar.tsx
new
+139
@@ -0,0 +1,139 @@
1
+import { useEffect, useRef, useState, type KeyboardEvent } from "react";
2
+import { ChevronDownIcon, ChevronUpIcon, XIcon } from "lucide-react";
3
+import { Button } from "../ui/button";
4
+import { InputGroup, InputGroupAddon, InputGroupInput } from "../ui/input-group";
5
+import { cn } from "~/lib/utils";
6
+import { previewBridge } from "./previewBridge";
7
+
8
+interface PreviewFindBarProps {
9
+ readonly tabId: string;
10
+ readonly focusRequestId: number;
11
+ readonly onClose: () => void;
12
+}
13
+
14
+export function PreviewFindBar({ tabId, focusRequestId, onClose }: PreviewFindBarProps) {
15
+ const inputRef = useRef<HTMLInputElement | null>(null);
16
+ const [query, setQuery] = useState("");
17
+ const [result, setResult] = useState<{ active: number; matches: number } | null>(null);
18
+
19
+ // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- focuses and selects the input DOM node when the bar opens or a find shortcut fires
20
+ useEffect(() => {
21
+ inputRef.current?.focus();
22
+ inputRef.current?.select();
23
+ // oxlint-disable-next-line react/exhaustive-effect-dependencies -- Each find shortcut bumps the request id, so an already-open bar refocuses and reselects its query.
24
+ }, [focusRequestId]);
25
+
26
+ // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- subscribes to Chromium find results for this tab and stops the search on unmount
27
+ useEffect(() => {
28
+ if (!previewBridge) return;
29
+ const unsubscribe = previewBridge.onFindResult((event) => {
30
+ if (event.tabId !== tabId) return;
31
+ // Chromium reports -1 for a field an update leaves unchanged.
32
+ setResult((previous) => ({
33
+ active: event.activeMatchOrdinal >= 0 ? event.activeMatchOrdinal : (previous?.active ?? 0),
34
+ matches: event.matches >= 0 ? event.matches : (previous?.matches ?? 0),
35
+ }));
36
+ });
37
+ return () => {
38
+ unsubscribe();
39
+ void previewBridge?.stopFindInPage(tabId).catch(() => undefined);
40
+ };
41
+ }, [tabId]);
42
+
43
+ const search = (text: string, options: { forward: boolean; newSession: boolean }) => {
44
+ if (!previewBridge) return;
45
+ void previewBridge.findInPage(tabId, text, options).catch(() => undefined);
46
+ };
47
+
48
+ const handleQueryChange = (next: string) => {
49
+ setQuery(next);
50
+ if (next.length === 0) {
51
+ setResult(null);
52
+ void previewBridge?.stopFindInPage(tabId).catch(() => undefined);
53
+ return;
54
+ }
55
+ search(next, { forward: true, newSession: true });
56
+ };
57
+
58
+ const step = (forward: boolean) => {
59
+ if (query.length === 0) return;
60
+ search(query, { forward, newSession: false });
61
+ };
62
+
63
+ const handleKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {
64
+ if (event.nativeEvent.isComposing || event.nativeEvent.keyCode === 229) return;
65
+ if (event.key === "Enter") {
66
+ event.preventDefault();
67
+ event.stopPropagation();
68
+ step(!event.shiftKey);
69
+ } else if (event.key === "Escape") {
70
+ event.preventDefault();
71
+ event.stopPropagation();
72
+ onClose();
73
+ }
74
+ };
75
+
76
+ const hasQuery = query.length > 0;
77
+ const noResults = hasQuery && result !== null && result.matches === 0;
78
+ const label =
79
+ hasQuery && result ? `${result.matches === 0 ? 0 : result.active}/${result.matches}` : "";
80
+ const navigationDisabled = !result || result.matches === 0;
81
+
82
+ return (
83
+ <div className="absolute top-3 right-3 z-40 w-[min(22rem,calc(100%-1.5rem))]">
84
+ <InputGroup
85
+ variant="popover"
86
+ size="lg"
87
+ role="search"
88
+ aria-label="Find in page"
89
+ className="w-full"
90
+ >
91
+ <InputGroupInput
92
+ ref={inputRef}
93
+ type="search"
94
+ size="sm"
95
+ value={query}
96
+ aria-label="Find in page"
97
+ placeholder="Find in page"
98
+ maxLength={200}
99
+ spellCheck={false}
100
+ autoComplete="off"
101
+ onChange={(event) => handleQueryChange(event.target.value)}
102
+ onKeyDown={handleKeyDown}
103
+ />
104
+ <InputGroupAddon align="inline-end" inset="pill">
105
+ <span
106
+ aria-live="polite"
107
+ className={cn(
108
+ "min-w-10 text-center text-xs tabular-nums",
109
+ noResults ? "text-destructive" : "text-muted-foreground",
110
+ )}
111
+ >
112
+ {label}
113
+ </span>
114
+ <Button
115
+ size="icon-xs"
116
+ variant="ghost"
117
+ aria-label="Previous match"
118
+ disabled={navigationDisabled}
119
+ onClick={() => step(false)}
120
+ >
121
+ <ChevronUpIcon />
122
+ </Button>
123
+ <Button
124
+ size="icon-xs"
125
+ variant="ghost"
126
+ aria-label="Next match"
127
+ disabled={navigationDisabled}
128
+ onClick={() => step(true)}
129
+ >
130
+ <ChevronDownIcon />
131
+ </Button>
132
+ <Button size="icon-xs" variant="ghost" aria-label="Close find" onClick={onClose}>
133
+ <XIcon />
134
+ </Button>
135
+ </InputGroupAddon>
136
+ </InputGroup>
137
+ </div>
138
+ );
139
+}
apps/web/src/components/preview/PreviewMoreMenu.tsx
+10
@@ -6,6 +6,7 @@ import {
6
Menu,
7
MenuItem,
8
MenuPopup,
9
+ MenuShortcut,
10
MenuRadioGroup,
11
MenuRadioItem,
12
MenuGroup,
@@ -37,6 +38,7 @@ export interface PreviewMoreMenuActions {
38
readonly clearCache: () => void;
39
readonly openDevTools?: () => void;
40
readonly toggleNativePictureInPicture?: () => void;
41
+ readonly find?: () => void;
42
}
43
44
interface Props {
@@ -48,6 +50,7 @@ interface Props {
50
onToggleDeviceToolbar: () => void;
51
nativePictureInPicture: boolean;
52
profileName: string | undefined;
53
+ findShortcutLabel?: string | null;
54
move?: { readonly label: string; readonly onMove: () => void };
55
}
56
@@ -75,6 +78,7 @@ export function PreviewMoreMenu({
78
onToggleDeviceToolbar,
79
nativePictureInPicture,
80
profileName,
81
+ findShortcutLabel,
82
move,
83
}: Props) {
84
const zoomLabel = `${Math.round(zoomFactor * 100)}%`;
@@ -83,6 +87,12 @@ export function PreviewMoreMenu({
87
<Menu>
88
<MenuTriggerButton />
89
<MenuPopup align="end" sideOffset={6}>
90
+ {actions.find ? (
91
+ <MenuItem onClick={actions.find} disabled={disabled}>
92
+ Find on page
93
+ {findShortcutLabel ? <MenuShortcut>{findShortcutLabel}</MenuShortcut> : null}
94
+ </MenuItem>
95
+ ) : null}
96
<MenuItem onClick={actions.hardReload} disabled={disabled}>
97
Hard reload
98
</MenuItem>
apps/web/src/components/preview/PreviewView.browser.test.tsx
+20
@@ -73,6 +73,9 @@ vi.mock(import("./previewBridge"), async (original) => ({
73
open: mocks.openPictureInPicture,
74
close: mocks.closePictureInPicture,
75
},
76
+ findInPage: vi.fn(async () => undefined),
77
+ stopFindInPage: vi.fn(async () => undefined),
78
+ onFindResult: vi.fn(() => () => undefined),
79
} as never,
80
}));
81
vi.mock(import("~/browserHistoryStore"), async (original) => ({
@@ -388,4 +391,21 @@ describe("PreviewView", () => {
391
act(() => dispatchPreviewAction("focus-url"));
392
await expect.element(address).toHaveFocus();
393
});
394
+
395
+ it("does not reopen find when the user returns to a tab they left with find open", async () => {
396
+ setup();
397
+ const tabView = (tabId: string) => (
398
+ <PreviewView threadRef={TEST_THREAD_REF} tabId={tabId} visible />
399
+ );
400
+ await using screen = await render(tabView("tab-1"));
401
+ const findBar = page.getByRole("search", { name: "Find in page" });
402
+
403
+ act(() => dispatchPreviewAction("find"));
404
+ await expect.element(findBar).toBeInTheDocument();
405
+
406
+ await screen.rerender(tabView("tab-2"));
407
+ await expect.element(findBar).not.toBeInTheDocument();
408
+ await screen.rerender(tabView("tab-1"));
409
+ await expect.element(findBar).not.toBeInTheDocument();
410
+ });
411
});
apps/web/src/components/preview/PreviewView.tsx
+54
-2
@@ -59,7 +59,7 @@ import {
59
import { readEnvironmentScope, useEnvironmentScope } from "~/state/session";
60
import { useRightPanelStore } from "~/rightPanelStore";
61
62
-import { effectiveShortcutsForCommand } from "~/keybindings";
62
+import { effectiveShortcutsForCommand, shortcutLabelForCommand } from "~/keybindings";
63
import { randomUUID } from "~/lib/utils";
64
import { primaryServerKeybindingsAtom } from "~/state/server";
65
import { PreviewAnnotationSpeech } from "./PreviewAnnotationSpeech";
@@ -90,6 +90,7 @@ import { useBrowserSurfaceStore } from "~/browser/browserSurfaceStore";
90
import { usePreviewSession } from "./usePreviewSession";
91
import { ZoomIndicator } from "./ZoomIndicator";
92
import { AgentBrowserCursor } from "./AgentBrowserCursor";
93
+import { PreviewFindBar } from "./PreviewFindBar";
94
import {
95
findActiveBrowserRecordingRuntimeTabId,
96
isBrowserRecordingStartCancelledError,
@@ -145,6 +146,14 @@ function ServerTabFileNotShown(props: {
146
);
147
}
148
149
+function focusPreviewPage(runtimeTabId: string) {
150
+ const active = document.activeElement;
151
+ if (active && active !== document.body && !active.closest("[data-preview-panel-mode]")) return;
152
+ document
153
+ .querySelector<HTMLElement>(`[data-preview-viewport="${CSS.escape(runtimeTabId)}"] webview`)
154
+ ?.focus();
155
+}
156
+
157
export function PreviewView({
158
threadRef,
159
tabId: requestedTabId,
@@ -153,6 +162,7 @@ export function PreviewView({
162
onSendAnnotation,
163
}: Props) {
164
const urlInputRef = useRef<HTMLInputElement | null>(null);
165
+ const [find, setFind] = useState<{ tabId: string; requestId: number } | null>(null);
166
const [pickActive, setPickActive] = useState(false);
167
const canSendAnnotation =
168
useEnvironmentScope(threadRef.environmentId, AuthOrchestrationOperateScope) &&
@@ -186,6 +196,7 @@ export function PreviewView({
196
const runtimeTabId = tabId
197
? previewRuntimeTabId(threadRef, previewState.serverEpoch, tabId)
198
: null;
199
+ if (find !== null && find.tabId !== runtimeTabId) setFind(null);
200
const recordingRuntimeTabId =
201
tabId && runtimeTabId
202
? activeRecordingTabIds.has(runtimeTabId)
@@ -247,6 +258,7 @@ export function PreviewView({
258
if (runtimeTabId && previewBridge) {
259
await previewBridge.navigate(runtimeTabId, resolvedUrl);
260
rememberPreviewUrl(threadRef, resolvedUrl);
261
+ focusPreviewPage(runtimeTabId);
262
return true;
263
}
264
const result = await openPreviewSession({ openPreview: open, threadRef, url: resolvedUrl });
@@ -342,6 +354,27 @@ export function PreviewView({
354
if (next !== serverZoomFactor) void adjustServerTab({ zoomFactor: next });
355
};
356
357
+ const canFindInPage =
358
+ previewBridge !== null &&
359
+ runtimeTabId !== null &&
360
+ desktopOverlay !== null &&
361
+ !isServerTab &&
362
+ !showEmptyState &&
363
+ !isUnreachable;
364
+ const handleFind = () => {
365
+ if (!canFindInPage) {
366
+ toastManager.add({ type: "info", title: "Find on page isn't available for this page" });
367
+ return;
368
+ }
369
+ setFind((previous) => ({ tabId: runtimeTabId, requestId: (previous?.requestId ?? 0) + 1 }));
370
+ };
371
+
372
+ // Otherwise focus falls to the body and the next find shortcut misses the preview.
373
+ const closeFind = () => {
374
+ setFind(null);
375
+ if (runtimeTabId) focusPreviewPage(runtimeTabId);
376
+ };
377
+
378
const handleZoomIn = () => {
379
if (serverOwnsRendering) stepServerZoom(1);
380
else if (previewBridge && runtimeTabId) void previewBridge.zoomIn(runtimeTabId);
@@ -455,6 +488,7 @@ export function PreviewView({
488
? {
489
openDevTools: desktopCall(previewBridge.openDevTools),
490
toggleNativePictureInPicture: () => handleNativePictureInPicture(),
491
+ ...(canFindInPage ? { find: handleFind } : {}),
492
}
493
: {}),
494
}
@@ -478,6 +512,7 @@ export function PreviewView({
512
.catch(() => undefined),
513
openDevTools: desktopCall(previewBridge.openDevTools),
514
toggleNativePictureInPicture: () => handleNativePictureInPicture(),
515
+ ...(canFindInPage ? { find: handleFind } : {}),
516
}
517
: null;
518
@@ -872,17 +907,23 @@ export function PreviewView({
907
case "reset-zoom":
908
handleResetZoom();
909
return;
910
+ case "find":
911
+ handleFind();
912
+ return;
913
case "toggle-panel":
914
return;
915
}
916
},
917
);
880
- // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- subscribes to preview actions while the view is visible
918
+ // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- subscribes to preview and desktop menu actions while the view is visible
919
useEffect(() => {
920
if (!visible) return;
921
const unsubscribeAction = subscribePreviewAction((action) => onPreviewAction(action));
922
+ // A focused page swallows its own keydowns, so the desktop forwards these
923
+ // shortcuts from the guest as menu actions instead.
924
const unsubscribeMenu = window.desktopBridge?.onMenuAction((action) => {
925
if (action === "preview.focusUrl") onPreviewAction("focus-url");
926
+ if (action === "preview.find") onPreviewAction("find");
927
});
928
return () => {
929
unsubscribeAction();
@@ -955,6 +996,9 @@ export function PreviewView({
996
? { move: { label: moveLabel, onMove: () => void handleMoveTab() } }
997
: {})}
998
profileName={activeProfileName}
999
+ findShortcutLabel={shortcutLabelForCommand(keybindings, "preview.find", {
1000
+ context: { previewFocus: true },
1001
+ })}
1002
zoomFactor={
1003
serverOwnsRendering ? serverZoomFactor : (desktopOverlay?.zoomFactor ?? 1)
1004
}
@@ -1059,6 +1103,14 @@ export function PreviewView({
1103
controller={controller}
1104
/>
1105
) : null}
1106
+ {find && canFindInPage && find.tabId === runtimeTabId ? (
1107
+ <PreviewFindBar
1108
+ key={find.tabId}
1109
+ tabId={find.tabId}
1110
+ focusRequestId={find.requestId}
1111
+ onClose={closeFind}
1112
+ />
1113
+ ) : null}
1114
{navStatus._tag === "LoadFailed" && navStatus.download ? (
1115
<div className="absolute inset-0 z-10 bg-background">
1116
<ServerTabFileNotShown
apps/web/src/components/preview/previewActionBus.ts
+2
-1
@@ -4,7 +4,8 @@ export type PreviewAction =
4
| "focus-url"
5
| "zoom-in"
6
| "zoom-out"
7
- | "reset-zoom";
7
+ | "reset-zoom"
8
+ | "find";
9
10
const EVENT_NAME = "t3code:preview-action";
11
apps/web/src/components/settings/KeybindingsSettings.logic.ts
+1
@@ -384,6 +384,7 @@ export function commandLabel(command: KeybindingCommand): string {
384
if (usagePeriod) return `Usage: Period: ${usagePeriod.label}`;
385
if (command === "view.reopenClosed") return "Reopen Closed Tab";
386
if (command === "preview.focusUrl") return "Preview: Focus URL";
387
+ if (command === "preview.find") return "Preview: Find on Page";
388
const raw = String(command);
389
if (raw.startsWith("script.") && raw.endsWith(".run")) {
390
return `Run Script: ${titleCaseCommandSegment(raw.slice("script.".length, -".run".length))}`;
apps/web/src/shortcuts/chatRouteCommands.ts
+1
@@ -168,6 +168,7 @@ export function installChatRouteCommands(router: AnyRouter): () => void {
168
"preview.zoomIn": previewCommand("zoom-in"),
169
"preview.zoomOut": previewCommand("zoom-out"),
170
"preview.resetZoom": previewCommand("reset-zoom"),
171
+ "preview.find": previewCommand("find"),
172
},
173
{
174
when: () =>
docs/user/keybindings.md
+7
@@ -153,6 +153,13 @@ update an older server to enable it. Select **Retry** if a search fails. It defa
153
`mod+f` outside terminals and previews. Press **Enter** or **Shift+Enter** to move between matches,
154
and **Escape** to close find.
155
156
+## Find on a browser page
157
+
158
+`preview.find` (`mod+f` while a browser has focus) searches the open page in the desktop app. It
159
+is also in the browser's **⋮** menu and the command palette. A page that handles `mod+f` itself,
160
+such as a code editor, keeps its own find. Use the **⋮** menu to reach the browser's find there.
161
+Streamed browser tabs and T3 Code in a web browser do not support it.
162
+
163
## Precedence
164
165
The last rule whose key and condition both match wins, even if it belongs to a
packages/contracts/src/ipc.ts
+20
@@ -635,6 +635,12 @@ export interface DesktopPreviewOpenLinkEvent {
635
background: boolean;
636
}
637
638
+export interface DesktopPreviewFindResultEvent {
639
+ tabId: string;
640
+ activeMatchOrdinal: number;
641
+ matches: number;
642
+}
643
+
644
export const DesktopPreviewRecordingInputSchema = Schema.Union([
645
Schema.Struct({
646
type: Schema.Literal("pointer"),
@@ -993,6 +999,13 @@ export const DesktopPreviewSetZoomFactorInputSchema = Schema.Struct({
999
zoomFactor: Schema.Number.check(Schema.isGreaterThan(0)),
1000
});
1001
1002
+export const DesktopPreviewFindInPageInputSchema = Schema.Struct({
1003
+ tabId: DesktopPreviewTabIdSchema,
1004
+ text: Schema.NonEmptyString.check(Schema.isMaxLength(1000)),
1005
+ forward: Schema.Boolean,
1006
+ newSession: Schema.Boolean,
1007
+});
1008
+
1009
export const DesktopPreviewSetAudioMutedInputSchema = Schema.Struct({
1010
tabId: DesktopPreviewTabIdSchema,
1011
audioMuted: Schema.Boolean,
@@ -1253,6 +1266,12 @@ export interface DesktopPreviewBridge {
1266
hardReload: (tabId: string) => Promise<void>;
1267
setColorScheme: (tabId: string, colorScheme: DesktopPreviewColorScheme) => Promise<void>;
1268
setAudioMuted: (tabId: string, audioMuted: boolean) => Promise<void>;
1269
+ findInPage: (
1270
+ tabId: string,
1271
+ text: string,
1272
+ options: { forward: boolean; newSession: boolean },
1273
+ ) => Promise<void>;
1274
+ stopFindInPage: (tabId: string) => Promise<void>;
1275
/** Tells the tab's server whether its webview is on screen. */
1276
setShown: (tabId: string, shown: boolean) => Promise<void>;
1277
openDevTools: (tabId: string) => Promise<void>;
@@ -1305,6 +1324,7 @@ export interface DesktopPreviewBridge {
1324
onStateChange: (listener: (tabId: string, state: DesktopPreviewTabState) => void) => () => void;
1325
onPointerEvent: (listener: (event: DesktopPreviewPointerEvent) => void) => () => void;
1326
onOpenLink: (listener: (event: DesktopPreviewOpenLinkEvent) => void) => () => void;
1327
+ onFindResult: (listener: (event: DesktopPreviewFindResultEvent) => void) => () => void;
1328
}
1329
1330
export type ConfirmDialogVariant = "default" | "destructive";
packages/contracts/src/keybindings.ts
+1
@@ -80,6 +80,7 @@ export const STATIC_KEYBINDING_COMMANDS = [
80
"preview.zoomIn",
81
"preview.zoomOut",
82
"preview.resetZoom",
83
+ "preview.find",
84
"commandPalette.toggle",
85
"filePicker.toggle",
86
"projectSearch.toggle",
packages/shared/src/keybindings.ts
+1
@@ -82,6 +82,7 @@ export const DEFAULT_KEYBINDINGS: ReadonlyArray<KeybindingRule> = [
82
{ key: "mod++", command: "preview.zoomIn", when: "previewFocus" },
83
{ key: "mod+-", command: "preview.zoomOut", when: "previewFocus" },
84
{ key: "mod+0", command: "preview.resetZoom", when: "previewFocus" },
85
+ { key: "mod+f", command: "preview.find", when: "previewFocus" },
86
{ key: "mod+k", command: "commandPalette.toggle", when: "!terminalFocus" },
87
{ key: "mod+p", command: "filePicker.toggle", when: "!terminalFocus" },
88
{ key: "mod+shift+f", command: "projectSearch.toggle", when: "!terminalFocus" },