// The spawn form's worktree section (#61): create-worktree toggle, then // (once a base repo is known) new-branch-vs-existing-branch, mirroring // spawnForm.ts's `.adv-group`/`.wt-body`/`.wt-mode` markup. import type { BranchInfo } from "../../types.js"; import type { WorktreeBranchMode } from "./model.js"; export interface BranchPickerProps { enabled: boolean; onToggleEnabled(enabled: boolean): void; /** Status line shown in place of the body — "Checking…", "not a repo", * "choose a directory first". `null` once the body itself can render. */ hint: string | null; /** The repo a worktree would branch from, once resolved. */ baseRepo: string | null; mode: WorktreeBranchMode; onModeChange(mode: WorktreeBranchMode): void; newBranch: string; onNewBranchChange(value: string): void; /** This cwd's local branches, or `undefined` while unknown/not yet loaded. */ branches: BranchInfo[] | undefined; existingBranch: string; onExistingBranchChange(value: string): void; } export function BranchPicker(props: BranchPickerProps) { return (
{props.hint &&

{props.hint}

} {props.enabled && !props.hint && (
{props.baseRepo && (

repo: {props.baseRepo}

)}
{props.mode === "new" ? ( ) : ( )}
)}
); } function branchOptions(branches: BranchInfo[] | undefined) { if (!branches || branches.length === 0) { return ; } return branches.map((b) => { // A branch already checked out anywhere stays visible but unpickable — // git refuses a second checkout. That includes the main checkout's own // HEAD, which is commonly `main` and would otherwise be the default pick, // making every existing-branch spawn fail (#54 review). const held = b.worktree ?? (b.is_head ? "the main checkout" : null); return ( ); }); }