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