Files
archie/ui/test/work-request.test.ts
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

65 lines
2.1 KiB
TypeScript

import assert from "node:assert/strict";
import test from "node:test";
import {
declaredInputs,
inputValues,
missingRequiredInputs,
type DeclaredInput,
} from "../src/workflows/work-request.ts";
// The shape GET /api/workflows reports for a definition, as far as the
// work-request form reads it.
const prReview = {
id: "pr-review",
name: "pr-review",
enabled: true,
inputs: {
pr_number: { type: "number", required: true },
depth: { type: "string" },
},
};
test("the form renders one field per declared input, in a stable order", () => {
assert.deepEqual(declaredInputs(prReview), [
{ name: "depth", type: "string", required: false },
{ name: "pr_number", type: "number", required: true },
]);
});
test("a workflow that declares no inputs renders no fields", () => {
assert.deepEqual(declaredInputs({ id: "implement" }), []);
assert.deepEqual(declaredInputs(undefined), []);
});
test("a declared number is sent as a number, not as the typed text", () => {
assert.deepEqual(
inputValues(declaredInputs(prReview), { pr_number: "77", depth: "deep" }),
{ pr_number: 77, depth: "deep" },
);
});
test("an input left empty is absent rather than an empty string", () => {
assert.deepEqual(inputValues(declaredInputs(prReview), { pr_number: "77" }), {
pr_number: 77,
});
});
test("text that is not the declared type is sent as typed, for the server to name", () => {
assert.deepEqual(inputValues(declaredInputs(prReview), { pr_number: "seventy-seven" }), {
pr_number: "seventy-seven",
});
});
test("required inputs that are still empty are named", () => {
const declared = declaredInputs(prReview);
assert.deepEqual(missingRequiredInputs(declared, {}), ["pr_number"]);
assert.deepEqual(missingRequiredInputs(declared, { pr_number: " " }), ["pr_number"]);
assert.deepEqual(missingRequiredInputs(declared, { pr_number: "77" }), []);
});
test("an optional input does not hold the form back", () => {
const declared: DeclaredInput[] = declaredInputs(prReview);
assert.deepEqual(missingRequiredInputs(declared, { pr_number: "1" }), []);
});