feat(webui): New task dialog with workflow cards, recent repositories and run-as identity

Repository with recent ones one click away, the workflow as a radiogroup
of cards showing runs and merge rate, title and instructions, and the
identity (the server requires one) defaulted to the first active actor
under an Advanced disclosure that names it. Cmd/Ctrl+Enter starts the
task and opens it. Replaces the Start work form. Workflows shows an empty
state rather than an editable template when there is none.
This commit is contained in:
sam committed 2026-09-25 16:34:38 +10:00
1 parent 93158f3e67
commit d37a425e43
6 files changed
+180 -163

No files matched your search

-126
View File
@@ -1,126 +0,0 @@
<script setup lang="ts">
import { computed, ref, useId, watchEffect } from "vue";
import { Button } from "@/components/ui/button";
import { Field, FieldGroup, FieldLabel } from "@/components/ui/field";
import { Input } from "@/components/ui/input";
import {
Select,
SelectContent,
SelectGroup,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import { Textarea } from "@/components/ui/textarea";
import { api } from "@/lib/api";
import { workflowLabel } from "./labels";
/** A workflow definition, as far as this form needs it. */
interface Definition {
id: string;
name?: string;
enabled?: boolean;
}
const props = defineProps<{ definitions: Definition[] }>();
const uid = useId();
const emit = defineEmits<{ started: [taskId: number] }>();
/** Starting work enters Archie's normal admitted task queue, not a side door. */
const enabled = computed(() => props.definitions.filter((d) => d.enabled));
const defaultWorkflow = computed(() => enabled.value[0]?.id ?? "");
const identity = ref("");
const repository = ref("");
const workflow = ref(defaultWorkflow.value);
const title = ref("");
const instructions = ref("");
const submitting = ref(false);
const notice = ref("");
// The definitions arrive after the first render, so the default can only be
// applied once they do.
watchEffect(() => {
if (!workflow.value && defaultWorkflow.value)
workflow.value = defaultWorkflow.value;
});
async function submit() {
submitting.value = true;
notice.value = "";
try {
const result = await api.workRequest<{ task_id: number }>({
identity: identity.value,
repository: repository.value,
workflow: workflow.value,
title: title.value,
instructions: instructions.value,
});
notice.value = `Queued task #${result.task_id}.`;
emit("started", result.task_id);
identity.value = "";
repository.value = "";
workflow.value = defaultWorkflow.value;
title.value = "";
instructions.value = "";
} catch (err) {
notice.value = String((err as Error).message || err);
} finally {
submitting.value = false;
}
}
</script>
<template>
<form @submit.prevent="submit">
<FieldGroup>
<Field>
<FieldLabel :for="`${uid}-identity`">Identity</FieldLabel>
<Input :id="`${uid}-identity`" v-model="identity" required />
</Field>
<Field>
<FieldLabel :for="`${uid}-repository`">Repository</FieldLabel>
<Input
:id="`${uid}-repository`"
v-model="repository"
placeholder="owner/repository"
required
/>
</Field>
<Field>
<FieldLabel :for="`${uid}-workflow`">Workflow</FieldLabel>
<Select v-model="workflow" required>
<SelectTrigger :id="`${uid}-workflow`">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectGroup>
<SelectItem v-for="d in enabled" :key="d.id" :value="d.id">
{{ workflowLabel(d.name || d.id) }}
</SelectItem>
</SelectGroup>
</SelectContent>
</Select>
</Field>
<Field>
<FieldLabel :for="`${uid}-title`">Task title</FieldLabel>
<Input :id="`${uid}-title`" v-model="title" required />
</Field>
<Field>
<FieldLabel :for="`${uid}-instructions`">Instructions</FieldLabel>
<Textarea
:id="`${uid}-instructions`"
v-model="instructions"
:rows="3"
required
/>
</Field>
<Field orientation="horizontal">
<Button type="submit" :disabled="submitting">Start work</Button>
<p v-if="notice" class="text-sm text-fg-muted">{{ notice }}</p>
</Field>
</FieldGroup>
</form>
</template>
+6 -2
View File
@@ -125,9 +125,13 @@ const rate = (merged = 0, total = 0) => (total ? merged / total : 0);
</li>
</ul>
<section class="min-w-0 rounded-lg border border-border bg-card px-5 py-4" aria-label="Workflow">
<section v-if="!selected" class="min-w-0 rounded-lg border border-border bg-card px-5 py-10 text-center" aria-label="Workflow">
<p class="font-medium">No workflows</p>
<p class="mt-1 text-sm text-fg-muted">Create one, or restore the shipped set.</p>
</section>
<section v-else class="min-w-0 rounded-lg border border-border bg-card px-5 py-4" aria-label="Workflow">
<header class="mb-2 flex flex-wrap items-center gap-2">
<h2 class="font-mono text-[15px] font-medium">{{ selected || "No workflow" }}</h2>
<h2 class="font-mono text-[15px] font-medium">{{ selected }}</h2>
<StatusPill v-if="current?.origin">{{ current.origin }}</StatusPill>
<span v-if="current" class="ml-auto text-xs text-fg-subtle">{{ current.runs || 0 }} runs</span>
</header>