Watch
0
0
Fork
You've already forked hyperhive
0

swarm-ui: edit an agent's inference in place, and move the resource caps to access

The inference section was one wrapping line of badges, with the CPU and
memory caps among them, and an edit button that opened the same fields in
a dialog. The editor is now the section itself: a line says what the
agent runs on now and where it comes from, and the fields sit in one row
where there is room, with save, reset and clear below. Unsaved edits are
kept per agent. The claude login and API key row stays below. The caps
are not inference settings, so they become a row of the access section.
This commit is contained in:
iris 2026-11-23 18:11:05 +01:00 • committed by mara
commit e4cab003d1

View file

@ -0,0 +1,59 @@
// The inference boxes and the drafts kept per agent. Run by `npm test`, which
// Node runs with its built-in test runner and type stripping.
import assert from "node:assert/strict";
import { test } from "node:test";
import {
EMPTY_INFERENCE_DRAFT,
draftOf,
rememberDraft,
sameDraft,
} from "../src/agent/detail/inference-draft.ts";
const stored = {
model: "sonnet",
effort: "high",
subagent_models: ["haiku", "sonnet"],
max_subagents: 0,
soft_context_percent: 70,
fresh_session_percent: 40,
};
test("a stored value fills the boxes, and none stored fills them empty", () => {
assert.deepEqual(draftOf(stored), {
model: "sonnet",
effort: "high",
subagents: "haiku, sonnet",
maxSubagents: "0",
softContext: "70",
freshSession: "40",
});
assert.deepEqual(draftOf(null), EMPTY_INFERENCE_DRAFT);
assert.deepEqual(draftOf({}), EMPTY_INFERENCE_DRAFT);
});
test("drafts are the same only when every box matches", () => {
const base = draftOf(stored);
assert.ok(sameDraft(base, { ...base }));
for (const box of Object.keys(base)) {
assert.ok(!sameDraft(base, { ...base, [box]: base[box] + "x" }), box);
}
});
test("an edited draft is kept for its agent, and dropped once it matches again", () => {
const kept = new Map();
const base = draftOf(stored);
const edited = { ...base, effort: "low" };
rememberDraft(kept, "iris", edited, base);
assert.deepEqual(kept.get("iris"), edited);
rememberDraft(kept, "iris", { ...base }, base);
assert.equal(kept.has("iris"), false);
});
test("one agent's draft does not touch another's", () => {
const kept = new Map();
const base = draftOf(stored);
rememberDraft(kept, "iris", { ...base, model: "opus" }, base);
rememberDraft(kept, "argus", { ...base }, base);
assert.equal(kept.size, 1);
assert.equal(kept.get("iris").model, "opus");
});