Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
feat(mobile): add thread snoozing (#5053)
Gabriel De Andradea041981276b4
diff --git a/apps/mobile/src/components/AppSymbol.tsx b/apps/mobile/src/components/AppSymbol.tsxindex ac813bdbe..d4c7088fe 100644--- a/apps/mobile/src/components/AppSymbol.tsx+++ b/apps/mobile/src/components/AppSymbol.tsx@@ -22,6 +22,7 @@ import {IconChevronUp,IconCircleCheck,IconCircleXFilled,+ IconClock,IconCopy,IconDeviceDesktop,IconDots,@@ -96,6 +97,7 @@ const ANDROID_ICON_BY_SF_SYMBOL: Partial<Record<SFSymbol, Icon>> = {camera: IconCamera,checkmark: IconCheck,"checkmark.circle": IconCircleCheck,+ clock: IconClock,"chevron.down": IconChevronDown,"chevron.left": IconChevronLeft,"chevron.left.forwardslash.chevron.right": IconCode,diff --git a/apps/mobile/src/features/home/HomeRouteScreen.tsx b/apps/mobile/src/features/home/HomeRouteScreen.tsxindex 7fcf78f83..0aefde991 100644--- a/apps/mobile/src/features/home/HomeRouteScreen.tsx+++ b/apps/mobile/src/features/home/HomeRouteScreen.tsx@@ -36,8 +36,14 @@ export function HomeRouteScreen() {void checkForAppUpdateOnLaunch();}, []);- const { archiveThread, confirmDeleteThread, settleThread, unsettleThread } =- useThreadListActions();+ const {+ archiveThread,+ confirmDeleteThread,+ settleThread,+ snoozeThread,+ unsnoozeThread,+ unsettleThread,+ } = useThreadListActions();const pendingTasks = usePendingNewTasks();const { openPendingTask, confirmDeletePendingTask } = usePendingTaskListActions();const environments = useMemo(() => {@@ -146,6 +152,8 @@ export function HomeRouteScreen() {onArchiveThread={archiveThread}onDeleteThread={confirmDeleteThread}onSettleThread={settleThread}+ onSnoozeThread={snoozeThread}+ onUnsnoozeThread={unsnoozeThread}onUnsettleThread={unsettleThread}onEnvironmentChange={setSelectedEnvironmentId}onProjectChange={setSelectedProjectKey}diff --git a/apps/mobile/src/features/home/HomeScreen.tsx b/apps/mobile/src/features/home/HomeScreen.tsxindex 507a39d94..78907cf21 100644--- a/apps/mobile/src/features/home/HomeScreen.tsx+++ b/apps/mobile/src/features/home/HomeScreen.tsx@@ -41,7 +41,11 @@ import {ThreadListRow,ThreadListShowMoreRow,} from "../threads/thread-list-items";-import { ThreadListV2PendingRow, ThreadListV2Row } from "../threads/thread-list-v2-items";+import {+ ThreadListV2PendingRow,+ ThreadListV2Row,+ ThreadListV2SnoozedShelfHeader,+} from "../threads/thread-list-v2-items";import {buildThreadListV2Items,buildThreadListV2ListItems,@@ -100,6 +104,11 @@ interface HomeScreenProps {readonly onDeleteThread: (thread: EnvironmentThreadShell) => void;/** Resolves true iff the settle was dispatched and succeeded. */readonly onSettleThread: (thread: EnvironmentThreadShell) => Promise<boolean>;+ readonly onSnoozeThread: (+ thread: EnvironmentThreadShell,+ snoozedUntil: string,+ ) => Promise<boolean>;+ readonly onUnsnoozeThread: (thread: EnvironmentThreadShell) => Promise<boolean>;readonly onUnsettleThread: (thread: EnvironmentThreadShell) => void;readonly onSelectPendingTask: (pendingTask: PendingNewTask) => void;readonly onDeletePendingTask: (pendingTask: PendingNewTask) => void;@@ -494,6 +503,18 @@ export function HomeScreen(props: HomeScreenProps) {},[props.onSettleThread],);+ const handleSnoozeThread = useCallback(+ (thread: EnvironmentThreadShell, snoozedUntil: string) => {+ void props.onSnoozeThread(thread, snoozedUntil);+ },+ [props.onSnoozeThread],+ );+ const handleUnsnoozeThread = useCallback(+ (thread: EnvironmentThreadShell) => {+ void props.onUnsnoozeThread(thread);+ },+ [props.onUnsnoozeThread],+ );const handleDeleteThread = props.onDeleteThread;const handleUnsettleThread = props.onUnsettleThread;// The settled tail renders in pages; expansion resets when the filter@@ -511,6 +532,8 @@ export function HomeScreen(props: HomeScreenProps) {() => setSettledVisibleCount((count) => count + THREAD_LIST_V2_SETTLED_PAGE_COUNT),[],);+ const [snoozedShelfExpanded, setSnoozedShelfExpanded] = useState(false);+ const toggleSnoozedShelf = useCallback(() => setSnoozedShelfExpanded((value) => !value), []);// now is quantized to the minute and ticks so the inactivity auto-settle// boundary is actually crossed while the app stays open (mirrors web);// without a clock dependency the partition memoizes a frozen "now".@@ -551,7 +574,13 @@ export function HomeScreen(props: HomeScreenProps) {}, [serverConfigs]);const threadListV2Layout = useMemo(() => {if (!threadListV2Enabled)- return { items: [], hiddenSettledCount: 0, snoozedCount: 0, nextSnoozeWakeAt: null };+ return {+ items: [],+ hiddenSettledCount: 0,+ snoozedCount: 0,+ snoozedShelfHeaderIndex: null,+ nextSnoozeWakeAt: null,+ };// Settled threads are live shells; archived threads keep their original// "hidden from lists" meaning.return buildThreadListV2Items({@@ -566,11 +595,14 @@ export function HomeScreen(props: HomeScreenProps) {settledLimit: settledVisibleCount,now: `${nowMinute}:00.000Z`,snoozeNow: new Date().toISOString(),+ snoozedShelfExpanded,+ selectedThreadKey: null,});}, [changeRequestStateByKey,nowMinute,snoozeWakeTick,+ snoozedShelfExpanded,settledVisibleCount,settlementEnvironmentIds,snoozeEnvironmentIds,@@ -620,8 +652,12 @@ export function HomeScreen(props: HomeScreenProps) {buildThreadListV2ListItems({items: threadListV2Layout.items,pendingTasks: v2PendingTasks,+ snoozedCount: threadListV2Layout.snoozedCount,+ snoozedShelfExpanded,+ snoozedShelfHeaderIndex: threadListV2Layout.snoozedShelfHeaderIndex,+ snoozeLabelNow: `${nowMinute}:00.000Z`,}),- [threadListV2Layout.items, v2PendingTasks],+ [snoozedShelfExpanded, threadListV2Layout, v2PendingTasks],);const renderV2Item = useCallback(@@ -648,12 +684,24 @@ export function HomeScreen(props: HomeScreenProps) {/>);}+ if (item.type === "v2-snoozed-shelf") {+ return (+ <ThreadListV2SnoozedShelfHeader+ count={item.count}+ expanded={item.expanded}+ onToggle={toggleSnoozedShelf}+ />+ );+ }const thread = item.item.thread;return (<ThreadListV2Rowthread={thread}variant={item.item.variant}showSettledDivider={item.item.showSettledDivider}+ snoozed={item.item.snoozed}+ snoozePresetMinute={nowMinute}+ snoozeWakeLabelText={item.snoozeWakeLabelText}project={projectByKey.get(scopedProjectKey(thread.environmentId, thread.projectId)) ?? null}@@ -686,6 +734,9 @@ export function HomeScreen(props: HomeScreenProps) {onArchiveThread={props.onArchiveThread}settlementSupported={settlementEnvironmentIds.has(thread.environmentId)}onSettleThread={handleSettleThread}+ snoozeSupported={snoozeEnvironmentIds.has(thread.environmentId)}+ onSnoozeThread={handleSnoozeThread}+ onUnsnoozeThread={handleUnsnoozeThread}onUnsettleThread={handleUnsettleThread}onChangeRequestState={handleChangeRequestState}projectCwd={@@ -700,6 +751,8 @@ export function HomeScreen(props: HomeScreenProps) {handleChangeRequestState,handleDeleteThread,handleSettleThread,+ handleSnoozeThread,+ handleUnsnoozeThread,handleSwipeableClose,handleSwipeableWillOpen,handleUnsettleThread,@@ -712,9 +765,12 @@ export function HomeScreen(props: HomeScreenProps) {props.savedConnectionsById,serverConfigs,settlementEnvironmentIds,+ snoozeEnvironmentIds,threadSearchMatchByKey,+ toggleSnoozedShelf,v2ProjectTitleByProjectKey,props.searchQuery,+ nowMinute,],);const v2KeyExtractor = useCallback((item: ThreadListV2ListItem) => item.key, []);@@ -730,6 +786,7 @@ export function HomeScreen(props: HomeScreenProps) {serverConfigs,savedConnectionsById: props.savedConnectionsById,searchQuery: props.searchQuery,+ snoozePresetMinute: nowMinute,threadSearchMatchByKey,}),[@@ -738,6 +795,7 @@ export function HomeScreen(props: HomeScreenProps) {props.searchQuery,props.savedConnectionsById,serverConfigs,+ nowMinute,threadSearchMatchByKey,v2ProjectTitleByProjectKey,],@@ -953,31 +1011,11 @@ export function HomeScreen(props: HomeScreenProps) {) : null;// Self-contained: v1's listEmpty keys off projectGroups, which ignores the// v2 project scope, so it can be null (results elsewhere) while this list- // is empty. Search outranks the scope — "No results" names the actionable- // fact when a query is active. Snoozed threads outrank the rest: "No- // threads yet" over an inbox that is merely all-snoozed reads as data- // loss.- const v2SnoozedCount = threadListV2Layout.snoozedCount;+ // is empty. Snoozed threads need no special empty state: their shelf header+ // is a list row even while collapsed.const v2ListEmpty =- hasSearchQuery && threadSearch.isPending && v2SnoozedCount === 0 ? null : hasSearchQuery ? (- v2SnoozedCount > 0 ? (- // The snoozed threads already passed this search filter: "No- // results" would claim nothing matched when matches are merely- // parked.- <EmptyState- title={- v2SnoozedCount === 1 ? "1 matching thread snoozed" : `All matching threads snoozed`- }- detail={`Threads matching "${props.searchQuery}" are snoozed and return when their wake time passes.`}- />- ) : (- <EmptyState title="No results" detail={`No threads matching "${props.searchQuery}".`} />- )- ) : v2SnoozedCount > 0 ? (- <EmptyState- title={v2SnoozedCount === 1 ? "1 thread snoozed" : `${v2SnoozedCount} threads snoozed`}- detail="Snoozed threads return when their wake time passes."- />+ hasSearchQuery && threadSearch.isPending ? null : hasSearchQuery ? (+ <EmptyState title="No results" detail={`No threads matching "${props.searchQuery}".`} />) : v2ScopedProjectGroup !== null ? (<EmptyStatetitle={`No threads in ${v2ScopedProjectGroup.title}`}diff --git a/apps/mobile/src/features/home/thread-swipe-actions.tsx b/apps/mobile/src/features/home/thread-swipe-actions.tsxindex 186c606ae..973c4fae9 100644--- a/apps/mobile/src/features/home/thread-swipe-actions.tsx+++ b/apps/mobile/src/features/home/thread-swipe-actions.tsx@@ -1,4 +1,6 @@import { SymbolView } from "../../components/AppSymbol";+import { ControlPillMenu } from "../../components/ControlPill";+import type { MenuAction } from "@react-native-menu/menu";import * as Haptics from "expo-haptics";import {createContext,@@ -47,13 +49,67 @@ export const THREAD_SWIPE_SPRING = {stiffness: 330,};-interface ThreadSwipePrimaryAction {+interface ThreadSwipeAction {readonly accessibilityLabel: string;readonly icon: ComponentProps<typeof SymbolView>["name"];readonly label: string;+ readonly menu?: {+ readonly actions: MenuAction[];+ readonly onPressAction: NonNullable<ComponentProps<typeof ControlPillMenu>["onPressAction"]>;+ readonly title?: string;+ };readonly onPress: () => void;}+interface ThreadSwipeSecondaryAction extends ThreadSwipeAction {+ readonly backgroundColor: string;+}++function swipeActionsWidth(hasSecondaryAction: boolean) {+ return hasSecondaryAction ? THREAD_SWIPE_ACTIONS_WIDTH : ACTION_ITEM_WIDTH;+}++/** `undefined` keeps the v1 Delete default; `null` means one action only. */+function resolveSecondaryAction(input: {+ readonly close: () => void;+ readonly onDelete: () => void;+ readonly secondaryAction: ThreadSwipeAction | null | undefined;+ readonly threadTitle: string;+}): ThreadSwipeSecondaryAction | null {+ if (input.secondaryAction === null) return null;+ if (input.secondaryAction === undefined) {+ return {+ accessibilityLabel: `Delete ${input.threadTitle}`,+ backgroundColor: "#ff2d55",+ icon: "trash",+ label: "Delete",+ onPress: () => {+ input.close();+ input.onDelete();+ },+ };+ }+ const action = input.secondaryAction;+ return {+ ...action,+ backgroundColor: "#5856d6",+ menu:+ action.menu === undefined+ ? undefined+ : {+ ...action.menu,+ onPressAction: (event) => {+ input.close();+ action.menu?.onPressAction(event);+ },+ },+ onPress: () => {+ input.close();+ action.onPress();+ },+ };+}+/*** Delivers the scroll gate to swipeables via context so that flipping it does* NOT re-render whole rows: putting the flag in list extraData/renderItem deps@@ -173,17 +229,22 @@ export function ThreadSwipeable(props: {readonly enabled?: boolean;readonly enableTrackpadSwipe?: boolean;/**- * What a full swipe commits: "delete" (default, v1 behavior — the Delete- * button stretches) or "primary" — the advertised primary action fires and- * its button stretches instead. A full swipe must always match the action- * the stretching button advertises.+ * What a full swipe commits. Omitted keeps the v1 Delete behavior only when+ * the built-in Delete secondary action is in use; custom or absent+ * secondary actions default to the advertised primary action.*/readonly fullSwipeAction?: "delete" | "primary";readonly fullSwipeWidth: number;readonly onDelete: () => void;readonly onSwipeableClose?: (methods: SwipeableMethods) => void;readonly onSwipeableWillOpen?: (methods: SwipeableMethods) => void;- readonly primaryAction: ThreadSwipePrimaryAction;+ readonly primaryAction: ThreadSwipeAction;+ /**+ * Omitted keeps the v1 destructive Delete action. Explicit null opts out of+ * a secondary action entirely so a gated Snooze can never fall back to an+ * unadvertised Delete.+ */+ readonly secondaryAction?: ThreadSwipeAction | null;/*** Identity of the content being wrapped. When a recycled list reuses this* component for a different item, the swipeable snaps back to closed so an@@ -197,7 +258,11 @@ export function ThreadSwipeable(props: {}) {const swipeableRef = useRef<SwipeableMethods | null>(null);const fullSwipeArmedRef = useRef(false);- const fullSwipeThreshold = Math.max(THREAD_SWIPE_ACTIONS_WIDTH + 44, props.fullSwipeWidth * 0.58);+ const hasSecondaryAction = props.secondaryAction !== null;+ const actionsWidth = swipeActionsWidth(hasSecondaryAction);+ const fullSwipeThreshold = Math.max(actionsWidth + 44, props.fullSwipeWidth * 0.58);+ const fullSwipeAction =+ props.fullSwipeAction ?? (props.secondaryAction === undefined ? "delete" : "primary");const close = useCallback(() => swipeableRef.current?.close(), []);const gateEnabled = use(SwipeableScrollGateContext);const resetKey = props.resetKey;@@ -251,7 +316,7 @@ export function ThreadSwipeable(props: {if (fullSwipeArmedRef.current) {fullSwipeArmedRef.current = false;methods.close();- if (props.fullSwipeAction === "primary") {+ if (fullSwipeAction === "primary") {props.primaryAction.onPress();} else {props.onDelete();@@ -264,9 +329,8 @@ export function ThreadSwipeable(props: {<ThreadSwipeActionsbackgroundColor={props.backgroundColor}compact={props.compactActions === true}- fullSwipeAction={props.fullSwipeAction ?? "delete"}+ fullSwipeAction={fullSwipeAction}fullSwipeThreshold={fullSwipeThreshold}- onDelete={props.onDelete}onFullSwipeArmedChange={handleFullSwipeArmedChange}primaryAction={{...props.primaryAction,@@ -275,12 +339,16 @@ export function ThreadSwipeable(props: {props.primaryAction.onPress();},}}- swipeableMethods={methods}- threadTitle={props.threadTitle}+ secondaryAction={resolveSecondaryAction({+ close: () => methods.close(),+ onDelete: props.onDelete,+ secondaryAction: props.secondaryAction,+ threadTitle: props.threadTitle,+ })}translation={translation}/>)}- rightThreshold={THREAD_SWIPE_ACTIONS_WIDTH * 0.42}+ rightThreshold={actionsWidth * 0.42}simultaneousWithExternalGesture={props.simultaneousWithExternalGesture}>{props.children(close)}@@ -290,12 +358,14 @@ export function ThreadSwipeable(props: {function SwipeActionButton(props: {readonly accessibilityLabel: string;+ readonly actionsWidth: number;readonly backgroundColor: string;readonly compact: boolean;readonly entryRange: readonly [number, number];readonly fullSwipeThreshold: number;readonly icon: ComponentProps<typeof SymbolView>["name"];readonly label: string;+ readonly menu?: ThreadSwipeAction["menu"];readonly onPress: () => void;readonly stretchesOnFullSwipe: boolean;readonly translation: SharedValue<number>;@@ -305,10 +375,10 @@ function SwipeActionButton(props: {const actionStyle = useAnimatedStyle(() => {const reveal = Math.max(-props.translation.value, 0);const entryProgress = interpolate(reveal, props.entryRange, [0, 1], Extrapolation.CLAMP);- const stretch = Math.max(reveal - THREAD_SWIPE_ACTIONS_WIDTH, 0);+ const stretch = Math.max(reveal - props.actionsWidth, 0);const fullSwipeProgress = interpolate(reveal,- [THREAD_SWIPE_ACTIONS_WIDTH, props.fullSwipeThreshold + 20],+ [props.actionsWidth, props.fullSwipeThreshold + 20],[0, 1],Extrapolation.CLAMP,);@@ -327,9 +397,7 @@ function SwipeActionButton(props: {});const circleStyle = useAnimatedStyle(() => {const reveal = Math.max(-props.translation.value, 0);- const stretch = props.stretchesOnFullSwipe- ? Math.max(reveal - THREAD_SWIPE_ACTIONS_WIDTH, 0)- : 0;+ const stretch = props.stretchesOnFullSwipe ? Math.max(reveal - props.actionsWidth, 0) : 0;return {transform: [{ translateX: -stretch }],@@ -338,9 +406,7 @@ function SwipeActionButton(props: {});const iconStyle = useAnimatedStyle(() => {const reveal = Math.max(-props.translation.value, 0);- const stretch = props.stretchesOnFullSwipe- ? Math.max(reveal - THREAD_SWIPE_ACTIONS_WIDTH, 0)- : 0;+ const stretch = props.stretchesOnFullSwipe ? Math.max(reveal - props.actionsWidth, 0) : 0;const armedProgress = interpolate(reveal,[props.fullSwipeThreshold, props.fullSwipeThreshold + 20],@@ -358,7 +424,7 @@ function SwipeActionButton(props: {}const reveal = Math.max(-props.translation.value, 0);- const stretch = Math.max(reveal - THREAD_SWIPE_ACTIONS_WIDTH, 0);+ const stretch = Math.max(reveal - props.actionsWidth, 0);return {opacity: interpolate(reveal,@@ -370,6 +436,63 @@ function SwipeActionButton(props: {};});+ const button = (+ <Pressable+ accessibilityLabel={props.accessibilityLabel}+ accessibilityRole="button"+ onPress={props.menu === undefined ? props.onPress : undefined}+ style={({ pressed }) => ({+ alignItems: "center",+ height: "100%",+ justifyContent: "center",+ opacity: pressed ? 0.72 : 1,+ width: "100%",+ })}+ >+ <View style={{ height: circleSize, width: circleSize }}>+ <Animated.View+ style={[+ {+ backgroundColor: props.backgroundColor,+ borderRadius: 999,+ height: circleSize,+ left: 0,+ position: "absolute",+ top: 0,+ },+ circleStyle,+ ]}+ />+ <Animated.View+ style={[+ {+ alignItems: "center",+ height: circleSize,+ justifyContent: "center",+ left: 0,+ position: "absolute",+ top: 0,+ width: circleSize,+ },+ iconStyle,+ ]}+ >+ <SymbolView name={props.icon} size={iconSize} tintColor="#ffffff" type="monochrome" />+ </Animated.View>+ </View>+ <Animated.View+ style={[+ { height: 14, justifyContent: "center", paddingTop: props.compact ? 0 : 2 },+ labelStyle,+ ]}+ >+ <Text className="text-3xs font-t3-medium text-foreground-muted" numberOfLines={1}>+ {props.label}+ </Text>+ </Animated.View>+ </Pressable>+ );+return (<Animated.Viewstyle={[@@ -383,60 +506,18 @@ function SwipeActionButton(props: {actionStyle,]}>- <Pressable- accessibilityLabel={props.accessibilityLabel}- accessibilityRole="button"- onPress={props.onPress}- style={({ pressed }) => ({- alignItems: "center",- height: "100%",- justifyContent: "center",- opacity: pressed ? 0.72 : 1,- width: "100%",- })}- >- <View style={{ height: circleSize, width: circleSize }}>- <Animated.View- style={[- {- backgroundColor: props.backgroundColor,- borderRadius: 999,- height: circleSize,- left: 0,- position: "absolute",- top: 0,- },- circleStyle,- ]}- />- <Animated.View- style={[- {- alignItems: "center",- height: circleSize,- justifyContent: "center",- left: 0,- position: "absolute",- top: 0,- width: circleSize,- },- iconStyle,- ]}- >- <SymbolView name={props.icon} size={iconSize} tintColor="#ffffff" type="monochrome" />- </Animated.View>- </View>- <Animated.View- style={[- { height: 14, justifyContent: "center", paddingTop: props.compact ? 0 : 2 },- labelStyle,- ]}+ {props.menu === undefined ? (+ button+ ) : (+ <ControlPillMenu+ actions={props.menu.actions}+ onPressAction={props.menu.onPressAction}+ title={props.menu.title}+ style={{ height: "100%", width: "100%" }}>- <Text className="text-3xs font-t3-medium text-foreground-muted" numberOfLines={1}>- {props.label}- </Text>- </Animated.View>- </Pressable>+ {button}+ </ControlPillMenu>+ )}</Animated.View>);}@@ -446,14 +527,14 @@ export function ThreadSwipeActions(props: {readonly compact: boolean;readonly fullSwipeAction?: "delete" | "primary";readonly fullSwipeThreshold: number;- readonly onDelete: () => void;readonly onFullSwipeArmedChange: (armed: boolean) => void;- readonly primaryAction: ThreadSwipePrimaryAction;- readonly swipeableMethods: SwipeableMethods;- readonly threadTitle: string;+ readonly primaryAction: ThreadSwipeAction;+ readonly secondaryAction: ThreadSwipeSecondaryAction | null;readonly translation: SharedValue<number>;}) {- const fullSwipeIsPrimary = props.fullSwipeAction === "primary";+ const secondaryAction = props.secondaryAction;+ const fullSwipeIsPrimary = props.fullSwipeAction === "primary" || secondaryAction === null;+ const actionsWidth = swipeActionsWidth(secondaryAction !== null);useAnimatedReaction(() => -props.translation.value >= props.fullSwipeThreshold,(armed, previous) => {@@ -470,14 +551,19 @@ export function ThreadSwipeActions(props: {backgroundColor: props.backgroundColor,flexDirection: "row",height: "100%",- width: THREAD_SWIPE_ACTIONS_WIDTH,+ width: actionsWidth,}}><SwipeActionButtonaccessibilityLabel={props.primaryAction.accessibilityLabel}+ actionsWidth={actionsWidth}backgroundColor="#007aff"compact={props.compact}- entryRange={[ACTION_ITEM_WIDTH * 0.55, THREAD_SWIPE_ACTIONS_WIDTH * 0.85]}+ entryRange={+ secondaryAction === null+ ? [8, ACTION_ITEM_WIDTH * 0.72]+ : [ACTION_ITEM_WIDTH * 0.55, THREAD_SWIPE_ACTIONS_WIDTH * 0.85]+ }fullSwipeThreshold={props.fullSwipeThreshold}icon={props.primaryAction.icon}label={props.primaryAction.label}@@ -485,21 +571,22 @@ export function ThreadSwipeActions(props: {stretchesOnFullSwipe={fullSwipeIsPrimary}translation={props.translation}/>- <SwipeActionButton- accessibilityLabel={`Delete ${props.threadTitle}`}- backgroundColor="#ff2d55"- compact={props.compact}- entryRange={[8, ACTION_ITEM_WIDTH * 0.72]}- fullSwipeThreshold={props.fullSwipeThreshold}- icon="trash"- label="Delete"- onPress={() => {- props.swipeableMethods.close();- props.onDelete();- }}- stretchesOnFullSwipe={!fullSwipeIsPrimary}- translation={props.translation}- />+ {secondaryAction === null ? null : (+ <SwipeActionButton+ accessibilityLabel={secondaryAction.accessibilityLabel}+ actionsWidth={actionsWidth}+ backgroundColor={secondaryAction.backgroundColor}+ compact={props.compact}+ entryRange={[8, ACTION_ITEM_WIDTH * 0.72]}+ fullSwipeThreshold={props.fullSwipeThreshold}+ icon={secondaryAction.icon}+ label={secondaryAction.label}+ menu={secondaryAction.menu}+ onPress={secondaryAction.onPress}+ stretchesOnFullSwipe={!fullSwipeIsPrimary}+ translation={props.translation}+ />+ )}</View>);}diff --git a/apps/mobile/src/features/home/useThreadListActions.ts b/apps/mobile/src/features/home/useThreadListActions.tsindex e200eb7ac..0c621a04e 100644--- a/apps/mobile/src/features/home/useThreadListActions.ts+++ b/apps/mobile/src/features/home/useThreadListActions.ts@@ -1,5 +1,5 @@import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell";-import { canSettle } from "@t3tools/client-runtime/state/thread-settled";+import { canSettle, canSnooze } from "@t3tools/client-runtime/state/thread-settled";import * as Cause from "effect/Cause";import * as Haptics from "expo-haptics";import { useCallback, useRef } from "react";@@ -22,6 +22,13 @@ function environmentSupportsSettlement(environmentId: EnvironmentThreadShell["en);}+function environmentSupportsSnooze(environmentId: EnvironmentThreadShell["environmentId"]) {+ return (+ appAtomRegistry.get(environmentServerConfigsAtom).get(environmentId)?.environment.capabilities+ .threadSnooze === true+ );+}+type ThreadListAction = "archive" | "unarchive" | "delete" | "settle" | "unsettle";const ACTION_VERBS: Record<ThreadListAction, string> = {@@ -192,9 +199,14 @@ export function useThreadListActions(): {readonly archiveThread: (thread: EnvironmentThreadShell) => void;readonly confirmDeleteThread: (thread: EnvironmentThreadShell) => void;readonly settleThread: (thread: EnvironmentThreadShell) => Promise<boolean>;+ readonly snoozeThread: (thread: EnvironmentThreadShell, snoozedUntil: string) => Promise<boolean>;+ readonly unsnoozeThread: (thread: EnvironmentThreadShell) => Promise<boolean>;readonly unsettleThread: (thread: EnvironmentThreadShell) => Promise<boolean>;} {const executeAction = useThreadActionExecutor();+ const snoozeMutation = useAtomCommand(threadEnvironment.snooze, { reportFailure: false });+ const unsnoozeMutation = useAtomCommand(threadEnvironment.unsnooze, { reportFailure: false });+ const snoozeInFlightThreadKeys = useRef(new Set<string>());const archiveThread = useCallback((thread: EnvironmentThreadShell) => {@@ -206,6 +218,94 @@ export function useThreadListActions(): {async (thread: EnvironmentThreadShell) => (await executeAction("settle", thread)) === true,[executeAction],);+ const snoozeThread = useCallback(+ async (thread: EnvironmentThreadShell, snoozedUntil: string) => {+ const key = scopedThreadKey(thread.environmentId, thread.id);+ if (snoozeInFlightThreadKeys.current.has(key)) {+ return false;+ }+ snoozeInFlightThreadKeys.current.add(key);+ try {+ if (!environmentSupportsSnooze(thread.environmentId)) {+ Alert.alert(+ "Could not snooze thread",+ "This environment's server does not support snoozing yet. Update the server to use Snooze.",+ );+ return false;+ }+ if (!canSnooze(thread, { now: new Date().toISOString() })) {+ Alert.alert(+ "Could not snooze thread",+ thread.hasPendingApprovals || thread.hasPendingUserInput+ ? "This thread is waiting on you. Respond to the pending request before snoozing it."+ : "This thread is still starting a turn. Try again once it's running.",+ );+ return false;+ }++ selectionHaptic();+ const result = await snoozeMutation({+ environmentId: thread.environmentId,+ input: {+ threadId: thread.id,+ snoozedUntil,+ },+ });+ if (result._tag === "Failure") {+ const error = Cause.squash(result.cause);+ Alert.alert(+ "Could not snooze thread",+ error instanceof Error && error.message.trim().length > 0+ ? error.message+ : "The thread could not be snoozed.",+ );+ return false;+ }+ return true;+ } finally {+ snoozeInFlightThreadKeys.current.delete(key);+ }+ },+ [snoozeMutation],+ );+ const unsnoozeThread = useCallback(+ async (thread: EnvironmentThreadShell) => {+ const key = scopedThreadKey(thread.environmentId, thread.id);+ if (snoozeInFlightThreadKeys.current.has(key)) {+ return false;+ }+ snoozeInFlightThreadKeys.current.add(key);+ try {+ if (!environmentSupportsSnooze(thread.environmentId)) {+ Alert.alert(+ "Could not wake thread",+ "This environment's server does not support snoozing yet. Update the server to wake this thread.",+ );+ return false;+ }++ selectionHaptic();+ const result = await unsnoozeMutation({+ environmentId: thread.environmentId,+ input: { threadId: thread.id, reason: "user" },+ });+ if (result._tag === "Failure") {+ const error = Cause.squash(result.cause);+ Alert.alert(+ "Could not wake thread",+ error instanceof Error && error.message.trim().length > 0+ ? error.message+ : "The thread could not be woken.",+ );+ return false;+ }+ return true;+ } finally {+ snoozeInFlightThreadKeys.current.delete(key);+ }+ },+ [unsnoozeMutation],+ );const unsettleThread = useCallback(async (thread: EnvironmentThreadShell) => (await executeAction("unsettle", thread)) === true,[executeAction],@@ -213,7 +313,14 @@ export function useThreadListActions(): {const confirmDeleteThread = useConfirmDeleteThread(executeAction);- return { archiveThread, confirmDeleteThread, settleThread, unsettleThread };+ return {+ archiveThread,+ confirmDeleteThread,+ settleThread,+ snoozeThread,+ unsnoozeThread,+ unsettleThread,+ };}export function useArchivedThreadListActions(diff --git a/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx b/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsxindex 36a86ceb1..adcec1ae5 100644--- a/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx+++ b/apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx@@ -67,7 +67,11 @@ import {ThreadListRow,ThreadListShowMoreRow,} from "./thread-list-items";-import { ThreadListV2PendingRow, ThreadListV2Row } from "./thread-list-v2-items";+import {+ ThreadListV2PendingRow,+ ThreadListV2Row,+ ThreadListV2SnoozedShelfHeader,+} from "./thread-list-v2-items";import {buildThreadListV2Items,buildThreadListV2ListItems,@@ -193,8 +197,14 @@ function ThreadNavigationSidebarPane(const openSwipeableRef = useRef<SwipeableMethods | null>(null);const headerIsOverContentRef = useRef(false);const sidebarScrollGesture = useMemo(() => Gesture.Native(), []);- const { archiveThread, confirmDeleteThread, settleThread, unsettleThread } =- useThreadListActions();+ const {+ archiveThread,+ confirmDeleteThread,+ settleThread,+ snoozeThread,+ unsnoozeThread,+ unsettleThread,+ } = useThreadListActions();const threadListV2Enabled = useThreadListV2Enabled();const pendingTasks = usePendingNewTasks();const { openPendingTask, confirmDeletePendingTask } = usePendingTaskListActions();@@ -428,6 +438,8 @@ function ThreadNavigationSidebarPane(() => setSettledVisibleCount((count) => count + THREAD_LIST_V2_SETTLED_PAGE_COUNT),[],);+ const [snoozedShelfExpanded, setSnoozedShelfExpanded] = useState(false);+ const toggleSnoozedShelf = useCallback(() => setSnoozedShelfExpanded((value) => !value), []);// now ticks per minute so the inactivity auto-settle boundary is actually// crossed while the pane stays open; without a clock dependency the// partition memoizes a frozen "now".@@ -468,7 +480,13 @@ function ThreadNavigationSidebarPane(}, [serverConfigs]);const threadListV2Layout = useMemo(() => {if (!threadListV2Enabled)- return { items: [], hiddenSettledCount: 0, snoozedCount: 0, nextSnoozeWakeAt: null };+ return {+ items: [],+ hiddenSettledCount: 0,+ snoozedCount: 0,+ snoozedShelfHeaderIndex: null,+ nextSnoozeWakeAt: null,+ };return buildThreadListV2Items({threads: threads.filter((thread) => thread.archivedAt === null),environmentId: options.selectedEnvironmentId,@@ -481,11 +499,15 @@ function ThreadNavigationSidebarPane(settledLimit: settledVisibleCount,now: `${nowMinute}:00.000Z`,snoozeNow: new Date().toISOString(),+ snoozedShelfExpanded,+ selectedThreadKey: props.selectedThreadKey ?? null,});}, [changeRequestStateByKey,nowMinute,snoozeWakeTick,+ snoozedShelfExpanded,+ props.selectedThreadKey,options.selectedEnvironmentId,props.searchQuery,matchedThreadKeys,@@ -532,6 +554,10 @@ function ThreadNavigationSidebarPane(const items: SidebarListItem[] = buildThreadListV2ListItems({items: threadListV2Layout.items,pendingTasks: v2PendingTasks,+ snoozedCount: threadListV2Layout.snoozedCount,+ snoozedShelfExpanded,+ snoozedShelfHeaderIndex: threadListV2Layout.snoozedShelfHeaderIndex,+ snoozeLabelNow: `${nowMinute}:00.000Z`,});if (threadListV2Layout.hiddenSettledCount > 0) {items.push({@@ -543,10 +569,12 @@ function ThreadNavigationSidebarPane(return items;}, [listLayout.items,+ nowMinute,options.selectedEnvironmentId,pendingTasks,props.searchQuery,selectedProjectRefs,+ snoozedShelfExpanded,threadListV2Enabled,threadListV2Layout,]);@@ -731,6 +759,7 @@ function ThreadNavigationSidebarPane(projectTitleByProjectKey,savedConnectionsById,serverConfigs,+ snoozePresetMinute: nowMinute,threadSearchMatchByKey,}),[@@ -740,6 +769,7 @@ function ThreadNavigationSidebarPane(projectTitleByProjectKey,savedConnectionsById,serverConfigs,+ nowMinute,threadSearchMatchByKey,],);@@ -750,7 +780,9 @@ 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 &&+ previous.item.snoozed === item.item.snoozed &&+ previous.snoozeWakeLabelText === item.snoozeWakeLabelText);}if (previous.type === "v2-show-more" && item.type === "v2-show-more") {@@ -762,13 +794,18 @@ function ThreadNavigationSidebarPane(previous.showPendingDivider === item.showPendingDivider);}+ if (previous.type === "v2-snoozed-shelf" && item.type === "v2-snoozed-shelf") {+ return previous.count === item.count && previous.expanded === item.expanded;+ }if (previous.type === "v2-thread" ||previous.type === "v2-show-more" ||previous.type === "v2-pending" ||+ previous.type === "v2-snoozed-shelf" ||item.type === "v2-thread" ||item.type === "v2-show-more" ||- item.type === "v2-pending"+ item.type === "v2-pending" ||+ item.type === "v2-snoozed-shelf") {return false;}@@ -827,6 +864,9 @@ function ThreadNavigationSidebarPane(thread={thread}variant={item.item.variant}showSettledDivider={item.item.showSettledDivider}+ snoozed={item.item.snoozed}+ snoozePresetMinute={nowMinute}+ snoozeWakeLabelText={item.snoozeWakeLabelText}project={projectByKey.get(scopeKey) ?? null}projectTitle={projectTitleByProjectKey.get(scopeKey)}providerDriver={@@ -860,6 +900,9 @@ function ThreadNavigationSidebarPane(onArchiveThread={archiveThread}settlementSupported={settlementEnvironmentIds.has(thread.environmentId)}onSettleThread={settleThread}+ snoozeSupported={snoozeEnvironmentIds.has(thread.environmentId)}+ onSnoozeThread={snoozeThread}+ onUnsnoozeThread={unsnoozeThread}onUnsettleThread={unsettleThread}onChangeRequestState={handleChangeRequestState}projectCwd={projectCwdByKey.get(scopeKey) ?? null}@@ -869,6 +912,15 @@ function ThreadNavigationSidebarPane(/>);}+ case "v2-snoozed-shelf":+ return (+ <ThreadListV2SnoozedShelfHeader+ count={item.count}+ expanded={item.expanded}+ onToggle={toggleSnoozedShelf}+ pane="sidebar"+ />+ );case "v2-show-more":return (<Pressable@@ -984,7 +1036,12 @@ function ThreadNavigationSidebarPane(settlementEnvironmentIds,showMoreSettled,sidebarScrollGesture,+ snoozeEnvironmentIds,+ snoozeThread,+ nowMinute,+ toggleSnoozedShelf,unsettleThread,+ unsnoozeThread,updateGroupDisplay,],);@@ -1031,30 +1088,19 @@ function ThreadNavigationSidebarPane(}),[filterIcon, filterMenu, props.onOpenSettings],);- // "No threads yet" over an inbox that is merely all-snoozed reads as- // data loss; name the snoozed threads instead.- const snoozedCount = threadListV2Layout.snoozedCount;+ // Snoozed threads need no special case: the shelf header is a list row+ // even while collapsed.const listEmpty = (<Text className="px-2 py-4 text-sm text-foreground-muted">{catalogState.isLoadingConnections? "Loading threads…": props.searchQuery.trim().length > 0- ? threadSearch.isPending && snoozedCount === 0+ ? threadSearch.isPending? "Searching thread messages…"- : snoozedCount > 0- ? // Snoozed matches passed this same search filter — "No- // matching threads" would misreport them as nonexistent.- snoozedCount === 1- ? "1 matching thread snoozed"- : "All matching threads snoozed"- : "No matching threads"- : snoozedCount > 0- ? snoozedCount === 1- ? "1 thread snoozed"- : `${snoozedCount} threads snoozed`- : selectedProjectScope !== null- ? `No threads in ${selectedProjectScope.title}`- : "No threads yet"}+ : "No matching threads"+ : selectedProjectScope !== null+ ? `No threads in ${selectedProjectScope.title}`+ : "No threads yet"}</Text>);diff --git a/apps/mobile/src/features/threads/thread-list-v2-items.tsx b/apps/mobile/src/features/threads/thread-list-v2-items.tsxindex 6af5795a9..42fb12f5e 100644--- a/apps/mobile/src/features/threads/thread-list-v2-items.tsx+++ b/apps/mobile/src/features/threads/thread-list-v2-items.tsx@@ -3,11 +3,20 @@ import type {EnvironmentThreadShell,} from "@t3tools/client-runtime/state/shell";import type { EnvironmentThreadSearchMatch } from "@t3tools/client-runtime/state/thread-search";+import { canSnooze, resolveSnoozePresets } from "@t3tools/client-runtime/state/thread-settled";import type { MenuAction } from "@react-native-menu/menu";-import { memo, useCallback, useEffect, useMemo, type ComponentProps } from "react";-import { Platform, Pressable, useWindowDimensions, View } from "react-native";+import { memo, useCallback, useEffect, useMemo, useState, type ComponentProps } from "react";+import {+ Alert,+ Platform,+ Pressable,+ useColorScheme,+ useWindowDimensions,+ View,+} from "react-native";import type { SwipeableMethods } from "react-native-gesture-handler/ReanimatedSwipeable";+import { SymbolView } from "../../components/AppSymbol";import { AppText as Text } from "../../components/AppText";import { ControlPillMenu } from "../../components/ControlPill";import { ProjectFavicon } from "../../components/ProjectFavicon";@@ -18,7 +27,13 @@ import { useThemeColor } from "../../lib/useThemeColor";import type { PendingNewTask } from "../../state/use-pending-new-tasks";import { useThreadPr } from "../../state/use-thread-pr";import { ThreadSwipeable } from "../home/thread-swipe-actions";-import { resolveThreadListV2Status, type ThreadListV2Status } from "./threadListV2";+import {+ resolveThreadListV2SnoozeMenuSelection,+ resolveThreadListV2SnoozeGateExpiryMs,+ resolveThreadListV2Status,+ resolveThreadListV2SwipeActions,+ type ThreadListV2Status,+} from "./threadListV2";import { ThreadSearchMatchExcerpt } from "./thread-search-match";/**@@ -62,6 +77,11 @@ const SLIM_MENU_ACTIONS: MenuAction[] = [{ id: "delete", title: "Delete", image: "trash", attributes: { destructive: true } },];+const SNOOZED_MENU_ACTIONS: MenuAction[] = [+ { id: "unsnooze", title: "Wake thread", image: "clock" },+ { id: "delete", title: "Delete", image: "trash", attributes: { destructive: true } },+];+// Pre-settlement servers: no lifecycle items, archive fills the gap.const LEGACY_MENU_ACTIONS: MenuAction[] = [{ id: "archive", title: "Archive", image: "archivebox" },@@ -90,6 +110,45 @@ export const ThreadListV2SectionDivider = memo(function ThreadListV2SectionDivid);});+const SNOOZE_ACCENT_LIGHT = "#2563eb";+const SNOOZE_ACCENT_DARK = "#60a5fa";++export const ThreadListV2SnoozedShelfHeader = memo(function ThreadListV2SnoozedShelfHeader(props: {+ readonly count: number;+ readonly expanded: boolean;+ readonly onToggle: () => void;+ readonly pane?: "screen" | "sidebar";+}) {+ const colorScheme = useColorScheme();+ return (+ <Pressable+ accessibilityHint={+ props.expanded ? "Collapses the snoozed threads." : "Expands the snoozed threads."+ }+ accessibilityLabel={props.count === 1 ? "1 snoozed thread" : `${props.count} snoozed threads`}+ accessibilityRole="button"+ accessibilityState={{ expanded: props.expanded }}+ className={cn(+ "mb-1.5 mt-4 flex-row items-center gap-2.5",+ props.pane === "sidebar" ? "px-3" : "px-5",+ )}+ onPress={props.onToggle}+ style={({ pressed }) => ({ opacity: pressed ? 0.6 : 1 })}+ >+ <Text className="text-xs font-t3-medium text-blue-600 dark:text-blue-400">+ {props.expanded ? "Snoozed" : `Snoozed (${props.count})`}+ </Text>+ <View className="h-px flex-1 bg-blue-500/20 dark:bg-blue-400/15" />+ <SymbolView+ name={props.expanded ? "chevron.up" : "chevron.down"}+ size={10}+ tintColor={colorScheme === "dark" ? SNOOZE_ACCENT_DARK : SNOOZE_ACCENT_LIGHT}+ type="monochrome"+ />+ </Pressable>+ );+});+const PENDING_TASK_MENU_ACTIONS: MenuAction[] = [{ id: "delete", title: "Delete", image: "trash", attributes: { destructive: true } },];@@ -209,6 +268,14 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {readonly thread: EnvironmentThreadShell;readonly variant: "card" | "slim";readonly showSettledDivider: boolean;+ /** Snoozed-shelf row: shows its wake time and offers Wake. */+ readonly snoozed?: boolean;+ /** Preformatted against the parent minute tick so this memoized row's+ countdown keeps moving. */+ readonly snoozeWakeLabelText?: string;+ /** Parent minute tick passed as a prop so this memoized row refreshes its+ native snooze menu while mounted. */+ readonly snoozePresetMinute: string;readonly project: EnvironmentProject | null;readonly projectTitle?: string;readonly providerDriver: string | null;@@ -231,11 +298,15 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {readonly onSelectThread: (thread: EnvironmentThreadShell) => void;readonly onDeleteThread: (thread: EnvironmentThreadShell) => void;readonly onSettleThread: (thread: EnvironmentThreadShell) => void;+ readonly onSnoozeThread: (thread: EnvironmentThreadShell, snoozedUntil: string) => void;+ readonly onUnsnoozeThread: (thread: EnvironmentThreadShell) => void;readonly onUnsettleThread: (thread: EnvironmentThreadShell) => void;readonly onArchiveThread: (thread: EnvironmentThreadShell) => void;/** False on environments whose server predates thread.settle/unsettle:swipe + menu fall back to Archive instead of failing on use. */readonly settlementSupported: boolean;+ /** False on servers that predate thread.snooze/unsnooze. */+ readonly snoozeSupported: boolean;readonly onSwipeableWillOpen: (methods: SwipeableMethods) => void;readonly onSwipeableClose: (methods: SwipeableMethods) => void;/** Reports this row's live PR state up so the partition can auto-settle@@ -258,10 +329,13 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {onSelectThread,onDeleteThread,onSettleThread,+ onSnoozeThread,+ onUnsnoozeThread,onUnsettleThread,onArchiveThread,onChangeRequestState,} = props;+ const snoozedRow = props.snoozed === true;const pr = useThreadPr(thread, props.projectCwd ?? props.project?.workspaceRoot ?? null);const prState = pr?.state ?? null;@@ -283,27 +357,94 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {const handleDelete = useCallback(() => onDeleteThread(thread), [onDeleteThread, thread]);const handleSettle = useCallback(() => onSettleThread(thread), [onSettleThread, thread]);+ const handleSnooze = useCallback(+ (snoozedUntil: string) => onSnoozeThread(thread, snoozedUntil),+ [onSnoozeThread, thread],+ );+ const handleUnsnooze = useCallback(() => onUnsnoozeThread(thread), [onUnsnoozeThread, thread]);const handleUnsettle = useCallback(() => onUnsettleThread(thread), [onUnsettleThread, thread]);const handleArchive = useCallback(() => onArchiveThread(thread), [onArchiveThread, thread]);++ // Swipe: the v2 primary action is the lifecycle transition. Every settled+ // row can un-settle — explicit settles clear the override, auto-settled+ // rows get pinned active until real activity clears the pin.+ const canUnsettle = variant === "slim";+ const [snoozeGateTick, bumpSnoozeGateTick] = useState(0);+ const snoozeGateExpiryMs = props.snoozeSupported+ ? resolveThreadListV2SnoozeGateExpiryMs(thread, { now: new Date().toISOString() })+ : null;+ useEffect(() => {+ if (snoozeGateExpiryMs === null) return;+ const delayMs = Math.min(Math.max(0, snoozeGateExpiryMs - Date.now()) + 50, 2_147_483_647);+ const id = setTimeout(() => bumpSnoozeGateTick((tick) => tick + 1), delayMs);+ return () => clearTimeout(id);+ }, [snoozeGateExpiryMs, snoozeGateTick]);+ const swipeActions = resolveThreadListV2SwipeActions({+ variant,+ settlementSupported: props.settlementSupported,+ snoozeSupported: props.snoozeSupported,+ snoozable: canSnooze(thread, { now: new Date().toISOString() }),+ snoozed: snoozedRow,+ });+ const snoozePresets = useMemo(+ () => (swipeActions.secondary === "snooze" ? resolveSnoozePresets(new Date()) : ([] as const)),+ [props.snoozePresetMinute, swipeActions.secondary],+ );+ const snoozePresetActions = useMemo<MenuAction[]>(+ () =>+ snoozePresets.map((preset) => ({+ id: `snooze:${preset.id}`,+ title: preset.label,+ subtitle: preset.whenLabel,+ })),+ [snoozePresets],+ );+ const snoozableCardMenuActions = useMemo<MenuAction[]>(+ () => [+ { id: "settle", title: "Settle", image: "checkmark" },+ {+ id: "snooze",+ title: "Snooze",+ image: "clock",+ subactions: snoozePresetActions,+ },+ { id: "delete", title: "Delete", image: "trash", attributes: { destructive: true } },+ ],+ [snoozePresetActions],+ );const handleMenuAction = useCallback(({ nativeEvent }: { readonly nativeEvent: { readonly event: string } }) => {if (nativeEvent.event === "settle") handleSettle();if (nativeEvent.event === "unsettle") handleUnsettle();+ if (nativeEvent.event === "unsnooze") handleUnsnooze();if (nativeEvent.event === "archive") handleArchive();if (nativeEvent.event === "delete") handleDelete();+ const snoozeSelection = resolveThreadListV2SnoozeMenuSelection({+ event: nativeEvent.event,+ displayedPresets: snoozePresets,+ now: new Date(),+ });+ if (snoozeSelection._tag === "selected") {+ handleSnooze(snoozeSelection.preset.snoozedUntil);+ } else if (snoozeSelection._tag === "expired") {+ Alert.alert("Could not snooze thread", "That snooze time has passed. Choose another time.");+ }},- [handleArchive, handleDelete, handleSettle, handleUnsettle],+ [+ handleArchive,+ handleDelete,+ handleSettle,+ handleSnooze,+ handleUnsettle,+ handleUnsnooze,+ snoozePresets,+ ],);-- // Swipe: the v2 primary action is the lifecycle transition. Every settled- // row can un-settle — explicit settles clear the override, auto-settled- // rows get pinned active until real activity clears the pin.- const canUnsettle = variant === "slim";const primaryAction = useMemo(() => {// Pre-settlement server: archive is the swipe action, as in v1. (Slim// rows cannot occur here — unsupported environments never classify as// settled.)- if (!props.settlementSupported) {+ if (swipeActions.primary === "archive") {return {accessibilityLabel: `Archive ${thread.title}`,icon: "archivebox" as const,@@ -311,7 +452,15 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {onPress: handleArchive,};}- return canUnsettle+ if (swipeActions.primary === "unsnooze") {+ return {+ accessibilityLabel: `Wake ${thread.title} now`,+ icon: "clock" as const,+ label: "Wake",+ onPress: handleUnsnooze,+ };+ }+ return swipeActions.primary === "unsettle"? {accessibilityLabel: `Un-settle ${thread.title}`,icon: "arrow.uturn.backward" as const,@@ -325,13 +474,34 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {onPress: handleSettle,};}, [- canUnsettle,handleArchive,handleSettle,handleUnsettle,- props.settlementSupported,+ handleUnsnooze,+ swipeActions.primary,thread.title,]);+ const secondaryAction = useMemo(+ () =>+ swipeActions.secondary === "snooze"+ ? {+ accessibilityLabel: `Choose when to snooze ${thread.title}`,+ icon: "clock" as const,+ label: "Snooze",+ menu: {+ actions: snoozePresetActions,+ onPressAction: handleMenuAction,+ title: "Snooze until",+ },+ onPress: () => undefined,+ }+ : null,+ [handleMenuAction, snoozePresetActions, swipeActions.secondary, thread.title],+ );+ const swipeAccessibilityHint =+ secondaryAction === null+ ? `Opens the thread. Swipe left to ${primaryAction.label.toLowerCase()}.`+ : `Opens the thread. Swipe left for ${primaryAction.label.toLowerCase()} and snooze actions.`;// The sidebar pane fills selected rows with the accent color (matching the// v1 sidebar), so every piece of row text needs a white-on-accent variant.@@ -453,7 +623,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {const rowContent = (close: () => void) =>variant === "card" ? (<Pressable- accessibilityHint={`Opens the thread. Swipe left to ${primaryAction.label.toLowerCase()}.`}+ accessibilityHint={swipeAccessibilityHint}accessibilityLabel={thread.title}accessibilityRole="button"accessibilityState={{ selected }}@@ -491,7 +661,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {</Pressable>) : (<Pressable- accessibilityHint={`Opens the thread. Swipe left to ${primaryAction.label.toLowerCase()}.`}+ accessibilityHint={swipeAccessibilityHint}accessibilityLabel={thread.title}accessibilityRole="button"accessibilityState={{ selected }}@@ -551,11 +721,17 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {<TextclassName={cn("text-sm tabular-nums",- selected ? "text-user-bubble-foreground-muted" : "text-foreground-tertiary",+ selected+ ? "text-user-bubble-foreground-muted"+ : snoozedRow+ ? "text-blue-600 dark:text-blue-400"+ : "text-foreground-tertiary",)}style={{ fontFamily: MONO_FONT }}>- {relativeTime(thread.latestUserMessageAt ?? thread.updatedAt ?? thread.createdAt)}+ {snoozedRow && props.snoozeWakeLabelText !== undefined+ ? props.snoozeWakeLabelText+ : relativeTime(thread.latestUserMessageAt ?? thread.updatedAt ?? thread.createdAt)}</Text></View></Pressable>@@ -574,13 +750,14 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {}enableTrackpadSwipe// Full swipe commits the advertised lifecycle action (Settle /- // Un-settle), never the destructive delete.+ // Un-settle), never the secondary snooze action.fullSwipeAction="primary"fullSwipeWidth={props.fullSwipeWidth ?? windowWidth - 32}onDelete={handleDelete}onSwipeableClose={props.onSwipeableClose}onSwipeableWillOpen={props.onSwipeableWillOpen}primaryAction={primaryAction}+ secondaryAction={secondaryAction}resetKey={`${thread.environmentId}:${thread.id}`}simultaneousWithExternalGesture={props.simultaneousSwipeGesture}threadTitle={thread.title}@@ -588,11 +765,15 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {{(close) => (<ControlPillMenuactions={- !props.settlementSupported- ? LEGACY_MENU_ACTIONS- : canUnsettle- ? SLIM_MENU_ACTIONS- : CARD_MENU_ACTIONS+ snoozedRow+ ? SNOOZED_MENU_ACTIONS+ : !props.settlementSupported+ ? LEGACY_MENU_ACTIONS+ : canUnsettle+ ? SLIM_MENU_ACTIONS+ : swipeActions.secondary === "snooze"+ ? snoozableCardMenuActions+ : CARD_MENU_ACTIONS}onPressAction={handleMenuAction}shouldOpenOnLongPressdiff --git a/apps/mobile/src/features/threads/threadListV2.test.ts b/apps/mobile/src/features/threads/threadListV2.test.tsindex 90b5897f1..9008b29fd 100644--- a/apps/mobile/src/features/threads/threadListV2.test.ts+++ b/apps/mobile/src/features/threads/threadListV2.test.ts@@ -1,5 +1,6 @@import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell";import { threadSearchMatchKey } from "@t3tools/client-runtime/state/thread-search";+import { resolveSnoozePresets } from "@t3tools/client-runtime/state/thread-settled";import {CommandId,EnvironmentId,@@ -16,7 +17,10 @@ import {buildThreadListV2Items,buildThreadListV2ListItems,resolveThreadListV2Enabled,+ resolveThreadListV2SnoozeMenuSelection,+ resolveThreadListV2SnoozeGateExpiryMs,resolveThreadListV2Status,+ resolveThreadListV2SwipeActions,sortThreadsForListV2,} from "./threadListV2";@@ -50,6 +54,54 @@ function makeThread(const NOW = "2026-06-02T00:00:00.000Z";+describe("resolveThreadListV2SnoozeMenuSelection", () => {+ it("accepts a displayed evening preset while its wake time is still future", () => {+ const menuOpenedAt = new Date(2026, 4, 8, 16, 59, 30);+ const selectedAt = new Date(2026, 4, 8, 17, 0, 30);+ const displayedPresets = resolveSnoozePresets(menuOpenedAt);++ const selection = resolveThreadListV2SnoozeMenuSelection({+ event: "snooze:evening",+ displayedPresets,+ now: selectedAt,+ });++ expect(selection).toEqual({+ _tag: "selected",+ preset: displayedPresets.find((preset) => preset.id === "evening"),+ });+ });++ it("expires a displayed preset once its wake time has passed", () => {+ const displayedPresets = resolveSnoozePresets(new Date(2026, 4, 8, 16, 59, 30));++ expect(+ resolveThreadListV2SnoozeMenuSelection({+ event: "snooze:evening",+ displayedPresets,+ now: new Date(2026, 4, 8, 18, 0, 1),+ }),+ ).toEqual({ _tag: "expired" });+ });++ it("recomputes presets that remain available instead of using old timestamps", () => {+ const displayedPresets = resolveSnoozePresets(new Date(2026, 4, 8, 10));+ const selectedAt = new Date(2026, 4, 8, 10, 30);+ const selection = resolveThreadListV2SnoozeMenuSelection({+ event: "snooze:hour",+ displayedPresets,+ now: selectedAt,+ });++ expect(selection._tag).toBe("selected");+ if (selection._tag === "selected") {+ expect(selection.preset.snoozedUntil).toBe(+ new Date(selectedAt.getTime() + 60 * 60 * 1_000).toISOString(),+ );+ }+ });+});+describe("resolveThreadListV2Enabled", () => {it("defaults on when the device has never chosen", () => {expect(resolveThreadListV2Enabled({ preference: undefined, preferencesLoaded: true })).toBe(@@ -96,6 +148,105 @@ describe("resolveThreadListV2Status", () => {});});+describe("resolveThreadListV2SwipeActions", () => {+ it("offers settle and snooze for an active snoozable thread", () => {+ expect(+ resolveThreadListV2SwipeActions({+ variant: "card",+ settlementSupported: true,+ snoozeSupported: true,+ snoozable: true,+ }),+ ).toEqual({ primary: "settle", secondary: "snooze" });+ });++ it("offers un-settle and snooze for settled history", () => {+ expect(+ resolveThreadListV2SwipeActions({+ variant: "slim",+ settlementSupported: true,+ snoozeSupported: true,+ snoozable: true,+ }),+ ).toEqual({ primary: "unsettle", secondary: "snooze" });+ });++ it("omits snooze when the server or thread does not allow it", () => {+ expect(+ resolveThreadListV2SwipeActions({+ variant: "card",+ settlementSupported: true,+ snoozeSupported: false,+ snoozable: true,+ }),+ ).toEqual({ primary: "settle", secondary: null });+ expect(+ resolveThreadListV2SwipeActions({+ variant: "card",+ settlementSupported: true,+ snoozeSupported: true,+ snoozable: false,+ }),+ ).toEqual({ primary: "settle", secondary: null });+ });++ it("falls back to archive only for a pre-lifecycle server", () => {+ expect(+ resolveThreadListV2SwipeActions({+ variant: "card",+ settlementSupported: false,+ snoozeSupported: false,+ snoozable: true,+ }),+ ).toEqual({ primary: "archive", secondary: null });+ });++ it("offers wake and no snooze on a snoozed row", () => {+ expect(+ resolveThreadListV2SwipeActions({+ variant: "slim",+ settlementSupported: true,+ snoozeSupported: true,+ snoozable: true,+ snoozed: true,+ }),+ ).toEqual({ primary: "unsnooze", secondary: null });+ });+});++describe("resolveThreadListV2SnoozeGateExpiryMs", () => {+ it("reports when an unadopted turn's grace window lapses", () => {+ const thread = makeThread({+ id: ThreadId.make("t"),+ title: "t",+ latestUserMessageAt: "2026-06-02T00:00:30.000Z",+ });+ expect(resolveThreadListV2SnoozeGateExpiryMs(thread, { now: "2026-06-02T00:01:00.000Z" })).toBe(+ Date.parse("2026-06-02T00:02:30.000Z"),+ );+ });++ it("returns null once the thread is snoozable or when only data can unblock it", () => {+ expect(+ resolveThreadListV2SnoozeGateExpiryMs(+ makeThread({ id: ThreadId.make("ready"), title: "Ready" }),+ { now: NOW },+ ),+ ).toBe(null);+ expect(+ resolveThreadListV2SnoozeGateExpiryMs(+ makeThread({+ id: ThreadId.make("blocked"),+ title: "Blocked",+ hasPendingApprovals: true,+ latestUserMessageAt: NOW,+ }),+ { now: NOW },+ ),+ ).toBe(null);+ });+});+describe("sortThreadsForListV2", () => {it("orders by creation time, newest first, ignoring activity", () => {const sorted = sortThreadsForListV2([@@ -167,6 +318,93 @@ describe("buildThreadListV2Items", () => {expect(layout.nextSnoozeWakeAt).toBe("2026-06-02T09:00:00.000Z");});+ it("builds snoozed rows between active and settled when the shelf is expanded", () => {+ const layout = buildThreadListV2Items({+ threads: [+ makeThread({ id: ThreadId.make("active"), title: "Active" }),+ makeThread({+ id: ThreadId.make("settled"),+ title: "Settled",+ settledOverride: "settled",+ settledAt: NOW,+ }),+ makeThread({+ id: ThreadId.make("later"),+ title: "Wakes later",+ snoozedUntil: "2026-06-03T09:00:00.000Z",+ snoozedAt: "2026-06-01T12:00:00.000Z",+ }),+ makeThread({+ id: ThreadId.make("sooner"),+ title: "Wakes sooner",+ snoozedUntil: "2026-06-02T09:00:00.000Z",+ snoozedAt: "2026-06-01T12:00:00.000Z",+ }),+ ],+ environmentId: null,+ searchQuery: "",+ now: NOW,+ snoozedShelfExpanded: true,+ });++ expect(layout.items.map((item) => item.thread.id)).toEqual([+ "active",+ "sooner",+ "later",+ "settled",+ ]);+ expect(layout.items.map((item) => item.snoozed)).toEqual([false, true, true, false]);+ expect(layout.snoozedShelfHeaderIndex).toBe(1);+ expect(layout.snoozedCount).toBe(2);+ });++ it("collapses to a header-only shelf", () => {+ const layout = buildThreadListV2Items({+ threads: [+ makeThread({+ id: ThreadId.make("snoozed"),+ title: "Snoozed",+ snoozedUntil: "2026-06-03T09:00:00.000Z",+ snoozedAt: "2026-06-01T12:00:00.000Z",+ }),+ ],+ environmentId: null,+ searchQuery: "",+ now: NOW,+ });++ expect(layout.items).toEqual([]);+ expect(layout.snoozedCount).toBe(1);+ expect(layout.snoozedShelfHeaderIndex).toBe(0);+ });++ it("keeps the selected thread on a collapsed shelf", () => {+ const layout = buildThreadListV2Items({+ threads: [+ makeThread({+ id: ThreadId.make("open"),+ title: "Open",+ snoozedUntil: "2026-06-03T09:00:00.000Z",+ snoozedAt: "2026-06-01T12:00:00.000Z",+ }),+ makeThread({+ id: ThreadId.make("other"),+ title: "Other",+ snoozedUntil: "2026-06-03T10:00:00.000Z",+ snoozedAt: "2026-06-01T12:00:00.000Z",+ }),+ ],+ environmentId: null,+ searchQuery: "",+ now: NOW,+ selectedThreadKey: `${environmentId}:open`,+ });++ expect(layout.items.map((item) => item.thread.id)).toEqual(["open"]);+ expect(layout.items[0]?.snoozed).toBe(true);+ expect(layout.snoozedCount).toBe(2);+ });+it("keeps snoozed threads visible on environments without the snooze capability", () => {const layout = buildThreadListV2Items({threads: [@@ -424,7 +662,11 @@ describe("buildThreadListV2ListItems", () => {expect(items.map((item) =>- item.type === "v2-pending" ? item.pendingTask.title : item.item.thread.id,+ item.type === "v2-pending"+ ? item.pendingTask.title+ : item.type === "v2-thread"+ ? item.item.thread.id+ : "snoozed-shelf",),).toEqual(["active", "queued-1", "queued-2", "settled"]);// Only the leading queued row labels the section, exactly like Settled.@@ -456,4 +698,41 @@ describe("buildThreadListV2ListItems", () => {`v2-thread:${environmentId}:settled`,]);});++ it("places queued tasks before a collapsed snoozed shelf", () => {+ const snoozedLayout = buildThreadListV2Items({+ threads: [+ makeThread({ id: ThreadId.make("active"), title: "active" }),+ makeThread({+ id: ThreadId.make("snoozed"),+ title: "snoozed",+ snoozedUntil: "2026-06-03T09:00:00.000Z",+ snoozedAt: "2026-06-01T12:00:00.000Z",+ }),+ makeThread({+ id: ThreadId.make("settled"),+ title: "settled",+ settledOverride: "settled",+ settledAt: NOW,+ }),+ ],+ environmentId: null,+ searchQuery: "",+ now: NOW,+ });+ const items = buildThreadListV2ListItems({+ items: snoozedLayout.items,+ pendingTasks: [makePendingTask("queued")],+ snoozedCount: snoozedLayout.snoozedCount,+ snoozedShelfExpanded: false,+ snoozedShelfHeaderIndex: snoozedLayout.snoozedShelfHeaderIndex,+ });++ expect(items.map((item) => item.type)).toEqual([+ "v2-thread",+ "v2-pending",+ "v2-snoozed-shelf",+ "v2-thread",+ ]);+ });});diff --git a/apps/mobile/src/features/threads/threadListV2.ts b/apps/mobile/src/features/threads/threadListV2.tsindex 920b7f0b5..6ed22f5c0 100644--- a/apps/mobile/src/features/threads/threadListV2.ts+++ b/apps/mobile/src/features/threads/threadListV2.ts@@ -1,10 +1,20 @@-import { effectiveSettled, effectiveSnoozed } from "@t3tools/client-runtime/state/thread-settled";+import {+ effectiveSettled,+ effectiveSnoozed,+ hasQueuedTurnStart,+ QUEUED_TURN_START_GRACE_MS,+ resolveSnoozePresets,+ snoozeWakeLabel,+} from "@t3tools/client-runtime/state/thread-settled";+import type { SnoozePreset } from "@t3tools/client-runtime/state/thread-settled";import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell";import { threadSearchMatchKey } from "@t3tools/client-runtime/state/thread-search";import type { EnvironmentId, ProjectId } from "@t3tools/contracts";import type { PendingNewTask } from "../../state/use-pending-new-tasks";+export { snoozeWakeLabel };+/*** Thread List v2 model, ported from the web sidebar v2* (apps/web/src/components/Sidebar.logic.ts + SidebarV2.tsx).@@ -14,6 +24,76 @@ import type { PendingNewTask } from "../../state/use-pending-new-tasks";* unlabeled resting state.*/export type ThreadListV2Status = "approval" | "input" | "working" | "failed" | "ready";+export type ThreadListV2SwipeAction = "archive" | "settle" | "unsettle" | "snooze" | "unsnooze";++export function resolveThreadListV2SnoozeMenuSelection(input: {+ readonly event: string;+ readonly displayedPresets: ReadonlyArray<SnoozePreset>;+ readonly now: Date;+}):+ | { readonly _tag: "selected"; readonly preset: SnoozePreset }+ | { readonly _tag: "expired" }+ | { readonly _tag: "not-snooze" } {+ if (!input.event.startsWith("snooze:")) return { _tag: "not-snooze" };++ const currentPreset = resolveSnoozePresets(input.now).find(+ (candidate) => input.event === `snooze:${candidate.id}`,+ );+ if (currentPreset) return { _tag: "selected", preset: currentPreset };++ const displayedPreset = input.displayedPresets.find(+ (candidate) => input.event === `snooze:${candidate.id}`,+ );+ if (displayedPreset && Date.parse(displayedPreset.snoozedUntil) > input.now.getTime()) {+ return { _tag: "selected", preset: displayedPreset };+ }+ return { _tag: "expired" };+}++export function resolveThreadListV2SwipeActions(input: {+ readonly variant: "card" | "slim";+ readonly settlementSupported: boolean;+ readonly snoozeSupported: boolean;+ readonly snoozable: boolean;+ /** Row is on the snoozed shelf. */+ readonly snoozed?: boolean;+}): {+ readonly primary: Exclude<ThreadListV2SwipeAction, "snooze">;+ readonly secondary: "snooze" | null;+} {+ if (input.snoozed === true) {+ return { primary: "unsnooze", secondary: null };+ }+ const primary = input.settlementSupported+ ? input.variant === "slim"+ ? "unsettle"+ : "settle"+ : "archive";+ return {+ primary,+ secondary: input.snoozeSupported && input.snoozable ? "snooze" : null,+ };+}++/**+ * The point at which a queued-turn snooze guard expires on its own. Rows arm+ * a one-shot timer for this boundary so Snooze appears without waiting for an+ * unrelated render. User-blocked threads return null because only fresh+ * server data can make them snoozable.+ */+export function resolveThreadListV2SnoozeGateExpiryMs(+ thread: Pick<+ EnvironmentThreadShell,+ "hasPendingApprovals" | "hasPendingUserInput" | "latestUserMessageAt" | "latestTurn" | "session"+ >,+ options: { readonly now: string },+): number | null {+ if (thread.hasPendingApprovals || thread.hasPendingUserInput) return null;+ if (!hasQueuedTurnStart(thread, options)) return null;+ const messageAtMs = Date.parse(thread.latestUserMessageAt ?? "");+ if (Number.isNaN(messageAtMs)) return null;+ return messageAtMs + QUEUED_TURN_START_GRACE_MS;+}// Settled-tail paging: recent history is the common lookup; the deep tail// stays behind an explicit Show more. Shared by the compact Home list and@@ -100,6 +180,8 @@ export interface ThreadListV2Item {readonly variant: "card" | "slim";/** First settled row after the card block draws the SETTLED divider. */readonly showSettledDivider: boolean;+ /** Snoozed-shelf row: shows the wake countdown and offers Wake. */+ readonly snoozed: boolean;readonly isLast: boolean;}@@ -107,10 +189,12 @@ export interface ThreadListV2Layout {readonly items: ThreadListV2Item[];/** Settled threads beyond the render limit (behind "Show more"). */readonly hiddenSettledCount: number;- /** Snoozed threads hidden from the list (visibility parity with web's- collapsed Snoozed shelf; mobile has no shelf UI yet). */+ /** Snoozed threads matching the current filters. */readonly snoozedCount: number;- /** Soonest wake time among hidden snoozed threads, or null. Callers arm+ /** Index in `items` where the Snoozed shelf header belongs. The header is+ still rendered when the shelf is collapsed and no snoozed rows exist. */+ readonly snoozedShelfHeaderIndex: number | null;+ /** Soonest wake time among snoozed threads, or null. Callers arma timeout at this boundary so the list re-partitions the moment asnooze expires instead of on the next minute tick. */readonly nextSnoozeWakeAt: string | null;@@ -120,6 +204,8 @@ export interface ThreadListV2ThreadListItem {readonly type: "v2-thread";readonly key: string;readonly item: ThreadListV2Item;+ /** Precomputed so recycled-list equality can see a minute-tick change. */+ readonly snoozeWakeLabelText: string | undefined;}export interface ThreadListV2PendingListItem {@@ -130,28 +216,42 @@ export interface ThreadListV2PendingListItem {readonly showPendingDivider: boolean;}-export type ThreadListV2ListItem = ThreadListV2ThreadListItem | ThreadListV2PendingListItem;+export interface ThreadListV2SnoozedShelfListItem {+ readonly type: "v2-snoozed-shelf";+ readonly key: "v2-snoozed-shelf";+ readonly count: number;+ readonly expanded: boolean;+}++export type ThreadListV2ListItem =+ | ThreadListV2ThreadListItem+ | ThreadListV2PendingListItem+ | ThreadListV2SnoozedShelfListItem;/**- * Splices queued tasks between the active block and the settled tail, so the- * list reads active → pending → settled. Queued work sits below the live- * threads because nothing can happen to it until its environment returns:- * it is waiting, not asking. Shared by the compact Home list and the iPad- * sidebar so both order and label the sections identically.+ * Builds the shared mobile order: active → pending → snoozed shelf → settled.+ * Pending tasks are waiting rather than asking, and parked work remains+ * reachable without competing with either the inbox or settled history.*/export function buildThreadListV2ListItems(input: {readonly items: ReadonlyArray<ThreadListV2Item>;readonly pendingTasks: ReadonlyArray<PendingNewTask>;+ readonly snoozedCount?: number;+ readonly snoozedShelfExpanded?: boolean;+ readonly snoozedShelfHeaderIndex?: number | null;+ readonly snoozeLabelNow?: string;}): ThreadListV2ListItem[] {const threadItems = input.items.map((item): ThreadListV2ListItem => ({type: "v2-thread",key: `v2-thread:${item.thread.environmentId}:${item.thread.id}`,item,+ snoozeWakeLabelText:+ item.snoozed && item.thread.snoozedUntil != null && input.snoozeLabelNow !== undefined+ ? snoozeWakeLabel(item.thread.snoozedUntil, { now: input.snoozeLabelNow })+ : undefined,}),);- if (input.pendingTasks.length === 0) return threadItems;-const pendingItems = input.pendingTasks.map((pendingTask, index): ThreadListV2ListItem => ({type: "v2-pending",@@ -160,8 +260,23 @@ export function buildThreadListV2ListItems(input: {showPendingDivider: index === 0,}),);- // The settled tail begins at the row that draws the SETTLED divider; with- // no settled rows the queued block simply ends the list.+ const snoozedCount = input.snoozedCount ?? 0;+ const snoozedShelfHeaderIndex = input.snoozedShelfHeaderIndex ?? null;+ if (snoozedShelfHeaderIndex !== null && snoozedCount > 0) {+ return [+ ...threadItems.slice(0, snoozedShelfHeaderIndex),+ ...pendingItems,+ {+ type: "v2-snoozed-shelf",+ key: "v2-snoozed-shelf",+ count: snoozedCount,+ expanded: input.snoozedShelfExpanded === true,+ },+ ...threadItems.slice(snoozedShelfHeaderIndex),+ ];+ }+ if (pendingItems.length === 0) return threadItems;+const settledStart = threadItems.findIndex((entry) => entry.type === "v2-thread" && entry.item.showSettledDivider,);@@ -204,6 +319,11 @@ export function buildThreadListV2Items(input: {second-precise, so classifying with the floored minute would hold awoken thread hidden for up to a minute. Defaults to `now`. */readonly snoozeNow?: string;+ /** Expands the snoozed shelf into rows. Collapsed is the default. */+ readonly snoozedShelfExpanded?: boolean;+ /** The selected thread remains visible on an otherwise collapsed shelf so+ a split-view detail can never lose its navigation row. */+ readonly selectedThreadKey?: string | null;}): ThreadListV2Layout {const now = input.now ?? new Date().toISOString();const snoozeNow = input.snoozeNow ?? now;@@ -215,7 +335,7 @@ export function buildThreadListV2Items(input: {const active: EnvironmentThreadShell[] = [];const settled: EnvironmentThreadShell[] = [];- let snoozedCount = 0;+ const snoozed: EnvironmentThreadShell[] = [];let nextSnoozeWakeAt: string | null = null;for (const thread of input.threads) {// Callers pass live (unarchived) shells; settled threads are among them@@ -244,7 +364,7 @@ export function buildThreadListV2Items(input: {// wakes (or raises its hand — effectiveSnoozed refuses blocked/failed// work). Snooze outranks settled classification, same as web.if (supportsSnooze && effectiveSnoozed(thread, { now: snoozeNow })) {- snoozedCount += 1;+ snoozed.push(thread);if (thread.snoozedUntil != null &&(nextSnoozeWakeAt === null ||@@ -265,6 +385,17 @@ export function buildThreadListV2Items(input: {}const orderedActive = sortThreadsForListV2(active);+ const orderedSnoozed = [...snoozed].sort(+ (left, right) =>+ parseTimestampMs(left.snoozedUntil ?? "") - parseTimestampMs(right.snoozedUntil ?? ""),+ );+ const selectedThreadKey = input.selectedThreadKey ?? null;+ const visibleSnoozed =+ input.snoozedShelfExpanded === true+ ? orderedSnoozed+ : orderedSnoozed.filter(+ (thread) => `${thread.environmentId}:${thread.id}` === selectedThreadKey,+ );const orderedSettled = [...settled].sort((left, right) =>firstValidTimestampMs(right.latestUserMessageAt, right.updatedAt) -@@ -276,13 +407,30 @@ export function buildThreadListV2Items(input: {const items: ThreadListV2Item[] = [];for (const thread of orderedActive) {- items.push({ thread, variant: "card", showSettledDivider: false, isLast: false });+ items.push({+ thread,+ variant: "card",+ showSettledDivider: false,+ snoozed: false,+ isLast: false,+ });+ }+ const snoozedShelfHeaderIndex = orderedSnoozed.length > 0 ? items.length : null;+ for (const thread of visibleSnoozed) {+ items.push({+ thread,+ variant: "slim",+ showSettledDivider: false,+ snoozed: true,+ isLast: false,+ });}for (const [index, thread] of visibleSettled.entries()) {items.push({thread,variant: "slim",showSettledDivider: index === 0,+ snoozed: false,isLast: false,});}@@ -293,7 +441,8 @@ export function buildThreadListV2Items(input: {return {items,hiddenSettledCount: orderedSettled.length - visibleSettled.length,- snoozedCount,+ snoozedCount: orderedSnoozed.length,+ snoozedShelfHeaderIndex,nextSnoozeWakeAt,};}diff --git a/apps/web/src/components/Sidebar.snooze.test.ts b/apps/web/src/components/Sidebar.snooze.test.tsindex 4a4518a25..88c1d9ea5 100644--- a/apps/web/src/components/Sidebar.snooze.test.ts+++ b/apps/web/src/components/Sidebar.snooze.test.ts@@ -1,6 +1,6 @@import { describe, expect, it } from "vite-plus/test";-import { resolveSnoozePresets, snoozeWakeDescription, snoozeWakeLabel } from "./Sidebar.snooze";+import { resolveSnoozePresets, snoozeWakeDescription } from "./Sidebar.snooze";// Local-time constructor so preset math is timezone-stable in tests.function localDate(year: number, month: number, day: number, hour: number, minute = 0): Date {@@ -64,21 +64,6 @@ describe("resolveSnoozePresets", () => {});});-describe("snoozeWakeLabel", () => {- const now = localDate(2026, 4, 8, 10);-- it("formats minutes, hours, and days, rounding up", () => {- expect(snoozeWakeLabel(new Date(now.getTime() + 30 * 60_000).toISOString(), now)).toBe("30m");- expect(snoozeWakeLabel(new Date(now.getTime() + 90 * 60_000).toISOString(), now)).toBe("2h");- expect(snoozeWakeLabel(new Date(now.getTime() + 26 * 3_600_000).toISOString(), now)).toBe("2d");- });-- it("reports now for past and malformed wake times", () => {- expect(snoozeWakeLabel(new Date(now.getTime() - 1000).toISOString(), now)).toBe("now");- expect(snoozeWakeLabel("not-a-date", now)).toBe("now");- });-});-describe("snoozeWakeDescription", () => {const now = localDate(2026, 4, 8, 10);diff --git a/apps/web/src/components/Sidebar.snooze.ts b/apps/web/src/components/Sidebar.snooze.tsindex dd56cec72..adbc361a8 100644--- a/apps/web/src/components/Sidebar.snooze.ts+++ b/apps/web/src/components/Sidebar.snooze.ts@@ -1,111 +1,13 @@-/**- * Snooze preset resolution for the sidebar snooze menu. Pure functions so- * the preset math (evening/tomorrow/next-week boundaries) is unit-testable- * without a DOM.- *- * Presets deliberately skew short: agent-thread rhythms are hours (a CI- * run, a teammate review, the next work session), not days.- */+import { snoozeWakeLabel } from "@t3tools/client-runtime/state/thread-settled";import { parseTimestampDate } from "../timestampFormat";-type SnoozePresetId = "hour" | "evening" | "tomorrow" | "next-week";--export interface SnoozePreset {- readonly id: SnoozePresetId;- readonly label: string;- /** Menu-row time column. Complements the label instead of repeating it:- "Tomorrow" pairs with "9:00 AM", not "tomorrow 9:00 AM". */- readonly whenLabel: string;- /** ISO wake time. */- readonly snoozedUntil: string;-}--function timeOfDayLabel(date: Date): string {- return date.toLocaleTimeString(undefined, { hour: "numeric", minute: "2-digit" });-}--const EVENING_HOUR = 18;-const MORNING_HOUR = 9;-const HOUR_MS = 60 * 60 * 1_000;-const DAY_MS = 24 * HOUR_MS;--function atHour(base: Date, hour: number): Date {- const next = new Date(base);- next.setHours(hour, 0, 0, 0);- return next;-}--// Calendar-day advance instead of adding DAY_MS: fixed millisecond offsets-// land on the wrong local day across DST transitions (a spring-forward day-// is 23 hours, so 23:30 + 24h skips the whole next day).-function addDays(base: Date, days: number): Date {- const next = new Date(base);- next.setDate(next.getDate() + days);- return next;-}+export {+ resolveSnoozePresets,+ type SnoozePreset,+} from "@t3tools/client-runtime/state/thread-settled";+export { snoozeWakeLabel };-/**- * Presets for "snooze until", computed against local time. "This evening"- * only appears while it is still meaningfully before evening; after that- * the list starts at "Tomorrow".- */-export function resolveSnoozePresets(now: Date): ReadonlyArray<SnoozePreset> {- const inAnHour = new Date(now.getTime() + HOUR_MS);- const presets: SnoozePreset[] = [- {- id: "hour",- label: "In 1 hour",- whenLabel: timeOfDayLabel(inAnHour),- snoozedUntil: inAnHour.toISOString(),- },- ];-- const evening = atHour(now, EVENING_HOUR);- // Suppress the evening preset once it is within an hour (or past): it- // would duplicate "In 1 hour" or point at the past.- if (evening.getTime() - now.getTime() > HOUR_MS) {- presets.push({- id: "evening",- label: "This evening",- whenLabel: timeOfDayLabel(evening),- snoozedUntil: evening.toISOString(),- });- }-- const tomorrow = atHour(addDays(now, 1), MORNING_HOUR);- presets.push({- id: "tomorrow",- label: "Tomorrow",- whenLabel: timeOfDayLabel(tomorrow),- snoozedUntil: tomorrow.toISOString(),- });-- // Next Monday 9:00 (a week out when today is Monday).- const daysUntilMonday = (1 - now.getDay() + 7) % 7 || 7;- const nextWeek = atHour(addDays(now, daysUntilMonday), MORNING_HOUR);- presets.push({- id: "next-week",- label: "Next week",- whenLabel: `${nextWeek.toLocaleDateString(undefined, { weekday: "short" })} ${timeOfDayLabel(nextWeek)}`,- snoozedUntil: nextWeek.toISOString(),- });-- return presets;-}--/**- * Compact "wakes in" label for snoozed rows: "2h", "18h", "3d". Minutes- * round up so a snooze never reads "0m" while still hidden.- */-export function snoozeWakeLabel(snoozedUntil: string, now: Date): string {- const wake = parseTimestampDate(snoozedUntil);- if (wake === null) return "now";- const remainingMs = wake.getTime() - now.getTime();- if (remainingMs <= 0) return "now";- if (remainingMs < HOUR_MS) return `${Math.max(1, Math.ceil(remainingMs / 60_000))}m`;- if (remainingMs < DAY_MS) return `${Math.ceil(remainingMs / HOUR_MS)}h`;- return `${Math.ceil(remainingMs / DAY_MS)}d`;-}+const DAY_MS = 24 * 60 * 60 * 1_000;/*** Human wake time for menus and toasts: "tomorrow 9:00", "Mon 9:00",diff --git a/apps/web/src/components/SidebarV2.tsx b/apps/web/src/components/SidebarV2.tsxindex d58d2b37c..e36a44070 100644--- a/apps/web/src/components/SidebarV2.tsx+++ b/apps/web/src/components/SidebarV2.tsx@@ -2611,7 +2611,9 @@ export default function SidebarV2() {}snoozeWakeLabelText={section === "snoozed" && thread.snoozedUntil != null- ? snoozeWakeLabel(thread.snoozedUntil, new Date())+ ? snoozeWakeLabel(thread.snoozedUntil, {+ now: new Date().toISOString(),+ }): null}// All sections: a woken thread can classify straightdiff --git a/packages/client-runtime/src/state/threadSettled.ts b/packages/client-runtime/src/state/threadSettled.tsindex 3a98b9d2f..51a823396 100644--- a/packages/client-runtime/src/state/threadSettled.ts+++ b/packages/client-runtime/src/state/threadSettled.ts@@ -1,3 +1,4 @@+// @effect-diagnostics globalDate:off -- UI snooze presets use local calendar boundaries and Intl labels.import type { OrchestrationThreadShell } from "@t3tools/contracts";export type ChangeRequestStateLike = "open" | "closed" | "merged";@@ -272,3 +273,100 @@ export function effectiveSettled(Date.parse(lastActivityAt) < Date.parse(options.now) - options.autoSettleAfterDays * DAY_MS);}++const HOUR_MS = 60 * 60 * 1_000;+const EVENING_HOUR = 18;+const MORNING_HOUR = 9;++export type SnoozePresetId = "hour" | "evening" | "tomorrow" | "next-week";++export interface SnoozePreset {+ readonly id: SnoozePresetId;+ readonly label: string;+ /** Menu-row time column. Complements the label instead of repeating it:+ "Tomorrow" pairs with "9:00 AM", not "tomorrow 9:00 AM". */+ readonly whenLabel: string;+ /** ISO wake time. */+ readonly snoozedUntil: string;+}++function snoozeTimeOfDayLabel(date: Date): string {+ return date.toLocaleTimeString(undefined, { hour: "numeric", minute: "2-digit" });+}++function snoozeAtHour(base: Date, hour: number): Date {+ const next = new Date(base);+ next.setHours(hour, 0, 0, 0);+ return next;+}++// Calendar-day advance instead of adding DAY_MS: fixed millisecond offsets+// land on the wrong local day across DST transitions (a spring-forward day+// is 23 hours, so 23:30 + 24h skips the whole next day).+function addSnoozeDays(base: Date, days: number): Date {+ const next = new Date(base);+ next.setDate(next.getDate() + days);+ return next;+}++/**+ * Shared "snooze until" choices for every client. "This evening" only+ * appears while it is meaningfully before evening; after that the list+ * starts at "Tomorrow".+ */+export function resolveSnoozePresets(now: Date): ReadonlyArray<SnoozePreset> {+ const inAnHour = new Date(now.getTime() + HOUR_MS);+ const presets: SnoozePreset[] = [+ {+ id: "hour",+ label: "In 1 hour",+ whenLabel: snoozeTimeOfDayLabel(inAnHour),+ snoozedUntil: inAnHour.toISOString(),+ },+ ];++ const evening = snoozeAtHour(now, EVENING_HOUR);+ if (evening.getTime() - now.getTime() > HOUR_MS) {+ presets.push({+ id: "evening",+ label: "This evening",+ whenLabel: snoozeTimeOfDayLabel(evening),+ snoozedUntil: evening.toISOString(),+ });+ }++ const tomorrow = snoozeAtHour(addSnoozeDays(now, 1), MORNING_HOUR);+ presets.push({+ id: "tomorrow",+ label: "Tomorrow",+ whenLabel: snoozeTimeOfDayLabel(tomorrow),+ snoozedUntil: tomorrow.toISOString(),+ });++ const daysUntilMonday = (1 - now.getDay() + 7) % 7 || 7;+ const nextWeek = snoozeAtHour(addSnoozeDays(now, daysUntilMonday), MORNING_HOUR);+ presets.push({+ id: "next-week",+ label: "Next week",+ whenLabel: `${nextWeek.toLocaleDateString(undefined, { weekday: "short" })} ${snoozeTimeOfDayLabel(nextWeek)}`,+ snoozedUntil: nextWeek.toISOString(),+ });++ return presets;+}++/**+ * Compact "wakes in" label for snoozed rows: "2h", "18h", "3d". Minutes+ * round up so a snooze never reads "0m" while still hidden. Shared by web+ * and mobile so the same wake time never reads differently per client.+ */+export function snoozeWakeLabel(snoozedUntil: string, options: { readonly now: string }): string {+ const wakeMs = Date.parse(snoozedUntil);+ const nowMs = Date.parse(options.now);+ if (Number.isNaN(wakeMs) || Number.isNaN(nowMs)) return "now";+ const remainingMs = wakeMs - nowMs;+ if (remainingMs <= 0) return "now";+ if (remainingMs < HOUR_MS) return `${Math.max(1, Math.ceil(remainingMs / 60_000))}m`;+ if (remainingMs < DAY_MS) return `${Math.ceil(remainingMs / HOUR_MS)}h`;+ return `${Math.ceil(remainingMs / DAY_MS)}d`;+}diff --git a/packages/client-runtime/src/state/threadSnoozed.test.ts b/packages/client-runtime/src/state/threadSnoozed.test.tsindex c26d23e26..2c1c58d37 100644--- a/packages/client-runtime/src/state/threadSnoozed.test.ts+++ b/packages/client-runtime/src/state/threadSnoozed.test.ts@@ -1,3 +1,4 @@+// @effect-diagnostics globalDate:off -- Tests exercise local calendar snooze boundaries.import { ThreadId } from "@t3tools/contracts";import { TurnId } from "@t3tools/contracts";import { describe, expect, it } from "vite-plus/test";@@ -5,6 +6,8 @@ import { describe, expect, it } from "vite-plus/test";import {canSnooze,effectiveSnoozed,+ resolveSnoozePresets,+ snoozeWakeLabel,threadRaisedHandWhileSnoozed,threadWokeAt,type ThreadSnoozeShell,@@ -15,6 +18,10 @@ const SNOOZED_AT = "2026-04-10T09:00:00.000Z";const FUTURE_WAKE = "2026-04-11T09:00:00.000Z";const PAST_WAKE = "2026-04-10T10:00:00.000Z";+function localDate(year: number, month: number, day: number, hour: number, minute = 0): Date {+ return new Date(year, month - 1, day, hour, minute, 0, 0);+}+function makeShell(input: {readonly snoozedUntil?: string | null;readonly snoozedAt?: string | null;@@ -235,3 +242,53 @@ describe("threadWokeAt", () => {).toBe("2026-04-10T09:30:00.000Z");});});++describe("snoozeWakeLabel", () => {+ const now = "2026-06-02T00:00:00.000Z";++ it("formats remaining time coarsely, rounding up", () => {+ expect(snoozeWakeLabel("2026-06-02T00:30:00.000Z", { now })).toBe("30m");+ expect(snoozeWakeLabel("2026-06-02T01:30:00.000Z", { now })).toBe("2h");+ expect(snoozeWakeLabel("2026-06-03T02:00:00.000Z", { now })).toBe("2d");+ });++ it("never reads zero or negative while still snoozed", () => {+ expect(snoozeWakeLabel("2026-06-02T00:00:30.000Z", { now })).toBe("1m");+ expect(snoozeWakeLabel("2026-06-01T23:59:59.000Z", { now })).toBe("now");+ expect(snoozeWakeLabel("not-a-date", { now })).toBe("now");+ expect(snoozeWakeLabel("2026-06-02T09:00:00.000Z", { now: "bad" })).toBe("now");+ });+});++describe("resolveSnoozePresets", () => {+ it("offers the shared desktop and mobile choices", () => {+ const presets = resolveSnoozePresets(localDate(2026, 4, 8, 10));+ expect(presets.map((preset) => preset.id)).toEqual([+ "hour",+ "evening",+ "tomorrow",+ "next-week",+ ]);+ expect(presets.find((preset) => preset.id === "evening")?.label).toBe("This evening");+ expect(+ new Date(presets.find((preset) => preset.id === "tomorrow")!.snoozedUntil).getHours(),+ ).toBe(9);+ });++ it("drops the evening choice once evening is near or past", () => {+ expect(resolveSnoozePresets(localDate(2026, 4, 8, 17, 30)).map((preset) => preset.id)).toEqual([+ "hour",+ "tomorrow",+ "next-week",+ ]);+ });++ it("puts next week on the following Monday", () => {+ const nextWeek = new Date(+ resolveSnoozePresets(localDate(2026, 4, 6, 10)).find((preset) => preset.id === "next-week")!+ .snoozedUntil,+ );+ expect(nextWeek.getDay()).toBe(1);+ expect(nextWeek.getDate()).toBe(13);+ });+});