// PEP-10/27/53: «Новый терминал», runner settings (project / story) and a runner's stories.
import { Plus, SquareTerminal } from "lucide-react";
import {
RUNNER_CONTEXT_RU,
RUNNER_CONTEXTS,
RUNNER_MODE_RU,
RUNNER_MODES,
RUNNER_WORKSPACE_RU,
RUNNER_WORKSPACES,
RUNNER_ISOLATION_RU,
RUNNER_ISOLATIONS,
HOST_STATUS_RU,
type RunnerHost,
type RunnerSettings,
type RunnerSettingsPatch,
type RunnerTaskView,
type SessionView,
} from "@peppa/core";
import { promoteRunnerAction, queueOnRunnerAction, renameRunnerAction, setRunnerSettingsAction, startFreeRunnerAction } from "@/app/(app)/actions";
import { Hidden } from "@/components/cards";
import { Key, StatusBadge } from "@/components/common";
import { PanelSection } from "@/components/ActivityAside";
import { Button } from "@/components/ui/button";
import { Input, Label, NativeSelect, Textarea } from "@/components/ui/input";
import { VoiceInput } from "@/components/VoiceInput";
import { getT } from "@/lib/i18n";
import { m, type Translator } from "@peppa/shared/i18n";
/** Free runner form: project (or fixed), name, agent, prompt with voice input. */
export async function NewRunnerForm({ projects, projectId, back }: { projects?: Array<{ id: number; key: string; name: string }>; projectId?: number; back: string }) {
const t = await getT();
const promptId = `runner-prompt-${projectId ?? "any"}`;
return (
);
}
const inherit = (t: Translator, label: string) => t("Как выше: {label}", { label: t(label) });
/** «⋯ Настройки проекта → Раннеры»: overrides of the project; empty = system. */
export async function RunnerSettingsPanel({ projectId, own, inherited, back, hosts = [] }: { projectId: number; own: RunnerSettingsPatch; inherited: RunnerSettings; back: string; hosts?: Pick[] }) {
const t = await getT();
const hostNames = (ids: number[]) => (ids.length ? ids.map((id) => hosts.find((h) => h.id === id)?.name ?? `#${id}`).join(", ") : m("Mac FORGE"));
return (
);
}
/** Story page: mode/context for this story only. */
export async function TaskRunnerSettings({ taskKey, own, inherited, back }: { taskKey: string; own: { mode?: string; context?: string }; inherited: RunnerSettings; back: string }) {
const t = await getT();
return (
);
}
/** Runner details: name, stories (history and queue), «Оформить стори» for a free runner. */
export async function RunnerStories({ s, history, queue, back }: { s: SessionView; history: RunnerTaskView[]; queue: RunnerTaskView[]; back: string }) {
const t = await getT();
const alive = !["done", "failed"].includes(s.status);
return (
<>
{s.workspacePath && worktree: {s.workspacePath}
}
{!s.taskId && (
)}
{(history.length > 0 || queue.length > 0 || (alive && s.taskId)) && (
{queue.map((r) => (
-
{r.front ? t("в очереди (первой)") : t("в очереди")}
{r.taskKey}
{r.taskTitle}
))}
{history.map((r) => (
-
{r.status === "active" ? t("ведёт") : t("вёл")}
{r.taskKey}
{r.taskTitle}
))}
{alive && s.taskId && (
)}
)}
>
);
}