"use client"; import { DialogTitle } from "@kandev/ui/dialog"; import { RepositorySelector, InlineTaskName } from "@/components/task-create-dialog-selectors"; import type { useRepositoryOptions } from "@/components/task-create-dialog-options"; function getRepositoryPlaceholder( workspaceId: string | null, repositoriesLoading: boolean, discoverReposLoading: boolean, ) { if (!workspaceId) return "Select workspace first"; if (repositoriesLoading || discoverReposLoading) return "Loading..."; return "Select repository"; } export type DialogHeaderContentProps = { isCreateMode: boolean; isEditMode: boolean; isTaskStarted: boolean; sessionRepoName?: string; initialTitle?: string; taskName: string; repositoryId: string; discoveredRepoPath: string; workspaceId: string | null; repositoriesLoading: boolean; discoverReposLoading: boolean; headerRepositoryOptions: ReturnType["headerRepositoryOptions"]; onRepositoryChange: (v: string) => void; onTaskNameChange: (v: string) => void; useGitHubUrl: boolean; githubUrl: string; githubUrlError: string | null; onToggleGitHubUrl: () => void; onGitHubUrlChange: (v: string) => void; }; function RepoSourceInput({ useGitHubUrl, githubUrl, githubUrlError, onGitHubUrlChange, isTaskStarted, headerRepositoryOptions, repositoryId, discoveredRepoPath, onRepositoryChange, workspaceId, repositoriesLoading, discoverReposLoading, }: Pick< DialogHeaderContentProps, | "useGitHubUrl" | "githubUrl" | "githubUrlError" | "onGitHubUrlChange" | "isTaskStarted" | "headerRepositoryOptions" | "repositoryId" | "discoveredRepoPath" | "onRepositoryChange" | "workspaceId" | "repositoriesLoading" | "discoverReposLoading" >): React.ReactNode { if (useGitHubUrl) { return (
onGitHubUrlChange(e.target.value)} placeholder="github.com/owner/repo" data-testid="github-url-input" aria-label="GitHub repository URL" aria-invalid={!!githubUrlError} aria-describedby={githubUrlError ? "github-url-error" : undefined} size={Math.max((githubUrl || "").length + 1, "github.com/owner/repo".length)} className={`bg-transparent border-none outline-none focus:ring-0 text-sm font-medium min-w-0 h-7 rounded-md px-2 hover:bg-muted focus:bg-muted transition-colors placeholder:text-muted-foreground ${githubUrlError ? "text-destructive" : ""}`} disabled={isTaskStarted} autoFocus /> {githubUrlError && ( )}
); } return ( ); } export function DialogHeaderContent(props: DialogHeaderContentProps) { const { isCreateMode, isEditMode, isTaskStarted, sessionRepoName, initialTitle } = props; const { taskName, onTaskNameChange, useGitHubUrl, onToggleGitHubUrl } = props; if (isCreateMode || isEditMode) { return ( <>
/
{!isTaskStarted && (
)} ); } return (
{sessionRepoName && ( <> {sessionRepoName} / )} {initialTitle || "Task"} / new session
); }