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 { environmentCatalog } from "../../connection/catalog";
7import { useUiStateStore } from "../../uiStateStore";
8import { environmentThreadShells, threadEnvironment } from "../../state/threads";
9
10const threadVisitTracker = createThreadVisitTracker({
11 threadShellAtom: environmentThreadShells.threadShellAtom,
12 sessionGenerationAtom: environmentCatalog.sessionGenerationAtom,
13 visit: threadEnvironment.visit,
14 markLocalVisit: (ref, visitedAt) =>
15 useUiStateStore.getState().markThreadVisited(scopedThreadKey(ref), visitedAt),
16});
17
18// The visit watermark is the one part of the chat view that follows the
19// shell's updatedAt, which ticks while a run streams. The tracker subscribes to
20// it outside React, so ChatView keeps reading the quiet shell.
21export function ThreadVisitWatermark(props: { readonly threadRef: ScopedThreadRef }) {
22 useAtomMount(threadVisitTracker(props.threadRef));
23 return null;
24}