@devries-cameron20 / t3code Mirror · read-only / commits / 2085ea32cc
Fork 0

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

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

Synced Nov 22, 20:45 UTC

fix(mobile): thread rows show wake status and elapsed time (#21394)

maria committed Oct 21, 2026 at 00:42 UTC 2085ea32cc72882cfef3db1f73b2c8381e8065b6
10 files changed +231 -20
apps/mobile/src/features/home/HomeScreen.tsx
+1
@@ -636,6 +636,7 @@ export function HomeScreen(props: HomeScreenProps) {
636 hasQueuedMessages={item.hasQueuedMessages}
637 snoozed={item.item.snoozed}
638 pinned={item.item.pinned}
639 + wokeAt={item.item.wokeAt}
640 snoozePresetMinute={item.snoozePresetMinute ?? ""}
641 snoozeWakeLabelText={item.snoozeWakeLabelText}
642 timeLabel={item.timeLabel}
apps/mobile/src/features/threads/ThreadDetailScreen.tsx
+28 -2
@@ -357,7 +357,25 @@ function ThreadVisitWatermark(props: {
357 const lastDispatchedVisitRef = useRef<string | null>(null);
358 const lastVisitDispatchRef = useRef({ threadKey: selectedThreadKey, at: 0 });
359 const selectedThreadId = thread.id;
360 - const selectedThreadUpdatedAt = thread.updatedAt;
360 + const snoozedUntil = thread.snoozedUntil;
361 + // Keep the clock in state so React Compiler invalidates the wake calculation.
362 + const [wakeNow, setWakeNow] = useState(() => new Date().toISOString());
363 + useEffect(() => {
364 + if (!showContent || snoozedUntil == null) return;
365 + const delay = Date.parse(snoozedUntil) - Date.now();
366 + if (!Number.isFinite(delay)) return;
367 + const timer = setTimeout(() => setWakeNow(new Date().toISOString()), Math.max(0, delay) + 50);
368 + return () => clearTimeout(timer);
369 + }, [showContent, snoozedUntil]);
370 + const selectedThreadWokeAt = threadWokeAt(thread, {
371 + now: wakeNow,
372 + });
373 + // A scheduled wake can happen without a newer server update.
374 + const selectedThreadUpdatedAt =
375 + selectedThreadWokeAt !== null && Date.parse(selectedThreadWokeAt) > Date.parse(thread.updatedAt)
376 + ? selectedThreadWokeAt
377 + : thread.updatedAt;
378 + const wakeIsLatestUpdate = selectedThreadUpdatedAt === selectedThreadWokeAt;
379 const selectedThreadLastVisitedAt = thread.lastVisitedAt;
380 const selectedThreadCompletedAt = thread.latestRun?.completedAt;
381 useEffect(() => {
@@ -384,7 +402,14 @@ function ThreadVisitWatermark(props: {
402 (Number.isNaN(lastVisitedAtMs) || completedAtMs > lastVisitedAtMs);
403 const previous = lastVisitDispatchRef.current;
404 const elapsed = Date.now() - previous.at;
387 - if (previous.threadKey !== selectedThreadKey || hasUnseenCompletion || elapsed >= 10_000) {
405 + // Like a completion, a wake the user is looking at must not wait out the throttle:
406 + // leaving within it would cancel the dispatch and keep Woke in the list.
407 + if (
408 + previous.threadKey !== selectedThreadKey ||
409 + hasUnseenCompletion ||
410 + wakeIsLatestUpdate ||
411 + elapsed >= 10_000
412 + ) {
413 dispatch();
414 return;
415 }
@@ -399,6 +424,7 @@ function ThreadVisitWatermark(props: {
424 selectedThreadUpdatedAt,
425 showContent,
426 visitThread,
427 + wakeIsLatestUpdate,
428 ]);
429 return null;
430 }
apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
+1
@@ -599,6 +599,7 @@ function ThreadNavigationSidebarPane(
599 hasQueuedMessages={item.hasQueuedMessages}
600 snoozed={item.item.snoozed}
601 pinned={item.item.pinned}
602 + wokeAt={item.item.wokeAt}
603 snoozePresetMinute={item.snoozePresetMinute ?? ""}
604 snoozeWakeLabelText={item.snoozeWakeLabelText}
605 timeLabel={item.timeLabel}
apps/mobile/src/features/threads/thread-list-v2-items.tsx
+68 -7
@@ -12,12 +12,19 @@ import { RowPressable } from "../../components/ui/RowPressable";
12 import { CustomSnoozeSheet } from "./CustomSnoozeSheet";
13 import { appAtomRegistry } from "../../state/atom-registry";
14 import { 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";
18 import type { ThreadMoveDestination } from "./threadOrder";
19 import type {
20 EnvironmentProject,
21 EnvironmentThreadShell,
22 } from "@t3tools/client-runtime/state/shell";
23 import type { EnvironmentThreadSearchMatch } from "@t3tools/client-runtime/state/thread-search";
24 +import {
25 + formatWorkingDurationLabel,
26 + resolveThreadWorkingStartedAt,
27 +} from "@t3tools/client-runtime/state/models";
28 import { AuthOrchestrationOperateScope, type EnvironmentMachineKind } from "@t3tools/contracts";
29 import { canSnooze, resolveSnoozePresets } from "@t3tools/client-runtime/state/thread-settled";
30 import type { MenuAction } from "@react-native-menu/menu";
@@ -112,6 +119,13 @@ const DONE_STATUS_LABEL: StatusLabel = {
119 iconTintClassName: "accent-adaptive-emerald-700-300",
120 };
121
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 +
129 const CARD_MENU_ACTIONS: MenuAction[] = [
130 { id: "settle", title: "Settle", image: "checkmark" },
131 { id: "delete", title: "Delete", image: "trash", attributes: { destructive: true } },
@@ -477,6 +491,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
491 readonly hasQueuedMessages?: boolean;
492 readonly snoozed?: boolean;
493 readonly pinned?: boolean;
494 + readonly wokeAt: string | null;
495 readonly snoozeWakeLabelText?: string;
496 readonly timeLabel: string;
497 readonly snoozePresetMinute: string;
@@ -568,12 +583,6 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
583 const handleOpenPullRequests = useCallback(() => {
584 if (pr) onOpenThreadPullRequests(thread, pr);
585 }, [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 - );
586
587 const theme = useUniwindTheme();
588 const sidebarPane = props.pane === "sidebar";
@@ -583,6 +592,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
592 const status = resolveThreadListV2Status(thread);
593 const isUnread = status === "ready" && threadHasUnseenCompletion(thread);
594 const workingLabel = STATUS_LABEL_BY_STATUS[status];
595 + const showsWoke = status === "ready" && props.wokeAt !== null;
596 const statusLabel =
597 (status === "working" && workingLabel !== undefined && thread.goal?.status === "active"
598 ? { ...workingLabel, label: "Goal" }
@@ -590,6 +600,23 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
600 const recede = shouldRecedeThreadRow({ status, selected });
601 const timeLabel = props.timeLabel;
602
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 +
620 const handleDelete = useCallback(() => onDeleteThread(thread), [onDeleteThread, thread]);
621 const handleRename = useCallback(() => onRenameThread(thread), [onRenameThread, thread]);
622 const canOperateThread = useEnvironmentScope(thread.environmentId, AuthOrchestrationOperateScope);
@@ -948,7 +975,34 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
975 type="monochrome"
976 />
977 ) : 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 ? (
1006 <View className="flex-row items-center gap-1">
1007 <SymbolView
1008 name={statusLabel.icon}
@@ -962,10 +1016,16 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
1016 <Text
1017 className={cn(
1018 "text-xs font-t3-bold",
1019 + (status === "working" || status === "waiting") && "tabular-nums",
1020 selected ? selectedThreadRowColors.foregroundClassName : statusLabel.className,
1021 )}
1022 >
1023 {statusLabel.label}
1024 + {status === "working" ? (
1025 + <ThreadListV2Duration startedAt={resolveThreadWorkingStartedAt(thread)} />
1026 + ) : status === "waiting" ? (
1027 + <ThreadListV2Duration startedAt={thread.latestRun?.completedAt ?? null} />
1028 + ) : null}
1029 </Text>
1030 </View>
1031 ) : (
@@ -1156,6 +1216,7 @@ export const ThreadListV2Row = memo(function ThreadListV2Row(props: {
1216 accessibilityActions={rowAccessibilityActions}
1217 onAccessibilityAction={(event) => {
1218 if (event.nativeEvent.actionName === "openPullRequests") handleOpenPullRequests();
1219 + if (event.nativeEvent.actionName === "dismissWoke") handleAcknowledgeWoke();
1220 }}
1221 onPress={() => {
1222 close();
apps/mobile/src/features/threads/threadListV2.test.ts
+95
@@ -35,6 +35,7 @@ import {
35 getThreadListV2OrderedSection,
36 resolveThreadListV2SnoozeMenuSelection,
37 resolveThreadListV2Status,
38 + resolveThreadListV2WokeAt,
39 resolveThreadListV2SwipeActions,
40 sortThreadsForListV2,
41 threadListV2ListItemsAreEqual,
@@ -1426,6 +1427,100 @@ describe("threadListV2ListItemsAreEqual", () => {
1427 });
1428 });
1429
1430 +describe("thread list Woke marker", () => {
1431 + const wokeAt = isoAt(BASE_MS - MINUTE_MS);
1432 + const thread = makeThread({
1433 + id: ThreadId.make("woke"),
1434 + title: "Woke",
1435 + latestUserMessageAt: isoAt(BASE_MS - 90 * MINUTE_MS),
1436 + snoozedAt: isoAt(BASE_MS - 60 * MINUTE_MS),
1437 + snoozedUntil: wokeAt,
1438 + lastVisitedAt: null,
1439 + });
1440 +
1441 + it("keeps a timer wake through a plain visit until acknowledgement reaches its timestamp", () => {
1442 + expect(resolveThreadListV2WokeAt(thread, { now: NOW })).toBe(wokeAt);
1443 + expect(
1444 + resolveThreadListV2WokeAt(
1445 + { ...thread, lastVisitedAt: isoAt(BASE_MS - 30 * MINUTE_MS) },
1446 + { now: NOW },
1447 + ),
1448 + ).toBe(wokeAt);
1449 + expect(
1450 + resolveThreadListV2WokeAt({ ...thread, lastVisitedAt: wokeAt }, { now: NOW }),
1451 + ).toBeNull();
1452 + expect(resolveThreadListV2WokeAt({ ...thread, lastVisitedAt: "invalid" }, { now: NOW })).toBe(
1453 + wokeAt,
1454 + );
1455 + });
1456 +
1457 + it("stays hidden while snoozed, after settling, and on servers without visited tracking", () => {
1458 + expect(resolveThreadListV2WokeAt(thread, { now: isoAt(BASE_MS - 2 * MINUTE_MS) })).toBeNull();
1459 + expect(
1460 + resolveThreadListV2WokeAt({ ...thread, settledOverride: "settled" }, { now: NOW }),
1461 + ).toBeNull();
1462 + expect(
1463 + resolveThreadListV2WokeAt({ ...thread, lastVisitedAt: undefined }, { now: NOW }),
1464 + ).toBeNull();
1465 + expect(resolveThreadListV2WokeAt({ ...thread, snoozedUntil: null }, { now: NOW })).toBeNull();
1466 + });
1467 +
1468 + it("keeps an early failure wake acknowledged after the scheduled time passes", () => {
1469 + const completedAt = isoAt(BASE_MS - 2 * MINUTE_MS);
1470 + const failed = makeThread({
1471 + ...thread,
1472 + snoozedUntil: isoAt(BASE_MS + MINUTE_MS),
1473 + runtime: {
1474 + status: "failed",
1475 + activeRunId: null,
1476 + providerInstanceId: ProviderInstanceId.make("codex"),
1477 + providerName: "Codex",
1478 + lastError: "Run failed",
1479 + updatedAt: completedAt,
1480 + },
1481 + latestRun: {
1482 + runId: RunId.make("woke-run"),
1483 + status: "failed",
1484 + requestedAt: isoAt(BASE_MS - 3 * MINUTE_MS),
1485 + startedAt: isoAt(BASE_MS - 3 * MINUTE_MS),
1486 + completedAt,
1487 + assistantMessageId: null,
1488 + },
1489 + });
1490 + expect(resolveThreadListV2WokeAt(failed, { now: NOW })).toBe(completedAt);
1491 + expect(
1492 + resolveThreadListV2WokeAt(
1493 + { ...failed, lastVisitedAt: completedAt },
1494 + { now: isoAt(BASE_MS + 2 * MINUTE_MS) },
1495 + ),
1496 + ).toBeNull();
1497 + });
1498 +
1499 + it("updates a recycled row at the wake boundary even without a new shell or minute tick", () => {
1500 + const waking = { ...thread, snoozedUntil: isoAt(BASE_MS + 30_000) };
1501 + const layout = (now: string) =>
1502 + buildThreadListV2Items({
1503 + threads: [waking],
1504 + environmentId: null,
1505 + searchQuery: "",
1506 + now,
1507 + snoozeEnvironmentIds: new Set<EnvironmentId>(),
1508 + });
1509 + const list = (now: string) =>
1510 + buildThreadListV2ListItems({
1511 + items: layout(now).items,
1512 + pendingTasks: [],
1513 + snoozeLabelNow: isoAt(BASE_MS),
1514 + });
1515 + const before = list(NOW)[0]!;
1516 + const after = list(isoAt(BASE_MS + 37_500))[0]!;
1517 + expect(before.type === "v2-thread" && before.item.wokeAt).toBeNull();
1518 + expect(after.type === "v2-thread" && after.item.wokeAt).toBe(waking.snoozedUntil);
1519 + expect(after.type === "v2-thread" && after.timeLabel).toBe("");
1520 + expect(threadListV2ListItemsAreEqual(before, after)).toBe(false);
1521 + });
1522 +});
1523 +
1524 describe("buildThreadListV2ListItems row-state stamps", () => {
1525 const readyThread = makeThread({
1526 id: ThreadId.make("stamp-ready"),
apps/mobile/src/features/threads/threadListV2.ts
+25 -1
@@ -6,6 +6,7 @@ import {
6 QUEUED_TURN_START_GRACE_MS,
7 resolveSnoozePresets,
8 snoozeWakeLabel,
9 + threadWokeAt,
10 } from "@t3tools/client-runtime/state/thread-settled";
11 import type { SnoozePreset } from "@t3tools/client-runtime/state/thread-settled";
12 import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell";
@@ -151,6 +152,20 @@ export function threadHasUnseenCompletion(
152 return completedAtMs > lastVisitedAtMs;
153 }
154
155 +export function resolveThreadListV2WokeAt(
156 + thread: EnvironmentThreadShell,
157 + options: { readonly now: string },
158 +): string | null {
159 + // Older servers cannot persist an acknowledgement.
160 + if (thread.lastVisitedAt === undefined || thread.settledOverride === "settled") return null;
161 + const wokeAt = threadWokeAt(thread, options);
162 + const wokeAtMs = Date.parse(wokeAt ?? "");
163 + const lastVisitedAtMs = Date.parse(thread.lastVisitedAt ?? "");
164 + return !Number.isNaN(wokeAtMs) && (Number.isNaN(lastVisitedAtMs) || lastVisitedAtMs < wokeAtMs)
165 + ? wokeAt
166 + : null;
167 +}
168 +
169 export function resolveThreadListV2Status(
170 thread: Pick<
171 EnvironmentThreadShell,
@@ -246,6 +261,7 @@ export interface ThreadListV2Item {
261 readonly variant: "card" | "slim";
262 readonly snoozed: boolean;
263 readonly pinned: boolean;
264 + readonly wokeAt: string | null;
265 readonly isLast: boolean;
266 }
267
@@ -357,6 +373,7 @@ export function threadListV2ListItemsAreEqual(
373 previous.item.variant === item.item.variant &&
374 previous.item.snoozed === item.item.snoozed &&
375 previous.item.pinned === item.item.pinned &&
376 + previous.item.wokeAt === item.item.wokeAt &&
377 previous.snoozeWakeLabelText === item.snoozeWakeLabelText &&
378 previous.timeLabel === item.timeLabel &&
379 previous.snoozePresetMinute === item.snoozePresetMinute &&
@@ -405,7 +422,9 @@ function resolveThreadListV2ItemTimeLabel(
422 if (showSnoozeWakeLabel) return "";
423 if (
424 variant === "card" &&
408 - (resolveThreadListV2Status(thread) !== "ready" || threadHasUnseenCompletion(thread))
425 + (resolveThreadListV2Status(thread) !== "ready" ||
426 + item.wokeAt !== null ||
427 + threadHasUnseenCompletion(thread))
428 )
429 return "";
430 const settledTimestamp =
@@ -694,6 +713,7 @@ export function buildThreadListV2Items(input: {
713 variant: "card",
714 snoozed: false,
715 pinned: true,
716 + wokeAt: resolveThreadListV2WokeAt(thread, { now }),
717 isLast: false,
718 });
719 }
@@ -703,6 +723,7 @@ export function buildThreadListV2Items(input: {
723 variant: "card",
724 snoozed: false,
725 pinned: false,
726 + wokeAt: resolveThreadListV2WokeAt(thread, { now }),
727 isLast: false,
728 });
729 }
@@ -713,6 +734,7 @@ export function buildThreadListV2Items(input: {
734 variant: "card",
735 snoozed: false,
736 pinned: false,
737 + wokeAt: resolveThreadListV2WokeAt(thread, { now }),
738 isLast: false,
739 });
740 }
@@ -723,6 +745,7 @@ export function buildThreadListV2Items(input: {
745 variant: "slim",
746 snoozed: true,
747 pinned: false,
748 + wokeAt: null,
749 isLast: false,
750 });
751 }
@@ -733,6 +756,7 @@ export function buildThreadListV2Items(input: {
756 variant: "slim",
757 snoozed: false,
758 pinned: false,
759 + wokeAt: null,
760 isLast: false,
761 });
762 }
apps/web/src/components/Sidebar.logic.test.ts
+4 -1
@@ -1,4 +1,7 @@
1 -import { presentThreadShell } from "@t3tools/client-runtime/state/models";
1 +import {
2 + formatWorkingDurationLabel,
3 + presentThreadShell,
4 +} from "@t3tools/client-runtime/state/models";
5 import * as DateTime from "effect/DateTime";
6 import { deriveActiveWorkStartedAt } from "../session-logic.ts";
7 import { describe, expect, it, vi } from "vite-plus/test";
apps/web/src/components/Sidebar.logic.ts
-8
@@ -1058,14 +1058,6 @@ export function resolveWorkingStartedAt(
1058 return resolveThreadWorkingStartedAt(thread);
1059 }
1060
1061 -export function formatWorkingDurationLabel(elapsedMs: number): string {
1062 - const seconds = Number.isFinite(elapsedMs) ? Math.max(0, Math.floor(elapsedMs / 1000)) : 0;
1063 - if (seconds < 60) return `${seconds}s`;
1064 - const minutes = Math.floor(seconds / 60);
1065 - if (minutes < 60) return `${minutes}m`;
1066 - return `${Math.floor(minutes / 60)}h ${minutes % 60}m`;
1067 -}
1068 -
1061 export function resolveThreadStatusPill(input: {
1062 thread: ThreadStatusInput;
1063 }): ThreadStatusPill | null {
apps/web/src/components/Sidebar.tsx
+1 -1
@@ -48,6 +48,7 @@ import {
48 type EnvironmentThreadSearchMatch,
49 } from "@t3tools/client-runtime/state/thread-search";
50 import {
51 + formatWorkingDurationLabel,
52 resolveThreadProviderStack,
53 threadRuntimeCanArchive,
54 type EnvironmentThreadShell,
@@ -195,7 +196,6 @@ import {
196 buildBulkUnpinContextMenuItem,
197 deleteSelectedThreadEntries,
198 filterSidebarProjectScopeItems,
198 - formatWorkingDurationLabel,
199 firstValidTimestampMs,
200 hasUnseenCompletion,
201 isSidebarNestedLinkClick,
packages/client-runtime/src/state/models.ts
+8
@@ -333,3 +333,11 @@ export function resolveThreadWorkingStartedAt(input: {
333 }
334 return null;
335 }
336 +
337 +export function formatWorkingDurationLabel(elapsedMs: number): string {
338 + const seconds = Number.isFinite(elapsedMs) ? Math.max(0, Math.floor(elapsedMs / 1000)) : 0;
339 + if (seconds < 60) return `${seconds}s`;
340 + const minutes = Math.floor(seconds / 60);
341 + if (minutes < 60) return `${minutes}m`;
342 + return `${Math.floor(minutes / 60)}h ${minutes % 60}m`;
343 +}