feat(webui): render scalar config sections generically from the schema
settings.js drops identityCard/budgetsCard/storageCard/webCard/ pullPolicyLabel in favour of one schemaCards() that walks cfg.schema and builds a card per section, a row per non-structured field -- label, type, description, editability and enum options all come from the backend descriptor instead of a hardcoded row(...) call per key. config-row.js gains: enum fields edit as a <select> from opts.options; opts.editable === false renders read-only distinct from a locked row (no reason to show, just no edit affordance); opts.hint carries a field's description as the label's tooltip, so "0 means unlimited." travels with the field instead of being baked into a display-value string per key. ConfigSection also gains Description, filled in per section to match each card's existing sub-text, since the card's own explanation is schema metadata too. Structured sections (repositories, models & providers) are untouched -- still the existing bespoke renderers, reserved for archie-core-b6ew.4. Closes archie-core-b6ew.3
This commit is contained in:
1 parent
e442eb5a72
commit
35eb4050de
6 files changed
+117
-106
No files matched your search
+1
-1
@@ -93,7 +93,7 @@
|
||||
{"_type":"issue","id":"archie-core-dzx","title":"Remove duplicate archie-agent safe.directory setup","description":"## Problem\\ncmd/archie-agent/main.go configures git safe.directory inline and then calls markWorktreeSafe, so startup writes the same global git configuration twice.\\n\\n## Scope\\nKeep markWorktreeSafe as the single tested production path and remove the older inline exec.Command block/import. Add regression coverage proving startup wiring has exactly one authoritative safe-directory call.\\n\\n## Acceptance\\n- archie-agent startup invokes markWorktreeSafe exactly once\\n- no second inline safe.directory command remains in main.go\\n- cmd/archie-agent tests and repository quality gate pass","acceptance_criteria":"Single tested safe.directory setup path remains; duplicate inline command is removed; tests and task check pass","notes":"Red proof: TestMainConfiguresWorktreeSafetyOnce failed with 2 setup paths before implementation. Green proof: go test/vet/build ./cmd/archie-agent/... passed; golangci-lint --new-from-rev=HEAD reported 0 issues. Fresh adversarial review found no blockers. Full task check was not run because the working tree contains unrelated in-progress changes and task check rewrites files; scoped package gate used per repository protocol.","status":"closed","priority":1,"issue_type":"bug","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-08-13T16:10:09Z","created_by":"Sam Catlow","updated_at":"2026-08-13T16:13:48Z","started_at":"2026-08-13T16:10:24Z","closed_at":"2026-08-13T16:13:48Z","close_reason":"Removed duplicate inline safe.directory setup; markWorktreeSafe is now the single tested production path","external_ref":"https://github.com/samcharles93/archie-core/issues/470","dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-b6ew.4","title":"Structured configuration editors: repositories, maps","description":"Repositories currently render as a static read-only table missing AllowConcurrent, MaxRetries, and ReviewEnabled entirely (ReviewEnabled is absent from RepoView in api_config.go, not just unrendered). Add ReviewEnabled to RepoView, and build a dedicated backend-defined editor for the repositories section (and the models/providers maps) so these stop being silently read-only. This is the concrete fix for the allow_concurrent discoverability gap Sam hit, delivered as a typed editor rather than a one-off card patch, since the schema this epic introduces is what should own its shape.","status":"open","priority":2,"issue_type":"feature","owner":"sam@catlow.tech","created_at":"2026-09-02T12:00:46Z","created_by":"Sam Catlow","updated_at":"2026-09-02T12:00:46Z","dependencies":[{"issue_id":"archie-core-b6ew.4","depends_on_id":"archie-core-b6ew","type":"parent-child","created_at":"2026-09-02T12:00:46Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-b6ew.4","depends_on_id":"archie-core-b6ew.2","type":"blocks","created_at":"2026-09-02T12:00:51Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":1,"dependent_count":1,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-b6ew.5","title":"Schema contract tests: metadata completeness and secret-safety","description":"Assert every field the schema exposes carries type, label, and section; assert restart_required and editable are set deliberately (not zero-value defaults hiding an unreviewed field); assert secrets still never appear (extend the existing TestHandleConfigNeverLeaksSecrets pattern to the schema response); assert the frontend's generic renderer can render the full schema fixture without any field-specific branch (a JS test walking the schema and asserting no field key appears literally in settings.js).","status":"open","priority":2,"issue_type":"task","owner":"sam@catlow.tech","created_at":"2026-09-02T12:00:46Z","created_by":"Sam Catlow","updated_at":"2026-09-02T12:00:46Z","dependencies":[{"issue_id":"archie-core-b6ew.5","depends_on_id":"archie-core-b6ew","type":"parent-child","created_at":"2026-09-02T12:00:46Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-b6ew.5","depends_on_id":"archie-core-b6ew.3","type":"blocks","created_at":"2026-09-02T12:00:52Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-b6ew.5","depends_on_id":"archie-core-b6ew.4","type":"blocks","created_at":"2026-09-02T12:00:52Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":2,"dependent_count":0,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-b6ew.3","title":"Generic frontend renderer for scalar configuration fields","description":"Replace settings.js's hardcoded row(...) calls for scalar/bool/int/enum/duration fields with a renderer that walks the backend's sections/fields schema and builds the section cards, labels, and edit affordances from the descriptor alone -- the frontend must not know that containers.max_concurrency is an int or which card it belongs in. Structured fields (repositories, models, providers maps) are out of scope here and keep their existing bespoke rendering, tagged type=structured so the generic renderer skips them without special-casing each key.","status":"open","priority":2,"issue_type":"feature","owner":"sam@catlow.tech","created_at":"2026-09-02T12:00:45Z","created_by":"Sam Catlow","updated_at":"2026-09-02T12:00:45Z","dependencies":[{"issue_id":"archie-core-b6ew.3","depends_on_id":"archie-core-b6ew","type":"parent-child","created_at":"2026-09-02T12:00:45Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-b6ew.3","depends_on_id":"archie-core-b6ew.2","type":"blocks","created_at":"2026-09-02T12:00:50Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":1,"dependent_count":1,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-b6ew.3","title":"Generic frontend renderer for scalar configuration fields","description":"Replace settings.js's hardcoded row(...) calls for scalar/bool/int/enum/duration fields with a renderer that walks the backend's sections/fields schema and builds the section cards, labels, and edit affordances from the descriptor alone -- the frontend must not know that containers.max_concurrency is an int or which card it belongs in. Structured fields (repositories, models, providers maps) are out of scope here and keep their existing bespoke rendering, tagged type=structured so the generic renderer skips them without special-casing each key.","status":"closed","priority":2,"issue_type":"feature","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-09-02T12:00:45Z","created_by":"Sam Catlow","updated_at":"2026-09-02T12:12:41Z","started_at":"2026-09-02T12:08:25Z","closed_at":"2026-09-02T12:12:41Z","close_reason":"settings.js renders identity/budgets/storage/web cards generically from cfg.schema sections (schemaCards()), replacing identityCard/budgetsCard/storageCard/webCard/pullPolicyLabel -- label, type, description, editability, and options all come from the backend descriptor. config-row.js gained enum edit support (select from opts.options), an editable:false branch distinct from locked rows, and a hint tooltip carrying the field's description. Structured sections (repositories, models \u0026 providers) are unaffected -- still rendered by their existing bespoke functions, reserved for b6ew.4. Not visually verified in a live browser (needs a full daemon+forge+NATS stack); verified via unit tests mirroring the existing config-row.test.js patterns and Go contract tests.","dependencies":[{"issue_id":"archie-core-b6ew.3","depends_on_id":"archie-core-b6ew","type":"parent-child","created_at":"2026-09-02T12:00:45Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-b6ew.3","depends_on_id":"archie-core-b6ew.2","type":"blocks","created_at":"2026-09-02T12:00:50Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":1,"dependent_count":1,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-b6ew.1","title":"Backend configuration schema contract: field descriptor types and section metadata","description":"Define the descriptor types (Section, Field, Option) in internal/webui alongside ConfigView -- Key, Label, Description, Section, Type (string|int|bool|duration|enum|structured), Editable, LockedReason, Overridden, Options, RestartRequired. Hand-author one descriptor per existing ConfigView field, grouped into the sections the settings page already renders (identity, repositories, models, providers, budgets, storage, containers, web). No reflection over config.Config -- config.Config is scheduled for dissolution (internal/config/config.go package doc) and every field here is already a deliberate allowlist entry, so this is metadata on fields that already passed the secret-safety allowlist, not a new safety boundary.","status":"closed","priority":2,"issue_type":"feature","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-09-02T12:00:44Z","created_by":"Sam Catlow","updated_at":"2026-09-02T12:05:40Z","started_at":"2026-09-02T12:02:40Z","closed_at":"2026-09-02T12:05:40Z","close_reason":"Added internal/webui/config_schema.go: ConfigFieldType/ConfigField/ConfigSection descriptor types and configFieldDescriptors(), hand-authoring key/label/type/editable/restart_required for every field ConfigView exposes today, grouped into the sections settings.js already renders. RestartRequired sourced from internal/app/archied/reload.go's reloadableFields/reloadableSubFields allowlist. Contract tests pin key completeness, structured-field non-editability, and locked-storage-field non-editability. Not yet wired into GET /api/config -- that's b6ew.2.","dependencies":[{"issue_id":"archie-core-b6ew.1","depends_on_id":"archie-core-b6ew","type":"parent-child","created_at":"2026-09-02T12:00:44Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":0,"dependent_count":1,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-b6ew.2","title":"Expose the config schema via GET /api/config","description":"Extend handleConfig's response with a schema-driven shape (sections of fields, each carrying its descriptor and current value) built from the field descriptors, replacing the flat ConfigView value tree the frontend currently re-interprets by hand. Keep the existing Locked/Overridden/Reload/Provenance top-level fields -- they describe runtime state, not the field catalog, and the schema-driven fields reference into them (locked_reason, overridden) rather than duplicating that logic.","status":"closed","priority":2,"issue_type":"feature","assignee":"Sam Catlow","owner":"sam@catlow.tech","created_at":"2026-09-02T12:00:44Z","created_by":"Sam Catlow","updated_at":"2026-09-02T12:07:58Z","started_at":"2026-09-02T12:06:31Z","closed_at":"2026-09-02T12:07:58Z","close_reason":"ConfigView gains a Schema []ConfigSection field, populated in handleConfig via buildConfigSchema(view), which attaches each request's Value/LockedReason/Overridden onto the static configFieldDescriptors() catalog. The flat ConfigView fields (Identity, Repositories, etc.) are untouched -- Schema is additive. Tests confirm schema values match the flat fields they derive from, locked reasons propagate, structured fields stay non-editable, and secrets never reach the schema block.","dependencies":[{"issue_id":"archie-core-b6ew.2","depends_on_id":"archie-core-b6ew","type":"parent-child","created_at":"2026-09-02T12:00:44Z","created_by":"Sam Catlow","metadata":"{}"},{"issue_id":"archie-core-b6ew.2","depends_on_id":"archie-core-b6ew.1","type":"blocks","created_at":"2026-09-02T12:00:50Z","created_by":"Sam Catlow","metadata":"{}"}],"dependency_count":1,"dependent_count":2,"comment_count":0}
|
||||
{"_type":"issue","id":"archie-core-b6ew","title":"[EPIC] Backend-owned configuration schema for the webui Configuration page","description":"The Configuration page's field definitions (label, section, type, editability, restart-required, options) are hand-maintained in ui/src/settings/settings.js and config-row.js, disjoint from the backend's own ConfigView allowlist in internal/webui/api_config.go. Adding or changing a runtime-tunable setting today means editing Go and JS in two unrelated places by hand, and nothing catches drift between them. Repo.ReviewEnabled is missing from the API entirely; AllowConcurrent and MaxRetries reach the API but the repositories card never renders them, which is what blocked Sam from discovering the allow_concurrent fix without an agent tracing the Go source directly.\n\nDesign: docs/prds/config-schema.md. The backend keeps its existing hand-picked, secret-free allowlist (ConfigView in api_config.go) -- config.Config is scheduled for dissolution per its own package doc, so this is deliberately NOT a reflection-based schema over config.Config. Instead each already-allowlisted field gains a hand-authored descriptor (label, section, type, editable, restart_required, options) alongside its existing value, and the frontend renders scalar/bool/int/enum/duration fields generically from that descriptor instead of hardcoding rows. Structured fields (repositories, maps) get dedicated typed editors rather than staying silently read-only.","status":"open","priority":2,"issue_type":"epic","owner":"sam@catlow.tech","created_at":"2026-09-02T12:00:27Z","created_by":"Sam Catlow","updated_at":"2026-09-02T12:00:27Z","dependency_count":0,"dependent_count":0,"comment_count":0}
|
||||
|
||||
@@ -69,9 +69,10 @@ type ConfigField struct {
|
||||
// ConfigSection groups fields the same way the settings page's cards
|
||||
// already do -- no new sections, this is metadata on existing rows.
|
||||
type ConfigSection struct {
|
||||
ID string `json:"id"`
|
||||
Label string `json:"label"`
|
||||
Fields []ConfigField `json:"fields"`
|
||||
ID string `json:"id"`
|
||||
Label string `json:"label"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Fields []ConfigField `json:"fields"`
|
||||
}
|
||||
|
||||
// configFieldDescriptors is the hand-authored catalog: one entry per field
|
||||
@@ -98,8 +99,9 @@ type ConfigSection struct {
|
||||
func configFieldDescriptors() []ConfigSection {
|
||||
return []ConfigSection{
|
||||
{
|
||||
ID: "identity",
|
||||
Label: "Identity",
|
||||
ID: "identity",
|
||||
Label: "Identity",
|
||||
Description: "Who Archie is on the forge, and how it addresses commits and comments.",
|
||||
Fields: []ConfigField{
|
||||
{Key: "bot_user", Label: "Bot account", Type: FieldString, Editable: true},
|
||||
{Key: "bot_email", Label: "Commit author email", Type: FieldString, Editable: true},
|
||||
@@ -110,8 +112,9 @@ func configFieldDescriptors() []ConfigSection {
|
||||
},
|
||||
},
|
||||
{
|
||||
ID: "repositories",
|
||||
Label: "Repositories",
|
||||
ID: "repositories",
|
||||
Label: "Repositories",
|
||||
Description: "Each repository Archie polls, and the quality gate a change must pass before it opens a pull request.",
|
||||
Fields: []ConfigField{
|
||||
{
|
||||
Key: "repos",
|
||||
@@ -123,16 +126,18 @@ func configFieldDescriptors() []ConfigSection {
|
||||
},
|
||||
},
|
||||
{
|
||||
ID: "models",
|
||||
Label: "Models & providers",
|
||||
ID: "models",
|
||||
Label: "Models & providers",
|
||||
Description: "Which model handles each stage of work, and which LLM providers are wired up. Only the environment variable NAME is shown, never its value.",
|
||||
Fields: []ConfigField{
|
||||
{Key: "models", Label: "Model roles", Type: FieldStructured, Editable: false},
|
||||
{Key: "providers", Label: "Providers", Type: FieldStructured, Editable: false},
|
||||
},
|
||||
},
|
||||
{
|
||||
ID: "budgets",
|
||||
Label: "Budgets",
|
||||
ID: "budgets",
|
||||
Label: "Budgets",
|
||||
Description: "The limits every autonomous stage runs under, so a stuck task cannot run forever.",
|
||||
Fields: []ConfigField{
|
||||
{Key: "budgets.max_steps", Label: "Max steps", Description: "0 means unlimited.", Type: FieldInt, Editable: true},
|
||||
{Key: "budgets.wall_clock", Label: "Wall clock", Type: FieldDuration, Editable: true},
|
||||
@@ -140,27 +145,29 @@ func configFieldDescriptors() []ConfigSection {
|
||||
},
|
||||
},
|
||||
{
|
||||
ID: "storage",
|
||||
Label: "Storage & sandboxing",
|
||||
ID: "storage",
|
||||
Label: "Storage & sandboxing",
|
||||
Description: "Where archied keeps its state, and how it isolates task execution.",
|
||||
Fields: []ConfigField{
|
||||
{Key: "work_dir", Label: "Work directory", Type: FieldString, Editable: false},
|
||||
{Key: "db_path", Label: "State path prefix", Type: FieldString, Editable: false},
|
||||
{Key: "skills_dir", Label: "Shared skills directory", Type: FieldString, Editable: true, RestartRequired: true},
|
||||
{Key: "plugin_dir", Label: "Daemon plugin directory", Type: FieldString, Editable: true, RestartRequired: true},
|
||||
{Key: "secret_engine_dir", Label: "Secret engine plugin directory", Type: FieldString, Editable: true, RestartRequired: true},
|
||||
{Key: "skills_dir", Label: "Shared skills directory", Description: "Empty uses the work directory.", Type: FieldString, Editable: true, RestartRequired: true},
|
||||
{Key: "plugin_dir", Label: "Daemon plugin directory", Description: "Empty means no daemon plugins.", Type: FieldString, Editable: true, RestartRequired: true},
|
||||
{Key: "secret_engine_dir", Label: "Secret engine plugin directory", Description: "Empty means built-in secret engines only.", Type: FieldString, Editable: true, RestartRequired: true},
|
||||
{Key: "containers.image", Label: "Agent image", Type: FieldString, Editable: true, RestartRequired: true},
|
||||
{Key: "containers.max_concurrency", Label: "Max concurrent tasks", Description: "0 means unlimited.", Type: FieldInt, Editable: true, RestartRequired: true},
|
||||
{Key: "containers.max_uptime", Label: "Container max lifetime", Type: FieldDuration, Editable: true, RestartRequired: true},
|
||||
{Key: "containers.volume_ttl", Label: "Persistent volume retention", Type: FieldDuration, Editable: true},
|
||||
{Key: "containers.pull_policy", Label: "How images are refreshed", Type: FieldEnum, Options: []string{"missing", "always"}, Editable: true, RestartRequired: true},
|
||||
{Key: "containers.network", Label: "Docker network", Type: FieldString, Editable: true, RestartRequired: true},
|
||||
{Key: "containers.pull_policy", Label: "How images are refreshed", Description: `"missing" pulls only when the image isn't present locally; "always" pulls before every run.`, Type: FieldEnum, Options: []string{"missing", "always"}, Editable: true, RestartRequired: true},
|
||||
{Key: "containers.network", Label: "Docker network", Description: "Empty auto-detects the Docker network.", Type: FieldString, Editable: true, RestartRequired: true},
|
||||
},
|
||||
},
|
||||
{
|
||||
ID: "web",
|
||||
Label: "Dashboard",
|
||||
ID: "web",
|
||||
Label: "Dashboard",
|
||||
Description: "This dashboard's own listen address.",
|
||||
Fields: []ConfigField{
|
||||
{Key: "web.listen", Label: "Listen address", Type: FieldString, Editable: true, RestartRequired: true},
|
||||
{Key: "web.listen", Label: "Listen address", Description: `"off" disables the dashboard.`, Type: FieldString, Editable: true, RestartRequired: true},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -19,6 +19,9 @@ func TestConfigFieldDescriptorsAreComplete(t *testing.T) {
|
||||
if section.Label == "" {
|
||||
t.Errorf("section %q has no label", section.ID)
|
||||
}
|
||||
if section.Description == "" {
|
||||
t.Errorf("section %q has no description", section.ID)
|
||||
}
|
||||
if len(section.Fields) == 0 {
|
||||
t.Errorf("section %q has no fields", section.ID)
|
||||
}
|
||||
|
||||
@@ -42,7 +42,11 @@ export function valueText(value) {
|
||||
// widening the row back into the action column.
|
||||
export function row(label, value, opts) {
|
||||
const text = valueText(value);
|
||||
const labelEl = el("span.kv-label", label);
|
||||
// opts.hint (a field's backend-authored description, e.g. "0 means
|
||||
// unlimited.") rides as a tooltip on the label rather than its own DOM
|
||||
// node, so a generic schema-driven field can carry an explanation
|
||||
// without every hardcoded caller having to pass one.
|
||||
const labelEl = el("span.kv-label", opts?.hint ? { title: opts.hint } : {}, label);
|
||||
const valueEl = el(`span.kv-value.mono${text === "—" ? ".is-empty" : ""}`, { title: text }, text);
|
||||
|
||||
if (!opts?.key) return el("div.kv", labelEl, valueEl);
|
||||
@@ -54,6 +58,11 @@ export function row(label, value, opts) {
|
||||
return el("div.kv.is-locked", labelEl, valueEl, el("span.kv-note", lockedReason));
|
||||
}
|
||||
|
||||
// opts.editable distinguishes a field the schema marks not-yet-editable
|
||||
// (e.g. a structured field with no dedicated editor) from a locked one:
|
||||
// no reason to show, just no edit affordance.
|
||||
if (opts.editable === false) return el("div.kv", labelEl, valueEl);
|
||||
|
||||
const overridden = opts.overridden?.includes(opts.key);
|
||||
const editBtn = el("button.kv-btn", { type: "button", title: `Edit ${label}` }, "Edit");
|
||||
const resetBtn = overridden
|
||||
@@ -101,14 +110,19 @@ function note(rowEl, message) {
|
||||
}
|
||||
|
||||
function startEdit(rowEl, label, opts, restore) {
|
||||
const { key, type, raw, onSaved } = opts;
|
||||
const { key, type, raw, options, onSaved } = opts;
|
||||
const input = type === "bool"
|
||||
? el(
|
||||
"select.kv-input",
|
||||
el("option", { value: "true", selected: raw === true }, "true"),
|
||||
el("option", { value: "false", selected: raw === false }, "false"),
|
||||
)
|
||||
: el("input.kv-input", { type: "text", value: String(raw ?? "") });
|
||||
: type === "enum"
|
||||
? el(
|
||||
"select.kv-input",
|
||||
...(options || []).map((o) => el("option", { value: o, selected: raw === o }, o)),
|
||||
)
|
||||
: el("input.kv-input", { type: "text", value: String(raw ?? "") });
|
||||
const save = el("button.kv-save", { type: "button" }, "Save");
|
||||
const cancel = el("button.kv-cancel", { type: "button" }, "Cancel");
|
||||
const error = el("span.kv-note.is-error");
|
||||
|
||||
+30
-81
@@ -119,14 +119,40 @@ export function settingsPage() {
|
||||
mount(
|
||||
body,
|
||||
...banners,
|
||||
identityCard(cfg.identity, ctx),
|
||||
...schemaCards(cfg.schema || []),
|
||||
repositoriesCard(cfg.repositories),
|
||||
modelsAndProvidersCard(cfg.models, cfg.providers),
|
||||
budgetsCard(cfg.budgets, ctx),
|
||||
storageCard(cfg.storage, cfg.containers, ctx),
|
||||
webCard(cfg.web, ctx),
|
||||
provenanceCard(cfg.provenance),
|
||||
);
|
||||
|
||||
// schemaCards renders one card per backend-defined section, generically,
|
||||
// from cfg.schema (archie-core-b6ew) -- a scalar field's label, type,
|
||||
// description and editability all come from the backend, not from a
|
||||
// hardcoded row(...) call here. A section whose fields are all
|
||||
// type=structured (repositories, models & providers) renders no card
|
||||
// here; those keep the dedicated renderers above, called directly off
|
||||
// the flat cfg fields (archie-core-b6ew.4 gives them their own editors).
|
||||
function schemaCards(sections) {
|
||||
return sections
|
||||
.map((s) => {
|
||||
const rows = s.fields
|
||||
.filter((f) => f.type !== "structured")
|
||||
.map((f) =>
|
||||
row(f.label, f.value, {
|
||||
key: f.key,
|
||||
type: f.type,
|
||||
options: f.options,
|
||||
raw: f.value,
|
||||
hint: f.description,
|
||||
editable: f.editable,
|
||||
...ctx,
|
||||
}),
|
||||
);
|
||||
if (!rows.length) return null;
|
||||
return section(s.label, s.description, el("div.kv-list", ...rows));
|
||||
})
|
||||
.filter(Boolean);
|
||||
}
|
||||
}
|
||||
|
||||
return root;
|
||||
@@ -197,23 +223,6 @@ function roleButtonClass(kind) {
|
||||
return kind === "quiet" ? "btn-quiet" : kind === "danger" ? "btn-danger" : "";
|
||||
}
|
||||
|
||||
function identityCard(identity, ctx) {
|
||||
if (!identity) return section("Identity", "Who Archie is on the forge.", empty("Not available"));
|
||||
return section(
|
||||
"Identity",
|
||||
"Who Archie is on the forge, and how it addresses commits and comments.",
|
||||
el(
|
||||
"div.kv-list",
|
||||
row("Bot account", identity.bot_user, { key: "bot_user", type: "string", raw: identity.bot_user, ...ctx }),
|
||||
row("Commit author email", identity.bot_email, { key: "bot_email", type: "string", raw: identity.bot_email, ...ctx }),
|
||||
row("Pickup label", identity.label, { key: "label", type: "string", raw: identity.label, ...ctx }),
|
||||
row("Forge type", identity.forge_type, { key: "forge.type", type: "string", raw: identity.forge_type, ...ctx }),
|
||||
row("Forge host", identity.forge_host, { key: "forge.host", type: "string", raw: identity.forge_host, ...ctx }),
|
||||
row("Max diff size (lines)", identity.diff_cap_lines || "Unlimited", { key: "diff_cap_lines", type: "int", raw: identity.diff_cap_lines, ...ctx }),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function repositoriesCard(repos) {
|
||||
if (!repos?.length) {
|
||||
return section(
|
||||
@@ -302,63 +311,3 @@ function roleLabel(role) {
|
||||
return role.charAt(0).toUpperCase() + role.slice(1).replace(/_/g, " ");
|
||||
}
|
||||
|
||||
function budgetsCard(budgets, ctx) {
|
||||
if (!budgets) return section("Budgets", "Limits on every agent stage.", empty("Not available"));
|
||||
return section(
|
||||
"Budgets",
|
||||
"The limits every autonomous stage runs under, so a stuck task cannot run forever.",
|
||||
el(
|
||||
"div.kv-list",
|
||||
row("Max steps", budgets.max_steps || "Unlimited", { key: "budgets.max_steps", type: "int", raw: budgets.max_steps, ...ctx }),
|
||||
row("Wall clock", budgets.wall_clock, { key: "budgets.wall_clock", type: "string", raw: budgets.wall_clock, ...ctx }),
|
||||
row("Max gate failures before parking", budgets.gate_max_failures || "Unlimited", { key: "budgets.gate_max_failures", type: "int", raw: budgets.gate_max_failures, ...ctx }),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function storageCard(storage, containers, ctx) {
|
||||
const children = [];
|
||||
if (storage) {
|
||||
children.push(
|
||||
el("h3.cfg-subhead", "Paths"),
|
||||
el(
|
||||
"div.kv-list",
|
||||
row("Work directory", storage.work_dir, { key: "work_dir", type: "string", ...ctx }),
|
||||
row("State path prefix", storage.db_path, { key: "db_path", type: "string", ...ctx }),
|
||||
row("Shared skills directory", storage.skills_dir || "None (uses the work directory)", { key: "skills_dir", type: "string", raw: storage.skills_dir, ...ctx }),
|
||||
row("Daemon plugin directory", storage.plugin_dir || "None", { key: "plugin_dir", type: "string", raw: storage.plugin_dir, ...ctx }),
|
||||
row("Secret engine plugin directory", storage.secret_engine_dir || "None (built-in engines only)", { key: "secret_engine_dir", type: "string", raw: storage.secret_engine_dir, ...ctx }),
|
||||
),
|
||||
);
|
||||
}
|
||||
if (containers) {
|
||||
children.push(
|
||||
el("h3.cfg-subhead", "Sandboxed containers"),
|
||||
el(
|
||||
"div.kv-list",
|
||||
row("Agent image", containers.image || "Not set", { key: "containers.image", type: "string", raw: containers.image, ...ctx }),
|
||||
row("Max concurrent tasks", containers.max_concurrency || "Unlimited", { key: "containers.max_concurrency", type: "int", raw: containers.max_concurrency, ...ctx }),
|
||||
row("Container max lifetime", containers.max_uptime, { key: "containers.max_uptime", type: "string", raw: containers.max_uptime, ...ctx }),
|
||||
row("Persistent volume retention", containers.volume_ttl, { key: "containers.volume_ttl", type: "string", raw: containers.volume_ttl, ...ctx }),
|
||||
row("How images are refreshed", pullPolicyLabel(containers.pull_policy), { key: "containers.pull_policy", type: "string", raw: containers.pull_policy, ...ctx }),
|
||||
row("Docker network", containers.network || "Auto-detected", { key: "containers.network", type: "string", raw: containers.network, ...ctx }),
|
||||
),
|
||||
);
|
||||
}
|
||||
if (!children.length) children.push(empty("Not available"));
|
||||
return section("Storage & sandboxing", "Where archied keeps its state, and how it isolates task execution.", ...children);
|
||||
}
|
||||
|
||||
function pullPolicyLabel(policy) {
|
||||
if (policy === "always") return "Always pull the latest image before running";
|
||||
return "Only pull when the image is missing locally";
|
||||
}
|
||||
|
||||
function webCard(web, ctx) {
|
||||
if (!web) return section("Dashboard", "This dashboard's own listen address.", empty("Not available"));
|
||||
return section(
|
||||
"Dashboard",
|
||||
"This dashboard's own listen address.",
|
||||
el("div.kv-list", row("Listen address", web.listen === "off" ? "Disabled" : web.listen, { key: "web.listen", type: "string", raw: web.listen === "off" ? "" : web.listen, ...ctx })),
|
||||
);
|
||||
}
|
||||
@@ -92,3 +92,41 @@ test("int edits reject a non-numeric entry before the round trip", () => {
|
||||
assert.equal(parseEdit("bool", "false").value, false);
|
||||
assert.equal(parseEdit("string", "1h0m0s").value, "1h0m0s");
|
||||
});
|
||||
|
||||
// archie-core-b6ew.3: a schema-driven field with editable: false (a
|
||||
// structured field with no dedicated editor yet, or a field the backend
|
||||
// deliberately doesn't allow editing) must not offer an Edit button, even
|
||||
// though it has a key -- distinct from a locked row, which does have a key
|
||||
// and a reason.
|
||||
test("a field marked editable: false renders read-only with no note", () => {
|
||||
const rowEl = row("Model roles", "{...}", { key: "models", type: "structured", editable: false });
|
||||
const parts = cells(rowEl);
|
||||
assert.equal(parts.length, 2, "expected only label and value, no actions or note");
|
||||
assert.ok(!classOf(rowEl).includes("is-locked"));
|
||||
});
|
||||
|
||||
// A locked reason still takes priority over editable: true -- the runtime
|
||||
// state (overlay.DeniedKeys) wins over the schema's static claim.
|
||||
test("a locked reason is shown even when the field claims editable: true", () => {
|
||||
const rowEl = row("Work directory", "/work/archie", {
|
||||
key: "work_dir",
|
||||
editable: true,
|
||||
locked: { work_dir: "pins the daemon's working layout; cannot be changed at runtime" },
|
||||
});
|
||||
assert.ok(classOf(rowEl).includes("is-locked"));
|
||||
});
|
||||
|
||||
// archie-core-b6ew.3: the backend-authored field description rides as a
|
||||
// tooltip on the label, so a generic renderer can carry "0 means
|
||||
// unlimited." without any field-specific frontend code.
|
||||
test("a field's hint becomes the label's title attribute", () => {
|
||||
const rowEl = row("Max steps", 0, { hint: "0 means unlimited." });
|
||||
const label = rowEl.childNodes.find((c) => classOf(c).includes("kv-label"));
|
||||
assert.equal(label.attrs.title, "0 means unlimited.");
|
||||
});
|
||||
|
||||
test("a field with no hint renders a plain label with no title", () => {
|
||||
const rowEl = row("Max steps", 0, {});
|
||||
const label = rowEl.childNodes.find((c) => classOf(c).includes("kv-label"));
|
||||
assert.equal(label.attrs.title, undefined);
|
||||
});
|
||||
Reference in new issue
Block a user