fix(ui): fit phone workflows and allow dynamic handoffs
This commit is contained in:
1 parent
454e08cabe
commit
0e3cb2e4d3
15 files changed
+499
-239
No files matched your search
@@ -37,7 +37,7 @@ 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 { deleteStep, duplicateStep, insertStep, moveStep, normalizeStepIDs, 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";
|
||||
@@ -89,7 +89,9 @@ const stepTab = ref("definition");
|
||||
// the canvas draws the definition alone.
|
||||
const unpinned = computed(() => Boolean(watchedRun.value && !watchedRun.value.workflow_definition_yaml));
|
||||
const drawnStages = computed(() => unpinned.value ? [] : stages.value);
|
||||
const graph = computed(() => withRuns(workflowGraph(yaml.value), drawnStages.value));
|
||||
const pinnedYaml = computed(() => watchedRun.value?.workflow_definition_yaml);
|
||||
const canvasYaml = computed(() => pinnedYaml.value || yaml.value);
|
||||
const graph = computed(() => withRuns(workflowGraph(canvasYaml.value), drawnStages.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;
|
||||
@@ -169,8 +171,8 @@ function load(value: string): void {
|
||||
(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;
|
||||
loadedYaml.value = workflows.drafts.find((draft) => draft.id === value)?.yaml ?? entry?.yaml ?? `id: ${value}\nsteps: []\n`;
|
||||
yaml.value = normalizeStepIDs(loadedYaml.value);
|
||||
open.value = null;
|
||||
localError.value = "";
|
||||
}
|
||||
@@ -276,8 +278,7 @@ 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.
|
||||
// The run button and draft menu item each control their dialog.
|
||||
const runOpen = ref(false);
|
||||
const draftOpen = ref(false);
|
||||
const confirmDelete = ref(false);
|
||||
@@ -336,13 +337,9 @@ function showError(path?: StepPath): void {
|
||||
view.value = "canvas";
|
||||
openStepAt(path);
|
||||
}
|
||||
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 workflowSummary = computed(() => String(workflowField(canvasYaml.value, "profile") ?? ""));
|
||||
const runOptions = computed(() => [
|
||||
{ value: "", label: "Current definition" },
|
||||
{ value: "", label: "Definition" },
|
||||
...runs.value.map((run) => ({
|
||||
value: String(run.id),
|
||||
label: [`${run.source === "test" ? "Test" : "Run"} #${run.id}`, run.status && statusLabel(run.status), run.created_at ? ago(run.created_at) : ""].filter(Boolean).join(" · "),
|
||||
@@ -365,16 +362,9 @@ function syncScroll(event: Event): void {
|
||||
</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">
|
||||
<form class="space-y-4 max-md:flex max-md:min-h-0 max-md:flex-1 max-md:flex-col" @submit.prevent="publish">
|
||||
<Tabs v-model="view" class="space-y-1.5 max-md:min-h-0 max-md:flex-1">
|
||||
<div class="workflow-editor-toolbar flex shrink-0 items-center gap-2 max-sm:grid max-sm:grid-cols-[1fr_auto]">
|
||||
<TabsList class="shrink-0 justify-start">
|
||||
<TabsTrigger value="canvas">Canvas</TabsTrigger>
|
||||
<TabsTrigger value="yaml">YAML</TabsTrigger>
|
||||
@@ -383,10 +373,8 @@ function syncScroll(event: Event): void {
|
||||
<TabsTrigger v-if="$slots.runs && stored !== undefined" 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 role="group" aria-label="Runs" class="ml-auto flex min-w-0 items-center gap-1">
|
||||
<!-- 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">
|
||||
<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">
|
||||
<RunWorkflowButton
|
||||
v-model:open="runOpen"
|
||||
:workflow="selected"
|
||||
@@ -395,8 +383,8 @@ function syncScroll(event: Event): void {
|
||||
@started="(id) => { view = 'canvas'; void follow(id); }"
|
||||
/>
|
||||
</div>
|
||||
<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 *:data-[slot=select-value]:block *:data-[slot=select-value]:truncate" @update:model-value="pick" />
|
||||
<div v-if="runs.length && view === 'canvas'" class="flex min-w-0 items-center gap-1 max-sm:flex-1">
|
||||
<OptionSelect :model-value="watched" :options="runOptions" aria-label="Run shown on the canvas" class="min-w-0 max-w-56 max-sm:w-full *:data-[slot=select-value]:block *:data-[slot=select-value]:truncate" @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. -->
|
||||
@@ -404,7 +392,7 @@ function syncScroll(event: Event): void {
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
<div role="group" aria-label="Edit" class="flex min-w-0 items-center gap-1 border-l pl-2">
|
||||
<div role="group" aria-label="Edit" class="workflow-edit-actions flex min-w-0 items-center gap-1 border-l pl-2 max-sm:col-start-2 max-sm:row-start-1">
|
||||
<slot name="toolbar" />
|
||||
<Popover v-if="!parsed.ok">
|
||||
<PopoverTrigger as-child>
|
||||
@@ -436,7 +424,6 @@ function syncScroll(event: Event): void {
|
||||
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="changes.length" @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>
|
||||
@@ -452,23 +439,20 @@ function syncScroll(event: Event): void {
|
||||
<p v-if="view === 'canvas' && unpinned" 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. On a phone the Archie bar
|
||||
already sits beside the launcher, so the canvas takes back the
|
||||
launcher padding the page reserves below it. -->
|
||||
<div class="relative flex h-[calc(100dvh-17rem)] min-h-[26rem] flex-col max-md:-mb-20 max-md:min-h-[23rem]">
|
||||
<TabsContent value="canvas" force-mount class="space-y-2 data-[state=inactive]:hidden max-md:flex max-md:min-h-0 max-md:flex-col">
|
||||
<div class="relative flex h-[calc(100dvh-17rem)] min-h-[26rem] flex-col max-md:h-auto max-md:min-h-0 max-md:flex-1">
|
||||
<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"
|
||||
:yaml="canvasYaml"
|
||||
:stages="drawnStages"
|
||||
:open="open"
|
||||
:triggers="triggers"
|
||||
:types="stepTypeNames"
|
||||
:readonly="!!pinnedYaml"
|
||||
:restartable="restartable"
|
||||
:problems="nodeProblems"
|
||||
:problems="pinnedYaml ? undefined : nodeProblems"
|
||||
:title="parsed.ok ? parsed.id : id"
|
||||
:summary="workflowSummary"
|
||||
@toggle="toggle"
|
||||
@@ -480,8 +464,8 @@ function syncScroll(event: Event): void {
|
||||
@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" />
|
||||
<fieldset v-if="data.kind === 'workflow'" :disabled="!!pinnedYaml" class="min-w-0"><WorkflowSettings :yaml="canvasYaml" @update:yaml="yaml = $event" /></fieldset>
|
||||
<fieldset v-else-if="data.kind === 'start'" :disabled="!!pinnedYaml" class="min-w-0"><TriggerSettings :yaml="canvasYaml" :triggers="triggers" @update:yaml="yaml = $event" @bound="reloadTriggers" /></fieldset>
|
||||
<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>
|
||||
@@ -490,21 +474,23 @@ function syncScroll(event: Event): void {
|
||||
<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>
|
||||
<fieldset v-else :disabled="!!pinnedYaml" class="min-w-0">
|
||||
<StepEditor
|
||||
v-else
|
||||
:key="open ?? ''"
|
||||
v-model:yaml="yaml"
|
||||
:yaml="canvasYaml"
|
||||
@update:yaml="yaml = $event"
|
||||
:workflows="collection.definitions"
|
||||
:path="data.path"
|
||||
:vocabulary="vocabulary"
|
||||
:model-aliases="modelAliases"
|
||||
/>
|
||||
</fieldset>
|
||||
</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">
|
||||
<div class="flex shrink-0 justify-center px-3 pt-2">
|
||||
<CoBuilder
|
||||
v-if="selected"
|
||||
:key="selected"
|
||||
@@ -516,12 +502,12 @@ function syncScroll(event: Event): void {
|
||||
</div>
|
||||
</div>
|
||||
</TabsContent>
|
||||
<TabsContent value="history">
|
||||
<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" @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">
|
||||
<TabsContent value="performance" class="grid gap-4 max-md:min-h-0 max-md:overflow-y-auto"><slot name="performance" /></TabsContent>
|
||||
<TabsContent value="runs" class="max-md:min-h-0 max-md:overflow-y-auto"><slot name="runs" /></TabsContent>
|
||||
<TabsContent value="yaml" :inert="archieWorking" 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,
|
||||
@@ -530,7 +516,7 @@ function syncScroll(event: Event): void {
|
||||
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"
|
||||
class="relative overflow-hidden rounded-lg border border-input font-mono max-md:h-full text-[13px] leading-6 focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50"
|
||||
>
|
||||
<div
|
||||
aria-hidden="true"
|
||||
@@ -568,7 +554,7 @@ function syncScroll(event: Event): void {
|
||||
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"
|
||||
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 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"
|
||||
@@ -602,3 +588,18 @@ function syncScroll(event: Event): void {
|
||||
</AlertDialog>
|
||||
</form>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
@media (max-width: 360px) {
|
||||
.workflow-editor-toolbar {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
.workflow-editor-toolbar > .workflow-edit-actions {
|
||||
grid-area: 2 / 1;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
.workflow-editor-toolbar > .workflow-run-actions {
|
||||
grid-area: 3 / 1;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user