Open History to see the last commit
1import { createThreadMovePlanner } from "../threads/threadOrder";
2import {
3 LegendList,
4 type LegendListRef,
5 type LegendListRenderItemProps,
6} from "@legendapp/list/react-native";
7import {
8 type EnvironmentProject,
9 type EnvironmentThreadShell,
10} from "@t3tools/client-runtime/state/shell";
11import {
12 threadSearchMatchKey,
13 type EnvironmentThreadSearchMatch,
14} from "@t3tools/client-runtime/state/thread-search";
15import {
16 type EnvironmentId,
17 resolveEnvironmentMachineKind,
18 type SidebarProjectGroupingMode,
19 type SidebarThreadSortOrder,
20} from "@t3tools/contracts";
21import { useAtomSet, useAtomValue } from "@effect/atom-react";
22import { AsyncResult } from "effect/unstable/reactivity";
23import { useFocusEffect } from "@react-navigation/native";
24import { useCallback, useEffect, useMemo, useRef, useState } from "react";
25import { ActivityIndicator, FlatList, Platform, Pressable, View } from "react-native";
26import type { SwipeableMethods } from "react-native-gesture-handler/ReanimatedSwipeable";
27import { useSafeAreaInsets } from "react-native-safe-area-context";
28
29import { AppText as Text } from "../../components/AppText";
30import { EmptyState } from "../../components/EmptyState";
31import type { WorkspaceEnvironment, WorkspaceState } from "../../state/workspaceModel";
32import type { SavedRemoteConnection } from "../../lib/connection";
33import { scopedProjectKey } from "../../lib/scopedEntities";
34import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass";
35import { mobilePreferencesAtom, updateMobilePreferencesAtom } from "../../state/preferences";
36import { useThreadSearch } from "../../state/queries";
37import { useThreadListV2Enabled } from "../threads/use-thread-list-v2-enabled";
38import { usePendingThreadOrder } from "../../state/thread-order";
39import { environmentServerConfigsAtom } from "../../state/server";
40import type { PendingNewTask } from "../../state/use-pending-new-tasks";
41import {
42 PendingTaskListRow,
43 ThreadListGroupHeader,
44 ThreadListRow,
45 ThreadListShowMoreRow,
46} from "../threads/thread-list-items";
47import {
48 ThreadListV2PendingRow,
49 ThreadListV2Row,
50 ThreadListV2SettledShelfHeader,
51 ThreadListV2SnoozedShelfHeader,
52} from "../threads/thread-list-v2-items";
53import {
54 buildThreadListV2Items,
55 getThreadListV2OrderedSection,
56 buildThreadListV2ListItems,
57 THREAD_LIST_V2_SETTLED_INITIAL_COUNT,
58 THREAD_LIST_V2_SETTLED_PAGE_COUNT,
59 type ThreadListV2ListItem,
60} from "../threads/threadListV2";
61import { useThreadListV2ShelfPreferences } from "../threads/use-thread-list-v2-shelf-preferences";
62import type { HomeListFilterMenuEnvironment } from "./home-list-filter-menu";
63import {
64 buildHomeListLayout,
65 DEFAULT_GROUP_DISPLAY_STATE,
66 EMPTY_HOME_LIST_LAYOUT,
67 homeListItemsAreEqual,
68 nextGroupDisplayState,
69 type HomeGroupDisplayAction,
70 type HomeGroupDisplayState,
71 type HomeListItem,
72} from "./homeListItems";
73import {
74 buildHomeProjectScopes,
75 buildHomeThreadGroups,
76 sortHomeProjectScopes,
77 type HomeProjectSortOrder,
78} from "./homeThreadList";
79import { SwipeableScrollGateProvider, useSwipeableScrollGate } from "./thread-swipe-actions";
80
81/* ─── Types ──────────────────────────────────────────────────────────── */
82
83interface HomeScreenProps {
84 readonly projects: ReadonlyArray<EnvironmentProject>;
85 readonly threads: ReadonlyArray<EnvironmentThreadShell>;
86 readonly pendingTasks: ReadonlyArray<PendingNewTask>;
87 readonly catalogState: WorkspaceState;
88 readonly savedConnectionsById: Readonly<Record<string, SavedRemoteConnection>>;
89 readonly environments: ReadonlyArray<
90 HomeListFilterMenuEnvironment & Pick<WorkspaceEnvironment, "connectionState">
91 >;
92 readonly searchQuery: string;
93 readonly selectedEnvironmentId: EnvironmentId | null;
94 readonly selectedProjectKey: string | null;
95 readonly projectSortOrder: HomeProjectSortOrder;
96 readonly threadSortOrder: SidebarThreadSortOrder;
97 readonly projectGroupingMode: SidebarProjectGroupingMode;
98 readonly onSearchQueryChange: (query: string) => void;
99 readonly onEnvironmentChange: (environmentId: EnvironmentId | null) => void;
100 readonly onProjectChange: (projectKey: string | null) => void;
101 readonly onProjectSortOrderChange: (sortOrder: HomeProjectSortOrder) => void;
102 readonly onThreadSortOrderChange: (sortOrder: SidebarThreadSortOrder) => void;
103 readonly onAddConnection: () => void;
104 readonly onOpenSettings: () => void;
105 readonly onStartNewTask: () => void;
106 readonly onSelectThread: (thread: EnvironmentThreadShell) => void;
107 readonly onArchiveThread: (thread: EnvironmentThreadShell) => void;
108 readonly onDeleteThread: (thread: EnvironmentThreadShell) => void;
109 /** Resolves true iff the settle was dispatched and succeeded. */
110 readonly onSettleThread: (thread: EnvironmentThreadShell) => Promise<boolean>;
111 readonly onSnoozeThread: (
112 thread: EnvironmentThreadShell,
113 snoozedUntil: string,
114 ) => Promise<boolean>;
115 readonly onUnsnoozeThread: (thread: EnvironmentThreadShell) => Promise<boolean>;
116 readonly onUnsettleThread: (thread: EnvironmentThreadShell) => void;
117 readonly onPinThread: (thread: EnvironmentThreadShell) => Promise<boolean>;
118 readonly onUnpinThread: (thread: EnvironmentThreadShell) => Promise<boolean>;
119 readonly onMoveThread: (
120 thread: EnvironmentThreadShell,
121 direction: "up" | "down",
122 ) => Promise<boolean>;
123 readonly onRegenerateThreadTitle: (thread: EnvironmentThreadShell) => Promise<boolean>;
124 readonly onSelectPendingTask: (pendingTask: PendingNewTask) => void;
125 readonly onDeletePendingTask: (pendingTask: PendingNewTask) => void;
126 readonly onNewThreadInProject: (project: EnvironmentProject) => void;
127}
128
129/* ─── Layout constants ───────────────────────────────────────────────── */
130
131const ESTIMATED_THREAD_ROW_HEIGHT = 72;
132const PRE_LIQUID_GLASS_BOTTOM_TOOLBAR_HEIGHT = 44;
133/**
134 * Top spacing between the list and the Android custom header. The Android
135 * header (AndroidHomeHeader) is rendered in-flow above this screen and
136 * already consumes the top safe-area inset, so the list only needs breathing
137 * room here.
138 */
139
140function deriveEmptyState(props: {
141 readonly catalogState: WorkspaceState;
142 readonly projectCount: number;
143}): { readonly title: string; readonly detail: string; readonly loading: boolean } {
144 const { catalogState } = props;
145 if (catalogState.isLoadingConnections) {
146 return {
147 title: "Loading environments",
148 detail: "Checking saved environments on this device.",
149 loading: true,
150 };
151 }
152
153 if (!catalogState.hasConnections) {
154 return {
155 title: "No environments connected",
156 detail: "Add an environment to load projects and start coding sessions.",
157 loading: false,
158 };
159 }
160
161 if (
162 (catalogState.connectionState === "available" ||
163 catalogState.connectionState === "offline" ||
164 catalogState.connectionState === "error") &&
165 !catalogState.hasLoadedShellSnapshot
166 ) {
167 return {
168 title: "Environment unavailable",
169 detail:
170 catalogState.connectionError ??
171 "The saved environment is offline. Check the URL or start the environment, then retry.",
172 loading: false,
173 };
174 }
175
176 if (
177 catalogState.hasConnectingEnvironment &&
178 !catalogState.hasLoadedShellSnapshot &&
179 catalogState.connectionError === null
180 ) {
181 return {
182 title: "Connecting to environment",
183 detail: "Loading projects and threads from the saved environment.",
184 loading: true,
185 };
186 }
187
188 if (props.projectCount === 0 && catalogState.hasLoadedShellSnapshot) {
189 return {
190 title: "No projects found",
191 detail: "The connected environment did not report any projects.",
192 loading: false,
193 };
194 }
195
196 return {
197 title: "No threads yet",
198 detail: "Create a task to start a new coding session in one of your connected projects.",
199 loading: false,
200 };
201}
202
203function HomeTopContentSpacer() {
204 return <View className="h-4" />;
205}
206
207/* ─── Main screen ────────────────────────────────────────────────────── */
208
209export function HomeScreen(props: HomeScreenProps) {
210 const [groupDisplayStates, setGroupDisplayStates] = useState<
211 ReadonlyMap<string, HomeGroupDisplayState>
212 >(() => new Map());
213 const preferencesResult = useAtomValue(mobilePreferencesAtom);
214 const threadListV2Enabled = useThreadListV2Enabled();
215 const savePreferences = useAtomSet(updateMobilePreferencesAtom);
216 const openSwipeableRef = useRef<SwipeableMethods | null>(null);
217 const listRef = useRef<LegendListRef | null>(null);
218 const insets = useSafeAreaInsets();
219 const iosBottomToolbarClearance =
220 Platform.OS === "ios" && !NATIVE_LIQUID_GLASS_SUPPORTED
221 ? PRE_LIQUID_GLASS_BOTTOM_TOOLBAR_HEIGHT
222 : 0;
223 const searchEnvironmentIds = useMemo(
224 () =>
225 props.selectedEnvironmentId === null
226 ? props.environments
227 .filter((environment) => environment.connectionState === "connected")
228 .map((environment) => environment.environmentId)
229 : props.environments.some(
230 (environment) =>
231 environment.environmentId === props.selectedEnvironmentId &&
232 environment.connectionState === "connected",
233 )
234 ? [props.selectedEnvironmentId]
235 : [],
236 [props.environments, props.selectedEnvironmentId],
237 );
238 const threadSearch = useThreadSearch(searchEnvironmentIds, props.searchQuery);
239 const threadSearchMatchByKey = useMemo(() => {
240 const matches = new Map<string, EnvironmentThreadSearchMatch>();
241 for (const match of threadSearch.matches) {
242 if (match.source === "user" || match.source === "assistant") {
243 matches.set(threadSearchMatchKey(match), match);
244 }
245 }
246 return matches;
247 }, [threadSearch.matches]);
248 const matchedThreadKeys = useMemo(
249 () => new Set(threadSearch.matches.map(threadSearchMatchKey)),
250 [threadSearch.matches],
251 );
252 const effectiveGroupDisplayStates = useMemo(() => {
253 const next = new Map(groupDisplayStates);
254 if (!AsyncResult.isSuccess(preferencesResult)) {
255 return next;
256 }
257 for (const key of preferencesResult.value.collapsedProjectGroups ?? []) {
258 const existing = next.get(key);
259 next.set(key, {
260 ...(existing ?? DEFAULT_GROUP_DISPLAY_STATE),
261 collapsed: true,
262 });
263 }
264 return next;
265 }, [groupDisplayStates, preferencesResult]);
266 const effectiveGroupDisplayStatesRef = useRef(effectiveGroupDisplayStates);
267 effectiveGroupDisplayStatesRef.current = effectiveGroupDisplayStates;
268
269 const updateGroupDisplay = useCallback(
270 (key: string, action: HomeGroupDisplayAction) => {
271 const next = new Map(effectiveGroupDisplayStatesRef.current);
272 next.set(key, nextGroupDisplayState(next.get(key) ?? DEFAULT_GROUP_DISPLAY_STATE, action));
273 effectiveGroupDisplayStatesRef.current = next;
274 setGroupDisplayStates(next);
275 if (action === "toggle-collapsed") {
276 const collapsedProjectGroups: string[] = [];
277 for (const [groupKey, state] of next) {
278 if (state.collapsed) {
279 collapsedProjectGroups.push(groupKey);
280 }
281 }
282 savePreferences({ collapsedProjectGroups });
283 }
284 },
285 [savePreferences],
286 );
287
288 const handleSwipeableWillOpen = useCallback((methods: SwipeableMethods) => {
289 if (openSwipeableRef.current !== methods) {
290 openSwipeableRef.current?.close();
291 openSwipeableRef.current = methods;
292 }
293 }, []);
294
295 const handleSwipeableClose = useCallback((methods: SwipeableMethods) => {
296 if (openSwipeableRef.current === methods) {
297 openSwipeableRef.current = null;
298 }
299 }, []);
300
301 const handleScrollBeginDrag = useCallback(() => {
302 openSwipeableRef.current?.close();
303 }, []);
304 const { swipeEnabled, scrollGateHandlers } = useSwipeableScrollGate({
305 onScrollBeginDrag: handleScrollBeginDrag,
306 });
307
308 const projectScopes = useMemo(
309 () =>
310 buildHomeProjectScopes({
311 projects: props.projects,
312 environmentId: props.selectedEnvironmentId,
313 projectGroupingMode: props.projectGroupingMode,
314 }),
315 [props.projectGroupingMode, props.projects, props.selectedEnvironmentId],
316 );
317 const selectedProjectScope = useMemo(
318 () =>
319 props.selectedProjectKey === null
320 ? null
321 : (projectScopes.find(
322 (scope) =>
323 scope.key === props.selectedProjectKey ||
324 scope.projectRefs.some(
325 (projectRef) =>
326 scopedProjectKey(projectRef.environmentId, projectRef.projectId) ===
327 props.selectedProjectKey,
328 ),
329 ) ?? null),
330 [projectScopes, props.selectedProjectKey],
331 );
332 const selectedProjectRefKeys = useMemo(
333 () =>
334 selectedProjectScope === null
335 ? null
336 : new Set(
337 selectedProjectScope.projectRefs.map((projectRef) =>
338 scopedProjectKey(projectRef.environmentId, projectRef.projectId),
339 ),
340 ),
341 [selectedProjectScope],
342 );
343 const scopedProjects = useMemo(
344 () =>
345 threadListV2Enabled
346 ? []
347 : selectedProjectRefKeys === null
348 ? props.projects
349 : props.projects.filter((project) =>
350 selectedProjectRefKeys.has(scopedProjectKey(project.environmentId, project.id)),
351 ),
352 [threadListV2Enabled, props.projects, selectedProjectRefKeys],
353 );
354 const scopedThreads = useMemo(
355 () =>
356 threadListV2Enabled
357 ? []
358 : selectedProjectRefKeys === null
359 ? props.threads
360 : props.threads.filter((thread) =>
361 selectedProjectRefKeys.has(scopedProjectKey(thread.environmentId, thread.projectId)),
362 ),
363 [threadListV2Enabled, props.threads, selectedProjectRefKeys],
364 );
365 const scopedPendingTasks = useMemo(
366 () =>
367 threadListV2Enabled
368 ? []
369 : selectedProjectRefKeys === null
370 ? props.pendingTasks
371 : props.pendingTasks.filter((pendingTask) =>
372 selectedProjectRefKeys.has(
373 scopedProjectKey(pendingTask.environmentId, pendingTask.projectId),
374 ),
375 ),
376 [threadListV2Enabled, props.pendingTasks, selectedProjectRefKeys],
377 );
378
379 const projectGroups = useMemo(
380 () =>
381 threadListV2Enabled
382 ? []
383 : buildHomeThreadGroups({
384 projects: scopedProjects,
385 threads: scopedThreads,
386 pendingTasks: scopedPendingTasks,
387 environmentId: props.selectedEnvironmentId,
388 searchQuery: props.searchQuery,
389 matchedThreadKeys,
390 projectSortOrder: props.projectSortOrder,
391 threadSortOrder: props.threadSortOrder,
392 projectGroupingMode: props.projectGroupingMode,
393 }),
394 [
395 threadListV2Enabled,
396 props.projectGroupingMode,
397 props.projectSortOrder,
398 props.searchQuery,
399 props.selectedEnvironmentId,
400 props.threadSortOrder,
401 matchedThreadKeys,
402 scopedPendingTasks,
403 scopedProjects,
404 scopedThreads,
405 ],
406 );
407
408 const hasSearchQuery = props.searchQuery.trim().length > 0;
409 const listLayout = useMemo(
410 () =>
411 threadListV2Enabled
412 ? EMPTY_HOME_LIST_LAYOUT
413 : buildHomeListLayout({
414 groups: projectGroups,
415 displayStates: effectiveGroupDisplayStates,
416 showAllThreads: hasSearchQuery,
417 }),
418 [threadListV2Enabled, projectGroups, effectiveGroupDisplayStates, hasSearchQuery],
419 );
420
421 const projectByKey = useMemo(() => {
422 const map = new Map<string, EnvironmentProject>();
423 for (const project of props.projects) {
424 map.set(scopedProjectKey(project.environmentId, project.id), project);
425 }
426 return map;
427 }, [props.projects]);
428
429 const v2ProjectScopeKey = props.selectedProjectKey;
430 const v2ScopeProjects = useMemo(
431 () =>
432 sortHomeProjectScopes({
433 scopes: projectScopes,
434 threads: props.threads,
435 pendingTasks: props.pendingTasks,
436 projectSortOrder: props.projectSortOrder,
437 }),
438 [
439 props.pendingTasks,
440 props.projects,
441 props.projectSortOrder,
442 props.selectedEnvironmentId,
443 props.threads,
444 projectScopes,
445 ],
446 );
447 const v2ScopedProjectGroup = useMemo(
448 () =>
449 v2ProjectScopeKey === null
450 ? null
451 : (v2ScopeProjects.find(
452 (scope) =>
453 scope.key === v2ProjectScopeKey ||
454 scope.projectRefs.some(
455 (projectRef) =>
456 scopedProjectKey(projectRef.environmentId, projectRef.projectId) ===
457 v2ProjectScopeKey,
458 ),
459 ) ?? null),
460 [v2ProjectScopeKey, v2ScopeProjects],
461 );
462 const v2ProjectTitleByProjectKey = useMemo(
463 () =>
464 new Map(
465 v2ScopeProjects.flatMap((scope) =>
466 scope.projectRefs.map(
467 (projectRef) =>
468 [
469 scopedProjectKey(projectRef.environmentId, projectRef.projectId),
470 scope.title,
471 ] as const,
472 ),
473 ),
474 ),
475 [v2ScopeProjects],
476 );
477 const v2ScopedProjectKeys = useMemo(
478 () =>
479 v2ScopedProjectGroup === null
480 ? null
481 : new Set(
482 v2ScopedProjectGroup.projectRefs.map((projectRef) =>
483 scopedProjectKey(projectRef.environmentId, projectRef.projectId),
484 ),
485 ),
486 [v2ScopedProjectGroup],
487 );
488 // Thread List v2 (beta): one flat list in creation order, no grouping.
489 // Settled threads collapse into a recency tail below the card block.
490 // Settled threads stay in the live shell stream (settled ≠ archived), so
491 // the partition works directly off live shells — no snapshot merging or
492 // optimistic holds.
493 const handleSettleThread = props.onSettleThread;
494 const handleSnoozeThread = useCallback(
495 (thread: EnvironmentThreadShell, snoozedUntil: string) => {
496 void props.onSnoozeThread(thread, snoozedUntil);
497 },
498 [props.onSnoozeThread],
499 );
500 const handleUnsnoozeThread = useCallback(
501 (thread: EnvironmentThreadShell) => {
502 void props.onUnsnoozeThread(thread);
503 },
504 [props.onUnsnoozeThread],
505 );
506 const handlePinThread = useCallback(
507 (thread: EnvironmentThreadShell) => {
508 void props.onPinThread(thread);
509 },
510 [props.onPinThread],
511 );
512 const handleMoveThread = useCallback(
513 (thread: EnvironmentThreadShell, direction: "up" | "down") => {
514 void props.onMoveThread(thread, direction);
515 },
516 [props.onMoveThread],
517 );
518 const handleUnpinThread = useCallback(
519 (thread: EnvironmentThreadShell) => {
520 void props.onUnpinThread(thread);
521 },
522 [props.onUnpinThread],
523 );
524 const handleRegenerateThreadTitle = useCallback(
525 (thread: EnvironmentThreadShell) => {
526 void props.onRegenerateThreadTitle(thread);
527 },
528 [props.onRegenerateThreadTitle],
529 );
530 const handleDeleteThread = props.onDeleteThread;
531 const handleUnsettleThread = props.onUnsettleThread;
532 // The settled tail renders in pages; expansion resets when the filter
533 // context changes so environment/search flips never inherit a deep page.
534 const [settledVisibleCount, setSettledVisibleCount] = useState(
535 THREAD_LIST_V2_SETTLED_INITIAL_COUNT,
536 );
537 const settledResetKey = `${props.selectedEnvironmentId ?? "all"}:${v2ProjectScopeKey ?? "all"}:${props.searchQuery.trim()}`;
538 const lastSettledResetKeyRef = useRef(settledResetKey);
539 if (lastSettledResetKeyRef.current !== settledResetKey) {
540 lastSettledResetKeyRef.current = settledResetKey;
541 setSettledVisibleCount(THREAD_LIST_V2_SETTLED_INITIAL_COUNT);
542 }
543 const showMoreSettled = useCallback(
544 () => setSettledVisibleCount((count) => count + THREAD_LIST_V2_SETTLED_PAGE_COUNT),
545 [],
546 );
547 const {
548 loaded: shelfPreferencesLoaded,
549 settledShelfExpanded,
550 snoozedShelfExpanded,
551 toggleSettledShelf,
552 toggleSnoozedShelf,
553 } = useThreadListV2ShelfPreferences();
554 // The queued-start and snooze helpers need a clock while the list stays open.
555 const [nowMinute, setNowMinute] = useState(() => new Date().toISOString().slice(0, 16));
556 // Snooze wake times are second-precise; a counter bumped exactly at the
557 // next wake boundary re-runs the partition with a fresh clock so a woken
558 // thread reappears immediately instead of on the next minute tick.
559 const [snoozeWakeTick, bumpSnoozeWakeTick] = useState(0);
560 useFocusEffect(
561 useCallback(() => {
562 if (!threadListV2Enabled) return;
563 // Refresh immediately on enable or focus because the previous value can be hours old.
564 setNowMinute(new Date().toISOString().slice(0, 16));
565 const id = setInterval(() => setNowMinute(new Date().toISOString().slice(0, 16)), 60_000);
566 return () => clearInterval(id);
567 }, [threadListV2Enabled]),
568 );
569 // Threads on servers without the settlement capability never classify as
570 // settled (the user could neither un-settle nor pin them).
571 const serverConfigs = useAtomValue(environmentServerConfigsAtom);
572 const settlementEnvironmentIds = useMemo(() => {
573 const supported = new Set<EnvironmentId>();
574 for (const [environmentId, config] of serverConfigs) {
575 if (config.environment.capabilities.threadSettlement === true) {
576 supported.add(environmentId);
577 }
578 }
579 return supported;
580 }, [serverConfigs]);
581 const snoozeEnvironmentIds = useMemo(() => {
582 const supported = new Set<EnvironmentId>();
583 for (const [environmentId, config] of serverConfigs) {
584 if (config.environment.capabilities.threadSnooze === true) {
585 supported.add(environmentId);
586 }
587 }
588 return supported;
589 }, [serverConfigs]);
590 const pinningEnvironmentIds = useMemo(() => {
591 const supported = new Set<EnvironmentId>();
592 for (const [environmentId, config] of serverConfigs) {
593 if (config.environment.capabilities.threadPinning === true) {
594 supported.add(environmentId);
595 }
596 }
597 return supported;
598 }, [serverConfigs]);
599 const pinReorderEnvironmentIds = useMemo(() => {
600 const supported = new Set<EnvironmentId>();
601 for (const [environmentId, config] of serverConfigs) {
602 if (config.environment.capabilities.threadPinReorder === true) {
603 supported.add(environmentId);
604 }
605 }
606 return supported;
607 }, [serverConfigs]);
608 const activeReorderEnvironmentIds = useMemo(() => {
609 const supported = new Set<EnvironmentId>();
610 for (const [environmentId, config] of serverConfigs) {
611 if (config.environment.capabilities.threadActiveReorder === true) {
612 supported.add(environmentId);
613 }
614 }
615 return supported;
616 }, [serverConfigs]);
617 const titleRegenerationEnvironmentIds = useMemo(() => {
618 const supported = new Set<EnvironmentId>();
619 for (const [environmentId, config] of serverConfigs) {
620 if (config.environment.capabilities.threadTitleRegeneration === true) {
621 supported.add(environmentId);
622 }
623 }
624 return supported;
625 }, [serverConfigs]);
626 const machineByEnvironmentId = useMemo(
627 () =>
628 new Map(
629 [...serverConfigs].map(
630 ([environmentId, config]) =>
631 [environmentId, resolveEnvironmentMachineKind(config)] as const,
632 ),
633 ),
634 [serverConfigs],
635 );
636 const pendingOrder = usePendingThreadOrder(nowMinute, snoozeWakeTick);
637 const threadMovePlanners = useMemo(() => {
638 const sectionPlanner = (section: "pinned" | "active") =>
639 createThreadMovePlanner({
640 allThreads: props.threads,
641 section,
642 reorderableEnvironmentIds: new Set(
643 [...serverConfigs].flatMap(([id, config]) =>
644 (section === "pinned"
645 ? config.environment.capabilities.threadPinReorder
646 : config.environment.capabilities.threadActiveReorder) === true
647 ? [id]
648 : [],
649 ),
650 ),
651 ordered: getThreadListV2OrderedSection({
652 threads: props.threads,
653 section,
654 pendingOrder,
655 now: new Date().toISOString(),
656 settlementEnvironmentIds,
657 snoozeEnvironmentIds,
658 }),
659 });
660 return { pinned: sectionPlanner("pinned"), active: sectionPlanner("active") };
661 }, [
662 serverConfigs,
663 props.threads,
664 pendingOrder,
665 settlementEnvironmentIds,
666 snoozeEnvironmentIds,
667 nowMinute,
668 snoozeWakeTick,
669 ]);
670 const threadListV2Layout = useMemo(() => {
671 if (!threadListV2Enabled)
672 return {
673 items: [],
674 hiddenSettledCount: 0,
675 snoozedCount: 0,
676 snoozedShelfHeaderIndex: null,
677 settledCount: 0,
678 settledShelfHeaderIndex: null,
679 nextSnoozeWakeAt: null,
680 };
681 // Settled threads are live shells; archived threads keep their original
682 // "hidden from lists" meaning.
683 return buildThreadListV2Items({
684 pendingOrder,
685 threads: props.threads.filter((thread) => thread.archivedAt === null),
686 environmentId: props.selectedEnvironmentId,
687 projectRefs: v2ScopedProjectGroup === null ? null : v2ScopedProjectGroup.projectRefs,
688 searchQuery: props.searchQuery,
689 matchedThreadKeys,
690 settlementEnvironmentIds,
691 snoozeEnvironmentIds,
692 settledLimit: settledVisibleCount,
693 now: new Date().toISOString(),
694 snoozedShelfExpanded,
695 settledShelfExpanded,
696 selectedThreadKey: null,
697 });
698 }, [
699 pendingOrder,
700 nowMinute,
701 snoozeWakeTick,
702 snoozedShelfExpanded,
703 settledShelfExpanded,
704 settledVisibleCount,
705 settlementEnvironmentIds,
706 snoozeEnvironmentIds,
707 props.searchQuery,
708 props.selectedEnvironmentId,
709 props.threads,
710 matchedThreadKeys,
711 threadListV2Enabled,
712 v2ScopedProjectGroup,
713 ]);
714 // Re-partition the moment the earliest snooze expires (clamped to the
715 // signed-32-bit setTimeout range; far-future wakes re-arm at the clamp).
716 const nextSnoozeWakeAt = threadListV2Layout.nextSnoozeWakeAt;
717 useEffect(() => {
718 if (nextSnoozeWakeAt === null) return;
719 const wakeAtMs = Date.parse(nextSnoozeWakeAt);
720 if (Number.isNaN(wakeAtMs)) return;
721 const delayMs = Math.min(Math.max(0, wakeAtMs - Date.now()) + 50, 2_147_483_647);
722 const id = setTimeout(() => bumpSnoozeWakeTick((tick) => tick + 1), delayMs);
723 return () => clearTimeout(id);
724 // snoozeWakeTick must re-arm the timer even when nextSnoozeWakeAt is
725 // unchanged: after a clamped fire (wake beyond the 32-bit setTimeout
726 // range) the boundary string is identical and the chain would die.
727 }, [nextSnoozeWakeAt, snoozeWakeTick]);
728 // Queued tasks are not thread shells, so the v2 partition never sees them;
729 // they are spliced in below the active block and stay visible and deletable
730 // while their environment is offline. Same environment scope and search
731 // filter as the list itself.
732 const v2SearchQuery = props.searchQuery.trim().toLocaleLowerCase();
733 const v2PendingTasks = useMemo(
734 () =>
735 props.pendingTasks.filter(
736 (pendingTask) =>
737 (props.selectedEnvironmentId === null ||
738 pendingTask.environmentId === props.selectedEnvironmentId) &&
739 (v2ScopedProjectKeys === null ||
740 v2ScopedProjectKeys.has(
741 scopedProjectKey(pendingTask.environmentId, pendingTask.projectId),
742 )) &&
743 (v2SearchQuery.length === 0 ||
744 pendingTask.title.toLocaleLowerCase().includes(v2SearchQuery)),
745 ),
746 [props.pendingTasks, props.selectedEnvironmentId, v2ScopedProjectKeys, v2SearchQuery],
747 );
748 const threadListV2Items = useMemo(
749 () =>
750 buildThreadListV2ListItems({
751 items: threadListV2Layout.items,
752 pendingTasks: v2PendingTasks,
753 snoozedCount: threadListV2Layout.snoozedCount,
754 snoozedShelfExpanded,
755 snoozedShelfHeaderIndex: threadListV2Layout.snoozedShelfHeaderIndex,
756 settledCount: threadListV2Layout.settledCount,
757 settledShelfExpanded,
758 settledShelfHeaderIndex: threadListV2Layout.settledShelfHeaderIndex,
759 snoozeLabelNow: `${nowMinute}:00.000Z`,
760 }),
761 [settledShelfExpanded, snoozedShelfExpanded, threadListV2Layout, v2PendingTasks],
762 );
763
764 const renderV2Item = useCallback(
765 ({ item, index }: { readonly item: ThreadListV2ListItem; readonly index: number }) => {
766 const nextItem = threadListV2Items[index + 1];
767 const showTrailingDivider =
768 nextItem?.type === "v2-thread" ||
769 (nextItem?.type === "v2-pending" && !nextItem.showPendingDivider);
770 if (item.type === "v2-pending") {
771 const pendingScopeKey = scopedProjectKey(
772 item.pendingTask.environmentId,
773 item.pendingTask.projectId,
774 );
775 return (
776 <ThreadListV2PendingRow
777 pendingTask={item.pendingTask}
778 project={projectByKey.get(pendingScopeKey) ?? null}
779 projectTitle={v2ProjectTitleByProjectKey.get(pendingScopeKey)}
780 environmentLabel={
781 Object.keys(props.savedConnectionsById).length > 1
782 ? (props.savedConnectionsById[item.pendingTask.environmentId]?.environmentLabel ??
783 null)
784 : null
785 }
786 environmentMachine={machineByEnvironmentId.get(item.pendingTask.environmentId)}
787 showPendingDivider={item.showPendingDivider}
788 showTrailingDivider={showTrailingDivider}
789 onSelectPendingTask={props.onSelectPendingTask}
790 onDeletePendingTask={props.onDeletePendingTask}
791 />
792 );
793 }
794 if (item.type === "v2-snoozed-shelf") {
795 return (
796 <ThreadListV2SnoozedShelfHeader
797 count={item.count}
798 disabled={!shelfPreferencesLoaded}
799 expanded={item.expanded}
800 onToggle={toggleSnoozedShelf}
801 />
802 );
803 }
804 if (item.type === "v2-settled-shelf") {
805 return (
806 <ThreadListV2SettledShelfHeader
807 count={item.count}
808 disabled={!shelfPreferencesLoaded}
809 expanded={item.expanded}
810 onToggle={toggleSettledShelf}
811 />
812 );
813 }
814 const thread = item.item.thread;
815 const movePlanner = item.item.pinned ? threadMovePlanners.pinned : threadMovePlanners.active;
816 const movedId = `${thread.environmentId}:${thread.id}`;
817 return (
818 <ThreadListV2Row
819 thread={thread}
820 variant={item.item.variant}
821 snoozed={item.item.snoozed}
822 pinned={item.item.pinned}
823 snoozePresetMinute={nowMinute}
824 snoozeWakeLabelText={item.snoozeWakeLabelText}
825 showTrailingDivider={showTrailingDivider}
826 project={
827 projectByKey.get(scopedProjectKey(thread.environmentId, thread.projectId)) ?? null
828 }
829 projectTitle={v2ProjectTitleByProjectKey.get(
830 scopedProjectKey(thread.environmentId, thread.projectId),
831 )}
832 providerDriver={
833 serverConfigs
834 .get(thread.environmentId)
835 ?.providers.find(
836 (provider) =>
837 provider.instanceId ===
838 (thread.session?.providerInstanceId ?? thread.modelSelection.instanceId),
839 )?.driver ?? null
840 }
841 environmentLabel={
842 Object.keys(props.savedConnectionsById).length > 1
843 ? (props.savedConnectionsById[thread.environmentId]?.environmentLabel ?? null)
844 : null
845 }
846 environmentMachine={machineByEnvironmentId.get(thread.environmentId)}
847 searchMatch={threadSearchMatchByKey.get(
848 threadSearchMatchKey({
849 environmentId: thread.environmentId,
850 threadId: thread.id,
851 }),
852 )}
853 searchQuery={props.searchQuery}
854 onSelectThread={props.onSelectThread}
855 onDeleteThread={handleDeleteThread}
856 onArchiveThread={props.onArchiveThread}
857 onRegenerateThreadTitle={handleRegenerateThreadTitle}
858 titleRegenerationSupported={titleRegenerationEnvironmentIds.has(thread.environmentId)}
859 settlementSupported={settlementEnvironmentIds.has(thread.environmentId)}
860 onSettleThread={handleSettleThread}
861 snoozeSupported={snoozeEnvironmentIds.has(thread.environmentId)}
862 pinningSupported={pinningEnvironmentIds.has(thread.environmentId)}
863 reorderSupported={
864 item.item.pinned
865 ? pinReorderEnvironmentIds.has(thread.environmentId)
866 : activeReorderEnvironmentIds.has(thread.environmentId)
867 }
868 canMoveUp={pendingOrder === null && movePlanner(movedId, "up") !== null}
869 canMoveDown={pendingOrder === null && movePlanner(movedId, "down") !== null}
870 onSnoozeThread={handleSnoozeThread}
871 onUnsnoozeThread={handleUnsnoozeThread}
872 onUnsettleThread={handleUnsettleThread}
873 onPinThread={handlePinThread}
874 onUnpinThread={handleUnpinThread}
875 onMoveThread={handleMoveThread}
876 onSwipeableClose={handleSwipeableClose}
877 onSwipeableWillOpen={handleSwipeableWillOpen}
878 />
879 );
880 },
881 [
882 handleDeleteThread,
883 activeReorderEnvironmentIds,
884 threadMovePlanners,
885 pendingOrder,
886 handleMoveThread,
887 handlePinThread,
888 handleRegenerateThreadTitle,
889 handleSettleThread,
890 handleSnoozeThread,
891 handleUnpinThread,
892 handleUnsnoozeThread,
893 handleSwipeableClose,
894 handleSwipeableWillOpen,
895 handleUnsettleThread,
896 pinningEnvironmentIds,
897 machineByEnvironmentId,
898 pinReorderEnvironmentIds,
899 projectByKey,
900 props.onArchiveThread,
901 props.onDeletePendingTask,
902 props.onSelectPendingTask,
903 props.onSelectThread,
904 props.savedConnectionsById,
905 serverConfigs,
906 shelfPreferencesLoaded,
907 settlementEnvironmentIds,
908 snoozeEnvironmentIds,
909 threadListV2Items,
910 threadSearchMatchByKey,
911 titleRegenerationEnvironmentIds,
912 toggleSettledShelf,
913 toggleSnoozedShelf,
914 v2ProjectTitleByProjectKey,
915 props.searchQuery,
916 nowMinute,
917 ],
918 );
919 const v2KeyExtractor = useCallback((item: ThreadListV2ListItem) => item.key, []);
920
921 // FlatList treats a changed extraData identity as "re-render every visible
922 // row", so an inline object literal would invalidate all rows on every
923 // HomeScreen render.
924 const v2ExtraData = useMemo(
925 () => ({
926 projectByKey,
927 projectTitleByProjectKey: v2ProjectTitleByProjectKey,
928 serverConfigs,
929 savedConnectionsById: props.savedConnectionsById,
930 searchQuery: props.searchQuery,
931 snoozePresetMinute: nowMinute,
932 threadSearchMatchByKey,
933 }),
934 [
935 projectByKey,
936 props.searchQuery,
937 props.savedConnectionsById,
938 serverConfigs,
939 nowMinute,
940 threadSearchMatchByKey,
941 v2ProjectTitleByProjectKey,
942 ],
943 );
944
945 const extraData = useMemo(
946 () => ({
947 savedConnectionsById: props.savedConnectionsById,
948 searchQuery: props.searchQuery,
949 threadSearchMatchByKey,
950 }),
951 [props.savedConnectionsById, props.searchQuery, threadSearchMatchByKey],
952 );
953
954 const renderItem = useCallback(
955 ({ item }: LegendListRenderItemProps<HomeListItem>) => {
956 switch (item.type) {
957 case "header":
958 return (
959 <ThreadListGroupHeader
960 variant="compact"
961 collapsed={item.collapsed}
962 isFirst={item.isFirst}
963 groupKey={item.group.key}
964 onGroupAction={updateGroupDisplay}
965 // Aggregated groups (same repo across machines) have no single
966 // target project, and `pending-project:` groups hold a placeholder
967 // built from queued-task metadata rather than a real project shell,
968 // so the quick new-thread button is single-real-project only.
969 newThreadTarget={item.group.newThreadTarget}
970 onNewThread={props.onNewThreadInProject}
971 project={item.group.representative}
972 threadCount={item.group.threads.length + item.group.pendingTasks.length}
973 title={item.group.title}
974 />
975 );
976 case "pending-task":
977 return (
978 <PendingTaskListRow
979 variant="compact"
980 pendingTask={item.pendingTask}
981 environmentLabel={
982 props.savedConnectionsById[item.pendingTask.environmentId]?.environmentLabel ?? null
983 }
984 environmentMachine={machineByEnvironmentId.get(item.pendingTask.environmentId)}
985 isLast={item.isLast}
986 onSelectPendingTask={props.onSelectPendingTask}
987 onDeletePendingTask={props.onDeletePendingTask}
988 />
989 );
990 case "thread": {
991 const thread = item.thread;
992 return (
993 <ThreadListRow
994 variant="compact"
995 thread={thread}
996 environmentLabel={
997 props.savedConnectionsById[thread.environmentId]?.environmentLabel ?? null
998 }
999 environmentMachine={machineByEnvironmentId.get(thread.environmentId)}
1000 isLast={item.isLast}
1001 searchMatch={threadSearchMatchByKey.get(
1002 threadSearchMatchKey({
1003 environmentId: thread.environmentId,
1004 threadId: thread.id,
1005 }),
1006 )}
1007 searchQuery={props.searchQuery}
1008 onArchiveThread={props.onArchiveThread}
1009 onDeleteThread={props.onDeleteThread}
1010 onRegenerateThreadTitle={handleRegenerateThreadTitle}
1011 titleRegenerationSupported={titleRegenerationEnvironmentIds.has(thread.environmentId)}
1012 onSelectThread={props.onSelectThread}
1013 onSwipeableClose={handleSwipeableClose}
1014 onSwipeableWillOpen={handleSwipeableWillOpen}
1015 />
1016 );
1017 }
1018 case "show-more":
1019 return (
1020 <ThreadListShowMoreRow
1021 variant="compact"
1022 hiddenCount={item.hiddenCount}
1023 canShowLess={item.canShowLess}
1024 groupKey={item.groupKey}
1025 onGroupAction={updateGroupDisplay}
1026 />
1027 );
1028 }
1029 },
1030 [
1031 handleSwipeableClose,
1032 handleSwipeableWillOpen,
1033 handleRegenerateThreadTitle,
1034 machineByEnvironmentId,
1035 props.onArchiveThread,
1036 props.onDeletePendingTask,
1037 props.onDeleteThread,
1038 props.onNewThreadInProject,
1039 props.onSelectPendingTask,
1040 props.onSelectThread,
1041 props.searchQuery,
1042 props.savedConnectionsById,
1043 threadSearchMatchByKey,
1044 titleRegenerationEnvironmentIds,
1045 updateGroupDisplay,
1046 ],
1047 );
1048
1049 const keyExtractor = useCallback((item: HomeListItem) => item.key, []);
1050
1051 /* Empty states */
1052 // The signal must ignore the search/environment filters: an active query
1053 // that matches nothing needs the in-list "No results" state, not the
1054 // full-page "No threads yet". Settled threads are unarchived live shells,
1055 // so the v1 check already covers v2.
1056 const hasAnyThreads =
1057 props.threads.some((thread) => thread.archivedAt === null) || props.pendingTasks.length > 0;
1058 const hasResults = threadListV2Enabled ? threadListV2Items.length > 0 : projectGroups.length > 0;
1059 const selectedEnvironmentLabel =
1060 props.selectedEnvironmentId === null
1061 ? null
1062 : (props.savedConnectionsById[props.selectedEnvironmentId]?.environmentLabel ??
1063 "this environment");
1064 // Connection state surfaces in the header title slot
1065 // (WorkspaceConnectionTitle) — nothing renders inside the list, so
1066 // reconnects never shift the rows.
1067 const emptyState = deriveEmptyState({
1068 catalogState: props.catalogState,
1069 projectCount: props.projects.length,
1070 });
1071
1072 if (!hasAnyThreads) {
1073 return (
1074 <View
1075 className="flex-1 items-center justify-center bg-screen px-8"
1076 style={{
1077 paddingBottom: Math.max(insets.bottom, 24) + iosBottomToolbarClearance,
1078 paddingTop: NATIVE_LIQUID_GLASS_SUPPORTED ? insets.top + 72 : 0,
1079 }}
1080 >
1081 <View className="w-full max-w-[430px]">
1082 <EmptyState
1083 title={emptyState.title}
1084 detail={emptyState.detail}
1085 actionLabel={!props.catalogState.hasReadyEnvironment ? "Add environment" : undefined}
1086 onAction={!props.catalogState.hasReadyEnvironment ? props.onAddConnection : undefined}
1087 variant="plain"
1088 />
1089 {emptyState.loading ? (
1090 <View className="mt-4 items-center">
1091 <ActivityIndicator colorClassName={"accent-icon-muted"} />
1092 </View>
1093 ) : null}
1094 </View>
1095 </View>
1096 );
1097 }
1098
1099 const listHeader = Platform.OS === "ios" ? null : <HomeTopContentSpacer />;
1100
1101 // Project scoping lives in the header filter menu (no inline chip row on
1102 // mobile — the menu is the one filter surface).
1103 const v2ListHeader = listHeader;
1104
1105 const listEmpty = !hasResults ? (
1106 hasSearchQuery && threadSearch.isPending ? null : hasSearchQuery ? (
1107 <EmptyState title="No results" detail={`No threads matching "${props.searchQuery}".`} />
1108 ) : selectedProjectScope !== null ? (
1109 <EmptyState
1110 title={`No threads in ${selectedProjectScope.title}`}
1111 detail="Choose another project or create a new task."
1112 />
1113 ) : selectedEnvironmentLabel ? (
1114 <EmptyState
1115 title={`No threads in ${selectedEnvironmentLabel}`}
1116 detail="Choose another environment or create a new task."
1117 />
1118 ) : (
1119 <EmptyState title="No threads yet" detail="Create a task to start a new coding session." />
1120 )
1121 ) : null;
1122 // Use the v2 project scope for its empty state. Snoozed threads need no
1123 // special empty state: their shelf header is a list row even while collapsed.
1124 const v2ListEmpty =
1125 hasSearchQuery && threadSearch.isPending ? null : hasSearchQuery ? (
1126 <EmptyState title="No results" detail={`No threads matching "${props.searchQuery}".`} />
1127 ) : v2ScopedProjectGroup !== null ? (
1128 <EmptyState
1129 title={`No threads in ${v2ScopedProjectGroup.title}`}
1130 detail="Choose another project or create a new task."
1131 />
1132 ) : (
1133 listEmpty
1134 );
1135
1136 if (threadListV2Enabled) {
1137 return (
1138 <View className="flex-1 bg-screen">
1139 <SwipeableScrollGateProvider enabled={swipeEnabled}>
1140 <FlatList
1141 data={threadListV2Items}
1142 renderItem={renderV2Item}
1143 keyExtractor={v2KeyExtractor}
1144 extraData={v2ExtraData}
1145 ListHeaderComponent={v2ListHeader}
1146 ListFooterComponent={
1147 settledShelfExpanded && threadListV2Layout.hiddenSettledCount > 0 ? (
1148 <Pressable
1149 accessibilityRole="button"
1150 accessibilityLabel={`Show ${Math.min(threadListV2Layout.hiddenSettledCount, THREAD_LIST_V2_SETTLED_PAGE_COUNT)} more settled threads`}
1151 onPress={showMoreSettled}
1152 className="mx-4 mt-2 items-center rounded-lg border border-dashed border-border py-2.5"
1153 style={({ pressed }) => ({ opacity: pressed ? 0.6 : 1 })}
1154 >
1155 <Text className="text-xs font-t3-medium text-foreground-muted">
1156 Show more ({threadListV2Layout.hiddenSettledCount} settled hidden)
1157 </Text>
1158 </Pressable>
1159 ) : null
1160 }
1161 ListEmptyComponent={v2ListEmpty}
1162 style={{ flex: 1 }}
1163 automaticallyAdjustsScrollIndicatorInsets={Platform.OS === "ios"}
1164 contentInsetAdjustmentBehavior={Platform.OS === "ios" ? "automatic" : "never"}
1165 showsVerticalScrollIndicator={false}
1166 keyboardDismissMode="on-drag"
1167 keyboardShouldPersistTaps="handled"
1168 {...scrollGateHandlers}
1169 scrollEventThrottle={16}
1170 contentContainerStyle={{
1171 paddingBottom:
1172 Platform.OS === "ios"
1173 ? Math.max(insets.bottom, 24) + 96 + iosBottomToolbarClearance
1174 : Math.max(insets.bottom, 16) + 88,
1175 }}
1176 />
1177 </SwipeableScrollGateProvider>
1178 </View>
1179 );
1180 }
1181
1182 return (
1183 <View className="flex-1 bg-screen">
1184 {/* Sticky headers are deliberately not wired up: LegendList's JS sticky
1185 implementation mispositions pinned headers at mount under iOS
1186 automatic content insets (headers render one nav-inset too low until
1187 the first scroll event) and blanks non-pinned headers after
1188 collapse/expand data changes. The flattened layout still exposes
1189 `stickyHeaderIndices` if this gets revisited. */}
1190 <SwipeableScrollGateProvider enabled={swipeEnabled}>
1191 <LegendList
1192 ref={listRef}
1193 data={listLayout.items}
1194 renderItem={renderItem}
1195 keyExtractor={keyExtractor}
1196 itemsAreEqual={homeListItemsAreEqual}
1197 drawDistance={500}
1198 estimatedItemSize={ESTIMATED_THREAD_ROW_HEIGHT}
1199 extraData={extraData}
1200 ListHeaderComponent={listHeader}
1201 ListEmptyComponent={listEmpty}
1202 style={{ flex: 1 }}
1203 automaticallyAdjustsScrollIndicatorInsets={NATIVE_LIQUID_GLASS_SUPPORTED}
1204 contentInsetAdjustmentBehavior={NATIVE_LIQUID_GLASS_SUPPORTED ? "automatic" : "never"}
1205 showsVerticalScrollIndicator={false}
1206 keyboardDismissMode="on-drag"
1207 keyboardShouldPersistTaps="handled"
1208 {...scrollGateHandlers}
1209 recycleItems
1210 scrollEventThrottle={16}
1211 contentContainerStyle={{
1212 // Android reserves room for the floating new-task FAB
1213 // (56 button + 16 gap + bottom inset). Pre-glass iOS shows a
1214 // standard 44pt bottom toolbar that overlays the list and is not
1215 // reflected in insets while contentInsetAdjustmentBehavior is
1216 // "never".
1217 paddingBottom:
1218 Platform.OS === "ios"
1219 ? Math.max(insets.bottom, 24) + 24 + iosBottomToolbarClearance
1220 : Math.max(insets.bottom, 16) + 88,
1221 }}
1222 scrollIndicatorInsets={
1223 Platform.OS === "ios"
1224 ? {
1225 bottom: Math.max(insets.bottom, 16) + 24 + iosBottomToolbarClearance,
1226 top: 0,
1227 }
1228 : undefined
1229 }
1230 />
1231 </SwipeableScrollGateProvider>
1232 </View>
1233 );
1234}