diff --git a/apps/mobile/src/features/home/HomeScreen.tsx b/apps/mobile/src/features/home/HomeScreen.tsx index fb389e09d7..7d253ea7a0 100644 --- a/apps/mobile/src/features/home/HomeScreen.tsx +++ b/apps/mobile/src/features/home/HomeScreen.tsx @@ -38,6 +38,7 @@ import { import { ThreadListV2Row, ThreadListV2SnoozedShelfHeader } from "../threads/thread-list-v2-items"; import { buildThreadListV2Items, + snoozeWakeLabel, THREAD_LIST_V2_SETTLED_INITIAL_COUNT, THREAD_LIST_V2_SETTLED_PAGE_COUNT, type ThreadListV2Item, @@ -625,6 +626,11 @@ export function HomeScreen(props: HomeScreenProps) { variant={item.variant} showSettledDivider={item.showSettledDivider} snoozed={item.snoozed} + snoozeWakeLabelText={ + item.snoozed && item.thread.snoozedUntil != null + ? snoozeWakeLabel(item.thread.snoozedUntil, new Date(`${nowMinute}:00.000Z`)) + : undefined + } project={ projectByKey.get(scopedProjectKey(item.thread.environmentId, item.thread.projectId)) ?? null @@ -683,6 +689,7 @@ export function HomeScreen(props: HomeScreenProps) { props.savedConnectionsById, serverConfigs, settlementEnvironmentIds, + nowMinute, snoozeEnvironmentIds, snoozedShelfExpanded, toggleSnoozedShelf, diff --git a/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx b/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx index a5e8f62a4a..f8cfcd3541 100644 --- a/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx +++ b/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx @@ -66,6 +66,7 @@ import { import { ThreadListV2Row, ThreadListV2SnoozedShelfHeader } from "./thread-list-v2-items"; import { buildThreadListV2Items, + snoozeWakeLabel, THREAD_LIST_V2_SETTLED_INITIAL_COUNT, THREAD_LIST_V2_SETTLED_PAGE_COUNT, type ThreadListV2Item, @@ -82,11 +83,19 @@ type SidebarListItem = readonly pendingTask: PendingNewTask; readonly isLast: boolean; } - | { readonly type: "v2-thread"; readonly key: string; readonly item: ThreadListV2Item } + | { + readonly type: "v2-thread"; + readonly key: string; + readonly item: ThreadListV2Item; + /** Precomputed against the minute tick so the row comparator can see + the countdown change; undefined for non-snoozed rows. */ + readonly snoozeWakeLabelText: string | undefined; + } | { readonly type: "v2-snoozed-shelf-header"; readonly key: string; readonly count: number; + readonly expanded: boolean; } | { readonly type: "v2-show-more"; readonly key: string; readonly hiddenCount: number }; @@ -526,10 +535,15 @@ function ThreadNavigationSidebarPane( pendingTask, isLast: index === v2PendingTasks.length - 1, })); + const snoozeLabelNow = new Date(`${nowMinute}:00.000Z`); const threadRows: SidebarListItem[] = threadListV2Layout.items.map((item) => ({ type: "v2-thread" as const, key: scopedThreadKey(item.thread.environmentId, item.thread.id), item, + snoozeWakeLabelText: + item.snoozed && item.thread.snoozedUntil != null + ? snoozeWakeLabel(item.thread.snoozedUntil, snoozeLabelNow) + : undefined, })); // The shelf header is a row of its own: collapsed, it IS the shelf, so // it has no thread row to hang off. splice() handles the all-snoozed @@ -539,6 +553,7 @@ function ThreadNavigationSidebarPane( type: "v2-snoozed-shelf-header", key: "v2-snoozed-shelf-header", count: threadListV2Layout.snoozedCount, + expanded: snoozedShelfExpanded, }); } items.push(...threadRows); @@ -552,10 +567,12 @@ function ThreadNavigationSidebarPane( return items; }, [ listLayout.items, + nowMinute, options.selectedEnvironmentId, pendingTasks, props.searchQuery, selectedProjectRefs, + snoozedShelfExpanded, threadListV2Enabled, threadListV2Layout, ]); @@ -744,14 +761,22 @@ function ThreadNavigationSidebarPane( previous.key === item.key && previous.item.thread === item.item.thread && previous.item.variant === item.item.variant && - previous.item.showSettledDivider === item.item.showSettledDivider + previous.item.showSettledDivider === item.item.showSettledDivider && + // A timer wake is derived from the clock, not from new data: the + // shell reference and variant can both be unchanged while the row + // stops being snoozed. Without this the woken row keeps its blue + // countdown and Wake action. + previous.item.snoozed === item.item.snoozed && + // Same reason for the countdown text: it changes on the minute + // tick while every other field holds still. + previous.snoozeWakeLabelText === item.snoozeWakeLabelText ); } if (previous.type === "v2-show-more" && item.type === "v2-show-more") { return previous.hiddenCount === item.hiddenCount; } if (previous.type === "v2-snoozed-shelf-header" && item.type === "v2-snoozed-shelf-header") { - return previous.count === item.count; + return previous.count === item.count && previous.expanded === item.expanded; } if (previous.type === "v2-pending-task" && item.type === "v2-pending-task") { return previous.pendingTask === item.pendingTask && previous.isLast === item.isLast; @@ -815,6 +840,7 @@ function ThreadNavigationSidebarPane( variant={item.item.variant} showSettledDivider={item.item.showSettledDivider} snoozed={item.item.snoozed} + snoozeWakeLabelText={item.snoozeWakeLabelText} project={projectByKey.get(scopeKey) ?? null} projectTitle={projectTitleByProjectKey.get(scopeKey)} providerDriver={ @@ -857,7 +883,7 @@ function ThreadNavigationSidebarPane( return ( @@ -970,7 +996,9 @@ function ThreadNavigationSidebarPane( sidebarScrollGesture, snoozeEnvironmentIds, snoozeThread, + toggleSnoozedShelf, unsettleThread, + unsnoozeThread, updateGroupDisplay, ], ); diff --git a/apps/mobile/src/features/threads/thread-list-v2-items.tsx b/apps/mobile/src/features/threads/thread-list-v2-items.tsx index b3d3528621..459c09a689 100644 --- a/apps/mobile/src/features/threads/thread-list-v2-items.tsx +++ b/apps/mobile/src/features/threads/thread-list-v2-items.tsx @@ -22,7 +22,6 @@ import { resolveThreadListV2SnoozeGateExpiryMs, resolveThreadListV2Status, resolveThreadListV2SwipeActions, - snoozeWakeLabel, type ThreadListV2Status, } from "./threadListV2"; @@ -151,6 +150,11 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: { readonly showSettledDivider: boolean; /** Snoozed-shelf row: shows its wake time and offers Wake, not Settle. */ readonly snoozed?: boolean; + /** Pre-formatted "wakes in" text for snoozed rows. Computed by the parent + against its minute tick rather than here: this row is memoized, so a + clock read inside it would freeze at first render and the countdown + would never move. Mirrors web's snoozeWakeLabelText prop. */ + readonly snoozeWakeLabelText?: string; readonly project: EnvironmentProject | null; readonly projectTitle?: string; readonly providerDriver: string | null; @@ -540,8 +544,8 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: { )} style={{ fontFamily: MONO_FONT }} > - {snoozedRow && thread.snoozedUntil != null - ? snoozeWakeLabel(thread.snoozedUntil, new Date()) + {snoozedRow && props.snoozeWakeLabelText !== undefined + ? props.snoozeWakeLabelText : relativeTime(thread.latestUserMessageAt ?? thread.updatedAt ?? thread.createdAt)}