Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
feat(web): search threads from the sidebar (#4769)
shivambfc31507f848
diff --git a/apps/web/src/components/Sidebar.logic.test.ts b/apps/web/src/components/Sidebar.logic.test.tsindex 9c1e7c8c5..ac2716a19 100644--- a/apps/web/src/components/Sidebar.logic.test.ts+++ b/apps/web/src/components/Sidebar.logic.test.ts@@ -20,6 +20,7 @@ import {resolveSidebarV2Status,resolveThreadStatusPill,resolveWorkingStartedAt,+ searchSidebarThreadsByTitle,formatWorkingDurationLabel,shouldNavigateAfterProjectRemoval,shouldClearThreadSelectionOnMouseDown,@@ -691,6 +692,26 @@ describe("resolveSidebarV2Status", () => {});});+describe("searchSidebarThreadsByTitle", () => {+ const threads = [+ { id: "thread-1", title: "Fix workspace search", project: "Alpha" },+ { id: "thread-2", title: "Review providers", project: "Workspace" },+ { id: "thread-3", title: "WORKTREE cleanup", project: "Beta" },+ ];++ it("matches thread titles case-insensitively and preserves their order", () => {+ expect(searchSidebarThreadsByTitle(threads, "work")).toEqual([threads[0], threads[2]]);+ });++ it("does not match project metadata", () => {+ expect(searchSidebarThreadsByTitle(threads, "workspace")).toEqual([threads[0]]);+ });++ it("returns no results for an empty query", () => {+ expect(searchSidebarThreadsByTitle(threads, " ")).toEqual([]);+ });+});+describe("sortThreadsForSidebarV2", () => {const sortable = (input: { id: string; createdAt: string }) => ({id: input.id,diff --git a/apps/web/src/components/Sidebar.logic.ts b/apps/web/src/components/Sidebar.logic.tsindex d11e06c84..7b8a0eff3 100644--- a/apps/web/src/components/Sidebar.logic.ts+++ b/apps/web/src/components/Sidebar.logic.ts@@ -490,6 +490,20 @@ export function sortThreadsForSidebarV2<);}+/**+ * Search the already-ordered sidebar thread collection by title only.+ * Keeping the input order means lifecycle ordering (active, snoozed, settled)+ * remains stable while the user narrows the list.+ */+export function searchSidebarThreadsByTitle<T extends { readonly title: string }>(+ threads: readonly T[],+ query: string,+): T[] {+ const normalizedQuery = query.trim().toLowerCase();+ if (normalizedQuery.length === 0) return [];+ return threads.filter((thread) => thread.title.toLowerCase().includes(normalizedQuery));+}+type SettledTimestampInput = Pick<SidebarThreadSummary,"settledAt" | "latestUserMessageAt" | "latestTurn" | "updatedAt"diff --git a/apps/web/src/components/SidebarV2.tsx b/apps/web/src/components/SidebarV2.tsxindex 2d482b30d..ee73b5705 100644--- a/apps/web/src/components/SidebarV2.tsx+++ b/apps/web/src/components/SidebarV2.tsx@@ -35,6 +35,7 @@ import {TerminalIcon,Trash2Icon,Undo2Icon,+ XIcon,} from "lucide-react";import {memo,@@ -115,6 +116,7 @@ import {resolveAdjacentThreadId,resolveSettledTimestamp,resolveSidebarV2Status,+ searchSidebarThreadsByTitle,resolveWorkingStartedAt,shouldNavigateAfterProjectRemoval,sortLogicalProjectsForSidebar,@@ -142,7 +144,6 @@ import { deriveProviderInstanceEntries, type ProviderInstanceEntry } from "../primport { primaryServerProvidersAtom } from "../state/server";import { useThreadRunningTerminalIds } from "../state/terminalSessions";import { stackedThreadToast, toastManager } from "./ui/toast";-import { CommandDialogTrigger } from "./ui/command";import { Button } from "./ui/button";import {Dialog,@@ -154,7 +155,6 @@ import {DialogTitle,} from "./ui/dialog";import { Input } from "./ui/input";-import { Kbd } from "./ui/kbd";import { Menu, MenuPopup, MenuRadioGroup, MenuRadioItem, MenuTrigger } from "./ui/menu";import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "./ui/select";import { SidebarContent, SidebarGroup, SidebarMenuButton, useSidebar } from "./ui/sidebar";@@ -1068,6 +1068,106 @@ function latestTurnDiff(return null;}+const SidebarV2SearchResultRow = memo(function SidebarV2SearchResultRow(props: {+ thread: SidebarThreadSummary;+ projectCwd: string | null;+ projectTitle: string | null;+ environmentLabel: string | null;+ providerEntryByInstanceId: ReadonlyMap<string, ProviderInstanceEntry>;+ isHighlighted: boolean;+ isRouteActive: boolean;+ resultId: string;+ onHighlight: () => void;+ onSelect: () => void;+}) {+ const { thread } = props;+ // Same details tooltip as the regular rows: a search hit is still a thread,+ // and the hover card is how you disambiguate identically-titled results.+ const gitCwd = thread.worktreePath ?? props.projectCwd;+ const gitStatus = useEnvironmentQuery(+ (thread.branch != null || thread.worktreePath !== null) && gitCwd !== null+ ? vcsEnvironment.status({+ environmentId: thread.environmentId,+ input: { cwd: gitCwd },+ })+ : null,+ );+ const branchMismatch = resolveLocalCheckoutBranchMismatch({+ effectiveEnvMode: thread.worktreePath === null ? "local" : "worktree",+ activeWorktreePath: thread.worktreePath,+ activeThreadBranch: thread.branch,+ currentGitBranch: gitStatus.data?.refName ?? null,+ });+ const modelInstanceId = thread.session?.providerInstanceId ?? thread.modelSelection.instanceId;+ const providerEntry = props.providerEntryByInstanceId.get(modelInstanceId) ?? null;+ const driverKind = providerEntry?.driverKind ?? null;+ const selectedModel = providerEntry?.models.find(+ (model) => model.slug === thread.modelSelection.model,+ );+ const modelLabel = selectedModel+ ? getTriggerDisplayModelLabel(selectedModel)+ : thread.modelSelection.model;+ const runningTerminalIds = useThreadRunningTerminalIds({+ environmentId: thread.environmentId,+ threadId: thread.id,+ });+ const terminalStatus = terminalStatusFromRunningIds(runningTerminalIds);+ return (+ <li role="presentation" className="list-none">+ <Tooltip>+ <TooltipTrigger+ render={+ <button+ id={props.resultId}+ type="button"+ role="option"+ // aria-activedescendant options: focus stays on the search input,+ // which owns all keyboard interaction for the listbox.+ tabIndex={-1}+ aria-selected={props.isHighlighted}+ aria-current={props.isRouteActive ? "page" : undefined}+ aria-label={+ props.projectTitle ? `${thread.title}, ${props.projectTitle}` : thread.title+ }+ onMouseMove={props.onHighlight}+ onClick={props.onSelect}+ className={cn(+ "flex h-9 w-full cursor-pointer items-center gap-2.5 rounded-md px-2.5 text-left text-sm outline-none",+ props.isHighlighted || props.isRouteActive+ ? "bg-sidebar-row-active text-sidebar-foreground"+ : "text-sidebar-muted-foreground/75 hover:bg-sidebar-row-hover hover:text-sidebar-foreground",+ )}+ />+ }+ >+ <ProjectFavicon+ environmentId={thread.environmentId}+ cwd={props.projectCwd ?? ""}+ className="size-4 shrink-0"+ fallbackIcon={MessageSquareIcon}+ />+ <span className="min-w-0 flex-1 truncate">{thread.title}</span>+ <span className="shrink-0 text-xs text-muted-foreground/55 tabular-nums">+ {threadTimeLabel(thread)}+ </span>+ </TooltipTrigger>+ <SidebarV2ThreadTooltip+ thread={thread}+ projectTitle={props.projectTitle}+ projectCwd={props.projectCwd}+ environmentLabel={props.environmentLabel}+ driverKind={driverKind}+ modelInstanceId={modelInstanceId}+ modelLabel={modelLabel}+ branchMismatch={branchMismatch}+ terminalStatus={terminalStatus}+ terminalProcessCount={runningTerminalIds.length}+ />+ </Tooltip>+ </li>+ );+});+export default function SidebarV2() {const projects = useProjects();const projectOrder = useUiStateStore((store) => store.projectOrder);@@ -1520,6 +1620,33 @@ export default function SidebarV2() {threads,]);+ const threadSearchInputRef = useRef<HTMLInputElement>(null);+ const [threadSearchQuery, setThreadSearchQuery] = useState("");+ const [activeSearchResultIndex, setActiveSearchResultIndex] = useState(0);+ const isSearchingThreads = threadSearchQuery.trim().length > 0;+ const searchableThreads = useMemo(+ () => [...activeThreads, ...snoozedThreads, ...settledThreads],+ [activeThreads, settledThreads, snoozedThreads],+ );+ const threadSearchResults = useMemo(+ () => searchSidebarThreadsByTitle(searchableThreads, threadSearchQuery),+ [searchableThreads, threadSearchQuery],+ );+ const threadSearchResultOrderKey = threadSearchResults+ .map((thread) => scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id)))+ .join("\0");++ useEffect(() => {+ setActiveSearchResultIndex(0);+ }, [threadSearchResultOrderKey]);++ useEffect(() => {+ if (!isSearchingThreads) return;+ document+ .getElementById(`sidebar-thread-search-result-${activeSearchResultIndex}`)+ ?.scrollIntoView({ block: "nearest" });+ }, [activeSearchResultIndex, isSearchingThreads, threadSearchResultOrderKey]);+// Arm a timeout for the earliest upcoming wake so the shelf empties the// moment a snooze expires instead of on the next minute tick. Sorted// soonest-first, so entry 0 is the boundary.@@ -1693,6 +1820,56 @@ export default function SidebarV2() {[clearSelection, isMobile, router, setOpenMobile, setSelectionAnchor],);+ const clearThreadSearch = useCallback(() => {+ setThreadSearchQuery("");+ setActiveSearchResultIndex(0);+ }, []);+ const selectThreadSearchResult = useCallback(+ (thread: EnvironmentThreadShell) => {+ clearThreadSearch();+ navigateToThread(scopeThreadRef(thread.environmentId, thread.id));+ },+ [clearThreadSearch, navigateToThread],+ );+ const handleThreadSearchKeyDown = useCallback(+ (event: ReactKeyboardEvent<HTMLInputElement>) => {+ // IME composition (Japanese/Chinese input) uses the same keys; committing+ // a candidate must not move the highlight or navigate away mid-compose.+ if (event.nativeEvent.isComposing || event.keyCode === 229) return;+ if (event.key === "Escape" && isSearchingThreads) {+ event.preventDefault();+ event.stopPropagation();+ clearThreadSearch();+ return;+ }+ if (threadSearchResults.length === 0) return;+ if (event.key === "ArrowDown") {+ event.preventDefault();+ setActiveSearchResultIndex((index) => (index + 1) % threadSearchResults.length);+ return;+ }+ if (event.key === "ArrowUp") {+ event.preventDefault();+ setActiveSearchResultIndex(+ (index) => (index - 1 + threadSearchResults.length) % threadSearchResults.length,+ );+ return;+ }+ if (event.key === "Enter") {+ event.preventDefault();+ const result = threadSearchResults[activeSearchResultIndex];+ if (result) selectThreadSearchResult(result);+ }+ },+ [+ activeSearchResultIndex,+ clearThreadSearch,+ isSearchingThreads,+ selectThreadSearchResult,+ threadSearchResults,+ ],+ );+const [renamingThreadKey, setRenamingThreadKey] = useState<string | null>(null);const [renamingTitle, setRenamingTitle] = useState("");const startThreadRename = useCallback((threadRef: ScopedThreadRef, title: string) => {@@ -2398,7 +2575,6 @@ export default function SidebarV2() {openCommandPalette({ open: "new-thread-in" });}, [isMobile, newThreadContext, projectGroups.length, setOpenMobile]);- const commandPaletteShortcutLabel = shortcutLabelForCommand(keybindings, "commandPalette.toggle");// Same resolution as v1: prefer the local-thread binding, fall back to// chat.new, no platform gating — web users have working shortcuts too.const newThreadShortcutLabel =@@ -2412,25 +2588,51 @@ export default function SidebarV2() {fixedHeader={<SidebarGroup className="gap-1 p-[var(--sidebar-content-inset)]"><div className="flex items-center gap-1">- <div className="min-w-0 flex-1">- <CommandDialogTrigger- render={- <SidebarMenuButton- type="button"- aria-label="Search threads and commands"- className="focus-visible:ring-offset-2 focus-visible:ring-offset-sidebar"- data-testid="command-palette-trigger"- />+ <div className="flex h-8 min-w-0 flex-1 items-center gap-2 rounded-md px-2 py-1.5 text-sm font-medium text-sidebar-muted-foreground hover:bg-sidebar-row-hover hover:text-sidebar-foreground">+ <SearchIcon className="size-4 shrink-0 text-sidebar-muted-foreground/80" />+ <Input+ ref={threadSearchInputRef}+ nativeInput+ unstyled+ type="search"+ value={threadSearchQuery}+ onChange={(event) => {+ setThreadSearchQuery(event.currentTarget.value);+ setActiveSearchResultIndex(0);+ }}+ onKeyDown={handleThreadSearchKeyDown}+ placeholder="Search"+ aria-label="Search threads"+ role="combobox"+ aria-autocomplete="list"+ aria-expanded={isSearchingThreads && threadSearchResults.length > 0}+ aria-controls={+ isSearchingThreads && threadSearchResults.length > 0+ ? "sidebar-thread-search-results"+ : undefined}- >- <SearchIcon />- <div className="flex-1 truncate text-left">Search</div>- {commandPaletteShortcutLabel ? (- <Kbd className="mr-px h-4 min-w-0 rounded-sm bg-sidebar-control-surface px-1.5 text-[10px] text-sidebar-muted-foreground ring-1 ring-sidebar-border">- {commandPaletteShortcutLabel}- </Kbd>- ) : null}- </CommandDialogTrigger>+ aria-activedescendant={+ isSearchingThreads && threadSearchResults[activeSearchResultIndex]+ ? `sidebar-thread-search-result-${activeSearchResultIndex}`+ : undefined+ }+ className="min-w-0 flex-1 [&_[data-slot=input]]:h-auto [&_[data-slot=input]]:p-0 [&_[data-slot=input]]:leading-normal [&_[data-slot=input]]:text-sm [&_[data-slot=input]]:font-medium [&_[data-slot=input]]:text-sidebar-foreground [&_[data-slot=input]]:placeholder:text-sidebar-muted-foreground"+ />+ {isSearchingThreads ? (+ <Button+ type="button"+ size="icon-xs"+ variant="ghost"+ className="size-5 shrink-0 rounded-sm text-sidebar-muted-foreground hover:bg-sidebar-control-surface hover:text-sidebar-foreground"+ aria-label="Clear thread search"+ onClick={() => {+ clearThreadSearch();+ threadSearchInputRef.current?.focus();+ }}+ >+ <XIcon className="size-3" />+ </Button>+ ) : null}</div><div className="shrink-0"><Tooltip>@@ -2559,179 +2761,245 @@ export default function SidebarV2() {}><SidebarGroup className="px-[var(--sidebar-content-inset)] pb-1 pt-0">- <TooltipProvider- key="sidebar-thread-tooltips-150"- delay={150}- closeDelay={0}- timeout={400}- >- <ul ref={attachListAutoAnimateRef} role="list" className="flex flex-col gap-px">- {(() => {- const renderThreadRow = (- thread: EnvironmentThreadShell,- section: "active" | "snoozed" | "settled",- ) => {- 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.- const isCard = section === "active";- const rowVariant = isCard ? "card" : "slim";- return (- <SidebarV2Row- // Keyed per variant on purpose: when a thread settles,- // the card fades out in place and the slim row fades- // in at its settled position instead of one element- // FLIP-sliding through every row in between (rows here- // are translucent, so a crossing row reads as text- // painted over text).- key={`${threadKey}:${rowVariant}`}- thread={thread}- variant={rowVariant}- // Snoozed rows wake; settled rows un-settle (explicit- // settles clear the override, auto-settled rows get- // pinned active); cards settle.- variantAction={- section === "snoozed"- ? "unsnooze"- : section === "settled"- ? "unsettle"- : "settle"- }- settlementSupported={- serverConfigs.get(thread.environmentId)?.environment.capabilities- .threadSettlement === true- }- snoozeSupported={- serverConfigs.get(thread.environmentId)?.environment.capabilities- .threadSnooze === true- }- snoozeWakeLabelText={- section === "snoozed" && thread.snoozedUntil != null- ? snoozeWakeLabel(thread.snoozedUntil, {- now: new Date().toISOString(),- })- : null- }- // All sections: a woken thread can classify straight- // into the settled tail (PR merged while snoozed), and- // the wake signal must survive the trip. Still-snoozed- // rows resolve to null on their own.- wokeAt={threadWokeAt(thread, { now: snoozeNow })}- isActive={routeThreadKey === threadKey}- jumpLabel={showJumpHints ? (jumpLabelByKey.get(threadKey) ?? null) : null}- currentEnvironmentId={primaryEnvironmentId}- environmentLabel={environmentLabelById.get(thread.environmentId) ?? null}- projectCwd={- projectCwdByKey.get(`${thread.environmentId}:${thread.projectId}`) ?? null- }- projectTitle={- projectDisplayNameByKey.get(- `${thread.environmentId}:${thread.projectId}`,- ) ?? null- }- providerEntryByInstanceId={providerEntryByInstanceId}- onThreadClick={handleThreadClick}- onThreadActivate={navigateToThread}- onStartRename={startThreadRename}- onRenameTitleChange={setRenamingTitle}- onCommitRename={commitThreadRename}- onCancelRename={cancelThreadRename}- isRenaming={renamingThreadKey === threadKey}- renamingTitle={renamingThreadKey === threadKey ? renamingTitle : ""}- onContextMenu={handleThreadContextMenu}- onSettle={attemptSettle}- onUnsettle={attemptUnsettle}- onSnooze={attemptSnooze}- onUnsnooze={attemptUnsnooze}- onChangeRequestState={handleChangeRequestState}- />+ {isSearchingThreads ? (+ threadSearchResults.length > 0 ? (+ <TooltipProvider+ key="sidebar-thread-search-tooltips-150"+ delay={150}+ closeDelay={0}+ timeout={400}+ >+ <ul+ id="sidebar-thread-search-results"+ role="listbox"+ aria-label="Thread search results"+ className="flex flex-col gap-px"+ >+ {threadSearchResults.map((thread, index) => {+ const threadKey = scopedThreadKey(+ scopeThreadRef(thread.environmentId, thread.id),+ );+ return (+ <SidebarV2SearchResultRow+ key={threadKey}+ thread={thread}+ projectCwd={+ projectCwdByKey.get(`${thread.environmentId}:${thread.projectId}`) ?? null+ }+ projectTitle={+ projectDisplayNameByKey.get(+ `${thread.environmentId}:${thread.projectId}`,+ ) ?? null+ }+ environmentLabel={environmentLabelById.get(thread.environmentId) ?? null}+ providerEntryByInstanceId={providerEntryByInstanceId}+ isHighlighted={activeSearchResultIndex === index}+ isRouteActive={routeThreadKey === threadKey}+ resultId={`sidebar-thread-search-result-${index}`}+ onHighlight={() => setActiveSearchResultIndex(index)}+ onSelect={() => selectThreadSearchResult(thread)}+ />+ );+ })}+ </ul>+ </TooltipProvider>+ ) : (+ <p+ role="status"+ className="px-2 py-6 text-center text-xs text-sidebar-muted-foreground"+ >+ No threads found+ </p>+ )+ ) : null}+ {!isSearchingThreads ? (+ <TooltipProvider+ key="sidebar-thread-tooltips-150"+ delay={150}+ closeDelay={0}+ timeout={400}+ >+ <ul ref={attachListAutoAnimateRef} role="list" className="flex flex-col gap-px">+ {(() => {+ const renderThreadRow = (+ thread: EnvironmentThreadShell,+ section: "active" | "snoozed" | "settled",+ ) => {+ 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.+ const isCard = section === "active";+ const rowVariant = isCard ? "card" : "slim";+ return (+ <SidebarV2Row+ // Keyed per variant on purpose: when a thread settles,+ // the card fades out in place and the slim row fades+ // in at its settled position instead of one element+ // FLIP-sliding through every row in between (rows here+ // are translucent, so a crossing row reads as text+ // painted over text).+ key={`${threadKey}:${rowVariant}`}+ thread={thread}+ variant={rowVariant}+ // Snoozed rows wake; settled rows un-settle (explicit+ // settles clear the override, auto-settled rows get+ // pinned active); cards settle.+ variantAction={+ section === "snoozed"+ ? "unsnooze"+ : section === "settled"+ ? "unsettle"+ : "settle"+ }+ settlementSupported={+ serverConfigs.get(thread.environmentId)?.environment.capabilities+ .threadSettlement === true+ }+ snoozeSupported={+ serverConfigs.get(thread.environmentId)?.environment.capabilities+ .threadSnooze === true+ }+ snoozeWakeLabelText={+ section === "snoozed" && thread.snoozedUntil != null+ ? snoozeWakeLabel(thread.snoozedUntil, {+ now: new Date().toISOString(),+ })+ : null+ }+ // All sections: a woken thread can classify straight+ // into the settled tail (PR merged while snoozed), and+ // the wake signal must survive the trip. Still-snoozed+ // rows resolve to null on their own.+ wokeAt={threadWokeAt(thread, { now: snoozeNow })}+ isActive={routeThreadKey === threadKey}+ jumpLabel={showJumpHints ? (jumpLabelByKey.get(threadKey) ?? null) : null}+ currentEnvironmentId={primaryEnvironmentId}+ environmentLabel={environmentLabelById.get(thread.environmentId) ?? null}+ projectCwd={+ projectCwdByKey.get(`${thread.environmentId}:${thread.projectId}`) ?? null+ }+ projectTitle={+ projectDisplayNameByKey.get(+ `${thread.environmentId}:${thread.projectId}`,+ ) ?? null+ }+ providerEntryByInstanceId={providerEntryByInstanceId}+ onThreadClick={handleThreadClick}+ onThreadActivate={navigateToThread}+ onStartRename={startThreadRename}+ onRenameTitleChange={setRenamingTitle}+ onCommitRename={commitThreadRename}+ onCancelRename={cancelThreadRename}+ isRenaming={renamingThreadKey === threadKey}+ renamingTitle={renamingThreadKey === threadKey ? renamingTitle : ""}+ onContextMenu={handleThreadContextMenu}+ onSettle={attemptSettle}+ onUnsettle={attemptUnsettle}+ onSnooze={attemptSnooze}+ onUnsnooze={attemptUnsnooze}+ onChangeRequestState={handleChangeRequestState}+ />+ );+ };+ const items: ReactNode[] = activeThreads.map((thread) =>+ renderThreadRow(thread, "active"),);- };- const items: ReactNode[] = activeThreads.map((thread) =>- renderThreadRow(thread, "active"),- );- // Snoozed shelf: between the inbox and Settled — out of the- // way, never gone. The header always renders while anything- // is snoozed (the count is the whole footprint when- // collapsed); rows only when expanded. Vanishes entirely at- // count 0.- if (snoozedThreads.length > 0) {- items.push(- <li key="snoozed-shelf-header" data-thread-selection-safe className="list-none">- <button- type="button"- onClick={toggleSnoozedShelf}- aria-expanded={snoozedShelfExpanded}- data-testid="sidebar-v2-snoozed-shelf-toggle"- className="mb-1 mt-3 flex w-full cursor-pointer items-center gap-2 px-2.5 text-left"+ // Snoozed shelf: between the inbox and Settled — out of the+ // way, never gone. The header always renders while anything+ // is snoozed (the count is the whole footprint when+ // collapsed); rows only when expanded. Vanishes entirely at+ // count 0.+ if (snoozedThreads.length > 0) {+ items.push(+ <li+ key="snoozed-shelf-header"+ data-thread-selection-safe+ className="list-none">- <span className="text-xs font-medium text-blue-600 dark:text-blue-400">- {snoozedShelfExpanded ? "Snoozed" : `Snoozed (${snoozedThreads.length})`}- </span>- <span className="h-px flex-1 bg-blue-500/20 dark:bg-blue-400/15" />- <ChevronDownIcon- aria-hidden- className={cn(- "size-3 text-blue-600 transition-transform dark:text-blue-400",- snoozedShelfExpanded && "rotate-180",- )}- />- </button>- </li>,- );- for (const thread of visibleSnoozedThreads) {- items.push(renderThreadRow(thread, "snoozed"));+ <button+ type="button"+ onClick={toggleSnoozedShelf}+ aria-expanded={snoozedShelfExpanded}+ data-testid="sidebar-v2-snoozed-shelf-toggle"+ className="mb-1 mt-3 flex w-full cursor-pointer items-center gap-2 px-2.5 text-left"+ >+ <span className="text-xs font-medium text-blue-600 dark:text-blue-400">+ {snoozedShelfExpanded+ ? "Snoozed"+ : `Snoozed (${snoozedThreads.length})`}+ </span>+ <span className="h-px flex-1 bg-blue-500/20 dark:bg-blue-400/15" />+ <ChevronDownIcon+ aria-hidden+ className={cn(+ "size-3 text-blue-600 transition-transform dark:text-blue-400",+ snoozedShelfExpanded && "rotate-180",+ )}+ />+ </button>+ </li>,+ );+ for (const thread of visibleSnoozedThreads) {+ items.push(renderThreadRow(thread, "snoozed"));+ }}- }- if (settledThreads.length > 0) {- items.push(- <li key="settled-shelf-header" data-thread-selection-safe className="list-none">- <button- type="button"- onClick={toggleSettledShelf}- aria-expanded={settledShelfExpanded}- data-testid="sidebar-v2-settled-shelf-toggle"- className="mb-1 mt-3 flex w-full cursor-pointer items-center gap-2 px-2.5 text-left"+ if (settledThreads.length > 0) {+ items.push(+ <li+ key="settled-shelf-header"+ data-thread-selection-safe+ className="list-none">- <span className="text-xs font-medium text-muted-foreground/50">- {settledShelfExpanded ? "Settled" : `Settled (${settledThreads.length})`}- </span>- <span className="h-px flex-1 bg-sidebar-border/60" />- <ChevronDownIcon- aria-hidden- className={cn(- "size-3 text-muted-foreground/50 transition-transform",- settledShelfExpanded && "rotate-180",- )}- />- </button>- </li>,- );- }- for (const thread of renderedSettledThreads) {- items.push(renderThreadRow(thread, "settled"));- }- return items;- })()}- {settledShelfExpanded && hiddenSettledCount > 0 ? (- <li className="list-none">- <button- type="button"- onClick={showMoreSettled}- className="flex h-9 w-full cursor-pointer items-center gap-2.5 rounded-md px-2.5 text-left text-sm text-sidebar-muted-foreground/55 hover:bg-sidebar-row-hover hover:text-sidebar-foreground"- >- <PlusIcon aria-hidden className="size-4 shrink-0" />- Show {Math.min(hiddenSettledCount, SETTLED_TAIL_PAGE_COUNT)} more- </button>- </li>- ) : null}- </ul>- </TooltipProvider>- {activeThreads.length + snoozedThreads.length + settledThreads.length === 0 ? (+ <button+ type="button"+ onClick={toggleSettledShelf}+ aria-expanded={settledShelfExpanded}+ data-testid="sidebar-v2-settled-shelf-toggle"+ className="mb-1 mt-3 flex w-full cursor-pointer items-center gap-2 px-2.5 text-left"+ >+ <span className="text-xs font-medium text-muted-foreground/50">+ {settledShelfExpanded+ ? "Settled"+ : `Settled (${settledThreads.length})`}+ </span>+ <span className="h-px flex-1 bg-sidebar-border/60" />+ <ChevronDownIcon+ aria-hidden+ className={cn(+ "size-3 text-muted-foreground/50 transition-transform",+ settledShelfExpanded && "rotate-180",+ )}+ />+ </button>+ </li>,+ );+ }+ for (const thread of renderedSettledThreads) {+ items.push(renderThreadRow(thread, "settled"));+ }+ return items;+ })()}+ {settledShelfExpanded && hiddenSettledCount > 0 ? (+ <li className="list-none">+ <button+ type="button"+ onClick={showMoreSettled}+ className="flex h-9 w-full cursor-pointer items-center gap-2.5 rounded-md px-2.5 text-left text-sm text-sidebar-muted-foreground/55 hover:bg-sidebar-row-hover hover:text-sidebar-foreground"+ >+ <PlusIcon aria-hidden className="size-4 shrink-0" />+ Show {Math.min(hiddenSettledCount, SETTLED_TAIL_PAGE_COUNT)} more+ </button>+ </li>+ ) : null}+ </ul>+ </TooltipProvider>+ ) : null}+ {!isSearchingThreads &&+ activeThreads.length + snoozedThreads.length + settledThreads.length === 0 ? (<div className="flex flex-col items-center gap-2 px-2 py-6 text-center text-xs text-muted-foreground/60">{projects.length === 0 ? (<>