@@ -12,12 +12,19 @@ import { RowPressable } from "../../components/ui/RowPressable";
1212import { CustomSnoozeSheet } from "./CustomSnoozeSheet" ;
1313import { appAtomRegistry } from "../../state/atom-registry" ;
1414import { threadArrangementOpenAtom } from "../../state/thread-order" ;
15+ import { threadEnvironment } from "../../state/threads" ;
16+ import { useAtomCommand } from "../../state/use-atom-command" ;
17+ import { useVisibleSecondClock } from "./use-visible-second-clock" ;
1518import type { ThreadMoveDestination } from "./threadOrder" ;
1619import type {
1720 EnvironmentProject ,
1821 EnvironmentThreadShell ,
1922} from "@t3tools/client-runtime/state/shell" ;
2023import type { EnvironmentThreadSearchMatch } from "@t3tools/client-runtime/state/thread-search" ;
24+ import {
25+ formatWorkingDurationLabel ,
26+ resolveThreadWorkingStartedAt ,
27+ } from "@t3tools/client-runtime/state/models" ;
2128import { AuthOrchestrationOperateScope , type EnvironmentMachineKind } from "@t3tools/contracts" ;
2229import { canSnooze , resolveSnoozePresets } from "@t3tools/client-runtime/state/thread-settled" ;
2330import type { MenuAction } from "@react-native-menu/menu" ;
@@ -112,6 +119,13 @@ const DONE_STATUS_LABEL: StatusLabel = {
112119 iconTintClassName : "accent-adaptive-emerald-700-300" ,
113120} ;
114121
122+ function ThreadListV2Duration ( props : { readonly startedAt : string | null } ) {
123+ const startedAtMs = Date . parse ( props . startedAt ?? "" ) ;
124+ const nowMs = useVisibleSecondClock ( Number . isFinite ( startedAtMs ) ) ;
125+ if ( ! Number . isFinite ( startedAtMs ) ) return null ;
126+ return ` ${ formatWorkingDurationLabel ( nowMs - startedAtMs ) } ` ;
127+ }
128+
115129const CARD_MENU_ACTIONS : MenuAction [ ] = [
116130 { id : "settle" , title : "Settle" , image : "checkmark" } ,
117131 { id : "delete" , title : "Delete" , image : "trash" , attributes : { destructive : true } } ,
@@ -477,6 +491,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
477491 readonly hasQueuedMessages ?: boolean ;
478492 readonly snoozed ?: boolean ;
479493 readonly pinned ?: boolean ;
494+ readonly wokeAt : string | null ;
480495 readonly snoozeWakeLabelText ?: string ;
481496 readonly timeLabel : string ;
482497 readonly snoozePresetMinute : string ;
@@ -568,12 +583,6 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
568583 const handleOpenPullRequests = useCallback ( ( ) => {
569584 if ( pr ) onOpenThreadPullRequests ( thread , pr ) ;
570585 } , [ onOpenThreadPullRequests , pr , thread ] ) ;
571- // VoiceOver cannot focus the badge inside the accessible row, so the row
572- // exposes the same action.
573- const rowAccessibilityActions = useMemo (
574- ( ) => ( prBadgeLabel ? [ { name : "openPullRequests" , label : prBadgeLabel } ] : undefined ) ,
575- [ prBadgeLabel ] ,
576- ) ;
577586
578587 const theme = useUniwindTheme ( ) ;
579588 const sidebarPane = props . pane === "sidebar" ;
@@ -583,13 +592,31 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
583592 const status = resolveThreadListV2Status ( thread ) ;
584593 const isUnread = status === "ready" && threadHasUnseenCompletion ( thread ) ;
585594 const workingLabel = STATUS_LABEL_BY_STATUS [ status ] ;
595+ const showsWoke = status === "ready" && props . wokeAt !== null ;
586596 const statusLabel =
587597 ( status === "working" && workingLabel !== undefined && thread . goal ?. status === "active"
588598 ? { ...workingLabel , label : "Goal" }
589599 : workingLabel ) ?? ( isUnread ? DONE_STATUS_LABEL : undefined ) ;
590600 const recede = shouldRecedeThreadRow ( { status, selected } ) ;
591601 const timeLabel = props . timeLabel ;
592602
603+ const visitThread = useAtomCommand ( threadEnvironment . visit , { reportFailure : false } ) ;
604+ const handleAcknowledgeWoke = useCallback ( ( ) => {
605+ if ( props . wokeAt === null ) return ;
606+ void visitThread ( {
607+ environmentId : thread . environmentId ,
608+ input : { threadId : thread . id , visitedAt : props . wokeAt } ,
609+ } ) ;
610+ } , [ props . wokeAt , thread . environmentId , thread . id , visitThread ] ) ;
611+ // VoiceOver cannot focus buttons inside the accessible row.
612+ const rowAccessibilityActions = useMemo (
613+ ( ) => [
614+ ...( prBadgeLabel ? [ { name : "openPullRequests" , label : prBadgeLabel } ] : [ ] ) ,
615+ ...( showsWoke ? [ { name : "dismissWoke" , label : "Dismiss Woke notification" } ] : [ ] ) ,
616+ ] ,
617+ [ prBadgeLabel , showsWoke ] ,
618+ ) ;
619+
593620 const handleDelete = useCallback ( ( ) => onDeleteThread ( thread ) , [ onDeleteThread , thread ] ) ;
594621 const handleRename = useCallback ( ( ) => onRenameThread ( thread ) , [ onRenameThread , thread ] ) ;
595622 const canOperateThread = useEnvironmentScope ( thread . environmentId , AuthOrchestrationOperateScope ) ;
@@ -948,7 +975,34 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
948975 type = "monochrome"
949976 />
950977 ) : null }
951- { statusLabel ? (
978+ { showsWoke ? (
979+ < Pressable
980+ className = "-m-2.5 flex-row items-center gap-1 p-2.5"
981+ accessibilityRole = "button"
982+ accessibilityLabel = "Dismiss Woke notification"
983+ onPress = { handleAcknowledgeWoke }
984+ onLongPress = { ( ) => undefined }
985+ style = { ( { pressed } ) => ( { opacity : pressed ? 0.6 : 1 } ) }
986+ >
987+ < SymbolView
988+ name = "bell.badge"
989+ size = { 13 }
990+ tintColorClassName = {
991+ selected ? selectedThreadRowColors . iconTintClassName : "accent-warning-foreground"
992+ }
993+ type = "monochrome"
994+ weight = "semibold"
995+ />
996+ < Text
997+ className = { cn (
998+ "text-xs font-t3-bold" ,
999+ selected ? selectedThreadRowColors . foregroundClassName : "text-warning-foreground" ,
1000+ ) }
1001+ >
1002+ Woke
1003+ </ Text >
1004+ </ Pressable >
1005+ ) : statusLabel ? (
9521006 < View className = "flex-row items-center gap-1" >
9531007 < SymbolView
9541008 name = { statusLabel . icon }
@@ -962,10 +1016,16 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
9621016 < Text
9631017 className = { cn (
9641018 "text-xs font-t3-bold" ,
1019+ ( status === "working" || status === "waiting" ) && "tabular-nums" ,
9651020 selected ? selectedThreadRowColors . foregroundClassName : statusLabel . className ,
9661021 ) }
9671022 >
9681023 { statusLabel . label }
1024+ { status === "working" ? (
1025+ < ThreadListV2Duration startedAt = { resolveThreadWorkingStartedAt ( thread ) } />
1026+ ) : status === "waiting" ? (
1027+ < ThreadListV2Duration startedAt = { thread . latestRun ?. completedAt ?? null } />
1028+ ) : null }
9691029 </ Text >
9701030 </ View >
9711031 ) : (
@@ -1156,6 +1216,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
11561216 accessibilityActions = { rowAccessibilityActions }
11571217 onAccessibilityAction = { ( event ) => {
11581218 if ( event . nativeEvent . actionName === "openPullRequests" ) handleOpenPullRequests ( ) ;
1219+ if ( event . nativeEvent . actionName === "dismissWoke" ) handleAcknowledgeWoke ( ) ;
11591220 } }
11601221 onPress = { ( ) => {
11611222 close ( ) ;
0 commit comments