The best way to control Claude Code, Codex and more from any computer or phone
feat(web): allow resizing the file explorer (#25737)
Co-authored-by: Rishabh Bothra <37180068+07rjain@users.noreply.github.com>
maria committed
Oct 29, 2026 at 18:04 UTC
f06dd4bbf5ad19226344279effcaa5928ce452f0
4 files changed
+116
-18
apps/web/src/components/files/FileExplorerPane.tsx
new
+90
@@ -0,0 +1,90 @@
1
+import { type CSSProperties, type ReactNode, useState } from "react";
2
+
3
+import { RightPanelResizeHandle } from "~/components/preview/RightPanelResizeHandle";
4
+import { RESIZABLE_WIDTH_PROPERTY, useResizableWidth } from "~/hooks/useResizableWidth";
5
+import { observeResize } from "~/lib/observeResize";
6
+import { cn } from "~/lib/utils";
7
+
8
+const MIN_WIDTH = 160;
9
+const MAX_WIDTH = 560;
10
+const FILE_CONTENT_MIN_WIDTH = 256;
11
+
12
+export function FileExplorerPane({
13
+ resizable,
14
+ children,
15
+}: {
16
+ resizable: boolean;
17
+ children: ReactNode;
18
+}) {
19
+ const [maxWidth, setMaxWidth] = useState(MAX_WIDTH);
20
+ const { width, setWidth, handlers } = useResizableWidth({
21
+ storageKey: "t3code.fileExplorerWidth",
22
+ defaultWidth: 256,
23
+ minWidth: MIN_WIDTH,
24
+ maxWidth,
25
+ edge: "left",
26
+ });
27
+
28
+ return (
29
+ <aside
30
+ ref={(host) => {
31
+ const row = host?.parentElement;
32
+ if (!row || !resizable) return;
33
+ const measure = () =>
34
+ setMaxWidth(
35
+ Math.max(MIN_WIDTH, Math.min(MAX_WIDTH, row.clientWidth - FILE_CONTENT_MIN_WIDTH)),
36
+ );
37
+ measure();
38
+ return observeResize(row, measure);
39
+ }}
40
+ aria-label="File explorer"
41
+ className={cn(
42
+ "relative flex min-h-0 min-w-0 shrink-0 bg-background",
43
+ resizable ? "border-l border-border/60" : "flex-1",
44
+ )}
45
+ style={
46
+ resizable
47
+ ? ({
48
+ [RESIZABLE_WIDTH_PROPERTY]: `${width}px`,
49
+ width: `var(${RESIZABLE_WIDTH_PROPERTY})`,
50
+ } as CSSProperties)
51
+ : undefined
52
+ }
53
+ >
54
+ {resizable ? (
55
+ <RightPanelResizeHandle
56
+ handlers={handlers}
57
+ label="Resize file explorer"
58
+ tabIndex={0}
59
+ aria-valuenow={width}
60
+ aria-valuemin={MIN_WIDTH}
61
+ aria-valuemax={maxWidth}
62
+ onKeyDown={(event) => {
63
+ if (event.altKey || event.ctrlKey || event.metaKey) return;
64
+ let nextWidth: number;
65
+ switch (event.key) {
66
+ case "ArrowLeft":
67
+ nextWidth = width + 16;
68
+ break;
69
+ case "ArrowRight":
70
+ nextWidth = width - 16;
71
+ break;
72
+ case "Home":
73
+ nextWidth = MIN_WIDTH;
74
+ break;
75
+ case "End":
76
+ nextWidth = maxWidth;
77
+ break;
78
+ default:
79
+ return;
80
+ }
81
+ event.preventDefault();
82
+ event.stopPropagation();
83
+ setWidth(nextWidth);
84
+ }}
85
+ />
86
+ ) : null}
87
+ {children}
88
+ </aside>
89
+ );
90
+}
apps/web/src/components/files/FilePreviewPanel.tsx
+3
-9
@@ -84,6 +84,7 @@ import { BrowserDocumentFrame, isPdfPreviewFile } from "./BrowserDocumentFrame";
84
import { DelimitedTablePreview } from "./DelimitedTablePreview";
85
import { PreviewImage } from "./PreviewImage";
86
import FileBrowserPanel from "./FileBrowserPanel";
87
+import { FileExplorerPane } from "./FileExplorerPane";
88
import { FileBreadcrumbs } from "./FileBreadcrumbs";
89
import { breadcrumbPathOf, retainedBreadcrumbTrail, trailChildOf } from "./filePath";
90
import { FileMarkdownPreview } from "./FileMarkdownPreview";
@@ -1513,14 +1514,7 @@ export default function FilePreviewPanel({
1514
) : null}
1515
</div>
1516
{showExplorer ? (
1516
- <aside
1517
- className={cn(
1518
- "flex min-h-0 shrink-0 bg-background",
1519
- previewPath
1520
- ? "w-[min(22rem,46%)] min-w-64 border-l border-border/60"
1521
- : "min-w-0 flex-1",
1522
- )}
1523
- >
1517
+ <FileExplorerPane resizable={Boolean(previewPath)}>
1518
<FileBrowserPanel
1519
key={`${environmentId}:${hostFolderPath ?? cwd}`}
1520
environmentId={environmentId}
@@ -1544,7 +1538,7 @@ export default function FilePreviewPanel({
1538
}
1539
: {})}
1540
/>
1547
- </aside>
1541
+ </FileExplorerPane>
1542
) : null}
1543
</div>
1544
</div>
apps/web/src/components/preview/RightPanelResizeHandle.tsx
+10
-3
@@ -1,16 +1,23 @@
1
+import type { ComponentProps } from "react";
2
import type { ResizableWidthHandlers } from "~/hooks/useResizableWidth";
3
import { cn } from "~/lib/utils";
4
4
-interface Props {
5
+interface Props extends Pick<
6
+ ComponentProps<"div">,
7
+ "tabIndex" | "onKeyDown" | "aria-valuenow" | "aria-valuemin" | "aria-valuemax"
8
+> {
9
handlers: ResizableWidthHandlers;
10
className?: string;
11
+ label?: string;
12
}
13
9
-export function RightPanelResizeHandle({ handlers, className }: Props) {
14
+export function RightPanelResizeHandle({ handlers, className, label, ...separatorProps }: Props) {
15
return (
16
<div
17
role="separator"
18
+ aria-label={label}
19
aria-orientation="vertical"
20
+ {...separatorProps}
21
className={cn(
22
"group absolute inset-y-0 -left-1 z-20 w-2 cursor-col-resize select-none",
23
className,
@@ -19,7 +26,7 @@ export function RightPanelResizeHandle({ handlers, className }: Props) {
26
>
27
<span
28
aria-hidden
22
- className="pointer-events-none absolute inset-y-0 left-1/2 w-px -translate-x-1/2 bg-transparent transition-colors duration-150 group-hover:bg-border group-active:bg-primary/60"
29
+ className="pointer-events-none absolute inset-y-0 left-1/2 w-px -translate-x-1/2 bg-transparent transition-colors duration-150 group-hover:bg-border group-focus-visible:bg-primary/60 group-active:bg-primary/60"
30
/>
31
</div>
32
);
apps/web/src/hooks/useResizableWidth.ts
+13
-6
@@ -29,6 +29,7 @@ export interface ResizableWidthHandlers {
29
/** Persist on drag end to avoid a storage write on every animation frame. */
30
export function useResizableWidth(options: UseResizableWidthOptions): {
31
readonly width: number;
32
+ readonly setWidth: (width: number) => void;
33
readonly handlers: ResizableWidthHandlers;
34
} {
35
const { storageKey, defaultWidth, minWidth, maxWidth, edge } = options;
@@ -55,6 +56,16 @@ export function useResizableWidth(options: UseResizableWidthOptions): {
56
57
const clampedWidth = clamp(widthState.width);
58
59
+ const commitWidth = (nextStorageKey: string, nextWidth: number) => {
60
+ // Resizing remains usable for this session when browser storage is unavailable.
61
+ setWidthState({ storageKey: nextStorageKey, width: nextWidth });
62
+ try {
63
+ setLocalStorageItem(nextStorageKey, nextWidth, WidthSchema);
64
+ } catch (error) {
65
+ console.error("Could not persist panel width.", error);
66
+ }
67
+ };
68
+
69
const drag = useResizeDrag<HTMLElement>((event) => {
70
const host = event.currentTarget.parentElement;
71
// Disable drag transitions through transition-property; the host renders transition-duration.
@@ -72,12 +83,7 @@ export function useResizableWidth(options: UseResizableWidthOptions): {
83
return nextWidth;
84
},
85
finish(finalWidth) {
75
- setWidthState({ storageKey: startStorageKey, width: finalWidth });
76
- try {
77
- setLocalStorageItem(startStorageKey, finalWidth, WidthSchema);
78
- } catch (error) {
79
- console.error("Could not persist panel width.", error);
80
- }
86
+ commitWidth(startStorageKey, finalWidth);
87
},
88
cleanup(committed) {
89
host?.style.removeProperty("transition-property");
@@ -94,6 +100,7 @@ export function useResizableWidth(options: UseResizableWidthOptions): {
100
101
return {
102
width: clampedWidth,
103
+ setWidth: (value) => commitWidth(storageKey, clamp(value)),
104
handlers: {
105
ref: drag.ref,
106
onPointerDown: drag.onPointerDown,