Watch
0
0
Fork
You've already forked hyperhive
0

swarm-ui: say why the model dropdown has no models, and let it retry

The model list read swallowed every failure, so a swarm that timed out
answering /api/models looked the same as one with no models: the dropdown
held only the agent's own value and "other…", with nothing to say why.
The failure now shows as a warning with the controller's reason and a
retry button, and the answer is read through a parser that ignores any
shape but a list of names.
This commit is contained in:
iris 2026-11-23 20:31:55 +01:00 • committed by mara
commit 479cdd6efb

View file

@ -7,6 +7,7 @@ import {
isListedModel,
modelOptions,
modelSelectValue,
parseKnownModels,
} from "../src/agent/detail/model-choice.ts";
const KNOWN = ["haiku", "opus"];
@ -38,3 +39,16 @@ test("an open custom entry stays selected while its name is empty or listed", ()
assert.equal(modelSelectValue("", KNOWN, true), CUSTOM_MODEL);
assert.equal(modelSelectValue("opus", KNOWN, true), CUSTOM_MODEL);
});
test("the model list is read from the answer, and any other shape is none", () => {
assert.deepEqual(parseKnownModels({ models: ["opus", "sonnet"] }), [
"opus",
"sonnet",
]);
assert.deepEqual(parseKnownModels({ models: ["opus", "", 3, null] }), [
"opus",
]);
assert.deepEqual(parseKnownModels({}), []);
assert.deepEqual(parseKnownModels({ models: "opus" }), []);
assert.deepEqual(parseKnownModels(null), []);
});