Files
kandev/apps/web/components/task-create-dialog-create-mode-selectors.tsx
T
Kandev Agent 278638ccf1 feat(web/task-create): repeatable repository rows for multi-repo task creation
Users can now actually create a multi-repo task: a "+ Add repository"
button below the primary repo + branch selectors expands the form with
additional (repository, base-branch) rows. Each extra row picks from a
filtered repository list that excludes the primary and any other already-
chosen extras, so duplicates are impossible to enter.

- ExtraRepositoryRow type + form-state hook (extraRepositories, add /
  remove / update / reset). Lives in its own file so the main state hook
  stays under the file-length lint cap.
- ExtraRepositoryRows component renders the rows and the "+ Add" button;
  per-row branches are loaded on demand via the existing
  useRepositoryBranches hook.
- buildRepositoriesPayload accepts the extras and appends them after the
  primary, dropping rows with empty repository_id silently so an
  unfinished row does not block submit. The backend's duplicate-repo
  validation (Phase 8) catches anything that slips through.
- DialogFormBody is split: CreateModeSelectors (selectors + extra rows)
  and useDialogHandlers move to dedicated files, keeping touched files
  under the lint thresholds.
- Tests cover the multi-repo payload (ordering, drop-empty, no-primary
  recovery, single-repo unchanged) and the existing
  store-multi-repo.test.ts gets named constants to satisfy the
  no-duplicate-string rule.

Verified: pnpm exec tsc --noEmit clean, vitest 608/608 green,
eslint --max-warnings 0 clean.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-26 01:20:04 +01:00

84 lines
3.0 KiB
TypeScript

"use client";
import type { AgentProfileOption } from "@/lib/state/slices";
import type { Repository } from "@/lib/types/http";
import type { DialogFormState } from "@/components/task-create-dialog-types";
import { CreateEditSelectors } from "@/components/task-create-dialog-form-body";
import {
AgentSelector,
BranchSelector,
ExecutorProfileSelector,
} from "@/components/task-create-dialog-selectors";
import {
useAgentProfileOptions,
useBranchOptions,
} from "@/components/task-create-dialog-options";
import { ExtraRepositoryRows } from "@/components/task-create-dialog-extra-repos";
type CreateModeSelectorsProps = {
isTaskStarted: boolean;
hasRepositorySelection: boolean;
branchOptions: ReturnType<typeof useBranchOptions>;
branchesLoading: boolean;
agentProfileOptions: ReturnType<typeof useAgentProfileOptions>;
executorProfileOptions: Array<{
value: string;
label: string;
renderLabel?: () => React.ReactNode;
}>;
agentProfiles: AgentProfileOption[];
agentProfilesLoading: boolean;
executorsLoading: boolean;
isCreatingSession: boolean;
fs: DialogFormState;
onBranchChange: (v: string) => void;
onAgentProfileChange: (v: string) => void;
onExecutorProfileChange: (v: string) => void;
isLocalExecutor: boolean;
workflowAgentLocked: boolean;
repositories: Repository[];
};
/**
* Create/edit-mode form body section: branch + agent + executor selectors,
* followed by the multi-repo extra-repository rows. Extracted from
* task-create-dialog.tsx to keep the parent file under the lint line cap.
*/
export function CreateModeSelectors(props: CreateModeSelectorsProps) {
return (
<>
<CreateEditSelectors
isTaskStarted={props.isTaskStarted}
hasRepositorySelection={props.hasRepositorySelection}
branchOptions={props.branchOptions}
branch={props.fs.branch}
onBranchChange={props.onBranchChange}
branchesLoading={props.branchesLoading}
localBranchesLoading={props.fs.localBranchesLoading}
agentProfiles={props.agentProfiles}
agentProfilesLoading={props.agentProfilesLoading}
agentProfileOptions={props.agentProfileOptions}
agentProfileId={props.fs.agentProfileId}
onAgentProfileChange={props.onAgentProfileChange}
isCreatingSession={props.isCreatingSession}
executorProfileOptions={props.executorProfileOptions}
executorProfileId={props.fs.executorProfileId}
onExecutorProfileChange={props.onExecutorProfileChange}
executorsLoading={props.executorsLoading}
isLocalExecutor={props.isLocalExecutor}
useGitHubUrl={props.fs.useGitHubUrl}
workflowAgentLocked={props.workflowAgentLocked}
BranchSelectorComponent={BranchSelector}
AgentSelectorComponent={AgentSelector}
ExecutorProfileSelectorComponent={ExecutorProfileSelector}
/>
<ExtraRepositoryRows
fs={props.fs}
repositories={props.repositories}
isTaskStarted={props.isTaskStarted}
primarySelected={props.hasRepositorySelection}
/>
</>
);
}