feat(ui): History is the workflow's YAML editor, marking changes since the picked version; the YAML tab goes
A never-run workflow's Runs view shows one empty state. Browser checks open the editor through History; the stale parts are #1966.
This commit is contained in:
7 files changed
+142
-138
No files matched your search
@@ -30,12 +30,12 @@ module.exports = async ({ page, go, shot, settled }) => {
|
||||
definition.yaml = definition.yaml.replace(/\bid: assess\b/, 'id: Write a Product Requirement Document').replaceAll('steps.assess.', 'steps.Write a Product Requirement Document.');
|
||||
await page.route('**/api/control-plane/resources/workflow-definitions', route => route.fulfill({ json: resource }));
|
||||
await go('/workflows?workflow=feasibility');
|
||||
await page.getByRole('tab', { name: 'YAML', exact: true }).click();
|
||||
await page.getByRole('tab', { name: 'History', exact: true }).click();
|
||||
const yaml = await page.getByLabel('Workflow YAML', { exact: true }).inputValue();
|
||||
assert.ok(yaml.includes('id: write-a-product-requirement-document'));
|
||||
assert.ok(yaml.includes('steps.write-a-product-requirement-document.result'));
|
||||
assert.ok(!yaml.includes('steps.Write a Product Requirement Document'));
|
||||
await page.getByRole('tab', { name: 'Canvas', exact: true }).click();
|
||||
await page.getByRole('tab', { name: 'Canvas', exact: true }).first().click();
|
||||
const approval = page.locator('.vue-flow__node').filter({ hasText: 'Approval' }).first();
|
||||
await panTo(approval);
|
||||
await approval.click();
|
||||
@@ -44,10 +44,10 @@ module.exports = async ({ page, go, shot, settled }) => {
|
||||
await chip.click();
|
||||
await shot('legacy-reference');
|
||||
await page.keyboard.press('Escape');
|
||||
await page.getByRole('tab', { name: 'YAML', exact: true }).click();
|
||||
await page.getByRole('tab', { name: 'History', exact: true }).click();
|
||||
const field = page.getByLabel('Workflow YAML', { exact: true });
|
||||
await field.fill((await field.inputValue()).replace('type: repo.prepare', 'type: repo.prepare\n when: not-a-valid-expression'));
|
||||
await page.getByRole('tab', { name: 'Canvas', exact: true }).click();
|
||||
await page.getByRole('tab', { name: 'Canvas', exact: true }).first().click();
|
||||
const problem = page.locator('.vue-flow__node').filter({ hasText: 'Prepare worktree' }).first().locator('svg.text-danger');
|
||||
await problem.waitFor();
|
||||
const toolbarProblem = page.getByRole('status').filter({ has: page.locator('svg') });
|
||||
@@ -105,14 +105,14 @@ module.exports = async ({ page, go, shot, settled }) => {
|
||||
await target.press('Home');
|
||||
await shot('dynamic-handoff');
|
||||
await page.keyboard.press('Escape');
|
||||
await page.getByRole('tab', { name: 'YAML', exact: true }).click();
|
||||
await page.getByRole('tab', { name: 'History', exact: true }).click();
|
||||
assert.ok((await page.getByLabel('Workflow YAML', { exact: true }).inputValue()).includes('steps.classify.result.alternative'));
|
||||
await page.getByRole('tab', { name: 'Canvas', exact: true }).click();
|
||||
await page.getByRole('tab', { name: 'Canvas', exact: true }).first().click();
|
||||
await panTo(handoff);
|
||||
await handoff.click();
|
||||
await target.fill('implement');
|
||||
await page.keyboard.press('Escape');
|
||||
await page.keyboard.press('Escape');
|
||||
await page.getByRole('tab', { name: 'YAML', exact: true }).click();
|
||||
await page.getByRole('tab', { name: 'History', exact: true }).click();
|
||||
assert.ok((await page.getByLabel('Workflow YAML', { exact: true }).inputValue()).includes('workflow: implement'));
|
||||
};
|
||||
@@ -31,9 +31,12 @@ module.exports = async ({ page, go, shot, settled }) => {
|
||||
left: el.getBoundingClientRect().left, right: el.getBoundingClientRect().right,
|
||||
})));
|
||||
assert.ok(nodes.every(node => node.left >= box.x && node.right <= box.x + box.width), 'branch lanes clipped horizontally');
|
||||
const controls = await page.getByRole('button', { name: 'Zoom in', exact: true }).boundingBox();
|
||||
const flow = await canvas.locator('.vue-flow').boundingBox();
|
||||
assert.ok(controls.y >= flow.y + flow.height, 'zoom control overlays graph');
|
||||
const controls = await page.getByRole('group', { name: 'Zoom', exact: true }).boundingBox();
|
||||
const covered = await page.locator('.vue-flow__node').evaluateAll((elements, c) => elements.some((el) => {
|
||||
const r = el.getBoundingClientRect();
|
||||
return r.left < c.x + c.width && r.right > c.x && r.top < c.y + c.height && r.bottom > c.y;
|
||||
}), controls);
|
||||
assert.ok(!covered, 'zoom controls cover a step');
|
||||
await shot(workflow);
|
||||
const step = page.locator('.vue-flow__node').filter({ hasText: 'Prepare worktree' }).first();
|
||||
assert.equal(await step.locator('[data-slot="badge"]').innerText(), 'Prepare worktree');
|
||||
@@ -53,13 +56,13 @@ module.exports = async ({ page, go, shot, settled }) => {
|
||||
}
|
||||
// YAML must not make the page scroll at phone width.
|
||||
await go('/workflows?workflow=feasibility');
|
||||
await page.getByRole('tab', { name: 'YAML', exact: true }).click();
|
||||
await page.getByRole('tab', { name: 'History', exact: true }).click();
|
||||
await settled();
|
||||
const yamlPage = await page.evaluate(() => ({
|
||||
scrollHeight: document.documentElement.scrollHeight, height: innerHeight,
|
||||
}));
|
||||
assert.equal(yamlPage.scrollHeight, yamlPage.height, 'YAML causes page scroll');
|
||||
await page.getByRole('tab', { name: 'Canvas', exact: true }).click();
|
||||
await page.getByRole('tab', { name: 'Canvas', exact: true }).first().click();
|
||||
// A pinned historical run keeps its header visible on the canvas.
|
||||
const response = await page.request.get(new URL('/api/control-plane/resources/workflow-definitions', page.url()).href);
|
||||
const resource = await response.json();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const assert = require('node:assert/strict');
|
||||
module.exports = async ({ page, go, shot }) => {
|
||||
await go('/workflows');
|
||||
await page.getByRole('button', {name:/^implement/}).click();
|
||||
await page.getByRole('button', {name:/^implement(?! actions)/}).click();
|
||||
const runPicker = page.getByRole('combobox', { name: 'Run shown on the canvas' });
|
||||
if (await runPicker.count()) { await runPicker.click(); await page.getByRole('option', { name: 'Definition', exact: true }).click(); }
|
||||
await page.locator('.vue-flow__node').filter({hasText:'Prepare worktree'}).first().click();
|
||||
@@ -17,7 +17,7 @@ module.exports = async ({ page, go, shot }) => {
|
||||
await page.getByLabel('Run only when',{exact:true}).focus();
|
||||
await page.getByText('Enter a number zero or greater.',{exact:true}).waitFor({state:'hidden'});
|
||||
await page.getByRole('combobox',{name:'Unit',exact:true}).selectOption('m');
|
||||
await page.getByRole('tab',{name:'YAML',exact:true}).click();
|
||||
await page.getByRole('tab',{name:'History',exact:true}).click();
|
||||
assert.match(await page.getByLabel('Workflow YAML',{exact:true}).inputValue(), /backoff: 30s/);
|
||||
await shot('validated');
|
||||
};
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import { computed, nextTick, onBeforeUnmount, onMounted, ref, toRef, watch } from "vue";
|
||||
import { computed, onBeforeUnmount, onMounted, ref, toRef, watch } from "vue";
|
||||
import { CircleAlert, Copy, RotateCcw, Trash2 } from "@lucide/vue";
|
||||
import { isSending, setTurnHooks } from "@/chat/state";
|
||||
|
||||
@@ -19,7 +19,6 @@ import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover
|
||||
import { Spinner } from "@/components/ui/spinner";
|
||||
import { MoreMenu } from "@/components/ui/more-menu";
|
||||
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, describeError } from "@/lib/api";
|
||||
@@ -53,8 +52,6 @@ import {
|
||||
settingsProblem,
|
||||
stepControlsProblem,
|
||||
validationLabel,
|
||||
yamlLines,
|
||||
yamlTokenClass,
|
||||
} from "./workflow-yaml";
|
||||
|
||||
const store = useSettingsStore();
|
||||
@@ -417,42 +414,6 @@ const runOptions = computed(() => [
|
||||
label: [`${run.source === "test" ? "Test" : "Run"} #${run.id}`, run.status && statusLabel(run.status), run.created_at ? ago(run.created_at) : ""].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.
|
||||
|
||||
// The highlight layer sits behind the textarea and never scrolls by itself, so
|
||||
// it follows the textarea's own scroll. Lines wrap at the editor's width, and
|
||||
// each wrapped line's gutter cell lists a continuation mark per extra row, so
|
||||
// the numbers still count lines of the file. A row's wrapped height is measured
|
||||
// from the layer, which breaks exactly where the textarea does.
|
||||
const scrolled = ref({ top: 0 });
|
||||
const scrollbar = ref(0);
|
||||
const rowEls = ref<HTMLElement[]>([]);
|
||||
const wraps = ref<number[]>([]);
|
||||
const yamlBox = ref<InstanceType<typeof Textarea> | null>(null);
|
||||
function syncScroll(event: Event): void {
|
||||
scrolled.value = { top: (event.target as HTMLTextAreaElement).scrollTop };
|
||||
}
|
||||
function measureWraps(): void {
|
||||
const field = document.getElementById("workflow-yaml");
|
||||
scrollbar.value = field ? field.offsetWidth - field.clientWidth : 0;
|
||||
wraps.value = rowEls.value.map((row) =>
|
||||
Math.max(1, Math.round(row.offsetHeight / (parseFloat(getComputedStyle(row).lineHeight) || 24))),
|
||||
);
|
||||
}
|
||||
let yamlObserver: ResizeObserver | undefined;
|
||||
watch(yamlBox, (box) => {
|
||||
yamlObserver?.disconnect();
|
||||
const field = box ? document.getElementById("workflow-yaml") : null;
|
||||
if (!field) return;
|
||||
yamlObserver = new ResizeObserver(measureWraps);
|
||||
yamlObserver.observe(field);
|
||||
});
|
||||
watch(lines, () => nextTick(measureWraps), { flush: "post" });
|
||||
onBeforeUnmount(() => yamlObserver?.disconnect());
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -464,12 +425,11 @@ onBeforeUnmount(() => yamlObserver?.disconnect());
|
||||
<div v-if="$slots.title" class="flex min-w-0 shrink items-center gap-2 max-lg:hidden"><slot name="title" /></div>
|
||||
<TabsList class="shrink-0 justify-start">
|
||||
<TabsTrigger value="canvas">Canvas</TabsTrigger>
|
||||
<TabsTrigger value="yaml">YAML</TabsTrigger>
|
||||
<TabsTrigger v-if="stored !== undefined" value="history">History</TabsTrigger>
|
||||
<TabsTrigger value="history">History</TabsTrigger>
|
||||
<TabsTrigger v-if="stored !== undefined" value="runs">Runs <span v-if="runs.length" class="ml-1 font-mono text-caption text-fg-subtle">{{ runs.length }}</span></TabsTrigger>
|
||||
</TabsList>
|
||||
<div role="group" aria-label="Runs" class="workflow-run-actions ml-auto flex min-w-0 items-center gap-1 max-sm:col-span-2 max-sm:row-start-2 max-sm:ml-0">
|
||||
<div v-if="stored !== undefined && (view === 'canvas' || view === 'yaml')" class="shrink-0">
|
||||
<div v-if="stored !== undefined && (view === 'canvas' || view === 'history')" class="shrink-0">
|
||||
<RunWorkflowButton
|
||||
v-model:open="runOpen"
|
||||
:workflow="selected"
|
||||
@@ -504,7 +464,7 @@ onBeforeUnmount(() => yamlObserver?.disconnect());
|
||||
</ul>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
<span v-if="dirty && (view === 'canvas' || view === 'yaml')" class="shrink-0" :title="publishBlocked">
|
||||
<span v-if="dirty && (view === 'canvas' || view === 'history')" class="shrink-0" :title="publishBlocked">
|
||||
<Button type="button" size="sm" class="disabled:bg-muted disabled:text-fg-muted disabled:opacity-100" :disabled="state.saving || !!publishBlocked" @click="publish">
|
||||
<Spinner v-if="state.saving" data-icon="inline-start" />Publish</Button>
|
||||
</span>
|
||||
@@ -583,69 +543,11 @@ onBeforeUnmount(() => yamlObserver?.disconnect());
|
||||
</div>
|
||||
</TabsContent>
|
||||
<TabsContent value="history" class="max-md:min-h-0 max-md:overflow-y-auto">
|
||||
<WorkflowHistory v-model:selected="historyRevision" v-model:mode="historyMode" :revisions="revisions" :current="yaml" :error="historyError" :loaded="historyLoaded" :locked="archieWorking" @restore="restoreRevision" @retry="reloadHistory" />
|
||||
<WorkflowHistory v-model:selected="historyRevision" v-model:mode="historyMode" :revisions="revisions" v-model:current="yaml" :error="historyError" :loaded="historyLoaded" :locked="archieWorking" @restore="restoreRevision" @retry="reloadHistory" />
|
||||
</TabsContent>
|
||||
<TabsContent value="runs" class="max-md:min-h-0 max-md:overflow-y-auto">
|
||||
<WorkflowRuns :runs="runs" :loading="runsLoading" :error="runsError" :stages="stageStats" :stats-known="statsKnown" :stats-error="statsError" @retry="refresh" />
|
||||
</TabsContent>
|
||||
<TabsContent value="yaml" class="max-md:min-h-0 max-md:overflow-y-auto">
|
||||
<!--
|
||||
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 max-md:h-full text-label leading-6 focus-within:border-ring focus-within:ring-3 focus-within:ring-ring"
|
||||
>
|
||||
<div
|
||||
aria-hidden="true"
|
||||
class="pointer-events-none absolute inset-y-0 left-0 w-11 select-none border-r border-border bg-secondary/40"
|
||||
></div>
|
||||
<div
|
||||
aria-hidden="true"
|
||||
class="pointer-events-none absolute inset-0 overflow-hidden py-3 pr-3"
|
||||
:style="{ paddingRight: `calc(0.75rem + ${scrollbar}px)` }"
|
||||
>
|
||||
<div :style="`transform:translateY(${-scrolled.top}px)`">
|
||||
<div
|
||||
v-for="(line, i) in lines"
|
||||
:key="line.number"
|
||||
:ref="(el) => { if (el) rowEls[i] = el as HTMLElement }"
|
||||
class="flex min-h-6"
|
||||
>
|
||||
<div class="w-11 shrink-0 select-none pr-2 text-right text-fg-subtle">
|
||||
<div>{{ line.number }}</div>
|
||||
<div v-for="n in (wraps[i] ?? 1) - 1" :key="n">↳</div>
|
||||
</div>
|
||||
<div class="max-w-[calc(var(--code-print-width)+0.75rem)] min-w-0 flex-1 pl-3 break-words whitespace-pre-wrap">
|
||||
<span
|
||||
v-for="(token, j) in line.tokens"
|
||||
:key="j"
|
||||
:class="yamlTokenClass(token.kind)"
|
||||
>{{ token.text }}</span
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<Textarea
|
||||
id="workflow-yaml"
|
||||
ref="yamlBox"
|
||||
aria-label="Workflow YAML"
|
||||
v-model="yaml"
|
||||
name="workflow-yaml"
|
||||
required
|
||||
:readonly="archieWorking"
|
||||
class="relative min-h-96 resize-y max-md:h-full max-md:min-h-0 max-md:resize-none rounded-none border-0 bg-transparent pt-3 pr-3 pb-[calc(0.75rem+var(--code-overscroll))] pl-14 text-label leading-6 break-words whitespace-pre-wrap text-transparent caret-foreground shadow-none md:text-label focus-visible:ring-0"
|
||||
spellcheck="false"
|
||||
wrap="soft"
|
||||
:style="{ maxWidth: `calc(3.5rem + var(--code-print-width) + 0.75rem + ${scrollbar}px)` }"
|
||||
@scroll="syncScroll"
|
||||
/>
|
||||
</div>
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
<Alert v-if="stepTypesMissing" variant="destructive"><AlertDescription>{{ errors.workflows.editor.stepTypesUnavailable }}</AlertDescription></Alert>
|
||||
<Alert v-if="draftConflict" variant="destructive">
|
||||
|
||||
@@ -11,9 +11,12 @@ import { ago } from "@/lib/format";
|
||||
import { Timestamp } from "@/components/ui/timestamp";
|
||||
import { cn } from "@/lib/utils";
|
||||
import WorkflowCanvas from "./WorkflowCanvas.vue";
|
||||
import { lineDiff, stepMarks, type WorkflowRevision } from "./workflow-revisions";
|
||||
import WorkflowYaml from "./WorkflowYaml.vue";
|
||||
import { stepMarks, type WorkflowRevision } from "./workflow-revisions";
|
||||
|
||||
const props = defineProps<{ revisions: WorkflowRevision[]; current: string; error?: string; loaded?: boolean; locked?: boolean }>();
|
||||
const props = defineProps<{ revisions: WorkflowRevision[]; error?: string; loaded?: boolean; locked?: boolean }>();
|
||||
/** The workflow as it is open now, edited here. */
|
||||
const current = defineModel<string>("current", { required: true });
|
||||
const emit = defineEmits<{ restore: [yaml: string]; retry: [] }>();
|
||||
const selected = defineModel<number>("selected", { default: 0 });
|
||||
const mode = defineModel<string>("mode", { default: "yaml" });
|
||||
@@ -23,17 +26,16 @@ watch(
|
||||
(revisions) => {
|
||||
if (revisions.some((revision) => revision.version === selected.value)) return;
|
||||
// Open on the newest version that differs from what is open now.
|
||||
selected.value = (revisions.find((revision) => revision.yaml !== props.current) ?? revisions[0])?.version ?? 0;
|
||||
selected.value = (revisions.find((revision) => revision.yaml !== current.value) ?? revisions[0])?.version ?? 0;
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
const revision = computed(() => props.revisions.find((candidate) => candidate.version === selected.value));
|
||||
const then = computed(() => revision.value?.yaml ?? null);
|
||||
const diff = computed(() => (then.value === null ? [] : lineDiff(then.value, props.current)));
|
||||
const identical = computed(() => then.value !== null && then.value === props.current);
|
||||
const thenMarks = computed(() => (then.value === null ? {} : stepMarks(then.value, props.current, "removed")));
|
||||
const nowMarks = computed(() => (then.value === null ? {} : stepMarks(props.current, then.value, "added")));
|
||||
const identical = computed(() => then.value !== null && then.value === current.value);
|
||||
const thenMarks = computed(() => (then.value === null ? {} : stepMarks(then.value, current.value, "removed")));
|
||||
const nowMarks = computed(() => (then.value === null ? {} : stepMarks(current.value, then.value, "added")));
|
||||
const CHANGE_VARIANTS = { added: "default", edited: "secondary", removed: "destructive" } as const;
|
||||
</script>
|
||||
|
||||
@@ -69,21 +71,15 @@ const CHANGE_VARIANTS = { added: "default", edited: "secondary", removed: "destr
|
||||
<SelectItem v-for="item in revisions" :key="item.version" :value="String(item.version)">v{{ item.version }} · {{ item.change }} · {{ item.actor || "unknown" }} · {{ ago(item.at) }}</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<div v-if="revision" class="flex min-h-0 flex-col gap-2">
|
||||
<div class="flex items-center gap-2 max-md:flex-wrap">
|
||||
<div class="flex min-h-0 flex-col gap-2">
|
||||
<div v-if="revision" class="flex items-center gap-2 max-md:flex-wrap">
|
||||
<Tabs v-model="mode"><TabsList><TabsTrigger value="yaml">YAML</TabsTrigger><TabsTrigger value="canvas">Canvas</TabsTrigger></TabsList></Tabs>
|
||||
<Button type="button" size="sm" variant="outline" class="ml-auto" :disabled="then === null || identical || locked" :title="then === null ? 'Workflow removed' : undefined" @click="emit('restore', then!)">
|
||||
<RotateCcw data-icon="inline-start" /> Restore this version</Button>
|
||||
</div>
|
||||
<Empty v-if="then === null"><EmptyHeader><EmptyTitle>Workflow removed in this revision.</EmptyTitle></EmptyHeader></Empty>
|
||||
<pre v-else-if="mode === 'yaml'" class="min-h-0 flex-1 overflow-auto rounded-lg border border-border pt-2 pb-[calc(0.5rem+var(--code-overscroll))] font-mono text-label leading-6"><code><span
|
||||
v-for="(line, i) in diff"
|
||||
:key="i"
|
||||
class="block min-h-6 px-3 whitespace-pre-wrap"
|
||||
:class="{ 'bg-ok/10': line.kind === 'add', 'bg-danger/10 text-danger': line.kind === 'del' }"
|
||||
><span class="inline-block w-4 select-none text-fg-subtle">{{ line.kind === "add" ? "+" : line.kind === "del" ? "-" : "" }}</span>{{ line.text }}</span></code></pre>
|
||||
<div v-else class="grid min-h-0 flex-1 gap-3 max-md:flex-none md:grid-cols-2">
|
||||
<div class="flex min-h-0 flex-col gap-1">
|
||||
<div v-if="revision && mode === 'canvas'" class="grid min-h-0 flex-1 gap-3 max-md:flex-none md:grid-cols-2">
|
||||
<Empty v-if="then === null"><EmptyHeader><EmptyTitle>Workflow removed in this revision.</EmptyTitle></EmptyHeader></Empty>
|
||||
<div v-else class="flex min-h-0 flex-col gap-1">
|
||||
<span class="text-caption font-medium uppercase text-fg-muted">v{{ revision.version }}</span>
|
||||
<div class="min-h-0 flex-1 max-md:h-72 max-md:flex-none"><WorkflowCanvas :yaml="then" :marks="thenMarks" /></div>
|
||||
</div>
|
||||
@@ -92,6 +88,7 @@ const CHANGE_VARIANTS = { added: "default", edited: "secondary", removed: "destr
|
||||
<div class="min-h-0 flex-1 max-md:h-72 max-md:flex-none"><WorkflowCanvas :yaml="current" :marks="nowMarks" /></div>
|
||||
</div>
|
||||
</div>
|
||||
<WorkflowYaml v-else v-model="current" :against="then" :readonly="locked" class="flex-1" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -63,7 +63,7 @@ function source(run: WorkflowRun): string {
|
||||
|
||||
<template>
|
||||
<div class="space-y-4">
|
||||
<Section title="Runs" class="mb-0">
|
||||
<div>
|
||||
<p v-if="loading && !runs.length" class="flex items-center gap-2 text-label text-fg-muted"><Spinner />Loading runs…</p>
|
||||
<div v-else-if="error && !runs.length" role="alert" class="flex items-center gap-2 text-label text-danger">
|
||||
{{ error }}
|
||||
@@ -86,9 +86,9 @@ function source(run: WorkflowRun): string {
|
||||
<template #cell-created="{ row }"><Timestamp v-if="row.created_at" :at="row.created_at" /></template>
|
||||
</DataTable>
|
||||
</template>
|
||||
</Section>
|
||||
</div>
|
||||
|
||||
<Section title="Stages" class="mb-0">
|
||||
<Section v-if="runs.length" title="Stages" class="mb-0">
|
||||
<p v-if="!statsKnown && statsError" role="alert" class="text-label text-danger">{{ statsError }}</p>
|
||||
<p v-else-if="!statsKnown" class="flex items-center gap-2 text-label text-fg-muted"><Spinner />Loading…</p>
|
||||
<Empty v-else-if="!stages.length"><EmptyHeader><EmptyTitle>No stage timings yet</EmptyTitle></EmptyHeader></Empty>
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
<script setup lang="ts">
|
||||
import { useResizeObserver } from "@vueuse/core";
|
||||
import { computed, nextTick, ref, watch } from "vue";
|
||||
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { lineDiff } from "./workflow-revisions";
|
||||
import { yamlLines, yamlTokenClass } from "./workflow-yaml";
|
||||
|
||||
/**
|
||||
* The workflow's YAML, edited in place: a numbered, highlighted layer sits
|
||||
* behind the live textarea. Given `against`, each line added since that
|
||||
* version is marked, and a red bar sits where lines were removed. The layer is
|
||||
* aria-hidden: the textarea stays the only thing an operator or a screen
|
||||
* reader reaches.
|
||||
*/
|
||||
const props = defineProps<{ readonly?: boolean; against?: string | null }>();
|
||||
const yaml = defineModel<string>({ required: true });
|
||||
|
||||
const lines = computed(() => yamlLines(yaml.value));
|
||||
|
||||
// Per line of the current text: whether it is new since `against`, and how
|
||||
// many of that version's lines were removed just before it.
|
||||
const marks = computed(() => {
|
||||
const added: boolean[] = [];
|
||||
const removedBefore: number[] = [];
|
||||
if (props.against == null) return { added, removedBefore, removedAtEnd: 0 };
|
||||
let at = 0;
|
||||
let removed = 0;
|
||||
for (const line of lineDiff(props.against, yaml.value)) {
|
||||
if (line.kind === "del") {
|
||||
removed++;
|
||||
continue;
|
||||
}
|
||||
added[at] = line.kind === "add";
|
||||
removedBefore[at] = removed;
|
||||
removed = 0;
|
||||
at++;
|
||||
}
|
||||
return { added, removedBefore, removedAtEnd: removed };
|
||||
});
|
||||
|
||||
// The layer never scrolls by itself, so it follows the textarea's scroll.
|
||||
// Lines wrap at the editor's width; each wrapped line's gutter cell gets a
|
||||
// continuation mark per extra row. The text cell is measured, not the row,
|
||||
// so the gutter's own marks never count, and it breaks where the textarea does.
|
||||
const top = ref(0);
|
||||
const scrollbar = ref(0);
|
||||
const rowEls = ref<HTMLElement[]>([]);
|
||||
const wraps = ref<number[]>([]);
|
||||
const box = ref<InstanceType<typeof Textarea> | null>(null);
|
||||
const field = computed(() => (box.value?.$el as HTMLTextAreaElement | undefined) ?? null);
|
||||
|
||||
function measure(): void {
|
||||
const el = field.value;
|
||||
scrollbar.value = el ? el.offsetWidth - el.clientWidth : 0;
|
||||
wraps.value = rowEls.value.map((row) =>
|
||||
Math.max(1, Math.round(row.offsetHeight / (parseFloat(getComputedStyle(row).lineHeight) || 24))),
|
||||
);
|
||||
}
|
||||
useResizeObserver(field, measure);
|
||||
watch(lines, () => nextTick(measure), { flush: "post" });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="relative flex min-h-0 flex-col overflow-hidden rounded-lg border border-input bg-background font-mono text-label leading-6 focus-within:border-ring focus-within:ring-3 focus-within:ring-ring">
|
||||
<div aria-hidden="true" class="pointer-events-none absolute inset-y-0 left-0 w-11 select-none border-r border-border bg-secondary/40" />
|
||||
<div aria-hidden="true" class="pointer-events-none absolute inset-0 overflow-hidden py-3" :style="{ paddingRight: `calc(0.75rem + ${scrollbar}px)` }">
|
||||
<div :style="`transform:translateY(${-top}px)`">
|
||||
<div
|
||||
v-for="(line, i) in lines"
|
||||
:key="line.number"
|
||||
:class="cn('relative flex min-h-6', marks.added[i] && 'bg-ok/10')"
|
||||
>
|
||||
<span v-if="marks.removedBefore[i]" class="absolute inset-x-0 -top-px h-0.5 bg-danger" />
|
||||
<div :class="cn('w-11 shrink-0 select-none pr-2 text-right', marks.added[i] ? 'text-ok' : 'text-fg-subtle')">
|
||||
<div>{{ line.number }}</div>
|
||||
<div v-for="n in (wraps[i] ?? 1) - 1" :key="n">↳</div>
|
||||
</div>
|
||||
<div :ref="(el) => { if (el) rowEls[i] = el as HTMLElement }" class="max-w-[calc(var(--code-print-width)+0.75rem)] min-w-0 flex-1 self-start pl-3 break-words whitespace-pre-wrap">
|
||||
<span v-for="(token, j) in line.tokens" :key="j" :class="yamlTokenClass(token.kind)">{{ token.text }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<span v-if="marks.removedAtEnd" class="block h-0.5 bg-danger" />
|
||||
</div>
|
||||
</div>
|
||||
<Textarea
|
||||
id="workflow-yaml"
|
||||
ref="box"
|
||||
v-model="yaml"
|
||||
aria-label="Workflow YAML"
|
||||
name="workflow-yaml"
|
||||
required
|
||||
:readonly="readonly"
|
||||
class="relative min-h-96 flex-1 resize-none rounded-none border-0 bg-transparent pt-3 pr-3 pb-[calc(0.75rem+var(--code-overscroll))] pl-14 text-label leading-6 break-words whitespace-pre-wrap text-transparent caret-foreground shadow-none md:text-label focus-visible:ring-0 dark:bg-transparent"
|
||||
spellcheck="false"
|
||||
wrap="soft"
|
||||
:style="{ maxWidth: `calc(3.5rem + var(--code-print-width) + 0.75rem + ${scrollbar}px)` }"
|
||||
@scroll="top = ($event.target as HTMLTextAreaElement).scrollTop"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
Reference in new issue
Block a user