@devries-cameron20 / t3code Mirror · read-only
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 21, 04:45 UTC

main
tsx 24 lines 1.16 KB
Raw
1 import { useAtomMount } from "@effect/atom-react";
2 import { scopedThreadKey } from "@t3tools/client-runtime/environment";
3 import { createThreadVisitTracker } from "@t3tools/client-runtime/state/thread-visits";
4 import { type ScopedThreadRef } from "@t3tools/contracts";
5
6 import { environmentCatalog } from "../../connection/catalog";
7 import { useUiStateStore } from "../../uiStateStore";
8 import { environmentThreadShells, threadEnvironment } from "../../state/threads";
9
10 const 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.
21 export function ThreadVisitWatermark(props: { readonly threadRef: ScopedThreadRef }) {
22 useAtomMount(threadVisitTracker(props.threadRef));
23 return null;
24 }