From 82f5afaa6d723f3c79050fcbab95d8e9d4abd173 Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Fri, 13 Nov 2026 23:49:46 +1100 Subject: [PATCH] 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. --- e2e/checks/workflow-logic.cjs | 14 ++-- e2e/checks/workflow-phone-layout.cjs | 13 ++-- e2e/checks/workflow-validation.cjs | 4 +- ui/src/workflows/WorkflowEditor.vue | 108 ++------------------------- ui/src/workflows/WorkflowHistory.vue | 33 ++++---- ui/src/workflows/WorkflowRuns.vue | 6 +- ui/src/workflows/WorkflowYaml.vue | 102 +++++++++++++++++++++++++ 7 files changed, 142 insertions(+), 138 deletions(-) create mode 100644 ui/src/workflows/WorkflowYaml.vue diff --git a/e2e/checks/workflow-logic.cjs b/e2e/checks/workflow-logic.cjs index 9ef9341db..db8d03fe9 100644 --- a/e2e/checks/workflow-logic.cjs +++ b/e2e/checks/workflow-logic.cjs @@ -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')); }; diff --git a/e2e/checks/workflow-phone-layout.cjs b/e2e/checks/workflow-phone-layout.cjs index 120cc3cf8..74181a8e7 100644 --- a/e2e/checks/workflow-phone-layout.cjs +++ b/e2e/checks/workflow-phone-layout.cjs @@ -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(); diff --git a/e2e/checks/workflow-validation.cjs b/e2e/checks/workflow-validation.cjs index 005ce1110..836d634fb 100644 --- a/e2e/checks/workflow-validation.cjs +++ b/e2e/checks/workflow-validation.cjs @@ -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'); }; diff --git a/ui/src/workflows/WorkflowEditor.vue b/ui/src/workflows/WorkflowEditor.vue index 0a83468f8..a2ef4491b 100644 --- a/ui/src/workflows/WorkflowEditor.vue +++ b/ui/src/workflows/WorkflowEditor.vue @@ -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([]); -const wraps = ref([]); -const yamlBox = ref | 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()); -