Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

thread-list-v2-items.tsx

1,373 lines48.9 KB

1import * as Dialog from "../../components/ui/Dialog";
2import type { ThreadRowProviderInstance } from "./thread-provider-instance";
3import {
4 THREAD_LIST_V2_MONO_FONT as MONO_FONT,
5 THREAD_LIST_V2_ROW_CONTENT_CLASS_NAME,
6 THREAD_LIST_V2_ROW_DIVIDERS,
7 selectedThreadRowColors,
8 getThreadListV2NewBranchMenuTitle,
9 getThreadListV2RowAppearance,
10} from "./thread-list-v2-row-appearance";
11import { RowPressable } from "../../components/ui/RowPressable";
12import { CustomSnoozeSheet } from "./CustomSnoozeSheet";
13import { appAtomRegistry } from "../../state/atom-registry";
14import { threadArrangementOpenAtom } from "../../state/thread-order";
15import { threadEnvironment } from "../../state/threads";
16import { useAtomCommand } from "../../state/use-atom-command";
17import { useVisibleSecondClock } from "./use-visible-second-clock";
18import type { ThreadMoveDestination } from "./threadOrder";
19import type {
20 EnvironmentProject,
21 EnvironmentThreadShell,
22} from "@t3tools/client-runtime/state/shell";
23import type { EnvironmentThreadSearchMatch } from "@t3tools/client-runtime/state/thread-search";
24import {
25 formatWorkingDurationLabel,
26 resolveThreadWorkingStartedAt,
27} from "@t3tools/client-runtime/state/models";
28import { AuthOrchestrationOperateScope, type EnvironmentMachineKind } from "@t3tools/contracts";
29import { canSnooze, resolveSnoozePresets } from "@t3tools/client-runtime/state/thread-settled";
30import type { MenuAction } from "@react-native-menu/menu";
31import { memo, useCallback, useEffect, useMemo, useState, type ComponentProps } from "react";
32import { Pressable, useWindowDimensions, View } from "react-native";
33import type { SwipeableMethods } from "react-native-gesture-handler/ReanimatedSwipeable";
34​
35import type { ThreadListProvider } from "../../state/thread-list-environments";
36import { SymbolView, type AppSymbolName } from "../../components/ui/AppSymbol";
37import { AppText as Text } from "../../components/ui/AppText";
38import { Menu } from "../../components/ui/Menu";
39import { EnvironmentMachineSymbol } from "../../components/EnvironmentMachineSymbol";
40import { ProjectFavicon } from "../../components/ProjectFavicon";
41import { ProviderIcon, ProviderInstanceIcon } from "../../components/ProviderIcon";
42import { cn } from "../../lib/cn";
43import { copyTextWithHaptic } from "../../lib/copyTextWithHaptic";
44import { useUniwindTheme } from "../../lib/useUniwindTheme";
45import { useEnvironmentScope } from "../../state/session";
46import type { PendingNewTask } from "../../state/use-pending-new-tasks";
47import {
48 resolveThreadPrBadgeAction,
49 type ThreadPrPresentation,
50} from "../../state/thread-pr-presentation";
51import { useThreadPr } from "../../state/use-thread-pr";
52import { useSwipeRowDormant } from "../home/swipe-row-activation";
53import { ThreadSwipeable } from "../home/thread-swipe-actions";
54import { buildThreadTitleRegenerationMenuItems } from "./thread-title-regeneration-menu";
55import {
56 THREAD_LIST_V2_SETTLED_PAGE_COUNT,
57 resolveThreadListV2SnoozeGateExpiryMs,
58 resolveThreadListV2SnoozeMenuSelection,
59 threadHasUnseenCompletion,
60 resolveThreadListV2Status,
61 resolveThreadListV2ProviderDrivers,
62 resolveThreadListV2SwipeActions,
63 type ThreadListV2Status,
64} from "./threadListV2";
65import { QueuedMessageIcon } from "./queued-message-icon";
66import { shouldRecedeThreadRow } from "./thread-row-emphasis";
67import { ThreadSearchMatchExcerpt } from "./thread-search-match";
68import { PullRequestGlyph } from "../pull-requests/pullRequestGlyphs";
69import { pullRequestStatus } from "../pull-requests/pullRequestStatus";
70​
71interface StatusLabel {
72 readonly label: string;
73 readonly icon: AppSymbolName;
74 readonly className: string;
75 readonly iconTintClassName: string;
77const STATUS_LABEL_BY_STATUS: Partial<Record<ThreadListV2Status, StatusLabel>> = {
78 approval: {
79 label: "Approval",
80 icon: "exclamationmark.shield",
81 className: "text-warning-foreground",
82 iconTintClassName: "accent-warning-foreground",
83 },
84 input: {
85 label: "Input",
86 icon: "questionmark.bubble",
87 className: "text-adaptive-indigo-600-300",
88 iconTintClassName: "accent-adaptive-indigo-600-300",
89 },
90 working: {
91 label: "Working",
92 icon: "circle.dashed",
93 className: "text-adaptive-sky-600-400",
94 iconTintClassName: "accent-adaptive-sky-600-400",
95 },
96 waiting: {
97 label: "Waiting",
98 icon: "circle.dashed.inset.filled",
99 className: "text-foreground-muted",
100 iconTintClassName: "accent-foreground-muted",
101 },
102 failed: {
103 label: "Failed",
104 icon: "exclamationmark.circle",
105 className: "text-danger-foreground",
106 iconTintClassName: "accent-danger-foreground",
107 },
108 limited: {
109 label: "Limited",
110 icon: "exclamationmark.circle",
111 className: "text-warning-foreground",
112 iconTintClassName: "accent-warning-foreground",
113 },
114};
115const DONE_STATUS_LABEL: StatusLabel = {
116 label: "Done",
117 icon: "checkmark.circle",
118 className: "text-adaptive-emerald-700-300",
119 iconTintClassName: "accent-adaptive-emerald-700-300",
120};
121​
122function ThreadListV2Duration(props: { readonly startedAt: string | null }) {
123 const startedAtMs = Date.parse(props.startedAt ?? "");
124 const nowMs = useVisibleSecondClock(Number.isFinite(startedAtMs));
125 if (!Number.isFinite(startedAtMs)) return null;
126 return ` ${formatWorkingDurationLabel(nowMs - startedAtMs)}`;
128​
129const CARD_MENU_ACTIONS: MenuAction[] = [
130 { id: "settle", title: "Settle", image: "checkmark" },
131 { id: "delete", title: "Delete", image: "trash", attributes: { destructive: true } },
132];
133​
134const SLIM_MENU_ACTIONS: MenuAction[] = [
135 { id: "unsettle", title: "Un-settle", image: "arrow.uturn.backward" },
136 { id: "delete", title: "Delete", image: "trash", attributes: { destructive: true } },
137];
138​
139const SNOOZED_MENU_ACTIONS: MenuAction[] = [
140 { id: "unsnooze", title: "Wake thread", image: "clock" },
141 { id: "delete", title: "Delete", image: "trash", attributes: { destructive: true } },
142];
143​
144const LEGACY_MENU_ACTIONS: MenuAction[] = [
145 { id: "archive", title: "Archive", image: "archivebox" },
146 { id: "delete", title: "Delete", image: "trash", attributes: { destructive: true } },
147];
148​
149const SIDEBAR_V2_ROW_RADIUS = 12;
150​
151function ThreadListV2Section(props: {
152 readonly label: string;
153 readonly pane?: "screen" | "sidebar";
154 readonly tone?: "default" | "snoozed";
155 readonly disclosure?: {
156 readonly expanded: boolean;
157 readonly disabled?: boolean;
158 readonly onToggle: () => void;
159 readonly accessibilityLabel: string;
160 readonly accessibilityHint: string;
161 };
162}) {
163 const snoozed = props.tone === "snoozed";
164 const sidebarPane = props.pane === "sidebar";
165 const className = cn(
166 "mb-1.5 mt-4 flex-row items-center gap-2.5",
167 props.pane === "sidebar" ? "px-3" : "px-5",
168 );
169 const content = (
170 <>
171 <Text
172 className={cn(
173 "text-xs font-t3-medium",
174 sidebarPane
175 ? "text-drawer-foreground-muted"
176 : snoozed
177 ? "text-foreground-secondary"
178 : "text-foreground-tertiary",
179 )}
180 >
181 {props.label}
182 </Text>
183 <View
184 className={cn(
185 "h-px flex-1",
186 snoozed ? "bg-primary/20" : sidebarPane ? "bg-drawer-border" : "bg-border",
187 )}
188 />
189 {props.disclosure ? (
190 <SymbolView
191 name="chevron.down"
192 size={10}
193 tintColorClassName={
194 sidebarPane
195 ? "accent-drawer-foreground-muted"
196 : snoozed
197 ? "accent-icon-muted"
198 : "accent-foreground-muted"
199 }
200 type="monochrome"
201 style={{ transform: [{ rotate: props.disclosure.expanded ? "180deg" : "0deg" }] }}
202 />
203 ) : null}
204 </>
205 );
206​
207 return props.disclosure ? (
208 <Pressable
209 accessibilityHint={props.disclosure.accessibilityHint}
210 accessibilityLabel={props.disclosure.accessibilityLabel}
211 accessibilityRole="button"
212 accessibilityState={{
213 disabled: props.disclosure.disabled,
214 expanded: props.disclosure.expanded,
215 }}
216 className={className}
217 disabled={props.disclosure.disabled}
218 onPress={props.disclosure.onToggle}
219 style={({ pressed }) => ({ opacity: pressed ? 0.6 : 1 })}
220 >
221 {content}
222 </Pressable>
223 ) : (
224 <View className={className}>{content}</View>
225 );
227​
228export const ThreadListV2SectionDivider = memo(function ThreadListV2SectionDivider(props: {
229 readonly label: string;
230 readonly pane?: "screen" | "sidebar";
231}) {
232 return <ThreadListV2Section {...props} />;
233});
234​
235type ThreadListV2ShelfHeaderProps = {
236 readonly count: number;
237 readonly disabled?: boolean;
238 readonly expanded: boolean;
239 readonly onToggle: () => void;
240 readonly pane?: "screen" | "sidebar";
241};
242​
243const SHELF_LABEL = { working: "Working", snoozed: "Snoozed", settled: "Settled" } as const;
244​
245function ThreadListV2ShelfHeader(
246 props: ThreadListV2ShelfHeaderProps & { readonly kind: keyof typeof SHELF_LABEL },
247) {
248 const label = SHELF_LABEL[props.kind];
249 return (
250 <ThreadListV2Section
251 label={props.expanded ? label : `${label} (${props.count})`}
252 pane={props.pane}
253 tone={props.kind === "snoozed" ? "snoozed" : "default"}
254 disclosure={{
255 expanded: props.expanded,
256 disabled: props.disabled,
257 onToggle: props.onToggle,
258 accessibilityLabel: `${props.count} ${props.kind} ${props.count === 1 ? "thread" : "threads"}`,
259 accessibilityHint: `${props.expanded ? "Collapses" : "Expands"} the ${props.kind} threads.`,
260 }}
261 />
262 );
264​
265export const ThreadListV2WorkingShelfHeader = memo(function ThreadListV2WorkingShelfHeader(
266 props: ThreadListV2ShelfHeaderProps,
267) {
268 return <ThreadListV2ShelfHeader {...props} kind="working" />;
269});
270​
271export const ThreadListV2SnoozedShelfHeader = memo(function ThreadListV2SnoozedShelfHeader(
272 props: ThreadListV2ShelfHeaderProps,
273) {
274 return <ThreadListV2ShelfHeader {...props} kind="snoozed" />;
275});
276​
277export const ThreadListV2SettledShelfHeader = memo(function ThreadListV2SettledShelfHeader(
278 props: ThreadListV2ShelfHeaderProps,
279) {
280 return <ThreadListV2ShelfHeader {...props} kind="settled" />;
281});
282​
283export const ThreadListV2ShowMoreRow = memo(function ThreadListV2ShowMoreRow(props: {
284 readonly pane?: "screen" | "sidebar";
285 readonly hiddenCount: number;
286 readonly onPress: () => void;
287}) {
288 return (
289 <Pressable
290 accessibilityRole="button"
291 accessibilityLabel={`Show ${Math.min(props.hiddenCount, THREAD_LIST_V2_SETTLED_PAGE_COUNT)} more settled threads`}
292 onPress={props.onPress}
293 className="mx-4 mt-2 items-center rounded-lg border border-dashed border-border py-2.5"
294 style={({ pressed }) => ({ opacity: pressed ? 0.6 : 1 })}
295 >
296 <Text
297 className={
298 props.pane === "sidebar"
299 ? "text-xs font-t3-medium text-drawer-foreground-muted"
300 : "text-xs font-t3-medium text-foreground-muted"
301 }
302 >
303 Show more ({props.hiddenCount} settled hidden)
304 </Text>
305 </Pressable>
306 );
307});
308​
309const PENDING_TASK_MENU_ACTIONS: MenuAction[] = [
310 { id: "delete", title: "Delete", image: "trash", attributes: { destructive: true } },
311];
312​
313const DRAFT_TASK_MENU_ACTIONS: MenuAction[] = [
314 { id: "delete", title: "Discard", image: "trash", attributes: { destructive: true } },
315];
316​
317export const ThreadListV2PendingRow = memo(function ThreadListV2PendingRow(props: {
318 readonly pendingTask: PendingNewTask;
319 readonly project: EnvironmentProject | null;
320 readonly projectTitle?: string;
321 readonly environmentLabel: string | null;
322 readonly environmentMachine?: EnvironmentMachineKind;
323 readonly pane?: "screen" | "sidebar";
324 readonly showPendingDivider: boolean;
325 readonly showTrailingDivider?: boolean;
326 readonly onSelectPendingTask: (pendingTask: PendingNewTask) => void;
327 readonly onDeletePendingTask: (pendingTask: PendingNewTask) => void;
328}) {
329 const { pendingTask, onSelectPendingTask, onDeletePendingTask } = props;
330 const sidebarPane = props.pane === "sidebar";
331 const isDraft = pendingTask.kind === "draft";
332 const projectTitle = props.projectTitle ?? props.project?.title ?? pendingTask.projectTitle ?? "";
333 const branch = pendingTask.branch;
334​
335 const handleMenuAction = useCallback(
336 ({ nativeEvent }: { readonly nativeEvent: { readonly event: string } }) => {
337 if (nativeEvent.event === "delete") onDeletePendingTask(pendingTask);
338 },
339 [onDeletePendingTask, pendingTask],
340 );
341​
342 const rowContent = (
343 <>
344 <View className="flex-row items-center gap-1.5">
345 {props.project ? (
346 <ProjectFavicon
347 environmentId={pendingTask.environmentId}
348 faviconPath={props.project.faviconPath}
349 projectIcon={props.project.projectIcon}
350 size={15}
351 projectTitle={props.project.title}
352 workspaceRoot={props.project.workspaceRoot}
353 />
354 ) : null}
355 <Text
356 className={cn(
357 "flex-1 text-sm font-t3-medium text-foreground-muted",
358 sidebarPane && "text-drawer-foreground-muted",
359 )}
360 numberOfLines={1}
361 >
362 {projectTitle}
363 </Text>
364 {isDraft ? (
365 <View className="flex-row items-center gap-1">
366 <SymbolView
367 name="square.and.pencil"
368 size={10}
369 tintColorClassName="accent-adaptive-amber-700-300"
370 type="monochrome"
371 />
372 <Text className="text-xs text-adaptive-amber-700-300">Draft</Text>
373 </View>
374 ) : (
375 <Text
376 className={cn(
377 "text-xs text-foreground-tertiary",
378 sidebarPane && "text-drawer-foreground-muted",
379 )}
380 >
381 Sends on reconnect
382 </Text>
383 )}
384 </View>
385 <Text
386 className={cn(
387 "mt-1 text-base font-t3-medium text-foreground",
388 sidebarPane && "text-drawer-foreground",
389 )}
390 numberOfLines={1}
391 >
392 {pendingTask.title}
393 </Text>
394 {branch || props.environmentLabel ? (
395 <View className="mt-1 flex-row items-center gap-1">
396 <Text
397 className={cn(
398 "shrink text-xs text-foreground-muted",
399 sidebarPane && "text-drawer-foreground-muted",
400 )}
401 numberOfLines={1}
402 >
403 {branch ? (
404 <Text
405 className={cn(
406 "text-xs text-foreground-muted",
407 sidebarPane && "text-drawer-foreground-muted",
408 )}
409 style={{ fontFamily: MONO_FONT }}
410 >
411 {branch}
412 </Text>
413 ) : null}
414 {branch && props.environmentLabel ? " · " : null}
415 {props.environmentLabel ? (
416 <Text
417 className={cn(
418 "text-xs text-foreground-tertiary",
419 sidebarPane && "text-drawer-foreground-muted",
420 )}
421 >
422 {props.environmentLabel}
423 </Text>
424 ) : null}
425 </Text>
426 {props.environmentLabel && props.environmentMachine ? (
427 <EnvironmentMachineSymbol
428 kind={props.environmentMachine}
429 size={11}
430 tintColorClassName={
431 sidebarPane ? "accent-drawer-foreground-muted" : "accent-foreground-tertiary"
432 }
433 />
434 ) : null}
435 </View>
436 ) : null}
437 </>
438 );
439​
440 return (
441 <>
442 {props.showPendingDivider ? (
443 <ThreadListV2SectionDivider label="Unsent" pane={props.pane} />
444 ) : null}
445 <Menu
446 actions={isDraft ? DRAFT_TASK_MENU_ACTIONS : PENDING_TASK_MENU_ACTIONS}
447 onPressAction={handleMenuAction}
448 shouldOpenOnLongPress
449 >
450 <RowPressable
451 accessibilityHint={
452 isDraft
453 ? "Opens the draft in the new task composer"
454 : "Sends when the environment reconnects. Opens the task for editing"
455 }
456 accessibilityLabel={pendingTask.title}
457 accessibilityRole="button"
458 key={pendingTask.key}
459 className={sidebarPane ? "bg-drawer" : "bg-screen"}
460 interactionClassName={sidebarPane ? "bg-thread-hover" : "bg-row-hover"}
461 onPress={() => onSelectPendingTask(pendingTask)}
462 style={
463 sidebarPane
464 ? {
465 borderRadius: SIDEBAR_V2_ROW_RADIUS,
466 paddingHorizontal: 12,
467 paddingVertical: 10,
468 }
469 : undefined
470 }
471 >
472 {sidebarPane ? (
473 rowContent
474 ) : (
475 <View>
476 <View className="px-5 py-2.5">{rowContent}</View>
477 {props.showTrailingDivider !== false ? (
478 <View className="ml-5 h-px bg-border-subtle" />
479 ) : null}
480 </View>
481 )}
482 </RowPressable>
483 </Menu>
484 </>
485 );
486});
487​
488export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
489 readonly thread: EnvironmentThreadShell;
490 readonly variant: "card" | "slim";
491 readonly hasQueuedMessages?: boolean;
492 readonly snoozed?: boolean;
493 readonly pinned?: boolean;
494 readonly wokeAt: string | null;
495 readonly snoozeWakeLabelText?: string;
496 readonly timeLabel: string;
497 readonly snoozePresetMinute: string;
498 readonly project: EnvironmentProject | null;
499 readonly projectTitle?: string;
500 readonly providers: ReadonlyArray<ThreadListProvider> | undefined;
501 readonly providerInstance: ThreadRowProviderInstance | null;
502 readonly environmentLabel: string | null;
503 readonly environmentMachine?: EnvironmentMachineKind;
504 readonly pane?: "screen" | "sidebar";
505 readonly showTrailingDivider?: boolean;
506 readonly selected?: boolean;
507 readonly fullSwipeWidth?: number;
508 readonly onSelectThread: (thread: EnvironmentThreadShell) => void;
509 readonly onOpenThreadPullRequests: (
510 thread: EnvironmentThreadShell,
511 pr: ThreadPrPresentation,
512 ) => void;
513 readonly onDeleteThread: (thread: EnvironmentThreadShell) => void;
514 readonly onNewThreadOnBranch: (thread: EnvironmentThreadShell) => void;
515 readonly onRenameThread: (thread: EnvironmentThreadShell) => void;
516 readonly onRegenerateThreadTitle: (thread: EnvironmentThreadShell) => void;
517 readonly onSettleThread: (thread: EnvironmentThreadShell) => Promise<boolean>;
518 readonly onSnoozeThread: (thread: EnvironmentThreadShell, snoozedUntil: string) => void;
519 readonly onUnsnoozeThread: (thread: EnvironmentThreadShell) => void;
520 readonly onUnsettleThread: (thread: EnvironmentThreadShell) => void;
521 readonly onArchiveThread: (thread: EnvironmentThreadShell) => void;
522 readonly onPinThread: (thread: EnvironmentThreadShell) => void;
523 readonly onUnpinThread: (thread: EnvironmentThreadShell) => void;
524 readonly onSetThreadAutoSettle: (thread: EnvironmentThreadShell, enabled: boolean) => void;
525 readonly settlementSupported: boolean;
526 readonly snoozeSupported: boolean;
527 readonly pinningSupported: boolean;
528 readonly autoSettleOptOutSupported: boolean;
529 readonly titleRegenerationSupported: boolean;
530 readonly reorderSupported?: boolean;
531 readonly onMoveThread?: (
532 thread: EnvironmentThreadShell,
533 direction: ThreadMoveDestination,
534 ) => void;
535 readonly canMoveUp?: boolean;
536 readonly canMoveDown?: boolean;
537 readonly onSwipeableWillOpen: (methods: SwipeableMethods) => void;
538 readonly onSwipeableClose: (methods: SwipeableMethods) => void;
539 readonly activationKey?: string;
540 readonly searchMatch?: EnvironmentThreadSearchMatch;
541 readonly searchQuery?: string;
542 readonly simultaneousSwipeGesture?: ComponentProps<typeof ThreadSwipeable>["simultaneousWith"];
543}) {
544 const { width: windowWidth } = useWindowDimensions();
545 const {
546 thread,
547 variant,
548 onSelectThread,
549 onOpenThreadPullRequests,
550 onDeleteThread,
551 onRenameThread,
552 onRegenerateThreadTitle,
553 onNewThreadOnBranch,
554 onSettleThread,
555 onSnoozeThread,
556 onUnsnoozeThread,
557 onUnsettleThread,
558 onArchiveThread,
559 onPinThread,
560 onUnpinThread,
561 onSetThreadAutoSettle,
562 onMoveThread,
563 } = props;
564 const snoozedRow = props.snoozed === true;
565 const pinnedRow = props.pinned === true;
566 const dormant = useSwipeRowDormant(props.activationKey);
567​
568 const { providerDrivers, providerIconUrl } = useMemo(() => {
569 const provider = props.providers?.find(
570 (candidate) =>
571 candidate.instanceId ===
572 (thread.runtime?.providerInstanceId ?? thread.modelSelection.instanceId),
573 );
574 return {
575 providerDrivers: resolveThreadListV2ProviderDrivers(thread, props.providers),
576 providerIconUrl: provider?.iconUrl,
577 };
578 }, [thread, props.providers]);
579​
580 const providerInstance = props.providerInstance;
581 const pr = useThreadPr(thread);
582 const prBadgeLabel = pr ? resolveThreadPrBadgeAction(pr).accessibilityLabel : null;
583 const handleOpenPullRequests = useCallback(() => {
584 if (pr) onOpenThreadPullRequests(thread, pr);
585 }, [onOpenThreadPullRequests, pr, thread]);
586​
587 const theme = useUniwindTheme();
588 const sidebarPane = props.pane === "sidebar";
589 const selected = props.selected === true;
590 const rowAppearance = getThreadListV2RowAppearance(theme, sidebarPane, selected);
591​
592 const status = resolveThreadListV2Status(thread);
593 const isUnread = status === "ready" && threadHasUnseenCompletion(thread);
594 const workingLabel = STATUS_LABEL_BY_STATUS[status];
595 const showsWoke = status === "ready" && props.wokeAt !== null;
596 const statusLabel =
597 (status === "working" && workingLabel !== undefined && thread.goal?.status === "active"
598 ? { ...workingLabel, label: "Goal" }
599 : workingLabel) ?? (isUnread ? DONE_STATUS_LABEL : undefined);
600 const recede = shouldRecedeThreadRow({ status, selected });
601 const timeLabel = props.timeLabel;
602​
603 const visitThread = useAtomCommand(threadEnvironment.visit, { reportFailure: false });
604 const handleAcknowledgeWoke = useCallback(() => {
605 if (props.wokeAt === null) return;
606 void visitThread({
607 environmentId: thread.environmentId,
608 input: { threadId: thread.id, visitedAt: props.wokeAt },
609 });
610 }, [props.wokeAt, thread.environmentId, thread.id, visitThread]);
611 // VoiceOver cannot focus buttons inside the accessible row.
612 const rowAccessibilityActions = useMemo(
613 () => [
614 ...(prBadgeLabel ? [{ name: "openPullRequests", label: prBadgeLabel }] : []),
615 ...(showsWoke ? [{ name: "dismissWoke", label: "Dismiss Woke notification" }] : []),
616 ],
617 [prBadgeLabel, showsWoke],
618 );
619​
620 const handleDelete = useCallback(() => onDeleteThread(thread), [onDeleteThread, thread]);
621 const handleRename = useCallback(() => onRenameThread(thread), [onRenameThread, thread]);
622 const canOperateThread = useEnvironmentScope(thread.environmentId, AuthOrchestrationOperateScope);
623 const handleRegenerateTitle = useCallback(
624 () => onRegenerateThreadTitle(thread),
625 [onRegenerateThreadTitle, thread],
626 );
627 const handleSettle = useCallback(() => onSettleThread(thread), [onSettleThread, thread]);
628 const [customSnoozeOpen, setCustomSnoozeOpen] = useState(false);
629 // A recycled cell reassigns this mounted row to a different thread without
630 // remounting it, and the render closure stops running while list equality
631 // says the item is unchanged — so any row-local UI state must be dismissed
632 // when the identity under it changes.
633 const rowIdentity = `${thread.environmentId}:${thread.id}`;
634 const [boundIdentity, setBoundIdentity] = useState(rowIdentity);
635 if (boundIdentity !== rowIdentity) {
636 setBoundIdentity(rowIdentity);
637 setCustomSnoozeOpen(false);
638 }
639 const handleSnooze = useCallback(
640 (snoozedUntil: string) => onSnoozeThread(thread, snoozedUntil),
641 [onSnoozeThread, thread],
642 );
643 const handleUnsnooze = useCallback(() => onUnsnoozeThread(thread), [onUnsnoozeThread, thread]);
644 const handleUnsettle = useCallback(() => onUnsettleThread(thread), [onUnsettleThread, thread]);
645 const handlePin = useCallback(() => onPinThread(thread), [onPinThread, thread]);
646 const handleUnpin = useCallback(() => onUnpinThread(thread), [onUnpinThread, thread]);
647 const handleSetAutoSettle = useCallback(
648 (enabled: boolean) => onSetThreadAutoSettle(thread, enabled),
649 [onSetThreadAutoSettle, thread],
650 );
651 const handleMoveUp = useCallback(() => onMoveThread?.(thread, "up"), [onMoveThread, thread]);
652 const handleMoveDown = useCallback(() => onMoveThread?.(thread, "down"), [onMoveThread, thread]);
653 const handleArchive = useCallback(() => onArchiveThread(thread), [onArchiveThread, thread]);
654​
655 const canUnsettle = variant === "slim";
656 // The React Compiler caches render results on props and state, so a clock read
657 // in render would stay frozen until `thread` changes: the gate could never
658 // expire and its timer would re-fire every 50ms. The gate's clock is state.
659 const [snoozeGateClock, setSnoozeGateClock] = useState(() => ({ thread, now: Date.now() }));
660 if (snoozeGateClock.thread !== thread) setSnoozeGateClock({ thread, now: Date.now() });
661 const snoozeGateNow = new Date(snoozeGateClock.now).toISOString();
662 const snoozeGateExpiryMs = props.snoozeSupported
663 ? resolveThreadListV2SnoozeGateExpiryMs(thread, { now: snoozeGateNow })
664 : null;
665 useEffect(() => {
666 // A gate still closed past its expiry is held by runtime status, not time,
667 // so no clock tick can open it.
668 if (snoozeGateExpiryMs === null || snoozeGateExpiryMs <= snoozeGateClock.now) return;
669 const delayMs = Math.min(snoozeGateExpiryMs - Date.now() + 50, 2_147_483_647);
670 const id = setTimeout(() => setSnoozeGateClock({ thread, now: Date.now() }), delayMs);
671 return () => clearTimeout(id);
672 }, [snoozeGateExpiryMs, snoozeGateClock.now, thread]);
673 const swipeActions = resolveThreadListV2SwipeActions({
674 variant,
675 settlementSupported: props.settlementSupported,
676 snoozeSupported: props.snoozeSupported,
677 snoozable: canSnooze(thread, { now: snoozeGateNow }),
678 snoozed: snoozedRow,
679 });
680 const snoozePresets = useMemo(
681 () => (swipeActions.secondary === "snooze" ? resolveSnoozePresets(new Date()) : ([] as const)),
682 [props.snoozePresetMinute, swipeActions.secondary],
683 );
684 const snoozePresetActions = useMemo<MenuAction[]>(
685 () => [
686 ...snoozePresets.map((preset) => ({
687 id: `snooze:${preset.id}`,
688 title: preset.label,
689 subtitle: preset.whenLabel,
690 })),
691 { id: "snooze:custom", title: "Custom…" },
692 ],
693 [snoozePresets],
694 );
695 const arrangementMenuItems = useMemo<MenuAction[]>(
696 () => [
697 ...(props.reorderSupported === true
698 ? [
699 { id: "arrange", title: "Arrange threads…", image: "line.3.horizontal" },
700 {
701 id: "move-up",
702 title: "Move up",
703 image: "arrow.up",
704 attributes: { disabled: props.canMoveUp !== true },
705 } satisfies MenuAction,
706 {
707 id: "move-down",
708 title: "Move down",
709 image: "arrow.down",
710 attributes: { disabled: props.canMoveDown !== true },
711 } satisfies MenuAction,
712 ]
713 : []),
714 ...(props.pinningSupported
715 ? [
716 thread.pinnedAt != null
717 ? { id: "unpin", title: "Unpin", image: "pin.slash" }
718 : { id: "pin", title: "Pin", image: "pin" },
719 ]
720 : []),
721 ],
722 [
723 props.canMoveDown,
724 props.canMoveUp,
725 props.reorderSupported,
726 props.pinningSupported,
727 thread.pinnedAt,
728 variant,
729 ],
730 );
731 const autoSettleMenuItems = useMemo<MenuAction[]>(
732 () =>
733 props.autoSettleOptOutSupported
734 ? [
735 {
736 id: "auto-settle",
737 title: "Auto-settle behavior",
738 image: "timer",
739 subactions: [
740 {
741 id: "auto-settle:enabled",
742 title: "Enabled",
743 state: thread.autoSettleDisabledAt == null ? "on" : "off",
744 },
745 {
746 id: "auto-settle:disabled",
747 title: "Disabled",
748 state: thread.autoSettleDisabledAt == null ? "off" : "on",
749 },
750 ],
751 } satisfies MenuAction,
752 ]
753 : [],
754 [props.autoSettleOptOutSupported, thread.autoSettleDisabledAt],
755 );
756 const titleMenuItems = useMemo<MenuAction[]>(
757 () => [
758 { id: "rename", title: "Rename", image: "square.and.pencil" },
759 ...buildThreadTitleRegenerationMenuItems({
760 supported: props.titleRegenerationSupported,
761 isRegenerating: thread.titleRegeneration != null,
762 }),
763 ],
764 [props.titleRegenerationSupported, thread.titleRegeneration],
765 );
766 const snoozableCardMenuActions = useMemo<MenuAction[]>(
767 () => [
768 { id: "settle", title: "Settle", image: "checkmark" },
769 {
770 id: "snooze",
771 title: "Snooze",
772 image: "clock",
773 subactions: snoozePresetActions,
774 },
775 ...arrangementMenuItems,
776 ...titleMenuItems,
777 ...autoSettleMenuItems,
778 LEGACY_MENU_ACTIONS[0]!,
779 { id: "delete", title: "Delete", image: "trash", attributes: { destructive: true } },
780 ],
781 [arrangementMenuItems, autoSettleMenuItems, snoozePresetActions, titleMenuItems],
782 );
783 const cardMenuActions = useMemo<MenuAction[]>(
784 () => [
785 CARD_MENU_ACTIONS[0]!,
786 ...arrangementMenuItems,
787 ...titleMenuItems,
788 ...autoSettleMenuItems,
789 LEGACY_MENU_ACTIONS[0]!,
790 ...CARD_MENU_ACTIONS.slice(1),
791 ],
792 [arrangementMenuItems, autoSettleMenuItems, titleMenuItems],
793 );
794 const slimMenuActions = useMemo<MenuAction[]>(
795 () => [
796 SLIM_MENU_ACTIONS[0]!,
797 ...arrangementMenuItems.filter(
798 (action) => action.id !== "move-up" && action.id !== "move-down",
799 ),
800 ...titleMenuItems,
801 ...autoSettleMenuItems,
802 LEGACY_MENU_ACTIONS[0]!,
803 SLIM_MENU_ACTIONS[1]!,
804 ],
805 [arrangementMenuItems, autoSettleMenuItems, titleMenuItems],
806 );
807 const snoozedMenuActions = useMemo<MenuAction[]>(
808 () => [
809 SNOOZED_MENU_ACTIONS[0]!,
810 ...titleMenuItems,
811 ...autoSettleMenuItems,
812 LEGACY_MENU_ACTIONS[0]!,
813 SNOOZED_MENU_ACTIONS[1]!,
814 ],
815 [autoSettleMenuItems, titleMenuItems],
816 );
817 const legacyMenuActions = useMemo<MenuAction[]>(
818 () => [
819 LEGACY_MENU_ACTIONS[0]!,
820 ...arrangementMenuItems,
821 ...titleMenuItems,
822 LEGACY_MENU_ACTIONS[1]!,
823 ],
824 [arrangementMenuItems, titleMenuItems],
825 );
826 const handleMenuAction = useCallback(
827 ({ nativeEvent }: { readonly nativeEvent: { readonly event: string } }) => {
828 if (nativeEvent.event === "new-thread-on-branch") onNewThreadOnBranch(thread);
829 if (nativeEvent.event === "settle") handleSettle();
830 if (nativeEvent.event === "unsettle") handleUnsettle();
831 if (nativeEvent.event === "unsnooze") handleUnsnooze();
832 if (nativeEvent.event === "pin") handlePin();
833 if (nativeEvent.event === "unpin") handleUnpin();
834 if (nativeEvent.event === "auto-settle:enabled") handleSetAutoSettle(true);
835 if (nativeEvent.event === "auto-settle:disabled") handleSetAutoSettle(false);
836 if (nativeEvent.event === "arrange") appAtomRegistry.set(threadArrangementOpenAtom, true);
837 if (nativeEvent.event === "move-up") handleMoveUp();
838 if (nativeEvent.event === "move-down") handleMoveDown();
839 if (nativeEvent.event === "archive") handleArchive();
840 if (nativeEvent.event === "rename") handleRename();
841 if (nativeEvent.event === "regenerate-title") handleRegenerateTitle();
842 if (nativeEvent.event === "copy-thread-id") {
843 copyTextWithHaptic(thread.id, { target: "thread-id" });
844 }
845 if (nativeEvent.event === "delete") handleDelete();
846 if (nativeEvent.event === "snooze:custom") {
847 setCustomSnoozeOpen(true);
848 return;
849 }
850 const snoozeSelection = resolveThreadListV2SnoozeMenuSelection({
851 event: nativeEvent.event,
852 displayedPresets: snoozePresets,
853 now: new Date(),
854 });
855 if (snoozeSelection._tag === "selected") {
856 handleSnooze(snoozeSelection.preset.snoozedUntil);
857 } else if (snoozeSelection._tag === "expired") {
858 Dialog.alert(
859 "Could not snooze thread",
860 "That snooze time has passed. Choose another time.",
861 );
862 }
863 },
864 [
865 onNewThreadOnBranch,
866 thread,
867 handleArchive,
868 handleDelete,
869 handleRegenerateTitle,
870 handleRename,
871 handleMoveDown,
872 handleMoveUp,
873 handlePin,
874 handleSettle,
875 handleSnooze,
876 handleSetAutoSettle,
877 handleUnpin,
878 handleUnsettle,
879 handleUnsnooze,
880 setCustomSnoozeOpen,
881 snoozePresets,
882 ],
883 );
884 const primaryAction = useMemo(() => {
885 if (swipeActions.primary === "archive") {
886 return {
887 accessibilityLabel: `Archive ${thread.title}`,
888 icon: "archivebox" as const,
889 label: "Archive",
890 onPress: handleArchive,
891 };
892 }
893 if (swipeActions.primary === "unsnooze") {
894 return {
895 accessibilityLabel: `Wake ${thread.title} now`,
896 icon: "clock" as const,
897 label: "Wake",
898 onPress: handleUnsnooze,
899 };
900 }
901 return swipeActions.primary === "unsettle"
902 ? {
903 accessibilityLabel: `Un-settle ${thread.title}`,
904 icon: "arrow.uturn.backward" as const,
905 label: "Un-settle",
906 onPress: handleUnsettle,
907 }
908 : {
909 accessibilityLabel: `Settle ${thread.title}`,
910 icon: "checkmark" as const,
911 label: "Settle",
912 onPress: handleSettle,
913 };
914 }, [
915 handleArchive,
916 handleSettle,
917 handleUnsettle,
918 handleUnsnooze,
919 swipeActions.primary,
920 thread.title,
921 ]);
922 const secondaryAction = useMemo(
923 () =>
924 swipeActions.secondary === "snooze"
925 ? {
926 accessibilityLabel: `Choose when to snooze ${thread.title}`,
927 icon: "clock" as const,
928 label: "Snooze",
929 menu: {
930 actions: snoozePresetActions,
931 onPressAction: handleMenuAction,
932 title: "Snooze until",
933 },
934 onPress: () => undefined,
935 }
936 : null,
937 [handleMenuAction, snoozePresetActions, swipeActions.secondary, thread.title],
938 );
939 const swipeAccessibilityHint = !canOperateThread
940 ? "Opens the thread"
941 : secondaryAction === null
942 ? `Opens the thread. Swipe left to ${primaryAction.label.toLowerCase()}.`
943 : `Opens the thread. Swipe left for ${primaryAction.label.toLowerCase()} and snooze actions.`;
944​
945 const cardContent = (
946 <>
947 <View className="flex-row items-center gap-1.5">
948 {props.project ? (
949 <ProjectFavicon
950 environmentId={thread.environmentId}
951 faviconPath={props.project.faviconPath}
952 projectIcon={props.project.projectIcon}
953 size={15}
954 projectTitle={props.project.title}
955 workspaceRoot={props.project.workspaceRoot}
956 />
957 ) : null}
958 <Text
959 className={cn(
960 "flex-1 text-sm font-t3-medium",
961 selected
962 ? selectedThreadRowColors.mutedForegroundClassName
963 : rowAppearance.mutedForegroundClassName,
964 )}
965 numberOfLines={1}
966 >
967 {props.projectTitle ?? props.project?.title ?? ""}
968 </Text>
969 {props.hasQueuedMessages ? <QueuedMessageIcon selected={selected} /> : null}
970 {pinnedRow ? (
971 <SymbolView
972 name="pin"
973 size={11}
974 tintColorClassName={rowAppearance.mutedIconTintClassName}
975 type="monochrome"
976 />
977 ) : null}
978 {showsWoke ? (
979 <Pressable
980 className="-m-2.5 flex-row items-center gap-1 p-2.5"
981 accessibilityRole="button"
982 accessibilityLabel="Dismiss Woke notification"
983 onPress={handleAcknowledgeWoke}
984 onLongPress={() => undefined}
985 style={({ pressed }) => ({ opacity: pressed ? 0.6 : 1 })}
986 >
987 <SymbolView
988 name="bell.badge"
989 size={13}
990 tintColorClassName={
991 selected ? selectedThreadRowColors.iconTintClassName : "accent-warning-foreground"
992 }
993 type="monochrome"
994 weight="semibold"
995 />
996 <Text
997 className={cn(
998 "text-xs font-t3-bold",
999 selected ? selectedThreadRowColors.foregroundClassName : "text-warning-foreground",
1000 )}
1002 Woke
1003 </Text>
1004 </Pressable>
1005 ) : statusLabel ? (
1006 <View className="flex-row items-center gap-1">
1007 <SymbolView
1008 name={statusLabel.icon}
1009 size={13}
1010 tintColorClassName={
1011 selected ? selectedThreadRowColors.iconTintClassName : statusLabel.iconTintClassName
1013 type="monochrome"
1014 weight="semibold"
1015 />
1016 <Text
1017 className={cn(
1018 "text-xs font-t3-bold",
1019 (status === "working" || status === "waiting") && "tabular-nums",
1020 selected ? selectedThreadRowColors.foregroundClassName : statusLabel.className,
1021 )}
1023 {statusLabel.label}
1024 {status === "working" ? (
1025 <ThreadListV2Duration startedAt={resolveThreadWorkingStartedAt(thread)} />
1026 ) : status === "waiting" ? (
1027 <ThreadListV2Duration startedAt={thread.latestRun?.completedAt ?? null} />
1028 ) : null}
1029 </Text>
1030 </View>
1031 ) : (
1032 <Text
1033 className={cn(
1034 "text-xs tabular-nums",
1035 selected
1036 ? selectedThreadRowColors.foregroundClassName
1037 : rowAppearance.tertiaryForegroundClassName,
1038 )}
1040 {timeLabel}
1041 </Text>
1042 )}
1043 </View>
1044 <Text
1045 className={cn(
1046 "mt-1 text-base",
1047 !recede && "font-t3-medium",
1048 selected
1049 ? selectedThreadRowColors.foregroundClassName
1050 : rowAppearance.foregroundClassName,
1051 )}
1052 numberOfLines={2}
1054 {thread.title}
1055 </Text>
1056 {props.searchMatch ? (
1057 <View className="mt-1">
1058 <ThreadSearchMatchExcerpt
1059 sidebar={sidebarPane}
1060 match={props.searchMatch}
1061 query={props.searchQuery ?? ""}
1062 selected={selected}
1063 />
1064 </View>
1065 ) : null}
1066 <View className="mt-1 flex-row items-center gap-2">
1067 {(status === "failed" || status === "limited") && thread.runtime?.lastError ? (
1068 <Text
1069 className={cn(
1070 "flex-1 text-xs",
1071 selected
1072 ? selectedThreadRowColors.mutedForegroundClassName
1073 : status === "limited"
1074 ? "text-warning-foreground"
1075 : "text-danger-foreground",
1076 )}
1077 numberOfLines={1}
1079 {thread.runtime.lastError}
1080 </Text>
1081 ) : thread.branch || props.environmentLabel ? (
1082 <View className="min-w-0 flex-1 flex-row items-center gap-1">
1083 <Text
1084 className={cn(
1085 "shrink text-xs",
1086 selected
1087 ? selectedThreadRowColors.mutedForegroundClassName
1088 : rowAppearance.mutedForegroundClassName,
1089 )}
1090 numberOfLines={1}
1092 {thread.branch ? (
1093 <Text
1094 className={cn(
1095 "text-xs",
1096 selected
1097 ? selectedThreadRowColors.mutedForegroundClassName
1098 : rowAppearance.mutedForegroundClassName,
1099 )}
1100 style={{ fontFamily: MONO_FONT }}
1102 {thread.branch}
1103 </Text>
1104 ) : null}
1105 {thread.branch && props.environmentLabel ? " · " : null}
1106 {props.environmentLabel ? (
1107 <Text
1108 className={cn(
1109 "text-xs",
1110 selected
1111 ? selectedThreadRowColors.mutedForegroundClassName
1112 : rowAppearance.tertiaryForegroundClassName,
1113 )}
1115 {props.environmentLabel}
1116 </Text>
1117 ) : null}
1118 </Text>
1119 {props.environmentLabel && props.environmentMachine ? (
1120 <EnvironmentMachineSymbol
1121 kind={props.environmentMachine}
1122 size={11}
1123 tintColorClassName={
1124 selected
1125 ? selectedThreadRowColors.mutedIconTintClassName
1126 : rowAppearance.tertiaryIconTintClassName
1128 />
1129 ) : null}
1130 </View>
1131 ) : (
1132 <View className="flex-1" />
1133 )}
1134 {pr ? (
1135 <Pressable
1136 // Padding cancelled by negative margin grows the touch target into
1137 // the row padding without moving the badge.
1138 className="-m-2.5 flex-row items-center gap-1 p-2.5"
1139 accessibilityRole="button"
1140 accessibilityLabel={prBadgeLabel ?? undefined}
1141 onPress={handleOpenPullRequests}
1142 // Without a long-press handler a hold that opens the row's iOS
1143 // context menu would also open the pull request on release.
1144 onLongPress={() => undefined}
1145 style={({ pressed }) => ({ opacity: pressed ? 0.6 : 1 })}
1147 <SymbolView
1148 name={
1149 pr.kind === "stack"
1150 ? PullRequestGlyph.stack
1151 : pr.state === null
1152 ? PullRequestGlyph.pullRequest
1153 : pullRequestStatus({ state: pr.state, isDraft: pr.isDraft }).icon
1155 size={12}
1156 tintColorClassName={
1157 pr.state === null || pr.isDraft
1158 ? rowAppearance.mutedIconTintClassName
1159 : pr.state === "open"
1160 ? "accent-adaptive-emerald-600-400"
1161 : pr.state === "closed"
1162 ? "accent-adaptive-rose-600-400"
1163 : "accent-adaptive-violet-600-400"
1165 />
1166 <Text
1167 accessibilityLabel={pr.accessibilityLabel}
1168 className={cn("text-xs", pr.textClassName)}
1169 style={{ fontFamily: MONO_FONT }}
1171 {pr.label}
1172 </Text>
1173 </Pressable>
1174 ) : null}
1175 {providerInstance ? (
1176 <View className="flex-row items-center">
1177 {providerDrivers.slice(0, -1).map((driver, index) => (
1178 <View key={`${driver}:${index}`} className="-mr-1 opacity-30">
1179 <ProviderIcon provider={driver} size={12} />
1180 </View>
1181 ))}
1182 <ProviderInstanceIcon
1183 iconUrl={providerIconUrl}
1184 provider={providerInstance.driverKind}
1185 size={14}
1186 displayName={providerInstance.displayName}
1187 accentColor={providerInstance.accentColor}
1188 showBadge={providerInstance.showBadge}
1189 surfaceColor={rowAppearance.providerIconSurfaceColor}
1190 />
1191 </View>
1192 ) : null}
1193 </View>
1194 </>
1195 );
1196​
1197 const fadedCardContent = recede ? (
1198 <View style={{ opacity: 0.55 }}>{cardContent}</View>
1199 ) : (
1200 cardContent
1201 );
1202​
1203 const rowContent = (close: () => void) =>
1204 variant === "card" ? (
1205 <RowPressable
1206 key={`${thread.environmentId}:${thread.id}`}
1207 interactionClassName={rowAppearance.interactionClassName}
1208 interactionOpacity={rowAppearance.interactionOpacity}
1209 className={rowAppearance.className}
1210 accessibilityHint={swipeAccessibilityHint}
1211 accessibilityLabel={
1212 props.hasQueuedMessages ? `${thread.title}, messages queued to send` : thread.title
1214 accessibilityRole="button"
1215 accessibilityState={{ selected }}
1216 accessibilityActions={rowAccessibilityActions}
1217 onAccessibilityAction={(event) => {
1218 if (event.nativeEvent.actionName === "openPullRequests") handleOpenPullRequests();
1219 if (event.nativeEvent.actionName === "dismissWoke") handleAcknowledgeWoke();
1220 }}
1221 onPress={() => {
1222 close();
1223 onSelectThread(thread);
1224 }}
1225 style={rowAppearance.cardStyle}
1227 {sidebarPane ? (
1228 fadedCardContent
1229 ) : (
1230 <View>
1231 <View className={THREAD_LIST_V2_ROW_CONTENT_CLASS_NAME}>{fadedCardContent}</View>
1232 {THREAD_LIST_V2_ROW_DIVIDERS && props.showTrailingDivider !== false ? (
1233 <View className="ml-5 h-px bg-border-subtle" />
1234 ) : null}
1235 </View>
1236 )}
1237 </RowPressable>
1238 ) : (
1239 <RowPressable
1240 key={`${thread.environmentId}:${thread.id}`}
1241 interactionClassName={rowAppearance.interactionClassName}
1242 interactionOpacity={rowAppearance.interactionOpacity}
1243 accessibilityHint={swipeAccessibilityHint}
1244 accessibilityLabel={
1245 props.hasQueuedMessages ? `${thread.title}, messages queued to send` : thread.title
1247 accessibilityRole="button"
1248 accessibilityState={{ selected }}
1249 className={rowAppearance.className}
1250 onPress={() => {
1251 close();
1252 onSelectThread(thread);
1253 }}
1254 style={rowAppearance.style}
1256 <View
1257 className={cn(
1258 "min-h-[44px] flex-row items-center gap-2.5 py-2",
1259 sidebarPane ? "px-3" : "px-5",
1260 )}
1262 {props.project ? (
1263 <View className="opacity-40">
1264 <ProjectFavicon
1265 environmentId={thread.environmentId}
1266 faviconPath={props.project.faviconPath}
1267 projectIcon={props.project.projectIcon}
1268 size={15}
1269 projectTitle={props.project.title}
1270 workspaceRoot={props.project.workspaceRoot}
1271 />
1272 </View>
1273 ) : null}
1274 <View className="min-w-0 flex-1">
1275 <Text
1276 className={cn(
1277 "text-base",
1278 selected
1279 ? selectedThreadRowColors.foregroundClassName
1280 : rowAppearance.mutedForegroundClassName,
1281 )}
1282 numberOfLines={1}
1284 {thread.title}
1285 </Text>
1286 {props.searchMatch ? (
1287 <ThreadSearchMatchExcerpt
1288 sidebar={sidebarPane}
1289 match={props.searchMatch}
1290 query={props.searchQuery ?? ""}
1291 selected={selected}
1292 />
1293 ) : null}
1294 </View>
1295 {props.hasQueuedMessages ? <QueuedMessageIcon selected={selected} /> : null}
1296 <Text
1297 className={cn(
1298 "text-sm tabular-nums",
1299 selected
1300 ? selectedThreadRowColors.mutedForegroundClassName
1301 : snoozedRow
1302 ? rowAppearance.mutedForegroundClassName
1303 : rowAppearance.tertiaryForegroundClassName,
1304 )}
1305 style={{ fontFamily: MONO_FONT }}
1307 {snoozedRow && props.snoozeWakeLabelText !== undefined
1308 ? props.snoozeWakeLabelText
1309 : timeLabel}
1310 </Text>
1311 </View>
1312 </RowPressable>
1313 );
1314​
1315 if (!canOperateThread)
1316 return <View style={rowAppearance.swipeContainerStyle}>{rowContent(() => {})}</View>;
1317​
1318 return (
1319 <View collapsable={false}>
1320 {customSnoozeOpen && (
1321 <CustomSnoozeSheet onClose={() => setCustomSnoozeOpen(false)} onSnooze={handleSnooze} />
1322 )}
1323 <ThreadSwipeable
1324 dormant={dormant}
1325 threadKey={`${thread.environmentId}:${thread.id}`}
1326 backgroundColor={rowAppearance.swipeBackgroundColor}
1327 compactActions={variant === "slim"}
1328 containerStyle={rowAppearance.swipeContainerStyle}
1329 enableTrackpadSwipe
1330 fullSwipeAction="primary"
1331 fullSwipeWidth={props.fullSwipeWidth ?? windowWidth - 32}
1332 onDelete={handleDelete}
1333 onSwipeableClose={props.onSwipeableClose}
1334 onSwipeableWillOpen={props.onSwipeableWillOpen}
1335 primaryAction={primaryAction}
1336 secondaryAction={secondaryAction}
1337 resetKey={`${thread.environmentId}:${thread.id}:${variant}:${snoozedRow}:${thread.settledAt}:${thread.unsettledAt}:${thread.snoozedUntil}`}
1338 simultaneousWith={props.simultaneousSwipeGesture}
1339 threadTitle={thread.title}
1341 {(close) => (
1342 <Menu
1343 actions={[
1344 ...(thread.branch
1345 ? [
1347 id: "new-thread-on-branch",
1348 title: getThreadListV2NewBranchMenuTitle(thread.branch),
1349 image: "square.and.pencil",
1350 },
1352 : []),
1353 { id: "copy-thread-id", title: "Copy thread ID", image: "doc.on.doc" },
1354 ...(snoozedRow
1355 ? snoozedMenuActions
1356 : !props.settlementSupported
1357 ? legacyMenuActions
1358 : canUnsettle
1359 ? slimMenuActions
1360 : swipeActions.secondary === "snooze"
1361 ? snoozableCardMenuActions
1362 : cardMenuActions),
1363 ]}
1364 onPressAction={handleMenuAction}
1365 shouldOpenOnLongPress
1367 {rowContent(close)}
1368 </Menu>
1369 )}
1370 </ThreadSwipeable>
1371 </View>
1372 );
1373});