"use client";
import { cn } from "@/lib/utils";
export type SourceMode = "workspace" | "remote" | "scratch";
function resolveMode(useRemote: boolean, noRepository: boolean): SourceMode {
if (noRepository) return "scratch";
if (useRemote) return "remote";
return "workspace";
}
type SourceModeSwitchProps = {
useRemote: boolean;
noRepository: boolean;
onToggleRemote?: () => void;
onToggleNoRepository?: () => void;
};
/**
* Three-mode segmented control rendered at the right edge of the chip row:
* - Repo : pick a workspace repository (default)
* - Remote : paste a GitHub URL (Task 4 renamed "url" → "remote")
* - None : run in a scratch workspace or a folder you pick
*
* Switching modes calls the underlying single-mode togglers in the right
* order so we never end up in two modes at once. Hidden when no togglers
* are provided (e.g. locked-fields wrapper).
*/
export function SourceModeSwitch({
useRemote,
noRepository,
onToggleRemote,
onToggleNoRepository,
}: SourceModeSwitchProps) {
if (!onToggleRemote && !onToggleNoRepository) return null;
const mode = resolveMode(useRemote, noRepository);
const setMode = (next: SourceMode) =>
switchMode({
from: mode,
to: next,
onToggleRemote,
onToggleNoRepository,
});
return (