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 | createVcsActionManager, |
| 3 | createVcsEnvironmentAtoms, |
| 4 | createVcsStatusRevalidationAtomFamily, |
| 5 | } from "@t3tools/client-runtime/state/vcs"; |
| 6 | import * as Equal from "effect/Equal"; |
| 7 | import { AsyncResult, Atom } from "effect/reactivity"; |
| 8 | |
| 9 | import { connectionAtomRuntime } from "../connection/runtime"; |
| 10 | import { subscribeDocumentReturn } from "../lib/documentActivity"; |
| 11 | |
| 12 | export const vcsEnvironment = createVcsEnvironmentAtoms(connectionAtomRuntime); |
| 13 | export const vcsActionManager = createVcsActionManager(connectionAtomRuntime); |
| 14 | |
| 15 | /** Only what a chat view reads, so changing file counts don't re-render it on every edit. */ |
| 16 | export const chatGitStatusAtom = Atom.family((status: ReturnType<typeof vcsEnvironment.status>) => |
| 17 | Atom.map(status, (result) => { |
| 18 | const data = AsyncResult.getOrElse(result, () => null); |
| 19 | if (data === null) return null; |
| 20 | const { isRepo, refName, hasWorkingTreeChanges, pr } = data; |
| 21 | return { isRepo, refName, hasWorkingTreeChanges, pr }; |
| 22 | }).pipe(Atom.withEquality(Equal.equals)), |
| 23 | ); |
| 24 | export const NO_CHAT_GIT_STATUS_ATOM: ReturnType<typeof chatGitStatusAtom> = Atom.make(null); |
| 25 | |
| 26 | /** |
| 27 | * Refreshes a checkout's status when the user comes back to the window, where |
| 28 | * edits made in another app or terminal may be waiting. |
| 29 | */ |
| 30 | export const vcsStatusRevalidation = createVcsStatusRevalidationAtomFamily({ |
| 31 | refreshStatus: vcsEnvironment.refreshStatus, |
| 32 | subscribeWake: subscribeDocumentReturn, |
| 33 | wakeDebounceMs: 250, |
| 34 | }); |
| 35 | |
| 36 | export const vcsBranchRevalidation = createVcsStatusRevalidationAtomFamily({ |
| 37 | refreshStatus: vcsEnvironment.refreshBranch, |
| 38 | subscribeWake: subscribeDocumentReturn, |
| 39 | wakeDebounceMs: 250, |
| 40 | }); |