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 { |
| 2 | createFilesystemEnvironmentAtoms, |
| 3 | resolveFilesystemReadAccess, |
| 4 | } from "@t3tools/client-runtime/state/filesystem"; |
| 5 | import type { EnvironmentId } from "@t3tools/contracts"; |
| 6 | |
| 7 | import { connectionAtomRuntime } from "../connection/runtime"; |
| 8 | import { m, type MessageResolver } from "../i18n/messages"; |
| 9 | import { useEnvironmentPresentation } from "./presentation"; |
| 10 | import { useEnvironmentQuery } from "./query"; |
| 11 | import { environmentSession } from "./session"; |
| 12 | |
| 13 | export const filesystemEnvironment = createFilesystemEnvironmentAtoms(connectionAtomRuntime); |
| 14 | |
| 15 | export function useFilesystemReadAccess( |
| 16 | environmentId: EnvironmentId | null, |
| 17 | resolve: MessageResolver = m, |
| 18 | ) { |
| 19 | const session = useEnvironmentQuery( |
| 20 | environmentId === null ? null : environmentSession.sessionStateAtom(environmentId), |
| 21 | resolve, |
| 22 | ); |
| 23 | const environment = useEnvironmentPresentation(environmentId); |
| 24 | return resolveFilesystemReadAccess( |
| 25 | { |
| 26 | isCatalogReady: environment.isReady, |
| 27 | connection: environment.presentation?.connection ?? null, |
| 28 | session: session.data, |
| 29 | sessionError: session.error, |
| 30 | }, |
| 31 | resolve, |
| 32 | ); |
| 33 | } |