(input: InjectThreadsInput, destroyRef: DestroyRef)
| 243 | readonly isMutating = this.#isMutating.asReadonly(); |
| 244 | |
| 245 | constructor(input: InjectThreadsInput, destroyRef: DestroyRef) { |
| 246 | const agentId = toAccessor(input.agentId); |
| 247 | const includeArchived = toAccessor(input.includeArchived); |
| 248 | const limit = toAccessor(input.limit); |
| 249 | const enabled = toAccessor(input.enabled); |
| 250 | // `enabled` defaults to `true`; only an explicit `false` keeps the store |
| 251 | // inert. An unset/`undefined` input is treated as enabled. |
| 252 | const isEnabled = (): boolean => enabled() !== false; |
| 253 | |
| 254 | this.#bridgeSelectors(); |
| 255 | this.#store.start(); |
| 256 | |
| 257 | // Synthesized error/loading reconcile the core store's internal state with |
| 258 | // configuration-level conditions (no runtime URL, unavailable endpoints), |
| 259 | // mirroring react-core's useThreads. |
| 260 | const runtimeUrl = this.#copilotkit.runtimeUrl; |
| 261 | const runtimeStatus = this.#copilotkit.runtimeConnectionStatus; |
| 262 | // Read `threadEndpoints`/`intelligence.wsUrl` through the CopilotKit |
| 263 | // signals (not plain `core.*` getters) so the computeds/effect re-run when |
| 264 | // `/info` populates them — even if it lands without a connection-status |
| 265 | // transition. This mirrors react-core, which lists both in its effect deps. |
| 266 | const threadEndpoints = this.#copilotkit.threadEndpoints; |
| 267 | const threadListSupported = (): boolean => |
| 268 | threadEndpoints()?.list !== false; |
| 269 | const threadMutationsSupported = (): boolean => |
| 270 | threadEndpoints()?.mutations !== false; |
| 271 | const threadEndpointsUnavailable = (): boolean => |
| 272 | !!runtimeUrl() && |
| 273 | runtimeStatus() === CopilotKitCoreRuntimeConnectionStatus.Connected && |
| 274 | !threadListSupported(); |
| 275 | |
| 276 | const runtimeError = (): Error | null => |
| 277 | runtimeUrl() ? null : new Error("Runtime URL is not configured"); |
| 278 | const endpointsError = (): Error | null => |
| 279 | threadEndpointsUnavailable() |
| 280 | ? new Error( |
| 281 | "Thread endpoints are not available on this CopilotKit runtime", |
| 282 | ) |
| 283 | : null; |
| 284 | const mutationsError = (): Error | null => |
| 285 | threadMutationsSupported() |
| 286 | ? null |
| 287 | : new Error( |
| 288 | "Thread mutations are not available on this CopilotKit runtime", |
| 289 | ); |
| 290 | |
| 291 | const preConnectLoading = (): boolean => |
| 292 | isEnabled() && |
| 293 | !!runtimeUrl() && |
| 294 | !threadEndpointsUnavailable() && |
| 295 | !this.#hasDispatchedContext(); |
| 296 | |
| 297 | // Synthesized error/loading combine configuration-level conditions with |
| 298 | // the core store's own state; expressed as pure derived signals. |
| 299 | this.error = computed( |
| 300 | () => runtimeError() ?? endpointsError() ?? this.#storeError(), |
| 301 | ); |
| 302 | // listError exposes only genuine fetch/mutation errors, excluding the |
nothing calls this directly
no test coverage detected