feat(web): add compact thread list mode (#9417)
Deploy T3 Connect relay / Deploy production relay (push) Has been cancelled
Mobile EAS Production / EAS Production ${{ github.event_name == 'push' && 'auto' || inputs.mode }} (push) Has been cancelled
CI / Check (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Test Server 1 (push) Has been cancelled
CI / Test Server 2 (push) Has been cancelled
CI / Test Server 3 (push) Has been cancelled
CI / Rust (push) Has been cancelled
CI / Mobile Native Changes (push) Has been cancelled
CI / Release Smoke (push) Has been cancelled
Forward to Cursor hygiene / POST to Cursor (push) Has been cancelled
Issue Labels / Sync issue labels (push) Has been cancelled
PR Vouch / Collect PR targets (push) Has been cancelled
CI / Mobile Native Static Analysis (push) Has been cancelled
PR Vouch / Label PR ${{ matrix.target.number }} (push) Has been cancelled
Deploy T3 Connect relay / Deploy production relay (push) Has been cancelled
Mobile EAS Production / EAS Production ${{ github.event_name == 'push' && 'auto' || inputs.mode }} (push) Has been cancelled
CI / Check (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Test Server 1 (push) Has been cancelled
CI / Test Server 2 (push) Has been cancelled
CI / Test Server 3 (push) Has been cancelled
CI / Rust (push) Has been cancelled
CI / Mobile Native Changes (push) Has been cancelled
CI / Release Smoke (push) Has been cancelled
Forward to Cursor hygiene / POST to Cursor (push) Has been cancelled
Issue Labels / Sync issue labels (push) Has been cancelled
PR Vouch / Collect PR targets (push) Has been cancelled
CI / Mobile Native Static Analysis (push) Has been cancelled
PR Vouch / Label PR ${{ matrix.target.number }} (push) Has been cancelled
Co-authored-by: Claude Opus 5 (1M context) <[email protected]> Co-authored-by: maria-rcks <[email protected]>
This commit is contained in:
11 files changed
+373
-102
No files matched your search
@@ -57,6 +57,7 @@ const clientSettings: ClientSettings = {
|
||||
proactivePanelsEnabled: true,
|
||||
showSkillsInSlashMenu: false,
|
||||
providerModelPreferences: {},
|
||||
sidebarCompactThreadRows: false,
|
||||
sidebarProjectGroupingMode: "repository_path",
|
||||
sidebarProjectGroupingOverrides: {
|
||||
"environment-1:/tmp/project-a": "separate",
|
||||
|
||||
@@ -124,6 +124,7 @@ import { startNewThreadFromContext } from "../lib/chatThreadActions";
|
||||
import { useClientSettings } from "../hooks/useSettings";
|
||||
import { useCopyToClipboard } from "../hooks/useCopyToClipboard";
|
||||
import { useLocalStorage } from "../hooks/useLocalStorage";
|
||||
import { SidebarCompletedTime } from "./sidebar/SidebarCompletedTime";
|
||||
import { useNowMinute } from "../hooks/useNowMinute";
|
||||
import { useEnvironments, usePrimaryEnvironmentId } from "../state/environments";
|
||||
import {
|
||||
@@ -1031,6 +1032,7 @@ const dropVerbBadge: Record<SidebarDropVerb, ReactNode> = {
|
||||
const SidebarThreadRow = memo(function SidebarThreadRow(props: {
|
||||
thread: SidebarThreadSummary;
|
||||
variant: "card" | "slim";
|
||||
compact: boolean;
|
||||
// Slim rows are either settled (action: un-settle) or merely quiet
|
||||
// (seen Ready threads — action: settle).
|
||||
variantAction: "settle" | "unsettle" | "unsnooze";
|
||||
@@ -1292,7 +1294,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {
|
||||
terminalStatus={terminalStatus}
|
||||
terminalProcessCount={terminalProcessCount}
|
||||
compactStatus={
|
||||
compact
|
||||
compact || (props.compact && variant === "card")
|
||||
? (topStatus?.label ??
|
||||
(variantAction === "unsnooze"
|
||||
? "Snoozed"
|
||||
@@ -1878,6 +1880,22 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {
|
||||
);
|
||||
}
|
||||
|
||||
const compactRows = props.compact;
|
||||
const CompactStatusIcon = topStatus
|
||||
? {
|
||||
working: CircleDashedIcon,
|
||||
monitoring: EyeIcon,
|
||||
approval: ShieldQuestionIcon,
|
||||
input: MessageCircleQuestionIcon,
|
||||
failed: CircleAlertIcon,
|
||||
woke: AlarmClockIcon,
|
||||
done: CircleCheckIcon,
|
||||
}[topStatus.icon]
|
||||
: null;
|
||||
const compactCompletedAt =
|
||||
compactRows && status === "ready" && !isWokeStatus
|
||||
? (thread.latestTurn?.completedAt ?? null)
|
||||
: null;
|
||||
const diff = latestTurnDiff(thread);
|
||||
|
||||
return (
|
||||
@@ -1886,8 +1904,10 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {
|
||||
{...sortableRootProps}
|
||||
{...(fileDropHandlers ?? {})}
|
||||
className={cn(
|
||||
// Matches the h-[4.875rem] content box; the py-0.5 padding is added on top.
|
||||
"list-none py-0.5 [content-visibility:auto] [contain-intrinsic-size:auto_78px]",
|
||||
"list-none [content-visibility:auto]",
|
||||
compactRows
|
||||
? "[contain-intrinsic-size:auto_36px]"
|
||||
: "py-0.5 [contain-intrinsic-size:auto_78px]",
|
||||
sortable?.isDragging && "relative z-20",
|
||||
)}
|
||||
>
|
||||
@@ -1902,7 +1922,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {
|
||||
ref={rowRef}
|
||||
role="button"
|
||||
tabIndex={0}
|
||||
data-testid="sidebar-row-card"
|
||||
data-testid={compactRows ? "sidebar-row-compact" : "sidebar-row-card"}
|
||||
aria-busy={isRegeneratingTitle || undefined}
|
||||
className={rowSurfaceClassName}
|
||||
onClick={handleClick}
|
||||
@@ -1912,13 +1932,22 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {
|
||||
/>
|
||||
}
|
||||
>
|
||||
<div className="relative z-10 h-[4.875rem] px-[var(--sidebar-row-content-inset)] py-[var(--sidebar-content-inset)]">
|
||||
<div className="flex h-5 min-w-0 items-center gap-1.5">
|
||||
<div
|
||||
className={cn(
|
||||
"relative z-10",
|
||||
compactRows
|
||||
? "flex h-9 items-center px-2.5"
|
||||
: "h-[4.875rem] px-[var(--sidebar-row-content-inset)] py-[var(--sidebar-content-inset)]",
|
||||
)}
|
||||
>
|
||||
<div className="flex h-5 w-full min-w-0 items-center gap-1.5">
|
||||
{draftIndicator}
|
||||
{props.project ? (
|
||||
<ProjectFavicon project={props.project} className="size-4 shrink-0" />
|
||||
) : null}
|
||||
{props.projectDisplayName ? (
|
||||
{compactRows ? (
|
||||
title
|
||||
) : props.projectDisplayName ? (
|
||||
<span
|
||||
className={cn(
|
||||
"min-w-0 flex-1 truncate text-secondary-label text-xs",
|
||||
@@ -1931,6 +1960,50 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {
|
||||
<span className="flex-1" />
|
||||
)}
|
||||
{pinIndicator}
|
||||
{compactRows ? (
|
||||
<>
|
||||
{isRemote ? (
|
||||
<span
|
||||
role="img"
|
||||
aria-label={props.environmentLabel ?? "Remote environment"}
|
||||
className="inline-flex shrink-0 text-sidebar-muted-foreground/70"
|
||||
>
|
||||
<EnvironmentMachineIcon
|
||||
kind={props.environmentMachine}
|
||||
className="size-3.5"
|
||||
/>
|
||||
</span>
|
||||
) : null}
|
||||
{terminalStatusIcon}
|
||||
{topStatus && CompactStatusIcon ? (
|
||||
isWokeStatus ? (
|
||||
<button
|
||||
type="button"
|
||||
aria-label="Dismiss Woke notification"
|
||||
onClick={handleAcknowledgeWokeClick}
|
||||
className={cn(
|
||||
"shrink-0 rounded-sm outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
||||
topStatus.className,
|
||||
)}
|
||||
>
|
||||
<CompactStatusIcon aria-hidden className="size-3.5" />
|
||||
<span role="status" className="sr-only">
|
||||
{topStatus.label}
|
||||
</span>
|
||||
</button>
|
||||
) : (
|
||||
<span
|
||||
role="status"
|
||||
className={cn("inline-flex shrink-0", topStatus.className)}
|
||||
>
|
||||
<CompactStatusIcon aria-hidden className="size-3.5" />
|
||||
<span className="sr-only">{topStatus.label}</span>
|
||||
</span>
|
||||
)
|
||||
) : null}
|
||||
{prBadge}
|
||||
</>
|
||||
) : null}
|
||||
{/* The visible state owns this slot's width: status at rest,
|
||||
actions on hover/keyboard focus or while the popover is open. Keeping
|
||||
the hidden state out of flow lets the project label reclaim
|
||||
@@ -1938,20 +2011,33 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {
|
||||
{sortable?.isDragging ? (
|
||||
dragDestination
|
||||
) : (
|
||||
<span className="group/sidebar-status-slot relative ml-auto flex h-5 min-w-8 shrink-0 items-stretch justify-end text-xs">
|
||||
<span
|
||||
className={cn(
|
||||
"group/sidebar-status-slot relative ml-auto flex h-5 shrink-0 items-stretch justify-end text-xs",
|
||||
!compactRows && "min-w-8",
|
||||
)}
|
||||
>
|
||||
{/* Read-only status labels yield to the hover actions. Woke is
|
||||
itself an action, so it stays pointer-enabled and visible
|
||||
while the other controls appear beside it. */}
|
||||
<span
|
||||
className={cn(
|
||||
isWokeStatus
|
||||
isWokeStatus && !compactRows
|
||||
? "pointer-events-auto"
|
||||
: "pointer-events-none group-has-[:focus-visible]/sidebar-status-slot:absolute group-has-[:focus-visible]/sidebar-status-slot:right-0 group-has-[:focus-visible]/sidebar-status-slot:opacity-0 group-hover/sidebar-row:absolute group-hover/sidebar-row:right-0 group-hover/sidebar-row:opacity-0",
|
||||
"flex items-center self-center justify-self-end tabular-nums text-secondary-label transition-opacity",
|
||||
snoozeMenuOpen && "pointer-events-none absolute right-0 opacity-0",
|
||||
)}
|
||||
>
|
||||
{topStatus ? (
|
||||
{compactRows ? (
|
||||
status === "working" ? (
|
||||
<WorkingDuration startedAt={resolveWorkingStartedAt(thread)} />
|
||||
) : compactCompletedAt ? (
|
||||
<SidebarCompletedTime completedAt={compactCompletedAt} />
|
||||
) : (
|
||||
threadTimeLabel(thread)
|
||||
)
|
||||
) : topStatus ? (
|
||||
isWokeStatus ? (
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
@@ -2057,7 +2143,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {
|
||||
}
|
||||
>
|
||||
<CheckIcon className="size-3.5" />
|
||||
Settle
|
||||
{compactRows ? null : "Settle"}
|
||||
</TooltipTrigger>
|
||||
<TooltipPopup>Settle thread</TooltipPopup>
|
||||
</Tooltip>
|
||||
@@ -2067,68 +2153,70 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: {
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<div className="mt-1 flex min-w-0">
|
||||
{title}
|
||||
{isRegeneratingTitle ? (
|
||||
<span role="status" className="sr-only">
|
||||
Regenerating title
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="mt-0.5 flex min-w-0 items-center gap-1.5 text-secondary-label text-xs">
|
||||
{/* Always the branch. The plan step used to take this slot while
|
||||
{isRegeneratingTitle ? (
|
||||
<span role="status" className="sr-only">
|
||||
Regenerating title
|
||||
</span>
|
||||
) : null}
|
||||
{compactRows ? null : (
|
||||
<>
|
||||
<div className="mt-1 flex min-w-0">{title}</div>
|
||||
<div className="mt-0.5 flex min-w-0 items-center gap-1.5 text-secondary-label text-xs">
|
||||
{/* Always the branch. The plan step used to take this slot while
|
||||
working, but it truncated to a half-sentence and dropped the
|
||||
branch, so the row lost its most stable identifier. */}
|
||||
{thread.branch ? (
|
||||
<>
|
||||
<ThreadWorktreeIndicator thread={thread} />
|
||||
<span className="min-w-0 flex-1 truncate whitespace-nowrap text-muted-foreground/40">
|
||||
{thread.branch}
|
||||
{thread.branch ? (
|
||||
<>
|
||||
<ThreadWorktreeIndicator thread={thread} />
|
||||
<span className="min-w-0 flex-1 truncate whitespace-nowrap text-muted-foreground/40">
|
||||
{thread.branch}
|
||||
</span>
|
||||
</>
|
||||
) : (
|
||||
<span className="flex-1" />
|
||||
)}
|
||||
{terminalStatusIcon}
|
||||
{prBadge}
|
||||
{diff ? (
|
||||
<span className="shrink-0 font-mono">
|
||||
<span className="text-diff-addition-foreground">+{diff.insertions}</span>{" "}
|
||||
<span className="text-diff-deletion-foreground">−{diff.deletions}</span>
|
||||
</span>
|
||||
) : null}
|
||||
<span
|
||||
aria-hidden
|
||||
className="pointer-events-none ml-auto inline-flex shrink-0 items-center gap-1"
|
||||
>
|
||||
{isRemote ? (
|
||||
<span className="inline-flex shrink-0 items-center text-sidebar-muted-foreground/70">
|
||||
<EnvironmentMachineIcon
|
||||
aria-hidden
|
||||
kind={props.environmentMachine}
|
||||
className="size-3.5"
|
||||
/>
|
||||
</span>
|
||||
) : null}
|
||||
{driverKind ? (
|
||||
<span className="inline-flex shrink-0 items-center">
|
||||
<ProviderInstanceIcon
|
||||
driverKind={driverKind}
|
||||
displayName={
|
||||
providerEntry?.displayName ??
|
||||
thread.session?.providerName ??
|
||||
modelInstanceId
|
||||
}
|
||||
accentColor={providerEntry?.accentColor}
|
||||
showBadge={showInstanceBadge}
|
||||
// Glyph dims, badge stays saturated; offset matches the composer trigger.
|
||||
iconClassName="size-3.5 opacity-60"
|
||||
badgeClassName="right-[-0.1875rem] bottom-[-0.1875rem] h-3 min-w-3 px-0.5 text-[7px]"
|
||||
/>
|
||||
</span>
|
||||
) : null}
|
||||
</span>
|
||||
</>
|
||||
) : (
|
||||
<span className="flex-1" />
|
||||
)}
|
||||
{terminalStatusIcon}
|
||||
{prBadge}
|
||||
{diff ? (
|
||||
<span className="shrink-0 font-mono">
|
||||
<span className="text-diff-addition-foreground">+{diff.insertions}</span>{" "}
|
||||
<span className="text-diff-deletion-foreground">−{diff.deletions}</span>
|
||||
</span>
|
||||
) : null}
|
||||
<span
|
||||
aria-hidden
|
||||
className="pointer-events-none ml-auto inline-flex shrink-0 items-center gap-1"
|
||||
>
|
||||
{isRemote ? (
|
||||
<span className="inline-flex shrink-0 items-center text-sidebar-muted-foreground/70">
|
||||
<EnvironmentMachineIcon
|
||||
aria-hidden
|
||||
kind={props.environmentMachine}
|
||||
className="size-3.5"
|
||||
/>
|
||||
</span>
|
||||
) : null}
|
||||
{driverKind ? (
|
||||
<span className="inline-flex shrink-0 items-center">
|
||||
<ProviderInstanceIcon
|
||||
driverKind={driverKind}
|
||||
displayName={
|
||||
providerEntry?.displayName ??
|
||||
thread.session?.providerName ??
|
||||
modelInstanceId
|
||||
}
|
||||
accentColor={providerEntry?.accentColor}
|
||||
showBadge={showInstanceBadge}
|
||||
// Glyph dims, badge stays saturated; offset matches the composer trigger.
|
||||
iconClassName="size-3.5 opacity-60"
|
||||
badgeClassName="right-[-0.1875rem] bottom-[-0.1875rem] h-3 min-w-3 px-0.5 text-[7px]"
|
||||
/>
|
||||
</span>
|
||||
) : null}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
{props.jumpLabel ? <JumpHintBadge label={props.jumpLabel} /> : null}
|
||||
</TooltipTrigger>
|
||||
@@ -2303,6 +2391,7 @@ export default function Sidebar() {
|
||||
const compact = compactEnabled && sidebarState === "collapsed" && !isMobile;
|
||||
const [snoozedFooter, setSnoozedFooter] = useState<HTMLUListElement | null>(null);
|
||||
const keybindings = useAtomValue(primaryServerKeybindingsAtom);
|
||||
const compactThreadRows = useClientSettings((s) => s.sidebarCompactThreadRows);
|
||||
const confirmThreadDelete = useClientSettings((s) => s.confirmThreadDelete);
|
||||
const confirmThreadArchive = useClientSettings((s) => s.confirmThreadArchive);
|
||||
const sidebarProjectSortOrder = useClientSettings((s) => s.sidebarProjectSortOrder);
|
||||
@@ -4829,10 +4918,9 @@ export default function Sidebar() {
|
||||
const threadKey = scopedThreadKey(
|
||||
scopeThreadRef(thread.environmentId, thread.id),
|
||||
);
|
||||
// Settled and snoozed are the ONLY things that collapse a
|
||||
// row: every other thread is a full card. Density comes
|
||||
// from users (or the auto rules) actually parking work,
|
||||
// not from the sidebar second-guessing what still matters.
|
||||
// Settled and snoozed always use slim rows. Active and
|
||||
// pinned threads use cards unless the user has explicitly
|
||||
// enabled the compact thread-list preference.
|
||||
const isCard = section === "active" || section === "pinned";
|
||||
const rowVariant = isCard ? "card" : "slim";
|
||||
return (
|
||||
@@ -4842,6 +4930,7 @@ export default function Sidebar() {
|
||||
key={`${threadKey}:${rowVariant}`}
|
||||
thread={thread}
|
||||
variant={rowVariant}
|
||||
compact={compactThreadRows}
|
||||
// Snoozed rows wake, settled rows un-settle, and cards settle.
|
||||
variantAction={
|
||||
section === "snoozed"
|
||||
|
||||
@@ -1,9 +1,30 @@
|
||||
import { useState } from "react";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
|
||||
import { cn } from "~/lib/utils";
|
||||
|
||||
export function CompactSidebarPreview() {
|
||||
export function CompactSidebarPreview({
|
||||
railEnabled,
|
||||
compactRows,
|
||||
}: {
|
||||
railEnabled: boolean;
|
||||
compactRows: boolean;
|
||||
}) {
|
||||
const [collapsed, setCollapsed] = useState(false);
|
||||
const sidebarRef = useRef<HTMLSpanElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) return;
|
||||
const animation = sidebarRef.current?.animate(
|
||||
[
|
||||
{ width: "36px", offset: 0 },
|
||||
{ width: railEnabled ? "12px" : "0px", offset: 0.45 },
|
||||
{ width: railEnabled ? "12px" : "0px", offset: 0.6 },
|
||||
{ width: "36px", offset: 1 },
|
||||
],
|
||||
{ duration: 800, easing: "ease-in-out" },
|
||||
);
|
||||
return () => animation?.cancel();
|
||||
}, [railEnabled, compactRows]);
|
||||
|
||||
return (
|
||||
<button
|
||||
@@ -11,24 +32,31 @@ export function CompactSidebarPreview() {
|
||||
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)}
|
||||
onClick={() => {
|
||||
sidebarRef.current?.getAnimations().forEach((animation) => animation.cancel());
|
||||
setCollapsed((value) => !value);
|
||||
}}
|
||||
>
|
||||
<span
|
||||
ref={sidebarRef}
|
||||
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",
|
||||
"flex h-full shrink-0 flex-col justify-center gap-1 overflow-hidden rounded-md bg-sidebar transition-[width] duration-250 ease-out motion-reduce:transition-none",
|
||||
collapsed ? (railEnabled ? "w-3" : "w-0") : "w-9",
|
||||
)}
|
||||
>
|
||||
{[0, 1, 2].map((row) => (
|
||||
<span key={row} className="flex h-1 shrink-0 items-center gap-1">
|
||||
{(compactRows ? [0, 1, 2, 3] : [0, 1, 2]).map((row) => (
|
||||
<span key={row} className="flex shrink-0 items-start gap-1 px-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",
|
||||
"flex shrink-0 flex-col gap-0.5 transition-opacity duration-250 ease-out motion-reduce:transition-none",
|
||||
collapsed && "opacity-0",
|
||||
)}
|
||||
/>
|
||||
>
|
||||
<span className="h-0.5 w-4 rounded-full bg-muted-foreground/25" />
|
||||
{!compactRows && <span className="h-0.5 w-2 rounded-full bg-muted-foreground/15" />}
|
||||
</span>
|
||||
</span>
|
||||
))}
|
||||
</span>
|
||||
@@ -42,6 +70,7 @@ export function CompactSidebarPreview() {
|
||||
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 &&
|
||||
railEnabled &&
|
||||
"group-hover/compact-preview:opacity-100 group-focus-visible/compact-preview:opacity-100",
|
||||
)}
|
||||
>
|
||||
|
||||
@@ -502,7 +502,8 @@ export function useSettingsRestore(onRestored?: () => void) {
|
||||
...(theme !== "system" ? ["Theme"] : []),
|
||||
...(!followSystem ? ["Follow system"] : []),
|
||||
...(themeHalves !== null ? ["Theme mix"] : []),
|
||||
...(settings.compactSidebarEnabled !== DEFAULT_UNIFIED_SETTINGS.compactSidebarEnabled
|
||||
...(settings.compactSidebarEnabled !== DEFAULT_UNIFIED_SETTINGS.compactSidebarEnabled ||
|
||||
settings.sidebarCompactThreadRows !== DEFAULT_UNIFIED_SETTINGS.sidebarCompactThreadRows
|
||||
? ["Compact sidebar"]
|
||||
: []),
|
||||
...(settings.appearanceContrast !== DEFAULT_UNIFIED_SETTINGS.appearanceContrast
|
||||
@@ -644,6 +645,7 @@ export function useSettingsRestore(onRestored?: () => void) {
|
||||
settings.continueThreadsAfterServerUpdate,
|
||||
settings.sidebarAutoSettleAfterDays,
|
||||
settings.sidebarAutoSettleOnMerge,
|
||||
settings.sidebarCompactThreadRows,
|
||||
settings.sidebarProjectGroupingMode,
|
||||
settings.sidebarThreadPreviewCount,
|
||||
settings.showSkillsInSlashMenu,
|
||||
@@ -739,6 +741,7 @@ export function useSettingsRestore(onRestored?: () => void) {
|
||||
panelAnimationDurationMs: DEFAULT_UNIFIED_SETTINGS.panelAnimationDurationMs,
|
||||
sidebarThreadPreviewCount: DEFAULT_UNIFIED_SETTINGS.sidebarThreadPreviewCount,
|
||||
sidebarProjectGroupingMode: DEFAULT_UNIFIED_SETTINGS.sidebarProjectGroupingMode,
|
||||
sidebarCompactThreadRows: DEFAULT_UNIFIED_SETTINGS.sidebarCompactThreadRows,
|
||||
sidebarAutoSettleAfterDays: DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleAfterDays,
|
||||
sidebarAutoSettleOnMerge: DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleOnMerge,
|
||||
enableLegacyTokenStreaming: DEFAULT_UNIFIED_SETTINGS.enableLegacyTokenStreaming,
|
||||
@@ -1081,6 +1084,19 @@ export function AppearanceSettingsPanel() {
|
||||
const [isImportThemeOpen, setIsImportThemeOpen] = useState(false);
|
||||
const settings = useScopedSettings();
|
||||
const updateSettings = useUpdateScopedSettings();
|
||||
const compactSidebarMode = settings.compactSidebarEnabled
|
||||
? settings.sidebarCompactThreadRows
|
||||
? "both"
|
||||
: "rail"
|
||||
: settings.sidebarCompactThreadRows
|
||||
? "threads"
|
||||
: "off";
|
||||
const compactSidebarModes = {
|
||||
off: "Off",
|
||||
rail: "Rail only",
|
||||
threads: "Threads only",
|
||||
both: "Both",
|
||||
};
|
||||
const environmentStageLabel = useEnvironmentStageLabel();
|
||||
const showEnvironmentIdentification =
|
||||
resolveEnvironmentIdentificationPillLabel(environmentStageLabel) !== null;
|
||||
@@ -1370,19 +1386,56 @@ export function AppearanceSettingsPanel() {
|
||||
<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."
|
||||
description="Choose a collapsed icon rail, denser thread rows, or both. Click the preview to collapse or expand."
|
||||
resetAction={
|
||||
settings.compactSidebarEnabled !== DEFAULT_UNIFIED_SETTINGS.compactSidebarEnabled ||
|
||||
settings.sidebarCompactThreadRows !==
|
||||
DEFAULT_UNIFIED_SETTINGS.sidebarCompactThreadRows ? (
|
||||
<SettingResetButton
|
||||
label="compact sidebar"
|
||||
onClick={() =>
|
||||
updateSettings({
|
||||
compactSidebarEnabled: DEFAULT_UNIFIED_SETTINGS.compactSidebarEnabled,
|
||||
sidebarCompactThreadRows: DEFAULT_UNIFIED_SETTINGS.sidebarCompactThreadRows,
|
||||
})
|
||||
}
|
||||
/>
|
||||
) : null
|
||||
}
|
||||
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 className="grid w-full grid-cols-[5rem_1fr] items-center gap-3 sm:w-auto sm:grid-cols-[7rem_10rem] sm:gap-4">
|
||||
<CompactSidebarPreview
|
||||
key={compactSidebarMode}
|
||||
railEnabled={settings.compactSidebarEnabled}
|
||||
compactRows={settings.sidebarCompactThreadRows}
|
||||
/>
|
||||
<Select
|
||||
value={compactSidebarMode}
|
||||
onValueChange={(value) => {
|
||||
if (
|
||||
value !== "off" &&
|
||||
value !== "rail" &&
|
||||
value !== "threads" &&
|
||||
value !== "both"
|
||||
)
|
||||
return;
|
||||
updateSettings({
|
||||
compactSidebarEnabled: value === "rail" || value === "both",
|
||||
sidebarCompactThreadRows: value === "threads" || value === "both",
|
||||
});
|
||||
}}
|
||||
>
|
||||
<SelectTrigger size="sm" className="w-full" aria-label="Compact sidebar">
|
||||
<SelectValue>{compactSidebarModes[compactSidebarMode]}</SelectValue>
|
||||
</SelectTrigger>
|
||||
<SelectPopup align="end" alignItemWithTrigger={false}>
|
||||
{Object.entries(compactSidebarModes).map(([value, label]) => (
|
||||
<SelectItem key={value} hideIndicator value={value}>
|
||||
{label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectPopup>
|
||||
</Select>
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -163,7 +163,9 @@ export const SETTINGS_SEARCH_ITEMS = [
|
||||
id: "compact-sidebar",
|
||||
title: "Compact sidebar",
|
||||
to: "/settings/appearance",
|
||||
searchTerms: ["collapsed icons rail hover navigation preview"],
|
||||
searchTerms: [
|
||||
"collapsed icons rail hover navigation preview expanded dense density one line rows chats threads compact thread list",
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "environment-identification",
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
import { act, memo } from "react";
|
||||
import { create, type ReactTestRenderer } from "react-test-renderer";
|
||||
import { afterEach, beforeEach, expect, it, vi } from "vite-plus/test";
|
||||
|
||||
import { SidebarCompletedTime } from "./SidebarCompletedTime";
|
||||
|
||||
let renderer: ReactTestRenderer | undefined;
|
||||
|
||||
beforeEach(() => {
|
||||
vi.useFakeTimers();
|
||||
vi.setSystemTime(new Date("2026-09-07T01:01:00Z"));
|
||||
vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true);
|
||||
vi.stubGlobal("window", {
|
||||
setTimeout,
|
||||
clearTimeout,
|
||||
setInterval,
|
||||
clearInterval,
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await act(() => renderer?.unmount());
|
||||
renderer = undefined;
|
||||
vi.unstubAllGlobals();
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
it("advances visible and accessible completion times without rerendering its memoized row", async () => {
|
||||
const rowRender = vi.fn();
|
||||
const Row = memo(function Row() {
|
||||
rowRender();
|
||||
return <SidebarCompletedTime completedAt="2026-09-07T01:00:00Z" />;
|
||||
});
|
||||
await act(() => {
|
||||
renderer = create(<Row />);
|
||||
});
|
||||
expect(renderer!.root.findByType("time").props.dateTime).toBe("2026-09-07T01:00:00Z");
|
||||
expect(renderer!.root.findByProps({ className: "sr-only" }).children).toEqual(["Completed "]);
|
||||
expect(
|
||||
renderer!.root.findAll((node) => node.props.role === "status" || node.props["aria-live"]),
|
||||
).toHaveLength(0);
|
||||
expect(renderer!.root.findByProps({ className: "text-secondary-label" }).children).toEqual([
|
||||
"1m",
|
||||
]);
|
||||
|
||||
await act(() => vi.advanceTimersByTime(60_000));
|
||||
|
||||
expect(renderer!.root.findByProps({ className: "sr-only" }).children).toEqual(["Completed "]);
|
||||
expect(renderer!.root.findByProps({ className: "text-secondary-label" }).children).toEqual([
|
||||
"2m",
|
||||
]);
|
||||
expect(rowRender).toHaveBeenCalledTimes(1);
|
||||
await act(() => renderer!.unmount());
|
||||
renderer = undefined;
|
||||
expect(vi.getTimerCount()).toBe(0);
|
||||
});
|
||||
@@ -0,0 +1,16 @@
|
||||
import { useNowMinute } from "../../hooks/useNowMinute";
|
||||
import { formatRelativeTimeLabel } from "../../timestampFormat";
|
||||
|
||||
export function SidebarCompletedTime({ completedAt }: { completedAt: string }) {
|
||||
// Subscribe inside the label so time advances even when the row is memoized.
|
||||
const nowMinute = useNowMinute();
|
||||
const relativeTime = formatRelativeTimeLabel(completedAt, Date.parse(`${nowMinute}:00Z`));
|
||||
const label = relativeTime === "just now" ? "now" : relativeTime.replace(/ ago$/, "");
|
||||
|
||||
return (
|
||||
<time dateTime={completedAt} className="inline-flex items-center">
|
||||
<span className="sr-only">Completed </span>
|
||||
<span className="text-secondary-label">{label}</span>
|
||||
</time>
|
||||
);
|
||||
}
|
||||
@@ -228,3 +228,15 @@ describe("formatElapsedDurationLabel", () => {
|
||||
expect(formatElapsedDurationLabel("2026-04-03T12:00:00.000Z")).toBe("4d");
|
||||
});
|
||||
});
|
||||
|
||||
describe("explicit relative-time clock", () => {
|
||||
it("uses the supplied minute instead of the wall clock", () => {
|
||||
const completedAt = "2026-09-07T01:00:00Z";
|
||||
expect(formatRelativeTimeLabel(completedAt, Date.parse("2026-09-07T01:01:00Z"))).toBe("1m ago");
|
||||
expect(formatRelativeTimeLabel(completedAt, Date.parse("2026-09-07T01:02:00Z"))).toBe("2m ago");
|
||||
expect(formatRelativeTime(completedAt, Date.parse("2026-09-07T01:02:00Z"))).toEqual({
|
||||
value: "2m",
|
||||
suffix: "ago",
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -196,10 +196,10 @@ export type RelativeTimeState =
|
||||
| { status: "invalid" }
|
||||
| { status: "relative"; value: string; suffix: string | null };
|
||||
|
||||
export function formatRelativeTime(isoDate: string): RelativeTimeParts | null {
|
||||
export function formatRelativeTime(isoDate: string, nowMs = Date.now()): RelativeTimeParts | null {
|
||||
const date = parseTimestampDate(isoDate);
|
||||
if (!date) return null;
|
||||
const diffMs = Date.now() - date.getTime();
|
||||
const diffMs = nowMs - date.getTime();
|
||||
if (diffMs < 0) return { value: "just now", suffix: null };
|
||||
const seconds = Math.floor(diffMs / 1000);
|
||||
if (seconds < 60) return { value: "just now", suffix: null };
|
||||
@@ -211,8 +211,8 @@ export function formatRelativeTime(isoDate: string): RelativeTimeParts | null {
|
||||
return { value: `${days}d`, suffix: "ago" };
|
||||
}
|
||||
|
||||
export function formatRelativeTimeLabel(isoDate: string) {
|
||||
const relative = formatRelativeTime(isoDate);
|
||||
export function formatRelativeTimeLabel(isoDate: string, nowMs = Date.now()) {
|
||||
const relative = formatRelativeTime(isoDate, nowMs);
|
||||
if (!relative) return "";
|
||||
return relative.suffix ? `${relative.value} ${relative.suffix}` : relative.value;
|
||||
}
|
||||
|
||||
@@ -482,7 +482,18 @@ describe("ClientSettings environment identification", () => {
|
||||
|
||||
describe("ClientSettings sidebar", () => {
|
||||
it("defaults to the current sidebar", () => {
|
||||
expect(decodeClientSettings({}).legacySidebarEnabled).toBe(false);
|
||||
const settings = decodeClientSettings({});
|
||||
expect(settings.legacySidebarEnabled).toBe(false);
|
||||
expect(settings.sidebarCompactThreadRows).toBe(false);
|
||||
});
|
||||
|
||||
it("preserves an explicit compact thread row preference", () => {
|
||||
expect(decodeClientSettings({ sidebarCompactThreadRows: true }).sidebarCompactThreadRows).toBe(
|
||||
true,
|
||||
);
|
||||
expect(
|
||||
decodeClientSettingsPatch({ sidebarCompactThreadRows: true }).sidebarCompactThreadRows,
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("drops the retired sidebar v2 beta keys, resetting everyone to the default", () => {
|
||||
|
||||
@@ -451,6 +451,7 @@ export const ClientSettingsSchema = Schema.Struct({
|
||||
sidebarThreadSortOrder: SidebarThreadSortOrder.pipe(
|
||||
Schema.withDecodingDefault(Effect.succeed(DEFAULT_SIDEBAR_THREAD_SORT_ORDER)),
|
||||
),
|
||||
sidebarCompactThreadRows: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
|
||||
sidebarThreadPreviewCount: SidebarThreadPreviewCount.pipe(
|
||||
Schema.withDecodingDefault(Effect.succeed(DEFAULT_SIDEBAR_THREAD_PREVIEW_COUNT)),
|
||||
),
|
||||
@@ -1500,6 +1501,7 @@ export const ClientSettingsPatch = Schema.Struct({
|
||||
),
|
||||
sidebarProjectSortOrder: Schema.optionalKey(SidebarProjectSortOrder),
|
||||
sidebarThreadSortOrder: Schema.optionalKey(SidebarThreadSortOrder),
|
||||
sidebarCompactThreadRows: Schema.optionalKey(Schema.Boolean),
|
||||
sidebarThreadPreviewCount: Schema.optionalKey(SidebarThreadPreviewCount),
|
||||
timestampFormat: Schema.optionalKey(TimestampFormat),
|
||||
snapShotEnabled: Schema.optionalKey(Schema.Boolean),
|
||||
|
||||
Reference in new issue
Block a user