diff --git a/apps/web/src/components/AppSidebarLayout.tsx b/apps/web/src/components/AppSidebarLayout.tsx index 455cc9199f..7f10efc9d3 100644 --- a/apps/web/src/components/AppSidebarLayout.tsx +++ b/apps/web/src/components/AppSidebarLayout.tsx @@ -3,12 +3,12 @@ import { useEffect, useState, type CSSProperties, type ReactNode } from "react"; import { useNavigate } from "@tanstack/react-router"; import { isElectron } from "../env"; -import { resolveShortcutCommand, shortcutLabelForCommand } from "../keybindings"; +import { resolveShortcutCommand } from "../keybindings"; import { isMacPlatform } from "../lib/utils"; import { primaryServerKeybindingsAtom } from "../state/server"; import ThreadSidebar from "./Sidebar"; -import { Sidebar, SidebarProvider, SidebarRail, SidebarTrigger, useSidebar } from "./ui/sidebar"; -import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip"; +import { MainSidebarToggle } from "./SidebarToggle"; +import { Sidebar, SidebarProvider, SidebarRail, useSidebar } from "./ui/sidebar"; const THREAD_SIDEBAR_WIDTH_STORAGE_KEY = "chat_thread_sidebar_width"; const THREAD_SIDEBAR_MIN_WIDTH = 13 * 16; @@ -18,7 +18,6 @@ const MACOS_TRAFFIC_LIGHTS_LEFT_INSET = "90px"; function SidebarControl() { const keybindings = useAtomValue(primaryServerKeybindingsAtom); const { toggleSidebar } = useSidebar(); - const shortcutLabel = shortcutLabelForCommand(keybindings, "sidebar.toggle"); useEffect(() => { const onKeyDown = (event: KeyboardEvent) => { @@ -34,21 +33,14 @@ function SidebarControl() { return () => window.removeEventListener("keydown", onKeyDown); }, [keybindings, toggleSidebar]); + // Only visible while the sidebar is collapsed: when expanded, the toggle + // lives at the right edge of the sidebar header instead. return (
- - - } - /> - - Toggle main sidebar{shortcutLabel ? ` (${shortcutLabel})` : ""} - - +
); } diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx index 6a76494daa..a7e7cab1cd 100644 --- a/apps/web/src/components/Sidebar.tsx +++ b/apps/web/src/components/Sidebar.tsx @@ -77,7 +77,7 @@ import { isElectron } from "../env"; import { APP_STAGE_LABEL } from "../branding"; import { useOpenPrLink } from "../lib/openPullRequestLink"; import { isTerminalFocused } from "../lib/terminalFocus"; -import { isMacPlatform } from "../lib/utils"; +import { cn, isMacPlatform } from "../lib/utils"; import { readThreadShell, useProject, @@ -126,6 +126,7 @@ import { import { stackedThreadToast, toastManager } from "./ui/toast"; import { formatRelativeTimeLabel } from "../timestampFormat"; import { SettingsSidebarNav } from "./settings/SettingsSidebarNav"; +import { MainSidebarToggle } from "./SidebarToggle"; import { Kbd } from "./ui/kbd"; import { getArm64IntelBuildWarningDescription, @@ -2744,15 +2745,16 @@ const SidebarChromeHeader = memo(function SidebarChromeHeader({ }: { isElectron: boolean; }) { - return isElectron ? ( - - - - - ) : ( - + return ( + + ); }); @@ -2763,7 +2765,7 @@ function SidebarBrand() { return ( diff --git a/apps/web/src/components/SidebarToggle.tsx b/apps/web/src/components/SidebarToggle.tsx new file mode 100644 index 0000000000..5a2a0ef09e --- /dev/null +++ b/apps/web/src/components/SidebarToggle.tsx @@ -0,0 +1,21 @@ +import { useAtomValue } from "@effect/atom-react"; +import type { ComponentProps } from "react"; + +import { shortcutLabelForCommand } from "../keybindings"; +import { primaryServerKeybindingsAtom } from "../state/server"; +import { SidebarTrigger } from "./ui/sidebar"; +import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip"; + +export function MainSidebarToggle(props: ComponentProps) { + const keybindings = useAtomValue(primaryServerKeybindingsAtom); + const shortcutLabel = shortcutLabelForCommand(keybindings, "sidebar.toggle"); + + return ( + + } /> + + Toggle main sidebar{shortcutLabel ? ` (${shortcutLabel})` : ""} + + + ); +}