Skip to content
This repository was archived by the owner on Oct 21, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,27 @@ import { cn } from "~/lib/utils";

interface Props {
handlers: ResizableWidthHandlers;
/** The panel edge the handle sits on: "left" for right-anchored panels, "right" for left-anchored ones. */
edge?: "left" | "right";
className?: string;
}

/**
* Hit target for resizing a right-anchored panel via its left edge.
* Hit target for resizing a side panel from one of its edges.
*
* - Sits on top of the panel's border with a 4px overlap on each side so the
* user can grab a few pixels off the edge without aiming.
* - Visual indicator is a 1px line that lights up on hover/active to mirror
* VS Code / Cursor.
*/
export function RightPanelResizeHandle({ handlers, className }: Props) {
export function PanelResizeHandle({ handlers, edge = "left", className }: Props) {
return (
<div
role="separator"
aria-orientation="vertical"
className={cn(
"group absolute inset-y-0 -left-1 z-20 w-2 cursor-col-resize select-none",
"group absolute inset-y-0 z-20 w-2 cursor-col-resize select-none",
edge === "left" ? "-left-1" : "-right-1",
className,
)}
{...handlers}
Expand Down
20 changes: 20 additions & 0 deletions apps/web/src/components/WorkspaceListPane.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { describe, expect, it } from "vite-plus/test";

import { getWorkspaceListPaneMaxWidth } from "./WorkspaceListPane";

describe("getWorkspaceListPaneMaxWidth", () => {
it("uses the fixed cap before the row is measured and on wide rows", () => {
expect(getWorkspaceListPaneMaxWidth()).toBe(512);
expect(getWorkspaceListPaneMaxWidth(1_600)).toBe(512);
});

it("keeps the editor usable in a narrow window with the app sidebar open", () => {
// 800px window minus a 208px app sidebar leaves a 592px row.
expect(getWorkspaceListPaneMaxWidth(592)).toBe(232);
expect(getWorkspaceListPaneMaxWidth(592.7)).toBe(232);
});

it("never drops below the pane's minimum width", () => {
expect(getWorkspaceListPaneMaxWidth(400)).toBe(208);
});
});
68 changes: 68 additions & 0 deletions apps/web/src/components/WorkspaceListPane.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { type CSSProperties, type ReactNode, useLayoutEffect, useRef, useState } from "react";

import { useResizableWidth } from "~/hooks/useResizableWidth";
import { cn } from "~/lib/utils";
import { PanelResizeHandle } from "./PanelResizeHandle";

const LIST_PANE_DEFAULT_WIDTH = 18 * 16;
const LIST_PANE_MIN_WIDTH = 13 * 16;
const LIST_PANE_MAX_WIDTH = 32 * 16;
/** Width kept free for the editor beside the pane so its controls never overflow. */
const EDITOR_MIN_WIDTH = 360;

export function getWorkspaceListPaneMaxWidth(rowWidth?: number): number {
const rowCap = rowWidth === undefined ? Infinity : Math.floor(rowWidth) - EDITOR_MIN_WIDTH;
// Never below the pane's minimum: when the row cannot fit both, the editor
// yields, and the width hook must not see max < min.
return Math.max(LIST_PANE_MIN_WIDTH, Math.min(LIST_PANE_MAX_WIDTH, rowCap));
}

/**
* The resizable list column on the left of a workspace page (Notes,
* Automations). Its width persists per page under `storageKey` and is clamped
* to the row it shares with the editor, so narrowing the window or opening the
* app sidebar never squeezes the editor below a usable width.
*/
export function WorkspaceListPane({
storageKey,
className,
children,
}: {
readonly storageKey: string;
readonly className?: string;
readonly children: ReactNode;
}) {
const paneRef = useRef<HTMLElement | null>(null);
const [rowWidth, setRowWidth] = useState<number | undefined>(undefined);
useLayoutEffect(() => {
const row = paneRef.current?.parentElement;
if (!row) return;
// Measure before first paint so a restored wide pane never flashes over the editor.
const measure = () => setRowWidth(row.clientWidth);
measure();
if (typeof ResizeObserver === "undefined") return;
const observer = new ResizeObserver(measure);
observer.observe(row);
return () => observer.disconnect();
}, []);
const { width, handlers } = useResizableWidth({
storageKey,
defaultWidth: LIST_PANE_DEFAULT_WIDTH,
minWidth: LIST_PANE_MIN_WIDTH,
maxWidth: getWorkspaceListPaneMaxWidth(rowWidth),
edge: "right",
});
return (
<aside
ref={paneRef}
style={{ "--list-pane-width": `${width}px` } as CSSProperties}
className={cn(
"relative flex w-(--list-pane-width) shrink-0 flex-col border-r border-pane-edge",
className,
)}
>
{children}
<PanelResizeHandle handlers={handlers} edge="right" className="max-sm:hidden" />
</aside>
);
}
9 changes: 5 additions & 4 deletions apps/web/src/components/automations/AutomationsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ import { Toggle, ToggleGroup } from "../ui/toggle-group";
import { toastManager } from "../ui/toast";
import { WorkspaceBreadcrumb, WorkspaceBreadcrumbItem } from "../WorkspaceBreadcrumb";
import { WorkspacePageHeader } from "../WorkspacePageHeader";
import { WorkspaceListPane } from "../WorkspaceListPane";
import { AutomationPromptField } from "./AutomationPromptField";
import {
AUTOMATION_TEMPLATE_CATEGORIES,
Expand Down Expand Up @@ -261,7 +262,7 @@ export function AutomationsPage({
return (
<SidebarInset className="h-dvh min-h-0 overflow-hidden overscroll-y-none isolate">
<div className="flex min-h-0 min-w-0 flex-1 flex-col bg-background text-foreground">
<WorkspacePageHeader electron={isElectron} className="border-b">
<WorkspacePageHeader electron={isElectron} className="border-b border-pane-edge">
<WorkspaceBreadcrumb ariaLabel="Automations breadcrumb" className="min-w-0">
<WorkspaceBreadcrumbItem current>
<h1 className="flex items-center gap-2">
Expand All @@ -272,8 +273,8 @@ export function AutomationsPage({
</WorkspaceBreadcrumb>
</WorkspacePageHeader>
<div className="flex min-h-0 flex-1">
<aside className="flex w-72 shrink-0 flex-col border-r max-md:hidden">
<div className="flex items-center gap-1 border-b p-2">
<WorkspaceListPane storageKey="automations_list_pane_width" className="max-md:hidden">
<div className="flex items-center gap-1 border-b border-pane-edge p-2">
<InputGroup className="min-w-0 flex-1">
<InputGroupAddon>
<SearchIcon />
Expand Down Expand Up @@ -320,7 +321,7 @@ export function AutomationsPage({
)}
</div>
</ScrollArea>
</aside>
</WorkspaceListPane>
<ScrollArea className="min-h-0 min-w-0 flex-1">
<div className="mx-auto w-full max-w-4xl px-4 py-6 sm:px-8">{content}</div>
</ScrollArea>
Expand Down
11 changes: 6 additions & 5 deletions apps/web/src/components/notes/NotesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { Textarea } from "../ui/textarea";
import { toastManager } from "../ui/toast";
import { WorkspaceBreadcrumb, WorkspaceBreadcrumbItem } from "../WorkspaceBreadcrumb";
import { WorkspacePageHeader } from "../WorkspacePageHeader";
import { WorkspaceListPane } from "../WorkspaceListPane";

interface Draft {
title: string;
Expand Down Expand Up @@ -251,7 +252,7 @@ export function NotesPage({
return (
<SidebarInset className="h-dvh min-h-0 overflow-hidden overscroll-y-none isolate">
<div className="flex min-h-0 min-w-0 flex-1 flex-col bg-background text-foreground">
<WorkspacePageHeader electron={isElectron} className="border-b">
<WorkspacePageHeader electron={isElectron} className="border-b border-pane-edge">
<WorkspaceBreadcrumb ariaLabel="Notes breadcrumb" className="min-w-0">
<WorkspaceBreadcrumbItem current>
<h1 className="flex items-center gap-2">
Expand All @@ -262,8 +263,8 @@ export function NotesPage({
</WorkspaceBreadcrumb>
</WorkspacePageHeader>
<div className="flex min-h-0 flex-1">
<aside className="flex w-72 shrink-0 flex-col border-r max-sm:w-48">
<div className="flex items-center gap-1 border-b p-2">
<WorkspaceListPane storageKey="notes_list_pane_width" className="max-sm:w-48">
<div className="flex items-center gap-1 border-b border-pane-edge p-2">
<InputGroup className="min-w-0 flex-1">
<InputGroupAddon>
<SearchIcon />
Expand All @@ -280,7 +281,7 @@ export function NotesPage({
<PlusIcon />
</Button>
</div>
<div className="border-b p-2">
<div className="border-b border-pane-edge p-2">
<Select value={tagFilter} onValueChange={(value) => setTagFilter(value ?? "")}>
<SelectTrigger size="sm" aria-label="Filter by tag">
<SelectValue>{tagFilter || "All tags"}</SelectValue>
Expand Down Expand Up @@ -322,7 +323,7 @@ export function NotesPage({
)}
</div>
</ScrollArea>
</aside>
</WorkspaceListPane>
<main className="min-w-0 flex-1 overflow-y-auto p-4">
{editor ? (
<div className="mx-auto flex max-w-3xl flex-col gap-4">
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/preview/PreviewPanelShell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import { useResizableWidth } from "~/hooks/useResizableWidth";
import { cn } from "~/lib/utils";

import { RightPanelResizeHandle } from "./RightPanelResizeHandle";
import { PanelResizeHandle } from "../PanelResizeHandle";

export type PreviewPanelMode = "inline" | "sheet" | "sidebar" | "embedded";

Expand Down Expand Up @@ -141,7 +141,7 @@ export function PreviewPanelShell(props: {
data-preview-panel-mode={props.mode}
data-preview-panel-maximized={maximized ? "true" : "false"}
>
{isInline && !maximized ? <RightPanelResizeHandle handlers={handlers} /> : null}
{isInline && !maximized ? <PanelResizeHandle handlers={handlers} /> : null}
<div className={cn("h-full min-h-0 w-full", collapsible && "overflow-clip")}>
<div
className="flex h-full min-h-0 min-w-0 flex-col"
Expand Down
14 changes: 14 additions & 0 deletions apps/web/src/hooks/useResizableWidth.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,20 @@ describe("panel resize cleanup", () => {
});

describe("panel width storage changes", () => {
it("restores a wide stored width into narrow bounds and recovers it when they grow", async () => {
savedWidths.set("wide-pane", "700");
await act(() => renderer.unmount());
await act(() => {
renderer = create(<Panel storageKey="wide-pane" maxWidth={300} />);
});
expect(result.width).toBe(300);
await act(() => renderer.update(<Panel storageKey="wide-pane" maxWidth={250} />));
expect(result.width).toBe(250);
await act(() => renderer.update(<Panel storageKey="wide-pane" maxWidth={800} />));
expect(result.width).toBe(700);
expect(setItem).not.toHaveBeenCalled();
});

it("restores separate thread widths without remounting and retains them after reload", async () => {
await act(() => {
result.handlers.onPointerDown(pointer());
Expand Down
7 changes: 4 additions & 3 deletions apps/web/src/hooks/useResizableWidth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@ export function useResizableWidth(options: UseResizableWidthOptions): {
[defaultWidth, maxWidth, minWidth],
);

// No cross-tab subscription: panel width is per-window state.
// No cross-tab subscription: panel width is per-window state. The stored
// width is kept unclamped so a pane restored into a narrow window returns to
// it once the bounds grow again; the clamp applies at render.
const readWidth = () => {
if (typeof window === "undefined") return defaultWidth;
try {
const stored = getLocalStorageItem(storageKey, WidthSchema);
return clamp(stored ?? defaultWidth);
return getLocalStorageItem(storageKey, WidthSchema) ?? defaultWidth;
} catch (error) {
console.error("Could not read persisted panel width.", error);
return defaultWidth;
Expand Down
24 changes: 20 additions & 4 deletions apps/web/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ html[data-mobile-composer-route-transition="true"]::view-transition-old(t3-mobil
--color-sidebar-row-active: var(--sidebar-row-active);
--color-sidebar-row-selected: var(--sidebar-row-selected);
--color-sidebar-border: var(--contrast-sidebar-border);
--color-pane-edge: var(--pane-edge);
--radius-sm: calc(var(--radius) - 4px);
--radius-md: calc(var(--radius) - 2px);
--radius-lg: var(--radius);
Expand Down Expand Up @@ -1130,6 +1131,8 @@ html[data-mobile-composer-route-transition="true"]::view-transition-old(t3-mobil
--sidebar-row-active: var(--accent);
--sidebar-row-selected: var(--muted);
--sidebar-stage-fade: var(--card);
/* Same as the app sidebar's own dark border, so --pane-edge matches it. */
--sidebar-border: rgb(255 255 255 / 8%);
--terminal-cursor: rgb(180 203 255);
--terminal-selection-background: rgb(180 203 255 / 25%);
}
Expand Down Expand Up @@ -1449,21 +1452,34 @@ html[data-theme-id] [data-app-sidebar] {
--sidebar-row-selected: var(--app-theme-sidebar-row-selected);
--sidebar-border: var(--app-theme-sidebar-border);
--sidebar-stage-fade: var(--app-theme-sidebar);
border-color: color-mix(in srgb, var(--contrast-sidebar-foreground) 10%, transparent);
}

/* The app sidebar's edge. Dividers between a page's own panes (border-pane-edge)
share it so every vertical seam in the workspace reads as one line. */
:root {
--pane-edge: var(--contrast-sidebar-border);
}

html[data-theme-id] {
--pane-edge: color-mix(in srgb, var(--contrast-sidebar-foreground) 10%, transparent);

@variant dark {
border-color: color-mix(in srgb, var(--contrast-sidebar-foreground) 8%, transparent);
--pane-edge: color-mix(in srgb, var(--contrast-sidebar-foreground) 8%, transparent);
}
}

/* T3 Chat's panel divider is deliberately pink, and its resize affordance
keeps that color while hovered. Do not neutralize this branded edge. */
html[data-theme-id="t3-chat"] [data-app-sidebar] {
html[data-theme-id="t3-chat"] {
@variant dark {
border-color: var(--contrast-sidebar-border);
--pane-edge: var(--contrast-sidebar-border);
}
}

[data-app-sidebar] {
border-color: var(--pane-edge);
}

/* Recompute contrast wherever a subtree owns its own semantic color palette. */
:root,
[data-app-sidebar] {
Expand Down
Loading