Files
archie/ui/src/workflows/StartWorkForm.vue
T
sam 8e91ccb76d feat(webui): port the dashboard (Phases 3-5)
Every page from the deleted Preact dashboard, rebuilt in Vue 3 + shadcn-vue.
The navigation restructure landed earlier on this branch; this is the surfaces
behind it, and the two are now one app.

Dashboard, Tasks (list and detail), Configuration split six ways, Logs,
Inspector, Mappings, Bindings, Workflows, Skills, Curators, Channels, chat.

Components, not files: docs/prds/dashboard-port-brief.md requires one
component, one job, one file, with shared state in a module beside it. So a
page file composes and holds nothing, and a shape repeated across panes becomes
its own component (LogRow, PageHeader, PanelLoading, WorkflowBar).

Behaviour that had to survive, because each was a fix:

- Live activity's detail is clamped to one line with the payload on the title.
  Unclamped, one row made the dashboard 7,481px tall.
- Each health card takes its own height. Equalising left a mostly-empty box
  taking a quarter of the first screen once setup was done.
- Tasks: `tab`/`attempt` live in the query string and are written with
  router.replace, so a tab click adds no history entry and does not remount.
  The list's deep-link reveal honours prefers-reduced-motion.
- LOG_LEVELS is a wire contract (the server matches that CSV server-side), used
  unchanged by both log panes.
- The chat panel's Phase 5 list: a FAB that is the only toggle, a morph whose
  scale, radius and position interpolate together, no scrim, no close button,
  Escape returning focus to the launcher, Stop only while streaming.
- Unconfigured is not broken. A 501 on /api/version or the log stream renders
  what is true ("Not configured on this deployment") rather than blank, and a
  read-only Configuration says so instead of offering controls that cannot work.

Three things the port decided rather than carried:

- Button gains an `attention` variant and Badge the five status tones, in the
  project's own cva. The pill's dot did not come across: the Badge's shape is
  the affordance, and the same tone now covers a trend indicator.
- The icon module is not ported. Its name-to-glyph lookup is the pattern
  shadcn-vue's rules call out as wrong, so icons come from @lucide/vue at the
  call site. The five bespoke glyphs have no consumer yet and become components
  if a page draws them.
- The theme control left the topbar for /system/appearance, per the approved
  navigation design. ThemeToggle.vue and Placeholder.vue are deleted rather
  than orphaned: every route now resolves to a real page.

Also fixes the bundle freshness check failing on the first build after every
change. ui/dist is committed, so nothing ignores it and Tailwind's content
detection scanned it, making each build an input to the next.
2026-09-20 20:04:55 +10:00

115 lines
3.9 KiB
Vue

<script setup lang="ts">
import { computed, ref, watchEffect } from "vue";
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
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[] }>();
/** 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}.`;
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>
<Card class="mb-4">
<CardHeader>
<CardTitle>Start work</CardTitle>
<CardDescription>This enters Archie's normal admitted task queue.</CardDescription>
</CardHeader>
<CardContent>
<form @submit.prevent="submit">
<FieldGroup>
<Field>
<FieldLabel for="wf-identity">Identity</FieldLabel>
<Input id="wf-identity" v-model="identity" required />
</Field>
<Field>
<FieldLabel for="wf-repository">Repository</FieldLabel>
<Input id="wf-repository" v-model="repository" placeholder="owner/repository" required />
</Field>
<Field>
<FieldLabel for="wf-workflow">Workflow</FieldLabel>
<Select v-model="workflow" required>
<SelectTrigger id="wf-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="wf-title">Task title</FieldLabel>
<Input id="wf-title" v-model="title" required />
</Field>
<Field>
<FieldLabel for="wf-instructions">Instructions</FieldLabel>
<Textarea id="wf-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>
</CardContent>
</Card>
</template>