File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,10 +5,10 @@ import {
55} from "@t3tools/contracts" ;
66import type { ThreadFeedEntry } from "../../lib/threadActivity" ;
77import { scopedThreadKey } from "../../lib/scopedEntities" ;
8- import {
9- threadHasCaughtUpTo ,
10- type AcknowledgedThreadMessage ,
11- type QueuedThreadMessage ,
8+ import { threadHasCaughtUpTo } from "@t3tools/client-runtime/state/thread-state" ;
9+ import type {
10+ AcknowledgedThreadMessage ,
11+ QueuedThreadMessage ,
1212} from "../../state/thread-outbox-model" ;
1313
1414/**
Original file line number Diff line number Diff line change 11import * as Option from "effect/Option" ;
22import { Atom } from "effect/reactivity" ;
33import { appAtomRegistry } from "./atom-registry" ;
4- import {
5- threadHasCaughtUpTo ,
6- type AcknowledgedThreadMessage ,
7- type QueuedThreadMessage ,
8- } from "./thread-outbox-model" ;
4+ import { threadHasCaughtUpTo } from "@t3tools/client-runtime/state/thread-state" ;
5+ import type { AcknowledgedThreadMessage , QueuedThreadMessage } from "./thread-outbox-model" ;
96import { environmentThreadDetails } from "./threads" ;
107
118// Keep acknowledged rows until the thread catches up; command receipts can precede messages.
Original file line number Diff line number Diff line change @@ -292,18 +292,3 @@ export type AcknowledgedThreadMessage = QueuedThreadMessage & {
292292 /** The server sequence that committed the message; older servers do not report it. */
293293 readonly sequence ?: number ;
294294} ;
295-
296- /**
297- * The thread holds the message once it has applied the message's sequence. A bounded
298- * projection can page the message out later, so finding it is only a fallback.
299- */
300- export function threadHasCaughtUpTo (
301- message : AcknowledgedThreadMessage ,
302- thread : {
303- readonly sequence : number ;
304- readonly messages : ReadonlyArray < { readonly id : string } > | undefined ;
305- } ,
306- ) : boolean {
307- if ( message . sequence !== undefined && thread . sequence >= message . sequence ) return true ;
308- return thread . messages ?. some ( ( entry ) => entry . id === message . messageId ) ?? false ;
309- }
Original file line number Diff line number Diff line change 303303 "types" : " ./src/state/threads.ts" ,
304304 "default" : " ./src/state/threads.ts"
305305 },
306+ "./state/thread-state" : {
307+ "types" : " ./src/state/threadState.ts" ,
308+ "default" : " ./src/state/threadState.ts"
309+ },
306310 "./state/subagent-display" : {
307311 "types" : " ./src/state/subagentDisplay.ts" ,
308312 "default" : " ./src/state/subagentDisplay.ts"
Original file line number Diff line number Diff line change @@ -25,3 +25,19 @@ export const EMPTY_ENVIRONMENT_THREAD_STATE: EnvironmentThreadState = {
2525 history : EMPTY_THREAD_HISTORY_META ,
2626 sequence : 0 ,
2727} ;
28+
29+ /**
30+ * A thread holds a write once it has applied the write's commit sequence. A bounded
31+ * projection can page the message out later, so finding it is only a fallback for
32+ * servers that do not report the sequence.
33+ */
34+ export function threadHasCaughtUpTo (
35+ write : { readonly messageId : string ; readonly sequence ?: number | undefined } ,
36+ thread : {
37+ readonly sequence : number ;
38+ readonly messages : ReadonlyArray < { readonly id : string } > | undefined ;
39+ } ,
40+ ) : boolean {
41+ if ( write . sequence !== undefined && thread . sequence >= write . sequence ) return true ;
42+ return thread . messages ?. some ( ( entry ) => entry . id === write . messageId ) ?? false ;
43+ }
You can’t perform that action at this time.
0 commit comments