Skip to content

Commit e012572

Browse files
donjor-agent[bot]donjor
authored andcommitted
feat(web): group title becomes a tab on its parent thread (#1878)
## Problem A group with a parent thread showed its title as a section header above the parent, detached from it. Collapse lived in two places: the header chevron, and an `8 threads` fold strip under the parent. ## Change - **Title tab:** joined to the parent card - **One control:** the tab toggles the children - **Collapsed:** urgent-first status dots, max 6 plus `+N` - **Tab tooltip:** every child's status; opens on focus - **Count:** children only - **Fold strip:** deleted, with drag hook and test - **Parentless groups:** header unchanged - **Cross-project:** cards keep their project line **Fork isolation:** the header lives in `SidebarThreadGroup.tsx`; upstream files carry `fork-hook` lines only. ## Scope and approval The human picked concept A (Tab) from four captured concepts, relayed by the orchestrator thread. Follows #1829 and #1840. ## Verification Real Chrome, seeded dev data: a cross-project parent group (8 children, 6 projects) and a parentless group (3). - Tab click flips `aria-expanded`; 6 dots plus `+2` - Keyboard focus on the tab opens the status list - Enter on the focused tab toggles; focus stays - Double-click opens rename; hover menu opens - Parentless header toggles as before - Light theme and active parent checked - No new console errors | State | Before | After | | --- | --- | --- | | Expanded | ![before](https://github.com/user-attachments/assets/4a6c2a8d-befe-40b0-943d-6d9cdf62b6a5) | ![after](https://github.com/user-attachments/assets/e801aeb1-5cb4-4be9-ad1a-361d5e2ba9b3) | | Collapsed | ![before](https://github.com/user-attachments/assets/8f9f9ccf-63d6-4589-a710-508a102df85f) | ![after](https://github.com/user-attachments/assets/f8338eca-d3a6-4d6b-a803-cc8599048714) | **Active parent:** ![active](https://github.com/user-attachments/assets/08ed94ed-5806-4113-9f09-d66625d8d2b6) **Checks:** - `vp run typecheck` (apps/web) → exit 0 - `vp run check:changed` → exit 1 on the last commit, from the unrelated `markdownPipeline.browser.test.ts`; it passes alone (exit 0 on earlier commits) - `vp run fork:ci` → exit 0 Claude Opus 5.5, Claude Code in T3 Code. ## Fork trailers Squashes: - 11840c4 feat(web): group title becomes a tab on its parent thread (#1878) (#1878) - 960f0b5 fixup! feat(web): group title becomes a tab on its parent thread (#1878) (#1878) Fork-Domain: thread-ordering Fork-Tier: qol Co-authored-by: donjor <[email protected]>
1 parent 6a2844f commit e012572

7 files changed

Lines changed: 112 additions & 120 deletions

File tree

‎apps/web/src/components/Sidebar.drag.fork.test.ts‎

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
import { describe, expect, it } from "vite-plus/test";
22

3-
import { createSidebarCollisionDetection, createSidebarSortingStrategy } from "./Sidebar.drag.ts";
4-
import {
5-
sidebarListItemId,
6-
sidebarMarkerId,
7-
type SidebarListItem,
8-
type SidebarSection,
9-
} from "./Sidebar.logic.ts";
3+
import { createSidebarCollisionDetection } from "./Sidebar.drag.ts";
4+
import { sidebarMarkerId, type SidebarListItem, type SidebarSection } from "./Sidebar.logic.ts";
105
import { sidebarThreadGroupHeaderMarker } from "./SidebarThreadGroup.markers.ts";
116

127
const thread = (key: string, section: SidebarSection): SidebarListItem => ({
@@ -115,32 +110,3 @@ describe("createSidebarCollisionDetection group headers", () => {
115110
expect(detector(withoutHeader)[0]?.id).toBe("member");
116111
});
117112
});
118-
119-
describe("createSidebarSortingStrategy folded group parent", () => {
120-
it("opens a gap the height of a taller lifted card", () => {
121-
// A collapsed group's parent carries its fold strip, so it outgrows a card.
122-
const items: SidebarListItem[] = [
123-
{ kind: "marker", marker: "pinned-header" },
124-
{ kind: "marker", marker: "pinned-divider" },
125-
thread("above", "active"),
126-
thread("parent", "active"),
127-
{ kind: "marker", marker: "settled-header" },
128-
{ kind: "marker", marker: "settled-placeholder" },
129-
];
130-
const rects = [
131-
rect(100, 0),
132-
rect(101, 0),
133-
rect(102, 82),
134-
rect(185, 110),
135-
rect(296, 32),
136-
rect(329, 0),
137-
];
138-
const strategy = createSidebarSortingStrategy({
139-
items,
140-
settledOrder: [],
141-
settledExpanded: false,
142-
});
143-
const args = { activeIndex: 3, overIndex: 2, activeNodeRect: rects[3]!, rects };
144-
expect(strategy({ ...args, index: 2 })?.y).toBe(111);
145-
});
146-
});

‎apps/web/src/components/Sidebar.drag.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,9 @@ export function createSidebarSortingStrategy(input: {
209209
? labelHeight
210210
: item.kind === "marker" && item.marker.endsWith("placeholder")
211211
? slimHeight
212-
: moved && target.section !== active.section
212+
: moved
213213
? fallback
214-
: (rect?.height ?? fallback); // fork-hook: thread-ordering/group-fold-drag-height
214+
: (rect?.height ?? fallback);
215215
});
216216
const firstShelf = items.findIndex(isShelfHeader);
217217
const shelfRect = rects[firstShelf];

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

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,7 @@ import { isModelPickerOpen } from "../modelPickerVisibility";
112112
import { selectThreadTerminalUiState, useTerminalUiStateStore } from "../terminalUiStateStore";
113113
import { isMacPlatform } from "~/lib/utils";
114114
import * as threadGroupsFork from "../state/threadGroups"; // fork-hook: thread-ordering/group-title-command-import
115-
import {
116-
SidebarThreadGroupDropLayerFork,
117-
SidebarThreadGroupFoldFork,
118-
SidebarThreadGroupHeader,
119-
} from "./SidebarThreadGroup"; // fork-hook: thread-ordering/group-header-import
115+
import { SidebarThreadGroupDropLayerFork, SidebarThreadGroupHeader } from "./SidebarThreadGroup"; // fork-hook: thread-ordering/group-header-import
120116
import { useSidebarThreadGroupDragFork } from "./SidebarThreadGroup.drag"; // fork-hook: thread-ordering/group-drag-import
121117
import { parseSidebarThreadGroupMarker } from "./SidebarThreadGroup.markers"; // fork-hook: thread-ordering/group-span-marker-import
122118
import { sidebarThreadGroupSpansFork } from "./SidebarThreadGroup.span"; // fork-hook: thread-ordering/group-span-import
@@ -3266,7 +3262,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
32663262
const renderThreadRow = (
32673263
thread: EnvironmentThreadShell,
32683264
section: SidebarSection,
3269-
groupState?: { grouped?: boolean; fold?: ReactNode }, // fork-hook: thread-ordering/group-row-state
3265+
groupState?: { grouped?: boolean; parent?: boolean }, // fork-hook: thread-ordering/group-row-state
32703266
) => {
32713267
const threadKey = scopedThreadKey(
32723268
scopeThreadRef(thread.environmentId, thread.id),
@@ -3307,7 +3303,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
33073303
}
33083304
isPinned={thread.pinnedAt != null}
33093305
grouped={groupState?.grouped}
3310-
groupFoldFork={groupState?.fold} // fork-hook: thread-ordering/group-fold
3306+
groupParent={groupState?.parent} // fork-hook: thread-ordering/group-parent
33113307
dropVerb={
33123308
dragState?.activeKey === threadKey
33133309
? resolveSidebarDropVerb(dragState.activeSection, dragTargetSection)
@@ -3417,15 +3413,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
34173413
// A parent leads flush; only its children indent.
34183414
grouped:
34193415
groupEntry !== undefined && !isDissolving && !groupEntry.isParent,
3420-
fold:
3421-
groupEntry?.isParent && groupEntry.group.collapsed ? (
3422-
<SidebarThreadGroupFoldFork
3423-
threads={groupEntry.threads.slice(1)}
3424-
onExpand={() =>
3425-
setThreadGroupCollapsed(groupEntry.group.id, false)
3426-
}
3427-
/>
3428-
) : undefined,
3416+
parent: groupEntry?.isParent === true && !isDissolving,
34293417
}, // fork-hook: thread-ordering/group-member-state
34303418
),
34313419
);
@@ -3441,10 +3429,14 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
34413429
<SortableSidebarMarker
34423430
key={item.marker}
34433431
marker={item.marker}
3444-
className="mx-0.5"
3432+
// A parent's tab lines up with the card edge below it.
3433+
className={span.parentKey === null ? "mx-0.5" : ""}
34453434
>
34463435
<SidebarThreadGroupHeader
34473436
group={span.group}
3437+
childThreads={
3438+
span.parentKey === null ? null : span.threads.slice(1)
3439+
}
34483440
canEdit={
34493441
threadGroupsFork.canGroupThreadsFork(span.group.threadIds) &&
34503442
canOperateThreads(span.threads)

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

Lines changed: 94 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useDndContext, useDndMonitor } from "@dnd-kit/core";
22
import { scopeThreadRef, scopedThreadKey } from "@t3tools/client-runtime/environment";
33
import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/models";
44
import {
5-
ChevronRightIcon,
5+
ChevronDownIcon,
66
MoreHorizontalIcon,
77
RefreshCwIcon,
88
SquarePenIcon,
@@ -36,15 +36,17 @@ import {
3636
} from "./SidebarThreadGroup.projection";
3737
import { sidebarProjectedLayoutFork } from "./SidebarThreadGroup.span";
3838

39-
// Mirrors upstream's shelf section header (Snoozed / Settled): label with the
40-
// count, a hairline, and a chevron, reading at full strength during a drag. It
41-
// renders inside the group's sortable header marker, so it moves with the rows
42-
// during a drag; the drop layer draws the outline when a row would join it.
39+
// A parentless group mirrors upstream's shelf section header (label, count, hairline,
40+
// chevron). A group with a parent wears its title as a tab on the parent card, whose surface
41+
// hook pulls up 1px to close the gap under the tab. Either renders inside the group's sortable
42+
// header marker so it moves with the rows during a drag.
4343
export function SidebarThreadGroupHeader(props: {
4444
readonly group: SidebarThreadGroup;
4545
/** False where this client cannot edit the group: actions hide, collapse still works. */
4646
readonly canEdit: boolean;
4747
readonly memberCount: number;
48+
/** The parent's children, in list order; null for a parentless group. */
49+
readonly childThreads: readonly EnvironmentThreadShell[] | null;
4850
readonly isGenerating: boolean;
4951
readonly isDissolving?: boolean;
5052
readonly onCollapsedChange: (collapsed: boolean) => void;
@@ -77,18 +79,26 @@ export function SidebarThreadGroupHeader(props: {
7779
setIsEditing(false);
7880
};
7981
const expanded = !props.group.collapsed;
82+
const children = props.childThreads;
83+
const statusDots = useChildStatusDots(expanded ? null : children);
84+
const toggle = {
85+
"aria-busy": props.isGenerating || undefined,
86+
onClick: () => props.onCollapsedChange(expanded),
87+
onDoubleClick: () => props.canEdit && setIsEditing(true),
88+
};
8089

8190
return (
8291
<div
8392
data-testid={`sidebar-thread-group-${props.group.id}`}
8493
className={cn(
85-
"group/thread-group relative h-8 transition-opacity duration-150 ease-out",
94+
"group/thread-group relative transition-opacity duration-150 ease-out",
95+
children ? "flex h-7 items-end gap-1" : "h-8",
8696
// Keeps its height: the sortable preview measured it at pickup.
8797
props.isDissolving && "pointer-events-none opacity-30",
8898
)}
8999
>
90100
{isEditing ? (
91-
<div className="flex h-full items-center px-1">
101+
<div className="flex h-full w-full items-center px-1">
92102
<SidebarRenameInput
93103
ariaLabel="Thread group title"
94104
value={title}
@@ -98,13 +108,46 @@ export function SidebarThreadGroupHeader(props: {
98108
className="h-6 text-xs"
99109
/>
100110
</div>
111+
) : children ? (
112+
// Disabled rather than unmounted while expanded, so a keyboard toggle keeps focus.
113+
<Tooltip disabled={expanded}>
114+
<TooltipTrigger
115+
render={
116+
<button
117+
type="button"
118+
{...toggle}
119+
aria-expanded={expanded}
120+
aria-label={`${props.group.title}, ${children.length} child ${children.length === 1 ? "thread" : "threads"}`}
121+
className={cn(
122+
"flex h-full min-w-0 max-w-[calc(100%-1.75rem)] cursor-pointer items-center gap-1.5 rounded-t-lg bg-sidebar-row-hover/60 px-2.5 text-left text-xs font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/70",
123+
dragging ? "text-sidebar-foreground/80" : "text-sidebar-muted-foreground",
124+
)}
125+
/>
126+
}
127+
>
128+
<span className="truncate">{props.group.title}</span>
129+
<span className="shrink-0 tabular-nums opacity-70">{children.length}</span>
130+
{statusDots.length > 0 ? <SidebarThreadGroupStatusDots dots={statusDots} /> : null}
131+
<ChevronDownIcon
132+
aria-hidden
133+
className={cn("size-3 shrink-0 transition-transform", !expanded && "rotate-180")}
134+
/>
135+
</TooltipTrigger>
136+
<TooltipPopup side="right">
137+
{statusDots.map((dot) => (
138+
<div key={dot.key} className="flex items-center gap-1.5">
139+
<span className={cn("size-2 shrink-0 rounded-full", dot.className)} />
140+
<span className="truncate">{dot.title}</span>
141+
<span className="text-muted-foreground">{dot.label}</span>
142+
</div>
143+
))}
144+
</TooltipPopup>
145+
</Tooltip>
101146
) : (
102147
<CollapsibleSectionHeader
103148
expanded={expanded}
104149
tone={dragging ? "emphasized" : "muted"}
105-
aria-busy={props.isGenerating || undefined}
106-
onClick={() => props.onCollapsedChange(expanded)}
107-
onDoubleClick={() => props.canEdit && setIsEditing(true)}
150+
{...toggle}
108151
// Room for the hover menu, so it never covers the label.
109152
accessory={<span aria-hidden className="w-5 shrink-0" />}
110153
>
@@ -115,7 +158,12 @@ export function SidebarThreadGroupHeader(props: {
115158
</CollapsibleSectionHeader>
116159
)}
117160
{isEditing || !props.canEdit ? null : (
118-
<div className="absolute inset-y-0 right-6 flex items-center opacity-0 transition-opacity group-hover/thread-group:opacity-100 group-focus-within/thread-group:opacity-100 has-[[data-popup-open]]:opacity-100">
161+
<div
162+
className={cn(
163+
"flex items-center opacity-0 transition-opacity group-hover/thread-group:opacity-100 group-focus-within/thread-group:opacity-100 has-[[data-popup-open]]:opacity-100",
164+
children ? "h-full" : "absolute inset-y-0 right-6",
165+
)}
166+
>
119167
<Menu>
120168
<MenuTrigger
121169
render={
@@ -145,66 +193,51 @@ export function SidebarThreadGroupHeader(props: {
145193
);
146194
}
147195

148-
const FOLD_DOT: Record<SidebarThreadStatus | "done", { label: string; className: string }> = {
196+
// Key order is urgency: a collapsed tab shows the first MAX_STATUS_DOTS, so a
197+
// child that needs attention never hides behind the overflow count.
198+
const STATUS_DOT: Record<SidebarThreadStatus | "done", { label: string; className: string }> = {
149199
approval: { label: "Approval", className: "bg-warning" },
150200
input: { label: "Input", className: "bg-indigo-500" },
151-
working: { label: "Working", className: "bg-info" },
152-
waiting: { label: "Waiting", className: "bg-muted-foreground/60" },
201+
request: { label: "Request", className: "bg-guest" },
153202
failed: { label: "Failed", className: "bg-error" },
154203
limited: { label: "Limited", className: "bg-warning" },
155204
done: { label: "Done", className: "bg-success" },
205+
working: { label: "Working", className: "bg-info" },
206+
waiting: { label: "Waiting", className: "bg-muted-foreground/60" },
156207
ready: { label: "Read", className: "border border-muted-foreground/50" },
157208
};
209+
const URGENCY = Object.keys(STATUS_DOT);
210+
const MAX_STATUS_DOTS = 6;
158211

159-
// A collapsed group keeps its parent row; the children fold into this strip
160-
// under it, one dot per child in the row's own status colours, so a finished
161-
// or blocked child still shows without opening the group.
162-
export function SidebarThreadGroupFoldFork(props: {
163-
readonly threads: readonly EnvironmentThreadShell[];
164-
readonly onExpand: () => void;
165-
}) {
212+
// A collapsed parent group keeps its parent row; its tab carries status dots
213+
// for the hidden children in the rows' own colours, so a finished or blocked child
214+
// still shows without opening the group. The tab's tooltip lists every child.
215+
function useChildStatusDots(threads: readonly EnvironmentThreadShell[] | null) {
166216
const localVisits = useUiStateStore((state) => state.threadLastVisitedAtById);
167-
const dots = props.threads.map((thread) => {
168-
const key = scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id));
169-
const lastVisitedAt = resolveThreadLastVisitedAt(thread.lastVisitedAt, localVisits[key]);
170-
const status = resolveSidebarThreadStatus(thread);
171-
const kind =
172-
status === "ready" && hasUnseenCompletion({ ...thread, lastVisitedAt }) ? "done" : status;
173-
return { key, title: thread.title, ...FOLD_DOT[kind] };
174-
});
217+
if (threads === null) return [];
218+
return threads
219+
.map((thread) => {
220+
const key = scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id));
221+
const lastVisitedAt = resolveThreadLastVisitedAt(thread.lastVisitedAt, localVisits[key]);
222+
const status = resolveSidebarThreadStatus(thread);
223+
const kind =
224+
status === "ready" && hasUnseenCompletion({ ...thread, lastVisitedAt }) ? "done" : status;
225+
return { key, kind, title: thread.title, ...STATUS_DOT[kind] };
226+
})
227+
.toSorted((a, b) => URGENCY.indexOf(a.kind) - URGENCY.indexOf(b.kind));
228+
}
229+
230+
function SidebarThreadGroupStatusDots(props: {
231+
readonly dots: ReturnType<typeof useChildStatusDots>;
232+
}) {
233+
const overflow = props.dots.length - MAX_STATUS_DOTS;
175234
return (
176-
<Tooltip>
177-
<TooltipTrigger
178-
render={
179-
<button
180-
type="button"
181-
data-testid="sidebar-thread-group-fold"
182-
aria-label={`Show ${dots.length} child threads`}
183-
onClick={props.onExpand}
184-
className="mt-0.5 ml-2 flex h-6 w-[calc(100%-0.5rem)] cursor-pointer items-center gap-1.5 rounded-r-md border-l border-sidebar-border/70 pl-2.5 text-secondary-label text-xs hover:bg-sidebar-row-hover"
185-
/>
186-
}
187-
>
188-
<ChevronRightIcon aria-hidden className="size-3 shrink-0" />
189-
<span className="shrink-0 tabular-nums">
190-
{dots.length} {dots.length === 1 ? "thread" : "threads"}
191-
</span>
192-
<span className="flex min-w-0 items-center gap-1 overflow-hidden">
193-
{dots.map((dot) => (
194-
<span key={dot.key} className={cn("size-2 shrink-0 rounded-full", dot.className)} />
195-
))}
196-
</span>
197-
</TooltipTrigger>
198-
<TooltipPopup side="right">
199-
{dots.map((dot) => (
200-
<div key={dot.key} className="flex items-center gap-1.5">
201-
<span className={cn("size-2 shrink-0 rounded-full", dot.className)} />
202-
<span className="truncate">{dot.title}</span>
203-
<span className="text-muted-foreground">{dot.label}</span>
204-
</div>
205-
))}
206-
</TooltipPopup>
207-
</Tooltip>
235+
<span data-testid="sidebar-thread-group-dots" className="flex shrink-0 items-center gap-0.5">
236+
{props.dots.slice(0, MAX_STATUS_DOTS).map((dot) => (
237+
<span key={dot.key} className={cn("size-2 shrink-0 rounded-full", dot.className)} />
238+
))}
239+
{overflow > 0 ? <span className="ms-0.5 tabular-nums">+{overflow}</span> : null}
240+
</span>
208241
);
209242
}
210243

‎apps/web/src/components/sidebar/SidebarThreadRow.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ const dropVerbBadge: Record<SidebarDropVerb, ReactNode> = {
512512

513513
type SidebarThreadRowProps = {
514514
grouped?: boolean | undefined; // fork-hook: thread-ordering/group-member-prop
515-
groupFoldFork?: ReactNode; // fork-hook: thread-ordering/group-fold-prop
515+
groupParent?: boolean | undefined; // fork-hook: thread-ordering/group-parent-prop
516516
thread: SidebarThreadSummary;
517517
variant: "card" | "slim";
518518
variantAction: SidebarSweepAction;
@@ -1268,6 +1268,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP
12681268
className={cn(
12691269
"list-none py-0.5 [content-visibility:auto] [contain-intrinsic-size:auto_78px]",
12701270
props.grouped && "ml-2 border-l border-sidebar-border/70 pl-1.5", // fork-hook: thread-ordering/group-member-rail
1271+
props.groupParent && "-mt-px rounded-lg rounded-tl-none bg-sidebar-row-hover/60", // fork-hook: thread-ordering/group-parent-surface
12711272
metaLineEmpty && "[contain-intrinsic-size:auto_58px]",
12721273
sortable?.isDragging && "relative z-20",
12731274
)}
@@ -1528,7 +1529,6 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP
15281529
</TooltipTrigger>
15291530
{detailsTooltip}
15301531
</Tooltip>
1531-
{props.groupFoldFork /* fork-hook: thread-ordering/group-fold */}
15321532
</li>
15331533
);
15341534
});

0 commit comments

Comments
 (0)