Skip to content
TypeScript

feat(web): add optional compact sidebar rail (#11525)

mariaca2cc1339bbd
diff --git a/apps/web/src/components/AppSidebarLayout.tsx b/apps/web/src/components/AppSidebarLayout.tsx
index 6769586f7fa..6497df68c8b 100644
--- a/apps/web/src/components/AppSidebarLayout.tsx
+++ b/apps/web/src/components/AppSidebarLayout.tsx
@@ -14,7 +14,11 @@ import { getLocalStorageItem, removeLocalStorageItem } from "../hooks/useLocalSt
import { resolveShortcutCommand, shortcutLabelForCommand } from "../keybindings";
import { cn, isMacPlatform } from "../lib/utils";
import { primaryServerKeybindingsAtom } from "../state/server";
-import { useEnvironmentIdentificationMode, useLegacySidebarEnabled } from "../hooks/useSettings";
+import {
+ useCompactSidebarEnabled,
+ useEnvironmentIdentificationMode,
+ useLegacySidebarEnabled,
+} from "../hooks/useSettings";
import {
PanelAnimationSuppressionProvider,
usePanelAnimationSettings,
@@ -144,6 +148,7 @@ function ProjectProjectionRetention() {
export function AppSidebarLayout({ children }: { children: ReactNode }) {
const navigate = useNavigate();
const legacySidebarEnabled = useLegacySidebarEnabled();
+ const compactSidebarEnabled = useCompactSidebarEnabled();
const { active: panelAnimationsActive, durationMs: panelAnimationDurationMs } =
usePanelAnimationSettings();
// Settings routes show the settings nav in place of whichever thread
@@ -229,7 +234,7 @@ export function AppSidebarLayout({ children }: { children: ReactNode }) {
<ProjectProjectionRetention />
<Sidebar
side="left"
- collapsible="offcanvas"
+ collapsible={compactSidebarEnabled ? "icon" : "offcanvas"}
data-app-sidebar=""
className="border-r border-sidebar-border bg-sidebar text-sidebar-foreground"
resizable={{
diff --git a/apps/web/src/components/LegacySidebar.tsx b/apps/web/src/components/LegacySidebar.tsx
index 81fd6047f13..37398f26608 100644
--- a/apps/web/src/components/LegacySidebar.tsx
+++ b/apps/web/src/components/LegacySidebar.tsx
@@ -199,7 +199,11 @@ import { SidebarChromeFooter, SidebarChromeHeader } from "./sidebar/SidebarChrom
import { useCopyToClipboard } from "~/hooks/useCopyToClipboard";
import { useIsMobile } from "~/hooks/useMediaQuery";
import { CommandDialogTrigger } from "./ui/command";
-import { useClientSettings, useUpdateClientSettings } from "~/hooks/useSettings";
+import {
+ useClientSettings,
+ useCompactSidebarEnabled,
+ useUpdateClientSettings,
+} from "~/hooks/useSettings";
import { primaryServerKeybindingsAtom } from "../state/server";
import {
derivePhysicalProjectKey,
@@ -1194,7 +1198,9 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
const router = useRouter();
const queuePendingFileDrop = useSidebarPendingFileDropStore((s) => s.queuePendingFileDrop);
const clearPendingFileDrop = useSidebarPendingFileDropStore((s) => s.clearPendingFileDrop);
- const { isMobile, setOpenMobile } = useSidebar();
+ const { isMobile, setOpenMobile, state, setOpen } = useSidebar();
+ const compactSidebarEnabled = useCompactSidebarEnabled();
+ const isCompact = compactSidebarEnabled && !isMobile && state === "collapsed";
const markThreadUnread = useUiStateStore((state) => state.markThreadUnread);
const setProjectExpanded = useUiStateStore((state) => state.setProjectExpanded);
const toggleThreadSelection = useThreadSelectionStore((state) => state.toggleThread);
@@ -1445,10 +1451,13 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
if (useThreadSelectionStore.getState().hasSelection()) {
clearSelection();
}
- setProjectExpanded(projectPreferenceKeys, !projectExpanded);
+ setProjectExpanded(projectPreferenceKeys, isCompact || !projectExpanded);
+ if (isCompact) setOpen(true);
},
[
clearSelection,
+ isCompact,
+ setOpen,
dragInProgressRef,
projectExpanded,
projectPreferenceKeys,
@@ -1465,9 +1474,17 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
if (dragInProgressRef.current) {
return;
}
- setProjectExpanded(projectPreferenceKeys, !projectExpanded);
+ setProjectExpanded(projectPreferenceKeys, isCompact || !projectExpanded);
+ if (isCompact) setOpen(true);
},
- [dragInProgressRef, projectExpanded, projectPreferenceKeys, setProjectExpanded],
+ [
+ dragInProgressRef,
+ isCompact,
+ projectExpanded,
+ projectPreferenceKeys,
+ setOpen,
+ setProjectExpanded,
+ ],
);
const handleProjectButtonPointerDownCapture = useCallback(
@@ -2359,8 +2376,10 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
<>
<div className="group/project-header relative">
<SidebarMenuButton
+ tooltip={project.displayName}
+ aria-label={project.displayName}
ref={isManualProjectSorting ? dragHandleProps?.setActivatorNodeRef : undefined}
- className={`pr-8 group-hover/project-header:bg-sidebar-row-hover group-hover/project-header:text-sidebar-foreground max-sm:pr-14 ${
+ className={`pr-8 group-hover/project-header:bg-sidebar-row-hover group-hover/project-header:text-sidebar-foreground max-sm:pr-14 group-data-[collapsible=icon]:justify-center ${
isManualProjectSorting ? "cursor-grab active:cursor-grabbing" : ""
}`}
{...(isManualProjectSorting && dragHandleProps ? dragHandleProps.attributes : {})}
@@ -2370,7 +2389,7 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
onKeyDown={handleProjectButtonKeyDown}
onContextMenu={handleProjectButtonContextMenu}
>
- {!projectExpanded && projectStatus ? (
+ {isCompact ? null : !projectExpanded && projectStatus ? (
<Tooltip>
<TooltipTrigger
render={
@@ -2401,7 +2420,7 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
<span className="flex shrink-0">
<ProjectFavicon project={project} />
</span>
- <span className="flex min-w-0 flex-1 items-center gap-2">
+ <span className="flex min-w-0 flex-1 items-center gap-2 group-data-[collapsible=icon]:hidden">
<span className="truncate text-sm font-medium text-sidebar-foreground/90">
{project.displayName}
</span>
@@ -2415,7 +2434,7 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
{/* Environment badge – visible by default, crossfades with the
"new thread" button on hover using the same pointer-events +
opacity pattern as the thread row archive/timestamp swap. */}
- {project.environmentPresence === "remote-only" && (
+ {!isCompact && project.environmentPresence === "remote-only" && (
<Tooltip>
<TooltipTrigger
render={
@@ -2441,7 +2460,7 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
<Tooltip>
<TooltipTrigger
render={
- <div className="pointer-events-none absolute top-[calc(50%+1px)] right-0.5 -translate-y-1/2 opacity-0 transition-opacity duration-150 max-sm:pointer-events-auto max-sm:opacity-100 group-hover/project-header:pointer-events-auto group-hover/project-header:opacity-100 group-focus-within/project-header:pointer-events-auto group-focus-within/project-header:opacity-100">
+ <div className="pointer-events-none absolute top-[calc(50%+1px)] right-0.5 -translate-y-1/2 opacity-0 transition-opacity duration-150 max-sm:pointer-events-auto max-sm:opacity-100 group-hover/project-header:pointer-events-auto group-hover/project-header:opacity-100 group-focus-within/project-header:pointer-events-auto group-focus-within/project-header:opacity-100 group-data-[collapsible=icon]:hidden">
<button
type="button"
aria-label={`Create new thread in ${project.displayName}`}
@@ -2674,7 +2693,7 @@ function LocalSecondaryStatus() {
}
return (
- <SidebarGroup className="px-2 pt-2 pb-0">
+ <SidebarGroup className="px-2 pt-2 pb-0 group-data-[collapsible=icon]:hidden">
{connecting.length > 0 ? (
<Alert
variant="default"
@@ -2978,14 +2997,16 @@ const SidebarProjectsContent = memo(function SidebarProjectsContent(
render={
<SidebarMenuButton
className="focus-visible:ring-0"
+ tooltip="Search"
+ aria-label="Search"
data-testid="command-palette-trigger"
/>
}
>
<SearchIcon />
- <span className="flex-1 truncate">Search</span>
+ <span className="flex-1 truncate group-data-[collapsible=icon]:hidden">Search</span>
{commandPaletteShortcutLabel ? (
- <Kbd className="h-4 min-w-0 rounded-sm px-1.5 text-[10px]">
+ <Kbd className="h-4 min-w-0 rounded-sm px-1.5 text-[10px] group-data-[collapsible=icon]:hidden">
{commandPaletteShortcutLabel}
</Kbd>
) : null}
@@ -2996,7 +3017,7 @@ const SidebarProjectsContent = memo(function SidebarProjectsContent(
}
>
{showArm64IntelBuildWarning && arm64IntelBuildWarningDescription ? (
- <SidebarGroup className="px-2 pt-2 pb-0">
+ <SidebarGroup className="px-2 pt-2 pb-0 group-data-[collapsible=icon]:hidden">
<Alert variant="warning" className="rounded-2xl border-warning/40 bg-warning/8">
<TriangleAlertIcon />
<AlertTitle>Intel build on Apple Silicon</AlertTitle>
@@ -3020,17 +3041,21 @@ const SidebarProjectsContent = memo(function SidebarProjectsContent(
) : null}
<LocalSecondaryStatus />
<SidebarGroup className="px-2 py-2">
- <div className="mb-1 flex items-center justify-between pl-2 pr-1.5">
- <span className="text-xs font-medium text-sidebar-muted-foreground/80">Projects</span>
+ <div className="mb-1 flex items-center justify-between pl-2 pr-1.5 group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:px-0">
+ <span className="text-xs font-medium text-sidebar-muted-foreground/80 group-data-[collapsible=icon]:hidden">
+ Projects
+ </span>
<div className="flex items-center gap-1">
- <ProjectSortMenu
- projectSortOrder={projectSortOrder}
- threadSortOrder={threadSortOrder}
- threadPreviewCount={threadPreviewCount}
- onProjectSortOrderChange={handleProjectSortOrderChange}
- onThreadSortOrderChange={handleThreadSortOrderChange}
- onThreadPreviewCountChange={handleThreadPreviewCountChange}
- />
+ <div className="group-data-[collapsible=icon]:hidden">
+ <ProjectSortMenu
+ projectSortOrder={projectSortOrder}
+ threadSortOrder={threadSortOrder}
+ threadPreviewCount={threadPreviewCount}
+ onProjectSortOrderChange={handleProjectSortOrderChange}
+ onThreadSortOrderChange={handleThreadSortOrderChange}
+ onThreadPreviewCountChange={handleThreadPreviewCountChange}
+ />
+ </div>
<Tooltip>
<TooltipTrigger
render={
@@ -3127,7 +3152,9 @@ const SidebarProjectsContent = memo(function SidebarProjectsContent(
)}
{projectsLength === 0 && (
- <div className="px-2 pt-4 text-center text-secondary-label text-xs">No projects yet</div>
+ <div className="px-2 pt-4 text-center text-secondary-label text-xs group-data-[collapsible=icon]:hidden">
+ No projects yet
+ </div>
)}
</SidebarGroup>
</SidebarContent>
diff --git a/apps/web/src/components/Sidebar.drag.ts b/apps/web/src/components/Sidebar.drag.ts
index 0aef9dec14b..c64de1c27b7 100644
--- a/apps/web/src/components/Sidebar.drag.ts
+++ b/apps/web/src/components/Sidebar.drag.ts
@@ -103,6 +103,7 @@ export function createSidebarSortingStrategy(input: {
snoozedThreadCount?: number;
cardHeight?: number;
slimHeight?: number;
+ compact?: boolean;
/** Space each pinned boundary opens for its label while dragging. The
* markers stay zero height at rest, so nothing is reserved until pickup. */
boundaryLabelHeight?: number;
@@ -140,11 +141,14 @@ export function createSidebarSortingStrategy(input: {
else slimHeight ??= rects[index]?.height;
if (item.key !== active.key) groups[item.section].push(item);
}
- // Cards are 4.875rem + 0.25rem padding; slim rows/placeholders are h-9.
- const scale =
- slimHeight !== undefined ? slimHeight / 36 : (headerScale ?? (cardHeight ?? 82) / 82);
- cardHeight ??= 82 * scale;
- slimHeight ??= 36 * scale;
+ // Compact icons use h-7; expanded cards include their vertical padding.
+ const scale = input.compact
+ ? (cardHeight ?? slimHeight ?? 28) / 28
+ : slimHeight !== undefined
+ ? slimHeight / 36
+ : (headerScale ?? (cardHeight ?? 82) / 82);
+ cardHeight ??= (input.compact ? 28 : 82) * scale;
+ slimHeight ??= (input.compact ? 28 : 36) * scale;
const labelHeight = (input.boundaryLabelHeight ?? 0) * scale;
const group = groups[target.section];
const order =
diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx
index e7a55e16e0c..1b850f1875b 100644
--- a/apps/web/src/components/Sidebar.tsx
+++ b/apps/web/src/components/Sidebar.tsx
@@ -1,10 +1,12 @@
import { useSupportsMultiplePullRequests } from "~/hooks/useSupportsMultiplePullRequests";
+import { useCompactSidebarEnabled } from "../hooks/useSettings";
import { resolveThreadCurrentPullRequestLink } from "@t3tools/shared/threadPullRequests";
import { useAtomValue } from "@effect/atom-react";
import { replaceComposerContextReferences } from "@t3tools/shared/composerContextReferences";
import * as Schema from "effect/Schema";
import {
DndContext,
+ DragOverlay,
useSensor,
useSensors,
type DragEndEvent,
@@ -72,6 +74,7 @@ import {
type MouseEvent as ReactMouseEvent,
type ReactNode,
} from "react";
+import { createPortal } from "react-dom";
import { useParams, useRouter } from "@tanstack/react-router";
import { useRightPanelStore } from "../rightPanelStore";
@@ -321,6 +324,7 @@ function SidebarThreadTooltip({
branchMismatch,
terminalStatus,
terminalProcessCount,
+ compactStatus,
}: {
thread: SidebarThreadSummary;
project: ProjectFaviconProject | null;
@@ -337,6 +341,7 @@ function SidebarThreadTooltip({
} | null;
terminalStatus: TerminalStatusIndicator | null;
terminalProcessCount: number;
+ compactStatus?: string | undefined;
}) {
const driverKind = providerEntry?.driverKind ?? null;
const supportsMultiplePullRequests = useSupportsMultiplePullRequests(thread.environmentId);
@@ -353,6 +358,7 @@ function SidebarThreadTooltip({
{thread.title}
</div>
<div className="grid gap-1.5 pl-0.5 text-xs text-muted-foreground">
+ {compactStatus ? <div>{compactStatus}</div> : null}
{projectDisplayName ? (
<div className="flex min-w-0 items-center gap-2">
{project ? <ProjectFavicon project={project} className="size-3 shrink-0" /> : null}
@@ -502,7 +508,7 @@ function SnoozePopoverButton(props: {
type SortableThreadRowBag = Pick<
ReturnType<typeof useSortable>,
"listeners" | "setNodeRef" | "transform" | "transition" | "isDragging"
->;
+> & { hidden?: boolean };
function SortableThreadRow(props: {
id: string;
@@ -583,7 +589,18 @@ function SidebarSectionPlaceholder(props: {
props.isDropTarget && "border-primary/40 bg-primary/5 text-primary",
)}
>
- {props.label}
+ <span className="group-data-[collapsible=icon]:sr-only">{props.label}</span>
+ {props.marker === "settled-placeholder" ? (
+ <CheckIcon
+ aria-hidden
+ className="hidden size-3.5 group-data-[collapsible=icon]:block"
+ />
+ ) : (
+ <Undo2Icon
+ aria-hidden
+ className="hidden size-3.5 group-data-[collapsible=icon]:block"
+ />
+ )}
</div>
) : null}
</SortableSidebarMarker>
@@ -607,19 +624,30 @@ function SidebarDragBoundary(props: {
className="pointer-events-none relative mx-0.5 -mb-px h-0"
>
{props.visible ? (
- <div className="sidebar-drag-boundary-label absolute inset-x-2 top-1 flex h-4 items-center gap-2">
+ <div className="sidebar-drag-boundary-label absolute inset-x-2 top-1 flex h-4 items-center gap-2 group-data-[collapsible=icon]:inset-x-0 group-data-[collapsible=icon]:justify-center">
<span
className={cn(
"shrink-0 text-xs font-medium",
props.isDropTarget ? "text-primary" : "text-sidebar-foreground/80",
)}
>
- {props.label}
+ <span className="group-data-[collapsible=icon]:sr-only">{props.label}</span>
+ {props.marker === "pinned-header" ? (
+ <PinIcon
+ aria-hidden
+ className="hidden size-3.5 group-data-[collapsible=icon]:block"
+ />
+ ) : (
+ <Undo2Icon
+ aria-hidden
+ className="hidden size-3.5 group-data-[collapsible=icon]:block"
+ />
+ )}
</span>
<span
aria-hidden
className={cn(
- "h-px flex-1",
+ "h-px flex-1 group-data-[collapsible=icon]:hidden",
props.isDropTarget ? "bg-primary/50" : "bg-sidebar-foreground/25",
)}
/>
@@ -639,20 +667,32 @@ function SidebarSectionHeader(props: {
isDropTarget?: boolean;
toggle: { expanded: boolean; onToggle: () => void };
}) {
+ const compactEnabled = useCompactSidebarEnabled();
+ const { state, isMobile } = useSidebar();
+ const compact = compactEnabled && state === "collapsed" && !isMobile;
const snoozed = props.marker === "snoozed-header";
const className = cn(
"flex h-full w-full items-center gap-2 px-2 text-left text-xs font-medium",
+ compact && "justify-center px-0",
snoozed ? "text-blue-600 dark:text-blue-400" : "text-sidebar-muted-foreground/60",
props.dragging && "text-sidebar-foreground/80",
props.isDropTarget && "text-primary",
);
const content = (
<>
- <span className="shrink-0">{props.label}</span>
+ <span className={compact ? "sr-only" : "shrink-0"}>{props.label}</span>
+ {compact ? (
+ snoozed ? (
+ <AlarmClockIcon aria-hidden className="size-3.5" />
+ ) : (
+ <CheckIcon aria-hidden className="size-3.5" />
+ )
+ ) : null}
<span
aria-hidden
className={cn(
"h-px min-w-2 flex-1",
+ compact && "hidden",
snoozed ? "bg-blue-500/20 dark:bg-blue-400/15" : "bg-sidebar-border/60",
props.dragging && "bg-sidebar-foreground/25",
props.isDropTarget && "bg-primary/50",
@@ -662,6 +702,7 @@ function SidebarSectionHeader(props: {
aria-hidden
className={cn(
"size-3 shrink-0 transition-transform",
+ compact && "hidden",
props.toggle.expanded && "rotate-180",
)}
/>
@@ -673,15 +714,22 @@ function SidebarSectionHeader(props: {
data-testid={`sidebar-${props.marker}`}
className="mx-0.5 h-8"
>
- <button
- type="button"
- onClick={props.toggle.onToggle}
- aria-expanded={props.toggle.expanded}
- data-testid={`sidebar-${snoozed ? "snoozed" : "settled"}-shelf-toggle`}
- className={cn(className, "cursor-pointer")}
- >
- {content}
- </button>
+ <Tooltip disabled={!compact}>
+ <TooltipTrigger
+ render={
+ <button
+ type="button"
+ onClick={props.toggle.onToggle}
+ aria-expanded={props.toggle.expanded}
+ data-testid={`sidebar-${snoozed ? "snoozed" : "settled"}-shelf-toggle`}
+ className={cn(className, "cursor-pointer")}
+ />
+ }
+ >
+ {content}
+ </TooltipTrigger>
+ <TooltipPopup side="right">{props.label}</TooltipPopup>
+ </Tooltip>
</SortableSidebarMarker>
);
}
@@ -704,6 +752,9 @@ const SidebarDraftRow = memo(function SidebarDraftRow(props: {
onDiscard: (draftId: DraftId) => void;
}) {
const { composer, draftId, onDiscard, onNavigate, session } = props;
+ const compactEnabled = useCompactSidebarEnabled();
+ const { state, isMobile } = useSidebar();
+ const compact = compactEnabled && state === "collapsed" && !isMobile;
const promptPreview =
replaceComposerContextReferences(composer.prompt, (occurrence) => occurrence.label)
.trim()
@@ -742,6 +793,34 @@ const SidebarDraftRow = memo(function SidebarDraftRow(props: {
},
[draftId, onDiscard],
);
+ if (compact) {
+ return (
+ <li className="list-none">
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <button
+ type="button"
+ data-testid="sidebar-draft-row"
+ aria-label={`Draft: ${preview}`}
+ onClick={handleActivate}
+ className={cn(
+ "relative flex h-7 w-full cursor-pointer items-center justify-center rounded-md outline-none hover:bg-sidebar-row-hover focus-visible:ring-2 focus-visible:ring-ring",
+ props.isActive ? "bg-sidebar-row-active" : draftSurfaceClassName,
+ )}
+ />
+ }
+ >
+ <SquarePenIcon aria-hidden className={cn(draftPenClassName, "size-4")} />
+ </TooltipTrigger>
+ <TooltipPopup side="right" className="max-w-80 whitespace-normal">
+ <div className="font-medium">{props.projectDisplayName}</div>
+ <div>{preview}</div>
+ </TooltipPopup>
+ </Tooltip>
+ </li>
+ );
+ }
return (
<li className="list-none py-0.5">
<div
@@ -1031,6 +1110,9 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {
variant,
variantAction,
} = props;
+ const compactEnabled = useCompactSidebarEnabled();
+ const { state, isMobile } = useSidebar();
+ const compact = compactEnabled && state === "collapsed" && !isMobile;
const threadRef = useMemo(
() => scopeThreadRef(thread.environmentId, thread.id),
[thread.environmentId, thread.id],
@@ -1208,6 +1290,16 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {
branchMismatch={branchMismatch}
terminalStatus={terminalStatus}
terminalProcessCount={terminalProcessCount}
+ compactStatus={
+ compact
+ ? (topStatus?.label ??
+ (variantAction === "unsnooze"
+ ? "Snoozed"
+ : variantAction === "unsettle"
+ ? "Settled"
+ : "Ready"))
+ : undefined
+ }
/>
);
@@ -1254,6 +1346,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {
[isRenaming, onStartRename, thread.title, threadRef],
);
const [isFileDragOver, setIsFileDragOver] = useState(false);
+ const [tooltipOpen, setTooltipOpen] = useState(false);
const fileDropHandlers = useMemo(
() =>
onFileDropThreads
@@ -1416,7 +1509,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {
// A zero-height boundary also makes dnd-kit scale the source to
// zero. Only projected peers use scaleY as a visibility sentinel.
visibility:
- !sortable.isDragging && sortable.transform?.scaleY === 0
+ sortable.hidden || (!sortable.isDragging && sortable.transform?.scaleY === 0)
? ("hidden" as const)
: undefined,
},
@@ -1557,6 +1650,77 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {
)
) : null;
+ if (compact) {
+ return (
+ <li
+ data-thread-item
+ {...sortableRootProps}
+ {...(fileDropHandlers ?? {})}
+ className={cn("list-none", sortable?.isDragging && "relative z-20")}
+ >
+ <Tooltip
+ open={
+ sortable?.hidden ? false : sortable?.isDragging ? dragDestination !== null : tooltipOpen
+ }
+ onOpenChange={setTooltipOpen}
+ >
+ <TooltipTrigger
+ render={
+ <div
+ ref={rowRef}
+ role="button"
+ tabIndex={0}
+ aria-label={`${thread.title}${topStatus ? `, ${topStatus.label}` : ""}`}
+ aria-current={props.isActive ? "page" : undefined}
+ aria-busy={isRegeneratingTitle || undefined}
+ className={cn(
+ rowSurfaceClassName,
+ "flex h-7 items-center justify-center focus-visible:ring-2 focus-visible:ring-ring",
+ )}
+ onClick={handleClick}
+ onDoubleClick={handleDoubleClick}
+ onKeyDown={handleKeyDown}
+ onContextMenu={handleContextMenu}
+ />
+ }
+ >
+ {props.project ? (
+ <ProjectFavicon project={props.project} className="size-4 shrink-0" />
+ ) : driverKind ? (
+ <ProviderInstanceIcon
+ driverKind={driverKind}
+ displayName={providerEntry?.displayName ?? modelInstanceId}
+ iconClassName="size-4"
+ />
+ ) : (
+ <SquarePenIcon aria-hidden className="size-4" />
+ )}
+ {topStatus ? (
+ <span
+ aria-hidden
+ className={cn(
+ "absolute right-0.5 bottom-0.5 size-1.5 rounded-full bg-current",
+ topStatus.className,
+ )}
+ />
+ ) : hasUnsentDraft ? (
+ <span
+ aria-hidden
+ className="absolute right-0.5 bottom-0.5 size-1.5 rounded-full bg-primary"
+ />
+ ) : null}
+ {props.jumpLabel ? <JumpHintBadge label={props.jumpLabel} /> : null}
+ </TooltipTrigger>
+ {sortable?.isDragging ? (
+ <TooltipPopup side="right">{dragDestination}</TooltipPopup>
+ ) : (
+ detailsTooltip
+ )}
+ </Tooltip>
+ </li>
+ );
+ }
+
if (variant === "slim") {
return (
<li
@@ -1569,7 +1733,11 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {
sortable?.isDragging && "relative z-20",
)}
>
- <Tooltip disabled={sortable?.isDragging}>
+ <Tooltip
+ open={!sortable?.isDragging && tooltipOpen}
+ onOpenChange={setTooltipOpen}
+ disabled={sortable?.isDragging}
+ >
<TooltipTrigger
render={
<div
@@ -1722,7 +1890,11 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {
sortable?.isDragging && "relative z-20",
)}
>
- <Tooltip disabled={snoozeMenuOpen || sortable?.isDragging}>
+ <Tooltip
+ open={!snoozeMenuOpen && !sortable?.isDragging && tooltipOpen}
+ onOpenChange={setTooltipOpen}
+ disabled={snoozeMenuOpen || sortable?.isDragging}
+ >
<TooltipTrigger
render={
<div
@@ -1989,6 +2161,9 @@ const SidebarSearchResultRow = memo(function SidebarSearchResultRow(props: {
onFileDropThreads: (threadRef: ScopedThreadRef, files: File[]) => void;
}) {
const { thread } = props;
+ const compactEnabled = useCompactSidebarEnabled();
+ const { state, isMobile } = useSidebar();
+ const compact = compactEnabled && state === "collapsed" && !isMobile;
const threadRef = useMemo(
() => scopeThreadRef(thread.environmentId, thread.id),
[thread.environmentId, thread.id],
@@ -2074,6 +2249,7 @@ const SidebarSearchResultRow = memo(function SidebarSearchResultRow(props: {
onClick={props.onSelect}
className={cn(
"flex h-9 w-full cursor-pointer items-center gap-2.5 rounded-md px-2.5 text-left text-sm outline-none",
+ compact && "justify-center px-0",
props.isHighlighted || props.isRouteActive
? "bg-sidebar-row-active text-sidebar-foreground"
: "text-sidebar-muted-foreground/75 hover:bg-sidebar-row-hover hover:text-sidebar-foreground",
@@ -2085,9 +2261,15 @@ const SidebarSearchResultRow = memo(function SidebarSearchResultRow(props: {
>
{props.project ? (
<ProjectFavicon project={props.project} className="size-4 shrink-0" />
+ ) : compact ? (
+ <SquarePenIcon aria-hidden className="size-4" />
) : null}
- <span className="min-w-0 flex-1 truncate">{thread.title}</span>
- <span className="shrink-0 text-xs text-muted-foreground/55 tabular-nums">
+ <span className={compact ? "sr-only" : "min-w-0 flex-1 truncate"}>{thread.title}</span>
+ <span
+ className={
+ compact ? "sr-only" : "shrink-0 text-xs text-muted-foreground/55 tabular-nums"
+ }
+ >
{threadTimeLabel(thread)}
</span>
</TooltipTrigger>
@@ -2115,7 +2297,10 @@ export default function Sidebar() {
const projectOrder = useUiStateStore((store) => store.projectOrder);
const threads = useThreadShells();
const router = useRouter();
- const { isMobile, setOpenMobile } = useSidebar();
+ const { isMobile, setOpenMobile, setOpen, state: sidebarState } = useSidebar();
+ const compactEnabled = useCompactSidebarEnabled();
+ const compact = compactEnabled && sidebarState === "collapsed" && !isMobile;
+ const [snoozedFooter, setSnoozedFooter] = useState<HTMLUListElement | null>(null);
const keybindings = useAtomValue(primaryServerKeybindingsAtom);
const confirmThreadDelete = useClientSettings((s) => s.confirmThreadDelete);
const confirmThreadArchive = useClientSettings((s) => s.confirmThreadArchive);
@@ -2687,6 +2872,7 @@ export default function Sidebar() {
[setSettledShelfExpanded],
);
const renderedSettledThreads = useMemo(() => {
+ if (compact) return EMPTY_THREADS;
if (settledShelfExpanded) return visibleSettledThreads;
if (routeThreadKey === null) return EMPTY_THREADS;
const routeThread = visibleSettledThreads.find(
@@ -2694,7 +2880,7 @@ export default function Sidebar() {
scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id)) === routeThreadKey,
);
return routeThread === undefined ? EMPTY_THREADS : [routeThread];
- }, [routeThreadKey, settledShelfExpanded, visibleSettledThreads]);
+ }, [compact, routeThreadKey, settledShelfExpanded, visibleSettledThreads]);
// The snoozed shelf is collapsed by default: out of the way, never gone.
// Collapsed threads don't render (and so don't participate in jump
@@ -2922,10 +3108,14 @@ export default function Sidebar() {
const [renamingThreadKey, setRenamingThreadKey] = useState<string | null>(null);
const [renamingTitle, setRenamingTitle] = useState("");
- const startThreadRename = useCallback((threadRef: ScopedThreadRef, title: string) => {
- setRenamingThreadKey(scopedThreadKey(threadRef));
- setRenamingTitle(title);
- }, []);
+ const startThreadRename = useCallback(
+ (threadRef: ScopedThreadRef, title: string) => {
+ if (compact) setOpen(true);
+ setRenamingThreadKey(scopedThreadKey(threadRef));
+ setRenamingTitle(title);
+ },
+ [compact, setOpen],
+ );
const cancelThreadRename = useCallback(() => setRenamingThreadKey(null), []);
const commitThreadRename = useCallback(
(threadRef: ScopedThreadRef, title: string, originalTitle: string) => {
@@ -3087,8 +3277,18 @@ export default function Sidebar() {
const threadListRef = useRef<HTMLUListElement | null>(null);
const dragLabelOffsetRef = useRef(0);
const restrictBelowPins = useCallback<Modifier>(
- (args) => restrictBelowSidebarLabel(args, dragLabelOffsetRef.current),
- [],
+ (args) =>
+ restrictBelowSidebarLabel(
+ {
+ ...args,
+ // The fixed snoozed shelf shares the main list's drag boundary.
+ containerNodeRect: compact
+ ? (threadListRef.current?.getBoundingClientRect() ?? args.containerNodeRect)
+ : args.containerNodeRect,
+ },
+ dragLabelOffsetRef.current,
+ ),
+ [compact],
);
const listMotionRef = useRef<ReturnType<typeof createSidebarListMotion> | null>(null);
const attachListMotionRef = useCallback((node: HTMLUListElement | null) => {
@@ -3310,7 +3510,7 @@ export default function Sidebar() {
pinnedThreads.length +
activeThreads.length +
snoozedThreads.length +
- settledThreads.length ===
+ (compact ? 0 : settledThreads.length) ===
0
) {
return [];
@@ -3326,13 +3526,15 @@ export default function Sidebar() {
items.push({ kind: "marker", marker: "snoozed-header" });
items.push(...rowsOf(visibleSnoozedThreads, "snoozed"));
}
- items.push({ kind: "marker", marker: "settled-header" });
- const settledRows = rowsOf(renderedSettledThreads, "settled");
- items.push({ kind: "marker", marker: "settled-placeholder" });
- items.push(...settledRows);
+ if (!compact) {
+ items.push({ kind: "marker", marker: "settled-header" });
+ items.push({ kind: "marker", marker: "settled-placeholder" });
+ items.push(...rowsOf(renderedSettledThreads, "settled"));
+ }
return items;
}, [
activeThreads,
+ compact,
pinnedThreads,
renderedSettledThreads,
settledThreads.length,
@@ -3402,6 +3604,7 @@ export default function Sidebar() {
() =>
createSidebarSortingStrategy({
items: sidebarListItems,
+ compact,
boundaryLabelHeight: SIDEBAR_DRAG_LABEL_HEIGHT,
settledOrder: draggedSettledOrder,
settledExpanded: settledShelfExpanded,
@@ -3410,6 +3613,7 @@ export default function Sidebar() {
snoozedThreadCount: snoozedThreads.length,
}),
[
+ compact,
draggedSettledOrder,
routeThreadKey,
settledShelfExpanded,
@@ -3418,6 +3622,22 @@ export default function Sidebar() {
snoozedThreads.length,
],
);
+ const draggingCompactSnoozed = compact && dragState?.activeSection === "snoozed";
+ const compactSnoozedDragThread =
+ draggingCompactSnoozed && dragState ? threadByKey.get(dragState.activeKey) : undefined;
+ const compactSidebarSortingStrategy = useCallback<typeof sidebarSortingStrategy>(
+ (args) => {
+ const item = sidebarListItems[args.index];
+ // Footer rows stay anchored while the main list previews a reorder.
+ if (
+ item?.kind === "thread" ? item.section === "snoozed" : item?.marker === "snoozed-header"
+ ) {
+ return null;
+ }
+ return sidebarSortingStrategy(args);
+ },
+ [sidebarListItems, sidebarSortingStrategy],
+ );
// Hidden and filtered threads keep their keys. Reserve those slots without
// including the rows in the visible drop order or writing to them.
const { pinnedKeysById, activeKeysById } = useMemo(
@@ -4321,7 +4541,16 @@ export default function Sidebar() {
<>
<SidebarChromeHeader isElectron={isElectron} />
<SidebarContent
- className="gap-0"
+ className={cn("gap-0", compact && "group-data-[collapsible=icon]:overflow-visible")}
+ fixedFooter={
+ compact && !isSearchingThreads && snoozedThreads.length > 0 ? (
+ <ul
+ ref={setSnoozedFooter}
+ aria-label="Snoozed threads"
+ className="relative flex max-h-[min(30vh,16rem)] flex-col gap-px overflow-y-auto px-[var(--sidebar-content-inset)] pb-1"
+ />
+ ) : null
+ }
fixedHeader={
// Lifted above the stage backdrop, whose fade bleeds below the
// header and would otherwise paint across the search row's outline.
@@ -4381,8 +4610,12 @@ export default function Sidebar() {
// popup opens under the field, is at least as wide as it,
// and grows to fit project names up to a cap, past which
// the rows truncate.
- anchor={headerSearchRef}
- className="max-w-[min(18rem,var(--available-width))] overflow-hidden"
+ anchor={compact ? undefined : headerSearchRef}
+ side={compact ? "right" : "bottom"}
+ className={cn(
+ "max-w-[min(18rem,var(--available-width))] overflow-hidden",
+ compact && "min-w-56",
+ )}
>
<ComboboxSearchInput
aria-label="Search projects"
@@ -4537,7 +4770,10 @@ export default function Sidebar() {
) : (
<p
role="status"
- className="px-2 py-6 text-center text-xs text-sidebar-muted-foreground"
+ className={cn(
+ "px-2 py-6 text-center text-xs text-sidebar-muted-foreground",
+ compact && "sr-only",
+ )}
>
No threads found
</p>
@@ -4556,14 +4792,17 @@ export default function Sidebar() {
modifiers={[
restrictToVerticalAxis,
restrictBelowPins,
- restrictToFirstScrollableAncestor,
+ ...(compact ? [] : [restrictToFirstScrollableAncestor]),
]}
onDragStart={handleThreadDragStart}
onDragOver={handleThreadDragOver}
onDragEnd={handleThreadDragEnd}
>
<SidebarDragLifecycle onUnmount={cancelThreadDrag} />
- <SortableContext items={sortableIds} strategy={sidebarSortingStrategy}>
+ <SortableContext
+ items={sortableIds}
+ strategy={compact ? compactSidebarSortingStrategy : sidebarSortingStrategy}
+ >
<ul
ref={attachListMotionRef}
role="list"
@@ -4693,11 +4932,25 @@ export default function Sidebar() {
!draggableThreadKeys.has(threadKey) || optimisticDrop !== null
}
>
- {(bag) => renderThreadRowInner(thread, section, bag)}
+ {(bag) =>
+ renderThreadRowInner(
+ thread,
+ section,
+ draggingCompactSnoozed && bag.isDragging
+ ? { ...bag, hidden: true }
+ : bag,
+ )
+ }
</SortableThreadRow>
);
};
const from = dragState?.activeSection ?? null;
+ const showDragLabels =
+ from !== null &&
+ (!compact ||
+ dragTargetSection === "active" ||
+ dragTargetSection === "pinned");
+ const snoozedItems: ReactNode[] = [];
const items: ReactNode[] = [
<SidebarDraftBlock
key="draft-sessions"
@@ -4709,8 +4962,17 @@ export default function Sidebar() {
/>,
];
for (const item of sidebarListItems) {
+ const destination =
+ compact &&
+ (item.kind === "thread"
+ ? item.section === "snoozed"
+ : item.marker === "snoozed-header")
+ ? snoozedItems
+ : items;
if (item.kind === "thread") {
- items.push(renderThreadRow(threadByKey.get(item.key)!, item.section));
+ destination.push(
+ renderThreadRow(threadByKey.get(item.key)!, item.section),
+ );
continue;
}
switch (item.marker) {
@@ -4720,7 +4982,7 @@ export default function Sidebar() {
key="pinned-header"
marker="pinned-header"
label="Pinned"
- visible={from !== null}
+ visible={showDragLabels}
isDropTarget={dragTargetSection === "pinned"}
/>,
);
@@ -4731,7 +4993,7 @@ export default function Sidebar() {
key="pinned-divider"
marker="pinned-divider"
label="Active"
- visible={from !== null}
+ visible={showDragLabels}
isDropTarget={dragTargetSection === "active"}
/>,
);
@@ -4755,7 +5017,7 @@ export default function Sidebar() {
);
break;
case "snoozed-header":
- items.push(
+ destination.push(
<SidebarSectionHeader
key="snoozed-shelf-header"
marker="snoozed-header"
@@ -4810,18 +5072,56 @@ export default function Sidebar() {
break;
}
}
- return items;
+ // Keep the shelf inside this drag context while anchoring
+ // its DOM outside the main thread scroller.
+ return [
+ ...items,
+ compact && snoozedFooter
+ ? createPortal(snoozedItems, snoozedFooter, "snoozed-footer")
+ : null,
+ compactSnoozedDragThread
+ ? createPortal(
+ <DragOverlay dropAnimation={null}>
+ <ul className="pointer-events-none">
+ {renderThreadRowInner(compactSnoozedDragThread, "snoozed", {
+ isDragging: true,
+ listeners: undefined,
+ setNodeRef: () => {},
+ transform: null,
+ transition: undefined,
+ })}
+ </ul>
+ </DragOverlay>,
+ document.body,
+ "compact-snoozed-drag",
+ )
+ : null,
+ ];
})()}
- {settledShelfExpanded && hiddenSettledCount > 0 ? (
+ {!compact && settledShelfExpanded && hiddenSettledCount > 0 ? (
<li className="list-none">
- <button
- type="button"
- onClick={showMoreSettled}
- className="flex h-9 w-full cursor-pointer items-center gap-2.5 rounded-md px-2.5 text-left text-sm text-sidebar-muted-foreground/55 hover:bg-sidebar-row-hover hover:text-sidebar-foreground"
- >
- <PlusIcon aria-hidden className="size-4 shrink-0" />
- Show {Math.min(hiddenSettledCount, SETTLED_TAIL_PAGE_COUNT)} more
- </button>
+ <Tooltip disabled={!compact}>
+ <TooltipTrigger
+ render={
+ <button
+ type="button"
+ onClick={showMoreSettled}
+ className={cn(
+ "flex h-9 w-full cursor-pointer items-center gap-2.5 rounded-md px-2.5 text-left text-sm text-sidebar-muted-foreground/55 hover:bg-sidebar-row-hover hover:text-sidebar-foreground",
+ compact && "justify-center px-0",
+ )}
+ />
+ }
+ >
+ <PlusIcon aria-hidden className="size-4 shrink-0" />
+ <span className={compact ? "sr-only" : undefined}>
+ Show {Math.min(hiddenSettledCount, SETTLED_TAIL_PAGE_COUNT)} more
+ </span>
+ </TooltipTrigger>
+ <TooltipPopup side="right">
+ Show {Math.min(hiddenSettledCount, SETTLED_TAIL_PAGE_COUNT)} more
+ </TooltipPopup>
+ </Tooltip>
</li>
) : null}
</ul>
@@ -4836,20 +5136,29 @@ export default function Sidebar() {
snoozedThreads.length +
settledThreads.length ===
0 ? (
- <div className="flex flex-col items-center gap-2 px-2 py-6 text-center text-xs text-muted-foreground/60">
+ <div
+ className={cn(
+ "flex flex-col items-center gap-2 px-2 py-6 text-center text-xs text-muted-foreground/60",
+ compact && "px-0",
+ )}
+ >
{projects.length === 0 ? (
<>
- <span>No projects yet</span>
+ <span className={compact ? "sr-only" : undefined}>No projects yet</span>
<button
type="button"
onClick={openAddProjectCommandPalette}
- className="inline-flex cursor-pointer items-center gap-1.5 rounded-md border border-sidebar-border px-2.5 py-1 text-[11px] font-medium text-sidebar-muted-foreground transition-colors hover:bg-sidebar-row-hover hover:text-sidebar-foreground"
+ aria-label="Add project"
+ className={cn(
+ "inline-flex cursor-pointer items-center gap-1.5 rounded-md border border-sidebar-border px-2.5 py-1 text-[11px] font-medium text-sidebar-muted-foreground transition-colors hover:bg-sidebar-row-hover hover:text-sidebar-foreground",
+ compact && "justify-center px-1.5",
+ )}
>
<PlusIcon className="-mx-0.5 size-3" />
- Add project
+ <span className={compact ? "sr-only" : undefined}>Add project</span>
</button>
</>
- ) : scopedProjectGroup ? (
+ ) : compact ? null : scopedProjectGroup ? (
`No threads in ${scopedProjectGroup.displayName} yet`
) : (
"No threads yet"
diff --git a/apps/web/src/components/settings/CompactSidebarPreview.tsx b/apps/web/src/components/settings/CompactSidebarPreview.tsx
new file mode 100644
index 00000000000..49fb0754e01
--- /dev/null
+++ b/apps/web/src/components/settings/CompactSidebarPreview.tsx
@@ -0,0 +1,53 @@
+import { useState } from "react";
+
+import { cn } from "~/lib/utils";
+
+export function CompactSidebarPreview() {
+ const [collapsed, setCollapsed] = useState(false);
+
+ return (
+ <button
+ type="button"
+ aria-label="Toggle compact sidebar preview"
+ aria-pressed={collapsed}
+ className="group/compact-preview relative flex h-10 w-full cursor-pointer overflow-hidden rounded-lg border border-border bg-background p-1 shadow-xs/5 outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background"
+ onClick={() => setCollapsed((value) => !value)}
+ >
+ <span
+ aria-hidden
+ className={cn(
+ "flex h-full shrink-0 flex-col justify-center gap-1 overflow-hidden rounded-md bg-sidebar px-1 transition-[width] duration-250 ease-out motion-reduce:transition-none",
+ collapsed ? "w-3" : "w-9",
+ )}
+ >
+ {[0, 1, 2].map((row) => (
+ <span key={row} className="flex h-1 shrink-0 items-center gap-1">
+ <span className="size-1 shrink-0 rounded-[1px] bg-muted-foreground/50" />
+ <span
+ className={cn(
+ "h-0.5 w-4 shrink-0 rounded-full bg-muted-foreground/25 transition-opacity duration-250 ease-out motion-reduce:transition-none",
+ collapsed && "opacity-0",
+ )}
+ />
+ </span>
+ ))}
+ </span>
+ <span aria-hidden className="flex min-w-0 flex-1 flex-col gap-1 px-1 pt-1">
+ <span className="h-0.5 w-full rounded-full bg-muted-foreground/25" />
+ <span className="h-0.5 w-4/5 rounded-full bg-muted-foreground/20" />
+ <span className="h-0.5 w-3/5 rounded-full bg-muted-foreground/15" />
+ </span>
+ <span
+ aria-hidden
+ className={cn(
+ "pointer-events-none absolute top-3 left-5 flex w-9 flex-col gap-1 rounded-sm border border-border bg-popover p-1 opacity-0 shadow-xs transition-opacity duration-150 ease-out motion-reduce:transition-none",
+ collapsed &&
+ "group-hover/compact-preview:opacity-100 group-focus-visible/compact-preview:opacity-100",
+ )}
+ >
+ <span className="h-0.5 w-full rounded-full bg-popover-foreground/45" />
+ <span className="h-0.5 w-2/3 rounded-full bg-popover-foreground/25" />
+ </span>
+ </button>
+ );
+}
diff --git a/apps/web/src/components/settings/SettingsPanels.tsx b/apps/web/src/components/settings/SettingsPanels.tsx
index c9700496f42..efefc79c32c 100644
--- a/apps/web/src/components/settings/SettingsPanels.tsx
+++ b/apps/web/src/components/settings/SettingsPanels.tsx
@@ -160,6 +160,7 @@ import {
import { searchableSetting } from "./settingsSearch";
import { ProjectFavicon } from "../ProjectFavicon";
import { PanelAnimationsPreview } from "./PanelAnimationsPreview";
+import { CompactSidebarPreview } from "./CompactSidebarPreview";
const ENVIRONMENT_IDENTIFICATION_LABELS: Record<EnvironmentIdentificationMode, string> = {
artwork: "Artwork",
@@ -501,6 +502,9 @@ export function useSettingsRestore(onRestored?: () => void) {
...(theme !== "system" ? ["Theme"] : []),
...(!followSystem ? ["Follow system"] : []),
...(themeHalves !== null ? ["Theme mix"] : []),
+ ...(settings.compactSidebarEnabled !== DEFAULT_UNIFIED_SETTINGS.compactSidebarEnabled
+ ? ["Compact sidebar"]
+ : []),
...(settings.appearanceContrast !== DEFAULT_UNIFIED_SETTINGS.appearanceContrast
? ["Contrast"]
: []),
@@ -605,6 +609,7 @@ export function useSettingsRestore(onRestored?: () => void) {
settings.browserLinkTarget,
settings.browserAutoShowFloatingPreview,
settings.appearanceContrast,
+ settings.compactSidebarEnabled,
settings.diffColorScheme,
settings.enableAgentBrowserAccess,
settings.confirmQuit,
@@ -712,6 +717,7 @@ export function useSettingsRestore(onRestored?: () => void) {
}
updateSettings({
appearanceContrast: DEFAULT_UNIFIED_SETTINGS.appearanceContrast,
+ compactSidebarEnabled: DEFAULT_UNIFIED_SETTINGS.compactSidebarEnabled,
diffColorScheme: DEFAULT_UNIFIED_SETTINGS.diffColorScheme,
timestampFormat: DEFAULT_UNIFIED_SETTINGS.timestampFormat,
notificationMode: DEFAULT_UNIFIED_SETTINGS.notificationMode,
@@ -1356,6 +1362,27 @@ export function AppearanceSettingsPanel() {
/>
</SettingsSection>
+ <SettingsSection id="appearance-sidebar" title="Sidebar">
+ <SettingsRow
+ {...searchableSetting("compact-sidebar")}
+ description="Keep an icon rail when the sidebar is collapsed. Click the preview to try it."
+ control={
+ <div className="grid w-full grid-cols-[5rem_auto] items-center justify-end gap-3 sm:w-auto sm:grid-cols-[7rem_auto] sm:gap-4">
+ <CompactSidebarPreview />
+ <div className="flex justify-end">
+ <Switch
+ checked={settings.compactSidebarEnabled}
+ onCheckedChange={(checked) =>
+ updateSettings({ compactSidebarEnabled: Boolean(checked) })
+ }
+ aria-label="Compact sidebar"
+ />
+ </div>
+ </div>
+ }
+ />
+ </SettingsSection>
+
<TypographySection />
</SettingsPageContainer>
);
diff --git a/apps/web/src/components/settings/SettingsSidebarNav.tsx b/apps/web/src/components/settings/SettingsSidebarNav.tsx
index c29068934ef..c206174a397 100644
--- a/apps/web/src/components/settings/SettingsSidebarNav.tsx
+++ b/apps/web/src/components/settings/SettingsSidebarNav.tsx
@@ -24,6 +24,7 @@ import {
XIcon,
} from "lucide-react";
import { useLocation, useNavigate } from "@tanstack/react-router";
+import { useCompactSidebarEnabled } from "../../hooks/useSettings";
import { Button } from "../ui/button";
import { Input } from "../ui/input";
@@ -111,12 +112,13 @@ export function SettingsSidebarNav({ pathname }: { pathname: string }) {
(item) => item.to !== "/settings/projects" || isSettingsOverviewVisible(scopeSearch),
);
const { isMobile, setOpenMobile, open, setOpen } = useSidebar();
+ const compactSidebarEnabled = useCompactSidebarEnabled();
const searchInputRef = useRef<HTMLInputElement>(null);
const [query, setQuery] = useState("");
const [activeResultIndex, setActiveResultIndex] = useState(0);
const searchableItems = useAvailableSettingsSearchItems();
const results = useMemo(() => searchSettings(query, searchableItems), [query, searchableItems]);
- const isSearching = query.trim().length > 0;
+ const isSearching = query.trim().length > 0 && !(compactSidebarEnabled && !isMobile && !open);
const hasResults = results.length > 0;
useEffect(() => {
@@ -233,7 +235,18 @@ export function SettingsSidebarNav({ pathname }: { pathname: string }) {
<>
<SidebarContent className="overflow-x-hidden">
<SidebarGroup className="gap-2 p-[var(--sidebar-content-inset)]">
- <div className="flex h-8 items-center gap-2 rounded-md px-2 py-1.5 text-sm font-medium text-sidebar-muted-foreground hover:bg-sidebar-row-hover hover:text-sidebar-foreground">
+ <SidebarMenuButton
+ className="hidden group-data-[collapsible=icon]:flex"
+ aria-label="Search settings"
+ tooltip="Search settings"
+ onClick={() => {
+ setOpen(true);
+ requestAnimationFrame(() => searchInputRef.current?.focus());
+ }}
+ >
+ <SearchIcon />
+ </SidebarMenuButton>
+ <div className="flex h-8 items-center gap-2 rounded-md px-2 py-1.5 text-sm font-medium text-sidebar-muted-foreground hover:bg-sidebar-row-hover hover:text-sidebar-foreground group-data-[collapsible=icon]:hidden">
<SearchIcon className="size-4 shrink-0 text-sidebar-muted-foreground/80" />
<Input
ref={searchInputRef}
@@ -330,10 +343,14 @@ export function SettingsSidebarNav({ pathname }: { pathname: string }) {
<SidebarMenuItem key={item.to}>
<SidebarMenuButton
isActive={isActive}
+ aria-label={item.label}
+ tooltip={item.label}
onClick={() => handleSectionClick(item.to)}
>
<Icon />
- <span className="truncate">{item.label}</span>
+ <span className="truncate group-data-[collapsible=icon]:hidden">
+ {item.label}
+ </span>
</SidebarMenuButton>
</SidebarMenuItem>
);
@@ -343,10 +360,12 @@ export function SettingsSidebarNav({ pathname }: { pathname: string }) {
</SidebarGroup>
</SidebarContent>
<SidebarFooter className="px-[var(--sidebar-content-inset)] py-1">
- <Suspense fallback={null}>
- <T3ConnectSidebarSignIn />
- </Suspense>
- <div className="flex items-center gap-1">
+ <div className="contents group-data-[collapsible=icon]:hidden">
+ <Suspense fallback={null}>
+ <T3ConnectSidebarSignIn />
+ </Suspense>
+ </div>
+ <div className="flex items-center gap-1 group-data-[collapsible=icon]:flex-col">
<div className="min-w-0 flex-1">
<SidebarUtilityMenu />
</div>
diff --git a/apps/web/src/components/settings/settingsSearch.ts b/apps/web/src/components/settings/settingsSearch.ts
index fefadbaaa9e..067ba54d1ec 100644
--- a/apps/web/src/components/settings/settingsSearch.ts
+++ b/apps/web/src/components/settings/settingsSearch.ts
@@ -159,6 +159,12 @@ export const SETTINGS_SEARCH_ITEMS = [
title: "Panel animations",
to: "/settings/appearance",
},
+ {
+ id: "compact-sidebar",
+ title: "Compact sidebar",
+ to: "/settings/appearance",
+ searchTerms: ["collapsed icons rail hover navigation preview"],
+ },
{
id: "environment-identification",
title: "Environment identification",
diff --git a/apps/web/src/components/sidebar/SidebarChrome.tsx b/apps/web/src/components/sidebar/SidebarChrome.tsx
index afbbf7671df..2f65cf8c369 100644
--- a/apps/web/src/components/sidebar/SidebarChrome.tsx
+++ b/apps/web/src/components/sidebar/SidebarChrome.tsx
@@ -86,7 +86,7 @@ function SidebarBrand({ onBackdrop }: { onBackdrop: boolean }) {
<Link
aria-label="Go to threads"
className={cn(
- "relative z-10 ml-[var(--workspace-titlebar-content-left)] hidden h-7 w-fit min-w-0 shrink-0 items-center overflow-hidden rounded-md outline-hidden ring-ring focus-visible:ring-2 md:flex",
+ "relative z-10 ml-[var(--workspace-titlebar-content-left)] hidden h-7 w-fit min-w-0 shrink-0 items-center overflow-hidden rounded-md outline-hidden ring-ring focus-visible:ring-2 md:flex group-data-[collapsible=icon]:hidden",
onBackdrop ? "text-white" : "text-foreground",
)}
to="/"
@@ -187,12 +187,12 @@ export const SidebarUtilityMenu = memo(function SidebarUtilityMenu() {
}, [canGoBack, closeMobileSidebar, navigate]);
return (
- <SidebarMenu className="flex-row items-center">
+ <SidebarMenu className="flex-row items-center group-data-[collapsible=icon]:flex-col">
{currentFooterPage ? (
<SidebarMenuItem className="min-w-0 flex-1">
- <SidebarMenuButton onClick={handleBackClick}>
+ <SidebarMenuButton onClick={handleBackClick} aria-label="Back" tooltip="Back">
<ArrowLeftIcon />
- <span>Back</span>
+ <span className="group-data-[collapsible=icon]:hidden">Back</span>
</SidebarMenuButton>
</SidebarMenuItem>
) : (
@@ -224,8 +224,10 @@ export const SidebarUtilityMenu = memo(function SidebarUtilityMenu() {
export const SidebarChromeFooter = memo(function SidebarChromeFooter() {
return (
<SidebarFooter className="px-[var(--sidebar-content-inset)] py-1">
- <SidebarProviderUpdatePill />
- <SidebarUpdateArchitectureWarning />
+ <div className="contents group-data-[collapsible=icon]:hidden">
+ <SidebarProviderUpdatePill />
+ <SidebarUpdateArchitectureWarning />
+ </div>
<SidebarUtilityMenu />
</SidebarFooter>
);
diff --git a/apps/web/src/components/sidebar/SidebarThreadHeader.tsx b/apps/web/src/components/sidebar/SidebarThreadHeader.tsx
index 878235615b3..d0718d9856f 100644
--- a/apps/web/src/components/sidebar/SidebarThreadHeader.tsx
+++ b/apps/web/src/components/sidebar/SidebarThreadHeader.tsx
@@ -20,9 +20,10 @@ import {
} from "react";
import { cn } from "~/lib/utils";
+import { useCompactSidebarEnabled } from "../../hooks/useSettings";
import { Button } from "../ui/button";
import { Input } from "../ui/input";
-import { SidebarMenuButton } from "../ui/sidebar";
+import { SidebarMenuButton, useSidebar } from "../ui/sidebar";
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
export interface SidebarThreadHeaderProps {
@@ -69,6 +70,9 @@ export function SidebarThreadHeader({
activeSearchResultIndex,
onClearSearch,
}: SidebarThreadHeaderProps) {
+ const compactEnabled = useCompactSidebarEnabled();
+ const { state, isMobile, setOpen } = useSidebar();
+ const compact = compactEnabled && state === "collapsed" && !isMobile;
const resultsVisible = isSearching && searchResultCount > 0;
// Results shrink as the query narrows, so the active index can outrun the
// list; pointing aria-activedescendant at a removed option strands the
@@ -79,10 +83,24 @@ export function SidebarThreadHeader({
: "New thread";
return (
- <div className="flex items-center gap-1">
+ <div className={cn("flex items-center gap-1", compact && "flex-col")}>
+ {compact ? (
+ <SidebarHeaderIconButton
+ label="Search threads"
+ onClick={() => {
+ setOpen(true);
+ requestAnimationFrame(() => searchInputRef.current?.focus());
+ }}
+ >
+ <SearchIcon />
+ </SidebarHeaderIconButton>
+ ) : null}
<div
ref={searchFieldRef}
- className="flex h-8 min-w-0 flex-1 items-center gap-2 rounded-md px-2 py-1.5 text-sm font-medium text-sidebar-muted-foreground hover:bg-sidebar-row-hover hover:text-sidebar-foreground"
+ className={cn(
+ "flex h-8 min-w-0 flex-1 items-center gap-2 rounded-md px-2 py-1.5 text-sm font-medium text-sidebar-muted-foreground hover:bg-sidebar-row-hover hover:text-sidebar-foreground",
+ compact && "hidden",
+ )}
>
<SearchIcon className="size-4 shrink-0 text-[var(--sidebar-icon-color)]" />
<Input
@@ -124,7 +142,12 @@ export function SidebarThreadHeader({
</div>
{/* Segmented well: the icons read as one control instead of three loose
buttons competing with the search field beside them. */}
- <div className="flex shrink-0 items-center rounded-md bg-sidebar-control-surface/60 p-px">
+ <div
+ className={cn(
+ "flex shrink-0 items-center rounded-md bg-sidebar-control-surface/60 p-px",
+ compact && "flex-col",
+ )}
+ >
{hasProjects ? (
<>
{projectScope}
diff --git a/apps/web/src/components/sidebar/SidebarUpdatePill.tsx b/apps/web/src/components/sidebar/SidebarUpdatePill.tsx
index a94b7801ecf..8c04eec6fe7 100644
--- a/apps/web/src/components/sidebar/SidebarUpdatePill.tsx
+++ b/apps/web/src/components/sidebar/SidebarUpdatePill.tsx
@@ -348,7 +348,7 @@ function SidebarUpdateControl() {
);
return (
- <SidebarMenuItem className="ml-auto shrink-0">
+ <SidebarMenuItem className="ml-auto shrink-0 group-data-[collapsible=icon]:hidden">
<Popover
handle={releaseNotesPopoverHandle}
onOpenChange={(open, details) => {
diff --git a/apps/web/src/components/ui/sidebar.tsx b/apps/web/src/components/ui/sidebar.tsx
index 307feda7abf..404295f5f5c 100644
--- a/apps/web/src/components/ui/sidebar.tsx
+++ b/apps/web/src/components/ui/sidebar.tsx
@@ -591,9 +591,11 @@ function SidebarSeparator({ className, ...props }: React.ComponentProps<typeof S
function SidebarContent({
className,
fixedHeader,
+ fixedFooter,
...props
}: React.ComponentProps<"div"> & {
fixedHeader?: React.ReactNode;
+ fixedFooter?: React.ReactNode;
}) {
return (
<>
@@ -617,6 +619,7 @@ function SidebarContent({
{...props}
/>
</ScrollArea>
+ {fixedFooter ? <div className="w-full shrink-0">{fixedFooter}</div> : null}
</>
);
}
diff --git a/apps/web/src/hooks/useSettings.ts b/apps/web/src/hooks/useSettings.ts
index 194cc36c55f..fa4b8bc8fd3 100644
--- a/apps/web/src/hooks/useSettings.ts
+++ b/apps/web/src/hooks/useSettings.ts
@@ -379,6 +379,13 @@ export function useLegacySidebarEnabled(): boolean {
return settingsHydrated && legacySidebarEnabled;
}
+/** Keep the default collapsed sidebar until persisted client settings hydrate. */
+export function useCompactSidebarEnabled(): boolean {
+ const settingsHydrated = useClientSettingsHydrated();
+ const compactSidebarEnabled = useClientSettingsValue().compactSidebarEnabled;
+ return settingsHydrated && compactSidebarEnabled;
+}
+
/** Read current settings for one environment, merged with client-local preferences. */
export function useEnvironmentSettings<T = UnifiedSettings>(
environmentId: EnvironmentId,
diff --git a/apps/web/src/workspaceTitlebar.ts b/apps/web/src/workspaceTitlebar.ts
index b481221e63a..aed95897cc5 100644
--- a/apps/web/src/workspaceTitlebar.ts
+++ b/apps/web/src/workspaceTitlebar.ts
@@ -1,2 +1,2 @@
export const COLLAPSED_SIDEBAR_TITLEBAR_INSET_CLASS =
- "[[data-sidebar-state=collapsed]_&]:pl-[var(--workspace-titlebar-content-left)]";
+ "[[data-sidebar-state=collapsed]_&]:pl-[var(--workspace-titlebar-content-left)] [[data-sidebar-state=collapsed]:has([data-side=left][data-collapsible=icon])_&]:pl-[max(calc(env(safe-area-inset-left)+1.25rem),calc(var(--workspace-titlebar-content-left)-var(--sidebar-width-icon)))]";
diff --git a/packages/contracts/src/settings.ts b/packages/contracts/src/settings.ts
index 004a53b320e..826440556d2 100644
--- a/packages/contracts/src/settings.ts
+++ b/packages/contracts/src/settings.ts
@@ -436,6 +436,7 @@ export const ClientSettingsSchema = Schema.Struct({
// old keys, so everyone, including prior beta opt-outs, resets to the new
// default sidebar.
legacySidebarEnabled: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
+ compactSidebarEnabled: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
sidebarProjectGroupingMode: SidebarProjectGroupingMode.pipe(
Schema.withDecodingDefault(Effect.succeed(DEFAULT_SIDEBAR_PROJECT_GROUPING_MODE)),
),
@@ -1490,6 +1491,7 @@ export const ClientSettingsPatch = Schema.Struct({
proactivePanelsEnabled: Schema.optionalKey(Schema.Boolean),
showSkillsInSlashMenu: Schema.optionalKey(Schema.Boolean),
legacySidebarEnabled: Schema.optionalKey(Schema.Boolean),
+ compactSidebarEnabled: Schema.optionalKey(Schema.Boolean),
sidebarProjectGroupingMode: Schema.optionalKey(SidebarProjectGroupingMode),
sidebarProjectGroupingOverrides: Schema.optionalKey(
Schema.Record(TrimmedNonEmptyString, SidebarProjectGroupingMode),