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:
6 files changed
+180
-163
No files matched your search
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from "vue";
|
||||
import { ref } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import { Plus } from "@lucide/vue";
|
||||
|
||||
@@ -12,25 +12,10 @@ import {
|
||||
DialogTitle,
|
||||
DialogTrigger,
|
||||
} from "@/components/ui/dialog";
|
||||
import { api } from "@/lib/api";
|
||||
import StartWorkForm from "@/workflows/StartWorkForm.vue";
|
||||
import type { WorkflowDefinition } from "@/workflows/workflow-rows";
|
||||
import NewTaskForm from "./NewTaskForm.vue";
|
||||
|
||||
const router = useRouter();
|
||||
const open = ref(false);
|
||||
const definitions = ref<WorkflowDefinition[]>([]);
|
||||
const error = ref("");
|
||||
|
||||
watch(open, async (isOpen) => {
|
||||
if (!isOpen) return;
|
||||
try {
|
||||
const data = await api.workflows<{ definitions?: WorkflowDefinition[] }>();
|
||||
definitions.value = data?.definitions ?? [];
|
||||
error.value = definitions.value.length ? "" : "No workflow definitions are served.";
|
||||
} catch (err) {
|
||||
error.value = String((err as Error).message || err);
|
||||
}
|
||||
});
|
||||
|
||||
function started(taskId: number) {
|
||||
open.value = false;
|
||||
@@ -41,21 +26,14 @@ function started(taskId: number) {
|
||||
<template>
|
||||
<Dialog v-model:open="open">
|
||||
<DialogTrigger as-child>
|
||||
<Button size="sm">
|
||||
<Plus data-icon="inline-start" /> New task
|
||||
</Button>
|
||||
<Button size="sm"><Plus data-icon="inline-start" /> New task</Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent class="sm:max-w-[640px]">
|
||||
<DialogHeader>
|
||||
<DialogTitle>New task</DialogTitle>
|
||||
<DialogDescription>Enters Archie's admitted task queue.</DialogDescription>
|
||||
</DialogHeader>
|
||||
<p v-if="error" class="text-sm text-danger" role="alert">{{ error }}</p>
|
||||
<StartWorkForm
|
||||
v-else-if="definitions.length"
|
||||
:definitions="definitions"
|
||||
@started="started"
|
||||
/>
|
||||
<NewTaskForm v-if="open" @started="started" @cancel="open = false" />
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</template>
|
||||
@@ -0,0 +1,161 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref, useId, watchEffect } from "vue";
|
||||
import { ChevronRight } from "@lucide/vue";
|
||||
import { RadioGroupItem, RadioGroupRoot } from "reka-ui";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Kbd } from "@/components/ui/kbd";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
import { Spinner } from "@/components/ui/spinner";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import { api } from "@/lib/api";
|
||||
import { useIdentitiesStore } from "@/stores/identities";
|
||||
import type { WorkflowDefinition, WorkflowStats } from "@/workflows/workflow-rows";
|
||||
|
||||
/** Starting work enters Archie's normal admitted task queue, not a side door. */
|
||||
const emit = defineEmits<{ started: [taskId: number]; cancel: [] }>();
|
||||
const uid = useId();
|
||||
|
||||
const definitions = ref<WorkflowDefinition[]>([]);
|
||||
const stats = ref<WorkflowStats[]>([]);
|
||||
const recentRepos = ref<string[]>([]);
|
||||
const loadError = ref("");
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const [workflows, tasks] = await Promise.all([
|
||||
api.workflows<{ definitions?: WorkflowDefinition[]; workflows?: WorkflowStats[] }>(),
|
||||
api.tasks<{ owner?: string; repo?: string }[]>(),
|
||||
]);
|
||||
definitions.value = (workflows?.definitions ?? []).filter((d) => d.enabled);
|
||||
stats.value = workflows?.workflows ?? [];
|
||||
recentRepos.value = [...new Set((tasks ?? []).filter((t) => t.owner && t.repo).map((t) => `${t.owner}/${t.repo}`))].slice(0, 5);
|
||||
} catch (err) {
|
||||
loadError.value = String((err as Error).message || err);
|
||||
}
|
||||
});
|
||||
|
||||
const identities = useIdentitiesStore();
|
||||
identities.watch();
|
||||
const actors = computed(() => identities.identities.filter((i) => i.kind !== "system" && i.lifecycle === "active"));
|
||||
|
||||
const repository = ref("");
|
||||
const workflow = ref("");
|
||||
const title = ref("");
|
||||
const instructions = ref("");
|
||||
const identity = ref("");
|
||||
watchEffect(() => {
|
||||
if (!workflow.value && definitions.value[0]) workflow.value = definitions.value[0].id;
|
||||
if (!identity.value && actors.value[0]) identity.value = actors.value[0].id;
|
||||
});
|
||||
|
||||
const statFor = (id: string) => stats.value.find((s) => s.workflow === id);
|
||||
const identityName = computed(() => actors.value.find((a) => a.id === identity.value)?.display_name ?? "nobody");
|
||||
|
||||
const submitting = ref(false);
|
||||
const error = ref("");
|
||||
const ready = computed(
|
||||
() => !!(repository.value.trim() && workflow.value && title.value.trim() && instructions.value.trim() && identity.value),
|
||||
);
|
||||
async function submit() {
|
||||
if (!ready.value || submitting.value) return;
|
||||
submitting.value = true;
|
||||
error.value = "";
|
||||
try {
|
||||
const result = await api.workRequest<{ task_id: number }>({
|
||||
identity: identity.value,
|
||||
repository: repository.value.trim(),
|
||||
workflow: workflow.value,
|
||||
title: title.value.trim(),
|
||||
instructions: instructions.value,
|
||||
});
|
||||
emit("started", result.task_id);
|
||||
} catch (err) {
|
||||
error.value = String((err as Error).message || err);
|
||||
} finally {
|
||||
submitting.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<form class="grid gap-5" @submit.prevent="submit" @keydown.meta.enter.prevent="submit" @keydown.ctrl.enter.prevent="submit">
|
||||
<p v-if="loadError" class="text-sm text-danger" role="alert">{{ loadError }}</p>
|
||||
|
||||
<div class="grid gap-1.5">
|
||||
<label :for="`${uid}-repo`" class="text-[13px] font-medium">Repository</label>
|
||||
<Input :id="`${uid}-repo`" v-model="repository" class="font-mono" placeholder="owner/repository" :list="`${uid}-repos`" required />
|
||||
<datalist :id="`${uid}-repos`">
|
||||
<option v-for="r in recentRepos" :key="r" :value="r" />
|
||||
</datalist>
|
||||
<p v-if="recentRepos.length" class="text-xs text-fg-subtle">
|
||||
Recent:
|
||||
<button
|
||||
v-for="r in recentRepos"
|
||||
:key="r"
|
||||
type="button"
|
||||
class="mr-2 font-mono hover:text-foreground"
|
||||
@click="repository = r"
|
||||
>{{ r }}</button>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="grid gap-1.5">
|
||||
<span :id="`${uid}-wf`" class="text-[13px] font-medium">Workflow</span>
|
||||
<RadioGroupRoot v-model="workflow" :aria-labelledby="`${uid}-wf`" class="grid grid-cols-1 gap-2 sm:grid-cols-3" loop>
|
||||
<RadioGroupItem
|
||||
v-for="d in definitions"
|
||||
:key="d.id"
|
||||
:value="d.id"
|
||||
class="rounded-md border border-border bg-card px-3 py-2.5 text-left transition-colors hover:bg-secondary focus-visible:outline-2 focus-visible:outline-ring data-[state=checked]:border-primary data-[state=checked]:bg-secondary"
|
||||
>
|
||||
<span class="block truncate font-mono text-[13px] font-medium">{{ d.name || d.id }}</span>
|
||||
<span class="block text-xs text-fg-subtle">
|
||||
{{ statFor(d.id)?.runs || 0 }} runs<template v-if="statFor(d.id)?.runs">
|
||||
· {{ Math.round(((statFor(d.id)?.merged || 0) / (statFor(d.id)?.runs || 1)) * 100) }}% merged</template
|
||||
>
|
||||
</span>
|
||||
</RadioGroupItem>
|
||||
</RadioGroupRoot>
|
||||
<p v-if="!definitions.length && !loadError" class="text-xs text-fg-subtle">No enabled workflows.</p>
|
||||
</div>
|
||||
|
||||
<div class="grid gap-1.5">
|
||||
<label :for="`${uid}-title`" class="text-[13px] font-medium">Title</label>
|
||||
<Input :id="`${uid}-title`" v-model="title" required />
|
||||
</div>
|
||||
<div class="grid gap-1.5">
|
||||
<label :for="`${uid}-instr`" class="text-[13px] font-medium">Instructions</label>
|
||||
<Textarea :id="`${uid}-instr`" v-model="instructions" :rows="4" required />
|
||||
</div>
|
||||
|
||||
<Collapsible>
|
||||
<CollapsibleTrigger class="group flex items-center gap-1 text-xs text-fg-muted hover:text-foreground">
|
||||
<ChevronRight class="size-3.5 transition-transform group-data-[state=open]:rotate-90" aria-hidden="true" />
|
||||
Advanced · run as <span class="font-mono">{{ identityName }}</span>
|
||||
</CollapsibleTrigger>
|
||||
<CollapsibleContent class="pt-2">
|
||||
<Select v-model="identity">
|
||||
<SelectTrigger class="w-64" aria-label="Run as identity"><SelectValue placeholder="Choose an identity" /></SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem v-for="a in actors" :key="a.id" :value="a.id">{{ a.display_name }}</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</CollapsibleContent>
|
||||
</Collapsible>
|
||||
|
||||
<p v-if="error" class="text-sm text-danger" role="alert">{{ error }}</p>
|
||||
<div class="flex items-center gap-2 border-t border-border pt-4">
|
||||
<span class="mr-auto text-xs text-fg-subtle"><Kbd>⌘</Kbd> <Kbd>↵</Kbd> to start</span>
|
||||
<Button type="button" variant="ghost" @click="emit('cancel')">Cancel</Button>
|
||||
<Button type="submit" :disabled="!ready || submitting"><Spinner v-if="submitting" data-icon="inline-start" /> Start task</Button>
|
||||
</div>
|
||||
</form>
|
||||
</template>
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
|
||||
Reference in new issue
Block a user