);
}
/**
* Shared repository + base-branch picker for the Linear / Jira / Sentry watcher
* dialogs. Binds the watcher to an optional repository so its tasks run against
* that codebase instead of an empty scratch checkout; an empty repository =
* unbound (repo-less task). How the repository is materialised (isolated
* worktree vs in-place) is decided by the executor profile, not this field. The
* base-branch select is disabled until a repository is chosen and defaults to
* the repository's default branch. The `onChange` callbacks receive values
* already collapsed from the dropdown sentinels back to "".
*/
export function WatcherRepositoryFields({
workspaceId,
repositoryId,
baseBranch,
onRepositoryChange,
onBaseBranchChange,
}: {
workspaceId: string;
repositoryId: string;
baseBranch: string;
onRepositoryChange: (repositoryId: string) => void;
onBaseBranchChange: (baseBranch: string) => void;
}) {
// forceRefresh: a repo created in settings doesn't update the shared store
// slice, and the lazy fetch is gated by isLoaded — so without this the picker
// could miss repositories created since the slice first loaded. The hook owns
// the fetch (keeps data-flow in the hook layer, not the component).
const { repositories } = useRepositories(workspaceId, !!workspaceId, true);
const branchSource = repositoryId ? ({ kind: "id", workspaceId, repositoryId } as const) : null;
const { branches, isLoading: branchesLoading } = useBranches(branchSource, !!repositoryId);
// A branch name can appear twice (local + remote tracking, e.g. "main" and
// origin/"main"), which would emit two — Radix then
// renders every matching item's text in the trigger ("mainmain") and React
// warns on duplicate keys. Dedupe by name so each branch is one option.
const uniqueBranchNames = Array.from(new Set(branches.map((b) => b.name)));
return (