The run selector is the only control that gives up width, and beside the workflow list it had none left: Open and the run's version move into the one menu at every width, so the picked run stays readable from 390 to 1440. Step editor and binding fields take the next rung (h-8) so they match the selects and switches they sit beside.
563 lines
27 KiB
Vue
563 lines
27 KiB
Vue
<script setup lang="ts">
|
|
import {
|
|
AlertDialog,
|
|
AlertDialogAction,
|
|
AlertDialogCancel,
|
|
AlertDialogContent,
|
|
AlertDialogFooter,
|
|
AlertDialogHeader,
|
|
AlertDialogTitle,
|
|
} from "@/components/ui/alert-dialog";
|
|
import { computed, onBeforeUnmount, ref, watch } from "vue";
|
|
import { CircleAlert, Ellipsis, RotateCcw, Trash2 } from "@lucide/vue";
|
|
|
|
import { Button } from "@/components/ui/button";
|
|
import {
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuItem,
|
|
DropdownMenuTrigger,
|
|
} from "@/components/ui/dropdown-menu";
|
|
import { Spinner } from "@/components/ui/spinner";
|
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
|
import { Textarea } from "@/components/ui/textarea";
|
|
import StepRun from "./StepRun.vue";
|
|
import { restartAt, withRuns, workflowGraph } from "./workflow-graph";
|
|
import { api } from "@/lib/api";
|
|
import StepEditor from "./StepEditor.vue";
|
|
import WorkflowSettings from "./WorkflowSettings.vue";
|
|
import TriggerSettings from "./TriggerSettings.vue";
|
|
import OptionSelect from "./OptionSelect.vue";
|
|
import RunWorkflowButton from "./RunWorkflowButton.vue";
|
|
import TaskRowActions from "@/tasks/TaskRowActions.vue";
|
|
import WorkflowCanvas from "./WorkflowCanvas.vue";
|
|
import WorkflowHistory from "./WorkflowHistory.vue";
|
|
import { useWorkflowHistory } from "./workflow-history";
|
|
import { revisionOfRun, type WorkflowRevision } from "./workflow-revisions";
|
|
import { deleteStep, duplicateStep, insertStep, moveStep, replaceStep, revertWorkflowChange, stepAt, workflowChanges, workflowField, type StepPath } from "./workflow-edit";
|
|
import ChangeList from "@/components/ChangeList.vue";
|
|
import CoBuilder from "./CoBuilder.vue";
|
|
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog";
|
|
import { useWorkflowRuns } from "./workflow-runs";
|
|
import { useWorkflowTriggers } from "./workflow-triggers";
|
|
import { useSettingsStore } from "@/stores/settings";
|
|
import {
|
|
removeWorkflowDefinition,
|
|
upsertWorkflowDefinition,
|
|
useWorkflowsStore,
|
|
type WorkflowDefinitionCollection,
|
|
} from "@/stores/workflows";
|
|
import {
|
|
parseWorkflowYaml,
|
|
settingsProblem,
|
|
stepControlsProblem,
|
|
validationLabel,
|
|
yamlLines,
|
|
yamlTokenClass,
|
|
} from "./workflow-yaml";
|
|
|
|
const store = useSettingsStore();
|
|
const workflows = useWorkflowsStore();
|
|
const state = computed(() => workflows.state);
|
|
// Chat and agent aliases: embedding and transcription have their own purposes.
|
|
const modelAliases = computed(() =>
|
|
Object.keys((store.stateFor("model-aliases").resource?.value ?? {}) as Record<string, string>)
|
|
.filter((alias) => alias !== "embedding" && alias !== "transcription")
|
|
.sort(),
|
|
);
|
|
const collection = computed(() => workflows.collection);
|
|
// Which definition is open belongs to the page, which also lists them.
|
|
const selected = defineModel<string>("selected", { required: true });
|
|
defineProps<{ runsCount?: number }>();
|
|
const id = ref("");
|
|
const yaml = ref("");
|
|
const loadedYaml = ref("");
|
|
// The one card open in place: "workflow", "start", or a step's path as JSON.
|
|
const open = ref<string | null>(null);
|
|
const openPath = computed<StepPath | null>(() => (open.value?.startsWith("[") ? (JSON.parse(open.value) as StepPath) : null));
|
|
function openStepAt(path: StepPath | null): void {
|
|
open.value = path ? JSON.stringify(path) : null;
|
|
}
|
|
const localError = ref("");
|
|
|
|
const { runs, error: runsError, loading: runsLoading, watched, watchedRun, stages, attempt, pick, follow, refresh } = useWorkflowRuns(selected);
|
|
const stepTab = ref("definition");
|
|
const graph = computed(() => withRuns(workflowGraph(yaml.value), stages.value));
|
|
function toggle(key: string): void {
|
|
open.value = open.value === key ? null : key;
|
|
const run = graph.value.nodes.find((node) => JSON.stringify(node.data.path ?? null) === open.value)?.data.run;
|
|
stepTab.value = run && watchedRun.value ? "run" : "definition";
|
|
}
|
|
watch(watched, () => { open.value = null; restartError.value = ""; });
|
|
|
|
// A parked run restarts at a step through the retry action, keeping the
|
|
// results of the steps before it.
|
|
const restartable = computed(() => watchedRun.value?.status === "parked");
|
|
const openRestart = computed(() => restartable.value && openPath.value ? restartAt(graph.value, openPath.value) : null);
|
|
const restarting = ref(false);
|
|
const restartError = ref("");
|
|
async function restartFrom(from: string): Promise<void> {
|
|
restartError.value = "";
|
|
restarting.value = true;
|
|
try {
|
|
await api.taskAction(watched.value, "retry", { resume_from: from });
|
|
await refresh();
|
|
} catch (err) {
|
|
restartError.value = err instanceof Error ? err.message : "Restart failed";
|
|
} finally {
|
|
restarting.value = false;
|
|
}
|
|
}
|
|
const { triggers, reload: reloadTriggers } = useWorkflowTriggers(selected);
|
|
|
|
const { revisions, error: historyError } = useWorkflowHistory(selected);
|
|
const historyRevision = ref(0);
|
|
const historyMode = ref("yaml");
|
|
// The revision a run used, matched by the definition it pinned.
|
|
function runRevision(run?: { workflow_definition_yaml?: string; created_at?: string }): WorkflowRevision | undefined {
|
|
return run ? revisionOfRun(revisions.value, run.workflow_definition_yaml, run.created_at) : undefined;
|
|
}
|
|
const watchedRevision = computed(() => runRevision(watchedRun.value));
|
|
function openRevision(version: number): void {
|
|
historyRevision.value = version;
|
|
view.value = "history";
|
|
}
|
|
// A restored version becomes the draft: nothing runs it until Publish.
|
|
function restoreRevision(restored: string): void {
|
|
yaml.value = restored;
|
|
open.value = null;
|
|
view.value = "canvas";
|
|
}
|
|
|
|
// Canvas edits are edits to the YAML; a newly placed step opens for editing.
|
|
const stepTypeNames = computed(() => vocabulary.value.map((info) => info.name));
|
|
function insertAt(after: StepPath, type: string): void {
|
|
stepTab.value = "definition";
|
|
const inserted = insertStep(yaml.value, after, type);
|
|
yaml.value = inserted.source;
|
|
openStepAt(inserted.path);
|
|
}
|
|
function duplicateAt(path: StepPath): void {
|
|
stepTab.value = "definition";
|
|
const copied = duplicateStep(yaml.value, path);
|
|
yaml.value = copied.source;
|
|
openStepAt(copied.path);
|
|
}
|
|
function moveAt(path: StepPath, delta: -1 | 1): void {
|
|
const moved = moveStep(yaml.value, path, delta);
|
|
yaml.value = moved.source;
|
|
if (openPath.value) openStepAt(moved.path);
|
|
}
|
|
function removeAt(path: StepPath): void {
|
|
yaml.value = deleteStep(yaml.value, path);
|
|
open.value = null;
|
|
}
|
|
function renameAt(path: StepPath, name: string): void {
|
|
const { id: _id, type, ...rest } = stepAt(yaml.value, path) ?? {};
|
|
yaml.value = replaceStep(yaml.value, path, { id: name || undefined, type, ...rest });
|
|
}
|
|
|
|
function load(value: string): void {
|
|
const entry = collection.value.definitions.find(
|
|
(candidate) => candidate.id === value,
|
|
);
|
|
id.value = entry?.id ?? value;
|
|
yaml.value = workflows.drafts.find((draft) => draft.id === value)?.yaml ?? entry?.yaml ?? `id: ${value}\nsteps: []\n`;
|
|
loadedYaml.value = yaml.value;
|
|
open.value = null;
|
|
localError.value = "";
|
|
}
|
|
|
|
watch(selected, load, { immediate: true });
|
|
// The collection arrives after the first render; a later live update must not
|
|
// overwrite what is being typed, so it only refreshes an editor with no local edits.
|
|
watch([collection, () => workflows.drafts], () => {
|
|
const incoming =
|
|
workflows.drafts.find((draft) => draft.id === selected.value) ??
|
|
collection.value.definitions.find((entry) => entry.id === selected.value);
|
|
if (incoming && yaml.value === loadedYaml.value && incoming.yaml !== loadedYaml.value) load(selected.value);
|
|
});
|
|
|
|
// Every edit lands in the workflow's draft shortly after it is made, so work
|
|
// survives a reload and nothing reaches the running workflow until Publish.
|
|
// A draft equal to the published definition is removed.
|
|
let pending: ReturnType<typeof setTimeout> | undefined;
|
|
async function persistDraft(target: string, value: string): Promise<void> {
|
|
if (!target) return;
|
|
const published = collection.value.definitions.find((entry) => entry.id === target)?.yaml ?? "";
|
|
const current = workflows.drafts.find((draft) => draft.id === target)?.yaml;
|
|
const next = value === published ? undefined : value;
|
|
if (next === current) return;
|
|
if (await workflows.putDraft(target, next)) {
|
|
if (target === selected.value && value === yaml.value) loadedYaml.value = value;
|
|
} else if (workflows.draftState.saving) {
|
|
pending = setTimeout(() => void persistDraft(target, value), 500);
|
|
}
|
|
}
|
|
// The last edit not yet written, flushed at once when the editor switches
|
|
// workflow so the switch cannot drop it.
|
|
let unsaved: { target: string; value: string } | undefined;
|
|
watch(yaml, (value) => {
|
|
clearTimeout(pending);
|
|
if (unsaved && unsaved.target !== selected.value) void persistDraft(unsaved.target, unsaved.value);
|
|
const edit = (unsaved = { target: selected.value, value });
|
|
pending = setTimeout(() => {
|
|
unsaved = undefined;
|
|
void persistDraft(edit.target, edit.value);
|
|
}, 800);
|
|
});
|
|
onBeforeUnmount(() => {
|
|
clearTimeout(pending);
|
|
void persistDraft(selected.value, yaml.value);
|
|
});
|
|
async function dropDraft(target: string): Promise<void> {
|
|
clearTimeout(pending);
|
|
unsaved = undefined;
|
|
await workflows.putDraft(target, undefined);
|
|
}
|
|
// Edits made while Archie works would be overwritten by its draft, so the
|
|
// editor is locked until the turn ends.
|
|
const archieWorking = ref(false);
|
|
// Archie works from the saved draft, so pending edits are written first.
|
|
async function flushDraft(): Promise<void> {
|
|
clearTimeout(pending);
|
|
unsaved = undefined;
|
|
await persistDraft(selected.value, yaml.value);
|
|
}
|
|
// Archie's draft replaces what the editor shows; the review then lists its
|
|
// changes against the published workflow.
|
|
async function takeProposal(): Promise<void> {
|
|
await workflows.reloadDrafts();
|
|
const draft = workflows.drafts.find((entry) => entry.id === selected.value)?.yaml;
|
|
if (draft === undefined || draft === yaml.value) return;
|
|
clearTimeout(pending);
|
|
unsaved = undefined;
|
|
load(selected.value);
|
|
}
|
|
// Back to the published definition: the draft is dropped, not merged.
|
|
async function restorePublished(): Promise<void> {
|
|
await dropDraft(selected.value);
|
|
load(selected.value);
|
|
}
|
|
|
|
async function save(next: WorkflowDefinitionCollection): Promise<boolean> {
|
|
localError.value = "";
|
|
return workflows.save(next);
|
|
}
|
|
|
|
async function publish(): Promise<void> {
|
|
// The id is the one the YAML declares; renaming is editing it there.
|
|
const nextID = parsed.value.ok ? parsed.value.id : "";
|
|
if (!nextID) return;
|
|
const previous = selected.value;
|
|
// Saving replaces the entry with that id, so a rename onto another
|
|
// workflow's id would silently overwrite it.
|
|
if (previous !== nextID && collection.value.definitions.some((entry) => entry.id === nextID)) {
|
|
localError.value = `A workflow with id "${nextID}" already exists; choose another id.`;
|
|
return;
|
|
}
|
|
let next = collection.value;
|
|
if (previous && previous !== nextID)
|
|
next = removeWorkflowDefinition(next, previous);
|
|
if (
|
|
await save(upsertWorkflowDefinition(next, { id: nextID, yaml: yaml.value }))
|
|
) {
|
|
await dropDraft(previous);
|
|
if (previous !== nextID) await dropDraft(nextID);
|
|
selected.value = nextID;
|
|
loadedYaml.value = yaml.value;
|
|
}
|
|
}
|
|
|
|
// The run and draft dialogs are opened from the one toolbar menu when the row
|
|
// has no button for them; each block and its menu item drive one flag.
|
|
const runOpen = ref(false);
|
|
const draftOpen = ref(false);
|
|
const confirmDelete = ref(false);
|
|
async function remove(): Promise<void> {
|
|
if (!selected.value) return;
|
|
if (
|
|
!(await save(removeWorkflowDefinition(collection.value, selected.value)))
|
|
)
|
|
return;
|
|
await dropDraft(selected.value);
|
|
selected.value = "";
|
|
id.value = "";
|
|
yaml.value = "";
|
|
}
|
|
|
|
// What is typed, read against the served step vocabulary (workflow-yaml.ts).
|
|
// The Steps preview, the gutter and the validity indicator are three readings
|
|
// of one parse, so they cannot disagree about the same text. Step settings are
|
|
// not served, so a save the server refuses still reports its own reason below.
|
|
const vocabulary = computed(() => workflows.stepTypes);
|
|
const parsed = computed(() => parseWorkflowYaml(yaml.value, vocabulary.value));
|
|
const stored = computed(() => collection.value.definitions.find((entry) => entry.id === selected.value)?.yaml);
|
|
const dirty = computed(() => yaml.value !== (stored.value ?? ""));
|
|
const changes = computed(() => (dirty.value ? workflowChanges(stored.value ?? "", yaml.value) : []));
|
|
const view = ref("canvas");
|
|
// What each step lacks, read the way its editor reads it.
|
|
const problems = computed(() =>
|
|
Object.fromEntries(
|
|
graph.value.nodes.flatMap((node) => {
|
|
const path = node.data.path;
|
|
const step = path && stepAt(yaml.value, path);
|
|
if (!step) return [];
|
|
const schema = vocabulary.value.find((info) => info.name === step.type)?.settings;
|
|
const problem = stepControlsProblem(step) || (schema && step.settings ? settingsProblem(step.settings, schema, "settings") : "");
|
|
return problem ? [[JSON.stringify(path), problem]] : [];
|
|
}),
|
|
),
|
|
);
|
|
const WORKS_ON: Record<string, string> = { optional: "Repository if given", none: "No repository" };
|
|
const REQUIRED = "Works on a repository";
|
|
const workflowSummary = computed(() =>
|
|
[WORKS_ON[String(workflowField(yaml.value, "repository") ?? "")] ?? REQUIRED, workflowField(yaml.value, "profile")].filter(Boolean).join(" · "),
|
|
);
|
|
const runOptions = computed(() => [
|
|
{ value: "", label: "Definition only" },
|
|
...runs.value.map((run) => ({
|
|
value: String(run.id),
|
|
label: [`${run.source === "test" ? "Test" : "Run"} #${run.id}`, run.title, run.status, runRevision(run) ? `v${runRevision(run)!.version}` : ""].filter(Boolean).join(" · "),
|
|
})),
|
|
]);
|
|
const lines = computed(() => yamlLines(yaml.value));
|
|
// The sections that sit beside Canvas and YAML once the editor has the width
|
|
// for them (the workflow list takes 24rem of it), and otherwise the one menu,
|
|
// which names the section in view beside the tabs.
|
|
const SECTIONS: Record<string, string> = { history: "History", performance: "Performance", runs: "Runs" };
|
|
|
|
// The highlight layer sits behind the textarea and never scrolls by itself, so
|
|
// it follows the textarea's own scroll on both axes.
|
|
const scrolled = ref({ top: 0, left: 0 });
|
|
function syncScroll(event: Event): void {
|
|
const { scrollTop, scrollLeft } = event.target as HTMLTextAreaElement;
|
|
scrolled.value = { top: scrollTop, left: scrollLeft };
|
|
}
|
|
|
|
</script>
|
|
|
|
<template>
|
|
<form class="space-y-4" @submit.prevent="publish">
|
|
<Tabs v-model="view" class="space-y-1.5">
|
|
<!--
|
|
Two rows at every width: the page header above names the workflow, and
|
|
this row is one toolbar. The tabs hold the views that fit, the run
|
|
selector and the actions share the right end, and everything else is in
|
|
the single menu beside Publish. Nothing wraps: the run selector gives up
|
|
width first.
|
|
-->
|
|
<div class="flex items-center gap-2">
|
|
<TabsList class="shrink-0 justify-start">
|
|
<TabsTrigger value="canvas">Canvas</TabsTrigger>
|
|
<TabsTrigger value="yaml">YAML</TabsTrigger>
|
|
<TabsTrigger v-if="stored !== undefined" value="history" class="max-xl:hidden">History</TabsTrigger>
|
|
<TabsTrigger v-if="$slots.performance" value="performance" class="max-xl:hidden">Performance</TabsTrigger>
|
|
<TabsTrigger v-if="$slots.runs" value="runs" class="max-xl:hidden">Runs <span class="ml-1 font-mono text-xs text-fg-subtle">{{ runsCount ?? 0 }}</span></TabsTrigger>
|
|
</TabsList>
|
|
<span v-if="SECTIONS[view]" class="shrink-0 text-xs font-medium text-fg-muted xl:hidden">{{ SECTIONS[view] }}</span>
|
|
<div class="ml-auto flex min-w-0 items-center gap-1">
|
|
<div v-if="runs.length && view === 'canvas'" class="flex min-w-0 items-center gap-1">
|
|
<OptionSelect :model-value="watched" :options="runOptions" aria-label="Run shown on the canvas" class="min-w-0 max-w-24 sm:max-w-56" @update:model-value="pick" />
|
|
<template v-if="watchedRun">
|
|
<!-- One run control keeps the row short; the run's other actions
|
|
are on the run, behind Open run in this menu. -->
|
|
<TaskRowActions :task="watchedRun" :only="watchedRun.actions?.slice(0, 1)" class="max-md:hidden" @done="refresh" />
|
|
</template>
|
|
</div>
|
|
<span v-if="!parsed.ok" class="hidden max-w-md truncate text-xs text-danger sm:block" role="status" :title="validationLabel(parsed)">{{ validationLabel(parsed) }}</span>
|
|
<span v-if="!parsed.ok" class="sm:hidden" role="status" :title="validationLabel(parsed)">
|
|
<CircleAlert class="size-4 text-danger" aria-hidden="true" /><span class="sr-only">{{ validationLabel(parsed) }}</span>
|
|
</span>
|
|
<!-- The dialog is teleported, so hiding this wrapper below sm hides the
|
|
trigger only and leaves the one dialog reachable from the menu. -->
|
|
<div v-if="stored !== undefined && (view === 'canvas' || view === 'yaml')" class="max-sm:hidden">
|
|
<RunWorkflowButton
|
|
v-model:open="runOpen"
|
|
:workflow="selected"
|
|
:draft="dirty ? yaml : undefined"
|
|
:disabled="!parsed.ok"
|
|
@started="(id) => { view = 'canvas'; void follow(id); }"
|
|
/>
|
|
</div>
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger as-child>
|
|
<Button type="button" variant="ghost" size="icon-sm" aria-label="More"><Ellipsis /></Button>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent align="end" class="w-48">
|
|
<DropdownMenuItem v-if="stored !== undefined" class="xl:hidden" @select="view = 'history'">History</DropdownMenuItem>
|
|
<DropdownMenuItem v-if="$slots.performance" class="xl:hidden" @select="view = 'performance'">Performance</DropdownMenuItem>
|
|
<DropdownMenuItem v-if="$slots.runs" class="xl:hidden" @select="view = 'runs'">Runs <span class="ml-auto font-mono text-xs text-fg-subtle">{{ runsCount ?? 0 }}</span></DropdownMenuItem>
|
|
<!-- The run's page and the version it pinned are menu items, not
|
|
row controls: the row keeps the width for the picked run. -->
|
|
<DropdownMenuItem v-if="watchedRun" as-child><RouterLink :to="`/tasks/${watchedRun.id}`">Open run</RouterLink></DropdownMenuItem>
|
|
<DropdownMenuItem v-if="watchedRevision" @select="openRevision(watchedRevision.version)">Version {{ watchedRevision.version }}</DropdownMenuItem>
|
|
<DropdownMenuItem v-if="stored !== undefined && (view === 'canvas' || view === 'yaml')" class="sm:hidden" :disabled="!parsed.ok" @select="runOpen = true">{{ dirty ? "Test" : "Run" }}</DropdownMenuItem>
|
|
<DropdownMenuItem v-if="dirty" @select="draftOpen = true">Draft changes <span class="ml-auto font-mono text-xs text-fg-subtle">{{ changes.length }}</span></DropdownMenuItem>
|
|
<DropdownMenuItem v-if="dirty" :disabled="archieWorking" @select="restorePublished"><RotateCcw />Restore</DropdownMenuItem>
|
|
<DropdownMenuItem v-if="view === 'canvas' || view === 'yaml'" variant="destructive" @select="confirmDelete = true"><Trash2 />Delete workflow</DropdownMenuItem>
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
<Button v-if="view === 'canvas' || view === 'yaml'" type="submit" size="sm" :disabled="state.saving || !parsed.ok || !dirty || archieWorking">
|
|
<Spinner v-if="state.saving" data-icon="inline-start" />Publish</Button>
|
|
</div>
|
|
</div>
|
|
<p v-if="runsLoading && !runs.length" class="text-xs text-fg-muted" role="status">Loading recent runs…</p>
|
|
<div v-else-if="runsError" class="text-sm text-danger" role="alert">
|
|
<p>Could not load recent runs: {{ runsError }}</p>
|
|
<Button type="button" variant="outline" size="sm" @click="refresh">Retry runs</Button>
|
|
</div>
|
|
<p v-if="view === 'canvas' && watchedRun && !watchedRun.workflow_definition_yaml" class="text-xs text-fg-muted" role="status">No workflow snapshot was recorded for this run.</p>
|
|
<!-- Kept mounted so an Archie turn started here still finishes, unlocks the
|
|
editor and loads its draft when the operator switches tabs. -->
|
|
<TabsContent value="canvas" force-mount class="space-y-2 data-[state=inactive]:hidden">
|
|
<!-- The canvas takes the height the viewport has left, so the page
|
|
itself does not scroll; the canvas pans. A phone stacks the run
|
|
selector over the step tooling, hence the larger offset below md. -->
|
|
<div class="relative flex h-[calc(100dvh-17rem)] min-h-[26rem] flex-col max-md:h-[calc(100dvh-22rem)] max-md:min-h-[23rem]">
|
|
<p v-if="restartError" role="alert" class="absolute bottom-16 left-14 z-10 max-w-xl rounded-md border border-danger/40 bg-card px-3 py-2 text-sm text-danger shadow-lg">{{ restartError }}</p>
|
|
<WorkflowCanvas
|
|
class="h-auto min-h-0 flex-1"
|
|
:inert="archieWorking"
|
|
:yaml="yaml"
|
|
:stages="stages"
|
|
:open="open"
|
|
:triggers="triggers"
|
|
:types="stepTypeNames"
|
|
:restartable="restartable"
|
|
:problems="problems"
|
|
:title="parsed.ok ? parsed.id : id"
|
|
:summary="workflowSummary"
|
|
@toggle="toggle"
|
|
@restart="restartFrom"
|
|
@insert="insertAt"
|
|
@duplicate="duplicateAt"
|
|
@move="moveAt"
|
|
@remove="removeAt"
|
|
@rename="renameAt"
|
|
>
|
|
<template #body="{ data }">
|
|
<WorkflowSettings v-if="data.kind === 'workflow'" v-model:yaml="yaml" />
|
|
<TriggerSettings v-else-if="data.kind === 'start'" v-model:yaml="yaml" :triggers="triggers" @bound="reloadTriggers" />
|
|
<template v-else-if="data.path">
|
|
<div v-if="data.run && watchedRun" class="flex items-center gap-2 border-b border-border px-3 py-2">
|
|
<Tabs v-model="stepTab"><TabsList><TabsTrigger value="run">Run</TabsTrigger><TabsTrigger value="definition">Definition</TabsTrigger></TabsList></Tabs>
|
|
<Button v-if="openRestart" type="button" size="sm" variant="outline" class="ml-auto" :disabled="restarting || openRestart.blocked" @click="restartFrom(openRestart.from)"><RotateCcw />{{ openRestart.label }}</Button>
|
|
</div>
|
|
<div v-if="data.run && watchedRun && stepTab === 'run'" class="max-h-[32rem] overflow-y-auto">
|
|
<StepRun :task="watchedRun" :attempt="attempt" :stage="data.run" :stages="stages" />
|
|
</div>
|
|
<StepEditor
|
|
v-else
|
|
:key="open ?? ''"
|
|
v-model:yaml="yaml"
|
|
:workflows="collection.definitions"
|
|
:path="data.path"
|
|
:vocabulary="vocabulary"
|
|
:model-aliases="modelAliases"
|
|
/>
|
|
</template>
|
|
</template>
|
|
</WorkflowCanvas>
|
|
<!-- Below the canvas rather than over it: nodes run to the bottom edge,
|
|
so a floating bar hid the last step. -->
|
|
<div class="flex justify-center px-3 pt-2 max-md:pr-16">
|
|
<CoBuilder
|
|
v-if="selected"
|
|
:key="selected"
|
|
:workflow="selected"
|
|
:empty="!parsed.ok || parsed.steps.length === 0"
|
|
:before-send="flushDraft"
|
|
@proposed="takeProposal"
|
|
@working="(value) => (archieWorking = value)"
|
|
/>
|
|
</div>
|
|
</div>
|
|
</TabsContent>
|
|
<TabsContent value="history">
|
|
<WorkflowHistory v-model:selected="historyRevision" v-model:mode="historyMode" :revisions="revisions" :current="yaml" :error="historyError" @restore="restoreRevision" />
|
|
</TabsContent>
|
|
<TabsContent value="performance" class="grid gap-4"><slot name="performance" /></TabsContent>
|
|
<TabsContent value="runs"><slot name="runs" /></TabsContent>
|
|
<TabsContent value="yaml" :inert="archieWorking">
|
|
<!--
|
|
A gutter and a highlighted layer behind the live textarea, so the YAML
|
|
is numbered and coloured where it is edited rather than in a second,
|
|
read-only pane beside it. The layer is aria-hidden and never focusable:
|
|
the textarea in front of it stays the only thing the operator and a
|
|
screen reader reach.
|
|
-->
|
|
<div
|
|
class="relative overflow-hidden rounded-lg border border-input font-mono text-[13px] leading-6 focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50"
|
|
>
|
|
<div
|
|
aria-hidden="true"
|
|
class="pointer-events-none absolute inset-y-0 left-0 w-11 select-none overflow-hidden border-r border-border bg-secondary/40 py-3 text-right"
|
|
>
|
|
<div :style="`transform:translateY(${-scrolled.top}px)`">
|
|
<div
|
|
v-for="line in lines"
|
|
:key="line.number"
|
|
class="min-h-6 pr-2 text-fg-subtle"
|
|
>{{ line.number }}</div
|
|
>
|
|
</div>
|
|
</div>
|
|
<!-- Clipped to the right of the gutter, so a line scrolled left never
|
|
paints over the numbers. -->
|
|
<div
|
|
aria-hidden="true"
|
|
class="pointer-events-none absolute inset-y-0 right-0 left-11 overflow-hidden py-3 pr-3 pl-3 whitespace-pre"
|
|
>
|
|
<div :style="`transform:translate(${-scrolled.left}px,${-scrolled.top}px)`">
|
|
<div v-for="line in lines" :key="line.number" class="min-h-6">
|
|
<span
|
|
v-for="(token, i) in line.tokens"
|
|
:key="i"
|
|
:class="yamlTokenClass(token.kind)"
|
|
>{{ token.text }}</span
|
|
>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<Textarea
|
|
id="workflow-yaml"
|
|
aria-label="Workflow YAML"
|
|
v-model="yaml"
|
|
name="workflow-yaml"
|
|
required
|
|
class="relative min-h-96 resize-y rounded-none border-0 bg-transparent py-3 pr-3 pl-14 text-[13px] leading-6 text-transparent caret-foreground shadow-none md:text-[13px] focus-visible:ring-0"
|
|
spellcheck="false"
|
|
wrap="off"
|
|
@scroll="syncScroll"
|
|
/>
|
|
</div>
|
|
</TabsContent>
|
|
</Tabs>
|
|
<p v-if="localError || state.error" class="text-sm text-danger" role="alert">
|
|
{{ localError || state.error }}
|
|
</p>
|
|
<Dialog v-model:open="draftOpen">
|
|
<DialogContent class="sm:max-w-lg">
|
|
<DialogHeader>
|
|
<DialogTitle>Draft changes</DialogTitle>
|
|
</DialogHeader>
|
|
<div class="max-h-96 overflow-y-auto rounded-md border border-border">
|
|
<ChangeList :changes="changes" @revert="(change) => (yaml = revertWorkflowChange(yaml, change))" />
|
|
</div>
|
|
</DialogContent>
|
|
</Dialog>
|
|
<AlertDialog v-model:open="confirmDelete">
|
|
<AlertDialogContent>
|
|
<AlertDialogHeader>
|
|
<AlertDialogTitle>Delete the {{ selected }} workflow?</AlertDialogTitle>
|
|
</AlertDialogHeader>
|
|
<AlertDialogFooter>
|
|
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
|
<AlertDialogAction variant="destructive" @click="remove">Delete</AlertDialogAction>
|
|
</AlertDialogFooter>
|
|
</AlertDialogContent>
|
|
</AlertDialog>
|
|
</form>
|
|
</template>
|