Files
archie/ui/src/workflows/workflow-rows.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

82 lines
2.5 KiB
TypeScript

// Merging workflow definitions with their run statistics.
//
// The rows used to come from the definition list alone, so a workflow that had
// run but was no longer in that list (or a definitions fetch that came back
// empty while the stats fetch succeeded) produced no rows at all. The page then
// showed "No workflow runs yet" directly above the stage tables listing those
// very runs (archie-core-rcbf).
//
// A run is evidence the workflow exists. Anything with either a definition or
// statistics gets a row.
/** A workflow's run statistics, as the stats endpoint reports them. */
export interface WorkflowStats {
workflow: string;
runs?: number;
merged?: number;
completed?: number;
avg_tokens?: number;
avg_steps?: number;
origin?: string;
}
/** A workflow definition, as the definitions endpoint reports it. */
export interface WorkflowDefinition {
id: string;
name?: string;
origin?: string;
enabled?: boolean;
/** The inputs the workflow declares, by name. A workflow that declares none
* is started without any, which is every workflow but pr-review today. */
inputs?: Record<string, { type: string; required?: boolean }>;
/** none, optional or required; a workflow that declares none needs a repository. */
repository?: string;
}
/** One table row: a definition, its statistics, or both. */
export interface WorkflowRow {
id: string;
name?: string;
workflow: string;
runs?: number;
merged?: number;
completed?: number;
avg_tokens?: number;
avg_steps?: number;
origin?: string;
}
/**
* workflowRows returns one row per known workflow, definitions first and in
* their declared order, then any workflow seen only in the statistics.
*/
export function workflowRows(
workflows: WorkflowStats[] | null | undefined,
definitions: WorkflowDefinition[] | null | undefined,
): WorkflowRow[] {
const stats = new Map((workflows || []).map((w) => [w.workflow, w]));
const rows: WorkflowRow[] = [];
const claimed = new Set<string>();
for (const definition of definitions || []) {
claimed.add(definition.id);
rows.push({
...definition,
...(stats.get(definition.id) || {
workflow: definition.id,
runs: 0,
merged: 0,
completed: 0,
}),
});
}
for (const workflow of workflows || []) {
if (claimed.has(workflow.workflow)) continue;
// No definition to describe it, so the id is the only name it has.
rows.push({ id: workflow.workflow, name: workflow.workflow, ...workflow });
}
return rows;
}