import { Box, Text } from "ink"
import {
CLAUDE_MODEL_ENV_KEYS,
EXPORT_ENV_EXTRA_EDITABLE_KEYS,
EXPORT_ENV_STATIC_ENTRIES,
type ClaudeEnvironmentDraft,
type ShellKind,
} from "../claude-env"
export function ClaudeEnvironmentEditor(props: {
draft: ClaudeEnvironmentDraft
selected: number
baseUrl: string
confirm: boolean
shell: ShellKind
settingsTarget: string
apiPassword?: string
}) {
const modelKeyCount = CLAUDE_MODEL_ENV_KEYS.length
const authValue = props.apiPassword || EXPORT_ENV_STATIC_ENTRIES.find((e) => e.key === "ANTHROPIC_AUTH_TOKEN")?.value || "codex2claudecode"
const lockedEntries: Array<{ key: string; value: string }> = [
{ key: "ANTHROPIC_BASE_URL", value: props.baseUrl },
...EXPORT_ENV_STATIC_ENTRIES.map((entry) =>
entry.key === "ANTHROPIC_AUTH_TOKEN" || entry.key === "ANTHROPIC_API_KEY"
? { ...entry, value: authValue }
: entry,
),
]
return (
────────────────────────────────────────────────────────────────────────────
{props.confirm ? "Confirm Claude Environment" : "Edit Claude Environment"}
Target: {props.settingsTarget} → env
↑/↓ move · type edit · Enter {props.confirm ? "save" : "confirm"} · Esc cancel
{"── Locked ──"}
{lockedEntries.map((entry) => (
))}
{"── Editable ──"}
{CLAUDE_MODEL_ENV_KEYS.map((key, index) => (
))}
{EXPORT_ENV_EXTRA_EDITABLE_KEYS.map((key, index) => (
))}
{props.draft.unsetEnv.length > 0 && (
{"── Unset On Save ──"}
{props.draft.unsetEnv.map((key) => (
delete {key}
))}
)}
{props.confirm && (
Write these values into {props.settingsTarget} env?
Enter or y to save · n or Esc to cancel
)}
)
}
function LockedRow(props: { name: string; value: string }) {
return (
{props.name}
{props.value}
)
}
function EditableRow(props: { name: string; value: string; active: boolean; confirm: boolean }) {
return (
{props.active ? "›" : " "}
{props.name}
{props.value}
{props.active && !props.confirm && }
)
}