Skip to content

Commit 77bca8b

Browse files
saphidclaudemaria-rcks
authored
feat(web): add compact thread list mode (pingdotgg#9417)
Co-authored-by: Claude Opus 5 (1M context) <[email protected]> Co-authored-by: maria-rcks <[email protected]>
1 parent 6e5e986 commit 77bca8b

11 files changed

Lines changed: 373 additions & 102 deletions

File tree

‎apps/desktop/src/settings/DesktopClientSettings.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ const clientSettings: ClientSettings = {
5757
proactivePanelsEnabled: true,
5858
showSkillsInSlashMenu: false,
5959
providerModelPreferences: {},
60+
sidebarCompactThreadRows: false,
6061
sidebarProjectGroupingMode: "repository_path",
6162
sidebarProjectGroupingOverrides: {
6263
"environment-1:/tmp/project-a": "separate",

‎apps/web/src/components/Sidebar.tsx‎

Lines changed: 163 additions & 74 deletions
Large diffs are not rendered by default.

‎apps/web/src/components/settings/CompactSidebarPreview.tsx‎

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,62 @@
1-
import { useState } from "react";
1+
import { useEffect, useRef, useState } from "react";
22

33
import { cn } from "~/lib/utils";
44

5-
export function CompactSidebarPreview() {
5+
export function CompactSidebarPreview({
6+
railEnabled,
7+
compactRows,
8+
}: {
9+
railEnabled: boolean;
10+
compactRows: boolean;
11+
}) {
612
const [collapsed, setCollapsed] = useState(false);
13+
const sidebarRef = useRef<HTMLSpanElement>(null);
14+
15+
useEffect(() => {
16+
if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) return;
17+
const animation = sidebarRef.current?.animate(
18+
[
19+
{ width: "36px", offset: 0 },
20+
{ width: railEnabled ? "12px" : "0px", offset: 0.45 },
21+
{ width: railEnabled ? "12px" : "0px", offset: 0.6 },
22+
{ width: "36px", offset: 1 },
23+
],
24+
{ duration: 800, easing: "ease-in-out" },
25+
);
26+
return () => animation?.cancel();
27+
}, [railEnabled, compactRows]);
728

829
return (
930
<button
1031
type="button"
1132
aria-label="Toggle compact sidebar preview"
1233
aria-pressed={collapsed}
1334
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"
14-
onClick={() => setCollapsed((value) => !value)}
35+
onClick={() => {
36+
sidebarRef.current?.getAnimations().forEach((animation) => animation.cancel());
37+
setCollapsed((value) => !value);
38+
}}
1539
>
1640
<span
41+
ref={sidebarRef}
1742
aria-hidden
1843
className={cn(
19-
"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",
20-
collapsed ? "w-3" : "w-9",
44+
"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",
45+
collapsed ? (railEnabled ? "w-3" : "w-0") : "w-9",
2146
)}
2247
>
23-
{[0, 1, 2].map((row) => (
24-
<span key={row} className="flex h-1 shrink-0 items-center gap-1">
48+
{(compactRows ? [0, 1, 2, 3] : [0, 1, 2]).map((row) => (
49+
<span key={row} className="flex shrink-0 items-start gap-1 px-1">
2550
<span className="size-1 shrink-0 rounded-[1px] bg-muted-foreground/50" />
2651
<span
2752
className={cn(
28-
"h-0.5 w-4 shrink-0 rounded-full bg-muted-foreground/25 transition-opacity duration-250 ease-out motion-reduce:transition-none",
53+
"flex shrink-0 flex-col gap-0.5 transition-opacity duration-250 ease-out motion-reduce:transition-none",
2954
collapsed && "opacity-0",
3055
)}
31-
/>
56+
>
57+
<span className="h-0.5 w-4 rounded-full bg-muted-foreground/25" />
58+
{!compactRows && <span className="h-0.5 w-2 rounded-full bg-muted-foreground/15" />}
59+
</span>
3260
</span>
3361
))}
3462
</span>
@@ -42,6 +70,7 @@ export function CompactSidebarPreview() {
4270
className={cn(
4371
"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",
4472
collapsed &&
73+
railEnabled &&
4574
"group-hover/compact-preview:opacity-100 group-focus-visible/compact-preview:opacity-100",
4675
)}
4776
>

‎apps/web/src/components/settings/SettingsPanels.tsx‎

Lines changed: 66 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,8 @@ export function useSettingsRestore(onRestored?: () => void) {
502502
...(theme !== "system" ? ["Theme"] : []),
503503
...(!followSystem ? ["Follow system"] : []),
504504
...(themeHalves !== null ? ["Theme mix"] : []),
505-
...(settings.compactSidebarEnabled !== DEFAULT_UNIFIED_SETTINGS.compactSidebarEnabled
505+
...(settings.compactSidebarEnabled !== DEFAULT_UNIFIED_SETTINGS.compactSidebarEnabled ||
506+
settings.sidebarCompactThreadRows !== DEFAULT_UNIFIED_SETTINGS.sidebarCompactThreadRows
506507
? ["Compact sidebar"]
507508
: []),
508509
...(settings.appearanceContrast !== DEFAULT_UNIFIED_SETTINGS.appearanceContrast
@@ -644,6 +645,7 @@ export function useSettingsRestore(onRestored?: () => void) {
644645
settings.continueThreadsAfterServerUpdate,
645646
settings.sidebarAutoSettleAfterDays,
646647
settings.sidebarAutoSettleOnMerge,
648+
settings.sidebarCompactThreadRows,
647649
settings.sidebarProjectGroupingMode,
648650
settings.sidebarThreadPreviewCount,
649651
settings.showSkillsInSlashMenu,
@@ -739,6 +741,7 @@ export function useSettingsRestore(onRestored?: () => void) {
739741
panelAnimationDurationMs: DEFAULT_UNIFIED_SETTINGS.panelAnimationDurationMs,
740742
sidebarThreadPreviewCount: DEFAULT_UNIFIED_SETTINGS.sidebarThreadPreviewCount,
741743
sidebarProjectGroupingMode: DEFAULT_UNIFIED_SETTINGS.sidebarProjectGroupingMode,
744+
sidebarCompactThreadRows: DEFAULT_UNIFIED_SETTINGS.sidebarCompactThreadRows,
742745
sidebarAutoSettleAfterDays: DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleAfterDays,
743746
sidebarAutoSettleOnMerge: DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleOnMerge,
744747
enableLegacyTokenStreaming: DEFAULT_UNIFIED_SETTINGS.enableLegacyTokenStreaming,
@@ -1081,6 +1084,19 @@ export function AppearanceSettingsPanel() {
10811084
const [isImportThemeOpen, setIsImportThemeOpen] = useState(false);
10821085
const settings = useScopedSettings();
10831086
const updateSettings = useUpdateScopedSettings();
1087+
const compactSidebarMode = settings.compactSidebarEnabled
1088+
? settings.sidebarCompactThreadRows
1089+
? "both"
1090+
: "rail"
1091+
: settings.sidebarCompactThreadRows
1092+
? "threads"
1093+
: "off";
1094+
const compactSidebarModes = {
1095+
off: "Off",
1096+
rail: "Rail only",
1097+
threads: "Threads only",
1098+
both: "Both",
1099+
};
10841100
const environmentStageLabel = useEnvironmentStageLabel();
10851101
const showEnvironmentIdentification =
10861102
resolveEnvironmentIdentificationPillLabel(environmentStageLabel) !== null;
@@ -1370,19 +1386,56 @@ export function AppearanceSettingsPanel() {
13701386
<SettingsSection id="appearance-sidebar" title="Sidebar">
13711387
<SettingsRow
13721388
{...searchableSetting("compact-sidebar")}
1373-
description="Keep an icon rail when the sidebar is collapsed. Click the preview to try it."
1389+
description="Choose a collapsed icon rail, denser thread rows, or both. Click the preview to collapse or expand."
1390+
resetAction={
1391+
settings.compactSidebarEnabled !== DEFAULT_UNIFIED_SETTINGS.compactSidebarEnabled ||
1392+
settings.sidebarCompactThreadRows !==
1393+
DEFAULT_UNIFIED_SETTINGS.sidebarCompactThreadRows ? (
1394+
<SettingResetButton
1395+
label="compact sidebar"
1396+
onClick={() =>
1397+
updateSettings({
1398+
compactSidebarEnabled: DEFAULT_UNIFIED_SETTINGS.compactSidebarEnabled,
1399+
sidebarCompactThreadRows: DEFAULT_UNIFIED_SETTINGS.sidebarCompactThreadRows,
1400+
})
1401+
}
1402+
/>
1403+
) : null
1404+
}
13741405
control={
1375-
<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">
1376-
<CompactSidebarPreview />
1377-
<div className="flex justify-end">
1378-
<Switch
1379-
checked={settings.compactSidebarEnabled}
1380-
onCheckedChange={(checked) =>
1381-
updateSettings({ compactSidebarEnabled: Boolean(checked) })
1382-
}
1383-
aria-label="Compact sidebar"
1384-
/>
1385-
</div>
1406+
<div className="grid w-full grid-cols-[5rem_1fr] items-center gap-3 sm:w-auto sm:grid-cols-[7rem_10rem] sm:gap-4">
1407+
<CompactSidebarPreview
1408+
key={compactSidebarMode}
1409+
railEnabled={settings.compactSidebarEnabled}
1410+
compactRows={settings.sidebarCompactThreadRows}
1411+
/>
1412+
<Select
1413+
value={compactSidebarMode}
1414+
onValueChange={(value) => {
1415+
if (
1416+
value !== "off" &&
1417+
value !== "rail" &&
1418+
value !== "threads" &&
1419+
value !== "both"
1420+
)
1421+
return;
1422+
updateSettings({
1423+
compactSidebarEnabled: value === "rail" || value === "both",
1424+
sidebarCompactThreadRows: value === "threads" || value === "both",
1425+
});
1426+
}}
1427+
>
1428+
<SelectTrigger size="sm" className="w-full" aria-label="Compact sidebar">
1429+
<SelectValue>{compactSidebarModes[compactSidebarMode]}</SelectValue>
1430+
</SelectTrigger>
1431+
<SelectPopup align="end" alignItemWithTrigger={false}>
1432+
{Object.entries(compactSidebarModes).map(([value, label]) => (
1433+
<SelectItem key={value} hideIndicator value={value}>
1434+
{label}
1435+
</SelectItem>
1436+
))}
1437+
</SelectPopup>
1438+
</Select>
13861439
</div>
13871440
}
13881441
/>

‎apps/web/src/components/settings/settingsSearch.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,9 @@ export const SETTINGS_SEARCH_ITEMS = [
163163
id: "compact-sidebar",
164164
title: "Compact sidebar",
165165
to: "/settings/appearance",
166-
searchTerms: ["collapsed icons rail hover navigation preview"],
166+
searchTerms: [
167+
"collapsed icons rail hover navigation preview expanded dense density one line rows chats threads compact thread list",
168+
],
167169
},
168170
{
169171
id: "environment-identification",
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { act, memo } from "react";
2+
import { create, type ReactTestRenderer } from "react-test-renderer";
3+
import { afterEach, beforeEach, expect, it, vi } from "vite-plus/test";
4+
5+
import { SidebarCompletedTime } from "./SidebarCompletedTime";
6+
7+
let renderer: ReactTestRenderer | undefined;
8+
9+
beforeEach(() => {
10+
vi.useFakeTimers();
11+
vi.setSystemTime(new Date("2026-09-07T01:01:00Z"));
12+
vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true);
13+
vi.stubGlobal("window", {
14+
setTimeout,
15+
clearTimeout,
16+
setInterval,
17+
clearInterval,
18+
});
19+
});
20+
21+
afterEach(async () => {
22+
await act(() => renderer?.unmount());
23+
renderer = undefined;
24+
vi.unstubAllGlobals();
25+
vi.useRealTimers();
26+
});
27+
28+
it("advances visible and accessible completion times without rerendering its memoized row", async () => {
29+
const rowRender = vi.fn();
30+
const Row = memo(function Row() {
31+
rowRender();
32+
return <SidebarCompletedTime completedAt="2026-09-07T01:00:00Z" />;
33+
});
34+
await act(() => {
35+
renderer = create(<Row />);
36+
});
37+
expect(renderer!.root.findByType("time").props.dateTime).toBe("2026-09-07T01:00:00Z");
38+
expect(renderer!.root.findByProps({ className: "sr-only" }).children).toEqual(["Completed "]);
39+
expect(
40+
renderer!.root.findAll((node) => node.props.role === "status" || node.props["aria-live"]),
41+
).toHaveLength(0);
42+
expect(renderer!.root.findByProps({ className: "text-secondary-label" }).children).toEqual([
43+
"1m",
44+
]);
45+
46+
await act(() => vi.advanceTimersByTime(60_000));
47+
48+
expect(renderer!.root.findByProps({ className: "sr-only" }).children).toEqual(["Completed "]);
49+
expect(renderer!.root.findByProps({ className: "text-secondary-label" }).children).toEqual([
50+
"2m",
51+
]);
52+
expect(rowRender).toHaveBeenCalledTimes(1);
53+
await act(() => renderer!.unmount());
54+
renderer = undefined;
55+
expect(vi.getTimerCount()).toBe(0);
56+
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { useNowMinute } from "../../hooks/useNowMinute";
2+
import { formatRelativeTimeLabel } from "../../timestampFormat";
3+
4+
export function SidebarCompletedTime({ completedAt }: { completedAt: string }) {
5+
// Subscribe inside the label so time advances even when the row is memoized.
6+
const nowMinute = useNowMinute();
7+
const relativeTime = formatRelativeTimeLabel(completedAt, Date.parse(`${nowMinute}:00Z`));
8+
const label = relativeTime === "just now" ? "now" : relativeTime.replace(/ ago$/, "");
9+
10+
return (
11+
<time dateTime={completedAt} className="inline-flex items-center">
12+
<span className="sr-only">Completed </span>
13+
<span className="text-secondary-label">{label}</span>
14+
</time>
15+
);
16+
}

‎apps/web/src/timestampFormat.test.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,3 +228,15 @@ describe("formatElapsedDurationLabel", () => {
228228
expect(formatElapsedDurationLabel("2026-04-03T12:00:00.000Z")).toBe("4d");
229229
});
230230
});
231+
232+
describe("explicit relative-time clock", () => {
233+
it("uses the supplied minute instead of the wall clock", () => {
234+
const completedAt = "2026-09-07T01:00:00Z";
235+
expect(formatRelativeTimeLabel(completedAt, Date.parse("2026-09-07T01:01:00Z"))).toBe("1m ago");
236+
expect(formatRelativeTimeLabel(completedAt, Date.parse("2026-09-07T01:02:00Z"))).toBe("2m ago");
237+
expect(formatRelativeTime(completedAt, Date.parse("2026-09-07T01:02:00Z"))).toEqual({
238+
value: "2m",
239+
suffix: "ago",
240+
});
241+
});
242+
});

‎apps/web/src/timestampFormat.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,10 @@ export type RelativeTimeState =
196196
| { status: "invalid" }
197197
| { status: "relative"; value: string; suffix: string | null };
198198

199-
export function formatRelativeTime(isoDate: string): RelativeTimeParts | null {
199+
export function formatRelativeTime(isoDate: string, nowMs = Date.now()): RelativeTimeParts | null {
200200
const date = parseTimestampDate(isoDate);
201201
if (!date) return null;
202-
const diffMs = Date.now() - date.getTime();
202+
const diffMs = nowMs - date.getTime();
203203
if (diffMs < 0) return { value: "just now", suffix: null };
204204
const seconds = Math.floor(diffMs / 1000);
205205
if (seconds < 60) return { value: "just now", suffix: null };
@@ -211,8 +211,8 @@ export function formatRelativeTime(isoDate: string): RelativeTimeParts | null {
211211
return { value: `${days}d`, suffix: "ago" };
212212
}
213213

214-
export function formatRelativeTimeLabel(isoDate: string) {
215-
const relative = formatRelativeTime(isoDate);
214+
export function formatRelativeTimeLabel(isoDate: string, nowMs = Date.now()) {
215+
const relative = formatRelativeTime(isoDate, nowMs);
216216
if (!relative) return "";
217217
return relative.suffix ? `${relative.value} ${relative.suffix}` : relative.value;
218218
}

‎packages/contracts/src/settings.test.ts‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,18 @@ describe("ClientSettings environment identification", () => {
482482

483483
describe("ClientSettings sidebar", () => {
484484
it("defaults to the current sidebar", () => {
485-
expect(decodeClientSettings({}).legacySidebarEnabled).toBe(false);
485+
const settings = decodeClientSettings({});
486+
expect(settings.legacySidebarEnabled).toBe(false);
487+
expect(settings.sidebarCompactThreadRows).toBe(false);
488+
});
489+
490+
it("preserves an explicit compact thread row preference", () => {
491+
expect(decodeClientSettings({ sidebarCompactThreadRows: true }).sidebarCompactThreadRows).toBe(
492+
true,
493+
);
494+
expect(
495+
decodeClientSettingsPatch({ sidebarCompactThreadRows: true }).sidebarCompactThreadRows,
496+
).toBe(true);
486497
});
487498

488499
it("drops the retired sidebar v2 beta keys, resetting everyone to the default", () => {

0 commit comments

Comments
 (0)