| ... | ... | @@ -15,12 +15,12 @@ import type { EnvironmentThread, EnvironmentThreadShell } from "./models.ts"; |
| 15 | 15 | import { scopeThread } from "./models.ts"; |
| 16 | 16 | import { EMPTY_ENVIRONMENT_THREAD_STATE, type EnvironmentThreadState } from "./threads.ts"; |
| 17 | 17 | import { parseThreadKey, threadKey } from "./entities.ts"; |
| 18 | import { THREAD_STATE_IDLE_TTL_MS } from "./threadRetention.ts"; |
| 18 | 19 | |
| 19 | 20 | const EMPTY_MESSAGES: ReadonlyArray<OrchestrationMessage> = Object.freeze([]); |
| 20 | 21 | const EMPTY_ACTIVITIES: ReadonlyArray<OrchestrationThreadActivity> = Object.freeze([]); |
| 21 | 22 | const EMPTY_PROPOSED_PLANS: ReadonlyArray<OrchestrationProposedPlan> = Object.freeze([]); |
| 22 | 23 | const EMPTY_CHECKPOINTS: ReadonlyArray<OrchestrationCheckpointSummary> = Object.freeze([]); |
| 23 | | const THREAD_DETAIL_IDLE_TTL_MS = 5 * 60_000; |
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * Combine detail-only collections with the shell's authoritative thread metadata. |
| ... | ... | @@ -75,7 +75,7 @@ export function createEnvironmentThreadDetailAtoms<E>( |
| 75 | 75 | () => EMPTY_ENVIRONMENT_THREAD_STATE, |
| 76 | 76 | ), |
| 77 | 77 | ).pipe( |
| 78 | | Atom.setIdleTTL(THREAD_DETAIL_IDLE_TTL_MS), |
| 78 | Atom.setIdleTTL(THREAD_STATE_IDLE_TTL_MS), |
| 79 | 79 | Atom.withLabel(`environment-thread-state-value:${key}`), |
| 80 | 80 | ); |
| 81 | 81 | }); |
| ... | ... | @@ -93,21 +93,21 @@ export function createEnvironmentThreadDetailAtoms<E>( |
| 93 | 93 | previousValue = source === null ? null : scopeThread(ref.environmentId, source); |
| 94 | 94 | return previousValue; |
| 95 | 95 | }).pipe( |
| 96 | | Atom.setIdleTTL(THREAD_DETAIL_IDLE_TTL_MS), |
| 96 | Atom.setIdleTTL(THREAD_STATE_IDLE_TTL_MS), |
| 97 | 97 | Atom.withLabel(`environment-thread-detail:${key}`), |
| 98 | 98 | ); |
| 99 | 99 | }); |
| 100 | 100 | |
| 101 | 101 | const threadStatusAtomFamily = Atom.family((key: string) => |
| 102 | 102 | Atom.make((get) => get(threadStateValueAtomFamily(key)).status).pipe( |
| 103 | | Atom.setIdleTTL(THREAD_DETAIL_IDLE_TTL_MS), |
| 103 | Atom.setIdleTTL(THREAD_STATE_IDLE_TTL_MS), |
| 104 | 104 | Atom.withLabel(`environment-thread-status:${key}`), |
| 105 | 105 | ), |
| 106 | 106 | ); |
| 107 | 107 | |
| 108 | 108 | const threadErrorAtomFamily = Atom.family((key: string) => |
| 109 | 109 | Atom.make((get) => Option.getOrNull(get(threadStateValueAtomFamily(key)).error)).pipe( |
| 110 | | Atom.setIdleTTL(THREAD_DETAIL_IDLE_TTL_MS), |
| 110 | Atom.setIdleTTL(THREAD_STATE_IDLE_TTL_MS), |
| 111 | 111 | Atom.withLabel(`environment-thread-error:${key}`), |
| 112 | 112 | ), |
| 113 | 113 | ); |
| ... | ... | @@ -117,7 +117,7 @@ export function createEnvironmentThreadDetailAtoms<E>( |
| 117 | 117 | (get): ReadonlyArray<OrchestrationMessage> => |
| 118 | 118 | get(threadDetailAtomFamily(key))?.messages ?? EMPTY_MESSAGES, |
| 119 | 119 | ).pipe( |
| 120 | | Atom.setIdleTTL(THREAD_DETAIL_IDLE_TTL_MS), |
| 120 | Atom.setIdleTTL(THREAD_STATE_IDLE_TTL_MS), |
| 121 | 121 | Atom.withLabel(`environment-thread-messages:${key}`), |
| 122 | 122 | ), |
| 123 | 123 | ); |
| ... | ... | @@ -127,7 +127,7 @@ export function createEnvironmentThreadDetailAtoms<E>( |
| 127 | 127 | (get): ReadonlyArray<OrchestrationThreadActivity> => |
| 128 | 128 | get(threadDetailAtomFamily(key))?.activities ?? EMPTY_ACTIVITIES, |
| 129 | 129 | ).pipe( |
| 130 | | Atom.setIdleTTL(THREAD_DETAIL_IDLE_TTL_MS), |
| 130 | Atom.setIdleTTL(THREAD_STATE_IDLE_TTL_MS), |
| 131 | 131 | Atom.withLabel(`environment-thread-activities:${key}`), |
| 132 | 132 | ), |
| 133 | 133 | ); |
| ... | ... | @@ -137,7 +137,7 @@ export function createEnvironmentThreadDetailAtoms<E>( |
| 137 | 137 | (get): ReadonlyArray<OrchestrationProposedPlan> => |
| 138 | 138 | get(threadDetailAtomFamily(key))?.proposedPlans ?? EMPTY_PROPOSED_PLANS, |
| 139 | 139 | ).pipe( |
| 140 | | Atom.setIdleTTL(THREAD_DETAIL_IDLE_TTL_MS), |
| 140 | Atom.setIdleTTL(THREAD_STATE_IDLE_TTL_MS), |
| 141 | 141 | Atom.withLabel(`environment-thread-proposed-plans:${key}`), |
| 142 | 142 | ), |
| 143 | 143 | ); |
| ... | ... | @@ -147,7 +147,7 @@ export function createEnvironmentThreadDetailAtoms<E>( |
| 147 | 147 | (get): ReadonlyArray<OrchestrationCheckpointSummary> => |
| 148 | 148 | get(threadDetailAtomFamily(key))?.checkpoints ?? EMPTY_CHECKPOINTS, |
| 149 | 149 | ).pipe( |
| 150 | | Atom.setIdleTTL(THREAD_DETAIL_IDLE_TTL_MS), |
| 150 | Atom.setIdleTTL(THREAD_STATE_IDLE_TTL_MS), |
| 151 | 151 | Atom.withLabel(`environment-thread-checkpoints:${key}`), |
| 152 | 152 | ), |
| 153 | 153 | ); |
| ... | ... | @@ -156,7 +156,7 @@ export function createEnvironmentThreadDetailAtoms<E>( |
| 156 | 156 | Atom.make( |
| 157 | 157 | (get): OrchestrationSession | null => get(threadDetailAtomFamily(key))?.session ?? null, |
| 158 | 158 | ).pipe( |
| 159 | | Atom.setIdleTTL(THREAD_DETAIL_IDLE_TTL_MS), |
| 159 | Atom.setIdleTTL(THREAD_STATE_IDLE_TTL_MS), |
| 160 | 160 | Atom.withLabel(`environment-thread-session:${key}`), |
| 161 | 161 | ), |
| 162 | 162 | ); |
| ... | ... | @@ -165,7 +165,7 @@ export function createEnvironmentThreadDetailAtoms<E>( |
| 165 | 165 | Atom.make( |
| 166 | 166 | (get): OrchestrationLatestTurn | null => get(threadDetailAtomFamily(key))?.latestTurn ?? null, |
| 167 | 167 | ).pipe( |
| 168 | | Atom.setIdleTTL(THREAD_DETAIL_IDLE_TTL_MS), |
| 168 | Atom.setIdleTTL(THREAD_STATE_IDLE_TTL_MS), |
| 169 | 169 | Atom.withLabel(`environment-thread-latest-turn:${key}`), |
| 170 | 170 | ), |
| 171 | 171 | ); |