| 1 | import type { OrchestrationV2ThreadProjection } from "@t3tools/contracts"; |
| 2 | import * as Option from "effect/Option"; |
| 3 | |
| 4 | import { EMPTY_THREAD_HISTORY_META, type ThreadHistoryMeta } from "./threadHistoryMerge.ts"; |
| 5 | |
| 6 | export type EnvironmentThreadStatus = "empty" | "cached" | "synchronizing" | "live" | "deleted"; |
| 7 | |
| 8 | export interface EnvironmentThreadState { |
| 9 | readonly data: Option.Option<OrchestrationV2ThreadProjection>; |
| 10 | readonly status: EnvironmentThreadStatus; |
| 11 | readonly error: Option.Option<string>; |
| 12 | /** |
| 13 | * Progressive history cursor for bounded hydration. Absent/cleared on full |
| 14 | * snapshot paths. Errors here are thread/history-local and must not be |
| 15 | * promoted into the environment disconnect path. |
| 16 | */ |
| 17 | readonly history: ThreadHistoryMeta; |
| 18 | } |
| 19 | |
| 20 | export const EMPTY_ENVIRONMENT_THREAD_STATE: EnvironmentThreadState = { |
| 21 | data: Option.none(), |
| 22 | status: "empty", |
| 23 | error: Option.none(), |
| 24 | history: EMPTY_THREAD_HISTORY_META, |
| 25 | }; |