Skip to content

Commit 2b08d86

Browse files
Add resizable chat sidebar (pingdotgg#1347)
Co-authored-by: Julius Marminge <[email protected]>
1 parent e11fb6e commit 2b08d86

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

‎apps/web/src/routes/_chat.tsx‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@ import { serverConfigQueryOptions } from "../lib/serverReactQuery";
1010
import { resolveShortcutCommand } from "../keybindings";
1111
import { selectThreadTerminalState, useTerminalStateStore } from "../terminalStateStore";
1212
import { useThreadSelectionStore } from "../threadSelectionStore";
13-
import { Sidebar, SidebarProvider } from "~/components/ui/sidebar";
1413
import { resolveSidebarNewThreadEnvMode } from "~/components/Sidebar.logic";
1514
import { useAppSettings } from "~/appSettings";
15+
import { Sidebar, SidebarProvider, SidebarRail } from "~/components/ui/sidebar";
1616

1717
const EMPTY_KEYBINDINGS: ResolvedKeybindingsConfig = [];
18+
const THREAD_SIDEBAR_WIDTH_STORAGE_KEY = "chat_thread_sidebar_width";
19+
const THREAD_SIDEBAR_MIN_WIDTH = 13 * 16;
20+
const THREAD_MAIN_CONTENT_MIN_WIDTH = 40 * 16;
1821

1922
function ChatRouteGlobalShortcuts() {
2023
const clearSelection = useThreadSelectionStore((state) => state.clearSelection);
@@ -116,8 +119,15 @@ function ChatRouteLayout() {
116119
side="left"
117120
collapsible="offcanvas"
118121
className="border-r border-border bg-card text-foreground"
122+
resizable={{
123+
minWidth: THREAD_SIDEBAR_MIN_WIDTH,
124+
shouldAcceptWidth: ({ nextWidth, wrapper }) =>
125+
wrapper.clientWidth - nextWidth >= THREAD_MAIN_CONTENT_MIN_WIDTH,
126+
storageKey: THREAD_SIDEBAR_WIDTH_STORAGE_KEY,
127+
}}
119128
>
120129
<ThreadSidebar />
130+
<SidebarRail />
121131
</Sidebar>
122132
<Outlet />
123133
</SidebarProvider>

0 commit comments

Comments
 (0)