Open History to see the last commit
1import type { EnvironmentId, ThreadId } from "@t3tools/contracts";
2import * as Option from "effect/Option";
3
4import { useEnvironmentThread } from "./threads";
5import { useThreadSelection } from "./use-thread-selection";
6
7export interface ThreadDetailTarget {
8 readonly environmentId: EnvironmentId | null;
9 readonly threadId: ThreadId | null;
10}
11
12export function useThreadDetail(target: ThreadDetailTarget) {
13 return useEnvironmentThread(target.environmentId, target.threadId);
14}
15
16/**
17 * The selection owns the subscription so it can hold it back while a queued
18 * creation has not reached the server yet.
19 */
20export function useSelectedThreadDetailState() {
21 return useThreadSelection().selectedThreadDetailState;
22}
23
24export function useSelectedThreadDetail() {
25 return Option.getOrNull(useSelectedThreadDetailState().data);
26}