@devries-cameron20 / t3code Mirror · read-only
Fork 0

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

main
ts 17 lines 777 Bytes
Raw
1 import { useAtomValue } from "@effect/atom-react";
2 import type { EnvironmentId } from "@t3tools/contracts";
3
4 import { environmentCatalog } from "../../connection/catalog";
5 import { useAtomCommand } from "../../state/use-atom-command";
6
7 export function useRetryEnvironment() {
8 const catalog = useAtomValue(environmentCatalog.catalogValueAtom);
9 const retryNow = useAtomCommand(environmentCatalog.retryNow, "environment retry");
10 const setEnabled = useAtomCommand(environmentCatalog.setEnabled, "environment toggle");
11
12 return (environmentId: EnvironmentId) =>
13 // A retry does nothing while the environment is switched off.
14 catalog.entries.get(environmentId)?.enabled === false
15 ? setEnabled({ environmentId, enabled: true })
16 : retryNow(environmentId);
17 }