Skip to content

Commit 31db544

Browse files
committed
fix(mobile): acknowledge scheduled wakes when visiting threads
1 parent 3277462 commit 31db544

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import type { WorktreeSetupCardProps } from "./worktree-setup-card";
99
import type { ComposerTextPaste } from "../../native/T3ComposerEditor.types";
1010
import { type EnvironmentConnectionPhase } from "@t3tools/client-runtime/connection";
1111
import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell";
12+
import { threadWokeAt } from "@t3tools/client-runtime/state/thread-settled";
1213
import type { HandoffEndpoints } from "@t3tools/client-runtime/handoff";
1314
import {
1415
childThreadInputsTitle,
@@ -787,7 +788,15 @@ export const ThreadDetailScreen = function ThreadDetailScreen(props: ThreadDetai
787788
const lastDispatchedVisitRef = useRef<string | null>(null);
788789
const lastVisitDispatchRef = useRef({ threadKey: selectedThreadKey, at: 0 });
789790
const selectedThreadId = props.selectedThread.id;
790-
const selectedThreadUpdatedAt = props.selectedThread.updatedAt;
791+
const selectedThreadWokeAt = threadWokeAt(props.selectedThread, {
792+
now: new Date().toISOString(),
793+
});
794+
// A scheduled wake can happen without a newer server update.
795+
const selectedThreadUpdatedAt =
796+
selectedThreadWokeAt !== null &&
797+
Date.parse(selectedThreadWokeAt) > Date.parse(props.selectedThread.updatedAt)
798+
? selectedThreadWokeAt
799+
: props.selectedThread.updatedAt;
791800
const selectedThreadLastVisitedAt = props.selectedThread.lastVisitedAt;
792801
const selectedThreadCompletedAt = props.selectedThread.latestRun?.completedAt;
793802
useEffect(() => {

0 commit comments

Comments
 (0)