Sidebar v2: per-card project title bars, static creation order

- Each card is a tiny window: a thin title bar carries the project
  favicon + mono uppercase name with the timestamp, separated from the
  thread content by a hairline — project identity reads as chrome
- Active card brightens its title bar on top of the near-white border
- Thread list is statically ordered by creation time, newest first;
  activity never reorders rows — only settling moves them
- Project identity mirrored on the open thread: favicon+name chip leads
  the chat header and the composer's run-context strip (drafts included)
- Settled rows keep dimmed favicons; chips/picker favicons restored
- Composer squared to match: 12px radius, higher-contrast border,
  neutral focus ring

Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
Theo BrowneandClaude Fable 5 committed 2026-07-15 13:47:56 -07:00
1 parent ab23a82b1d
commit 23d7a3d1c8
7 files changed
+185 -142

No files matched your search

+16
View File
@@ -24,6 +24,7 @@ import {
import { BranchToolbarBranchSelector } from "./BranchToolbarBranchSelector";
import { BranchToolbarEnvironmentSelector } from "./BranchToolbarEnvironmentSelector";
import { BranchToolbarEnvModeSelector } from "./BranchToolbarEnvModeSelector";
import { ProjectFavicon } from "./ProjectFavicon";
import { Button } from "./ui/button";
import {
Menu,
@@ -240,6 +241,21 @@ export const BranchToolbar = memo(function BranchToolbar({
return (
<div className="mx-auto flex w-full max-w-3xl items-center gap-2 px-2.5 pb-3 pt-1 sm:px-3">
{/* The submit target leads the run-context strip: this is the one
surface where "which project am I about to send this to" must be
answered before the first keystroke, especially on drafts.
Mirrors the sidebar cards' title bar — favicon + mono name. */}
<span className="inline-flex shrink-0 items-center gap-1.5 border border-black/12 py-0.5 pl-1.5 pr-2 dark:border-white/12">
<ProjectFavicon
environmentId={activeProject.environmentId}
cwd={activeProject.workspaceRoot}
className="size-3"
/>
<span className="max-w-32 truncate font-mono text-[10px] font-semibold uppercase tracking-[0.08em] text-muted-foreground">
{activeProject.title}
</span>
</span>
<Separator orientation="vertical" className="mx-0.5 h-3.5!" />
{isMobile ? (
<MobileRunContextSelector
envLocked={envLocked}
+1
View File
@@ -5040,6 +5040,7 @@ function ChatViewContent(props: ChatViewProps) {
{...(routeKind === "draft" && draftId ? { draftId } : {})}
activeThreadTitle={activeThread.title}
activeProjectName={activeProject?.title}
activeProjectCwd={activeProject?.workspaceRoot ?? null}
openInCwd={gitCwd}
activeProjectScripts={activeProject?.scripts}
preferredScriptId={
+15 -31
View File
@@ -619,44 +619,28 @@ describe("resolveSidebarV2Status", () => {
});
describe("sortThreadsForSidebarV2", () => {
const sortable = (input: {
id: string;
hasPendingApprovals?: boolean;
latestUserMessageAt: string;
updatedAt?: string;
}) => ({
const sortable = (input: { id: string; createdAt: string }) => ({
id: input.id,
hasPendingApprovals: input.hasPendingApprovals ?? false,
session: null,
createdAt: "2026-03-09T10:00:00.000Z",
updatedAt: input.updatedAt ?? input.latestUserMessageAt,
latestUserMessageAt: input.latestUserMessageAt,
createdAt: input.createdAt,
});
it("pins approval-blocked threads above the recency flow, longest wait first", () => {
it("orders by creation time, newest first, ignoring activity", () => {
const sorted = sortThreadsForSidebarV2([
sortable({ id: "fresh", latestUserMessageAt: "2026-03-09T12:00:00.000Z" }),
sortable({
id: "approval-new",
hasPendingApprovals: true,
latestUserMessageAt: "2026-03-09T08:00:00.000Z",
updatedAt: "2026-03-09T11:00:00.000Z",
}),
sortable({
id: "approval-old",
hasPendingApprovals: true,
latestUserMessageAt: "2026-03-09T11:30:00.000Z",
updatedAt: "2026-03-09T09:00:00.000Z",
}),
sortable({ id: "stale", latestUserMessageAt: "2026-03-09T08:00:00.000Z" }),
sortable({ id: "oldest", createdAt: "2026-03-09T08:00:00.000Z" }),
sortable({ id: "newest", createdAt: "2026-03-09T12:00:00.000Z" }),
sortable({ id: "middle", createdAt: "2026-03-09T10:00:00.000Z" }),
]);
expect(sorted.map((thread) => thread.id)).toEqual([
"approval-old",
"approval-new",
"fresh",
"stale",
expect(sorted.map((thread) => thread.id)).toEqual(["newest", "middle", "oldest"]);
});
it("breaks creation-time ties by id so the order is stable", () => {
const sorted = sortThreadsForSidebarV2([
sortable({ id: "b", createdAt: "2026-03-09T10:00:00.000Z" }),
sortable({ id: "a", createdAt: "2026-03-09T10:00:00.000Z" }),
]);
expect(sorted.map((thread) => thread.id)).toEqual(["a", "b"]);
});
});
+9 -21
View File
@@ -379,29 +379,17 @@ export function resolveSidebarV2Status(thread: SidebarV2StatusInput): SidebarV2S
return "ready";
}
// v2 sort: approval-blocked threads pin above the recency flow, longest wait
// first, so nothing actionable can scroll away. Everything else is recency.
// v2 sort: static creation order, newest thread on top. Activity NEVER
// reorders the list — a row holds its position from open until settled, so
// the screen only moves at lifecycle transitions. Status (including pending
// approval) is carried by each card's edge strip, not by position.
export function sortThreadsForSidebarV2<
T extends SidebarV2StatusInput & ThreadSortInput & { readonly id: string },
T extends { readonly id: string; readonly createdAt: string },
>(threads: readonly T[]): T[] {
return [...threads].toSorted((left, right) => {
const leftApproval = resolveSidebarV2Status(left) === "approval";
const rightApproval = resolveSidebarV2Status(right) === "approval";
if (leftApproval !== rightApproval) {
return leftApproval ? -1 : 1;
}
// Approval activities update the shell's updatedAt in the projection
// pipeline, making it the best available request-time proxy. Oldest waits
// pin first. (The shell does not expose the approval request timestamp.)
if (leftApproval && rightApproval) {
return (
Date.parse(left.updatedAt) - Date.parse(right.updatedAt) || left.id.localeCompare(right.id)
);
}
const byRecency =
getThreadSortTimestamp(right, "updated_at") - getThreadSortTimestamp(left, "updated_at");
return byRecency || left.id.localeCompare(right.id);
});
return [...threads].toSorted(
(left, right) =>
Date.parse(right.createdAt) - Date.parse(left.createdAt) || left.id.localeCompare(right.id),
);
}
export function resolveThreadStatusPill(input: {
+110 -82
View File
@@ -140,15 +140,16 @@ const SidebarV2Row = memo(function SidebarV2Row(props: {
// Slim rows are either settled (action: un-settle) or merely quiet
// (seen Ready threads — action: settle).
variantAction: "settle" | "unsettle";
// Draws a hairline above the first quiet row after the card block, so the
// active island and the history tail read as separate zones (mock's
// SETTLED rule) without a labeled section header.
// Draws a hairline above the first settled row after a group's card
// block, so active work and the history tail read as separate zones
// inside each project section.
showQuietDivider?: boolean;
isActive: boolean;
jumpLabel: string | null;
currentEnvironmentId: string | null;
environmentLabel: string | null;
projectCwd: string | null;
projectTitle: string | null;
providerEntryByInstanceId: ReadonlyMap<string, ProviderInstanceEntry>;
onThreadClick: (event: ReactMouseEvent, threadRef: ScopedThreadRef) => void;
onThreadActivate: (threadRef: ScopedThreadRef) => void;
@@ -310,14 +311,6 @@ const SidebarV2Row = memo(function SidebarV2Row(props: {
: "hover:bg-foreground/5 dark:hover:bg-white/[0.06]",
);
const favicon = (
<ProjectFavicon
environmentId={thread.environmentId}
cwd={props.projectCwd ?? ""}
className={variant === "card" ? "size-4" : "size-3.5"}
/>
);
const title = isRenaming ? (
<input
autoFocus
@@ -391,8 +384,8 @@ const SidebarV2Row = memo(function SidebarV2Row(props: {
onKeyDown={handleKeyDown}
onContextMenu={handleContextMenu}
>
{/* Settled history recedes: desaturated and dimmed at rest, restored
on hover so the tail stays scannable when you're hunting. */}
{/* Settled history recedes: dimmed favicon at rest, restored on
hover so the tail stays scannable when you're hunting. */}
<span
className={cn(
"shrink-0 transition-opacity",
@@ -400,7 +393,11 @@ const SidebarV2Row = memo(function SidebarV2Row(props: {
"opacity-40 grayscale group-hover/v2-row:opacity-100 group-hover/v2-row:grayscale-0",
)}
>
{favicon}
<ProjectFavicon
environmentId={thread.environmentId}
cwd={props.projectCwd ?? ""}
className="size-3.5"
/>
</span>
{title}
{prBadge}
@@ -445,14 +442,14 @@ const SidebarV2Row = memo(function SidebarV2Row(props: {
return (
<li
data-thread-item
className="list-none py-0.5 [content-visibility:auto] [contain-intrinsic-size:auto_88px]"
className="list-none py-0.5 [content-visibility:auto] [contain-intrinsic-size:auto_100px]"
>
<div
role="button"
tabIndex={0}
data-testid="sidebar-v2-row-card"
className={cn(
"group/v2-row relative w-full cursor-pointer select-none overflow-hidden border bg-card py-2 pl-[15px] pr-3 text-left transition-colors dark:bg-white/[0.04]",
"group/v2-row relative w-full cursor-pointer select-none overflow-hidden border bg-card text-left transition-colors dark:bg-white/[0.04]",
props.isActive
? "border-foreground/70 bg-foreground/5 dark:border-foreground/75 dark:bg-white/[0.08]"
: isSelected
@@ -465,24 +462,36 @@ const SidebarV2Row = memo(function SidebarV2Row(props: {
onContextMenu={handleContextMenu}
>
{statusEdge ? (
<span aria-hidden className={cn("absolute inset-y-0 left-0 w-[3px]", statusEdge)} />
<span aria-hidden className={cn("absolute inset-y-0 left-0 z-10 w-[3px]", statusEdge)} />
) : null}
<div className="flex items-start gap-2.5">
<span className="mt-0.5 shrink-0">{favicon}</span>
{title}
{diff ? (
<span className="shrink-0 font-mono text-[11px] leading-5">
<span className="text-emerald-600 dark:text-emerald-400">+{diff.insertions}</span>{" "}
<span className="text-red-600 dark:text-red-400">−{diff.deletions}</span>
{/* Title bar: the card is a tiny window whose chrome carries project
identity — favicon + name up top, separated by a hairline, so
"which project" reads before the thread content does. */}
<div
className={cn(
"flex items-center gap-1.5 border-b py-1 pl-[15px] pr-3",
props.isActive
? "border-black/20 bg-black/[0.06] dark:border-white/25 dark:bg-white/[0.06]"
: "border-black/10 bg-black/[0.03] dark:border-white/10 dark:bg-white/[0.03]",
)}
>
<ProjectFavicon
environmentId={thread.environmentId}
cwd={props.projectCwd ?? ""}
className="size-3"
/>
{props.projectTitle ? (
<span className="min-w-0 truncate font-mono text-[9px] font-semibold uppercase tracking-[0.14em] text-muted-foreground">
{props.projectTitle}
</span>
) : null}
<span className="relative flex h-5 w-16 shrink-0 items-center justify-end">
<span className="relative ml-auto flex h-4 w-16 shrink-0 items-center justify-end">
<span
className={cn(
"font-mono text-[11px] tabular-nums transition-opacity group-hover/v2-row:opacity-0",
"font-mono text-[10px] tabular-nums transition-opacity group-hover/v2-row:opacity-0",
status === "approval"
? "text-amber-600 dark:text-amber-400"
: "text-muted-foreground/70",
: "text-muted-foreground/50",
)}
>
{props.jumpLabel ?? workingTimer ?? threadTimeLabel(thread, status)}
@@ -491,68 +500,79 @@ const SidebarV2Row = memo(function SidebarV2Row(props: {
type="button"
aria-label="Settle thread"
onClick={handleSettleClick}
className="absolute inset-y-0 right-0 inline-flex items-center gap-1 border border-border bg-background px-2 text-[11px] text-muted-foreground opacity-0 transition-opacity hover:text-foreground group-hover/v2-row:opacity-100"
className="absolute inset-y-0 right-0 inline-flex items-center gap-1 border border-border bg-background px-2 text-[10px] text-muted-foreground opacity-0 transition-opacity hover:text-foreground group-hover/v2-row:opacity-100"
>
<CheckIcon className="size-3" />
Settle
</button>
</span>
</div>
<div className="mt-1.5 flex items-center gap-2 pl-[26px] text-[11px] text-muted-foreground/70">
{statusWord ? (
<span
className={cn(
"shrink-0 font-mono text-[10px] font-semibold uppercase tracking-[0.08em]",
statusWord.className,
)}
>
{statusWord.label}
</span>
) : null}
{status === "failed" && thread.session?.lastError ? (
<span className="min-w-0 truncate text-red-600/80 dark:text-red-400/80">
{thread.session.lastError}
</span>
) : (
<>
{thread.branch ? (
<span className="min-w-0 truncate font-mono text-muted-foreground/70">
{thread.branch}
</span>
<div className="py-2 pl-[15px] pr-3">
<div className="flex items-start gap-2.5">
{title}
{diff ? (
<span className="shrink-0 font-mono text-[11px] leading-5">
<span className="text-emerald-600 dark:text-emerald-400">+{diff.insertions}</span>{" "}
<span className="text-red-600 dark:text-red-400">−{diff.deletions}</span>
</span>
) : null}
</div>
<div className="mt-1 flex items-center gap-2 text-[11px] text-muted-foreground/70">
{statusWord ? (
<span
className={cn(
"shrink-0 font-mono text-[10px] font-semibold uppercase tracking-[0.08em]",
statusWord.className,
)}
>
{statusWord.label}
</span>
) : null}
{status === "failed" && thread.session?.lastError ? (
<span className="min-w-0 truncate text-red-600/80 dark:text-red-400/80">
{thread.session.lastError}
</span>
) : (
<>
{thread.branch ? (
<span className="min-w-0 truncate font-mono text-muted-foreground/70">
{thread.branch}
</span>
) : null}
{prBadge}
</>
)}
<span className="ml-auto inline-flex shrink-0 items-center gap-1.5">
{driverKind ? (
<Tooltip>
<TooltipTrigger
render={<span className="inline-flex shrink-0 items-center opacity-70" />}
>
<ProviderInstanceIcon
driverKind={driverKind}
displayName={thread.session?.providerName ?? modelInstanceId}
iconClassName="size-3"
/>
</TooltipTrigger>
<TooltipPopup side="top">{thread.modelSelection.model}</TooltipPopup>
</Tooltip>
) : null}
{prBadge}
</>
)}
<span className="ml-auto inline-flex shrink-0 items-center gap-1.5">
{driverKind ? (
<Tooltip>
<TooltipTrigger
render={<span className="inline-flex shrink-0 items-center opacity-70" />}
>
<ProviderInstanceIcon
driverKind={driverKind}
displayName={thread.session?.providerName ?? modelInstanceId}
iconClassName="size-3"
/>
</TooltipTrigger>
<TooltipPopup side="top">{thread.modelSelection.model}</TooltipPopup>
</Tooltip>
) : null}
{isRemote ? (
<Tooltip>
<TooltipTrigger
render={
<span className="inline-flex shrink-0 items-center text-muted-foreground/50" />
}
>
<CloudIcon className="size-3" />
</TooltipTrigger>
<TooltipPopup side="top">
Running on {props.environmentLabel ?? "a remote environment"}
</TooltipPopup>
</Tooltip>
) : null}
</span>
{isRemote ? (
<Tooltip>
<TooltipTrigger
render={
<span className="inline-flex shrink-0 items-center text-muted-foreground/50" />
}
>
<CloudIcon className="size-3" />
</TooltipTrigger>
<TooltipPopup side="top">
Running on {props.environmentLabel ?? "a remote environment"}
</TooltipPopup>
</Tooltip>
) : null}
</span>
</div>
</div>
</div>
</li>
@@ -622,6 +642,11 @@ export default function SidebarV2() {
),
[projects],
);
const projectTitleByKey = useMemo(
() =>
new Map(projects.map((project) => [`${project.environmentId}:${project.id}`, project.title])),
[projects],
);
// now is quantized to the minute so effectiveSettled memoization doesn't
// churn on every render; auto-settle thresholds are day-granular anyway.
@@ -1344,6 +1369,9 @@ export default function SidebarV2() {
projectCwd={
projectCwdByKey.get(`${thread.environmentId}:${thread.projectId}`) ?? null
}
projectTitle={
projectTitleByKey.get(`${thread.environmentId}:${thread.projectId}`) ?? null
}
providerEntryByInstanceId={providerEntryByInstanceId}
onThreadClick={handleThreadClick}
onThreadActivate={navigateToThread}
+10 -8
View File
@@ -2049,7 +2049,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
>
<div
className={cn(
"group rounded-[22px] p-px transition-colors duration-200",
"group rounded-[13px] p-px transition-colors duration-200",
composerProviderState.composerFrameClassName,
)}
onDragEnter={onComposerDragEnter}
@@ -2061,8 +2061,10 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
ref={composerSurfaceRef}
data-chat-composer-mobile-collapsed={isComposerCollapsedMobile ? "true" : "false"}
className={cn(
"chat-composer-glass rounded-[20px] border transition-colors duration-200 has-focus-visible:border-ring/45",
isDragOverComposer ? "border-primary/70 bg-accent/45" : "border-border",
"chat-composer-glass rounded-[12px] border transition-colors duration-200 has-focus-visible:border-foreground/40",
isDragOverComposer
? "border-primary/70 bg-accent/45"
: "border-black/12 dark:border-white/12",
environmentUnavailable ? "opacity-75" : null,
composerProviderState.composerSurfaceClassName,
)}
@@ -2087,14 +2089,14 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
>
{!isComposerCollapsedMobile &&
(activePendingApproval ? (
<div className="rounded-t-[19px] border-b border-border/65 bg-muted/20">
<div className="rounded-t-[11px] border-b border-border/65 bg-muted/20">
<ComposerPendingApprovalPanel
approval={activePendingApproval}
pendingCount={pendingApprovals.length}
/>
</div>
) : pendingUserInputs.length > 0 ? (
<div className="rounded-t-[19px] border-b border-border/65 bg-muted/20">
<div className="rounded-t-[11px] border-b border-border/65 bg-muted/20">
<ComposerPendingUserInputPanel
pendingUserInputs={pendingUserInputs}
respondingRequestIds={respondingRequestIds}
@@ -2105,7 +2107,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
/>
</div>
) : showPlanFollowUpPrompt && activeProposedPlan ? (
<div className="rounded-t-[19px] border-b border-border/65 bg-muted/20">
<div className="rounded-t-[11px] border-b border-border/65 bg-muted/20">
<ComposerPlanFollowUpBanner
key={activeProposedPlan.id}
planTitle={proposedPlanTitle(activeProposedPlan.planMarkdown) ?? null}
@@ -2115,7 +2117,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
{isComposerCollapsedMobile && activePendingApproval ? (
<div
className="rounded-t-[19px] border-b border-border/65 bg-muted/20"
className="rounded-t-[11px] border-b border-border/65 bg-muted/20"
data-chat-composer-collapsed-controls="true"
>
<ComposerPendingApprovalPanel
@@ -2132,7 +2134,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
</div>
) : isComposerCollapsedMobile && pendingUserInputs.length > 0 ? (
<div
className="rounded-t-[19px] border-b border-border/65 bg-muted/20"
className="rounded-t-[11px] border-b border-border/65 bg-muted/20"
data-chat-composer-collapsed-controls="true"
>
<ComposerPendingUserInputPanel
@@ -16,6 +16,7 @@ import ProjectScriptsControl, {
} from "../ProjectScriptsControl";
import { OpenInPicker } from "./OpenInPicker";
import { usePrimaryEnvironmentId } from "../../state/environments";
import { ProjectFavicon } from "../ProjectFavicon";
import { cn } from "~/lib/utils";
interface ChatHeaderProps {
@@ -24,6 +25,7 @@ interface ChatHeaderProps {
draftId?: DraftId;
activeThreadTitle: string;
activeProjectName: string | undefined;
activeProjectCwd: string | null;
openInCwd: string | null;
activeProjectScripts: ReadonlyArray<ProjectScript> | undefined;
preferredScriptId: string | null;
@@ -58,6 +60,7 @@ export const ChatHeader = memo(function ChatHeader({
draftId,
activeThreadTitle,
activeProjectName,
activeProjectCwd,
openInCwd,
activeProjectScripts,
preferredScriptId,
@@ -79,6 +82,27 @@ export const ChatHeader = memo(function ChatHeader({
return (
<div className="@container/header-actions flex min-w-0 flex-1 items-center gap-2 sm:gap-3">
<div className="flex min-w-0 flex-1 items-center gap-2 overflow-hidden sm:gap-3">
{/* The project always leads the header: knowing which project a
thread lives in is priority zero, and the thread title alone
doesn't answer it. Mirrors the sidebar cards' title bar —
favicon + mono uppercase name. */}
{activeProjectName ? (
<span className="inline-flex shrink-0 items-center gap-2">
<span className="inline-flex items-center gap-1.5 border border-black/12 py-0.5 pl-1.5 pr-2 dark:border-white/12">
<ProjectFavicon
environmentId={activeThreadEnvironmentId}
cwd={activeProjectCwd ?? ""}
className="size-3"
/>
<span className="max-w-40 truncate font-mono text-[10px] font-semibold uppercase tracking-[0.08em] text-muted-foreground">
{activeProjectName}
</span>
</span>
<span aria-hidden className="text-muted-foreground/40">
/
</span>
</span>
) : null}
<Tooltip>
<TooltipTrigger
render={