@devries-cameron20 / t3code Mirror · read-only / commits / 916cff733c
Fork 0

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

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

Synced Nov 24, 19:00 UTC

feat(mobile): make settled threads collapsible (#5056)

Alex committed Jul 31, 2026 at 11:55 UTC 916cff733cd00c85fe0419df5bcb9372a6384746
5 files changed +215 -48
apps/mobile/src/features/home/HomeScreen.tsx
+22 -3
@@ -44,6 +44,7 @@ import {
44 import {
45 ThreadListV2PendingRow,
46 ThreadListV2Row,
47 + ThreadListV2SettledShelfHeader,
48 ThreadListV2SnoozedShelfHeader,
49 } from "../threads/thread-list-v2-items";
50 import {
@@ -534,6 +535,8 @@ export function HomeScreen(props: HomeScreenProps) {
535 );
536 const [snoozedShelfExpanded, setSnoozedShelfExpanded] = useState(false);
537 const toggleSnoozedShelf = useCallback(() => setSnoozedShelfExpanded((value) => !value), []);
538 + const [settledShelfExpanded, setSettledShelfExpanded] = useState(true);
539 + const toggleSettledShelf = useCallback(() => setSettledShelfExpanded((value) => !value), []);
540 // now is quantized to the minute and ticks so the inactivity auto-settle
541 // boundary is actually crossed while the app stays open (mirrors web);
542 // without a clock dependency the partition memoizes a frozen "now".
@@ -579,6 +582,8 @@ export function HomeScreen(props: HomeScreenProps) {
582 hiddenSettledCount: 0,
583 snoozedCount: 0,
584 snoozedShelfHeaderIndex: null,
585 + settledCount: 0,
586 + settledShelfHeaderIndex: null,
587 nextSnoozeWakeAt: null,
588 };
589 // Settled threads are live shells; archived threads keep their original
@@ -596,6 +601,7 @@ export function HomeScreen(props: HomeScreenProps) {
601 now: `${nowMinute}:00.000Z`,
602 snoozeNow: new Date().toISOString(),
603 snoozedShelfExpanded,
604 + settledShelfExpanded,
605 selectedThreadKey: null,
606 });
607 }, [
@@ -603,6 +609,7 @@ export function HomeScreen(props: HomeScreenProps) {
609 nowMinute,
610 snoozeWakeTick,
611 snoozedShelfExpanded,
612 + settledShelfExpanded,
613 settledVisibleCount,
614 settlementEnvironmentIds,
615 snoozeEnvironmentIds,
@@ -655,9 +662,12 @@ export function HomeScreen(props: HomeScreenProps) {
662 snoozedCount: threadListV2Layout.snoozedCount,
663 snoozedShelfExpanded,
664 snoozedShelfHeaderIndex: threadListV2Layout.snoozedShelfHeaderIndex,
665 + settledCount: threadListV2Layout.settledCount,
666 + settledShelfExpanded,
667 + settledShelfHeaderIndex: threadListV2Layout.settledShelfHeaderIndex,
668 snoozeLabelNow: `${nowMinute}:00.000Z`,
669 }),
660 - [snoozedShelfExpanded, threadListV2Layout, v2PendingTasks],
670 + [settledShelfExpanded, snoozedShelfExpanded, threadListV2Layout, v2PendingTasks],
671 );
672
673 const renderV2Item = useCallback(
@@ -693,12 +703,20 @@ export function HomeScreen(props: HomeScreenProps) {
703 />
704 );
705 }
706 + if (item.type === "v2-settled-shelf") {
707 + return (
708 + <ThreadListV2SettledShelfHeader
709 + count={item.count}
710 + expanded={item.expanded}
711 + onToggle={toggleSettledShelf}
712 + />
713 + );
714 + }
715 const thread = item.item.thread;
716 return (
717 <ThreadListV2Row
718 thread={thread}
719 variant={item.item.variant}
701 - showSettledDivider={item.item.showSettledDivider}
720 snoozed={item.item.snoozed}
721 snoozePresetMinute={nowMinute}
722 snoozeWakeLabelText={item.snoozeWakeLabelText}
@@ -767,6 +785,7 @@ export function HomeScreen(props: HomeScreenProps) {
785 settlementEnvironmentIds,
786 snoozeEnvironmentIds,
787 threadSearchMatchByKey,
788 + toggleSettledShelf,
789 toggleSnoozedShelf,
790 v2ProjectTitleByProjectKey,
791 props.searchQuery,
@@ -1036,7 +1055,7 @@ export function HomeScreen(props: HomeScreenProps) {
1055 extraData={v2ExtraData}
1056 ListHeaderComponent={v2ListHeader}
1057 ListFooterComponent={
1039 - threadListV2Layout.hiddenSettledCount > 0 ? (
1058 + settledShelfExpanded && threadListV2Layout.hiddenSettledCount > 0 ? (
1059 <Pressable
1060 accessibilityRole="button"
1061 accessibilityLabel={`Show ${Math.min(threadListV2Layout.hiddenSettledCount, THREAD_LIST_V2_SETTLED_PAGE_COUNT)} more settled threads`}
apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
+28 -4
@@ -70,6 +70,7 @@ import {
70 import {
71 ThreadListV2PendingRow,
72 ThreadListV2Row,
73 + ThreadListV2SettledShelfHeader,
74 ThreadListV2SnoozedShelfHeader,
75 } from "./thread-list-v2-items";
76 import {
@@ -440,6 +441,8 @@ function ThreadNavigationSidebarPane(
441 );
442 const [snoozedShelfExpanded, setSnoozedShelfExpanded] = useState(false);
443 const toggleSnoozedShelf = useCallback(() => setSnoozedShelfExpanded((value) => !value), []);
444 + const [settledShelfExpanded, setSettledShelfExpanded] = useState(true);
445 + const toggleSettledShelf = useCallback(() => setSettledShelfExpanded((value) => !value), []);
446 // now ticks per minute so the inactivity auto-settle boundary is actually
447 // crossed while the pane stays open; without a clock dependency the
448 // partition memoizes a frozen "now".
@@ -485,6 +488,8 @@ function ThreadNavigationSidebarPane(
488 hiddenSettledCount: 0,
489 snoozedCount: 0,
490 snoozedShelfHeaderIndex: null,
491 + settledCount: 0,
492 + settledShelfHeaderIndex: null,
493 nextSnoozeWakeAt: null,
494 };
495 return buildThreadListV2Items({
@@ -500,6 +505,7 @@ function ThreadNavigationSidebarPane(
505 now: `${nowMinute}:00.000Z`,
506 snoozeNow: new Date().toISOString(),
507 snoozedShelfExpanded,
508 + settledShelfExpanded,
509 selectedThreadKey: props.selectedThreadKey ?? null,
510 });
511 }, [
@@ -507,6 +513,7 @@ function ThreadNavigationSidebarPane(
513 nowMinute,
514 snoozeWakeTick,
515 snoozedShelfExpanded,
516 + settledShelfExpanded,
517 props.selectedThreadKey,
518 options.selectedEnvironmentId,
519 props.searchQuery,
@@ -557,9 +564,12 @@ function ThreadNavigationSidebarPane(
564 snoozedCount: threadListV2Layout.snoozedCount,
565 snoozedShelfExpanded,
566 snoozedShelfHeaderIndex: threadListV2Layout.snoozedShelfHeaderIndex,
567 + settledCount: threadListV2Layout.settledCount,
568 + settledShelfExpanded,
569 + settledShelfHeaderIndex: threadListV2Layout.settledShelfHeaderIndex,
570 snoozeLabelNow: `${nowMinute}:00.000Z`,
571 });
562 - if (threadListV2Layout.hiddenSettledCount > 0) {
572 + if (settledShelfExpanded && threadListV2Layout.hiddenSettledCount > 0) {
573 items.push({
574 type: "v2-show-more",
575 key: "v2-show-more",
@@ -574,6 +584,7 @@ function ThreadNavigationSidebarPane(
584 pendingTasks,
585 props.searchQuery,
586 selectedProjectRefs,
587 + settledShelfExpanded,
588 snoozedShelfExpanded,
589 threadListV2Enabled,
590 threadListV2Layout,
@@ -780,7 +791,6 @@ function ThreadNavigationSidebarPane(
791 previous.key === item.key &&
792 previous.item.thread === item.item.thread &&
793 previous.item.variant === item.item.variant &&
783 - previous.item.showSettledDivider === item.item.showSettledDivider &&
794 previous.item.snoozed === item.item.snoozed &&
795 previous.snoozeWakeLabelText === item.snoozeWakeLabelText
796 );
@@ -797,15 +807,20 @@ function ThreadNavigationSidebarPane(
807 if (previous.type === "v2-snoozed-shelf" && item.type === "v2-snoozed-shelf") {
808 return previous.count === item.count && previous.expanded === item.expanded;
809 }
810 + if (previous.type === "v2-settled-shelf" && item.type === "v2-settled-shelf") {
811 + return previous.count === item.count && previous.expanded === item.expanded;
812 + }
813 if (
814 previous.type === "v2-thread" ||
815 previous.type === "v2-show-more" ||
816 previous.type === "v2-pending" ||
817 previous.type === "v2-snoozed-shelf" ||
818 + previous.type === "v2-settled-shelf" ||
819 item.type === "v2-thread" ||
820 item.type === "v2-show-more" ||
821 item.type === "v2-pending" ||
808 - item.type === "v2-snoozed-shelf"
822 + item.type === "v2-snoozed-shelf" ||
823 + item.type === "v2-settled-shelf"
824 ) {
825 return false;
826 }
@@ -863,7 +878,6 @@ function ThreadNavigationSidebarPane(
878 <ThreadListV2Row
879 thread={thread}
880 variant={item.item.variant}
866 - showSettledDivider={item.item.showSettledDivider}
881 snoozed={item.item.snoozed}
882 snoozePresetMinute={nowMinute}
883 snoozeWakeLabelText={item.snoozeWakeLabelText}
@@ -921,6 +935,15 @@ function ThreadNavigationSidebarPane(
935 pane="sidebar"
936 />
937 );
938 + case "v2-settled-shelf":
939 + return (
940 + <ThreadListV2SettledShelfHeader
941 + count={item.count}
942 + expanded={item.expanded}
943 + onToggle={toggleSettledShelf}
944 + pane="sidebar"
945 + />
946 + );
947 case "v2-show-more":
948 return (
949 <Pressable
@@ -1039,6 +1062,7 @@ function ThreadNavigationSidebarPane(
1062 snoozeEnvironmentIds,
1063 snoozeThread,
1064 nowMinute,
1065 + toggleSettledShelf,
1066 toggleSnoozedShelf,
1067 unsettleThread,
1068 unsnoozeThread,
apps/mobile/src/features/threads/thread-list-v2-items.tsx
+36 -4
@@ -149,6 +149,42 @@ export const ThreadListV2SnoozedShelfHeader = memo(function ThreadListV2SnoozedS
149 );
150 });
151
152 +export const ThreadListV2SettledShelfHeader = memo(function ThreadListV2SettledShelfHeader(props: {
153 + readonly count: number;
154 + readonly expanded: boolean;
155 + readonly onToggle: () => void;
156 + readonly pane?: "screen" | "sidebar";
157 +}) {
158 + const mutedColor = useThemeColor("--color-foreground-muted");
159 + return (
160 + <Pressable
161 + accessibilityHint={
162 + props.expanded ? "Collapses the settled threads." : "Expands the settled threads."
163 + }
164 + accessibilityLabel={props.count === 1 ? "1 settled thread" : `${props.count} settled threads`}
165 + accessibilityRole="button"
166 + accessibilityState={{ expanded: props.expanded }}
167 + className={cn(
168 + "mb-1.5 mt-4 flex-row items-center gap-2.5",
169 + props.pane === "sidebar" ? "px-3" : "px-5",
170 + )}
171 + onPress={props.onToggle}
172 + style={({ pressed }) => ({ opacity: pressed ? 0.6 : 1 })}
173 + >
174 + <Text className="text-xs font-t3-medium text-foreground-tertiary">
175 + {props.expanded ? "Settled" : `Settled (${props.count})`}
176 + </Text>
177 + <View className="h-px flex-1 bg-border" />
178 + <SymbolView
179 + name={props.expanded ? "chevron.up" : "chevron.down"}
180 + size={10}
181 + tintColor={mutedColor}
182 + type="monochrome"
183 + />
184 + </Pressable>
185 + );
186 +});
187 +
188 const PENDING_TASK_MENU_ACTIONS: MenuAction[] = [
189 { id: "delete", title: "Delete", image: "trash", attributes: { destructive: true } },
190 ];
@@ -267,7 +303,6 @@ export const ThreadListV2PendingRow = memo(function ThreadListV2PendingRow(props
303 export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
304 readonly thread: EnvironmentThreadShell;
305 readonly variant: "card" | "slim";
270 - readonly showSettledDivider: boolean;
306 /** Snoozed-shelf row: shows its wake time and offers Wake. */
307 readonly snoozed?: boolean;
308 /** Preformatted against the parent minute tick so this memoized row's
@@ -739,9 +774,6 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
774
775 return (
776 <>
742 - {props.showSettledDivider ? (
743 - <ThreadListV2SectionDivider label="Settled" pane={props.pane} />
744 - ) : null}
777 <ThreadSwipeable
778 backgroundColor={sidebarPane ? drawerColor : screenColor}
779 compactActions={variant === "slim"}
apps/mobile/src/features/threads/threadListV2.test.ts
+73 -9
@@ -425,8 +425,8 @@ describe("buildThreadListV2Items", () => {
425 expect(layout.snoozedCount).toBe(0);
426 });
427
428 - it("partitions settled threads into a slim tail with one divider", () => {
429 - const { items } = buildThreadListV2Items({
428 + it("partitions settled threads into a slim shelf", () => {
429 + const layout = buildThreadListV2Items({
430 threads: [
431 makeThread({ id: ThreadId.make("active"), title: "Active" }),
432 makeThread({
@@ -447,13 +447,64 @@ describe("buildThreadListV2Items", () => {
447 now: NOW,
448 });
449
450 - expect(items.map((item) => [item.thread.id, item.variant])).toEqual([
450 + expect(layout.items.map((item) => [item.thread.id, item.variant])).toEqual([
451 ["active", "card"],
452 ["settled", "slim"],
453 ["settled-2", "slim"],
454 ]);
455 - expect(items.map((item) => item.showSettledDivider)).toEqual([false, true, false]);
456 - expect(items.map((item) => item.isLast)).toEqual([false, false, true]);
455 + expect(layout.items.map((item) => item.isLast)).toEqual([false, false, true]);
456 + expect(layout.settledCount).toBe(2);
457 + expect(layout.settledShelfHeaderIndex).toBe(1);
458 + });
459 +
460 + it("collapses settled threads to a counted shelf header", () => {
461 + const layout = buildThreadListV2Items({
462 + threads: [
463 + makeThread({ id: ThreadId.make("active"), title: "Active" }),
464 + makeThread({
465 + id: ThreadId.make("settled"),
466 + title: "Settled",
467 + settledOverride: "settled",
468 + settledAt: NOW,
469 + }),
470 + ],
471 + environmentId: null,
472 + searchQuery: "",
473 + now: NOW,
474 + settledShelfExpanded: false,
475 + });
476 +
477 + expect(layout.items.map((item) => item.thread.id)).toEqual(["active"]);
478 + expect(layout.settledCount).toBe(1);
479 + expect(layout.settledShelfHeaderIndex).toBe(1);
480 + });
481 +
482 + it("keeps the selected settled thread visible when its shelf is collapsed", () => {
483 + const layout = buildThreadListV2Items({
484 + threads: [
485 + makeThread({
486 + id: ThreadId.make("selected"),
487 + title: "Selected",
488 + settledOverride: "settled",
489 + settledAt: NOW,
490 + }),
491 + makeThread({
492 + id: ThreadId.make("other"),
493 + title: "Other",
494 + settledOverride: "settled",
495 + settledAt: NOW,
496 + }),
497 + ],
498 + environmentId: null,
499 + searchQuery: "",
500 + now: NOW,
501 + settledShelfExpanded: false,
502 + selectedThreadKey: `${environmentId}:selected`,
503 + });
504 +
505 + expect(layout.items.map((item) => item.thread.id)).toEqual(["selected"]);
506 + expect(layout.settledCount).toBe(2);
507 + expect(layout.settledShelfHeaderIndex).toBe(0);
508 });
509
510 it("keeps cards in creation order while settled sorts by recency", () => {
@@ -658,6 +709,8 @@ describe("buildThreadListV2ListItems", () => {
709 const items = buildThreadListV2ListItems({
710 items: layout.items,
711 pendingTasks: [makePendingTask("queued-1"), makePendingTask("queued-2")],
712 + settledCount: layout.settledCount,
713 + settledShelfHeaderIndex: layout.settledShelfHeaderIndex,
714 });
715
716 expect(
@@ -666,9 +719,11 @@ describe("buildThreadListV2ListItems", () => {
719 ? item.pendingTask.title
720 : item.type === "v2-thread"
721 ? item.item.thread.id
669 - : "snoozed-shelf",
722 + : item.type === "v2-snoozed-shelf"
723 + ? "snoozed-shelf"
724 + : "settled-shelf",
725 ),
671 - ).toEqual(["active", "queued-1", "queued-2", "settled"]);
726 + ).toEqual(["active", "queued-1", "queued-2", "settled-shelf", "settled"]);
727 // Only the leading queued row labels the section, exactly like Settled.
728 expect(
729 items.filter((item) => item.type === "v2-pending" && item.showPendingDivider),
@@ -690,11 +745,17 @@ describe("buildThreadListV2ListItems", () => {
745 expect(items.map((item) => item.type)).toEqual(["v2-thread", "v2-pending"]);
746 });
747
693 - it("leaves the thread order untouched when nothing is queued", () => {
694 - const items = buildThreadListV2ListItems({ items: layout.items, pendingTasks: [] });
748 + it("keeps the settled shelf between active and settled rows when nothing is queued", () => {
749 + const items = buildThreadListV2ListItems({
750 + items: layout.items,
751 + pendingTasks: [],
752 + settledCount: layout.settledCount,
753 + settledShelfHeaderIndex: layout.settledShelfHeaderIndex,
754 + });
755
756 expect(items.map((item) => item.key)).toEqual([
757 `v2-thread:${environmentId}:active`,
758 + "v2-settled-shelf",
759 `v2-thread:${environmentId}:settled`,
760 ]);
761 });
@@ -726,12 +787,15 @@ describe("buildThreadListV2ListItems", () => {
787 snoozedCount: snoozedLayout.snoozedCount,
788 snoozedShelfExpanded: false,
789 snoozedShelfHeaderIndex: snoozedLayout.snoozedShelfHeaderIndex,
790 + settledCount: snoozedLayout.settledCount,
791 + settledShelfHeaderIndex: snoozedLayout.settledShelfHeaderIndex,
792 });
793
794 expect(items.map((item) => item.type)).toEqual([
795 "v2-thread",
796 "v2-pending",
797 "v2-snoozed-shelf",
798 + "v2-settled-shelf",
799 "v2-thread",
800 ]);
801 });
apps/mobile/src/features/threads/threadListV2.ts
+56 -28
@@ -178,8 +178,6 @@ export function sortThreadsForListV2<T extends { readonly id: string; readonly c
178 export interface ThreadListV2Item {
179 readonly thread: EnvironmentThreadShell;
180 readonly variant: "card" | "slim";
181 - /** First settled row after the card block draws the SETTLED divider. */
182 - readonly showSettledDivider: boolean;
181 /** Snoozed-shelf row: shows the wake countdown and offers Wake. */
182 readonly snoozed: boolean;
183 readonly isLast: boolean;
@@ -194,6 +192,10 @@ export interface ThreadListV2Layout {
192 /** Index in `items` where the Snoozed shelf header belongs. The header is
193 still rendered when the shelf is collapsed and no snoozed rows exist. */
194 readonly snoozedShelfHeaderIndex: number | null;
195 + /** Total settled threads in scope, including rows hidden by collapse/paging. */
196 + readonly settledCount: number;
197 + /** Index in `items` where the Settled shelf header belongs. */
198 + readonly settledShelfHeaderIndex: number | null;
199 /** Soonest wake time among snoozed threads, or null. Callers arm
200 a timeout at this boundary so the list re-partitions the moment a
201 snooze expires instead of on the next minute tick. */
@@ -223,10 +225,18 @@ export interface ThreadListV2SnoozedShelfListItem {
225 readonly expanded: boolean;
226 }
227
228 +export interface ThreadListV2SettledShelfListItem {
229 + readonly type: "v2-settled-shelf";
230 + readonly key: "v2-settled-shelf";
231 + readonly count: number;
232 + readonly expanded: boolean;
233 +}
234 +
235 export type ThreadListV2ListItem =
236 | ThreadListV2ThreadListItem
237 | ThreadListV2PendingListItem
229 - | ThreadListV2SnoozedShelfListItem;
238 + | ThreadListV2SnoozedShelfListItem
239 + | ThreadListV2SettledShelfListItem;
240
241 /**
242 * Builds the shared mobile order: active → pending → snoozed shelf → settled.
@@ -239,6 +249,9 @@ export function buildThreadListV2ListItems(input: {
249 readonly snoozedCount?: number;
250 readonly snoozedShelfExpanded?: boolean;
251 readonly snoozedShelfHeaderIndex?: number | null;
252 + readonly settledCount?: number;
253 + readonly settledShelfExpanded?: boolean;
254 + readonly settledShelfHeaderIndex?: number | null;
255 readonly snoozeLabelNow?: string;
256 }): ThreadListV2ListItem[] {
257 const threadItems = input.items.map(
@@ -262,27 +275,30 @@ export function buildThreadListV2ListItems(input: {
275 );
276 const snoozedCount = input.snoozedCount ?? 0;
277 const snoozedShelfHeaderIndex = input.snoozedShelfHeaderIndex ?? null;
278 + const settledCount = input.settledCount ?? 0;
279 + const settledShelfHeaderIndex = input.settledShelfHeaderIndex ?? null;
280 + const activeEnd = snoozedShelfHeaderIndex ?? settledShelfHeaderIndex ?? threadItems.length;
281 + const snoozedEnd = settledShelfHeaderIndex ?? threadItems.length;
282 + const result: ThreadListV2ListItem[] = [...threadItems.slice(0, activeEnd), ...pendingItems];
283 if (snoozedShelfHeaderIndex !== null && snoozedCount > 0) {
266 - return [
267 - ...threadItems.slice(0, snoozedShelfHeaderIndex),
268 - ...pendingItems,
269 - {
270 - type: "v2-snoozed-shelf",
271 - key: "v2-snoozed-shelf",
272 - count: snoozedCount,
273 - expanded: input.snoozedShelfExpanded === true,
274 - },
275 - ...threadItems.slice(snoozedShelfHeaderIndex),
276 - ];
284 + result.push({
285 + type: "v2-snoozed-shelf",
286 + key: "v2-snoozed-shelf",
287 + count: snoozedCount,
288 + expanded: input.snoozedShelfExpanded === true,
289 + });
290 + result.push(...threadItems.slice(snoozedShelfHeaderIndex, snoozedEnd));
291 }
278 - if (pendingItems.length === 0) return threadItems;
279 -
280 - const settledStart = threadItems.findIndex(
281 - (entry) => entry.type === "v2-thread" && entry.item.showSettledDivider,
282 - );
283 - return settledStart === -1
284 - ? [...threadItems, ...pendingItems]
285 - : [...threadItems.slice(0, settledStart), ...pendingItems, ...threadItems.slice(settledStart)];
292 + if (settledShelfHeaderIndex !== null && settledCount > 0) {
293 + result.push({
294 + type: "v2-settled-shelf",
295 + key: "v2-settled-shelf",
296 + count: settledCount,
297 + expanded: input.settledShelfExpanded !== false,
298 + });
299 + result.push(...threadItems.slice(settledShelfHeaderIndex));
300 + }
301 + return result;
302 }
303
304 /**
@@ -321,6 +337,8 @@ export function buildThreadListV2Items(input: {
337 readonly snoozeNow?: string;
338 /** Expands the snoozed shelf into rows. Collapsed is the default. */
339 readonly snoozedShelfExpanded?: boolean;
340 + /** Expands the settled shelf into rows. Expanded is the default. */
341 + readonly settledShelfExpanded?: boolean;
342 /** The selected thread remains visible on an otherwise collapsed shelf so
343 a split-view detail can never lose its navigation row. */
344 readonly selectedThreadKey?: string | null;
@@ -402,15 +420,24 @@ export function buildThreadListV2Items(input: {
420 firstValidTimestampMs(left.latestUserMessageAt, left.updatedAt),
421 );
422 const settledLimit = input.settledLimit ?? Number.POSITIVE_INFINITY;
405 - const visibleSettled =
423 + const pagedSettled =
424 orderedSettled.length > settledLimit ? orderedSettled.slice(0, settledLimit) : orderedSettled;
425 + const selectedSettled = orderedSettled
426 + .slice(pagedSettled.length)
427 + .find((thread) => `${thread.environmentId}:${thread.id}` === selectedThreadKey);
428 + if (selectedSettled !== undefined) pagedSettled.push(selectedSettled);
429 + const visibleSettled =
430 + input.settledShelfExpanded !== false
431 + ? pagedSettled
432 + : pagedSettled.filter(
433 + (thread) => `${thread.environmentId}:${thread.id}` === selectedThreadKey,
434 + );
435
436 const items: ThreadListV2Item[] = [];
437 for (const thread of orderedActive) {
438 items.push({
439 thread,
440 variant: "card",
413 - showSettledDivider: false,
441 snoozed: false,
442 isLast: false,
443 });
@@ -420,16 +447,15 @@ export function buildThreadListV2Items(input: {
447 items.push({
448 thread,
449 variant: "slim",
423 - showSettledDivider: false,
450 snoozed: true,
451 isLast: false,
452 });
453 }
428 - for (const [index, thread] of visibleSettled.entries()) {
454 + const settledShelfHeaderIndex = orderedSettled.length > 0 ? items.length : null;
455 + for (const thread of visibleSettled) {
456 items.push({
457 thread,
458 variant: "slim",
432 - showSettledDivider: index === 0,
459 snoozed: false,
460 isLast: false,
461 });
@@ -440,9 +466,11 @@ export function buildThreadListV2Items(input: {
466 }
467 return {
468 items,
443 - hiddenSettledCount: orderedSettled.length - visibleSettled.length,
469 + hiddenSettledCount: orderedSettled.length - pagedSettled.length,
470 snoozedCount: orderedSnoozed.length,
471 snoozedShelfHeaderIndex,
472 + settledCount: orderedSettled.length,
473 + settledShelfHeaderIndex,
474 nextSnoozeWakeAt,
475 };
476 }