The best way to control Claude Code, Codex and more from any computer or phone
fix(web): Cmd+F in the Files panel focuses its search (#34346)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Arman Arutiunov committed
Nov 11, 2026 at 22:14 UTC
eceeab4d5c5bb02b58906978ff9e50bbd595ec19
3 files changed
+63
-2
apps/web/src/components/files/FileBrowserPanel.browser.test.tsx
+29
@@ -4,8 +4,10 @@ import { page, userEvent } from "vite-plus/test/browser";
4
5
import { COMPOSER_MENTION_DRAG_TYPE } from "~/components/chat/composerMentionDrag";
6
import { dismissContextMenu } from "~/contextMenuFallback";
7
+import { isMacPlatform } from "~/lib/utils";
8
import { render } from "../../../test/render";
9
import FileBrowserPanel from "./FileBrowserPanel";
10
+import { dispatchPreviewAction } from "../preview/previewActionBus";
11
12
const entries: readonly ProjectEntry[] = [
13
{ path: "src", kind: "directory" },
@@ -115,4 +117,31 @@ describe("FileBrowserPanel", () => {
117
row.click();
118
await vi.waitFor(() => expect(onOpenFile).toHaveBeenCalledTimes(1));
119
});
120
+
121
+ it("mod+f from a tree row, or the panel find command, focuses the file search", async () => {
122
+ await using _screen = await render(
123
+ <FileBrowserPanel
124
+ environmentId={EnvironmentId.make("env-files")}
125
+ cwd="/repo"
126
+ projectName="repo"
127
+ selectedPath={null}
128
+ selectedPathRevealId={0}
129
+ onOpenFile={() => {}}
130
+ workspaceMutationId={null}
131
+ answersPanelFind
132
+ />,
133
+ );
134
+ await vi.waitFor(() => expect(findTreeRow("README.md")).not.toBeNull());
135
+ findTreeRow("README.md")!.focus();
136
+
137
+ const modifier = isMacPlatform(navigator.platform) ? "Meta" : "Control";
138
+ await userEvent.keyboard(`{${modifier}>}f{/${modifier}}`);
139
+
140
+ const search = page.getByRole("searchbox", { name: "Search repo files" });
141
+ await expect.element(search).toHaveFocus();
142
+
143
+ (search.element() as HTMLElement).blur();
144
+ dispatchPreviewAction("find");
145
+ await expect.element(search).toHaveFocus();
146
+ });
147
});
apps/web/src/components/files/FileBrowserPanel.tsx
+33
-2
@@ -10,7 +10,7 @@ import { serializeComposerFileLink } from "@t3tools/shared/composerTrigger";
10
import * as AsyncResult from "effect/reactivity/AsyncResult";
11
import * as Cause from "effect/Cause";
12
import { ChevronsDownUpIcon, ChevronsUpDownIcon } from "lucide-react";
13
-import { useEffect, useRef, useState } from "react";
13
+import { type Ref, useEffect, useEffectEvent, useRef, useState } from "react";
14
15
import { Button } from "~/components/ui/button";
16
import { InputGroup, InputGroupInput } from "~/components/ui/input-group";
@@ -33,6 +33,8 @@ import { buildFileTreePathUpdates } from "./fileTreePathReconciliation";
33
import { loadFileAncestors } from "./loadFileAncestors";
34
import { useDirectoryEntries } from "./useDirectoryEntries";
35
import { useProjectPathSearch } from "~/state/queries";
36
+import { isMacPlatform } from "~/lib/utils";
37
+import { type PreviewAction, subscribePreviewAction } from "../preview/previewActionBus";
38
39
interface FileBrowserPanelProps {
40
environmentId: EnvironmentId;
@@ -46,6 +48,7 @@ interface FileBrowserPanelProps {
48
hostFolder?: boolean;
49
onRefreshSelectedFile?: () => void;
50
workspaceMutationId: string | null;
51
+ answersPanelFind?: boolean;
52
}
53
54
function treePath(entry: ProjectEntry): string {
@@ -73,16 +76,21 @@ function RefreshFilesButton(props: { isPending: boolean; onRefresh: () => void }
76
);
77
}
78
76
-function FileSearchField(props: {
79
+function FileSearchField({
80
+ ref,
81
+ ...props
82
+}: {
83
ariaLabel: string;
84
name: string;
85
onClose: () => void;
86
onValueChange: (value: string) => void;
87
+ ref: Ref<HTMLInputElement>;
88
value: string;
89
}) {
90
return (
91
<InputGroup variant="ghost" className="h-7 min-w-0 flex-1">
92
<InputGroupInput
93
+ ref={ref}
94
type="search"
95
name={props.name}
96
size="sm"
@@ -142,6 +150,7 @@ export default function FileBrowserPanel({
150
onRefreshSelectedFile,
151
workspaceMutationId,
152
hostFolder = false,
153
+ answersPanelFind = false,
154
}: FileBrowserPanelProps) {
155
const panelPath = (relativePath: string) =>
156
hostFolder ? joinHostPath(cwd, relativePath) : relativePath;
@@ -320,6 +329,20 @@ export default function FileBrowserPanel({
329
setQuery("");
330
search.close();
331
};
332
+ const searchInputRef = useRef<HTMLInputElement>(null);
333
+ const focusSearch = () => {
334
+ searchInputRef.current?.focus();
335
+ searchInputRef.current?.select();
336
+ };
337
+ const onPanelAction = useEffectEvent((action: PreviewAction) => {
338
+ // Hidden panel tabs stay mounted; only the visible Files tab answers.
339
+ if (action === "find" && searchInputRef.current?.getClientRects().length) focusSearch();
340
+ });
341
+ // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- subscribes to the panel find command, which fires while focus is anywhere in the right panel
342
+ useEffect(() => {
343
+ if (!answersPanelFind) return;
344
+ return subscribePreviewAction(onPanelAction);
345
+ }, [answersPanelFind]);
346
const expandedPathsRef = useRef(new Set<string>());
347
// oxlint-disable-next-line t3code/no-unreasoned-state-sync -- subscribes to the Pierre tree model to load directories as they are expanded
348
useEffect(() => {
@@ -482,6 +505,13 @@ export default function FileBrowserPanel({
505
// Capture dragstart before the tree selects the row so selection sees the drag flag.
506
onDragStartCapture={(event) => dragMention.handleDragStart(event.nativeEvent)}
507
onDragEnd={() => dragMention.handleDragEnd((path) => model.getItem(path)?.deselect())}
508
+ onKeyDown={(event) => {
509
+ const isModPressed = isMacPlatform(navigator.platform) ? event.metaKey : event.ctrlKey;
510
+ if (!isModPressed || event.altKey || event.shiftKey || event.key.toLowerCase() !== "f")
511
+ return;
512
+ event.preventDefault();
513
+ focusSearch();
514
+ }}
515
>
516
<div
517
className="flex h-10 min-h-10 shrink-0 items-center gap-1 border-b border-border/60 bg-background px-2 in-data-[preview-panel-mode=inline]:mb-1 in-data-[preview-panel-mode=inline]:h-9 in-data-[preview-panel-mode=inline]:min-h-9 in-data-[preview-panel-mode=inline]:border-b-transparent"
@@ -489,6 +519,7 @@ export default function FileBrowserPanel({
519
>
520
<RefreshFilesButton isPending={isPending} onRefresh={handleRefresh} />
521
<FileSearchField
522
+ ref={searchInputRef}
523
name="project-files-search"
524
ariaLabel={`Search ${projectName} files`}
525
value={search.value}
apps/web/src/components/files/FilePreviewPanel.tsx
+1
@@ -1638,6 +1638,7 @@ export default function FilePreviewPanel({
1638
}
1639
selectedPathRevealId={revealRequestId}
1640
onOpenFile={onOpenFile}
1641
+ answersPanelFind={!previewPath}
1642
workspaceMutationId={workspaceMutationId}
1643
{...(previewPath && !isMedia && !isPdf
1644
? {