Skip to content
Open
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
18 changes: 16 additions & 2 deletions apps/web/src/components/AppSidebarLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
import { useEffect, type ReactNode } from "react";
import { useNavigate } from "@tanstack/react-router";
import { useNavigate, useRouterState } from "@tanstack/react-router";

import ThreadSidebar from "./Sidebar";
import { Sidebar, SidebarProvider, SidebarRail } from "./ui/sidebar";
import { Sidebar, SidebarProvider, SidebarRail, useSidebar } from "./ui/sidebar";
import {
clearShortcutModifierState,
syncShortcutModifierStateFromKeyboardEvent,
} from "../shortcutModifierState";

function CloseMobileSidebarOnNavigate() {
const { isMobile, openMobile, setOpenMobile } = useSidebar();
const pathname = useRouterState({ select: (state) => state.location.pathname });
useEffect(() => {
if (isMobile && openMobile) {
setOpenMobile(false);
}
// Only close on pathname changes — isMobile/openMobile flips alone shouldn't dismiss.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [pathname]);
return null;
}

const THREAD_SIDEBAR_WIDTH_STORAGE_KEY = "chat_thread_sidebar_width";
const THREAD_SIDEBAR_MIN_WIDTH = 13 * 16;
const THREAD_MAIN_CONTENT_MIN_WIDTH = 40 * 16;
Expand Down Expand Up @@ -55,6 +68,7 @@ export function AppSidebarLayout({ children }: { children: ReactNode }) {

return (
<SidebarProvider className="h-dvh! min-h-0!" defaultOpen>
<CloseMobileSidebarOnNavigate />
<Sidebar
side="left"
collapsible="offcanvas"
Expand Down
Loading