Open History to see the last commit
1import { useAtomMount } from "@effect/atom-react";
2import { scopedThreadKey } from "@t3tools/client-runtime/environment";
3import { createThreadVisitTracker } from "@t3tools/client-runtime/state/thread-visits";
4import { type ScopedThreadRef } from "@t3tools/contracts";
5
6import { useUiStateStore } from "../../uiStateStore";
7import { environmentThreadShells, threadEnvironment } from "../../state/threads";
8
9const threadVisitTracker = createThreadVisitTracker({
10 threadShellAtom: environmentThreadShells.threadShellAtom,
11 visit: threadEnvironment.visit,
12 markLocalVisit: (ref, visitedAt) =>
13 useUiStateStore.getState().markThreadVisited(scopedThreadKey(ref), visitedAt),
14});
15
16// The visit watermark is the one part of the chat view that follows the
17// shell's updatedAt, which ticks while a run streams. The tracker subscribes to
18// it outside React, so ChatView keeps reading the quiet shell.
19export function ThreadVisitWatermark(props: { readonly threadRef: ScopedThreadRef }) {
20 useAtomMount(threadVisitTracker(props.threadRef));
21 return null;
22}