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:
parent
da5c52e4c8
commit
479cdd6efb
1 changed files with 70 additions and 22 deletions
|
|
@ -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), []);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue