Skip to content

Commit 41f23d1

Browse files
committed
feat(mobile): make settled threads collapsible
1 parent a041981 commit 41f23d1

5 files changed

Lines changed: 215 additions & 48 deletions

File tree

‎apps/mobile/src/features/home/HomeScreen.tsx‎

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import {
4444
import {
4545
ThreadListV2PendingRow,
4646
ThreadListV2Row,
47+
ThreadListV2SettledShelfHeader,
4748
ThreadListV2SnoozedShelfHeader,
4849
} from "../threads/thread-list-v2-items";
4950
import {
@@ -534,6 +535,8 @@ export function HomeScreen(props: HomeScreenProps) {
534535
);
535536
const [snoozedShelfExpanded, setSnoozedShelfExpanded] = useState(false);
536537
const toggleSnoozedShelf = useCallback(() => setSnoozedShelfExpanded((value) => !value), []);
538+
const [settledShelfExpanded, setSettledShelfExpanded] = useState(true);
539+
const toggleSettledShelf = useCallback(() => setSettledShelfExpanded((value) => !value), []);
537540
// now is quantized to the minute and ticks so the inactivity auto-settle
538541
// boundary is actually crossed while the app stays open (mirrors web);
539542
// without a clock dependency the partition memoizes a frozen "now".
@@ -579,6 +582,8 @@ export function HomeScreen(props: HomeScreenProps) {
579582
hiddenSettledCount: 0,
580583
snoozedCount: 0,
581584
snoozedShelfHeaderIndex: null,
585+
settledCount: 0,
586+
settledShelfHeaderIndex: null,
582587
nextSnoozeWakeAt: null,
583588
};
584589
// Settled threads are live shells; archived threads keep their original
@@ -596,13 +601,15 @@ export function HomeScreen(props: HomeScreenProps) {
596601
now: `${nowMinute}:00.000Z`,
597602
snoozeNow: new Date().toISOString(),
598603
snoozedShelfExpanded,
604+
settledShelfExpanded,
599605
selectedThreadKey: null,
600606
});
601607
}, [
602608
changeRequestStateByKey,
603609
nowMinute,
604610
snoozeWakeTick,
605611
snoozedShelfExpanded,
612+
settledShelfExpanded,
606613
settledVisibleCount,
607614
settlementEnvironmentIds,
608615
snoozeEnvironmentIds,
@@ -655,9 +662,12 @@ export function HomeScreen(props: HomeScreenProps) {
655662
snoozedCount: threadListV2Layout.snoozedCount,
656663
snoozedShelfExpanded,
657664
snoozedShelfHeaderIndex: threadListV2Layout.snoozedShelfHeaderIndex,
665+
settledCount: threadListV2Layout.settledCount,
666+
settledShelfExpanded,
667+
settledShelfHeaderIndex: threadListV2Layout.settledShelfHeaderIndex,
658668
snoozeLabelNow: `${nowMinute}:00.000Z`,
659669
}),
660-
[snoozedShelfExpanded, threadListV2Layout, v2PendingTasks],
670+
[settledShelfExpanded, snoozedShelfExpanded, threadListV2Layout, v2PendingTasks],
661671
);
662672

663673
const renderV2Item = useCallback(
@@ -693,12 +703,20 @@ export function HomeScreen(props: HomeScreenProps) {
693703
/>
694704
);
695705
}
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+
}
696715
const thread = item.item.thread;
697716
return (
698717
<ThreadListV2Row
699718
thread={thread}
700719
variant={item.item.variant}
701-
showSettledDivider={item.item.showSettledDivider}
702720
snoozed={item.item.snoozed}
703721
snoozePresetMinute={nowMinute}
704722
snoozeWakeLabelText={item.snoozeWakeLabelText}
@@ -767,6 +785,7 @@ export function HomeScreen(props: HomeScreenProps) {
767785
settlementEnvironmentIds,
768786
snoozeEnvironmentIds,
769787
threadSearchMatchByKey,
788+
toggleSettledShelf,
770789
toggleSnoozedShelf,
771790
v2ProjectTitleByProjectKey,
772791
props.searchQuery,
@@ -1036,7 +1055,7 @@ export function HomeScreen(props: HomeScreenProps) {
10361055
extraData={v2ExtraData}
10371056
ListHeaderComponent={v2ListHeader}
10381057
ListFooterComponent={
1039-
threadListV2Layout.hiddenSettledCount > 0 ? (
1058+
settledShelfExpanded && threadListV2Layout.hiddenSettledCount > 0 ? (
10401059
<Pressable
10411060
accessibilityRole="button"
10421061
accessibilityLabel={`Show ${Math.min(threadListV2Layout.hiddenSettledCount, THREAD_LIST_V2_SETTLED_PAGE_COUNT)} more settled threads`}

‎apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx‎

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ import {
7070
import {
7171
ThreadListV2PendingRow,
7272
ThreadListV2Row,
73+
ThreadListV2SettledShelfHeader,
7374
ThreadListV2SnoozedShelfHeader,
7475
} from "./thread-list-v2-items";
7576
import {
@@ -440,6 +441,8 @@ function ThreadNavigationSidebarPane(
440441
);
441442
const [snoozedShelfExpanded, setSnoozedShelfExpanded] = useState(false);
442443
const toggleSnoozedShelf = useCallback(() => setSnoozedShelfExpanded((value) => !value), []);
444+
const [settledShelfExpanded, setSettledShelfExpanded] = useState(true);
445+
const toggleSettledShelf = useCallback(() => setSettledShelfExpanded((value) => !value), []);
443446
// now ticks per minute so the inactivity auto-settle boundary is actually
444447
// crossed while the pane stays open; without a clock dependency the
445448
// partition memoizes a frozen "now".
@@ -485,6 +488,8 @@ function ThreadNavigationSidebarPane(
485488
hiddenSettledCount: 0,
486489
snoozedCount: 0,
487490
snoozedShelfHeaderIndex: null,
491+
settledCount: 0,
492+
settledShelfHeaderIndex: null,
488493
nextSnoozeWakeAt: null,
489494
};
490495
return buildThreadListV2Items({
@@ -500,13 +505,15 @@ function ThreadNavigationSidebarPane(
500505
now: `${nowMinute}:00.000Z`,
501506
snoozeNow: new Date().toISOString(),
502507
snoozedShelfExpanded,
508+
settledShelfExpanded,
503509
selectedThreadKey: props.selectedThreadKey ?? null,
504510
});
505511
}, [
506512
changeRequestStateByKey,
507513
nowMinute,
508514
snoozeWakeTick,
509515
snoozedShelfExpanded,
516+
settledShelfExpanded,
510517
props.selectedThreadKey,
511518
options.selectedEnvironmentId,
512519
props.searchQuery,
@@ -557,9 +564,12 @@ function ThreadNavigationSidebarPane(
557564
snoozedCount: threadListV2Layout.snoozedCount,
558565
snoozedShelfExpanded,
559566
snoozedShelfHeaderIndex: threadListV2Layout.snoozedShelfHeaderIndex,
567+
settledCount: threadListV2Layout.settledCount,
568+
settledShelfExpanded,
569+
settledShelfHeaderIndex: threadListV2Layout.settledShelfHeaderIndex,
560570
snoozeLabelNow: `${nowMinute}:00.000Z`,
561571
});
562-
if (threadListV2Layout.hiddenSettledCount > 0) {
572+
if (settledShelfExpanded && threadListV2Layout.hiddenSettledCount > 0) {
563573
items.push({
564574
type: "v2-show-more",
565575
key: "v2-show-more",
@@ -574,6 +584,7 @@ function ThreadNavigationSidebarPane(
574584
pendingTasks,
575585
props.searchQuery,
576586
selectedProjectRefs,
587+
settledShelfExpanded,
577588
snoozedShelfExpanded,
578589
threadListV2Enabled,
579590
threadListV2Layout,
@@ -780,7 +791,6 @@ function ThreadNavigationSidebarPane(
780791
previous.key === item.key &&
781792
previous.item.thread === item.item.thread &&
782793
previous.item.variant === item.item.variant &&
783-
previous.item.showSettledDivider === item.item.showSettledDivider &&
784794
previous.item.snoozed === item.item.snoozed &&
785795
previous.snoozeWakeLabelText === item.snoozeWakeLabelText
786796
);
@@ -797,15 +807,20 @@ function ThreadNavigationSidebarPane(
797807
if (previous.type === "v2-snoozed-shelf" && item.type === "v2-snoozed-shelf") {
798808
return previous.count === item.count && previous.expanded === item.expanded;
799809
}
810+
if (previous.type === "v2-settled-shelf" && item.type === "v2-settled-shelf") {
811+
return previous.count === item.count && previous.expanded === item.expanded;
812+
}
800813
if (
801814
previous.type === "v2-thread" ||
802815
previous.type === "v2-show-more" ||
803816
previous.type === "v2-pending" ||
804817
previous.type === "v2-snoozed-shelf" ||
818+
previous.type === "v2-settled-shelf" ||
805819
item.type === "v2-thread" ||
806820
item.type === "v2-show-more" ||
807821
item.type === "v2-pending" ||
808-
item.type === "v2-snoozed-shelf"
822+
item.type === "v2-snoozed-shelf" ||
823+
item.type === "v2-settled-shelf"
809824
) {
810825
return false;
811826
}
@@ -863,7 +878,6 @@ function ThreadNavigationSidebarPane(
863878
<ThreadListV2Row
864879
thread={thread}
865880
variant={item.item.variant}
866-
showSettledDivider={item.item.showSettledDivider}
867881
snoozed={item.item.snoozed}
868882
snoozePresetMinute={nowMinute}
869883
snoozeWakeLabelText={item.snoozeWakeLabelText}
@@ -921,6 +935,15 @@ function ThreadNavigationSidebarPane(
921935
pane="sidebar"
922936
/>
923937
);
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+
);
924947
case "v2-show-more":
925948
return (
926949
<Pressable
@@ -1039,6 +1062,7 @@ function ThreadNavigationSidebarPane(
10391062
snoozeEnvironmentIds,
10401063
snoozeThread,
10411064
nowMinute,
1065+
toggleSettledShelf,
10421066
toggleSnoozedShelf,
10431067
unsettleThread,
10441068
unsnoozeThread,

‎apps/mobile/src/features/threads/thread-list-v2-items.tsx‎

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,42 @@ export const ThreadListV2SnoozedShelfHeader = memo(function ThreadListV2SnoozedS
149149
);
150150
});
151151

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+
152188
const PENDING_TASK_MENU_ACTIONS: MenuAction[] = [
153189
{ id: "delete", title: "Delete", image: "trash", attributes: { destructive: true } },
154190
];
@@ -267,7 +303,6 @@ export const ThreadListV2PendingRow = memo(function ThreadListV2PendingRow(props
267303
export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
268304
readonly thread: EnvironmentThreadShell;
269305
readonly variant: "card" | "slim";
270-
readonly showSettledDivider: boolean;
271306
/** Snoozed-shelf row: shows its wake time and offers Wake. */
272307
readonly snoozed?: boolean;
273308
/** Preformatted against the parent minute tick so this memoized row's
@@ -739,9 +774,6 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
739774

740775
return (
741776
<>
742-
{props.showSettledDivider ? (
743-
<ThreadListV2SectionDivider label="Settled" pane={props.pane} />
744-
) : null}
745777
<ThreadSwipeable
746778
backgroundColor={sidebarPane ? drawerColor : screenColor}
747779
compactActions={variant === "slim"}

0 commit comments

Comments
 (0)