/** * @file RunSetup.tsx * @description The pre-run setup panel: everything the user picks before a run * exists. Moved verbatim out of `pages/Run.tsx` (where it was `ConfigCard`) so * the Run page and the Workspace page can both mount the same panel. * * What lives here: * - `RunSetup` — fresh-vs-resume source, the prompt editor, and the cwd / * model / permission-mode / effort fields, plus the concurrency hint and * the Start button. Its disabled state is driven by the `binaryFound` prop, * so a missing `claude` binary is a surfaced state here rather than a probe * of its own. * - the pickers the panel owns: `CwdAutocomplete`, `SessionPicker`, * `ModelPicker`, and the small `Field` layout helper. * * Props only for `RunSetup`: no `/stage` call, no lane API call, and no run * lifecycle — the page owns `api.run.start` and hands the result back through * `onStart`. `SessionPicker` keeps the one API call it already owned (listing * past sessions to resume) and `PromptEditor` keeps its `@`-file lookup. * * @author Nguyễn Ngọc Trí Vĩ */ import { useEffect, useMemo, useRef, useState } from "react"; import { useTranslation } from "react-i18next"; import { Play, RefreshCw, AlertCircle, ChevronDown, ShieldAlert, X, FolderOpen, Home, History as HistoryIcon, Search, RotateCcw, Lock, } from "lucide-react"; import { api, RUN_MODEL_CHOICES, RUN_EFFORT_CHOICES } from "../../lib/api"; import type { CwdSuggestion, DashboardRunHistoryItem, RunListResponse, EffortLevel, PermissionMode, RunStartArgs, } from "../../lib/api"; import type { Session } from "../../lib/types"; import { Select } from "../Select"; // Minimal SlashCommand type (from deleted RunConsole) export interface SlashCommand { name: string; source: "project" | "user" | "plugin" | "builtin"; description?: string; } // Minimal PromptEditor component (from deleted RunConsole) interface PromptEditorProps { value: string; onChange: (s: string) => void; onSubmit: () => void; placeholder: string; rows?: number; slashCommands: SlashCommand[]; fileCwd: string; } function PromptEditor({ value, onChange, onSubmit, placeholder, rows = 5 }: PromptEditorProps) { const handleKeyDown = (e: React.KeyboardEvent) => { if ((e.ctrlKey || e.metaKey) && e.key === "Enter") { e.preventDefault(); onSubmit(); } }; return (