Skip to content

Commit d88d9e8

Browse files
committed
feat(web): start a thread from a project section header
Grouping the inbox by project surfaces every project as a header, but starting work in one still meant going back up to the project selector and changing scope. Adds a New thread button beside the collapse arrow on project section headers. Environment and provider sections span several projects, so they have no unambiguous target and get no button rather than a guess. The button is a sibling of the toggle rather than a child (a button inside a button is invalid), and it reads its target off the section's first thread instead of parsing the group key, so ids stay branded and the key format stays an implementation detail. Written by Claude Opus 5 in Claude Code.
1 parent fbd5825 commit d88d9e8

3 files changed

Lines changed: 59 additions & 9 deletions

File tree

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

Lines changed: 53 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4196,6 +4196,43 @@ export default function Sidebar() {
41964196
/>,
41974197
);
41984198
}
4199+
// A project section owns exactly one project, so its
4200+
// header can start a thread there. Read off the first
4201+
// thread rather than parsing the group key, so the ids stay
4202+
// branded and the key format stays an implementation detail.
4203+
const groupNewThreadTarget = (
4204+
group: (typeof activeThreadGroups)[number],
4205+
): ReactNode => {
4206+
if (group.axis !== "project") {
4207+
return null;
4208+
}
4209+
const thread = group.threads[0] ?? group.children[0]?.threads[0] ?? null;
4210+
if (thread === null) {
4211+
return null;
4212+
}
4213+
const projectRef = scopeProjectRef(thread.environmentId, thread.projectId);
4214+
return (
4215+
<Tooltip>
4216+
<TooltipTrigger
4217+
render={
4218+
<Button
4219+
size="icon-xs"
4220+
variant="ghost-muted"
4221+
aria-label={`New thread in ${group.label}`}
4222+
className="size-5 shrink-0 text-icon-muted opacity-0 transition-opacity focus-visible:opacity-100 group-hover/sidebar-group-header:opacity-100"
4223+
onClick={(event) => {
4224+
event.stopPropagation();
4225+
void handleNewThreadRef.current(projectRef);
4226+
}}
4227+
/>
4228+
}
4229+
>
4230+
<SquarePenIcon className="size-3" />
4231+
</TooltipTrigger>
4232+
<TooltipPopup side="right">New thread in {group.label}</TooltipPopup>
4233+
</Tooltip>
4234+
);
4235+
};
41994236
// Ungrouped is the default and stays a plain run of rows.
42004237
// Grouped mode walks the pre-flattened rows so collapse
42014238
// state is resolved once, in pure code, instead of being
@@ -4225,7 +4262,14 @@ export default function Sidebar() {
42254262
<li
42264263
key={`group-header:${group.key}`}
42274264
data-thread-selection-safe
4228-
className="relative list-none"
4265+
className={cn(
4266+
"group/sidebar-group-header relative flex list-none items-center gap-1 pe-1",
4267+
// Top level carries the weight of a shelf header;
4268+
// the nested level reads as a caption inside it,
4269+
// so two grouping axes never look like one flat
4270+
// run of identical headers.
4271+
isTopLevel ? "mb-1.5 mt-4 first:mt-1" : "mb-1 mt-2",
4272+
)}
42294273
style={groupIndentStyle(row.depth)}
42304274
>
42314275
<GroupIndentGuides depth={row.depth} />
@@ -4234,14 +4278,7 @@ export default function Sidebar() {
42344278
onClick={() => toggleThreadGroupCollapsed(group.key)}
42354279
aria-expanded={!isCollapsed}
42364280
data-testid={`sidebar-thread-group-toggle:${group.key}`}
4237-
className={cn(
4238-
"flex w-full cursor-pointer items-center gap-2 px-2.5 text-left",
4239-
// Top level carries the weight of a shelf header;
4240-
// the nested level reads as a caption inside it,
4241-
// so two grouping axes never look like one flat
4242-
// run of identical headers.
4243-
isTopLevel ? "mb-1.5 mt-4 first:mt-1" : "mb-1 mt-2",
4244-
)}
4281+
className="flex min-w-0 flex-1 cursor-pointer items-center gap-2 ps-2.5 text-left"
42454282
>
42464283
<span
42474284
className={cn(
@@ -4286,6 +4323,13 @@ export default function Sidebar() {
42864323
)}
42874324
/>
42884325
</button>
4326+
{/* Project sections are the only ones with an
4327+
unambiguous target for a new thread; an
4328+
environment or provider section spans several
4329+
projects, so it gets no button rather than a
4330+
guess. Sibling of the toggle, not a child: a
4331+
button inside a button is invalid. */}
4332+
{groupNewThreadTarget(group)}
42894333
</li>,
42904334
);
42914335
}

‎docs/user/thread-sidebar.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ snoozed, and settled ones. The menu only lists providers that currently have thr
3333
The last menu sorts threads by **Last activity** or **Date created**. Sorting and grouping are
3434
independent: changing one never reshuffles the other.
3535

36+
Project sections carry a **New thread** button next to their collapse arrow, so you can start work
37+
in that project without changing the project selector first. Environment and provider sections span
38+
several projects, so they do not offer one.
39+
3640
A collapsed section shows what is waiting inside it as colored dots with counts, in order of
3741
urgency: amber for approvals, indigo for input requests, red for failures, green for finished
3842
threads you have not opened yet, and blue for threads still working. Open sections leave that to

‎pnpm-lock.yaml‎

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)