Files
archie/ui/src/tasks/NewTaskForm.vue
T
sam e16f4c8f57 feat(webui): name a workflow's declared inputs on the work-request form
The dashboard could not name a workflow's declared inputs, so POST
/api/work-requests admitted a pr-review task with no pr_number, which then
failed at the workflow's intake stage (archie-core-06nq). The handler now takes
`inputs`, checks it against the workflow's declared interface before admitting
the task, and carries it through SpawnRequest.Inputs -> EnqueueChatTaskRequest;
the form renders one field per declared input, sends a declared number as a
number, and keeps Start disabled while a required input is empty.

Item 2 of the lane brief -- archie-core-afbk.12, review.precision_gate /
review.approve_before_post in the dashboard Config tab -- is deliberately NOT in
this commit. The surface it describes no longer exists in this tree; the
supervisor's decision was to stop it and re-scope it as its own lane, and the
facts it must start from belong in the branch's record:

* The Config-tab components were deleted by becb0b5e (2026-09-25, "the legacy
  config catalog stops advertising fields the control plane owns"): ConfigSections.vue,
  ConfigRow.vue, ConfigControl.vue, ConfigList.vue, ConfigNotices.vue,
  ConfigUnavailable.vue, config-field.ts and sections.ts all went, because no
  page used them. Descriptor entries in internal/webui/config_schema.go would
  therefore change nothing a person can see: the only consumer of GET /api/config
  is SystemModelsPage reading `catalog`; the per-field `schema` has no renderer.
* The config write seams went earlier, in 31622ec5 (2026-09-21, "delete the
  runtime config overlay"): UpdateConfig, ResetConfig and UpdateRepoField are
  gone and internal/webui/server.go serves only GET /api/config. Configuration
  is written through the control plane.
* No control-plane resource carries review settings. executionSettingsDocument
  (internal/app/controlplane/workflow_settings.go) and workflow.ExecutionSettings
  carry only the four budget fields, and runtimeConfigFrom never layers
  cfg.Review. That is exactly why the budget descriptors survive in the catalog
  and review.* cannot: budgets are saved through workflow-execution-settings,
  edited on the Task-execution page, so those entries match a real write path.
* The brief's precedent name is wrong: TestToolSettingsProjectionCarriesEveryMCPServerField
  does not exist. The precedent is TestToolSettingsProjectionCarriesEveryMirroredField
  (internal/app/controlplane/runtime_config_test.go:349).

Making review.* genuinely editable needs a carrying control-plane resource
(extend workflow-execution-settings or add a review-settings kind), a layering
step in internal/app/archied/control_plane.go, and the round-trip test that
precedent sets -- an unsettled design decision spanning packages this lane does
not own.
2026-09-30 04:00:31 +10:00

199 lines
8.4 KiB
Vue

<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 { delivered } from "@/lib/delivered";
import { useIdentitiesStore } from "@/stores/identities";
import type { WorkflowDefinition, WorkflowStats } from "@/workflows/workflow-rows";
import {
declaredInputs,
inputValues,
missingRequiredInputs,
} from "@/workflows/work-request";
/** 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("");
// One text field per declared input, by input name: the chosen workflow's
// declaration decides what is rendered and what the request carries.
const inputText = ref<Record<string, string>>({});
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 selected = computed(() => definitions.value.find((d) => d.id === workflow.value));
const declared = computed(() => declaredInputs(selected.value));
const missing = computed(() => missingRequiredInputs(declared.value, inputText.value));
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) &&
missing.value.length === 0,
);
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,
inputs: inputValues(declared.value, inputText.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((delivered(statFor(d.id)) / (statFor(d.id)?.runs || 1)) * 100) }}% delivered</template
>
</span>
</RadioGroupItem>
</RadioGroupRoot>
<p v-if="!definitions.length && !loadError" class="text-xs text-fg-subtle">No enabled workflows.</p>
</div>
<!-- One field per input the chosen workflow declares: pr-review cannot run
without its pr_number, and the server refuses a request that does not
set what the workflow declares. The declared type is the hint, so the
value is typed the way the workflow reads it. -->
<div v-if="declared.length" class="grid gap-3">
<div v-for="field in declared" :key="field.name" class="grid gap-1.5">
<label :for="`${uid}-input-${field.name}`" class="text-[13px] font-medium">
<span class="font-mono">{{ field.name }}</span>
<span v-if="field.required" class="text-fg-subtle"> · required</span>
</label>
<Input
:id="`${uid}-input-${field.name}`"
v-model="inputText[field.name]"
:type="field.type === 'number' ? 'number' : 'text'"
class="font-mono"
:required="field.required"
/>
<p class="text-xs text-fg-subtle">{{ field.type }}</p>
</div>
</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>