@devries-cameron20 / t3code Mirror · read-only / commits / 4e4d4ba395
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 13:15 UTC

feat(web): boring sidebar groups threads into project folders (#21039)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Theo Browne committed Oct 28, 2026 at 00:05 UTC 4e4d4ba3959cae17db7bba1915e6a25885844484
24 files changed +549 -3899
apps/desktop/src/settings/DesktopClientSettings.test.ts
+1 -1
@@ -63,7 +63,7 @@ const clientSettings: ClientSettings = {
63 },
64 sidebarProjectSortOrder: "manual",
65 sidebarThreadSortOrder: "created_at",
66 - sidebarThreadPreviewCount: 6,
66 + boringSidebarEnabled: false,
67 legacySidebarEnabled: false,
68 sidebarWorkingShelfEnabled: false,
69 loadBalancingEnabled: false,
apps/web/package.json
-1
@@ -27,7 +27,6 @@
27 "@dnd-kit/utilities": "^3.2.2",
28 "@effect/atom-react": "catalog:",
29 "@fontsource-variable/inter": "^5.3.0",
30 - "@formkit/auto-animate": "^0.9.0",
30 "@legendapp/list": "catalog:",
31 "@noble/hashes": "catalog:",
32 "@pierre/diffs": "catalog:",
apps/web/src/components/AppSidebarLayout.tsx
+2 -8
@@ -31,14 +31,13 @@ import { selectActiveRightPanel, useRightPanelStore } from "../rightPanelStore";
31 import { selectThreadTerminalUiState, useTerminalUiStateStore } from "../terminalUiStateStore";
32 import { cn, isMacPlatform } from "../lib/utils";
33 import { primaryServerKeybindingsAtom } from "../state/server";
34 -import { useEnvironmentIdentificationMode, useLegacySidebarEnabled } from "../hooks/useSettings";
34 +import { useEnvironmentIdentificationMode } from "../hooks/useSettings";
35 import {
36 PanelAnimationSuppressionProvider,
37 usePanelAnimationSettings,
38 usePanelNavigationSuppression,
39 } from "../panelAnimations";
40 import { BackgroundThreadAnnouncer } from "./BackgroundThreadAnnouncer";
41 -import LegacyThreadSidebar from "./LegacySidebar";
41 import ThreadSidebar from "./Sidebar";
42 import { SidebarBrandWidthProbe } from "./sidebar/SidebarChrome";
43 import { isAppModalPage } from "./sidebar/mainAppLocation";
@@ -403,7 +402,6 @@ function SidebarControl() {
402
403 export function AppSidebarLayout({ children }: { children: ReactNode }) {
404 const sidebarArea = workspaceAreaProps("sidebar", 0, "Threads");
406 - const legacySidebarEnabled = useLegacySidebarEnabled();
405 const [sidebarRouteReveal] = useState<SidebarRouteReveal>(() => ({
406 observedKey: null,
407 pendingKey: null,
@@ -470,11 +468,7 @@ export function AppSidebarLayout({ children }: { children: ReactNode }) {
468 }}
469 style={windowControlsInsetStyle}
470 >
473 - {legacySidebarEnabled ? (
474 - <LegacyThreadSidebar routeReveal={sidebarRouteReveal} />
475 - ) : (
476 - <ThreadSidebar routeReveal={sidebarRouteReveal} />
477 - )}
471 + <ThreadSidebar routeReveal={sidebarRouteReveal} />
472 <SidebarRail onDoubleClick={resetSidebarWidth} />
473 </Sidebar>
474 {children}
apps/web/src/components/LegacySidebar.tsx deleted
-3743
@@ -1,3743 +0,0 @@
1 -import { attachSidebarTree, SIDEBAR_TREE_PROPS } from "../lib/sidebarTree";
2 -import { useSupportsMultiplePullRequests } from "~/hooks/useSupportsMultiplePullRequests";
3 -import { resolveThreadCurrentPullRequestLink } from "@t3tools/client-runtime/thread-pull-requests";
4 -import { Spinner } from "~/components/ui/spinner";
5 -import {
6 - ArchiveIcon,
7 - ArrowUpDownIcon,
8 - ChevronRightIcon,
9 - FolderPlusIcon,
10 - Globe2Icon,
11 - SearchIcon,
12 - SquarePenIcon,
13 - TriangleAlertIcon,
14 -} from "lucide-react";
15 -import {
16 - ChangeRequestStatusIcon,
17 - prStatusIndicator,
18 - PrStatusTooltipContent,
19 - ThreadTerminalStatusButton,
20 - ThreadStatusLabel,
21 - ThreadWorktreeIndicator,
22 - useLinkedThreadPullRequest,
23 -} from "./ThreadStatusIndicators";
24 -import { EnvironmentMachineIcon } from "./EnvironmentMachineIcon";
25 -import { ProjectFavicon } from "./ProjectFavicon";
26 -import { useAtomValue } from "@effect/atom-react";
27 -import { autoAnimate } from "@formkit/auto-animate";
28 -import React, {
29 - createContext,
30 - useEffect,
31 - useEffectEvent,
32 - memo,
33 - useContext,
34 - useRef,
35 - useState,
36 -} from "react";
37 -import { cn } from "~/lib/utils";
38 -import { useShallow } from "zustand/react/shallow";
39 -import {
40 - DndContext,
41 - type DragCancelEvent,
42 - type CollisionDetection,
43 - PointerSensor,
44 - type DragStartEvent,
45 - closestCorners,
46 - pointerWithin,
47 - useSensor,
48 - useSensors,
49 - type DragEndEvent,
50 -} from "@dnd-kit/core";
51 -import { SortableContext, useSortable, verticalListSortingStrategy } from "@dnd-kit/sortable";
52 -import { restrictToFirstScrollableAncestor, restrictToVerticalAxis } from "@dnd-kit/modifiers";
53 -import { CSS } from "@dnd-kit/utilities";
54 -import {
55 - AuthOrchestrationOperateScope,
56 - AuthPreviewOperateScope,
57 - type ContextMenuItem,
58 - type EnvironmentId,
59 - ProjectId,
60 - type ScopedThreadRef,
61 - type ResolvedKeybindingsConfig,
62 - type SidebarProjectGroupingMode,
63 - resolveEnvironmentMachineKind,
64 - ThreadId,
65 -} from "@t3tools/contracts";
66 -import {
67 - parseScopedThreadKey,
68 - scopedProjectKey,
69 - scopedThreadKey,
70 - scopeProjectRef,
71 - scopeThreadRef,
72 -} from "@t3tools/client-runtime/environment";
73 -import { safeErrorLogAttributes } from "@t3tools/client-runtime/errors";
74 -import {
75 - isAtomCommandInterrupted,
76 - settlePromise,
77 - squashAtomCommandFailure,
78 -} from "@t3tools/client-runtime/state/runtime";
79 -import { threadRuntimeCanArchive } from "@t3tools/client-runtime/state/models";
80 -import { useNavigate, useRouter } from "@tanstack/react-router";
81 -import {
82 - MAX_SIDEBAR_THREAD_PREVIEW_COUNT,
83 - MIN_SIDEBAR_THREAD_PREVIEW_COUNT,
84 - type SidebarProjectSortOrder,
85 - type SidebarThreadPreviewCount,
86 - type SidebarThreadSortOrder,
87 -} from "@t3tools/contracts/settings";
88 -import { isDesktopLocalConnectionTarget, isWslConnectionTarget } from "../connection/desktopLocal";
89 -import { useDesktopLocalBootstraps } from "../connection/useDesktopLocalBootstraps";
90 -import { isElectron } from "../env";
91 -import { useStableCallback } from "../hooks/useStableCallback";
92 -import { useTerminalFocus } from "../hooks/useTerminalFocus";
93 -import { useOpenPrLink } from "../lib/openPullRequestLink";
94 -import { releaseProjectDraftUploads } from "../lib/composerDraftUploads";
95 -import { isTerminalFocused } from "../lib/terminalFocus";
96 -import { isMacPlatform } from "../lib/utils";
97 -import { useSidebarPendingFileDropStore } from "../sidebarPendingFileDropStore";
98 -import { makeWorkspaceFileDropHandlers } from "./chat/workspaceFileDrop";
99 -import {
100 - readThreadShell,
101 - useProjects,
102 - useDelegatedUnderParent,
103 - useThreadShells,
104 - useThreadShellsForProjectRefs,
105 - waitForProjectRemoval,
106 -} from "../state/entities";
107 -import { selectThreadTerminalUiState, useTerminalUiStateStore } from "../terminalUiStateStore";
108 -import { useThreadRunningTerminalIds } from "../state/terminalSessions";
109 -import { useThreadDiscoveredPorts } from "../portDiscoveryState";
110 -import { openDiscoveredPort } from "./preview/openDiscoveredPort";
111 -import { useAtomCommand } from "../state/use-atom-command";
112 -import {
113 - ORCHESTRATION_OPERATE_DENIED_MESSAGE,
114 - useOrchestrationCommand,
115 -} from "../state/use-orchestration-command";
116 -import { previewEnvironment } from "../state/preview";
117 -import { readEnvironmentScope, useEnvironmentScope } from "../state/session";
118 -import {
119 - legacyProjectCwdPreferenceKey,
120 - resolveProjectExpanded,
121 - useUiStateStore,
122 -} from "../uiStateStore";
123 -import {
124 - resolveShortcutCommand,
125 - shortcutLabelForCommand,
126 - shouldShowThreadJumpHintsForModifiers,
127 - threadJumpCommandForIndex,
128 - threadJumpIndexFromCommand,
129 - threadTraversalDirectionFromCommand,
130 -} from "../keybindings";
131 -import { isModelPickerOpen } from "../modelPickerVisibility";
132 -import { useShortcutModifierState } from "../shortcutModifierState";
133 -import { ensureLocalApi, readLocalApi } from "../localApi";
134 -import { useComposerDraftStore } from "../composerDraftStore";
135 -import { useNewThreadHandler } from "../hooks/useHandleNewThread";
136 -import { useDesktopUpdateState } from "../state/desktopUpdate";
137 -
138 -import { useThreadActions } from "../hooks/useThreadActions";
139 -import { projectEnvironment } from "../state/projects";
140 -import { threadEnvironment, useEnvironmentThread } from "../state/threads";
141 -import { readUnloadedThreadCount } from "../state/olderSettledShelf";
142 -import { useEnvironment, useEnvironments, usePrimaryEnvironmentId } from "../state/environments";
143 -import { buildThreadRouteParams, resolveActiveThreadRouteRef } from "../threadRoutes";
144 -import { stackedThreadToast, toastManager } from "./ui/toast";
145 -import { copyThreadReference } from "../lib/copyThreadReference";
146 -import { threadChipCopyTarget } from "@t3tools/client-runtime/thread-reference";
147 -import { RelativeTime } from "./RelativeTime";
148 -import { Kbd } from "./ui/kbd";
149 -import {
150 - getArm64IntelBuildWarningDescription,
151 - getDesktopUpdateActionError,
152 - getDesktopUpdateInstallConfirmationMessage,
153 - isDesktopUpdateButtonDisabled,
154 - resolveDesktopUpdateButtonAction,
155 - shouldShowArm64IntelBuildWarning,
156 - shouldToastDesktopUpdateActionResult,
157 -} from "./desktopUpdate.logic";
158 -import { showDesktopUpdateDownloadedToast } from "./desktopUpdate.toast";
159 -import { Alert, AlertAction, AlertDescription, AlertTitle } from "./ui/alert";
160 -import { Button } from "./ui/button";
161 -import {
162 - Dialog,
163 - DialogDescription,
164 - DialogFooter,
165 - DialogHeader,
166 - DialogPanel,
167 - DialogPopup,
168 - DialogTitle,
169 -} from "./ui/dialog";
170 -import { Input } from "./ui/input";
171 -import { Menu, MenuGroup, MenuPopup, MenuRadioGroup, MenuRadioItem, MenuTrigger } from "./ui/menu";
172 -import {
173 - NumberField,
174 - NumberFieldDecrement,
175 - NumberFieldGroup,
176 - NumberFieldIncrement,
177 - NumberFieldInput,
178 -} from "./ui/number-field";
179 -import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "./ui/select";
180 -import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip";
181 -import {
182 - SidebarContent,
183 - SidebarGroup,
184 - SidebarMenu,
185 - SidebarMenuButton,
186 - SidebarMenuItem,
187 - SidebarMenuSub,
188 - SidebarMenuSubButton,
189 - SidebarMenuSubItem,
190 - useSidebar,
191 -} from "./ui/sidebar";
192 -import {
193 - getThreadKeysToDeselectAfterDelete,
194 - useThreadSelectionStore,
195 -} from "../threadSelectionStore";
196 -import { isCommandPaletteOpen, openCommandPalette } from "../commandPaletteBus";
197 -import {
198 - archiveSelectedThreadEntries,
199 - buildMultiSelectThreadContextMenuItems,
200 - deleteSelectedThreadEntries,
201 - filterSidebarV2VisibleThreads,
202 - getSidebarThreadIdsToPrewarm,
203 - resolveAdjacentThreadId,
204 - isContextMenuPointerDown,
205 - isSidebarNestedLinkClick,
206 - isTrailingDoubleClick,
207 - resolveProjectStatusIndicator,
208 - resolveThreadLastVisitedAt,
209 - resolveThreadStatusPill,
210 - orderItemsByPreferredIds,
211 - shouldClearThreadSelectionOnMouseDown,
212 - sortProjectsForSidebar,
213 - useSidebarRowSubscriptionLease,
214 - setFileDragActive,
215 - useThreadJumpHintsVisible,
216 - ThreadStatusPill,
217 -} from "./Sidebar.logic";
218 -import { sortThreads } from "@t3tools/client-runtime/state/thread-sort";
219 -import { SidebarChromeFooter, SidebarChromeHeader } from "./sidebar/SidebarChrome";
220 -import { useCopyToClipboard } from "~/hooks/useCopyToClipboard";
221 -import { useIsMobile } from "~/hooks/useMediaQuery";
222 -import { CommandDialogTrigger } from "./ui/command";
223 -import { useClientSettings, updateClientSettings } from "~/hooks/useSettings";
224 -import { primaryServerKeybindingsAtom } from "../state/server";
225 -import { appAtomRegistry } from "../rpc/atomRegistry";
226 -import { canShareWithGuestAtom } from "./chat/guestShareAvailability";
227 -import { openGuestShareDialog } from "./chat/guestShareDialogState";
228 -import {
229 - derivePhysicalProjectKey,
230 - deriveProjectGroupingOverrideKey,
231 - getProjectOrderKey,
232 - selectProjectGroupingSettings,
233 -} from "@t3tools/client-runtime/state/project-grouping";
234 -import type { SidebarThreadSummary } from "../types";
235 -import {
236 - buildPhysicalToLogicalProjectKeyMap,
237 - buildSidebarProjectSnapshots,
238 - type SidebarProjectGroupMember,
239 - type SidebarProjectSnapshot,
240 -} from "../sidebarProjectGrouping";
241 -import { PullRequestGlyph } from "~/components/pullRequest/pullRequestIcons";
242 -import { useThreadRouteTarget } from "../hooks/useThreadRouteTarget";
243 -import { type SidebarRouteReveal, useActiveRowReveal } from "./sidebar/routeReveal";
244 -const SIDEBAR_SORT_LABELS: Record<SidebarProjectSortOrder, string> = {
245 - updated_at: "Last user message",
246 - created_at: "Created at",
247 - manual: "Manual",
248 -};
249 -const SIDEBAR_THREAD_SORT_LABELS: Record<SidebarThreadSortOrder, string> = {
250 - updated_at: "Last user message",
251 - created_at: "Created at",
252 -};
253 -const SIDEBAR_LIST_ANIMATION_OPTIONS = {
254 - duration: 180,
255 - easing: "ease-out",
256 -} as const;
257 -const EMPTY_THREAD_JUMP_LABELS = new Map<string, string>();
258 -const PROJECT_GROUPING_MODE_LABELS: Record<SidebarProjectGroupingMode, string> = {
259 - repository: "Group by repository",
260 - repository_path: "Group by repository path",
261 - separate: "Keep separate",
262 -};
263 -const SIDEBAR_ICON_ACTION_BUTTON_CLASS =
264 - "inline-flex h-6 min-w-6 cursor-pointer items-center justify-center rounded-md px-0.75 text-icon-muted hover:text-foreground focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring";
265 -
266 -function SidebarThreadDetailPrewarmer({ threadRef }: { readonly threadRef: ScopedThreadRef }) {
267 - useEnvironmentThread(threadRef.environmentId, threadRef.threadId);
268 - return null;
269 -}
270 -
271 -function clampSidebarThreadPreviewCount(value: number): SidebarThreadPreviewCount {
272 - return Math.min(
273 - MAX_SIDEBAR_THREAD_PREVIEW_COUNT,
274 - Math.max(MIN_SIDEBAR_THREAD_PREVIEW_COUNT, value),
275 - ) as SidebarThreadPreviewCount;
276 -}
277 -
278 -function formatProjectMemberActionLabel(
279 - member: SidebarProjectGroupMember,
280 - groupedProjectCount: number,
281 -): string {
282 - if (groupedProjectCount <= 1) {
283 - return member.title;
284 - }
285 -
286 - return member.environmentLabel
287 - ? `${member.environmentLabel}: ${member.workspaceRoot}`
288 - : member.workspaceRoot;
289 -}
290 -
291 -function projectExpansionPreferenceKeys(project: SidebarProjectSnapshot): string[] {
292 - return [
293 - project.projectKey,
294 - ...project.memberProjects.map((member) => member.physicalProjectKey),
295 - ...project.memberProjects.map((member) => legacyProjectCwdPreferenceKey(member.workspaceRoot)),
296 - ];
297 -}
298 -
299 -function projectGroupingModeDescription(mode: SidebarProjectGroupingMode): string {
300 - switch (mode) {
301 - case "repository":
302 - return "Projects from the same repository share one sidebar row.";
303 - case "repository_path":
304 - return "Projects group only when both the repository and repo-relative path match.";
305 - case "separate":
306 - return "Every project path gets its own sidebar row.";
307 - }
308 -}
309 -
310 -function buildThreadJumpLabelMap(input: {
311 - keybindings: ResolvedKeybindingsConfig;
312 - platform: string;
313 - terminalOpen: boolean;
314 - threadJumpCommandByKey: ReadonlyMap<
315 - string,
316 - NonNullable<ReturnType<typeof threadJumpCommandForIndex>>
317 - >;
318 -}): ReadonlyMap<string, string> {
319 - if (input.threadJumpCommandByKey.size === 0) {
320 - return EMPTY_THREAD_JUMP_LABELS;
321 - }
322 -
323 - const shortcutLabelOptions = {
324 - platform: input.platform,
325 - context: {
326 - terminalFocus: false,
327 - terminalOpen: input.terminalOpen,
328 - },
329 - } as const;
330 - const mapping = new Map<string, string>();
331 - for (const [threadKey, command] of input.threadJumpCommandByKey) {
332 - const label = shortcutLabelForCommand(input.keybindings, command, shortcutLabelOptions);
333 - if (label) {
334 - mapping.set(threadKey, label);
335 - }
336 - }
337 - return mapping.size > 0 ? mapping : EMPTY_THREAD_JUMP_LABELS;
338 -}
339 -
340 -interface SidebarThreadRowProps {
341 - navigationParent?: string | undefined;
342 - thread: SidebarThreadSummary;
343 - orderedProjectThreadKeys: readonly string[];
344 - isActive: boolean;
345 - openPullRequestsInRightPanel: boolean;
346 - jumpLabel: string | null;
347 - appSettingsConfirmThreadArchive: boolean;
348 - renamingThreadKey: string | null;
349 - renamingTitle: string;
350 - setRenamingTitle: (title: string) => void;
351 - startThreadRename: (threadKey: string, title: string) => void;
352 - renamingInputRef: React.RefObject<HTMLInputElement | null>;
353 - renamingCommittedRef: React.RefObject<boolean>;
354 - confirmingArchiveThreadKey: string | null;
355 - setConfirmingArchiveThreadKey: React.Dispatch<React.SetStateAction<string | null>>;
356 - confirmArchiveButtonRefs: React.RefObject<Map<string, HTMLButtonElement>>;
357 - handleThreadClick: (
358 - event: React.MouseEvent,
359 - threadRef: ScopedThreadRef,
360 - orderedProjectThreadKeys: readonly string[],
361 - ) => void;
362 - navigateToThread: (threadRef: ScopedThreadRef) => Promise<void>;
363 - handleMultiSelectContextMenu: (position: { x: number; y: number }) => Promise<void>;
364 - handleThreadContextMenu: (
365 - threadRef: ScopedThreadRef,
366 - position: { x: number; y: number },
367 - ) => Promise<void>;
368 - clearSelection: () => void;
369 - commitRename: (
370 - threadRef: ScopedThreadRef,
371 - newTitle: string,
372 - originalTitle: string,
373 - ) => Promise<void>;
374 - cancelRename: () => void;
375 - attemptArchiveThread: (threadRef: ScopedThreadRef) => Promise<void>;
376 - openPrLink: (
377 - event: React.MouseEvent<HTMLElement>,
378 - prUrl: string,
379 - threadRef?: ScopedThreadRef,
380 - ) => boolean;
381 - onFileDropThreads: (threadRef: ScopedThreadRef, files: File[]) => void;
382 -}
383 -
384 -function checkTaskPermission(environmentId: EnvironmentId): boolean {
385 - if (readEnvironmentScope(environmentId, AuthOrchestrationOperateScope)) return true;
386 - toastManager.add(
387 - stackedThreadToast({
388 - type: "error",
389 - title: "Action unavailable",
390 - description: ORCHESTRATION_OPERATE_DENIED_MESSAGE,
391 - }),
392 - );
393 - return false;
394 -}
395 -
396 -// The active row reports itself, so a route change scrolls to it once it mounts.
397 -const RevealActiveRowContext = createContext<(row: HTMLElement | null, threadKey: string) => void>(
398 - () => {},
399 -);
400 -
401 -const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowProps) {
402 - const {
403 - orderedProjectThreadKeys,
404 - isActive,
405 - openPullRequestsInRightPanel,
406 - jumpLabel,
407 - appSettingsConfirmThreadArchive,
408 - renamingThreadKey,
409 - renamingTitle,
410 - setRenamingTitle,
411 - startThreadRename,
412 - renamingInputRef,
413 - renamingCommittedRef,
414 - confirmingArchiveThreadKey,
415 - setConfirmingArchiveThreadKey,
416 - confirmArchiveButtonRefs,
417 - handleThreadClick,
418 - navigateToThread,
419 - handleMultiSelectContextMenu,
420 - handleThreadContextMenu,
421 - clearSelection,
422 - commitRename,
423 - cancelRename,
424 - attemptArchiveThread,
425 - openPrLink,
426 - onFileDropThreads,
427 - thread,
428 - } = props;
429 - const canOperateThread = useEnvironmentScope(thread.environmentId, AuthOrchestrationOperateScope);
430 - const canOperatePreview = useEnvironmentScope(thread.environmentId, AuthPreviewOperateScope);
431 - const threadKey = scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id));
432 - const [isFileDragOver, setIsFileDragOver] = useState(false);
433 - const revealActiveRow = useContext(RevealActiveRowContext);
434 - const { leaseLiveStatus, rowRef } = useSidebarRowSubscriptionLease(isActive);
435 - const localLastVisitedAt = useUiStateStore((state) => state.threadLastVisitedAtById[threadKey]);
436 - const lastVisitedAt = resolveThreadLastVisitedAt(thread.lastVisitedAt, localLastVisitedAt);
437 - const isSelected = useThreadSelectionStore((state) => state.selectedThreadKeys.has(threadKey));
438 - const runningTerminalIds = useThreadRunningTerminalIds({
439 - environmentId: thread.environmentId,
440 - threadId: thread.id,
441 - });
442 - const isMobile = useIsMobile();
443 - const discoveredPorts = useThreadDiscoveredPorts({
444 - environmentId: thread.environmentId,
445 - threadId: thread.id,
446 - });
447 - const openPreview = useAtomCommand(previewEnvironment.open, {
448 - reportFailure: false,
449 - });
450 - const environment = useEnvironment(thread.environmentId);
451 - const primaryEnvironmentId = usePrimaryEnvironmentId();
452 - const isRemoteThread = thread.environmentId !== primaryEnvironmentId;
453 - const remoteEnvLabel = environment?.label ?? null;
454 - const remoteMachine = resolveEnvironmentMachineKind(environment?.serverConfig ?? null);
455 - const isDesktopLocalThread =
456 - environment !== null && isDesktopLocalConnectionTarget(environment.entry.target);
457 - const threadEnvironmentLabel = isRemoteThread
458 - ? (remoteEnvLabel ?? (isDesktopLocalThread ? "Local" : "Remote"))
459 - : null;
460 - const isThreadRunning = !threadRuntimeCanArchive(thread.runtime);
461 - const threadStatus = resolveThreadStatusPill({
462 - thread: {
463 - ...thread,
464 - lastVisitedAt,
465 - },
466 - });
467 - const linkedPullRequestStatus = useLinkedThreadPullRequest(
468 - thread.environmentId,
469 - thread.linkedPullRequest,
470 - leaseLiveStatus,
471 - thread.pullRequests,
472 - thread.branchPullRequest,
473 - );
474 - const pr = linkedPullRequestStatus?.pr ?? null;
475 - const supportsMultiplePullRequests = useSupportsMultiplePullRequests(thread.environmentId);
476 - // Hooks must precede this ref's plain uses for the compiler to cache it.
477 - const threadRef = scopeThreadRef(thread.environmentId, thread.id);
478 - const fileDropHandlers = makeWorkspaceFileDropHandlers({
479 - setDragActive: (active) => setFileDragActive(setIsFileDragOver, active),
480 - addFiles: (files) => {
481 - onFileDropThreads(threadRef, files);
482 - },
483 - addFolders: () => {},
484 - });
485 - const isHighlighted = isActive || isSelected;
486 - const handleOpenDiscoveredPort = (event: React.MouseEvent<HTMLButtonElement>) => {
487 - const port = discoveredPorts[0];
488 - if (!port || !canOperatePreview) return;
489 - event.preventDefault();
490 - event.stopPropagation();
491 - navigateToThread(threadRef);
492 - void (async () => {
493 - const result = await openDiscoveredPort({ threadRef, port, openPreview });
494 - if (result._tag === "Success" || isAtomCommandInterrupted(result)) {
495 - return;
496 - }
497 - const error = squashAtomCommandFailure(result);
498 - toastManager.add(
499 - stackedThreadToast({
500 - type: "error",
501 - title: "Unable to open preview",
502 - description: error instanceof Error ? error.message : "The preview could not be opened.",
503 - }),
504 - );
505 - })();
506 - };
507 - const currentLinkedPr = supportsMultiplePullRequests
508 - ? resolveThreadCurrentPullRequestLink(thread.pullRequests)
509 - : null;
510 - const prStatus = prStatusIndicator(pr, linkedPullRequestStatus?.sourceControlProvider);
511 - const isConfirmingArchive =
512 - canOperateThread && confirmingArchiveThreadKey === threadKey && !isThreadRunning;
513 - const threadMetaClassName = isConfirmingArchive
514 - ? "pointer-events-none opacity-0"
515 - : canOperateThread && !isThreadRunning
516 - ? "pointer-events-none transition-opacity duration-150 max-sm:pr-6 group-hover/menu-sub-item:opacity-0 group-focus-within/menu-sub-item:opacity-0"
517 - : "pointer-events-none";
518 - const clearConfirmingArchive = () => {
519 - setConfirmingArchiveThreadKey((current) => (current === threadKey ? null : current));
520 - };
521 - const handleMouseLeave = () => {
522 - clearConfirmingArchive();
523 - };
524 - const handleBlurCapture = (event: React.FocusEvent<HTMLLIElement>) => {
525 - const currentTarget = event.currentTarget;
526 - requestAnimationFrame(() => {
527 - if (currentTarget.contains(document.activeElement)) {
528 - return;
529 - }
530 - clearConfirmingArchive();
531 - });
532 - };
533 - const handleRowClick = (event: React.MouseEvent) => {
534 - handleThreadClick(event, threadRef, orderedProjectThreadKeys);
535 - };
536 - const handleRowDoubleClick = (event: React.MouseEvent) => {
537 - if (!readEnvironmentScope(thread.environmentId, AuthOrchestrationOperateScope)) return;
538 - if (renamingThreadKey === threadKey) return;
539 - // Mobile navigation closes the sidebar on the first tap, so rename stays in the context menu.
540 - if (isMobile) return;
541 - if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;
542 - if ((event.target as HTMLElement).closest("button, a")) return;
543 - event.preventDefault();
544 - startThreadRename(threadKey, thread.title);
545 - };
546 - const handleRowKeyDown = (event: React.KeyboardEvent) => {
547 - if (event.target !== event.currentTarget) return;
548 - if (
549 - event.key === "F2" &&
550 - renamingThreadKey !== threadKey &&
551 - readEnvironmentScope(thread.environmentId, AuthOrchestrationOperateScope)
552 - ) {
553 - event.preventDefault();
554 - startThreadRename(threadKey, thread.title);
555 - return;
556 - }
557 - if (event.key !== "Enter" && event.key !== " ") return;
558 - event.preventDefault();
559 - navigateToThread(threadRef);
560 - };
561 - const handleRowContextMenu = (event: React.MouseEvent) => {
562 - event.preventDefault();
563 - const hasSelection = useThreadSelectionStore.getState().hasSelection();
564 - if (hasSelection && isSelected) {
565 - void (async () => {
566 - const result = await settlePromise(() =>
567 - handleMultiSelectContextMenu({
568 - x: event.clientX,
569 - y: event.clientY,
570 - }),
571 - );
572 - if (result._tag === "Failure") {
573 - const error = squashAtomCommandFailure(result);
574 - toastManager.add(
575 - stackedThreadToast({
576 - type: "error",
577 - title: "Thread action failed",
578 - description: error instanceof Error ? error.message : "An error occurred.",
579 - }),
580 - );
581 - }
582 - })();
583 - return;
584 - }
585 -
586 - if (hasSelection) {
587 - clearSelection();
588 - }
589 - void (async () => {
590 - const result = await settlePromise(() =>
591 - handleThreadContextMenu(threadRef, {
592 - x: event.clientX,
593 - y: event.clientY,
594 - }),
595 - );
596 - if (result._tag === "Failure") {
597 - const error = squashAtomCommandFailure(result);
598 - toastManager.add(
599 - stackedThreadToast({
600 - type: "error",
601 - title: "Thread action failed",
602 - description: error instanceof Error ? error.message : "An error occurred.",
603 - }),
604 - );
605 - }
606 - })();
607 - };
608 - const handlePrClick = (event: React.MouseEvent<HTMLAnchorElement>) => {
609 - const url = prStatus?.url ?? currentLinkedPr?.url;
610 - if (!url) return;
611 - const openedInRightPanel = openPrLink(
612 - event,
613 - url,
614 - openPullRequestsInRightPanel ? threadRef : undefined,
615 - );
616 - if (openedInRightPanel && openPullRequestsInRightPanel && !isActive) {
617 - navigateToThread(threadRef);
618 - }
619 - };
620 - const handleRenameInputRef = (element: HTMLInputElement | null) => {
621 - if (element && renamingInputRef.current !== element) {
622 - renamingInputRef.current = element;
623 - element.focus();
624 - element.select();
625 - }
626 - };
627 - const handleRenameInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
628 - setRenamingTitle(event.target.value);
629 - };
630 - const handleRenameInputKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {
631 - event.stopPropagation();
632 - if (event.key === "Enter") {
633 - event.preventDefault();
634 - renamingCommittedRef.current = true;
635 - void commitRename(threadRef, renamingTitle, thread.title);
636 - } else if (event.key === "Escape") {
637 - event.preventDefault();
638 - renamingCommittedRef.current = true;
639 - cancelRename();
640 - }
641 - };
642 - const handleRenameInputBlur = () => {
643 - if (!renamingCommittedRef.current) {
644 - void commitRename(threadRef, renamingTitle, thread.title);
645 - }
646 - };
647 - // Stop dblclick propagation so word selection cannot restart rename and discard edits.
648 - const handleRenameInputClick = (event: React.MouseEvent<HTMLInputElement>) => {
649 - event.stopPropagation();
650 - };
651 - const handleConfirmArchiveRef = (element: HTMLButtonElement | null) => {
652 - if (element) {
653 - confirmArchiveButtonRefs.current.set(threadKey, element);
654 - } else {
655 - confirmArchiveButtonRefs.current.delete(threadKey);
656 - }
657 - };
658 - const stopPropagationOnPointerDown = (event: React.PointerEvent<HTMLButtonElement>) => {
659 - event.stopPropagation();
660 - };
661 - const handleConfirmArchiveClick = (event: React.MouseEvent<HTMLButtonElement>) => {
662 - event.preventDefault();
663 - event.stopPropagation();
664 - clearConfirmingArchive();
665 - void attemptArchiveThread(threadRef);
666 - };
667 - const handleStartArchiveConfirmation = (event: React.MouseEvent<HTMLButtonElement>) => {
668 - event.preventDefault();
669 - event.stopPropagation();
670 - if (!checkTaskPermission(thread.environmentId)) return;
671 - setConfirmingArchiveThreadKey(threadKey);
672 - requestAnimationFrame(() => {
673 - confirmArchiveButtonRefs.current.get(threadKey)?.focus();
674 - });
675 - };
676 - const handleArchiveImmediateClick = (event: React.MouseEvent<HTMLButtonElement>) => {
677 - event.preventDefault();
678 - event.stopPropagation();
679 - void attemptArchiveThread(threadRef);
680 - };
681 -
682 - return (
683 - <SidebarMenuSubItem
684 - ref={rowRef}
685 - className="w-full"
686 - data-thread-item
687 - {...fileDropHandlers}
688 - onMouseLeave={handleMouseLeave}
689 - onBlurCapture={handleBlurCapture}
690 - >
691 - <div
692 - ref={isActive ? (node) => revealActiveRow(node, threadKey) : undefined}
693 - role="treeitem"
694 - tabIndex={-1}
695 - data-sidebar-row={threadKey}
696 - data-sidebar-parent={props.navigationParent}
697 - aria-current={isActive ? "page" : undefined}
698 - data-active={isActive}
699 - data-slot="sidebar-menu-sub-button"
700 - data-sidebar="menu-sub-button"
701 - data-size="sm"
702 - data-testid={`thread-row-${thread.id}`}
703 - className={cn(
704 - "relative isolate flex h-8 w-full min-w-0 cursor-pointer select-none items-center gap-2 overflow-hidden rounded-md px-2 text-left text-xs outline-hidden focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring group-data-[collapsible=icon]:hidden [&>span:last-child]:truncate [&>svg:not([class*='size-'])]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-muted-foreground",
705 - isActive
706 - ? "bg-sidebar-row-active font-medium text-sidebar-foreground hover:bg-sidebar-row-active"
707 - : isSelected
708 - ? "bg-sidebar-row-selected text-sidebar-foreground hover:bg-sidebar-row-active"
709 - : "text-sidebar-muted-foreground/80 hover:bg-sidebar-row-hover hover:text-sidebar-foreground",
710 - isFileDragOver && "ring-1 ring-inset ring-primary/70",
711 - )}
712 - onClick={handleRowClick}
713 - onDoubleClick={handleRowDoubleClick}
714 - onKeyDown={handleRowKeyDown}
715 - onContextMenu={handleRowContextMenu}
716 - >
717 - <div className="flex min-w-0 flex-1 items-center gap-1.5 text-left">
718 - {prStatus && pr && (
719 - <Tooltip>
720 - <TooltipTrigger
721 - render={
722 - <a
723 - href={prStatus.url}
724 - target="_blank"
725 - rel="noopener noreferrer"
726 - aria-label={prStatus.tooltip}
727 - className={`inline-flex items-center justify-center ${prStatus.colorClass} cursor-pointer rounded-sm outline-hidden focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring`}
728 - onPointerDown={(event) => event.stopPropagation()}
729 - onClick={handlePrClick}
730 - >
731 - <ChangeRequestStatusIcon
732 - state={pr.state}
733 - isDraft={pr.isDraft}
734 - className="size-3"
735 - />
736 - </a>
737 - }
738 - />
739 - <TooltipPopup side="top">
740 - <PrStatusTooltipContent status={prStatus} />
741 - </TooltipPopup>
742 - </Tooltip>
743 - )}
744 - {!pr && currentLinkedPr ? (
745 - <a
746 - href={currentLinkedPr.url}
747 - target="_blank"
748 - rel="noopener noreferrer"
749 - onPointerDown={(event) => event.stopPropagation()}
750 - onClick={handlePrClick}
751 - className="text-muted-foreground"
752 - aria-label={`PR #${currentLinkedPr.number}, status pending`}
753 - >
754 - <PullRequestGlyph.pullRequest className="size-3" />
755 - </a>
756 - ) : null}
757 - {threadStatus && <ThreadStatusLabel status={threadStatus} />}
758 - {canOperateThread && renamingThreadKey === threadKey ? (
759 - <input
760 - ref={handleRenameInputRef}
761 - className="min-w-0 flex-1 truncate rounded border border-ring bg-transparent px-0.5 text-sm outline-none"
762 - value={renamingTitle}
763 - onChange={handleRenameInputChange}
764 - onKeyDown={handleRenameInputKeyDown}
765 - onBlur={handleRenameInputBlur}
766 - onClick={handleRenameInputClick}
767 - onDoubleClick={handleRenameInputClick}
768 - />
769 - ) : (
770 - <Tooltip>
771 - <TooltipTrigger
772 - render={
773 - <span
774 - className="min-w-0 flex-1 truncate text-sm"
775 - data-testid={`thread-title-${thread.id}`}
776 - >
777 - {thread.title}
778 - </span>
779 - }
780 - />
781 - <TooltipPopup side="top">{thread.title}</TooltipPopup>
782 - </Tooltip>
783 - )}
784 - </div>
785 - <div className="ml-auto flex shrink-0 items-center gap-1.5">
786 - {canOperatePreview && discoveredPorts.length > 0 && (
787 - <Tooltip>
788 - <TooltipTrigger
789 - render={
790 - <button
791 - type="button"
792 - aria-label={`Open localhost:${discoveredPorts[0]?.port ?? ""}`}
793 - className="inline-flex cursor-pointer items-center justify-center text-success-foreground outline-hidden focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring"
794 - onClick={handleOpenDiscoveredPort}
795 - />
796 - }
797 - >
798 - <Globe2Icon className="size-3" />
799 - </TooltipTrigger>
800 - <TooltipPopup side="top">
801 - Open localhost:{discoveredPorts[0]?.port}
802 - {discoveredPorts.length > 1 ? ` (+${discoveredPorts.length - 1})` : ""}
803 - </TooltipPopup>
804 - </Tooltip>
805 - )}
806 - <ThreadWorktreeIndicator thread={thread} />
807 - <ThreadTerminalStatusButton
808 - threadRef={threadRef}
809 - terminalIds={runningTerminalIds}
810 - onThreadActivate={navigateToThread}
811 - />
812 - <div
813 - className={`flex min-w-12 justify-end ${
814 - isRemoteThread ? "max-sm:min-w-24" : "max-sm:min-w-20"
815 - }`}
816 - >
817 - {isConfirmingArchive ? (
818 - <button
819 - ref={handleConfirmArchiveRef}
820 - type="button"
821 - data-thread-selection-safe
822 - data-testid={`thread-archive-confirm-${thread.id}`}
823 - aria-label={`Confirm archive ${thread.title}`}
824 - className="absolute top-1/2 right-1 inline-flex h-5 -translate-y-1/2 cursor-pointer items-center rounded-md bg-destructive/12 px-2 text-3xs font-medium text-destructive transition-colors hover:bg-destructive/18 focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-destructive/40"
825 - onPointerDown={stopPropagationOnPointerDown}
826 - onClick={handleConfirmArchiveClick}
827 - >
828 - Confirm
829 - </button>
830 - ) : canOperateThread && !isThreadRunning ? (
831 - appSettingsConfirmThreadArchive ? (
832 - <div className="pointer-events-none absolute top-1/2 right-0.5 -translate-y-1/2 opacity-0 transition-opacity duration-150 max-sm:pointer-events-auto max-sm:opacity-100 group-hover/menu-sub-item:pointer-events-auto group-hover/menu-sub-item:opacity-100 group-focus-within/menu-sub-item:pointer-events-auto group-focus-within/menu-sub-item:opacity-100">
833 - <button
834 - type="button"
835 - data-thread-selection-safe
836 - data-testid={`thread-archive-${thread.id}`}
837 - aria-label={`Archive ${thread.title}`}
838 - className={SIDEBAR_ICON_ACTION_BUTTON_CLASS}
839 - onPointerDown={stopPropagationOnPointerDown}
840 - onClick={handleStartArchiveConfirmation}
841 - >
842 - <ArchiveIcon className="size-3.5" />
843 - </button>
844 - </div>
845 - ) : (
846 - <Tooltip>
847 - <TooltipTrigger
848 - render={
849 - <div className="pointer-events-none absolute top-1/2 right-0.5 -translate-y-1/2 opacity-0 transition-opacity duration-150 max-sm:pointer-events-auto max-sm:opacity-100 group-hover/menu-sub-item:pointer-events-auto group-hover/menu-sub-item:opacity-100 group-focus-within/menu-sub-item:pointer-events-auto group-focus-within/menu-sub-item:opacity-100">
850 - <button
851 - type="button"
852 - data-thread-selection-safe
853 - data-testid={`thread-archive-${thread.id}`}
854 - aria-label={`Archive ${thread.title}`}
855 - className={SIDEBAR_ICON_ACTION_BUTTON_CLASS}
856 - onPointerDown={stopPropagationOnPointerDown}
857 - onClick={handleArchiveImmediateClick}
858 - >
859 - <ArchiveIcon className="size-3.5" />
860 - </button>
861 - </div>
862 - }
863 - />
864 - <TooltipPopup side="top">Archive</TooltipPopup>
865 - </Tooltip>
866 - )
867 - ) : null}
868 - <span className={threadMetaClassName}>
869 - <span className="inline-flex items-center gap-1">
870 - {isRemoteThread && !isDesktopLocalThread && (
871 - <Tooltip>
872 - <TooltipTrigger
873 - render={
874 - <span
875 - aria-label={threadEnvironmentLabel ?? "Remote"}
876 - className="inline-flex items-center justify-center"
877 - />
878 - }
879 - >
880 - <EnvironmentMachineIcon
881 - kind={remoteMachine}
882 - className="size-3 text-muted-foreground/40"
883 - />
884 - </TooltipTrigger>
885 - <TooltipPopup side="top">{threadEnvironmentLabel}</TooltipPopup>
886 - </Tooltip>
887 - )}
888 - {jumpLabel ? (
889 - <Tooltip>
890 - <TooltipTrigger
891 - render={
892 - <span
893 - aria-label={jumpLabel}
894 - className="inline-flex h-5 items-center rounded-full border border-border/80 bg-background/90 px-1.5 font-mono text-3xs font-medium tracking-tight text-foreground shadow-sm"
895 - />
896 - }
897 - >
898 - {jumpLabel}
899 - </TooltipTrigger>
900 - <TooltipPopup side="top">{jumpLabel}</TooltipPopup>
901 - </Tooltip>
902 - ) : (
903 - <span
904 - className={`text-3xs tabular-nums ${
905 - isHighlighted ? "text-foreground" : "text-secondary-label"
906 - }`}
907 - >
908 - <RelativeTime
909 - timestamp={thread.latestUserMessageAt ?? thread.updatedAt ?? thread.createdAt}
910 - />
911 - </span>
912 - )}
913 - </span>
914 - </span>
915 - </div>
916 - </div>
917 - </div>
918 - </SidebarMenuSubItem>
919 - );
920 -});
921 -
922 -interface SidebarProjectThreadListProps {
923 - projectKey: string;
924 - projectExpanded: boolean;
925 - hasOverflowingThreads: boolean;
926 - hiddenThreadStatus: ThreadStatusPill | null;
927 - orderedProjectThreadKeys: readonly string[];
928 - renderedThreads: readonly SidebarThreadSummary[];
929 - showEmptyThreadState: boolean;
930 - shouldShowThreadPanel: boolean;
931 - isThreadListExpanded: boolean;
932 - activeRouteThreadKey: string | null;
933 - openPullRequestsInRightPanel: boolean;
934 - threadJumpLabelByKey: ReadonlyMap<string, string>;
935 - appSettingsConfirmThreadArchive: boolean;
936 - renamingThreadKey: string | null;
937 - renamingTitle: string;
938 - setRenamingTitle: (title: string) => void;
939 - startThreadRename: (threadKey: string, title: string) => void;
940 - renamingInputRef: React.RefObject<HTMLInputElement | null>;
941 - renamingCommittedRef: React.RefObject<boolean>;
942 - confirmingArchiveThreadKey: string | null;
943 - setConfirmingArchiveThreadKey: React.Dispatch<React.SetStateAction<string | null>>;
944 - confirmArchiveButtonRefs: React.RefObject<Map<string, HTMLButtonElement>>;
945 - attachThreadListAutoAnimateRef: (node: HTMLElement | null) => void;
946 - handleThreadClick: (
947 - event: React.MouseEvent,
948 - threadRef: ScopedThreadRef,
949 - orderedProjectThreadKeys: readonly string[],
950 - ) => void;
951 - navigateToThread: (threadRef: ScopedThreadRef) => Promise<void>;
952 - onFileDropThreads: (threadRef: ScopedThreadRef, files: File[]) => void;
953 - handleMultiSelectContextMenu: (position: { x: number; y: number }) => Promise<void>;
954 - handleThreadContextMenu: (
955 - threadRef: ScopedThreadRef,
956 - position: { x: number; y: number },
957 - ) => Promise<void>;
958 - clearSelection: () => void;
959 - commitRename: (
960 - threadRef: ScopedThreadRef,
961 - newTitle: string,
962 - originalTitle: string,
963 - ) => Promise<void>;
964 - cancelRename: () => void;
965 - attemptArchiveThread: (threadRef: ScopedThreadRef) => Promise<void>;
966 - openPrLink: (
967 - event: React.MouseEvent<HTMLElement>,
968 - prUrl: string,
969 - threadRef?: ScopedThreadRef,
970 - ) => boolean;
971 - expandThreadListForProject: (projectKey: string) => void;
972 - collapseThreadListForProject: (projectKey: string) => void;
973 -}
974 -
975 -const SidebarProjectThreadList = memo(function SidebarProjectThreadList(
976 - props: SidebarProjectThreadListProps,
977 -) {
978 - const {
979 - projectKey,
980 - projectExpanded,
981 - hasOverflowingThreads,
982 - hiddenThreadStatus,
983 - orderedProjectThreadKeys,
984 - renderedThreads,
985 - showEmptyThreadState,
986 - shouldShowThreadPanel,
987 - isThreadListExpanded,
988 - activeRouteThreadKey,
989 - openPullRequestsInRightPanel,
990 - threadJumpLabelByKey,
991 - appSettingsConfirmThreadArchive,
992 - renamingThreadKey,
993 - renamingTitle,
994 - setRenamingTitle,
995 - startThreadRename,
996 - renamingInputRef,
997 - renamingCommittedRef,
998 - confirmingArchiveThreadKey,
999 - setConfirmingArchiveThreadKey,
1000 - confirmArchiveButtonRefs,
1001 - attachThreadListAutoAnimateRef,
1002 - handleThreadClick,
1003 - navigateToThread,
1004 - onFileDropThreads,
1005 - handleMultiSelectContextMenu,
1006 - handleThreadContextMenu,
1007 - clearSelection,
1008 - commitRename,
1009 - cancelRename,
1010 - attemptArchiveThread,
1011 - openPrLink,
1012 - expandThreadListForProject,
1013 - collapseThreadListForProject,
1014 - } = props;
1015 - const showMoreButtonRender = <button type="button" />;
1016 - const showLessButtonRender = <button type="button" />;
1017 -
1018 - return (
1019 - <SidebarMenuSub
1020 - role="presentation"
1021 - ref={attachThreadListAutoAnimateRef}
1022 - className="mx-0.5 my-0 w-full translate-x-0 overflow-hidden empty:hidden sm:mx-1"
1023 - >
1024 - {shouldShowThreadPanel && showEmptyThreadState ? (
1025 - <SidebarMenuSubItem className="w-full" data-thread-selection-safe>
1026 - <div
1027 - data-thread-selection-safe
1028 - className="flex h-8 w-full translate-x-0 items-center px-2 text-left text-xs text-sidebar-muted-foreground/75"
1029 - >
1030 - <span>No threads yet</span>
1031 - </div>
1032 - </SidebarMenuSubItem>
1033 - ) : null}
1034 - {shouldShowThreadPanel &&
1035 - renderedThreads.map((thread) => {
1036 - const threadKey = scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id));
1037 - return (
1038 - <SidebarThreadRow
1039 - key={threadKey}
1040 - thread={thread}
1041 - navigationParent={projectExpanded ? `project:${projectKey}` : undefined}
1042 - orderedProjectThreadKeys={orderedProjectThreadKeys}
1043 - isActive={activeRouteThreadKey === threadKey}
1044 - openPullRequestsInRightPanel={openPullRequestsInRightPanel}
1045 - jumpLabel={threadJumpLabelByKey.get(threadKey) ?? null}
1046 - appSettingsConfirmThreadArchive={appSettingsConfirmThreadArchive}
1047 - renamingThreadKey={renamingThreadKey}
1048 - renamingTitle={renamingTitle}
1049 - setRenamingTitle={setRenamingTitle}
1050 - startThreadRename={startThreadRename}
1051 - renamingInputRef={renamingInputRef}
1052 - renamingCommittedRef={renamingCommittedRef}
1053 - confirmingArchiveThreadKey={confirmingArchiveThreadKey}
1054 - setConfirmingArchiveThreadKey={setConfirmingArchiveThreadKey}
1055 - confirmArchiveButtonRefs={confirmArchiveButtonRefs}
1056 - handleThreadClick={handleThreadClick}
1057 - navigateToThread={navigateToThread}
1058 - onFileDropThreads={onFileDropThreads}
1059 - handleMultiSelectContextMenu={handleMultiSelectContextMenu}
1060 - handleThreadContextMenu={handleThreadContextMenu}
1061 - clearSelection={clearSelection}
1062 - commitRename={commitRename}
1063 - cancelRename={cancelRename}
1064 - attemptArchiveThread={attemptArchiveThread}
1065 - openPrLink={openPrLink}
1066 - />
1067 - );
1068 - })}
1069 -
1070 - {projectExpanded && hasOverflowingThreads && !isThreadListExpanded && (
1071 - <SidebarMenuSubItem className="w-full">
1072 - <SidebarMenuSubButton
1073 - render={showMoreButtonRender}
1074 - role="treeitem"
1075 - tabIndex={-1}
1076 - data-sidebar-row={`project:${projectKey}:more`}
1077 - data-sidebar-parent={`project:${projectKey}`}
1078 - data-thread-selection-safe
1079 - size="sm"
1080 - onClick={() => {
1081 - expandThreadListForProject(projectKey);
1082 - }}
1083 - >
1084 - <span className="flex min-w-0 flex-1 items-center gap-2">
1085 - {hiddenThreadStatus && <ThreadStatusLabel status={hiddenThreadStatus} compact />}
1086 - <span>Show more</span>
1087 - </span>
1088 - </SidebarMenuSubButton>
1089 - </SidebarMenuSubItem>
1090 - )}
1091 - {projectExpanded && hasOverflowingThreads && isThreadListExpanded && (
1092 - <SidebarMenuSubItem className="w-full">
1093 - <SidebarMenuSubButton
1094 - render={showLessButtonRender}
1095 - role="treeitem"
1096 - tabIndex={-1}
1097 - data-sidebar-row={`project:${projectKey}:less`}
1098 - data-sidebar-parent={`project:${projectKey}`}
1099 - data-thread-selection-safe
1100 - size="sm"
1101 - onClick={() => {
1102 - collapseThreadListForProject(projectKey);
1103 - }}
1104 - >
1105 - <span>Show less</span>
1106 - </SidebarMenuSubButton>
1107 - </SidebarMenuSubItem>
1108 - )}
1109 - </SidebarMenuSub>
1110 - );
1111 -});
1112 -
1113 -interface SidebarProjectItemProps {
1114 - project: SidebarProjectSnapshot;
1115 - isThreadListExpanded: boolean;
1116 - activeRouteThreadKey: string | null;
1117 - openPullRequestsInRightPanel: boolean;
1118 - newThreadShortcutLabel: string | null;
1119 - handleNewThread: ReturnType<typeof useNewThreadHandler>;
1120 - archiveThread: ReturnType<typeof useThreadActions>["archiveThread"];
1121 - deleteThread: ReturnType<typeof useThreadActions>["deleteThread"];
1122 - markThreadUnread: ReturnType<typeof useThreadActions>["markThreadUnread"];
1123 - threadJumpLabelByKey: ReadonlyMap<string, string>;
1124 - attachThreadListAutoAnimateRef: (node: HTMLElement | null) => void;
1125 - expandThreadListForProject: (projectKey: string) => void;
1126 - collapseThreadListForProject: (projectKey: string) => void;
1127 - dragInProgressRef: React.RefObject<boolean>;
1128 - suppressProjectClickAfterDragRef: React.RefObject<boolean>;
1129 - suppressProjectClickForContextMenuRef: React.RefObject<boolean>;
1130 - isManualProjectSorting: boolean;
1131 - dragHandleProps: SortableProjectHandleProps | null;
1132 -}
1133 -
1134 -function resolveProjectThreadStatus(
1135 - thread: SidebarThreadSummary,
1136 - lastVisitedAtByThreadKey: ReadonlyMap<string, string | undefined>,
1137 -) {
1138 - const lastVisitedAt = lastVisitedAtByThreadKey.get(
1139 - scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id)),
1140 - );
1141 - return resolveThreadStatusPill({
1142 - thread: {
1143 - ...thread,
1144 - ...(lastVisitedAt !== null && lastVisitedAt !== undefined ? { lastVisitedAt } : {}),
1145 - },
1146 - });
1147 -}
1148 -
1149 -// Separate hooks keep array caches independent of the route-dependent panel.
1150 -function useProjectThreads(project: SidebarProjectSnapshot) {
1151 - const threadSortOrder = useClientSettings<SidebarThreadSortOrder>(
1152 - (settings) => settings.sidebarThreadSortOrder,
1153 - );
1154 - const sidebarThreads = useThreadShellsForProjectRefs(project.memberProjectRefs);
1155 - const delegatedUnderParent = useDelegatedUnderParent();
1156 - const threadLastVisitedAts = useUiStateStore(
1157 - useShallow((state) =>
1158 - sidebarThreads.map(
1159 - (thread) =>
1160 - state.threadLastVisitedAtById[
1161 - scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id))
1162 - ] ?? null,
1163 - ),
1164 - ),
1165 - );
1166 - const sidebarThreadByKey = new Map(
1167 - sidebarThreads.map(
1168 - (thread) =>
1169 - [scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id)), thread] as const,
1170 - ),
1171 - );
1172 - const memberProjectByScopedKey = new Map(
1173 - project.memberProjects.map((member) => [
1174 - scopedProjectKey(scopeProjectRef(member.environmentId, member.id)),
1175 - member,
1176 - ]),
1177 - );
1178 - const memberThreadCountByPhysicalKey = new Map<string, number>(
1179 - project.memberProjects.map((member) => [member.physicalProjectKey, 0] as const),
1180 - );
1181 - for (const thread of sidebarThreads) {
1182 - const member = memberProjectByScopedKey.get(
1183 - scopedProjectKey(scopeProjectRef(thread.environmentId, thread.projectId)),
1184 - );
1185 - if (!member) {
1186 - continue;
1187 - }
1188 - memberThreadCountByPhysicalKey.set(
1189 - member.physicalProjectKey,
1190 - (memberThreadCountByPhysicalKey.get(member.physicalProjectKey) ?? 0) + 1,
1191 - );
1192 - }
1193 - const lastVisitedAtByThreadKey = new Map(
1194 - sidebarThreads.map((thread, index) => [
1195 - scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id)),
1196 - resolveThreadLastVisitedAt(thread.lastVisitedAt, threadLastVisitedAts[index] ?? undefined),
1197 - ]),
1198 - );
1199 - const visibleProjectThreads = sortThreads(
1200 - filterSidebarV2VisibleThreads(sidebarThreads, null, delegatedUnderParent),
1201 - threadSortOrder,
1202 - );
1203 - const projectStatus = resolveProjectStatusIndicator(
1204 - visibleProjectThreads.map((thread) =>
1205 - resolveProjectThreadStatus(thread, lastVisitedAtByThreadKey),
1206 - ),
1207 - );
1208 - const orderedProjectThreadKeys = visibleProjectThreads.map((thread) =>
1209 - scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id)),
1210 - );
1211 - return {
1212 - sidebarThreads,
1213 - sidebarThreadByKey,
1214 - memberProjectByScopedKey,
1215 - memberThreadCountByPhysicalKey,
1216 - lastVisitedAtByThreadKey,
1217 - visibleProjectThreads,
1218 - projectStatus,
1219 - orderedProjectThreadKeys,
1220 - };
1221 -}
1222 -
1223 -function useProjectThreadPanel(input: {
1224 - visibleProjectThreads: readonly SidebarThreadSummary[];
1225 - lastVisitedAtByThreadKey: ReadonlyMap<string, string | undefined>;
1226 - activeRouteThreadKey: string | null;
1227 - projectExpanded: boolean;
1228 - isThreadListExpanded: boolean;
1229 -}) {
1230 - const {
1231 - visibleProjectThreads,
1232 - lastVisitedAtByThreadKey,
1233 - activeRouteThreadKey,
1234 - projectExpanded,
1235 - isThreadListExpanded,
1236 - } = input;
1237 - const sidebarThreadPreviewCount = useClientSettings<SidebarThreadPreviewCount>(
1238 - (settings) => settings.sidebarThreadPreviewCount,
1239 - );
1240 - const activeThreadKey = activeRouteThreadKey ?? undefined;
1241 - const activeThread = activeThreadKey
1242 - ? (visibleProjectThreads.find(
1243 - (thread) =>
1244 - scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id)) === activeThreadKey,
1245 - ) ?? null)
1246 - : null;
1247 - const pinnedCollapsedThread = projectExpanded ? null : activeThread;
1248 - // The open thread stays listed past the preview cut, as it does in a
1249 - // collapsed project, so it alone does not overflow the preview.
1250 - const hasOverflowingThreads = visibleProjectThreads.some(
1251 - (thread, index) =>
1252 - index >= sidebarThreadPreviewCount &&
1253 - scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id)) !== activeThreadKey,
1254 - );
1255 - const previewThreads =
1256 - isThreadListExpanded || !hasOverflowingThreads
1257 - ? visibleProjectThreads
1258 - : visibleProjectThreads.slice(0, sidebarThreadPreviewCount);
1259 - const visibleThreadKeys = new Set(
1260 - [...previewThreads, ...(activeThread ? [activeThread] : [])].map((thread) =>
1261 - scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id)),
1262 - ),
1263 - );
1264 - const renderedThreads = pinnedCollapsedThread
1265 - ? [pinnedCollapsedThread]
1266 - : visibleProjectThreads.filter((thread) =>
1267 - visibleThreadKeys.has(scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id))),
1268 - );
1269 - const hiddenThreads = visibleProjectThreads.filter(
1270 - (thread) =>
1271 - !visibleThreadKeys.has(scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id))),
1272 - );
1273 - return {
1274 - hasOverflowingThreads,
1275 - hiddenThreadStatus: resolveProjectStatusIndicator(
1276 - hiddenThreads.map((thread) => resolveProjectThreadStatus(thread, lastVisitedAtByThreadKey)),
1277 - ),
1278 - renderedThreads,
1279 - showEmptyThreadState: projectExpanded && visibleProjectThreads.length === 0,
1280 - shouldShowThreadPanel: projectExpanded || pinnedCollapsedThread !== null,
1281 - };
1282 -}
1283 -
1284 -const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjectItemProps) {
1285 - const {
1286 - project,
1287 - isThreadListExpanded,
1288 - activeRouteThreadKey,
1289 - openPullRequestsInRightPanel,
1290 - newThreadShortcutLabel,
1291 - handleNewThread,
1292 - archiveThread,
1293 - deleteThread,
1294 - markThreadUnread,
1295 - threadJumpLabelByKey,
1296 - attachThreadListAutoAnimateRef,
1297 - expandThreadListForProject,
1298 - collapseThreadListForProject,
1299 - dragInProgressRef,
1300 - suppressProjectClickAfterDragRef,
1301 - suppressProjectClickForContextMenuRef,
1302 - isManualProjectSorting,
1303 - dragHandleProps,
1304 - } = props;
1305 - const environmentMachine = project.allRemoteMembersAreWsl
1306 - ? "linux"
1307 - : project.allRemoteMembersAreDesktopLocal
1308 - ? "laptop"
1309 - : "cloud";
1310 - const appSettingsConfirmThreadDelete = useClientSettings<boolean>(
1311 - (settings) => settings.confirmThreadDelete,
1312 - );
1313 - const appSettingsConfirmThreadArchive = useClientSettings<boolean>(
1314 - (settings) => settings.confirmThreadArchive,
1315 - );
1316 - const projectGroupingSettings = useClientSettings(selectProjectGroupingSettings);
1317 - const deleteProject = useOrchestrationCommand(projectEnvironment.delete, {
1318 - reportFailure: false,
1319 - });
1320 - const updateProject = useOrchestrationCommand(projectEnvironment.update, {
1321 - reportFailure: false,
1322 - });
1323 - const updateThreadMetadata = useOrchestrationCommand(threadEnvironment.updateMetadata, {
1324 - reportFailure: false,
1325 - });
1326 - const router = useRouter();
1327 - const queuePendingFileDrop = useSidebarPendingFileDropStore((s) => s.queuePendingFileDrop);
1328 - const clearPendingFileDrop = useSidebarPendingFileDropStore((s) => s.clearPendingFileDrop);
1329 - const { isMobile, setOpenMobile } = useSidebar();
1330 - const setProjectExpanded = useUiStateStore((state) => state.setProjectExpanded);
1331 - const toggleThreadSelection = useThreadSelectionStore((state) => state.toggleThread);
1332 - const rangeSelectTo = useThreadSelectionStore((state) => state.rangeSelectTo);
1333 - const clearSelection = useThreadSelectionStore((state) => state.clearSelection);
1334 - const removeFromSelection = useThreadSelectionStore((state) => state.removeFromSelection);
1335 - const setSelectionAnchor = useThreadSelectionStore((state) => state.setAnchor);
1336 - const { copyToClipboard: copyThreadIdToClipboard } = useCopyToClipboard<{
1337 - threadId: ThreadId;
1338 - }>({
1339 - onCopy: (ctx) => {
1340 - toastManager.add({
1341 - type: "success",
1342 - title: "Thread ID copied",
1343 - description: ctx.threadId,
1344 - });
1345 - },
1346 - onError: (error) => {
1347 - toastManager.add(
1348 - stackedThreadToast({
1349 - type: "error",
1350 - title: "Failed to copy thread ID",
1351 - description: error instanceof Error ? error.message : "An error occurred.",
1352 - }),
1353 - );
1354 - },
1355 - });
1356 - const { copyToClipboard: copyPathToClipboard } = useCopyToClipboard<{
1357 - path: string;
1358 - }>({
1359 - onCopy: (ctx) => {
1360 - toastManager.add({
1361 - type: "success",
1362 - title: "Path copied",
1363 - description: ctx.path,
1364 - });
1365 - },
1366 - onError: (error) => {
1367 - toastManager.add(
1368 - stackedThreadToast({
1369 - type: "error",
1370 - title: "Failed to copy path",
1371 - description: error instanceof Error ? error.message : "An error occurred.",
1372 - }),
1373 - );
1374 - },
1375 - });
1376 - const openPrLink = useOpenPrLink();
1377 - const {
1378 - sidebarThreads,
1379 - sidebarThreadByKey,
1380 - memberProjectByScopedKey,
1381 - memberThreadCountByPhysicalKey,
1382 - projectStatus,
1383 - visibleProjectThreads,
1384 - orderedProjectThreadKeys,
1385 - lastVisitedAtByThreadKey,
1386 - } = useProjectThreads(project);
1387 - const readSidebarThreadByKey = useStableCallback(() => sidebarThreadByKey);
1388 - const projectPreferenceKeys = projectExpansionPreferenceKeys(project);
1389 - const projectExpanded = useUiStateStore((state) =>
1390 - resolveProjectExpanded(state.projectExpandedById, projectPreferenceKeys),
1391 - );
1392 - const [renamingThreadKey, setRenamingThreadKey] = useState<string | null>(null);
1393 - const [renamingTitle, setRenamingTitle] = useState("");
1394 - const [confirmingArchiveThreadKey, setConfirmingArchiveThreadKey] = useState<string | null>(null);
1395 - const [projectRenameTarget, setProjectRenameTarget] = useState<SidebarProjectGroupMember | null>(
1396 - null,
1397 - );
1398 - const [projectRenameTitle, setProjectRenameTitle] = useState("");
1399 - const canRenameProject = useEnvironmentScope(
1400 - projectRenameTarget?.environmentId ?? null,
1401 - AuthOrchestrationOperateScope,
1402 - );
1403 - const [projectGroupingTarget, setProjectGroupingTarget] =
1404 - useState<SidebarProjectGroupMember | null>(null);
1405 - const [projectGroupingSelection, setProjectGroupingSelection] = useState<
1406 - SidebarProjectGroupingMode | "inherit"
1407 - >("inherit");
1408 - const renamingCommittedRef = useRef(false);
1409 - const renamingInputRef = useRef<HTMLInputElement | null>(null);
1410 - const confirmArchiveButtonRefs = useRef(new Map<string, HTMLButtonElement>());
1411 - const {
1412 - hasOverflowingThreads,
1413 - hiddenThreadStatus,
1414 - renderedThreads,
1415 - showEmptyThreadState,
1416 - shouldShowThreadPanel,
1417 - } = useProjectThreadPanel({
1418 - visibleProjectThreads,
1419 - lastVisitedAtByThreadKey,
1420 - activeRouteThreadKey,
1421 - projectExpanded,
1422 - isThreadListExpanded,
1423 - });
1424 -
1425 - const handleProjectButtonClick = (event: React.MouseEvent<HTMLButtonElement>) => {
1426 - if (suppressProjectClickForContextMenuRef.current) {
1427 - suppressProjectClickForContextMenuRef.current = false;
1428 - // A keyboard-made click (detail 0) never follows a context menu.
1429 - if (event.detail !== 0) {
1430 - event.preventDefault();
1431 - event.stopPropagation();
1432 - return;
1433 - }
1434 - }
1435 - if (dragInProgressRef.current) {
1436 - event.preventDefault();
1437 - event.stopPropagation();
1438 - return;
1439 - }
1440 - if (suppressProjectClickAfterDragRef.current) {
1441 - suppressProjectClickAfterDragRef.current = false;
1442 - event.preventDefault();
1443 - event.stopPropagation();
1444 - return;
1445 - }
1446 - if (useThreadSelectionStore.getState().hasSelection()) {
1447 - clearSelection();
1448 - }
1449 - setProjectExpanded(projectPreferenceKeys, !projectExpanded);
1450 - };
1451 -
1452 - const handleProjectButtonKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>) => {
1453 - if (event.key !== "Enter" && event.key !== " ") return;
1454 - event.preventDefault();
1455 - if (dragInProgressRef.current) {
1456 - return;
1457 - }
1458 - setProjectExpanded(projectPreferenceKeys, !projectExpanded);
1459 - };
1460 -
1461 - const handleProjectButtonPointerDownCapture = (event: React.PointerEvent<HTMLButtonElement>) => {
1462 - suppressProjectClickForContextMenuRef.current = false;
1463 - if (
1464 - isContextMenuPointerDown({
1465 - button: event.button,
1466 - ctrlKey: event.ctrlKey,
1467 - isMac: isMacPlatform(navigator.platform),
1468 - })
1469 - ) {
1470 - event.stopPropagation();
1471 - }
1472 -
1473 - suppressProjectClickAfterDragRef.current = false;
1474 - };
1475 -
1476 - const openProjectRenameDialog = (member: SidebarProjectGroupMember) => {
1477 - if (!checkTaskPermission(member.environmentId)) return;
1478 - setProjectRenameTarget(member);
1479 - setProjectRenameTitle(member.title);
1480 - };
1481 -
1482 - const openProjectGroupingDialog = (member: SidebarProjectGroupMember) => {
1483 - const overrideKey = deriveProjectGroupingOverrideKey(member);
1484 - setProjectGroupingTarget(member);
1485 - setProjectGroupingSelection(
1486 - projectGroupingSettings.sidebarProjectGroupingOverrides?.[overrideKey] ?? "inherit",
1487 - );
1488 - };
1489 -
1490 - const removeProject = async (member: SidebarProjectGroupMember) => {
1491 - const memberProjectRef = scopeProjectRef(member.environmentId, member.id);
1492 - const result = await deleteProject({
1493 - environmentId: member.environmentId,
1494 - input: {
1495 - projectId: member.id,
1496 - force: true,
1497 - },
1498 - });
1499 - if (result._tag === "Failure") {
1500 - return result;
1501 - }
1502 - await waitForProjectRemoval(memberProjectRef);
1503 - const draftStore = useComposerDraftStore.getState();
1504 - releaseProjectDraftUploads(
1505 - memberProjectRef,
1506 - sidebarThreads
1507 - .filter(
1508 - (thread) =>
1509 - thread.environmentId === member.environmentId && thread.projectId === member.id,
1510 - )
1511 - .map((thread) => scopeThreadRef(thread.environmentId, thread.id)),
1512 - );
1513 - const projectDraftThread = draftStore.getDraftThreadByProjectRef(memberProjectRef);
1514 - if (projectDraftThread) {
1515 - draftStore.clearDraftThread(projectDraftThread.draftId);
1516 - }
1517 - draftStore.clearProjectDraftThreadId(memberProjectRef);
1518 - return result;
1519 - };
1520 -
1521 - const handleRemoveProject = async (member: SidebarProjectGroupMember) => {
1522 - if (!checkTaskPermission(member.environmentId)) return;
1523 - const api = readLocalApi();
1524 - if (!api) {
1525 - return;
1526 - }
1527 -
1528 - const memberProjectRef = scopeProjectRef(member.environmentId, member.id);
1529 - const memberThreadCount =
1530 - (memberThreadCountByPhysicalKey.get(member.physicalProjectKey) ?? 0) +
1531 - readUnloadedThreadCount(
1532 - [{ environmentId: member.environmentId, id: member.id }],
1533 - sidebarThreads,
1534 - );
1535 - if (memberThreadCount > 0) {
1536 - const warningToastId = toastManager.add(
1537 - stackedThreadToast({
1538 - type: "warning",
1539 - title: "Project is not empty",
1540 - description: "Delete all threads in this project before removing it.",
1541 - actionVariant: "destructive",
1542 - actionProps: {
1543 - children: "Delete anyway",
1544 - onClick: () => {
1545 - void (async () => {
1546 - toastManager.close(warningToastId);
1547 - await new Promise<void>((resolve) => {
1548 - window.setTimeout(resolve, 180);
1549 - });
1550 - if (!checkTaskPermission(member.environmentId)) return;
1551 -
1552 - const latestProjectThreads = Array.from(readSidebarThreadByKey().values()).filter(
1553 - (thread) =>
1554 - thread.environmentId === memberProjectRef.environmentId &&
1555 - thread.projectId === memberProjectRef.projectId,
1556 - );
1557 - const threadCount =
1558 - latestProjectThreads.length +
1559 - readUnloadedThreadCount(
1560 - [{ environmentId: member.environmentId, id: member.id }],
1561 - latestProjectThreads,
1562 - );
1563 - const confirmed = await api.dialogs.confirm(
1564 - threadCount > 0
1565 - ? [
1566 - `Remove project "${member.title}" and delete its ${threadCount} thread${
1567 - threadCount === 1 ? "" : "s"
1568 - }?`,
1569 - `Path: ${member.workspaceRoot}`,
1570 - ...(member.environmentLabel
1571 - ? [`Environment: ${member.environmentLabel}`]
1572 - : []),
1573 - "This permanently clears conversation history for those threads and any archived threads.",
1574 - "This removes only this project entry.",
1575 - "This action cannot be undone.",
1576 - ].join("\n")
1577 - : [
1578 - `Remove project "${member.title}"?`,
1579 - `Path: ${member.workspaceRoot}`,
1580 - ...(member.environmentLabel
1581 - ? [`Environment: ${member.environmentLabel}`]
1582 - : []),
1583 - "This permanently clears any archived conversation history.",
1584 - "This removes only this project entry.",
1585 - ].join("\n"),
1586 - { variant: "destructive" },
1587 - );
1588 - if (!confirmed) {
1589 - return;
1590 - }
1591 -
1592 - const result = await removeProject(member);
1593 - if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {
1594 - const error = squashAtomCommandFailure(result);
1595 - toastManager.add(
1596 - stackedThreadToast({
1597 - type: "error",
1598 - title: `Failed to remove "${member.title}"`,
1599 - description:
1600 - error instanceof Error ? error.message : "Unknown error removing project.",
1601 - }),
1602 - );
1603 - }
1604 - })().catch((error) => {
1605 - const message =
1606 - error instanceof Error ? error.message : "Unknown error removing project.";
1607 - console.error("Failed to remove project", {
1608 - projectId: member.id,
1609 - environmentId: member.environmentId,
1610 - ...safeErrorLogAttributes(error),
1611 - });
1612 - toastManager.add(
1613 - stackedThreadToast({
1614 - type: "error",
1615 - title: `Failed to remove "${member.title}"`,
1616 - description: message,
1617 - }),
1618 - );
1619 - });
1620 - },
1621 - },
1622 - }),
1623 - );
1624 - return;
1625 - }
1626 -
1627 - const message = [
1628 - `Remove project "${member.title}"?`,
1629 - `Path: ${member.workspaceRoot}`,
1630 - ...(member.environmentLabel ? [`Environment: ${member.environmentLabel}`] : []),
1631 - "This permanently clears any archived conversation history.",
1632 - "This removes only this project entry.",
1633 - ].join("\n");
1634 - const confirmed = await api.dialogs.confirm(message, { variant: "destructive" });
1635 - if (!confirmed) {
1636 - return;
1637 - }
1638 -
1639 - const result = await removeProject(member);
1640 - if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {
1641 - const error = squashAtomCommandFailure(result);
1642 - const message = error instanceof Error ? error.message : "Unknown error removing project.";
1643 - console.error("Failed to remove project", {
1644 - projectId: member.id,
1645 - environmentId: member.environmentId,
1646 - ...safeErrorLogAttributes(error),
1647 - });
1648 - toastManager.add(
1649 - stackedThreadToast({
1650 - type: "error",
1651 - title: `Failed to remove "${member.title}"`,
1652 - description: message,
1653 - }),
1654 - );
1655 - }
1656 - };
1657 -
1658 - const handleProjectButtonContextMenu = (event: React.MouseEvent<HTMLButtonElement>) => {
1659 - event.preventDefault();
1660 - suppressProjectClickForContextMenuRef.current = true;
1661 - void (async () => {
1662 - const api = readLocalApi();
1663 - if (!api) return;
1664 -
1665 - const actionHandlers = new Map<string, () => Promise<void> | void>();
1666 - const makeLeaf = (
1667 - action: "rename" | "grouping" | "copy-path" | "delete",
1668 - member: SidebarProjectGroupMember,
1669 - options?: {
1670 - destructive?: boolean;
1671 - disabled?: boolean;
1672 - },
1673 - ): ContextMenuItem<string> => {
1674 - const id = `${action}:${member.physicalProjectKey}`;
1675 - actionHandlers.set(id, () => {
1676 - switch (action) {
1677 - case "rename":
1678 - openProjectRenameDialog(member);
1679 - return;
1680 - case "grouping":
1681 - openProjectGroupingDialog(member);
1682 - return;
1683 - case "copy-path":
1684 - copyPathToClipboard(member.workspaceRoot, { path: member.workspaceRoot });
1685 - return;
1686 - case "delete":
1687 - return handleRemoveProject(member);
1688 - }
1689 - });
1690 -
1691 - return {
1692 - id,
1693 - label: formatProjectMemberActionLabel(member, project.groupedProjectCount),
1694 - ...(options?.destructive ? { destructive: true } : {}),
1695 - ...(options?.disabled ? { disabled: true } : {}),
1696 - };
1697 - };
1698 -
1699 - const buildTargetedItem = (
1700 - action: "rename" | "grouping" | "copy-path" | "delete",
1701 - label: string,
1702 - options?: {
1703 - destructive?: boolean;
1704 - isDisabled?: (member: SidebarProjectGroupMember) => boolean;
1705 - },
1706 - ): ContextMenuItem<string> => {
1707 - if (project.memberProjects.length === 1) {
1708 - const singleMember = project.memberProjects[0]!;
1709 - return {
1710 - ...makeLeaf(action, singleMember, {
1711 - ...(options?.destructive ? { destructive: true } : {}),
1712 - ...(options?.isDisabled?.(singleMember) ? { disabled: true } : {}),
1713 - }),
1714 - label,
1715 - ...(action === "delete" ? { icon: "trash" } : {}),
1716 - };
1717 - }
1718 -
1719 - return {
1720 - id: `${action}:submenu`,
1721 - label,
1722 - ...(action === "delete" ? { icon: "trash" } : {}),
1723 - children: project.memberProjects.map((member) =>
1724 - makeLeaf(action, member, {
1725 - ...(options?.destructive ? { destructive: true } : {}),
1726 - ...(options?.isDisabled?.(member) ? { disabled: true } : {}),
1727 - }),
1728 - ),
1729 - };
1730 - };
1731 -
1732 - actionHandlers.set("project-settings", () => {
1733 - if (isMobile) setOpenMobile(false);
1734 - void router.navigate({
1735 - to: "/projects/$projectKey",
1736 - params: { projectKey: project.projectKey },
1737 - });
1738 - });
1739 -
1740 - const clicked = await api.contextMenu.show(
1741 - [
1742 - buildTargetedItem("rename", "Rename", {
1743 - isDisabled: (member) =>
1744 - !readEnvironmentScope(member.environmentId, AuthOrchestrationOperateScope),
1745 - }),
1746 - buildTargetedItem("grouping", "Group into..."),
1747 - buildTargetedItem("copy-path", "Copy Path"),
1748 - { id: "project-settings", label: "Project settings", icon: "settings" },
1749 - buildTargetedItem("delete", "Remove", {
1750 - destructive: true,
1751 - isDisabled: (member) =>
1752 - !readEnvironmentScope(member.environmentId, AuthOrchestrationOperateScope),
1753 - }),
1754 - ],
1755 - {
1756 - x: event.clientX,
1757 - y: event.clientY,
1758 - },
1759 - );
1760 -
1761 - if (!clicked) {
1762 - return;
1763 - }
1764 -
1765 - await actionHandlers.get(clicked)?.();
1766 - })();
1767 - };
1768 -
1769 - const navigateToThread = (threadRef: ScopedThreadRef) => {
1770 - if (useThreadSelectionStore.getState().selectedThreadKeys.size > 0) {
1771 - clearSelection();
1772 - }
1773 - setSelectionAnchor(scopedThreadKey(threadRef));
1774 - if (isMobile) {
1775 - setOpenMobile(false);
1776 - }
1777 - return router.navigate({
1778 - to: "/$environmentId/$threadId",
1779 - params: buildThreadRouteParams(threadRef),
1780 - });
1781 - };
1782 - const handleThreadFileDrop = async (threadRef: ScopedThreadRef, files: File[]) => {
1783 - const dropId = queuePendingFileDrop({ threadRef, files });
1784 - const targetPathname = router.buildLocation({
1785 - to: "/$environmentId/$threadId",
1786 - params: buildThreadRouteParams(threadRef),
1787 - }).pathname;
1788 - if (targetPathname === router.state.location.pathname) return;
1789 - try {
1790 - await navigateToThread(threadRef);
1791 - if (targetPathname !== router.state.location.pathname) {
1792 - clearPendingFileDrop(dropId);
1793 - }
1794 - } catch {
1795 - clearPendingFileDrop(dropId);
1796 - }
1797 - };
1798 -
1799 - const handleThreadClick = (
1800 - event: React.MouseEvent,
1801 - threadRef: ScopedThreadRef,
1802 - orderedProjectThreadKeys: readonly string[],
1803 - ) => {
1804 - if (isSidebarNestedLinkClick(event.target)) return;
1805 - const isMac = isMacPlatform(navigator.platform);
1806 - const isModClick = isMac ? event.metaKey : event.ctrlKey;
1807 - const isShiftClick = event.shiftKey;
1808 - const threadKey = scopedThreadKey(threadRef);
1809 - const currentSelectionCount = useThreadSelectionStore.getState().selectedThreadKeys.size;
1810 -
1811 - if (isModClick) {
1812 - event.preventDefault();
1813 - toggleThreadSelection(threadKey);
1814 - return;
1815 - }
1816 -
1817 - if (isShiftClick) {
1818 - event.preventDefault();
1819 - rangeSelectTo(threadKey, orderedProjectThreadKeys);
1820 - return;
1821 - }
1822 -
1823 - // Ignore trailing double-clicks after modifier handling so rename does not navigate or break selection.
1824 - if (isTrailingDoubleClick(event.detail)) {
1825 - return;
1826 - }
1827 -
1828 - if (currentSelectionCount > 0) {
1829 - clearSelection();
1830 - }
1831 - setSelectionAnchor(threadKey);
1832 - if (isMobile) {
1833 - setOpenMobile(false);
1834 - }
1835 - void router.navigate({
1836 - to: "/$environmentId/$threadId",
1837 - params: buildThreadRouteParams(threadRef),
1838 - });
1839 - };
1840 -
1841 - const handleMultiSelectContextMenu = async (position: { x: number; y: number }) => {
1842 - const api = readLocalApi();
1843 - if (!api) return;
1844 - const threadKeys = [...useThreadSelectionStore.getState().selectedThreadKeys];
1845 - if (threadKeys.length === 0) return;
1846 - const count = threadKeys.length;
1847 - const selectedThreadEntries = threadKeys.flatMap((threadKey) => {
1848 - const threadRef = parseScopedThreadKey(threadKey);
1849 - const thread = threadRef ? readThreadShell(threadRef) : null;
1850 - return threadRef && thread ? [{ threadKey, threadRef, thread }] : [];
1851 - });
1852 - const hasRunningThread = selectedThreadEntries.some(
1853 - ({ thread }) => !threadRuntimeCanArchive(thread.runtime),
1854 - );
1855 - const canOperateSelection = selectedThreadEntries.every(({ threadRef }) =>
1856 - readEnvironmentScope(threadRef.environmentId, AuthOrchestrationOperateScope),
1857 - );
1858 -
1859 - const clicked = await api.contextMenu.show(
1860 - buildMultiSelectThreadContextMenuItems({ count, hasRunningThread }).map((item) =>
1861 - item.id === "archive" || item.id === "delete"
1862 - ? { ...item, disabled: item.disabled || !canOperateSelection }
1863 - : item,
1864 - ),
1865 - position,
1866 - );
1867 -
1868 - if (clicked === "mark-unread") {
1869 - for (const { threadRef } of selectedThreadEntries) {
1870 - markThreadUnread(threadRef);
1871 - }
1872 - clearSelection();
1873 - return;
1874 - }
1875 -
1876 - if (
1877 - (clicked === "archive" || clicked === "delete") &&
1878 - !selectedThreadEntries.every(({ threadRef }) => checkTaskPermission(threadRef.environmentId))
1879 - ) {
1880 - return;
1881 - }
1882 -
1883 - if (clicked === "archive") {
1884 - if (appSettingsConfirmThreadArchive) {
1885 - const confirmed = await api.dialogs.confirm(
1886 - `Archive ${count} thread${count === 1 ? "" : "s"}?`,
1887 - );
1888 - if (!confirmed) return;
1889 - }
1890 - if (
1891 - !selectedThreadEntries.every(({ threadRef }) =>
1892 - checkTaskPermission(threadRef.environmentId),
1893 - )
1894 - ) {
1895 - return;
1896 - }
1897 -
1898 - const archiveOutcome = await archiveSelectedThreadEntries({
1899 - entries: selectedThreadEntries,
1900 - archive: ({ threadRef }, onArchived) => archiveThread(threadRef, { onArchived }),
1901 - });
1902 - for (const failure of archiveOutcome.followupFailures) {
1903 - if (isAtomCommandInterrupted(failure)) continue;
1904 - const error = squashAtomCommandFailure(failure);
1905 - toastManager.add(
1906 - stackedThreadToast({
1907 - type: "error",
1908 - title: "Thread archived, but navigation failed",
1909 - description: error instanceof Error ? error.message : "An error occurred.",
1910 - }),
1911 - );
1912 - }
1913 - if (archiveOutcome.mutationFailure) {
1914 - removeFromSelection(archiveOutcome.archivedThreadKeys);
1915 - if (!isAtomCommandInterrupted(archiveOutcome.mutationFailure)) {
1916 - const error = squashAtomCommandFailure(archiveOutcome.mutationFailure);
1917 - toastManager.add(
1918 - stackedThreadToast({
1919 - type: "error",
1920 - title: "Failed to archive threads",
1921 - description: error instanceof Error ? error.message : "An error occurred.",
1922 - }),
1923 - );
1924 - }
1925 - return;
1926 - }
1927 - removeFromSelection(threadKeys);
1928 - return;
1929 - }
1930 -
1931 - if (clicked !== "delete") return;
1932 -
1933 - if (appSettingsConfirmThreadDelete) {
1934 - const confirmed = await api.dialogs.confirm(
1935 - [
1936 - `Delete ${count} thread${count === 1 ? "" : "s"}?`,
1937 - "This permanently clears conversation history for these threads.",
1938 - ].join("\n"),
1939 - { variant: "destructive" },
1940 - );
1941 - if (!confirmed) return;
1942 - }
1943 - if (
1944 - !selectedThreadEntries.every(({ threadRef }) => checkTaskPermission(threadRef.environmentId))
1945 - ) {
1946 - return;
1947 - }
1948 -
1949 - const { deletedThreadKeys, firstFailure } = await deleteSelectedThreadEntries({
1950 - entries: selectedThreadEntries,
1951 - delete: ({ threadRef }, deletedThreadKeys) => deleteThread(threadRef, { deletedThreadKeys }),
1952 - });
1953 - if (firstFailure !== null) {
1954 - const firstError = squashAtomCommandFailure(firstFailure);
1955 - toastManager.add(
1956 - stackedThreadToast({
1957 - type: "error",
1958 - title: "Failed to delete threads",
1959 - description: firstError instanceof Error ? firstError.message : "An error occurred.",
1960 - }),
1961 - );
1962 - }
1963 - removeFromSelection(
1964 - getThreadKeysToDeselectAfterDelete(threadKeys, deletedThreadKeys, (threadKey) => {
1965 - const threadRef = parseScopedThreadKey(threadKey);
1966 - return threadRef !== null && readThreadShell(threadRef) !== null;
1967 - }),
1968 - );
1969 - };
1970 -
1971 - const createThreadForProjectMember = (member: SidebarProjectGroupMember) => {
1972 - if (isMobile) {
1973 - setOpenMobile(false);
1974 - }
1975 - void (async () => {
1976 - const result = await settlePromise(() =>
1977 - handleNewThread(scopeProjectRef(member.environmentId, member.id)),
1978 - );
1979 - if (result._tag === "Failure") {
1980 - const error = squashAtomCommandFailure(result);
1981 - toastManager.add(
1982 - stackedThreadToast({
1983 - type: "error",
1984 - title: "Could not create thread",
1985 - description: error instanceof Error ? error.message : "An error occurred.",
1986 - }),
1987 - );
1988 - }
1989 - })();
1990 - };
1991 -
1992 - const handleCreateThreadClick = (event: React.MouseEvent<HTMLButtonElement>) => {
1993 - event.preventDefault();
1994 - event.stopPropagation();
1995 -
1996 - if (project.memberProjects.length === 1) {
1997 - createThreadForProjectMember(project.memberProjects[0]!);
1998 - return;
1999 - }
2000 -
2001 - void (async () => {
2002 - const api = readLocalApi();
2003 - if (!api) {
2004 - return;
2005 - }
2006 - const clickedResult = await settlePromise(() =>
2007 - api.contextMenu.show(
2008 - project.memberProjects.map((member) => ({
2009 - id: member.physicalProjectKey,
2010 - label: formatProjectMemberActionLabel(member, project.groupedProjectCount),
2011 - })),
2012 - {
2013 - x: event.clientX,
2014 - y: event.clientY,
2015 - },
2016 - ),
2017 - );
2018 - if (clickedResult._tag === "Failure") {
2019 - const error = squashAtomCommandFailure(clickedResult);
2020 - toastManager.add(
2021 - stackedThreadToast({
2022 - type: "error",
2023 - title: "Could not choose environment",
2024 - description: error instanceof Error ? error.message : "An error occurred.",
2025 - }),
2026 - );
2027 - return;
2028 - }
2029 - const clicked = clickedResult.value;
2030 - if (!clicked) {
2031 - return;
2032 - }
2033 - const targetMember = project.memberProjects.find(
2034 - (member) => member.physicalProjectKey === clicked,
2035 - );
2036 - if (!targetMember) {
2037 - return;
2038 - }
2039 - createThreadForProjectMember(targetMember);
2040 - })();
2041 - };
2042 -
2043 - const attemptArchiveThread = async (threadRef: ScopedThreadRef) => {
2044 - if (!checkTaskPermission(threadRef.environmentId)) return;
2045 - const result = await archiveThread(threadRef);
2046 - if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {
2047 - const error = squashAtomCommandFailure(result);
2048 - toastManager.add(
2049 - stackedThreadToast({
2050 - type: "error",
2051 - title: "Failed to archive thread",
2052 - description: error instanceof Error ? error.message : "An error occurred.",
2053 - }),
2054 - );
2055 - }
2056 - };
2057 -
2058 - const cancelRename = () => {
2059 - setRenamingThreadKey(null);
2060 - renamingInputRef.current = null;
2061 - };
2062 -
2063 - const startThreadRename = (threadKey: string, title: string) => {
2064 - const threadRef = parseScopedThreadKey(threadKey);
2065 - if (!threadRef || !checkTaskPermission(threadRef.environmentId)) return;
2066 - setRenamingThreadKey(threadKey);
2067 - setRenamingTitle(title);
2068 - renamingCommittedRef.current = false;
2069 - };
2070 -
2071 - const commitRename = async (
2072 - threadRef: ScopedThreadRef,
2073 - newTitle: string,
2074 - originalTitle: string,
2075 - ) => {
2076 - const threadKey = scopedThreadKey(threadRef);
2077 - const finishRename = () => {
2078 - setRenamingThreadKey((current) => {
2079 - if (current !== threadKey) return current;
2080 - renamingInputRef.current = null;
2081 - return null;
2082 - });
2083 - };
2084 -
2085 - const trimmed = newTitle.trim();
2086 - if (trimmed.length === 0) {
2087 - toastManager.add({
2088 - type: "warning",
2089 - title: "Thread title cannot be empty",
2090 - });
2091 - finishRename();
2092 - return;
2093 - }
2094 - if (trimmed === originalTitle) {
2095 - finishRename();
2096 - return;
2097 - }
2098 - const result = await updateThreadMetadata({
2099 - environmentId: threadRef.environmentId,
2100 - input: {
2101 - threadId: threadRef.threadId,
2102 - title: trimmed,
2103 - },
2104 - });
2105 - if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {
2106 - const error = squashAtomCommandFailure(result);
2107 - toastManager.add(
2108 - stackedThreadToast({
2109 - type: "error",
2110 - title: "Failed to rename thread",
2111 - description: error instanceof Error ? error.message : "An error occurred.",
2112 - }),
2113 - );
2114 - }
2115 - finishRename();
2116 - };
2117 -
2118 - const closeProjectRenameDialog = () => {
2119 - setProjectRenameTarget(null);
2120 - setProjectRenameTitle("");
2121 - };
2122 -
2123 - const submitProjectRename = async () => {
2124 - if (!projectRenameTarget) {
2125 - return;
2126 - }
2127 -
2128 - const trimmed = projectRenameTitle.trim();
2129 - if (trimmed.length === 0) {
2130 - toastManager.add({
2131 - type: "warning",
2132 - title: "Project title cannot be empty",
2133 - });
2134 - return;
2135 - }
2136 -
2137 - if (trimmed === projectRenameTarget.title) {
2138 - closeProjectRenameDialog();
2139 - return;
2140 - }
2141 -
2142 - const result = await updateProject({
2143 - environmentId: projectRenameTarget.environmentId,
2144 - input: {
2145 - projectId: projectRenameTarget.id,
2146 - title: trimmed,
2147 - },
2148 - });
2149 - if (result._tag === "Success") {
2150 - closeProjectRenameDialog();
2151 - } else if (!isAtomCommandInterrupted(result)) {
2152 - const error = squashAtomCommandFailure(result);
2153 - toastManager.add(
2154 - stackedThreadToast({
2155 - type: "error",
2156 - title: "Failed to rename project",
2157 - description: error instanceof Error ? error.message : "An error occurred.",
2158 - }),
2159 - );
2160 - }
2161 - };
2162 -
2163 - const closeProjectGroupingDialog = () => {
2164 - setProjectGroupingTarget(null);
2165 - setProjectGroupingSelection("inherit");
2166 - };
2167 -
2168 - const saveProjectGroupingPreference = () => {
2169 - if (!projectGroupingTarget) {
2170 - return;
2171 - }
2172 -
2173 - const overrideKey = deriveProjectGroupingOverrideKey(projectGroupingTarget);
2174 - const nextOverrides = {
2175 - ...projectGroupingSettings.sidebarProjectGroupingOverrides,
2176 - };
2177 - if (projectGroupingSelection === "inherit") {
2178 - delete nextOverrides[overrideKey];
2179 - } else {
2180 - nextOverrides[overrideKey] = projectGroupingSelection;
2181 - }
2182 - updateClientSettings({
2183 - sidebarProjectGroupingOverrides: nextOverrides,
2184 - });
2185 - closeProjectGroupingDialog();
2186 - };
2187 -
2188 - const handleThreadContextMenu = useStableCallback(
2189 - async (threadRef: ScopedThreadRef, position: { x: number; y: number }) => {
2190 - const api = readLocalApi();
2191 - if (!api) return;
2192 - const threadKey = scopedThreadKey(threadRef);
2193 - const thread = sidebarThreadByKey.get(threadKey) ?? null;
2194 - if (!thread) return;
2195 - const threadProject = memberProjectByScopedKey.get(
2196 - scopedProjectKey(scopeProjectRef(thread.environmentId, thread.projectId)),
2197 - );
2198 - const threadWorkspacePath =
2199 - thread.worktreePath ?? threadProject?.workspaceRoot ?? project.workspaceRoot ?? null;
2200 - const canOperateThread = readEnvironmentScope(
2201 - thread.environmentId,
2202 - AuthOrchestrationOperateScope,
2203 - );
2204 - const clicked = await api.contextMenu.show(
2205 - [
2206 - ...(thread.branch
2207 - ? [{ id: "new-thread-on-branch", label: `New thread on ${thread.branch}` }]
2208 - : []),
2209 - { id: "rename", label: "Rename thread", disabled: !canOperateThread },
2210 - ...(appAtomRegistry.get(canShareWithGuestAtom(thread.environmentId))
2211 - ? [{ id: "share-guest", label: "Share with guest" }]
2212 - : []),
2213 - { id: "mark-unread", label: "Mark unread" },
2214 - { id: "copy-path", label: "Copy Path" },
2215 - { id: "copy-thread", label: "Copy Thread" },
2216 - { id: "copy-thread-id", label: "Copy Thread ID" },
2217 - { id: "project-settings", label: "Project settings" },
2218 - {
2219 - id: "delete",
2220 - label: "Delete",
2221 - destructive: true,
2222 - icon: "trash",
2223 - disabled: !canOperateThread,
2224 - },
2225 - ],
2226 - position,
2227 - );
2228 -
2229 - if (clicked === "project-settings") {
2230 - if (isMobile) setOpenMobile(false);
2231 - void router.navigate({
2232 - to: "/projects/$projectKey",
2233 - params: { projectKey: project.projectKey },
2234 - });
2235 - return;
2236 - }
2237 -
2238 - if (clicked === "new-thread-on-branch") {
2239 - const result = await settlePromise(() =>
2240 - handleNewThread(scopeProjectRef(thread.environmentId, thread.projectId), {
2241 - branch: thread.branch,
2242 - worktreePath: thread.worktreePath,
2243 - envMode: thread.worktreePath ? "worktree" : "local",
2244 - startFromOrigin: false,
2245 - }),
2246 - );
2247 - if (result._tag === "Failure") {
2248 - const error = squashAtomCommandFailure(result);
2249 - toastManager.add(
2250 - stackedThreadToast({
2251 - type: "error",
2252 - title: "Could not create thread",
2253 - description: error instanceof Error ? error.message : "An error occurred.",
2254 - }),
2255 - );
2256 - }
2257 - return;
2258 - }
2259 -
2260 - if (clicked === "rename") {
2261 - startThreadRename(threadKey, thread.title);
2262 - return;
2263 - }
2264 -
2265 - if (clicked === "share-guest") {
2266 - openGuestShareDialog(threadRef);
2267 - return;
2268 - }
2269 - if (clicked === "mark-unread") {
2270 - markThreadUnread(threadRef);
2271 - return;
2272 - }
2273 - if (clicked === "copy-path") {
2274 - if (!threadWorkspacePath) {
2275 - toastManager.add(
2276 - stackedThreadToast({
2277 - type: "error",
2278 - title: "Path unavailable",
2279 - description: "This thread does not have a workspace path to copy.",
2280 - }),
2281 - );
2282 - return;
2283 - }
2284 - copyPathToClipboard(threadWorkspacePath, { path: threadWorkspacePath });
2285 - return;
2286 - }
2287 - if (clicked === "copy-thread") {
2288 - void copyThreadReference(threadChipCopyTarget(threadRef, thread.title));
2289 - return;
2290 - }
2291 - if (clicked === "copy-thread-id") {
2292 - copyThreadIdToClipboard(thread.id, { threadId: thread.id });
2293 - return;
2294 - }
2295 - if (clicked !== "delete") return;
2296 - if (!checkTaskPermission(threadRef.environmentId)) return;
2297 - if (appSettingsConfirmThreadDelete) {
2298 - const confirmed = await api.dialogs.confirm(
2299 - [
2300 - `Delete thread "${thread.title}"?`,
2301 - "This permanently clears conversation history for this thread.",
2302 - ].join("\n"),
2303 - { variant: "destructive" },
2304 - );
2305 - if (!confirmed) {
2306 - return;
2307 - }
2308 - }
2309 - if (!checkTaskPermission(threadRef.environmentId)) return;
2310 - const result = await deleteThread(threadRef);
2311 - if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {
2312 - const error = squashAtomCommandFailure(result);
2313 - toastManager.add(
2314 - stackedThreadToast({
2315 - type: "error",
2316 - title: "Failed to delete thread",
2317 - description: error instanceof Error ? error.message : "An error occurred.",
2318 - }),
2319 - );
2320 - }
2321 - },
2322 - );
2323 -
2324 - return (
2325 - <>
2326 - <div className="group/project-header relative">
2327 - <SidebarMenuButton
2328 - ref={isManualProjectSorting ? dragHandleProps?.setActivatorNodeRef : undefined}
2329 - className={isManualProjectSorting ? "cursor-grab active:cursor-grabbing" : undefined}
2330 - {...(isManualProjectSorting && dragHandleProps ? dragHandleProps.attributes : {})}
2331 - {...(isManualProjectSorting && dragHandleProps ? dragHandleProps.listeners : {})}
2332 - role="treeitem"
2333 - tabIndex={-1}
2334 - data-sidebar-row={`project:${project.projectKey}`}
2335 - aria-expanded={projectExpanded}
2336 - aria-label={project.displayName}
2337 - onPointerDownCapture={handleProjectButtonPointerDownCapture}
2338 - onClick={handleProjectButtonClick}
2339 - onKeyDown={handleProjectButtonKeyDown}
2340 - onContextMenu={handleProjectButtonContextMenu}
2341 - >
2342 - {!projectExpanded && projectStatus ? (
2343 - <Tooltip>
2344 - <TooltipTrigger
2345 - render={
2346 - <span
2347 - aria-label={projectStatus.label}
2348 - className={`-ml-0.5 relative inline-flex size-3.5 shrink-0 items-center justify-center ${projectStatus.colorClass}`}
2349 - />
2350 - }
2351 - >
2352 - <span className="absolute inset-0 flex items-center justify-center transition-opacity duration-150 group-hover/project-header:opacity-0">
2353 - <span
2354 - className={`size-[9px] rounded-full ${projectStatus.dotClass} ${
2355 - projectStatus.pulse ? "motion-safe:animate-status-pulse" : ""
2356 - }`}
2357 - />
2358 - </span>
2359 - <ChevronRightIcon className="absolute inset-0 m-auto size-3.5 text-icon-muted opacity-0 transition-opacity duration-150 group-hover/project-header:opacity-100" />
2360 - </TooltipTrigger>
2361 - <TooltipPopup side="top">{projectStatus.label}</TooltipPopup>
2362 - </Tooltip>
2363 - ) : (
2364 - <ChevronRightIcon
2365 - className={`-ml-0.5 size-3.5 shrink-0 text-muted-foreground/70 transition-transform duration-150 ${
2366 - projectExpanded ? "rotate-90" : ""
2367 - }`}
2368 - />
2369 - )}
2370 - <span className="flex shrink-0">
2371 - <ProjectFavicon project={project} />
2372 - </span>
2373 - <span className="flex min-w-0 flex-1 items-center gap-2">
2374 - <span className="truncate text-sm font-medium text-sidebar-foreground/90">
2375 - {project.displayName}
2376 - </span>
2377 - {project.groupedProjectCount > 1 ? (
2378 - <span className="shrink-0 text-secondary-label text-3xs">
2379 - {project.groupedProjectCount} projects
2380 - </span>
2381 - ) : null}
2382 - </span>
2383 - <span aria-hidden className="w-4 shrink-0 max-sm:w-10" />
2384 - </SidebarMenuButton>
2385 -
2386 - {project.environmentPresence === "remote-only" && (
2387 - <Tooltip>
2388 - <TooltipTrigger
2389 - render={
2390 - <span
2391 - aria-label={
2392 - project.allRemoteMembersAreDesktopLocal
2393 - ? "Local sandbox project"
2394 - : "Remote project"
2395 - }
2396 - className="pointer-events-none absolute top-1/2 right-1.5 inline-flex size-5 -translate-y-1/2 items-center justify-center rounded-md text-icon-muted transition-opacity duration-150 max-sm:right-7 group-hover/project-header:opacity-0 group-focus-within/project-header:opacity-0 max-sm:group-hover/project-header:opacity-100 max-sm:group-focus-within/project-header:opacity-100"
2397 - />
2398 - }
2399 - >
2400 - <EnvironmentMachineIcon kind={environmentMachine} className="size-3" />
2401 - </TooltipTrigger>
2402 - <TooltipPopup side="top">
2403 - {project.allRemoteMembersAreDesktopLocal
2404 - ? `Local sandbox: ${project.remoteEnvironmentLabels.join(", ")}`
2405 - : `Remote environment: ${project.remoteEnvironmentLabels.join(", ")}`}
2406 - </TooltipPopup>
2407 - </Tooltip>
2408 - )}
2409 - <Tooltip>
2410 - <TooltipTrigger
2411 - render={
2412 - <div className="pointer-events-none absolute top-[calc(50%+1px)] right-0.5 -translate-y-1/2 opacity-0 transition-opacity duration-150 max-sm:pointer-events-auto max-sm:opacity-100 group-hover/project-header:pointer-events-auto group-hover/project-header:opacity-100 group-focus-within/project-header:pointer-events-auto group-focus-within/project-header:opacity-100">
2413 - <button
2414 - type="button"
2415 - aria-label={`Create new thread in ${project.displayName}`}
2416 - data-sidebar-action-for={`project:${project.projectKey}`}
2417 - data-testid="new-thread-button"
2418 - className={SIDEBAR_ICON_ACTION_BUTTON_CLASS}
2419 - onClick={handleCreateThreadClick}
2420 - >
2421 - <SquarePenIcon className="size-3.5" />
2422 - </button>
2423 - </div>
2424 - }
2425 - />
2426 - <TooltipPopup side="top">
2427 - {newThreadShortcutLabel ? `New thread (${newThreadShortcutLabel})` : "New thread"}
2428 - </TooltipPopup>
2429 - </Tooltip>
2430 - </div>
2431 -
2432 - <SidebarProjectThreadList
2433 - projectKey={project.projectKey}
2434 - projectExpanded={projectExpanded}
2435 - hasOverflowingThreads={hasOverflowingThreads}
2436 - hiddenThreadStatus={hiddenThreadStatus}
2437 - orderedProjectThreadKeys={orderedProjectThreadKeys}
2438 - renderedThreads={renderedThreads}
2439 - showEmptyThreadState={showEmptyThreadState}
2440 - shouldShowThreadPanel={shouldShowThreadPanel}
2441 - isThreadListExpanded={isThreadListExpanded}
2442 - activeRouteThreadKey={activeRouteThreadKey}
2443 - openPullRequestsInRightPanel={openPullRequestsInRightPanel}
2444 - threadJumpLabelByKey={threadJumpLabelByKey}
2445 - appSettingsConfirmThreadArchive={appSettingsConfirmThreadArchive}
2446 - renamingThreadKey={renamingThreadKey}
2447 - renamingTitle={renamingTitle}
2448 - setRenamingTitle={setRenamingTitle}
2449 - startThreadRename={startThreadRename}
2450 - renamingInputRef={renamingInputRef}
2451 - renamingCommittedRef={renamingCommittedRef}
2452 - confirmingArchiveThreadKey={confirmingArchiveThreadKey}
2453 - setConfirmingArchiveThreadKey={setConfirmingArchiveThreadKey}
2454 - confirmArchiveButtonRefs={confirmArchiveButtonRefs}
2455 - attachThreadListAutoAnimateRef={attachThreadListAutoAnimateRef}
2456 - handleThreadClick={handleThreadClick}
2457 - navigateToThread={navigateToThread}
2458 - onFileDropThreads={handleThreadFileDrop}
2459 - handleMultiSelectContextMenu={handleMultiSelectContextMenu}
2460 - handleThreadContextMenu={handleThreadContextMenu}
2461 - clearSelection={clearSelection}
2462 - commitRename={commitRename}
2463 - cancelRename={cancelRename}
2464 - attemptArchiveThread={attemptArchiveThread}
2465 - openPrLink={openPrLink}
2466 - expandThreadListForProject={expandThreadListForProject}
2467 - collapseThreadListForProject={collapseThreadListForProject}
2468 - />
2469 -
2470 - <Dialog
2471 - open={projectRenameTarget !== null}
2472 - onOpenChange={(open) => {
2473 - if (!open) {
2474 - closeProjectRenameDialog();
2475 - }
2476 - }}
2477 - >
2478 - <DialogPopup className="max-w-lg">
2479 - <DialogHeader>
2480 - <DialogTitle>Rename project</DialogTitle>
2481 - <DialogDescription>
2482 - {projectRenameTarget
2483 - ? `Update the title for ${projectRenameTarget.workspaceRoot}.`
2484 - : "Update the project title."}
2485 - </DialogDescription>
2486 - </DialogHeader>
2487 - <DialogPanel>
2488 - <div className="grid gap-1.5">
2489 - <span className="text-xs font-medium text-foreground">Project title</span>
2490 - <Input
2491 - aria-label="Project title"
2492 - disabled={!canRenameProject}
2493 - value={projectRenameTitle}
2494 - onChange={(event) => setProjectRenameTitle(event.target.value)}
2495 - onKeyDown={(event) => {
2496 - if (event.key === "Enter") {
2497 - event.preventDefault();
2498 - void submitProjectRename();
2499 - }
2500 - }}
2501 - />
2502 - </div>
2503 - {projectRenameTarget?.environmentLabel ? (
2504 - <p className="text-xs text-muted-foreground">
2505 - Environment: {projectRenameTarget.environmentLabel}
2506 - </p>
2507 - ) : null}
2508 - {!canRenameProject ? (
2509 - <p className="text-xs text-muted-foreground">
2510 - This connection cannot change projects.
2511 - </p>
2512 - ) : null}
2513 - </DialogPanel>
2514 - <DialogFooter>
2515 - <Button variant="outline" onClick={closeProjectRenameDialog}>
2516 - Cancel
2517 - </Button>
2518 - <Button disabled={!canRenameProject} onClick={() => void submitProjectRename()}>
2519 - Save
2520 - </Button>
2521 - </DialogFooter>
2522 - </DialogPopup>
2523 - </Dialog>
2524 -
2525 - <Dialog
2526 - open={projectGroupingTarget !== null}
2527 - onOpenChange={(open) => {
2528 - if (!open) {
2529 - closeProjectGroupingDialog();
2530 - }
2531 - }}
2532 - >
2533 - <DialogPopup className="max-w-lg">
2534 - <DialogHeader>
2535 - <DialogTitle>Project grouping</DialogTitle>
2536 - <DialogDescription>
2537 - {projectGroupingTarget
2538 - ? `Choose how ${projectGroupingTarget.workspaceRoot} should be grouped in the sidebar.`
2539 - : "Choose how this project should be grouped in the sidebar."}
2540 - </DialogDescription>
2541 - </DialogHeader>
2542 - <DialogPanel>
2543 - <div className="grid gap-1.5">
2544 - <span className="text-xs font-medium text-foreground">Grouping rule</span>
2545 - <Select
2546 - value={projectGroupingSelection}
2547 - onValueChange={(value) => {
2548 - if (
2549 - value === "inherit" ||
2550 - value === "repository" ||
2551 - value === "repository_path" ||
2552 - value === "separate"
2553 - ) {
2554 - setProjectGroupingSelection(value);
2555 - }
2556 - }}
2557 - >
2558 - <SelectTrigger className="w-full" aria-label="Project grouping rule">
2559 - <SelectValue>
2560 - {projectGroupingSelection === "inherit"
2561 - ? `Use global default (${PROJECT_GROUPING_MODE_LABELS[projectGroupingSettings.sidebarProjectGroupingMode]})`
2562 - : PROJECT_GROUPING_MODE_LABELS[projectGroupingSelection]}
2563 - </SelectValue>
2564 - </SelectTrigger>
2565 - <SelectPopup align="end" alignItemWithTrigger={false}>
2566 - <SelectItem hideIndicator value="inherit">
2567 - Use global default
2568 - </SelectItem>
2569 - <SelectItem hideIndicator value="repository">
2570 - {PROJECT_GROUPING_MODE_LABELS.repository}
2571 - </SelectItem>
2572 - <SelectItem hideIndicator value="repository_path">
2573 - {PROJECT_GROUPING_MODE_LABELS.repository_path}
2574 - </SelectItem>
2575 - <SelectItem hideIndicator value="separate">
2576 - {PROJECT_GROUPING_MODE_LABELS.separate}
2577 - </SelectItem>
2578 - </SelectPopup>
2579 - </Select>
2580 - </div>
2581 - <p className="text-xs text-muted-foreground">
2582 - {projectGroupingSelection === "inherit"
2583 - ? projectGroupingModeDescription(projectGroupingSettings.sidebarProjectGroupingMode)
2584 - : projectGroupingModeDescription(projectGroupingSelection)}
2585 - </p>
2586 - </DialogPanel>
2587 - <DialogFooter>
2588 - <Button variant="outline" onClick={closeProjectGroupingDialog}>
2589 - Cancel
2590 - </Button>
2591 - <Button onClick={saveProjectGroupingPreference}>Save</Button>
2592 - </DialogFooter>
2593 - </DialogPopup>
2594 - </Dialog>
2595 - </>
2596 - );
2597 -});
2598 -
2599 -const SidebarProjectListRow = memo(function SidebarProjectListRow(props: SidebarProjectItemProps) {
2600 - return (
2601 - <SidebarMenuItem>
2602 - <SidebarProjectItem {...props} />
2603 - </SidebarMenuItem>
2604 - );
2605 -});
2606 -
2607 -function LocalSecondaryStatus() {
2608 - const { environments } = useEnvironments();
2609 - // Poll desktop-local backends because the bridge has no change event.
2610 - const secondaries = useDesktopLocalBootstraps();
2611 -
2612 - const localEnvByUrl = (() => {
2613 - const map = new Map<string, { phase: string; error: string | null }>();
2614 - for (const environment of environments) {
2615 - if (
2616 - isDesktopLocalConnectionTarget(environment.entry.target) &&
2617 - environment.displayUrl !== null
2618 - ) {
2619 - map.set(environment.displayUrl, {
2620 - phase: environment.connection.phase,
2621 - error: environment.connection.error,
2622 - });
2623 - }
2624 - }
2625 - return map;
2626 - })();
2627 -
2628 - const connecting: string[] = [];
2629 - const failed: Array<{ label: string; error: string | null }> = [];
2630 - for (const bootstrap of secondaries) {
2631 - const env =
2632 - bootstrap.httpBaseUrl !== null ? localEnvByUrl.get(bootstrap.httpBaseUrl) : undefined;
2633 - if (env?.phase === "connected") {
2634 - continue;
2635 - }
2636 - if (env?.phase === "error") {
2637 - failed.push({ label: bootstrap.label, error: env.error });
2638 - continue;
2639 - }
2640 - connecting.push(bootstrap.label);
2641 - }
2642 -
2643 - if (connecting.length === 0 && failed.length === 0) {
2644 - return null;
2645 - }
2646 -
2647 - return (
2648 - <SidebarGroup>
2649 - {connecting.length > 0 ? (
2650 - <Alert variant="sidebar">
2651 - <Spinner />
2652 - <AlertTitle>Connecting {connecting.join(", ")}</AlertTitle>
2653 - </Alert>
2654 - ) : null}
2655 - {failed.length > 0 ? (
2656 - <Alert variant="warning">
2657 - <TriangleAlertIcon />
2658 - <AlertTitle>Couldn't connect {failed.map((entry) => entry.label).join(", ")}</AlertTitle>
2659 - <AlertDescription>
2660 - {failed
2661 - .map((entry) => entry.error)
2662 - .filter(Boolean)
2663 - .join("; ") || "The backend didn't respond."}
2664 - </AlertDescription>
2665 - </Alert>
2666 - ) : null}
2667 - </SidebarGroup>
2668 - );
2669 -}
2670 -
2671 -type SortableProjectHandleProps = Pick<
2672 - ReturnType<typeof useSortable>,
2673 - "attributes" | "listeners" | "setActivatorNodeRef"
2674 ->;
2675 -
2676 -function ProjectSortMenu({
2677 - projectSortOrder,
2678 - threadSortOrder,
2679 - threadPreviewCount,
2680 - onProjectSortOrderChange,
2681 - onThreadSortOrderChange,
2682 - onThreadPreviewCountChange,
2683 -}: {
2684 - projectSortOrder: SidebarProjectSortOrder;
2685 - threadSortOrder: SidebarThreadSortOrder;
2686 - threadPreviewCount: SidebarThreadPreviewCount;
2687 - onProjectSortOrderChange: (sortOrder: SidebarProjectSortOrder) => void;
2688 - onThreadSortOrderChange: (sortOrder: SidebarThreadSortOrder) => void;
2689 - onThreadPreviewCountChange: (count: SidebarThreadPreviewCount) => void;
2690 -}) {
2691 - const handleThreadPreviewCountChange = (nextValue: number | null) => {
2692 - if (nextValue === null) {
2693 - return;
2694 - }
2695 -
2696 - const clampedValue = clampSidebarThreadPreviewCount(nextValue);
2697 - if (clampedValue !== threadPreviewCount) {
2698 - onThreadPreviewCountChange(clampedValue);
2699 - }
2700 - };
2701 -
2702 - return (
2703 - <Menu>
2704 - <Tooltip>
2705 - <TooltipTrigger
2706 - render={
2707 - <MenuTrigger
2708 - render={<Button size="icon-xs" variant="ghost-muted" aria-label="Sidebar options" />}
2709 - />
2710 - }
2711 - >
2712 - <ArrowUpDownIcon className="size-3.5" />
2713 - </TooltipTrigger>
2714 - <TooltipPopup side="right">Sidebar options</TooltipPopup>
2715 - </Tooltip>
2716 - <MenuPopup align="end" side="bottom">
2717 - <MenuGroup>
2718 - <div className="px-2 py-1 sm:text-xs font-medium text-muted-foreground">
2719 - Sort projects
2720 - </div>
2721 - <MenuRadioGroup
2722 - value={projectSortOrder}
2723 - onValueChange={(value) => {
2724 - onProjectSortOrderChange(value as SidebarProjectSortOrder);
2725 - }}
2726 - >
2727 - {(Object.entries(SIDEBAR_SORT_LABELS) as Array<[SidebarProjectSortOrder, string]>).map(
2728 - ([value, label]) => (
2729 - <MenuRadioItem key={value} value={value}>
2730 - {label}
2731 - </MenuRadioItem>
2732 - ),
2733 - )}
2734 - </MenuRadioGroup>
2735 - </MenuGroup>
2736 - <MenuGroup>
2737 - <div className="px-2 pt-2 pb-1 sm:text-xs font-medium text-muted-foreground">
2738 - Sort threads
2739 - </div>
2740 - <MenuRadioGroup
2741 - value={threadSortOrder}
2742 - onValueChange={(value) => {
2743 - onThreadSortOrderChange(value as SidebarThreadSortOrder);
2744 - }}
2745 - >
2746 - {(
2747 - Object.entries(SIDEBAR_THREAD_SORT_LABELS) as Array<[SidebarThreadSortOrder, string]>
2748 - ).map(([value, label]) => (
2749 - <MenuRadioItem key={value} value={value}>
2750 - {label}
2751 - </MenuRadioItem>
2752 - ))}
2753 - </MenuRadioGroup>
2754 - </MenuGroup>
2755 - <MenuGroup>
2756 - <div className="px-2 pt-2 pb-1 text-muted-foreground sm:text-xs font-medium">
2757 - Visible threads
2758 - </div>
2759 - <div className="px-2 py-1">
2760 - <NumberField
2761 - aria-label="Visible thread count"
2762 - className="w-28"
2763 - max={MAX_SIDEBAR_THREAD_PREVIEW_COUNT}
2764 - min={MIN_SIDEBAR_THREAD_PREVIEW_COUNT}
2765 - onValueChange={handleThreadPreviewCountChange}
2766 - size="sm"
2767 - step={1}
2768 - value={threadPreviewCount}
2769 - >
2770 - <NumberFieldGroup>
2771 - <NumberFieldDecrement
2772 - aria-label="Decrease visible thread count"
2773 - className="[&_svg]:size-3.5"
2774 - />
2775 - <NumberFieldInput
2776 - aria-label="Visible thread count"
2777 - inputMode="numeric"
2778 - onKeyDownCapture={(event) => {
2779 - event.stopPropagation();
2780 - }}
2781 - />
2782 - <NumberFieldIncrement
2783 - aria-label="Increase visible thread count"
2784 - className="[&_svg]:size-3.5"
2785 - />
2786 - </NumberFieldGroup>
2787 - </NumberField>
2788 - </div>
2789 - </MenuGroup>
2790 - </MenuPopup>
2791 - </Menu>
2792 - );
2793 -}
2794 -
2795 -function SortableProjectItem({
2796 - projectId,
2797 - disabled = false,
2798 - children,
2799 -}: {
2800 - projectId: string;
2801 - disabled?: boolean;
2802 - children: (handleProps: SortableProjectHandleProps) => React.ReactNode;
2803 -}) {
2804 - const {
2805 - attributes,
2806 - listeners,
2807 - setActivatorNodeRef,
2808 - setNodeRef,
2809 - transform,
2810 - transition,
2811 - isDragging,
2812 - isOver,
2813 - } = useSortable({ id: projectId, disabled });
2814 - return (
2815 - <li
2816 - ref={setNodeRef}
2817 - style={{
2818 - transform: CSS.Translate.toString(transform),
2819 - transition,
2820 - }}
2821 - className={`group/menu-item relative rounded-md ${
2822 - isDragging ? "z-20 opacity-80" : ""
2823 - } ${isOver && !isDragging ? "ring-1 ring-inset ring-primary/40" : ""}`}
2824 - data-sidebar="menu-item"
2825 - data-slot="sidebar-menu-item"
2826 - >
2827 - {children({ attributes, listeners, setActivatorNodeRef })}
2828 - </li>
2829 - );
2830 -}
2831 -
2832 -interface SidebarProjectsContentProps {
2833 - showArm64IntelBuildWarning: boolean;
2834 - arm64IntelBuildWarningDescription: string | null;
2835 - desktopUpdateButtonAction: "download" | "install" | "none";
2836 - desktopUpdateButtonDisabled: boolean;
2837 - desktopUpdateActionPending: boolean;
2838 - handleDesktopUpdateButtonClick: () => void;
2839 - projectSortOrder: SidebarProjectSortOrder;
2840 - threadSortOrder: SidebarThreadSortOrder;
2841 - threadPreviewCount: SidebarThreadPreviewCount;
2842 - openAddProject: () => void;
2843 - isManualProjectSorting: boolean;
2844 - projectDnDSensors: ReturnType<typeof useSensors>;
2845 - projectCollisionDetection: CollisionDetection;
2846 - handleProjectDragStart: (event: DragStartEvent) => void;
2847 - handleProjectDragEnd: (event: DragEndEvent) => void;
2848 - handleProjectDragCancel: (event: DragCancelEvent) => void;
2849 - handleNewThread: ReturnType<typeof useNewThreadHandler>;
2850 - archiveThread: ReturnType<typeof useThreadActions>["archiveThread"];
2851 - deleteThread: ReturnType<typeof useThreadActions>["deleteThread"];
2852 - markThreadUnread: ReturnType<typeof useThreadActions>["markThreadUnread"];
2853 - sortedProjects: readonly SidebarProjectSnapshot[];
2854 - sortedProjectKeys: string[];
2855 - expandedThreadListsByProject: ReadonlySet<string>;
2856 - activeRouteProjectKey: string | null;
2857 - routeThreadKey: string | null;
2858 - openPullRequestsInRightPanel: boolean;
2859 - newThreadShortcutLabel: string | null;
2860 - commandPaletteShortcutLabel: string | null;
2861 - threadJumpLabelByKey: ReadonlyMap<string, string>;
2862 - attachThreadListAutoAnimateRef: (node: HTMLElement | null) => void;
2863 - expandThreadListForProject: (projectKey: string) => void;
2864 - collapseThreadListForProject: (projectKey: string) => void;
2865 - dragInProgressRef: React.RefObject<boolean>;
2866 - suppressProjectClickAfterDragRef: React.RefObject<boolean>;
2867 - suppressProjectClickForContextMenuRef: React.RefObject<boolean>;
2868 - attachProjectListAutoAnimateRef: (node: HTMLElement | null) => void;
2869 - projectsLength: number;
2870 -}
2871 -
2872 -const SidebarProjectsContent = memo(function SidebarProjectsContent(
2873 - props: SidebarProjectsContentProps,
2874 -) {
2875 - const {
2876 - showArm64IntelBuildWarning,
2877 - arm64IntelBuildWarningDescription,
2878 - desktopUpdateButtonAction,
2879 - desktopUpdateButtonDisabled,
2880 - desktopUpdateActionPending,
2881 - handleDesktopUpdateButtonClick,
2882 - projectSortOrder,
2883 - threadSortOrder,
2884 - threadPreviewCount,
2885 - openAddProject,
2886 - isManualProjectSorting,
2887 - projectDnDSensors,
2888 - projectCollisionDetection,
2889 - handleProjectDragStart,
2890 - handleProjectDragEnd,
2891 - handleProjectDragCancel,
2892 - handleNewThread,
2893 - archiveThread,
2894 - deleteThread,
2895 - markThreadUnread,
2896 - sortedProjects,
2897 - sortedProjectKeys,
2898 - expandedThreadListsByProject,
2899 - activeRouteProjectKey,
2900 - routeThreadKey,
2901 - openPullRequestsInRightPanel,
2902 - newThreadShortcutLabel,
2903 - commandPaletteShortcutLabel,
2904 - threadJumpLabelByKey,
2905 - attachThreadListAutoAnimateRef,
2906 - expandThreadListForProject,
2907 - collapseThreadListForProject,
2908 - dragInProgressRef,
2909 - suppressProjectClickAfterDragRef,
2910 - suppressProjectClickForContextMenuRef,
2911 - attachProjectListAutoAnimateRef,
2912 - projectsLength,
2913 - } = props;
2914 -
2915 - const attachTreeRef = (node: HTMLUListElement | null) => {
2916 - attachProjectListAutoAnimateRef(node);
2917 - const dispose = attachSidebarTree(node);
2918 - return () => {
2919 - dispose?.();
2920 - attachProjectListAutoAnimateRef(null);
2921 - };
2922 - };
2923 - const handleProjectSortOrderChange = (sortOrder: SidebarProjectSortOrder) => {
2924 - updateClientSettings({ sidebarProjectSortOrder: sortOrder });
2925 - };
2926 - const handleThreadSortOrderChange = (sortOrder: SidebarThreadSortOrder) => {
2927 - updateClientSettings({ sidebarThreadSortOrder: sortOrder });
2928 - };
2929 - const handleThreadPreviewCountChange = (count: SidebarThreadPreviewCount) => {
2930 - updateClientSettings({ sidebarThreadPreviewCount: count });
2931 - };
2932 -
2933 - return (
2934 - <SidebarContent
2935 - fixedHeader={
2936 - <SidebarGroup className="z-[1]">
2937 - <SidebarMenu>
2938 - <SidebarMenuItem>
2939 - <CommandDialogTrigger
2940 - render={<SidebarMenuButton data-testid="command-palette-trigger" />}
2941 - >
2942 - <SearchIcon />
2943 - <span className="flex-1 truncate">Search</span>
2944 - {commandPaletteShortcutLabel ? <Kbd>{commandPaletteShortcutLabel}</Kbd> : null}
2945 - </CommandDialogTrigger>
2946 - </SidebarMenuItem>
2947 - </SidebarMenu>
2948 - </SidebarGroup>
2949 - }
2950 - >
2951 - {showArm64IntelBuildWarning && arm64IntelBuildWarningDescription ? (
2952 - <SidebarGroup>
2953 - <Alert variant="warning">
2954 - <TriangleAlertIcon />
2955 - <AlertTitle>Intel build on Apple Silicon</AlertTitle>
2956 - <AlertDescription>{arm64IntelBuildWarningDescription}</AlertDescription>
2957 - {desktopUpdateButtonAction !== "none" ? (
2958 - <AlertAction>
2959 - <Button
2960 - size="xs"
2961 - variant="outline"
2962 - disabled={desktopUpdateButtonDisabled || desktopUpdateActionPending}
2963 - onClick={handleDesktopUpdateButtonClick}
2964 - >
2965 - {desktopUpdateButtonAction === "download"
2966 - ? "Download ARM build"
2967 - : "Install ARM build"}
2968 - </Button>
2969 - </AlertAction>
2970 - ) : null}
2971 - </Alert>
2972 - </SidebarGroup>
2973 - ) : null}
2974 - <LocalSecondaryStatus />
2975 - <SidebarGroup>
2976 - <div className="mb-1 flex items-center justify-between pl-2 pr-1.5">
2977 - <span className="text-xs font-medium text-sidebar-muted-foreground/80">Projects</span>
2978 - <div className="flex items-center gap-1">
2979 - <ProjectSortMenu
2980 - projectSortOrder={projectSortOrder}
2981 - threadSortOrder={threadSortOrder}
2982 - threadPreviewCount={threadPreviewCount}
2983 - onProjectSortOrderChange={handleProjectSortOrderChange}
2984 - onThreadSortOrderChange={handleThreadSortOrderChange}
2985 - onThreadPreviewCountChange={handleThreadPreviewCountChange}
2986 - />
2987 - <Tooltip>
2988 - <TooltipTrigger
2989 - render={
2990 - <Button
2991 - size="icon-xs"
2992 - variant="ghost-muted"
2993 - aria-label="Add project"
2994 - data-testid="sidebar-add-project-trigger"
2995 - onClick={openAddProject}
2996 - />
2997 - }
2998 - >
2999 - <FolderPlusIcon className="size-3.5" />
3000 - </TooltipTrigger>
3001 - <TooltipPopup side="right">Add project</TooltipPopup>
3002 - </Tooltip>
3003 - </div>
3004 - </div>
3005 -
3006 - {isManualProjectSorting ? (
3007 - <DndContext
3008 - sensors={projectDnDSensors}
3009 - collisionDetection={projectCollisionDetection}
3010 - modifiers={PROJECT_DND_MODIFIERS}
3011 - onDragStart={handleProjectDragStart}
3012 - onDragEnd={handleProjectDragEnd}
3013 - onDragCancel={handleProjectDragCancel}
3014 - >
3015 - <SidebarMenu {...SIDEBAR_TREE_PROPS} ref={attachSidebarTree}>
3016 - <SortableContext items={sortedProjectKeys} strategy={verticalListSortingStrategy}>
3017 - {sortedProjects.map((project) => (
3018 - <SortableProjectItem key={project.projectKey} projectId={project.projectKey}>
3019 - {(dragHandleProps) => (
3020 - <SidebarProjectItem
3021 - project={project}
3022 - isThreadListExpanded={expandedThreadListsByProject.has(project.projectKey)}
3023 - activeRouteThreadKey={
3024 - activeRouteProjectKey === project.projectKey ? routeThreadKey : null
3025 - }
3026 - openPullRequestsInRightPanel={openPullRequestsInRightPanel}
3027 - newThreadShortcutLabel={newThreadShortcutLabel}
3028 - handleNewThread={handleNewThread}
3029 - archiveThread={archiveThread}
3030 - deleteThread={deleteThread}
3031 - markThreadUnread={markThreadUnread}
3032 - threadJumpLabelByKey={threadJumpLabelByKey}
3033 - attachThreadListAutoAnimateRef={attachThreadListAutoAnimateRef}
3034 - expandThreadListForProject={expandThreadListForProject}
3035 - collapseThreadListForProject={collapseThreadListForProject}
3036 - dragInProgressRef={dragInProgressRef}
3037 - suppressProjectClickAfterDragRef={suppressProjectClickAfterDragRef}
3038 - suppressProjectClickForContextMenuRef={
3039 - suppressProjectClickForContextMenuRef
3040 - }
3041 - isManualProjectSorting={isManualProjectSorting}
3042 - dragHandleProps={dragHandleProps}
3043 - />
3044 - )}
3045 - </SortableProjectItem>
3046 - ))}
3047 - </SortableContext>
3048 - </SidebarMenu>
3049 - </DndContext>
3050 - ) : (
3051 - <SidebarMenu {...SIDEBAR_TREE_PROPS} ref={attachTreeRef}>
3052 - {sortedProjects.map((project) => (
3053 - <SidebarProjectListRow
3054 - key={project.projectKey}
3055 - project={project}
3056 - isThreadListExpanded={expandedThreadListsByProject.has(project.projectKey)}
3057 - activeRouteThreadKey={
3058 - activeRouteProjectKey === project.projectKey ? routeThreadKey : null
3059 - }
3060 - openPullRequestsInRightPanel={openPullRequestsInRightPanel}
3061 - newThreadShortcutLabel={newThreadShortcutLabel}
3062 - handleNewThread={handleNewThread}
3063 - archiveThread={archiveThread}
3064 - deleteThread={deleteThread}
3065 - markThreadUnread={markThreadUnread}
3066 - threadJumpLabelByKey={threadJumpLabelByKey}
3067 - attachThreadListAutoAnimateRef={attachThreadListAutoAnimateRef}
3068 - expandThreadListForProject={expandThreadListForProject}
3069 - collapseThreadListForProject={collapseThreadListForProject}
3070 - dragInProgressRef={dragInProgressRef}
3071 - suppressProjectClickAfterDragRef={suppressProjectClickAfterDragRef}
3072 - suppressProjectClickForContextMenuRef={suppressProjectClickForContextMenuRef}
3073 - isManualProjectSorting={isManualProjectSorting}
3074 - dragHandleProps={null}
3075 - />
3076 - ))}
3077 - </SidebarMenu>
3078 - )}
3079 -
3080 - {projectsLength === 0 && (
3081 - <div className="px-2 pt-4 text-center text-secondary-label text-xs">No projects yet</div>
3082 - )}
3083 - </SidebarGroup>
3084 - </SidebarContent>
3085 - );
3086 -});
3087 -
3088 -const PROJECT_POINTER_SENSOR_OPTIONS = { activationConstraint: { distance: 6 } };
3089 -const PROJECT_DND_MODIFIERS = [restrictToVerticalAxis, restrictToFirstScrollableAncestor];
3090 -
3091 -const projectCollisionDetection: CollisionDetection = (args) => {
3092 - const pointerCollisions = pointerWithin(args);
3093 - if (pointerCollisions.length > 0) {
3094 - return pointerCollisions;
3095 - }
3096 -
3097 - return closestCorners(args);
3098 -};
3099 -
3100 -function openAddProjectCommandPalette() {
3101 - openCommandPalette({ open: "add-project" });
3102 -}
3103 -
3104 -// Separate hooks cache real inputs; later sidebar hooks would invalidate every row's props.
3105 -function useLegacySidebarProjects() {
3106 - const projects = useProjects();
3107 - const projectOrder = useUiStateStore((store) => store.projectOrder);
3108 - const projectGroupingSettings = useClientSettings(selectProjectGroupingSettings);
3109 - const { environments } = useEnvironments();
3110 - const primaryEnvironmentId = usePrimaryEnvironmentId();
3111 - const environmentLabelById = new Map(
3112 - environments.map((environment) => [environment.environmentId, environment.label] as const),
3113 - );
3114 - const desktopLocalEnvironmentIds = new Set(
3115 - environments
3116 - .filter((environment) => isDesktopLocalConnectionTarget(environment.entry.target))
3117 - .map((environment) => environment.environmentId),
3118 - );
3119 - const wslEnvironmentIds = new Set(
3120 - environments
3121 - .filter((environment) => isWslConnectionTarget(environment.entry.target))
3122 - .map((environment) => environment.environmentId),
3123 - );
3124 - const orderedProjects = orderItemsByPreferredIds({
3125 - items: projects,
3126 - preferredIds: projectOrder,
3127 - getId: getProjectOrderKey,
3128 - getPreferenceIds: (project) => [
3129 - getProjectOrderKey(project),
3130 - legacyProjectCwdPreferenceKey(project.workspaceRoot),
3131 - ],
3132 - });
3133 - const physicalToLogicalKey = buildPhysicalToLogicalProjectKeyMap({
3134 - projects: orderedProjects,
3135 - settings: projectGroupingSettings,
3136 - primaryEnvironmentId,
3137 - });
3138 - const projectPhysicalKeyByScopedRef = new Map(
3139 - orderedProjects.map((project) => [
3140 - scopedProjectKey(scopeProjectRef(project.environmentId, project.id)),
3141 - derivePhysicalProjectKey(project),
3142 - ]),
3143 - );
3144 - const sidebarProjects: SidebarProjectSnapshot[] = buildSidebarProjectSnapshots({
3145 - projects: orderedProjects,
3146 - settings: projectGroupingSettings,
3147 - primaryEnvironmentId,
3148 - resolveEnvironmentLabel: (environmentId) => environmentLabelById.get(environmentId) ?? null,
3149 - isDesktopLocalEnvironment: (environmentId) => desktopLocalEnvironmentIds.has(environmentId),
3150 - isWslEnvironment: (environmentId) => wslEnvironmentIds.has(environmentId),
3151 - });
3152 - return {
3153 - projectsLength: projects.length,
3154 - orderedProjects,
3155 - physicalToLogicalKey,
3156 - projectPhysicalKeyByScopedRef,
3157 - sidebarProjects,
3158 - };
3159 -}
3160 -
3161 -// Re-sort on thread changes without rebuilding project snapshots used as row keys.
3162 -function useSortedLegacySidebarProjects(input: {
3163 - sidebarProjects: readonly SidebarProjectSnapshot[];
3164 - physicalToLogicalKey: ReadonlyMap<string, string>;
3165 - projectPhysicalKeyByScopedRef: ReadonlyMap<string, string>;
3166 - sidebarProjectSortOrder: SidebarProjectSortOrder;
3167 -}) {
3168 - const {
3169 - sidebarProjects,
3170 - physicalToLogicalKey,
3171 - projectPhysicalKeyByScopedRef,
3172 - sidebarProjectSortOrder,
3173 - } = input;
3174 - const sidebarThreads = useThreadShells();
3175 - const delegatedUnderParent = useDelegatedUnderParent();
3176 - const sidebarProjectByKey = new Map(
3177 - sidebarProjects.map((project) => [project.projectKey, project] as const),
3178 - );
3179 - const sortableProjects = sidebarProjects.map((project) => ({
3180 - ...project,
3181 - id: project.projectKey,
3182 - }));
3183 - const sortableThreads = filterSidebarV2VisibleThreads(
3184 - sidebarThreads,
3185 - null,
3186 - delegatedUnderParent,
3187 - ).map((thread) => {
3188 - const physicalKey =
3189 - projectPhysicalKeyByScopedRef.get(
3190 - scopedProjectKey(scopeProjectRef(thread.environmentId, thread.projectId)),
3191 - ) ?? scopedProjectKey(scopeProjectRef(thread.environmentId, thread.projectId));
3192 - return {
3193 - ...thread,
3194 - projectId: (physicalToLogicalKey.get(physicalKey) ?? physicalKey) as ProjectId,
3195 - };
3196 - });
3197 - const sortedProjects = sortProjectsForSidebar(
3198 - sortableProjects,
3199 - sortableThreads,
3200 - sidebarProjectSortOrder,
3201 - ).flatMap((project) => {
3202 - const resolvedProject = sidebarProjectByKey.get(project.id);
3203 - return resolvedProject ? [resolvedProject] : [];
3204 - });
3205 - return {
3206 - sortedProjects,
3207 - sortedProjectKeys: sortedProjects.map((project) => project.projectKey),
3208 - };
3209 -}
3210 -
3211 -function useLegacySidebarThreads(input: {
3212 - sortedProjects: readonly SidebarProjectSnapshot[];
3213 - physicalToLogicalKey: ReadonlyMap<string, string>;
3214 - projectPhysicalKeyByScopedRef: ReadonlyMap<string, string>;
3215 - routeThreadKey: string | null;
3216 - sidebarThreadSortOrder: SidebarThreadSortOrder;
3217 - sidebarThreadPreviewCount: number;
3218 - expandedThreadListsByProject: ReadonlySet<string>;
3219 -}) {
3220 - const {
3221 - sortedProjects,
3222 - physicalToLogicalKey,
3223 - projectPhysicalKeyByScopedRef,
3224 - routeThreadKey,
3225 - sidebarThreadSortOrder,
3226 - sidebarThreadPreviewCount,
3227 - expandedThreadListsByProject,
3228 - } = input;
3229 - const sidebarThreads = useThreadShells();
3230 - const delegatedUnderParent = useDelegatedUnderParent();
3231 - const projectExpandedById = useUiStateStore((store) => store.projectExpandedById);
3232 - const sidebarThreadByKey = new Map(
3233 - sidebarThreads.map(
3234 - (thread) =>
3235 - [scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id)), thread] as const,
3236 - ),
3237 - );
3238 - const logicalProjectKeyForThread = (thread: SidebarThreadSummary) => {
3239 - const physicalKey =
3240 - projectPhysicalKeyByScopedRef.get(
3241 - scopedProjectKey(scopeProjectRef(thread.environmentId, thread.projectId)),
3242 - ) ?? scopedProjectKey(scopeProjectRef(thread.environmentId, thread.projectId));
3243 - return physicalToLogicalKey.get(physicalKey) ?? physicalKey;
3244 - };
3245 - const activeRouteThread = routeThreadKey ? sidebarThreadByKey.get(routeThreadKey) : undefined;
3246 - const activeRouteProjectKey = activeRouteThread
3247 - ? logicalProjectKeyForThread(activeRouteThread)
3248 - : null;
3249 - const threadsByProjectKey = new Map<string, SidebarThreadSummary[]>();
3250 - for (const thread of sidebarThreads) {
3251 - const logicalKey = logicalProjectKeyForThread(thread);
3252 - const existing = threadsByProjectKey.get(logicalKey);
3253 - if (existing) {
3254 - existing.push(thread);
3255 - } else {
3256 - threadsByProjectKey.set(logicalKey, [thread]);
3257 - }
3258 - }
3259 - const visibleSidebarThreadKeys = sortedProjects.flatMap((project) => {
3260 - const projectThreads = sortThreads(
3261 - filterSidebarV2VisibleThreads(
3262 - threadsByProjectKey.get(project.projectKey) ?? [],
3263 - null,
3264 - delegatedUnderParent,
3265 - ),
3266 - sidebarThreadSortOrder,
3267 - );
3268 - const projectExpanded = resolveProjectExpanded(
3269 - projectExpandedById,
3270 - projectExpansionPreferenceKeys(project),
3271 - );
3272 - const activeThreadKey = routeThreadKey ?? undefined;
3273 - const pinnedCollapsedThread =
3274 - !projectExpanded && activeThreadKey
3275 - ? (projectThreads.find(
3276 - (thread) =>
3277 - scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id)) === activeThreadKey,
3278 - ) ?? null)
3279 - : null;
3280 - const shouldShowThreadPanel = projectExpanded || pinnedCollapsedThread !== null;
3281 - if (!shouldShowThreadPanel) {
3282 - return [];
3283 - }
3284 - const isThreadListExpanded = expandedThreadListsByProject.has(project.projectKey);
3285 - const hasOverflowingThreads = projectThreads.length > sidebarThreadPreviewCount;
3286 - const previewThreads =
3287 - isThreadListExpanded || !hasOverflowingThreads
3288 - ? projectThreads
3289 - : projectThreads.slice(0, sidebarThreadPreviewCount);
3290 - if (pinnedCollapsedThread) {
3291 - return [
3292 - scopedThreadKey(
3293 - scopeThreadRef(pinnedCollapsedThread.environmentId, pinnedCollapsedThread.id),
3294 - ),
3295 - ];
3296 - }
3297 - return projectThreads.flatMap((thread, index) => {
3298 - const threadKey = scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id));
3299 - return index < previewThreads.length || threadKey === activeThreadKey ? [threadKey] : [];
3300 - });
3301 - });
3302 - const threadJumpCommandByKey = new Map<
3303 - string,
3304 - NonNullable<ReturnType<typeof threadJumpCommandForIndex>>
3305 - >();
3306 - for (const [visibleThreadIndex, threadKey] of visibleSidebarThreadKeys.entries()) {
3307 - const jumpCommand = threadJumpCommandForIndex(visibleThreadIndex);
3308 - if (!jumpCommand) {
3309 - break;
3310 - }
3311 - threadJumpCommandByKey.set(threadKey, jumpCommand);
3312 - }
3313 - const prewarmedSidebarThreadRefs = getSidebarThreadIdsToPrewarm(visibleSidebarThreadKeys).flatMap(
3314 - (threadKey) => {
3315 - const ref = parseScopedThreadKey(threadKey);
3316 - return ref ? [ref] : [];
3317 - },
3318 - );
3319 - return {
3320 - sidebarThreadByKey,
3321 - activeRouteProjectKey,
3322 - visibleSidebarThreadKeys,
3323 - threadJumpCommandByKey,
3324 - threadJumpThreadKeys: [...threadJumpCommandByKey.keys()],
3325 - prewarmedSidebarThreadRefs,
3326 - };
3327 -}
3328 -
3329 -function clearThreadSelectionOnOutsideMouseDown(event: globalThis.MouseEvent) {
3330 - const selection = useThreadSelectionStore.getState();
3331 - if (!selection.hasSelection()) return;
3332 - const target = event.target instanceof HTMLElement ? event.target : null;
3333 - if (shouldClearThreadSelectionOnMouseDown(target)) selection.clearSelection();
3334 -}
3335 -
3336 -export default function LegacySidebar({ routeReveal }: { routeReveal: SidebarRouteReveal }) {
3337 - const reorderProjects = useUiStateStore((store) => store.reorderProjects);
3338 - const navigate = useNavigate();
3339 - const sidebarThreadSortOrder = useClientSettings((s) => s.sidebarThreadSortOrder);
3340 - const sidebarProjectSortOrder = useClientSettings((s) => s.sidebarProjectSortOrder);
3341 - const sidebarThreadPreviewCount = useClientSettings((s) => s.sidebarThreadPreviewCount);
3342 - const handleNewThread = useNewThreadHandler();
3343 - const { archiveThread, deleteThread, markThreadUnread } = useThreadActions();
3344 - const { isMobile, setOpenMobile } = useSidebar();
3345 - const routeTarget = useThreadRouteTarget();
3346 - const routeDraftThread = useComposerDraftStore((store) =>
3347 - routeTarget?.kind === "draft" ? store.getDraftSession(routeTarget.draftId) : null,
3348 - );
3349 - const routeThreadRef = resolveActiveThreadRouteRef(routeTarget, routeDraftThread);
3350 - const routeThreadKey = routeThreadRef ? scopedThreadKey(routeThreadRef) : null;
3351 - const routeTerminalOpen = useTerminalUiStateStore((state) =>
3352 - routeThreadRef
3353 - ? selectThreadTerminalUiState(state.terminalUiStateByThreadKey, routeThreadRef).terminalOpen
3354 - : false,
3355 - );
3356 - const keybindings = useAtomValue(primaryServerKeybindingsAtom);
3357 - const [expandedThreadListsByProject, setExpandedThreadListsByProject] = useState<
3358 - ReadonlySet<string>
3359 - >(() => new Set());
3360 - const dragInProgressRef = useRef(false);
3361 - const suppressProjectClickAfterDragRef = useRef(false);
3362 - const suppressProjectClickForContextMenuRef = useRef(false);
3363 - const desktopUpdateState = useDesktopUpdateState();
3364 - const [desktopUpdateActionPending, setDesktopUpdateActionPending] = useState(false);
3365 - const clearSelection = useThreadSelectionStore((s) => s.clearSelection);
3366 - const setSelectionAnchor = useThreadSelectionStore((s) => s.setAnchor);
3367 - const platform = navigator.platform;
3368 - const shortcutModifiers = useShortcutModifierState();
3369 - const terminalFocused = useTerminalFocus();
3370 - const {
3371 - projectsLength,
3372 - orderedProjects,
3373 - physicalToLogicalKey,
3374 - projectPhysicalKeyByScopedRef,
3375 - sidebarProjects,
3376 - } = useLegacySidebarProjects();
3377 - const { sortedProjects, sortedProjectKeys } = useSortedLegacySidebarProjects({
3378 - sidebarProjects,
3379 - physicalToLogicalKey,
3380 - projectPhysicalKeyByScopedRef,
3381 - sidebarProjectSortOrder,
3382 - });
3383 - const {
3384 - sidebarThreadByKey,
3385 - activeRouteProjectKey,
3386 - visibleSidebarThreadKeys,
3387 - threadJumpCommandByKey,
3388 - threadJumpThreadKeys,
3389 - prewarmedSidebarThreadRefs,
3390 - } = useLegacySidebarThreads({
3391 - sortedProjects,
3392 - physicalToLogicalKey,
3393 - projectPhysicalKeyByScopedRef,
3394 - routeThreadKey,
3395 - sidebarThreadSortOrder,
3396 - sidebarThreadPreviewCount,
3397 - expandedThreadListsByProject,
3398 - });
3399 - const revealActiveRow = useActiveRowReveal(routeReveal, routeThreadKey);
3400 - const newThreadShortcutLabelOptions = {
3401 - platform,
3402 - context: {
3403 - terminalFocus: false,
3404 - terminalOpen: false,
3405 - },
3406 - };
3407 - const newThreadShortcutLabel =
3408 - shortcutLabelForCommand(keybindings, "chat.newLocal", newThreadShortcutLabelOptions) ??
3409 - shortcutLabelForCommand(keybindings, "chat.new", newThreadShortcutLabelOptions);
3410 -
3411 - const navigateToThread = (threadRef: ScopedThreadRef) => {
3412 - if (useThreadSelectionStore.getState().selectedThreadKeys.size > 0) {
3413 - clearSelection();
3414 - }
3415 - setSelectionAnchor(scopedThreadKey(threadRef));
3416 - if (isMobile) {
3417 - setOpenMobile(false);
3418 - }
3419 - void navigate({
3420 - to: "/$environmentId/$threadId",
3421 - params: buildThreadRouteParams(threadRef),
3422 - });
3423 - };
3424 -
3425 - const projectDnDSensors = useSensors(useSensor(PointerSensor, PROJECT_POINTER_SENSOR_OPTIONS));
3426 -
3427 - const handleProjectDragEnd = useStableCallback((event: DragEndEvent) => {
3428 - if (sidebarProjectSortOrder !== "manual") {
3429 - dragInProgressRef.current = false;
3430 - return;
3431 - }
3432 - dragInProgressRef.current = false;
3433 - const { active, over } = event;
3434 - if (!over || active.id === over.id) return;
3435 - const activeProject = sidebarProjects.find((project) => project.projectKey === active.id);
3436 - const overProject = sidebarProjects.find((project) => project.projectKey === over.id);
3437 - if (!activeProject || !overProject) return;
3438 - const activeMemberKeys = activeProject.memberProjects.map(
3439 - (member) => member.physicalProjectKey,
3440 - );
3441 - const overMemberKeys = overProject.memberProjects.map((member) => member.physicalProjectKey);
3442 - reorderProjects(orderedProjects.map(getProjectOrderKey), activeMemberKeys, overMemberKeys);
3443 - });
3444 -
3445 - const handleProjectDragStart = useStableCallback((_event: DragStartEvent) => {
3446 - if (sidebarProjectSortOrder !== "manual") {
3447 - return;
3448 - }
3449 - dragInProgressRef.current = true;
3450 - suppressProjectClickAfterDragRef.current = true;
3451 - });
3452 -
3453 - const handleProjectDragCancel = (_event: DragCancelEvent) => {
3454 - dragInProgressRef.current = false;
3455 - };
3456 -
3457 - const animatedProjectListsRef = useRef(new WeakSet<HTMLElement>());
3458 - const attachProjectListAutoAnimateRef = (node: HTMLElement | null) => {
3459 - if (!node || animatedProjectListsRef.current.has(node)) {
3460 - return;
3461 - }
3462 - autoAnimate(node, SIDEBAR_LIST_ANIMATION_OPTIONS);
3463 - animatedProjectListsRef.current.add(node);
3464 - };
3465 -
3466 - const animatedThreadListsRef = useRef(new WeakSet<HTMLElement>());
3467 - const attachThreadListAutoAnimateRef = (node: HTMLElement | null) => {
3468 - if (!node || animatedThreadListsRef.current.has(node)) {
3469 - return;
3470 - }
3471 - autoAnimate(node, SIDEBAR_LIST_ANIMATION_OPTIONS);
3472 - animatedThreadListsRef.current.add(node);
3473 - };
3474 -
3475 - const isManualProjectSorting = sidebarProjectSortOrder === "manual";
3476 - // Build before modifier-dependent context to give the compiler a separate cache used by every row.
3477 - const threadJumpLabelByKey = buildThreadJumpLabelMap({
3478 - keybindings,
3479 - platform,
3480 - terminalOpen: routeTerminalOpen,
3481 - threadJumpCommandByKey,
3482 - });
3483 - const sidebarShortcutContext = {
3484 - terminalFocus: terminalFocused,
3485 - terminalOpen: routeTerminalOpen,
3486 - modelPickerOpen: isModelPickerOpen(),
3487 - };
3488 - const shouldShowThreadJumpHintsNow = shouldShowThreadJumpHintsForModifiers(
3489 - shortcutModifiers,
3490 - keybindings,
3491 - {
3492 - platform,
3493 - context: sidebarShortcutContext,
3494 - },
3495 - );
3496 - const showThreadJumpHints = useThreadJumpHintsVisible(shouldShowThreadJumpHintsNow);
3497 - const visibleThreadJumpLabelByKey = showThreadJumpHints
3498 - ? threadJumpLabelByKey
3499 - : EMPTY_THREAD_JUMP_LABELS;
3500 - const orderedSidebarThreadKeys = visibleSidebarThreadKeys;
3501 -
3502 - const onWindowKeyDown = useEffectEvent((event: globalThis.KeyboardEvent) => {
3503 - const shortcutContext = {
3504 - terminalFocus: isTerminalFocused(),
3505 - terminalOpen: routeTerminalOpen,
3506 - modelPickerOpen: isModelPickerOpen(),
3507 - };
3508 -
3509 - if (event.defaultPrevented || event.repeat || isCommandPaletteOpen() || isModelPickerOpen()) {
3510 - return;
3511 - }
3512 -
3513 - const command = resolveShortcutCommand(event, keybindings, {
3514 - platform,
3515 - context: shortcutContext,
3516 - });
3517 - const traversalDirection = threadTraversalDirectionFromCommand(command);
3518 - if (traversalDirection !== null) {
3519 - const targetThreadKey = resolveAdjacentThreadId({
3520 - threadIds: orderedSidebarThreadKeys,
3521 - currentThreadId: routeThreadKey,
3522 - direction: traversalDirection,
3523 - });
3524 - if (!targetThreadKey) {
3525 - return;
3526 - }
3527 - const targetThread = sidebarThreadByKey.get(targetThreadKey);
3528 - if (!targetThread) {
3529 - return;
3530 - }
3531 -
3532 - event.preventDefault();
3533 - event.stopPropagation();
3534 - navigateToThread(scopeThreadRef(targetThread.environmentId, targetThread.id));
3535 - return;
3536 - }
3537 -
3538 - const jumpIndex = threadJumpIndexFromCommand(command ?? "");
3539 - if (jumpIndex === null) {
3540 - return;
3541 - }
3542 -
3543 - const targetThreadKey = threadJumpThreadKeys[jumpIndex];
3544 - if (!targetThreadKey) {
3545 - return;
3546 - }
3547 - const targetThread = sidebarThreadByKey.get(targetThreadKey);
3548 - if (!targetThread) {
3549 - return;
3550 - }
3551 -
3552 - event.preventDefault();
3553 - event.stopPropagation();
3554 - navigateToThread(scopeThreadRef(targetThread.environmentId, targetThread.id));
3555 - });
3556 - // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- subscribes to window keydown for thread navigation shortcuts for the sidebar's lifetime
3557 - useEffect(() => {
3558 - const handleWindowKeyDown = (event: globalThis.KeyboardEvent) => onWindowKeyDown(event);
3559 - window.addEventListener("keydown", handleWindowKeyDown);
3560 - return () => {
3561 - window.removeEventListener("keydown", handleWindowKeyDown);
3562 - };
3563 - }, []);
3564 - // A window listener whose lifetime is the sidebar's: no element owns outside clicks.
3565 - // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- window mousedown listener that clears thread selection on outside clicks for the sidebar's lifetime
3566 - useEffect(() => {
3567 - window.addEventListener("mousedown", clearThreadSelectionOnOutsideMouseDown);
3568 - return () => window.removeEventListener("mousedown", clearThreadSelectionOnOutsideMouseDown);
3569 - }, []);
3570 -
3571 - const desktopUpdateButtonDisabled = isDesktopUpdateButtonDisabled(desktopUpdateState);
3572 - const desktopUpdateButtonAction = desktopUpdateState
3573 - ? resolveDesktopUpdateButtonAction(desktopUpdateState)
3574 - : "none";
3575 - const showArm64IntelBuildWarning =
3576 - isElectron && shouldShowArm64IntelBuildWarning(desktopUpdateState);
3577 - const arm64IntelBuildWarningDescription =
3578 - desktopUpdateState && showArm64IntelBuildWarning
3579 - ? getArm64IntelBuildWarningDescription(desktopUpdateState)
3580 - : null;
3581 - const commandPaletteShortcutLabel = isMobile
3582 - ? null
3583 - : shortcutLabelForCommand(keybindings, "commandPalette.toggle", newThreadShortcutLabelOptions);
3584 - const handleDesktopUpdateButtonClick = async () => {
3585 - const bridge = window.desktopBridge;
3586 - if (!bridge || !desktopUpdateState) return;
3587 - if (
3588 - desktopUpdateButtonDisabled ||
3589 - desktopUpdateButtonAction === "none" ||
3590 - desktopUpdateActionPending
3591 - ) {
3592 - return;
3593 - }
3594 -
3595 - setDesktopUpdateActionPending(true);
3596 -
3597 - if (desktopUpdateButtonAction === "download") {
3598 - void bridge
3599 - .downloadUpdate()
3600 - .then((result) => {
3601 - if (result.completed) {
3602 - showDesktopUpdateDownloadedToast(bridge, result.state);
3603 - }
3604 - if (!shouldToastDesktopUpdateActionResult(result)) return;
3605 - const actionError = getDesktopUpdateActionError(result);
3606 - if (!actionError) return;
3607 - toastManager.add(
3608 - stackedThreadToast({
3609 - type: "error",
3610 - title: "Could not download update",
3611 - description: actionError,
3612 - }),
3613 - );
3614 - })
3615 - .catch((error) => {
3616 - toastManager.add(
3617 - stackedThreadToast({
3618 - type: "error",
3619 - title: "Could not start update download",
3620 - description: error instanceof Error ? error.message : "An unexpected error occurred.",
3621 - }),
3622 - );
3623 - })
3624 - .finally(() => setDesktopUpdateActionPending(false));
3625 - return;
3626 - }
3627 -
3628 - if (desktopUpdateButtonAction === "install") {
3629 - let confirmed = false;
3630 - try {
3631 - confirmed = await ensureLocalApi().dialogs.confirm(
3632 - getDesktopUpdateInstallConfirmationMessage(desktopUpdateState),
3633 - );
3634 - } catch (error) {
3635 - setDesktopUpdateActionPending(false);
3636 - toastManager.add(
3637 - stackedThreadToast({
3638 - type: "error",
3639 - title: "Could not confirm update",
3640 - description: error instanceof Error ? error.message : "Update confirmation failed.",
3641 - }),
3642 - );
3643 - return;
3644 - }
3645 - if (!confirmed) {
3646 - setDesktopUpdateActionPending(false);
3647 - return;
3648 - }
3649 - void bridge
3650 - .installUpdate()
3651 - .then((result) => {
3652 - if (!shouldToastDesktopUpdateActionResult(result)) return;
3653 - const actionError = getDesktopUpdateActionError(result);
3654 - if (!actionError) return;
3655 - toastManager.add(
3656 - stackedThreadToast({
3657 - type: "error",
3658 - title: "Could not install update",
3659 - description: actionError,
3660 - }),
3661 - );
3662 - })
3663 - .catch((error) => {
3664 - toastManager.add(
3665 - stackedThreadToast({
3666 - type: "error",
3667 - title: "Could not install update",
3668 - description: error instanceof Error ? error.message : "An unexpected error occurred.",
3669 - }),
3670 - );
3671 - })
3672 - .finally(() => setDesktopUpdateActionPending(false));
3673 - }
3674 - };
3675 -
3676 - const expandThreadListForProject = (projectKey: string) => {
3677 - setExpandedThreadListsByProject((current) => {
3678 - if (current.has(projectKey)) return current;
3679 - const next = new Set(current);
3680 - next.add(projectKey);
3681 - return next;
3682 - });
3683 - };
3684 -
3685 - const collapseThreadListForProject = (projectKey: string) => {
3686 - setExpandedThreadListsByProject((current) => {
3687 - if (!current.has(projectKey)) return current;
3688 - const next = new Set(current);
3689 - next.delete(projectKey);
3690 - return next;
3691 - });
3692 - };
3693 -
3694 - return (
3695 - <RevealActiveRowContext value={revealActiveRow}>
3696 - {prewarmedSidebarThreadRefs.map((threadRef) => (
3697 - <SidebarThreadDetailPrewarmer key={scopedThreadKey(threadRef)} threadRef={threadRef} />
3698 - ))}
3699 - <SidebarChromeHeader isElectron={isElectron} />
3700 -
3701 - <SidebarProjectsContent
3702 - showArm64IntelBuildWarning={showArm64IntelBuildWarning}
3703 - arm64IntelBuildWarningDescription={arm64IntelBuildWarningDescription}
3704 - desktopUpdateButtonAction={desktopUpdateButtonAction}
3705 - desktopUpdateButtonDisabled={desktopUpdateButtonDisabled}
3706 - desktopUpdateActionPending={desktopUpdateActionPending}
3707 - handleDesktopUpdateButtonClick={handleDesktopUpdateButtonClick}
3708 - projectSortOrder={sidebarProjectSortOrder}
3709 - threadSortOrder={sidebarThreadSortOrder}
3710 - threadPreviewCount={sidebarThreadPreviewCount}
3711 - openAddProject={openAddProjectCommandPalette}
3712 - isManualProjectSorting={isManualProjectSorting}
3713 - projectDnDSensors={projectDnDSensors}
3714 - projectCollisionDetection={projectCollisionDetection}
3715 - handleProjectDragStart={handleProjectDragStart}
3716 - handleProjectDragEnd={handleProjectDragEnd}
3717 - handleProjectDragCancel={handleProjectDragCancel}
3718 - handleNewThread={handleNewThread}
3719 - archiveThread={archiveThread}
3720 - deleteThread={deleteThread}
3721 - markThreadUnread={markThreadUnread}
3722 - sortedProjects={sortedProjects}
3723 - sortedProjectKeys={sortedProjectKeys}
3724 - expandedThreadListsByProject={expandedThreadListsByProject}
3725 - activeRouteProjectKey={activeRouteProjectKey}
3726 - routeThreadKey={routeThreadKey}
3727 - openPullRequestsInRightPanel={routeThreadRef !== null}
3728 - newThreadShortcutLabel={newThreadShortcutLabel}
3729 - commandPaletteShortcutLabel={commandPaletteShortcutLabel}
3730 - threadJumpLabelByKey={visibleThreadJumpLabelByKey}
3731 - attachThreadListAutoAnimateRef={attachThreadListAutoAnimateRef}
3732 - expandThreadListForProject={expandThreadListForProject}
3733 - collapseThreadListForProject={collapseThreadListForProject}
3734 - dragInProgressRef={dragInProgressRef}
3735 - suppressProjectClickAfterDragRef={suppressProjectClickAfterDragRef}
3736 - suppressProjectClickForContextMenuRef={suppressProjectClickForContextMenuRef}
3737 - attachProjectListAutoAnimateRef={attachProjectListAutoAnimateRef}
3738 - projectsLength={projectsLength}
3739 - />
3740 - <SidebarChromeFooter showUndoNotice />
3741 - </RevealActiveRowContext>
3742 - );
3743 -}
apps/web/src/components/Sidebar.logic.test.ts
+98
@@ -32,7 +32,11 @@ import {
32 type SidebarListMarker,
33 type SidebarSection,
34 resolveSidebarDropVerb,
35 + groupSidebarThreadsByProject,
36 + resolveSidebarFolderDot,
37 + sidebarFolderExpansionKeys,
38 } from "./Sidebar.logic";
39 +import { resolveProjectExpanded } from "../uiStateStore";
40 import { threadSearchMatchKey } from "@t3tools/client-runtime/state/thread-search";
41 import { EnvironmentId, ProjectId, ProviderInstanceId, RunId, ThreadId } from "@t3tools/contracts";
42
@@ -1348,3 +1352,97 @@ describe("resolveSidebarRouteReveal", () => {
1352 ).toEqual({ pendingKey: hiddenKey, widensScope: false });
1353 });
1354 });
1355 +
1356 +describe("sidebarFolderExpansionKeys", () => {
1357 + it("honors a collapse the legacy sidebar saved under a member's cwd", () => {
1358 + const keys = sidebarFolderExpansionKeys({
1359 + projectKey: "github.com/pingdotgg/t3code",
1360 + memberProjects: [{ physicalProjectKey: "local:/code/t3code", workspaceRoot: "/code/t3code" }],
1361 + });
1362 + const cwdKey = keys.at(-1)!;
1363 +
1364 + expect(resolveProjectExpanded({}, keys)).toBe(true);
1365 + expect(resolveProjectExpanded({ [cwdKey]: false }, keys)).toBe(false);
1366 + expect(resolveProjectExpanded({ [keys[0]!]: true, [cwdKey]: false }, keys)).toBe(true);
1367 + });
1368 +});
1369 +
1370 +describe("groupSidebarThreadsByProject", () => {
1371 + it("puts each thread in its project's folder and keeps empty projects", () => {
1372 + const remoteEnvironmentId = EnvironmentId.make("environment-remote");
1373 + const t3code = ProjectId.make("t3code");
1374 + const t3codeRemote = ProjectId.make("t3code-remote");
1375 + const fleet = ProjectId.make("fleet");
1376 + const thread = (id: string, environmentId: EnvironmentId, projectId: ProjectId) => ({
1377 + id,
1378 + environmentId,
1379 + projectId,
1380 + });
1381 + const groups = [
1382 + {
1383 + projectKey: "t3code",
1384 + memberProjectRefs: [
1385 + { environmentId: localEnvironmentId, projectId: t3code },
1386 + { environmentId: remoteEnvironmentId, projectId: t3codeRemote },
1387 + ],
1388 + },
1389 + {
1390 + projectKey: "fleet",
1391 + memberProjectRefs: [{ environmentId: localEnvironmentId, projectId: fleet }],
1392 + },
1393 + ];
1394 +
1395 + const folders = groupSidebarThreadsByProject(groups, [
1396 + thread("a", localEnvironmentId, t3code),
1397 + thread("orphan", localEnvironmentId, ProjectId.make("deleted")),
1398 + thread("b", remoteEnvironmentId, t3codeRemote),
1399 + ]);
1400 +
1401 + expect(
1402 + folders.map((folder) => ({
1403 + projectKey: folder.group.projectKey,
1404 + threads: folder.threads.map((entry) => entry.id),
1405 + })),
1406 + ).toEqual([
1407 + { projectKey: "t3code", threads: ["a", "b"] },
1408 + { projectKey: "fleet", threads: [] },
1409 + ]);
1410 + });
1411 +});
1412 +
1413 +describe("resolveSidebarFolderDot", () => {
1414 + it("flags the most urgent hidden thread and stays quiet otherwise", () => {
1415 + const idle = {
1416 + hasActionableProposedPlan: false,
1417 + hasPendingApprovals: false,
1418 + hasPendingUserInput: false,
1419 + interactionMode: "default" as const,
1420 + latestRun: makeLatestRun(),
1421 + lastVisitedAt: "2026-03-09T10:06:00.000Z",
1422 + runtime: null,
1423 + };
1424 + const runtime = {
1425 + status: "running" as const,
1426 + activeRunId: null,
1427 + providerInstanceId: ProviderInstanceId.make("codex"),
1428 + providerName: "Codex",
1429 + lastError: null,
1430 + updatedAt: "2026-03-09T10:00:00.000Z",
1431 + };
1432 + const working = { ...idle, runtime };
1433 + const unread = { ...idle, lastVisitedAt: "2026-03-09T10:04:00.000Z" };
1434 + const limited = {
1435 + ...idle,
1436 + runtime: { ...runtime, status: "failed" as const, lastErrorClass: "usage_limit" as const },
1437 + };
1438 +
1439 + expect(resolveSidebarFolderDot([idle])).toBeNull();
1440 + // A waiting thread stays quiet even with an unread completion, like its row.
1441 + expect(
1442 + resolveSidebarFolderDot([{ ...unread, runtime: { ...runtime, status: "idle" as const } }]),
1443 + ).toBeNull();
1444 + expect(resolveSidebarFolderDot([idle, working])).toBe("working");
1445 + expect(resolveSidebarFolderDot([working, unread])).toBe("unread");
1446 + expect(resolveSidebarFolderDot([unread, limited])).toBe("attention");
1447 + });
1448 +});
apps/web/src/components/Sidebar.logic.ts
+87 -38
@@ -34,6 +34,7 @@ import { isLatestRunSettled } from "../session-logic";
34 import { observeIntersection } from "../lib/observeIntersection";
35 import { deadlineAfter, deadlineStore } from "@t3tools/client-runtime/clock";
36 import { useDeadlinePassed } from "../hooks/useDeadline";
37 +import { legacyProjectCwdPreferenceKey } from "../uiStateStore";
38
39 export function shouldNavigateAfterThreadPark(input: {
40 readonly threadKey: string;
@@ -51,7 +52,6 @@ export function shouldNavigateAfterThreadPark(input: {
52 );
53 }
54
54 -const THREAD_SELECTION_SAFE_SELECTOR = "[data-thread-item], [data-thread-selection-safe]";
55 const THREAD_JUMP_HINT_SHOW_DELAY_MS = 200;
56
57 export function resolveSidebarRowAccessibility(input: {
@@ -67,7 +67,6 @@ export function resolveSidebarRowAccessibility(input: {
67 }
68
69 // Each prewarm retains growing thread detail and a live subscription, multiplying heap and server load.
70 -const SIDEBAR_THREAD_PREWARM_LIMIT = 3;
70 const SIDEBAR_ROW_SUBSCRIPTION_OVERSCAN_PX = 160;
71
72 export function useSidebarRowSubscriptionLease(isActive: boolean): {
@@ -542,21 +541,6 @@ export async function archiveSelectedThreadEntries<
541 return { archivedThreadKeys, mutationFailure: null, followupFailures };
542 }
543
545 -export function buildMultiSelectThreadContextMenuItems(input: {
546 - count: number;
547 - hasRunningThread: boolean;
548 -}): readonly ContextMenuItem<"mark-unread" | "archive" | "delete">[] {
549 - return [
550 - { id: "mark-unread", label: `Mark unread (${input.count})` },
551 - {
552 - id: "archive",
553 - label: `Archive (${input.count})`,
554 - disabled: input.hasRunningThread,
555 - },
556 - { id: "delete", label: `Delete (${input.count})`, destructive: true },
557 - ];
558 -}
559 -
544 export function isSidebarSubagentThread(thread: Pick<SidebarThreadSummary, "lineage">): boolean {
545 return thread.lineage.relationshipToParent === "subagent";
546 }
@@ -722,11 +706,6 @@ function hasUnseenFailure(thread: ThreadStatusInput): boolean {
706 return completedAt > lastVisitedAt;
707 }
708
725 -export function shouldClearThreadSelectionOnMouseDown(target: HTMLElement | null): boolean {
726 - if (target === null) return true;
727 - return !target.closest(THREAD_SELECTION_SAFE_SELECTOR);
728 -}
729 -
709 // Suppress trailing double-click navigation; keyboard and synthetic clicks use detail 0.
710 export function isTrailingDoubleClick(detail: number): boolean {
711 return detail > 1;
@@ -795,13 +774,6 @@ export function orderItemsByPreferredIds<TItem, TId>(input: {
774 return [...ordered, ...remaining];
775 }
776
798 -export function getSidebarThreadIdsToPrewarm<TThreadId>(
799 - visibleThreadIds: readonly TThreadId[],
800 - limit = SIDEBAR_THREAD_PREWARM_LIMIT,
801 -): TThreadId[] {
802 - return visibleThreadIds.slice(0, Math.max(0, limit));
803 -}
804 -
777 export function resolveAdjacentThreadId<T>(input: {
778 threadIds: readonly T[];
779 currentThreadId: T | null;
@@ -829,15 +801,6 @@ export function resolveAdjacentThreadId<T>(input: {
801 return currentIndex < threadIds.length - 1 ? (threadIds[currentIndex + 1] ?? null) : null;
802 }
803
832 -export function isContextMenuPointerDown(input: {
833 - button: number;
834 - ctrlKey: boolean;
835 - isMac: boolean;
836 -}): boolean {
837 - if (input.button === 2) return true;
838 - return input.isMac && input.button === 0 && input.ctrlKey;
839 -}
840 -
804 export type SidebarThreadStatus =
805 | "approval"
806 | "input"
@@ -909,6 +872,92 @@ export function resolveSidebarThreadStatus(thread: SidebarThreadStatusInput): Si
872 return "ready";
873 }
874
875 +/**
876 + * The dot on a closed boring-sidebar folder: the most urgent state among its
877 + * hidden threads. Waiting threads stay quiet, like their rows.
878 + */
879 +export function resolveSidebarFolderDot(
880 + threads: ReadonlyArray<ThreadStatusInput & SidebarThreadStatusInput>,
881 +): "attention" | "failed" | "unread" | "working" | null {
882 + const statuses = new Set(threads.map(resolveSidebarThreadStatus));
883 + if (
884 + statuses.has("input") ||
885 + statuses.has("approval") ||
886 + statuses.has("request") ||
887 + statuses.has("limited")
888 + ) {
889 + return "attention";
890 + }
891 + if (statuses.has("failed")) return "failed";
892 + // Rows show Done only for ready threads, so the dot follows the same rule.
893 + const hasUnread = threads.some(
894 + (thread) => resolveSidebarThreadStatus(thread) === "ready" && hasUnseenCompletion(thread),
895 + );
896 + if (hasUnread) return "unread";
897 + if (statuses.has("working")) return "working";
898 + return null;
899 +}
900 +
901 +/**
902 + * Keys the old per-project sidebar saved folder open state under, most
903 + * specific first, for `resolveProjectExpanded`. Boring folders read and write
904 + * the same keys, so a legacy user's closed folders stay closed after regrouping.
905 + */
906 +export function sidebarFolderExpansionKeys(group: {
907 + readonly projectKey: string;
908 + readonly memberProjects: ReadonlyArray<{
909 + readonly physicalProjectKey: string;
910 + readonly workspaceRoot: string;
911 + }>;
912 +}): string[] {
913 + return [
914 + group.projectKey,
915 + ...group.memberProjects.map((member) => member.physicalProjectKey),
916 + ...group.memberProjects.map((member) => legacyProjectCwdPreferenceKey(member.workspaceRoot)),
917 + ];
918 +}
919 +
920 +/**
921 + * Boring sidebar folders. Folders follow `groups` order and include empty
922 + * projects so each one can start a thread. Threads keep their input order.
923 + * A thread whose project is in no group has no folder and is left out.
924 + */
925 +export function groupSidebarThreadsByProject<
926 + TGroup extends {
927 + readonly memberProjectRefs: ReadonlyArray<{
928 + readonly environmentId: EnvironmentId;
929 + readonly projectId: string;
930 + }>;
931 + },
932 + TThread extends Pick<SidebarThreadSummary, "environmentId" | "projectId">,
933 +>(
934 + groups: readonly TGroup[],
935 + threads: readonly TThread[],
936 +): Array<{ group: TGroup; threads: TThread[] }> {
937 + const folders = groups.map((group) => ({ group, threads: [] as TThread[] }));
938 + const folderByProject = new Map<string, (typeof folders)[number]>();
939 + for (const folder of folders) {
940 + for (const ref of folder.group.memberProjectRefs) {
941 + folderByProject.set(`${ref.environmentId}:${ref.projectId}`, folder);
942 + }
943 + }
944 + for (const thread of threads) {
945 + folderByProject.get(`${thread.environmentId}:${thread.projectId}`)?.threads.push(thread);
946 + }
947 + return folders;
948 +}
949 +
950 +export type SidebarV2TopStatusKind =
951 + | "approval"
952 + | "done"
953 + | "failed"
954 + | "limited"
955 + | "input"
956 + | "request"
957 + | "waiting"
958 + | "woke"
959 + | "working";
960 +
961 export function firstValidTimestampMs(
962 ...candidates: ReadonlyArray<string | null | undefined>
963 ): number {
apps/web/src/components/Sidebar.tsx
+134 -10
@@ -110,7 +110,7 @@ import {
110 getSidebarProjectSettingsKey,
111 type SidebarProjectSnapshot,
112 } from "../sidebarProjectGrouping";
113 -import { useUiStateStore } from "../uiStateStore";
113 +import { resolveProjectExpanded, useUiStateStore } from "../uiStateStore";
114 import {
115 getThreadKeysToDeselectAfterDelete,
116 useThreadSelectionStore,
@@ -122,7 +122,7 @@ import { useTerminalFocus } from "../hooks/useTerminalFocus";
122 import { isCommandPaletteOpen, openCommandPalette } from "../commandPaletteBus";
123 import { registerSettleAndAdvance } from "../settleAndAdvance";
124 import { startNewThreadFromContext } from "../lib/chatThreadActions";
125 -import { useClientSettings } from "../hooks/useSettings";
125 +import { useBoringSidebarEnabled, useClientSettings } from "../hooks/useSettings";
126 import { useCopyToClipboard } from "../hooks/useCopyToClipboard";
127 import { useLocalStorage } from "../hooks/useLocalStorage";
128 import { useNowMinute } from "../hooks/useNowMinute";
@@ -168,6 +168,8 @@ import {
168 import {
169 applySidebarThreadDrop,
170 filterSidebarV2VisibleThreads,
171 + groupSidebarThreadsByProject,
172 + sidebarFolderExpansionKeys,
173 buildBulkTitleRegenerationContextMenuItem,
174 buildBulkUnpinContextMenuItem,
175 deleteSelectedThreadEntries,
@@ -246,6 +248,10 @@ import {
248 type SidebarSweepAction,
249 } from "./sidebar/SidebarThreadRow";
250 import { SidebarDraftBlock } from "./sidebar/SidebarDraftBlock";
251 +import {
252 + SidebarProjectFolderHeader,
253 + sidebarFolderRowId,
254 +} from "./sidebar/SidebarProjectFolderHeader";
255 import {
256 SidebarDragBoundary,
257 SidebarSectionHeader,
@@ -391,6 +397,8 @@ function useSidebarThreads(input: {
397 readonly threads: readonly EnvironmentThreadShell[];
398 readonly delegatedUnderParent: ReadonlySet<string>;
399 readonly routeRowThreadKey: string | null;
400 + // Set in boring mode: the project groups to fold active threads into, in order.
401 + readonly folderGroups: readonly SidebarProjectSnapshot[] | null;
402 }) {
403 const {
404 projectScopeKey,
@@ -400,8 +408,11 @@ function useSidebarThreads(input: {
408 threads,
409 delegatedUnderParent,
410 routeRowThreadKey,
411 + folderGroups,
412 } = input;
404 - const workingShelfEnabled = useClientSettings((s) => s.sidebarWorkingShelfEnabled);
413 + // Folders already separate the work, so boring mode has no Working shelf.
414 + const workingShelfEnabled =
415 + useClientSettings((s) => s.sidebarWorkingShelfEnabled) && folderGroups === null;
416 const inboxReturnsVersion = useSyncExternalStore(
417 inboxReturns.subscribe,
418 inboxReturns.getSnapshot,
@@ -424,6 +435,9 @@ function useSidebarThreads(input: {
435 false,
436 Schema.Boolean,
437 );
438 + // Shared with the old per-project sidebar, so folders keep their open state.
439 + const projectExpandedById = useUiStateStore((store) => store.projectExpandedById);
440 + const setProjectExpanded = useUiStateStore((store) => store.setProjectExpanded);
441 const [settledTail, setSettledTail] = useState({
442 scopeKey: projectScopeKey,
443 count: SETTLED_TAIL_INITIAL_COUNT,
@@ -478,9 +492,31 @@ function useSidebarThreads(input: {
492 const visibleWorkingThreads = workingShelfExpanded
493 ? workingThreads
494 : routeThreadOnly(workingThreads, routeRowThreadKey);
495 + const projectFolders =
496 + folderGroups === null
497 + ? null
498 + : groupSidebarThreadsByProject(folderGroups, activeThreads).map((folder) => {
499 + const collapsed = !resolveProjectExpanded(
500 + projectExpandedById,
501 + sidebarFolderExpansionKeys(folder.group),
502 + );
503 + return {
504 + group: folder.group,
505 + collapsed,
506 + // A closed folder still shows the open thread, and hints at the rest.
507 + threads: collapsed
508 + ? routeThreadOnly(folder.threads, routeRowThreadKey)
509 + : folder.threads,
510 + hiddenThreads: collapsed
511 + ? folder.threads.filter((thread) => threadShellKey(thread) !== routeRowThreadKey)
512 + : EMPTY_THREADS,
513 + };
514 + });
515 const orderedThreads = [
516 ...pinnedThreads,
483 - ...activeThreads,
517 + ...(projectFolders === null
518 + ? activeThreads
519 + : projectFolders.flatMap((folder) => folder.threads)),
520 ...visibleWorkingThreads,
521 ...visibleSnoozedThreads,
522 ...renderedSettledThreads,
@@ -521,6 +557,11 @@ function useSidebarThreads(input: {
557 toggleSnoozedShelf: () => setSnoozedShelfExpanded((value) => !value),
558 workingShelfExpanded,
559 toggleWorkingShelf: () => setWorkingShelfExpanded((value) => !value),
560 + projectFolders,
561 + toggleProjectFolder: (group: SidebarProjectSnapshot) => {
562 + const keys = sidebarFolderExpansionKeys(group);
563 + setProjectExpanded(keys, !resolveProjectExpanded(projectExpandedById, keys));
564 + },
565 renderedSettledThreads,
566 visibleSnoozedThreads,
567 visibleWorkingThreads,
@@ -911,6 +952,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
952 );
953 },
954 });
955 + const boringSidebarEnabled = useBoringSidebarEnabled();
956 const newThreadContext = useHandleNewThread();
957 // Row callbacks capture only the handler; the rest of the context changes with the route.
958 const { handleNewThread } = newThreadContext;
@@ -1145,6 +1187,40 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
1187 openProjectSettings(projectGroup);
1188 },
1189 );
1190 + const startThreadInProjectFolder = useStableCallback((group: SidebarProjectSnapshot) => {
1191 + if (isMobile) setOpenMobile(false);
1192 + void handleNewThread(scopeProjectRef(group.environmentId, group.id));
1193 + });
1194 + const handleProjectFolderContextMenu = useStableCallback(
1195 + (group: SidebarProjectSnapshot, position: { x: number; y: number }) => {
1196 + const api = readLocalApi();
1197 + if (!api) return;
1198 + void (async () => {
1199 + const clicked = await settlePromise(() =>
1200 + api.contextMenu.show(
1201 + [
1202 + { id: "new-thread", label: "New thread" },
1203 + { id: "copy-path", label: "Copy path" },
1204 + { id: "project-settings", label: "Project settings", icon: "settings" },
1205 + ],
1206 + position,
1207 + ),
1208 + );
1209 + if (clicked._tag === "Failure") return;
1210 + switch (clicked.value) {
1211 + case "new-thread":
1212 + startThreadInProjectFolder(group);
1213 + return;
1214 + case "copy-path":
1215 + copyPathToClipboard(group.workspaceRoot, { path: group.workspaceRoot });
1216 + return;
1217 + case "project-settings":
1218 + openProjectSettings(group);
1219 + return;
1220 + }
1221 + })();
1222 + },
1223 + );
1224
1225 const {
1226 workingShelfEnabled,
@@ -1168,6 +1244,8 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
1244 toggleSnoozedShelf,
1245 workingShelfExpanded,
1246 toggleWorkingShelf,
1247 + projectFolders,
1248 + toggleProjectFolder,
1249 renderedSettledThreads,
1250 visibleSnoozedThreads,
1251 visibleWorkingThreads,
@@ -1188,6 +1266,11 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
1266 threads,
1267 delegatedUnderParent,
1268 routeRowThreadKey,
1269 + folderGroups: boringSidebarEnabled
1270 + ? scopedProjectGroups.length === 0
1271 + ? projectGroups
1272 + : scopedProjectGroups
1273 + : null,
1274 });
1275
1276 // Ranked across environments as the palette ranks them, so one
@@ -1748,6 +1831,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
1831 event.activatorEvent instanceof PointerEvent ? event.activatorEvent.clientY : null,
1832 });
1833 };
1834 + const hasProjectFolders = projectFolders !== null && projectFolders.length > 0;
1835 const sidebarListItemsFresh = ((): readonly SidebarListItem[] => {
1836 const rowsOf = (
1837 list: readonly EnvironmentThreadShell[],
@@ -1757,13 +1841,15 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
1841 const key = scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id));
1842 return { kind: "thread", key, section };
1843 });
1844 + // Boring mode keeps empty project folders, so each can start a thread.
1845 if (
1846 + !hasProjectFolders &&
1847 pinnedThreads.length +
1848 activeThreads.length +
1849 workingThreads.length +
1850 snoozedThreads.length +
1851 settledCount ===
1766 - 0
1852 + 0
1853 ) {
1854 return [];
1855 }
@@ -1813,6 +1899,9 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
1899 // Only order, section, or draft changes need layout reads and motion.
1900 const listMotionLayoutKey = [
1901 sidebarListItemsKey,
1902 + projectFolders
1903 + ?.map((folder) => `${folder.group.projectKey}:${folder.threads.length}`)
1904 + .join("\n") ?? "",
1905 visibleDraftSessionCount,
1906 routeDraftIdForRows ?? "",
1907 ].join("\0");
@@ -2742,7 +2831,10 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
2831 const showJumpHints = useThreadJumpHintsVisible(shouldShowJumpHintsNow);
2832
2833 const handleNewThreadClick = (event?: ReactMouseEvent) => {
2745 - if (shouldCreateNewThreadInCurrentProject(event?.shiftKey ?? false, projectGroups.length)) {
2834 + if (
2835 + boringSidebarEnabled ||
2836 + shouldCreateNewThreadInCurrentProject(event?.shiftKey ?? false, projectGroups.length)
2837 + ) {
2838 if (isMobile) setOpenMobile(false);
2839 void startNewThreadFromContext({
2840 activeDraftThread: newThreadContext.activeDraftThread,
@@ -2942,7 +3034,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
3034 newThreadDisabled={projects.length === 0}
3035 newThreadShortcutLabel={newThreadShortcutLabel}
3036 newThreadInProjectShortcutLabel={newThreadInProjectShortcutLabel}
2945 - showNewThreadInProjectHint={projectGroups.length > 1}
3037 + showNewThreadInProjectHint={!boringSidebarEnabled && projectGroups.length > 1}
3038 searchInputRef={threadSearchInputRef}
3039 searchQuery={threadSearchQuery}
3040 onSearchQueryChange={(value) => {
@@ -3058,19 +3150,22 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
3150 const renderThreadRow = (
3151 thread: EnvironmentThreadShell,
3152 section: SidebarSection,
3153 + // The tree row of the project folder this row sits in.
3154 + folderRow?: string,
3155 ) => {
3156 const threadKey = scopedThreadKey(
3157 scopeThreadRef(thread.environmentId, thread.id),
3158 );
3159 const isCard =
3160 section === "active" || section === "pinned" || section === "working";
3067 - const rowVariant = isCard ? "card" : "slim";
3161 + const rowVariant = folderRow ? "folder" : isCard ? "card" : "slim";
3162 return (
3163 <SortableThreadRow
3164 key={threadKey}
3165 sortableId={threadKey}
3166 contextDrag={isContextDrag}
3167 sortableDisabled={
3168 + projectFolders !== null ||
3169 renamingThreadKey === threadKey ||
3170 !draggableThreadKeys.has(threadKey) ||
3171 optimisticDrop !== null
@@ -3078,11 +3173,12 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
3173 thread={thread}
3174 variant={rowVariant}
3175 navigationParent={
3081 - section === "working" ||
3176 + folderRow ??
3177 + (section === "working" ||
3178 section === "snoozed" ||
3179 section === "settled"
3180 ? `shelf:${section}`
3085 - : undefined
3181 + : undefined)
3182 }
3183 variantAction={
3184 section === "snoozed"
@@ -3179,9 +3275,36 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
3275 ];
3276 for (const item of sidebarListItems) {
3277 if (item.kind === "thread") {
3278 + // Folders draw active rows in their own place below.
3279 + if (projectFolders !== null && item.section === "active") continue;
3280 items.push(renderThreadRow(threadByKey.get(item.key)!, item.section));
3281 continue;
3282 }
3283 + if (projectFolders !== null && item.marker === "active-placeholder") {
3284 + for (const folder of projectFolders) {
3285 + items.push(
3286 + <SidebarProjectFolderHeader
3287 + key={`project-folder:${folder.group.projectKey}`}
3288 + group={folder.group}
3289 + collapsed={folder.collapsed}
3290 + hiddenThreads={folder.hiddenThreads}
3291 + onToggle={toggleProjectFolder}
3292 + onNewThread={startThreadInProjectFolder}
3293 + onContextMenu={handleProjectFolderContextMenu}
3294 + />,
3295 + );
3296 + for (const thread of folder.threads) {
3297 + items.push(
3298 + renderThreadRow(
3299 + thread,
3300 + "active",
3301 + sidebarFolderRowId(folder.group.projectKey),
3302 + ),
3303 + );
3304 + }
3305 + }
3306 + continue;
3307 + }
3308 switch (item.marker) {
3309 case "pinned-header":
3310 items.push(
@@ -3330,6 +3453,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
3453 </TooltipProvider>
3454 ) : null}
3455 {!isSearchingThreads &&
3456 + !hasProjectFolders &&
3457 visibleDraftSessionCount === 0 &&
3458 pinnedThreads.length +
3459 activeThreads.length +
apps/web/src/components/ThreadStatusIndicators.tsx
+2 -2
@@ -440,7 +440,7 @@ export function ChangeRequestStatusIcon({
440 return <presentation.Icon className={className} />;
441 }
442
443 -export function PrStatusTooltipContent({ status }: { status: PrStatusIndicator }) {
443 +function PrStatusTooltipContent({ status }: { status: PrStatusIndicator }) {
444 return (
445 <span className="flex max-w-[min(34rem,calc(100vw-2rem))] items-stretch overflow-hidden whitespace-nowrap">
446 <span className="shrink-0 pr-2 font-medium">{status.tooltipLead}</span>
@@ -600,7 +600,7 @@ export function ThreadWorktreeIndicator({
600 );
601 }
602
603 -export function ThreadStatusLabel({
603 +function ThreadStatusLabel({
604 status,
605 compact = false,
606 }: {
apps/web/src/components/settings/LabsSettingsPanel.tsx
+23
@@ -4,6 +4,7 @@ import { Link } from "@tanstack/react-router";
4 import { hasCloudPublicConfig } from "~/cloud/publicConfig";
5 import { useT3ConnectAuthPrompt } from "../clerk/useT3ConnectAuthPrompt";
6 import { Button } from "../ui/button";
7 +import { Switch } from "../ui/switch";
8 import { ScopedSwitch } from "./ScopedSwitch";
9 import { SettingsPageContainer, SettingsRow, SettingsSection } from "./settingsLayout";
10 import { searchableSetting } from "./settingsSearch";
@@ -15,6 +16,7 @@ export function LabsSettingsPanel() {
16 return (
17 <SettingsPageContainer>
18 <SettingsSection id="beta" title="Beta">
19 + <BoringSidebarRow />
20 {/* Clerk is only mounted when this build has T3 Connect. */}
21 {hasCloudPublicConfig() ? <GuestLinksRowWithSignIn /> : <GuestLinksRow />}
22 <LinkedEnvironmentsRow />
@@ -24,6 +26,27 @@ export function LabsSettingsPanel() {
26 );
27 }
28
29 +function BoringSidebarRow() {
30 + const settings = useScopedSettings();
31 + const updateSettings = useUpdateScopedSettings();
32 + return (
33 + <SettingsRow
34 + {...searchableSetting("boring-sidebar")}
35 + description="Group sidebar threads into project folders. Pinned threads stay on top, and Snoozed and Settled stay below the folders."
36 + control={
37 + <Switch
38 + checked={settings.boringSidebarEnabled || settings.legacySidebarEnabled}
39 + // Turning it off also clears the opt-in of the removed legacy sidebar.
40 + onCheckedChange={(checked) =>
41 + updateSettings({ boringSidebarEnabled: Boolean(checked), legacySidebarEnabled: false })
42 + }
43 + aria-label="Boring sidebar (group by project)"
44 + />
45 + }
46 + />
47 + );
48 +}
49 +
50 /** Signed out of T3 Connect, the row offers to sign in instead of its switch. */
51 function GuestLinksRowWithSignIn() {
52 const { isSignedIn } = useAuth();
apps/web/src/components/settings/SettingsPanels.tsx
+1 -18
@@ -425,9 +425,6 @@ export function useSettingsRestore(onRestored?: () => void) {
425 ...(settings.inAppNotificationsEnabled !== DEFAULT_UNIFIED_SETTINGS.inAppNotificationsEnabled
426 ? ["In-app notifications"]
427 : []),
428 - ...(settings.sidebarThreadPreviewCount !== DEFAULT_UNIFIED_SETTINGS.sidebarThreadPreviewCount
429 - ? ["Visible threads"]
430 - : []),
428 ...(settings.sidebarProjectGroupingMode !== DEFAULT_UNIFIED_SETTINGS.sidebarProjectGroupingMode
429 ? ["Project Grouping"]
430 : []),
@@ -603,7 +600,6 @@ export function useSettingsRestore(onRestored?: () => void) {
600 environmentIdentificationMode: DEFAULT_UNIFIED_SETTINGS.environmentIdentificationMode,
601 glassOpacity: DEFAULT_UNIFIED_SETTINGS.glassOpacity,
602 panelAnimationDurationMs: DEFAULT_UNIFIED_SETTINGS.panelAnimationDurationMs,
606 - sidebarThreadPreviewCount: DEFAULT_UNIFIED_SETTINGS.sidebarThreadPreviewCount,
603 sidebarProjectGroupingMode: DEFAULT_UNIFIED_SETTINGS.sidebarProjectGroupingMode,
604 sidebarProjectSortOrder: DEFAULT_UNIFIED_SETTINGS.sidebarProjectSortOrder,
605 sidebarWorkingShelfEnabled: DEFAULT_UNIFIED_SETTINGS.sidebarWorkingShelfEnabled,
@@ -732,19 +728,6 @@ export function LegacyFeaturesSection() {
728 />
729 }
730 />
735 - <SettingsRow
736 - {...searchableSetting("legacy-sidebar")}
737 - description="Restore per-project thread trees instead of the default flat sidebar."
738 - control={
739 - <Switch
740 - checked={settings.legacySidebarEnabled}
741 - onCheckedChange={(checked) =>
742 - updateSettings({ legacySidebarEnabled: Boolean(checked) })
743 - }
744 - aria-label="Sidebar (legacy)"
745 - />
746 - }
747 - />
731 </SettingsSection>
732 );
733 }
@@ -851,7 +834,7 @@ export function GeneralSettingsPanel() {
834 />
835 <SettingsRow
836 {...searchableSetting("working-shelf")}
854 - description="Fold working and monitoring threads into a Working section. They return to the top of the inbox when they need you."
837 + description="Fold working and monitoring threads into a Working section. They return to the top of the inbox when they need you. The boring sidebar in Labs has no Working section."
838 resetAction={
839 settings.sidebarWorkingShelfEnabled !==
840 DEFAULT_UNIFIED_SETTINGS.sidebarWorkingShelfEnabled ? (
apps/web/src/components/settings/settingsSearch.test.ts
+1 -1
@@ -197,7 +197,7 @@ describe("settings search targets", () => {
197 const streaming = getSettingsSearchTargetScope("response-streaming")!;
198 expect(streaming.scope).toBe("project-defaults");
199 expect(isSettingsSearchScopeAvailable(streaming.scope, "project")).toBe(true);
200 - for (const id of ["legacy-plan-mode", "legacy-context-window-indicator", "legacy-sidebar"]) {
200 + for (const id of ["legacy-plan-mode", "legacy-context-window-indicator", "boring-sidebar"]) {
201 expect(getSettingsSearchTargetScope(id)!.scope).toBeNull();
202 }
203 });
apps/web/src/components/settings/settingsSearch.ts
+6 -6
@@ -419,6 +419,12 @@ export const SETTINGS_SEARCH_ITEMS = [
419 to: "/settings/general",
420 searchTerms: ["hide fold running monitoring threads inbox sidebar shelf"],
421 },
422 + {
423 + id: "boring-sidebar",
424 + title: "Boring sidebar (group by project)",
425 + to: "/settings/labs",
426 + searchTerms: ["beta folders project tree legacy old classic sidebar"],
427 + },
428 {
429 id: "guest-links",
430 title: "Guest links",
@@ -708,12 +714,6 @@ export const SETTINGS_SEARCH_ITEMS = [
714 to: "/settings/labs",
715 searchTerms: ["composer meter usage tokens circle old"],
716 },
711 - {
712 - id: "legacy-sidebar",
713 - title: "Sidebar (legacy)",
714 - to: "/settings/labs",
715 - searchTerms: ["project thread tree old flat list"],
716 - },
717 {
718 id: "keybindings",
719 title: "Keybindings",
apps/web/src/components/sidebar/SidebarProjectFolderHeader.tsx new
+115
@@ -0,0 +1,115 @@
1 +import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/models";
2 +import { scopedThreadKey, scopeThreadRef } from "@t3tools/client-runtime/environment";
3 +import { ChevronDownIcon, SquarePenIcon } from "lucide-react";
4 +import { memo } from "react";
5 +
6 +import { cn } from "~/lib/utils";
7 +import type { SidebarProjectSnapshot } from "../../sidebarProjectGrouping";
8 +import { useUiStateStore } from "../../uiStateStore";
9 +import { resolveSidebarFolderDot, resolveThreadLastVisitedAt } from "../Sidebar.logic";
10 +import { ProjectFavicon } from "../ProjectFavicon";
11 +import { Button } from "../ui/button";
12 +
13 +const FOLDER_DOT_CLASS_NAME = {
14 + attention: "bg-warning",
15 + failed: "bg-error",
16 + unread: "bg-success",
17 + working: "bg-info",
18 +} as const;
19 +
20 +const FOLDER_DOT_LABEL = {
21 + attention: ", needs you",
22 + failed: ", failed",
23 + unread: ", done",
24 + working: ", working",
25 +} as const;
26 +
27 +/** The folder's sidebar tree row; its thread rows name it as their parent. */
28 +export function sidebarFolderRowId(projectKey: string) {
29 + return `folder:${projectKey}`;
30 +}
31 +
32 +/**
33 + * A project folder in the boring sidebar. It reads like a shelf header: a trailing
34 + * count and chevron, with the count and a status dot only while it is closed, so a
35 + * closed folder still says when a hidden thread needs you.
36 + */
37 +export const SidebarProjectFolderHeader = memo(function SidebarProjectFolderHeader(props: {
38 + group: SidebarProjectSnapshot;
39 + collapsed: boolean;
40 + hiddenThreads: readonly EnvironmentThreadShell[];
41 + onToggle: (group: SidebarProjectSnapshot) => void;
42 + onNewThread: (group: SidebarProjectSnapshot) => void;
43 + onContextMenu: (group: SidebarProjectSnapshot, position: { x: number; y: number }) => void;
44 +}) {
45 + const { group, collapsed, hiddenThreads } = props;
46 + const rowId = sidebarFolderRowId(group.projectKey);
47 + const localLastVisitedAtById = useUiStateStore((state) => state.threadLastVisitedAtById);
48 + const dot = collapsed
49 + ? resolveSidebarFolderDot(
50 + hiddenThreads.map((thread) => ({
51 + ...thread,
52 + lastVisitedAt: resolveThreadLastVisitedAt(
53 + thread.lastVisitedAt,
54 + localLastVisitedAtById[
55 + scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id))
56 + ],
57 + ),
58 + })),
59 + )
60 + : null;
61 + return (
62 + <li
63 + data-testid="sidebar-project-folder"
64 + className="group/project-folder relative mt-2 list-none first:mt-0"
65 + >
66 + <button
67 + type="button"
68 + role="treeitem"
69 + tabIndex={-1}
70 + data-sidebar-row={rowId}
71 + aria-expanded={!collapsed}
72 + onClick={() => props.onToggle(group)}
73 + onContextMenu={(event) => {
74 + event.preventDefault();
75 + props.onContextMenu(group, { x: event.clientX, y: event.clientY });
76 + }}
77 + className="flex h-8 w-full cursor-pointer items-center gap-2.5 rounded-(--control-radius) px-(--sidebar-row-content-inset) text-left outline-none hover:bg-sidebar-row-hover focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring"
78 + >
79 + <ProjectFavicon project={group} className="size-4 shrink-0" />
80 + <span className="min-w-0 flex-1 truncate text-sm font-medium text-sidebar-foreground/90">
81 + {group.displayName}
82 + </span>
83 + {dot ? (
84 + <span className={cn("size-1.5 shrink-0 rounded-full", FOLDER_DOT_CLASS_NAME[dot])}>
85 + <span className="sr-only">{FOLDER_DOT_LABEL[dot]}</span>
86 + </span>
87 + ) : null}
88 + {collapsed && hiddenThreads.length > 0 ? (
89 + <span className="shrink-0 text-xs tabular-nums text-sidebar-muted-foreground group-hover/project-folder:invisible pointer-coarse:invisible">
90 + {hiddenThreads.length}
91 + </span>
92 + ) : null}
93 + <ChevronDownIcon
94 + aria-hidden
95 + className={cn(
96 + "size-3 shrink-0 text-sidebar-muted-foreground transition-transform",
97 + collapsed && "-rotate-90",
98 + )}
99 + />
100 + </button>
101 + {/* Sits over the count, which hides on hover, and left of the chevron. */}
102 + <span className="absolute inset-y-0 right-6 flex items-center opacity-0 focus-within:opacity-100 group-hover/project-folder:opacity-100 pointer-coarse:opacity-100">
103 + <Button
104 + data-sidebar-action-for={rowId}
105 + size="icon-xs"
106 + variant="ghost-muted"
107 + aria-label={`New thread in ${group.displayName}`}
108 + onClick={() => props.onNewThread(group)}
109 + >
110 + <SquarePenIcon aria-hidden />
111 + </Button>
112 + </span>
113 + </li>
114 + );
115 +});
apps/web/src/components/sidebar/SidebarThreadRow.tsx
+54 -30
@@ -515,9 +515,26 @@ const dropVerbBadge: Record<SidebarDropVerb, ReactNode> = {
515 ),
516 };
517
518 +const TOP_STATUS_ICONS = {
519 + working: CircleDashedIcon,
520 + waiting: CircleDotDashedIcon,
521 + input: MessageCircleQuestionIcon,
522 + request: UserRoundIcon,
523 + approval: ShieldQuestionIcon,
524 + failed: CircleAlertIcon,
525 + done: CircleCheckIcon,
526 + woke: AlarmClockIcon,
527 +} as const;
528 +
529 +function TopStatusIcon(props: { icon: keyof typeof TOP_STATUS_ICONS; className: string }) {
530 + const Icon = TOP_STATUS_ICONS[props.icon];
531 + return <Icon aria-hidden className={cn("shrink-0", props.className)} />;
532 +}
533 +
534 type SidebarThreadRowProps = {
535 thread: SidebarThreadSummary;
520 - variant: "card" | "slim";
536 + // "folder" is a one-line row inside a boring sidebar project folder.
537 + variant: "card" | "slim" | "folder";
538 navigationParent?: string | undefined;
539 variantAction: SidebarSweepAction;
540 settlementSupported: boolean;
@@ -997,7 +1014,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP
1014 className={cn(
1015 "min-w-0 flex-1 text-start text-sm transition-opacity motion-reduce:transition-none",
1016 shouldRecede ? "font-normal" : "font-medium",
1000 - variant === "card"
1017 + variant !== "slim"
1018 ? cn(
1019 "truncate",
1020 shouldRecede
@@ -1104,7 +1121,8 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP
1121 )
1122 ) : null;
1123
1107 - if (variant === "slim") {
1124 + if (variant !== "card") {
1125 + const inFolder = variant === "folder";
1126 return (
1127 <li
1128 data-thread-item={threadKey}
@@ -1126,9 +1144,14 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP
1144 data-sidebar-parent={props.navigationParent}
1145 aria-label={accessibility.label}
1146 aria-current={accessibility.current}
1129 - data-testid="sidebar-row-slim"
1147 + data-testid={inFolder ? "sidebar-row-folder" : "sidebar-row-slim"}
1148 aria-busy={isRegeneratingTitle || undefined}
1131 - className={cn(rowSurfaceClassName, "flex h-9 items-center gap-2.5 px-2.5")}
1149 + className={cn(
1150 + rowSurfaceClassName,
1151 + "flex h-9 items-center gap-2.5 px-2.5",
1152 + // Lines titles up with the folder name, past its chevron and icon.
1153 + inFolder && "ps-9",
1154 + )}
1155 onClick={handleClick}
1156 onDoubleClick={handleDoubleClick}
1157 onKeyDown={handleKeyDown}
@@ -1137,15 +1160,19 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP
1160 }
1161 >
1162 {accessibleTitle}
1140 - <span
1141 - className={cn(
1142 - "flex shrink-0 items-center transition-opacity",
1143 - (!props.isActive || variantAction === "unsettle") &&
1144 - "opacity-40 grayscale group-focus-within/sidebar-row:opacity-100 group-focus-within/sidebar-row:grayscale-0 group-hover/sidebar-row:opacity-100 group-hover/sidebar-row:grayscale-0",
1145 - )}
1146 - >
1147 - {props.project ? <ProjectFavicon project={props.project} className="size-4" /> : null}
1148 - </span>
1163 + {inFolder ? null : (
1164 + <span
1165 + className={cn(
1166 + "flex shrink-0 items-center transition-opacity",
1167 + (!props.isActive || variantAction === "unsettle") &&
1168 + "opacity-40 grayscale group-focus-within/sidebar-row:opacity-100 group-focus-within/sidebar-row:grayscale-0 group-hover/sidebar-row:opacity-100 group-hover/sidebar-row:grayscale-0",
1169 + )}
1170 + >
1171 + {props.project ? (
1172 + <ProjectFavicon project={props.project} className="size-4" />
1173 + ) : null}
1174 + </span>
1175 + )}
1176 {draftIndicator}
1177 {title}
1178 {pinIndicator}
@@ -1176,7 +1203,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP
1203 <AlarmClockIcon aria-hidden className="size-3" />
1204 {props.snoozeWakeLabelText}
1205 </span>
1179 - ) : isWoke ? (
1206 + ) : (inFolder ? isWokeStatus : isWoke) ? (
1207 <Tooltip>
1208 <TooltipTrigger
1209 render={
@@ -1193,6 +1220,17 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP
1220 />
1221 <TooltipPopup side="top">Dismiss Woke notification</TooltipPopup>
1222 </Tooltip>
1223 + ) : inFolder && topStatus ? (
1224 + // Folder rows have no status line, so the status takes the time slot.
1225 + <span
1226 + className={cn(
1227 + "inline-flex items-center gap-1 text-xs font-medium",
1228 + topStatus.className,
1229 + )}
1230 + >
1231 + <TopStatusIcon icon={topStatus.icon} className="size-3" />
1232 + {topStatus.label}
1233 + </span>
1234 ) : (
1235 <span className="text-xs">
1236 <RelativeTimeLabel
@@ -1377,21 +1415,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThreadRowP
1415 topStatus.className,
1416 )}
1417 >
1380 - {topStatus.icon === "working" ? (
1381 - <CircleDashedIcon aria-hidden className="size-4 shrink-0" />
1382 - ) : topStatus.icon === "waiting" ? (
1383 - <CircleDotDashedIcon aria-hidden className="size-4 shrink-0" />
1384 - ) : topStatus.icon === "input" ? (
1385 - <MessageCircleQuestionIcon aria-hidden className="size-4 shrink-0" />
1386 - ) : topStatus.icon === "request" ? (
1387 - <UserRoundIcon aria-hidden className="size-4 shrink-0" />
1388 - ) : topStatus.icon === "approval" ? (
1389 - <ShieldQuestionIcon aria-hidden className="size-4 shrink-0" />
1390 - ) : topStatus.icon === "failed" ? (
1391 - <CircleAlertIcon aria-hidden className="size-4 shrink-0" />
1392 - ) : topStatus.icon === "done" ? (
1393 - <CircleCheckIcon aria-hidden className="size-4 shrink-0" />
1394 - ) : null}
1418 + <TopStatusIcon icon={topStatus.icon} className="size-4" />
1419 {/* Not a live region: a collapsed sidebar is inert, so
1420 BackgroundThreadAnnouncer and the open thread's
1421 timeline speak status changes instead. */}
apps/web/src/components/ui/sidebar.tsx
+1 -1
@@ -97,7 +97,7 @@ function useSidebarVisibility() {
97 return isMobile ? openMobile : open;
98 }
99
100 -// Same breakpoint as useIsMobile, also read when a shortcut fires.
100 +// The `max-md` breakpoint, also read when a shortcut fires.
101 const SIDEBAR_MOBILE_QUERY = "(max-width: 767px)";
102
103 function isMobileViewport(): boolean {
apps/web/src/connection/desktopLocal.ts
-4
@@ -26,10 +26,6 @@ export function desktopLocalBackendId(target: ConnectionTarget): string | null {
26 : null;
27 }
28
29 -export function isWslConnectionTarget(target: ConnectionTarget): boolean {
30 - return desktopLocalBackendId(target)?.startsWith("wsl:") === true;
31 -}
32 -
29 export type DesktopSecondaryBootstrapsRead =
30 | {
31 readonly _tag: "Success";
apps/web/src/hooks/useMediaQuery.ts
-4
@@ -77,7 +77,3 @@ export function useMediaQuery(query: BreakpointQuery | MediaQueryInput | (string
77
78 return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
79 }
80 -
81 -export function useIsMobile(): boolean {
82 - return useMediaQuery("max-md");
83 -}
apps/web/src/hooks/useSettings.ts
+5 -5
@@ -415,11 +415,11 @@ export function useEnvironmentIdentificationMode(): EnvironmentIdentificationMod
415 });
416 }
417
418 -/** Wait for hydration: swapping sidebar implementations after mount remounts the whole tree. */
419 -export function useLegacySidebarEnabled(): boolean {
420 - const settingsHydrated = useClientSettingsHydrated();
421 - const legacySidebarEnabled = useClientSettings((settings) => settings.legacySidebarEnabled);
422 - return settingsHydrated && legacySidebarEnabled;
418 +/** Legacy sidebar opt-ins still count, so those users land in the boring sidebar. */
419 +export function useBoringSidebarEnabled(): boolean {
420 + return useClientSettings(
421 + (settings) => settings.boringSidebarEnabled || settings.legacySidebarEnabled,
422 + );
423 }
424
425 export async function prepareModelPreferencesPatch(
apps/web/src/shortcuts/chatRouteCommands.ts
+4 -2
@@ -117,8 +117,10 @@ export function installChatRouteCommands(router: AnyRouter): () => void {
117 void scratch.startScratchThread(environmentId);
118 },
119 "chat.new": (event) => {
120 - // Pre-hydration settings are the defaults, where the legacy sidebar is off.
121 - if (!getClientSettings().legacySidebarEnabled && readProjectGroupCount() > 1) {
120 + // The boring sidebar's folders already show the context, so it starts in
121 + // the current project like the legacy sidebar did.
122 + const { boringSidebarEnabled, legacySidebarEnabled } = getClientSettings();
123 + if (!boringSidebarEnabled && !legacySidebarEnabled && readProjectGroupCount() > 1) {
124 claim(event);
125 openCommandPalette({ open: "new-thread-in" });
126 return;
apps/web/src/state/use-orchestration-command.ts
+1 -2
@@ -14,8 +14,7 @@ import { AsyncResult } from "effect/reactivity";
14 import { readEnvironmentScope } from "./session";
15 import { useAtomCommand } from "./use-atom-command";
16
17 -export const ORCHESTRATION_OPERATE_DENIED_MESSAGE =
18 - "This connection cannot change threads or projects.";
17 +const ORCHESTRATION_OPERATE_DENIED_MESSAGE = "This connection cannot change threads or projects.";
18
19 export function useOrchestrationCommand<W extends { readonly environmentId: EnvironmentId }, A, E>(
20 command: AtomCommand<W, A, E>,
docs/user/thread-sidebar.md
+9
@@ -139,6 +139,15 @@ choice.
139 While this is on, the active list is ordered by when each thread last came back to you, so you
140 cannot drag or move threads within it. Your saved order returns when you turn it off.
141
142 +### Group threads by project (beta)
143 +
144 +Turn on **Settings → Labs → Boring sidebar (group by project)** on web and desktop to put active
145 +threads in a folder for each project. Click a folder to open or close it. A closed folder shows how
146 +many threads it holds, and a dot when one of them needs you. Use the pen button on a folder, or
147 +right-click it, to start a thread in that project. Pinned threads stay above the folders, and
148 +Snoozed and Settled stay below them. In this mode you cannot drag threads, and the Working section
149 +is off. Each device keeps its own choice.
150 +
151 ## Settle finished work
152
153 Choose **Settle thread** from its menu to move finished work out of the active list
packages/client-runtime/src/state/projectGrouping.ts
+1 -1
@@ -78,7 +78,7 @@ export function derivePhysicalProjectKey(
78 return derivePhysicalProjectKeyFromPath(project.environmentId, project.workspaceRoot);
79 }
80
81 -export function deriveProjectGroupingOverrideKey(
81 +function deriveProjectGroupingOverrideKey(
82 project: Pick<EnvironmentProject, "environmentId" | "workspaceRoot">,
83 ): string {
84 return derivePhysicalProjectKey(project);
packages/contracts/src/settings.ts
+4 -14
@@ -72,16 +72,6 @@ export const SidebarProjectGroupingMode = Schema.Literals([
72 ]);
73 export type SidebarProjectGroupingMode = typeof SidebarProjectGroupingMode.Type;
74 const DEFAULT_SIDEBAR_PROJECT_GROUPING_MODE: SidebarProjectGroupingMode = "repository";
75 -export const MIN_SIDEBAR_THREAD_PREVIEW_COUNT = 1;
76 -export const MAX_SIDEBAR_THREAD_PREVIEW_COUNT = 15;
77 -export const SidebarThreadPreviewCount = Schema.Int.check(
78 - Schema.isBetween({
79 - minimum: MIN_SIDEBAR_THREAD_PREVIEW_COUNT,
80 - maximum: MAX_SIDEBAR_THREAD_PREVIEW_COUNT,
81 - }),
82 -);
83 -export type SidebarThreadPreviewCount = typeof SidebarThreadPreviewCount.Type;
84 -const DEFAULT_SIDEBAR_THREAD_PREVIEW_COUNT: SidebarThreadPreviewCount = 6;
75 export const MIN_SIDEBAR_AUTO_SETTLE_AFTER_DAYS = 1;
76 export const MAX_SIDEBAR_AUTO_SETTLE_AFTER_DAYS = 90;
77 export const SidebarAutoSettleAfterDays = Schema.Number.check(
@@ -479,6 +469,9 @@ export const ClientSettingsSchema = Schema.Struct({
469 ),
470 proactivePanelsEnabled: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
471 showSkillsInSlashMenu: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
472 + boringSidebarEnabled: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
473 + // Opt-in for the removed legacy sidebar. Still read so those users land in
474 + // the boring sidebar; the boring sidebar toggle clears it.
475 legacySidebarEnabled: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
476 sidebarWorkingShelfEnabled: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
477 sidebarProjectGroupingMode: SidebarProjectGroupingMode.pipe(
@@ -494,9 +487,6 @@ export const ClientSettingsSchema = Schema.Struct({
487 sidebarThreadSortOrder: SidebarThreadSortOrder.pipe(
488 Schema.withDecodingDefault(Effect.succeed(DEFAULT_SIDEBAR_THREAD_SORT_ORDER)),
489 ),
497 - sidebarThreadPreviewCount: SidebarThreadPreviewCount.pipe(
498 - Schema.withDecodingDefault(Effect.succeed(DEFAULT_SIDEBAR_THREAD_PREVIEW_COUNT)),
499 - ),
490 timestampFormat: TimestampFormat.pipe(
491 Schema.withDecodingDefault(Effect.succeed(DEFAULT_TIMESTAMP_FORMAT)),
492 ),
@@ -1712,6 +1702,7 @@ export const ClientSettingsPatch = Schema.Struct({
1702 followUpBehavior: Schema.optionalKey(Schema.Literals(["queue", "steer"])),
1703 proactivePanelsEnabled: Schema.optionalKey(Schema.Boolean),
1704 showSkillsInSlashMenu: Schema.optionalKey(Schema.Boolean),
1705 + boringSidebarEnabled: Schema.optionalKey(Schema.Boolean),
1706 legacySidebarEnabled: Schema.optionalKey(Schema.Boolean),
1707 sidebarWorkingShelfEnabled: Schema.optionalKey(Schema.Boolean),
1708 sidebarProjectGroupingMode: Schema.optionalKey(SidebarProjectGroupingMode),
@@ -1720,7 +1711,6 @@ export const ClientSettingsPatch = Schema.Struct({
1711 ),
1712 sidebarProjectSortOrder: Schema.optionalKey(SidebarProjectSortOrder),
1713 sidebarThreadSortOrder: Schema.optionalKey(SidebarThreadSortOrder),
1723 - sidebarThreadPreviewCount: Schema.optionalKey(SidebarThreadPreviewCount),
1714 timestampFormat: Schema.optionalKey(TimestampFormat),
1715 snapShotEnabled: Schema.optionalKey(Schema.Boolean),
1716 snapShotIncludeAccessibility: Schema.optionalKey(Schema.Boolean),
pnpm-lock.yaml
-8
@@ -1033,9 +1033,6 @@ importers:
1033 '@fontsource-variable/inter':
1034 specifier: ^5.3.0
1035 version: 5.3.0
1036 - '@formkit/auto-animate':
1037 - specifier: ^0.9.0
1038 - version: 0.9.0
1036 '@legendapp/list':
1037 specifier: 3.3.5
1038 version: 3.3.5(patch_hash=6cbdacd8c380d9a5afb9f73d4198dc2cc44be6ef28a955b1183c781469307896)(react-dom@19.3.0(react@19.3.0))(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0)
@@ -4311,9 +4308,6 @@ packages:
4308 '@fontsource-variable/inter@5.3.0':
4309 resolution: {integrity: sha512-OupL48va4JNofb97w6NYeF9S7W/kHNKM0Er8Dem5nqi4jeOLrVJDoE8tZEpnMJmtkvNbB1EIPPwHcdkF6b1oUA==}
4310
4314 - '@formkit/auto-animate@0.9.0':
4315 - resolution: {integrity: sha512-VhP4zEAacXS3dfTpJpJ88QdLqMTcabMg0jwpOSxZ/VzfQVfl3GkZSCZThhGC5uhq/TxPHPzW0dzr4H9Bb1OgKA==}
4316 -
4311 '@hono/node-server@1.19.17':
4312 resolution: {integrity: sha512-dSneS5qhiauZWGDCeK4o695Xd9nUNjviSZCMQrj10eetr8Uln1ucn6bbphOM6UynAMMtNIzZNSpL9vnASJwrPQ==}
4313 engines: {node: '>=18.14.1'}
@@ -14427,8 +14421,6 @@ snapshots:
14421
14422 '@fontsource-variable/inter@5.3.0': {}
14423
14430 - '@formkit/auto-animate@0.9.0': {}
14431 -
14424 '@hono/node-server@1.19.17(hono@4.13.7)':
14425 dependencies:
14426 hono: 4.13.7