The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | import { useAtomValue } from "@effect/atom-react"; |
| 2 | import type { ScopedThreadRef } from "@t3tools/contracts"; |
| 3 | import { Atom } from "effect/reactivity"; |
| 4 | import type { ReactNode } from "react"; |
| 5 | |
| 6 | import { environmentThreadDetails } from "../../state/threads"; |
| 7 | import { WorkspaceMutationIdContext } from "./workspaceMutationIdContext"; |
| 8 | |
| 9 | const NO_WORKSPACE_MUTATION_ID_ATOM = Atom.make<string | null | undefined>(undefined); |
| 10 | |
| 11 | export function WorkspaceMutationIdProvider(props: { |
| 12 | readonly threadRef: ScopedThreadRef | null; |
| 13 | readonly children: ReactNode; |
| 14 | }) { |
| 15 | const workspaceMutationId = useAtomValue( |
| 16 | props.threadRef === null |
| 17 | ? NO_WORKSPACE_MUTATION_ID_ATOM |
| 18 | : environmentThreadDetails.workspaceMutationIdAtom(props.threadRef), |
| 19 | ); |
| 20 | return ( |
| 21 | <WorkspaceMutationIdContext value={workspaceMutationId}> |
| 22 | {props.children} |
| 23 | </WorkspaceMutationIdContext> |
| 24 | ); |
| 25 | } |