fix(ui): one workflows toolbar row, one menu, no repeat step type

The step editor's More disclosure no longer fills when open, so only the
chevron moves. A step card keeps its type chip only when its title does not
already say it.

The editor header is one toolbar at every width: view tabs left, the run
selector and actions right, and a single menu holding the sections that do
not fit, the run's own actions and the draft's change list. Publish is the
one primary action. Restore replaces Discard draft and the per-workflow
Restore default, which settings owns.

The page header no longer wraps, and run rows on a phone no longer squeeze
the run title.
This commit is contained in:
sam committed 2026-10-18 22:29:25 +11:00
1 parent 66ec3437fc
commit 14ea688920
6 files changed
+97 -93

No files matched your search

+6 -3
View File
@@ -1,5 +1,4 @@
<script setup lang="ts">
import { ref } from "vue";
import { FlaskConical, Play } from "@lucide/vue";
import { Button } from "@/components/ui/button";
@@ -13,7 +12,9 @@ defineProps<{
draft?: string;
}>();
const emit = defineEmits<{ started: [taskId: number] }>();
const open = ref(false);
// A controlled open lets the toolbar's one menu run this when its own button
// does not fit.
const open = defineModel<boolean>("open", { default: false });
function started(taskId: number): void {
open.value = false;
@@ -28,10 +29,12 @@ function started(taskId: number): void {
type="button"
size="sm"
variant="outline"
class="max-sm:w-7 max-sm:px-0"
:aria-label="`${draft !== undefined ? 'Test' : 'Run'} ${workflow}`"
:disabled="disabled"
:title="draft !== undefined ? 'Runs this draft once. Forge writes and pushes are skipped, including in called workflows; commands and tools still run' : disabled ? 'Save first' : undefined"
>
<component :is="draft !== undefined ? FlaskConical : Play" data-icon="inline-start" /> {{ draft !== undefined ? "Test" : "Run" }}</Button>
<component :is="draft !== undefined ? FlaskConical : Play" data-icon="inline-start" /> <span class="max-sm:hidden">{{ draft !== undefined ? "Test" : "Run" }}</span></Button>
</DialogTrigger>
<DialogContent class="sm:max-w-[640px]">
<DialogHeader>
+3 -1
View File
@@ -203,7 +203,9 @@ const ON_FAILURE = [{ value: "", label: "Park the task" }, { value: "continue",
</div>
</section>
<Button type="button" variant="ghost" size="xs" class="-ml-2 text-fg-muted" :aria-expanded="more" @click="more = !more">
<!-- Only the chevron moves: a filled trigger changed the row's weight and
read as a different control once open. -->
<Button type="button" variant="ghost" size="xs" class="-ml-2 text-fg-muted aria-expanded:bg-transparent" :aria-expanded="more" @click="more = !more">
<ChevronDown data-icon="inline-start" class="transition-transform" :class="!more && '-rotate-90'" />More
</Button>
+5 -1
View File
@@ -63,6 +63,9 @@ const badge = computed(() => {
return { icon: stepIcon(props.data.type), label: stepTitle(props.data.type) };
});
const number = computed(() => (props.data.step ? `${Number(props.data.step)}.` : ""));
// A step with no id of its own is titled by its type, so the chip would repeat
// the line below it; the icon alone still names the type there.
const typeNamed = computed(() => props.data.title !== badge.value.label);
function duration(ms?: number): string {
if (ms === undefined) return "";
@@ -104,7 +107,7 @@ function commitRename(event: Event): void {
<Handle id="data-in" type="target" :position="Position.Right" class="!opacity-0" />
<div class="px-3 py-2.5" @click="data.onToggle?.()">
<div class="flex items-center gap-1.5">
<Badge variant="outline" class="max-w-40 gap-1 bg-background">
<Badge v-if="typeNamed" variant="outline" class="max-w-40 gap-1 bg-background">
<component :is="badge.icon" class="text-primary" aria-hidden="true" /><span class="truncate">{{ badge.label }}</span>
</Badge>
<span v-if="data.run?.duration_ms !== undefined" class="ml-auto font-mono text-[11px] text-fg-subtle">{{ duration(data.run.duration_ms) }}</span>
@@ -123,6 +126,7 @@ function commitRename(event: Event): void {
</DropdownMenu>
</div>
<div class="mt-1.5 flex min-w-0 items-baseline gap-1 text-sm font-medium">
<component :is="badge.icon" v-if="!typeNamed" class="size-3.5 shrink-0 self-center text-primary" aria-hidden="true" />
<span v-if="number" class="shrink-0">{{ number }}</span>
<Input
v-if="renaming"
+74 -79
View File
@@ -9,14 +9,13 @@ import {
AlertDialogTitle,
} from "@/components/ui/alert-dialog";
import { computed, onBeforeUnmount, ref, watch } from "vue";
import { ChevronDown, Ellipsis, RotateCcw, Trash2 } from "@lucide/vue";
import { CircleAlert, Ellipsis, RotateCcw, Trash2 } from "@lucide/vue";
import { Button } from "@/components/ui/button";
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import { Spinner } from "@/components/ui/spinner";
@@ -38,10 +37,10 @@ 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 { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog";
import { useWorkflowRuns } from "./workflow-runs";
import { useWorkflowTriggers } from "./workflow-triggers";
import { cloneControlPlaneValue, useSettingsStore } from "@/stores/settings";
import { useSettingsStore } from "@/stores/settings";
import {
removeWorkflowDefinition,
upsertWorkflowDefinition,
@@ -67,7 +66,6 @@ const modelAliases = computed(() =>
.sort(),
);
const collection = computed(() => workflows.collection);
const shipped = computed(() => workflows.shipped);
// Which definition is open belongs to the page, which also lists them.
const selected = defineModel<string>("selected", { required: true });
defineProps<{ runsCount?: number }>();
@@ -159,10 +157,6 @@ function renameAt(path: StepPath, name: string): void {
yaml.value = replaceStep(yaml.value, path, { id: name || undefined, type, ...rest });
}
const shippedEntry = computed(() =>
shipped.value.definitions.find((entry) => entry.id === id.value),
);
function load(value: string): void {
const entry = collection.value.definitions.find(
(candidate) => candidate.id === value,
@@ -240,7 +234,8 @@ async function takeProposal(): Promise<void> {
unsaved = undefined;
load(selected.value);
}
async function discard(): Promise<void> {
// Back to the published definition: the draft is dropped, not merged.
async function restorePublished(): Promise<void> {
await dropDraft(selected.value);
load(selected.value);
}
@@ -274,6 +269,10 @@ async function publish(): Promise<void> {
}
}
// 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;
@@ -287,22 +286,6 @@ async function remove(): Promise<void> {
yaml.value = "";
}
async function restoreOne(): Promise<void> {
if (!shippedEntry.value) return;
// The restored definition replaces whatever draft was open.
if (
await save(
upsertWorkflowDefinition(
collection.value,
cloneControlPlaneValue(shippedEntry.value),
),
)
) {
await dropDraft(selected.value);
load(selected.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
@@ -339,9 +322,10 @@ const runOptions = computed(() => [
})),
]);
const lines = computed(() => yamlLines(yaml.value));
// Below md the section tabs that do not fit beside Canvas and YAML are picked
// from one menu, which also names the section in view.
const OVERFLOW: Record<string, string> = { history: "History", performance: "Performance", runs: "Runs" };
// 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.
@@ -356,79 +340,80 @@ function syncScroll(event: Event): void {
<template>
<form class="space-y-4" @submit.prevent="publish">
<Tabs v-model="view" class="space-y-1.5">
<div class="flex flex-wrap items-center gap-2">
<TabsList class="max-w-full justify-start">
<!--
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-md:hidden">History</TabsTrigger>
<TabsTrigger v-if="$slots.performance" value="performance" class="max-md:hidden">Performance</TabsTrigger>
<TabsTrigger v-if="$slots.runs" value="runs" class="max-md:hidden">Runs <span class="ml-1 font-mono text-xs text-fg-subtle">{{ runsCount ?? 0 }}</span></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>
<DropdownMenu>
<DropdownMenuTrigger as-child>
<Button type="button" variant="outline" size="sm" class="md:hidden" aria-label="More sections">
{{ OVERFLOW[view] ?? "More" }}<ChevronDown data-icon="inline-end" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="start" class="w-40">
<DropdownMenuItem v-if="stored !== undefined" @select="view = 'history'">History</DropdownMenuItem>
<DropdownMenuItem v-if="$slots.performance" @select="view = 'performance'">Performance</DropdownMenuItem>
<DropdownMenuItem v-if="$slots.runs" @select="view = 'runs'">Runs <span class="ml-auto font-mono text-xs text-fg-subtle">{{ runsCount ?? 0 }}</span></DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
<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-64" @update:model-value="pick" />
<template v-if="watchedRun">
<RouterLink :to="`/tasks/${watchedRun.id}`" class="shrink-0 px-1 text-xs text-fg-muted hover:text-foreground hover:underline">Open</RouterLink>
<button v-if="watchedRevision" type="button" class="shrink-0 px-1 font-mono text-xs text-fg-muted hover:text-foreground hover:underline" title="Open the version this run used" @click="openRevision(watchedRevision.version)">v{{ watchedRevision.version }}</button>
<TaskRowActions :task="watchedRun" class="shrink-0" @done="refresh" />
</template>
</div>
<template v-if="view === 'canvas' || view === 'yaml'">
<div class="ml-auto flex flex-wrap items-center justify-end gap-2">
<span v-if="!parsed.ok" class="max-w-md truncate text-xs text-danger" role="status" :title="validationLabel(parsed)">
{{ validationLabel(parsed) }}
<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">
<Button as-child variant="ghost" size="sm" class="max-md:hidden"><RouterLink :to="`/tasks/${watchedRun.id}`">Open</RouterLink></Button>
<Button v-if="watchedRevision" type="button" variant="ghost" size="sm" class="max-md:hidden font-mono text-xs" title="Open the version this run used" @click="openRevision(watchedRevision.version)">v{{ watchedRevision.version }}</Button>
<!-- One run control keeps the row short; the run's other actions
are on the run, one Open away. -->
<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>
<Popover v-else-if="dirty">
<PopoverTrigger as-child>
<Button type="button" variant="ghost" size="sm" class="text-xs text-fg-subtle">
Draft · {{ changes.length }} {{ changes.length === 1 ? "change" : "changes" }}</Button>
</PopoverTrigger>
<PopoverContent align="end" class="max-h-96 w-96 overflow-y-auto p-0">
<ChangeList :changes="changes" @revert="(change) => (yaml = revertWorkflowChange(yaml, change))" />
</PopoverContent>
</Popover>
<!-- 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="dirty" :disabled="archieWorking" @select="discard"><RotateCcw />Discard draft</DropdownMenuItem>
<DropdownMenuItem v-if="shippedEntry" @select="restoreOne"><RotateCcw />Restore default</DropdownMenuItem>
<DropdownMenuSeparator v-if="dirty || shippedEntry" />
<DropdownMenuItem variant="destructive" @select="confirmDelete = true"><Trash2 />Delete workflow</DropdownMenuItem>
<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>
<DropdownMenuItem v-if="watchedRun" as-child class="md:hidden"><RouterLink :to="`/tasks/${watchedRun.id}`">Open run</RouterLink></DropdownMenuItem>
<DropdownMenuItem v-if="watchedRevision" class="md:hidden" @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>
<RunWorkflowButton v-if="stored !== undefined" :workflow="selected" :draft="yaml" :disabled="!parsed.ok" @started="(id) => { view = 'canvas'; void follow(id); }" />
<RunWorkflowButton v-if="stored !== undefined" :workflow="selected" :disabled="dirty" @started="(id) => { view = 'canvas'; void follow(id); }" />
<Button type="submit" size="sm" :disabled="state.saving || !parsed.ok || !dirty || archieWorking">
<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>
</template>
</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="watchedRun && !watchedRun.workflow_definition_yaml" class="text-xs text-fg-muted" role="status">No workflow snapshot was recorded for this run.</p>
<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 more chrome
above it (the workflow list, a two-row toolbar and the run picker),
hence the larger offset below md. -->
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
@@ -552,6 +537,16 @@ function syncScroll(event: Event): void {
<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>
+2 -2
View File
@@ -1,13 +1,13 @@
<script setup lang="ts">
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
defineProps<{ value: string; workflows: { id: string }[]; label: string }>();
defineProps<{ value: string; workflows: { id: string }[]; label: string; class?: string }>();
const emit = defineEmits<{ pick: [string] }>();
</script>
<template>
<Select :model-value="value || undefined" @update:model-value="emit('pick', String($event))">
<SelectTrigger :aria-label="label"><SelectValue placeholder="Choose workflow" /></SelectTrigger>
<SelectTrigger :aria-label="label" :class="$props.class"><SelectValue placeholder="Choose workflow" /></SelectTrigger>
<SelectContent>
<SelectItem v-if="value && !workflows.some((entry) => entry.id === value)" :value="value" disabled>{{ value }} (unavailable)</SelectItem>
<SelectItem v-for="entry in workflows" :key="entry.id" :value="entry.id">{{ entry.id }}</SelectItem>
+7 -7
View File
@@ -212,13 +212,13 @@ const rate = (deliveredRuns = 0, total = 0) => (total ? deliveredRuns / total :
</Empty>
</section>
<section v-else-if="selected && store.state.resource" class="min-w-0 rounded-lg border border-border bg-card px-3 py-4 sm:px-5" aria-label="Workflow">
<header class="mb-2 flex flex-wrap items-center gap-2">
<header class="mb-2 flex items-center gap-2">
<!-- Below lg the list is gone: this picks the workflow instead. -->
<div class="lg:hidden"><WorkflowPicker :value="selected" :workflows="rows" label="Workflow" @pick="selected = $event" /></div>
<h2 class="font-mono text-[15px] font-medium max-lg:hidden">{{ selected }}</h2>
<Badge v-if="provenance" variant="outline">{{ provenance }}</Badge>
<Badge v-if="drafted" variant="outline" class="lg:hidden">Draft</Badge>
<div class="ml-auto flex items-center gap-3">
<div class="min-w-0 flex-1 lg:hidden"><WorkflowPicker class="w-full" :value="selected" :workflows="rows" label="Workflow" @pick="selected = $event" /></div>
<h2 class="min-w-0 truncate font-mono text-[15px] font-medium max-lg:hidden">{{ selected }}</h2>
<Badge v-if="provenance" variant="outline" class="shrink-0">{{ provenance }}</Badge>
<Badge v-if="drafted" variant="outline" class="shrink-0 lg:hidden">Draft</Badge>
<div class="ml-auto flex shrink-0 items-center gap-3">
<ApplyStatusRows kind="workflow-definitions" compact />
<Switch v-if="enabled !== undefined" :model-value="enabled" aria-label="Workflow enabled" @update:model-value="setEnabled" />
</div>
@@ -249,7 +249,7 @@ const rate = (deliveredRuns = 0, total = 0) => (total ? deliveredRuns / total :
<ul v-else class="divide-y divide-border">
<li v-for="t in workflowRuns" :key="t.id" class="flex items-center gap-3 py-2 text-sm">
<RouterLink :to="`/tasks/${t.id}`" class="min-w-0 flex-1 truncate hover:underline">{{ t.title || `Task ${t.id}` }}</RouterLink>
<span class="font-mono text-xs text-fg-subtle">{{ t.owner && t.repo ? `${t.owner}/${t.repo} #${t.issue_number}` : "" }}</span>
<span class="hidden font-mono text-xs text-fg-subtle sm:block">{{ t.owner && t.repo ? `${t.owner}/${t.repo} #${t.issue_number}` : "" }}</span>
<Badge :variant="statusKind(t.status ?? '')">{{ statusLabel(t.status ?? "") }}</Badge>
</li>
</ul>