The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { useAtomValue } from "@effect/atom-react"; |
| 2 | import type { EnvironmentId, ProviderDriverKind } from "@t3tools/contracts"; |
| 3 | import { T, Var } from "gt-react"; |
| 4 | import { InfoIcon } from "lucide-react"; |
| 5 | |
| 6 | import { serverEnvironment } from "../../state/server"; |
| 7 | import { Alert, AlertDescription } from "../ui/alert"; |
| 8 | |
| 9 | const MULTIPLE_ACCOUNTS_FAQ_URL = |
| 10 | "https://github.com/pingdotgg/t3code/blob/main/docs/user/faq.md#can-i-add-a-bunch-of-accounts-for-one-provider"; |
| 11 | |
| 12 | const PROVIDER_NAMES = new Map<string, string>([ |
| 13 | ["codex", "Codex"], |
| 14 | ["claudeAgent", "Claude"], |
| 15 | ]); |
| 16 | |
| 17 | /** Shown while adding a Claude or Codex account when the environment already has one signed in. */ |
| 18 | export function MultipleAccountsNote({ |
| 19 | environmentId, |
| 20 | driver, |
| 21 | }: { |
| 22 | readonly environmentId: EnvironmentId; |
| 23 | readonly driver: ProviderDriverKind; |
| 24 | }) { |
| 25 | const providers = useAtomValue(serverEnvironment.providersValueAtom(environmentId)); |
| 26 | const providerName = PROVIDER_NAMES.get(driver); |
| 27 | const hasSignedInAccount = |
| 28 | providerName !== undefined && |
| 29 | providers?.some( |
| 30 | (provider) => provider.driver === driver && provider.auth.status === "authenticated", |
| 31 | ); |
| 32 | if (!hasSignedInAccount) return null; |
| 33 | return ( |
| 34 | <Alert variant="info" role="note"> |
| 35 | <InfoIcon aria-hidden /> |
| 36 | <AlertDescription> |
| 37 | <p> |
| 38 | <T> |
| 39 | We do not recommend managing multiple <Var>{providerName}</Var> accounts in T3 Code.{" "} |
| 40 | <a |
| 41 | href={MULTIPLE_ACCOUNTS_FAQ_URL} |
| 42 | target="_blank" |
| 43 | rel="noreferrer" |
| 44 | className="underline underline-offset-2 hover:text-foreground" |
| 45 | > |
| 46 | More info |
| 47 | </a> |
| 48 | </T> |
| 49 | </p> |
| 50 | </AlertDescription> |
| 51 | </Alert> |
| 52 | ); |
| 53 | } |