web: filter the chat model picker

Add a search field that narrows models by name, id or provider in place, keeps
focus while typing, and reports when nothing matches.
This commit is contained in:
2026-10-20 15:04:10 +01:00
parent 1480591a34
commit 9f29f387ba
5 changed files with 85 additions and 17 deletions
+14
View File
@@ -111,6 +111,7 @@ import {
deltaPartId,
directoryChoices,
directoryLabel,
filterChatModels,
homeDirectoryFor,
abbreviateHome,
dismissChatNotice,
@@ -572,6 +573,19 @@ test("groupSessionsByDirectory groups in first-occurrence order and labels a bla
assert.equal(directoryLabel("/a"), "/a");
});
test("filterChatModels matches name, id or provider case-insensitively", () => {
const models = [
{ id: "deepseek-v4.1-flash", provider: "opencode-go", name: "DeepSeek V4.1 Flash" },
{ id: "gpt-6-luna", provider: "openai", name: "GPT-6 Luna" },
{ id: "beam-free", provider: "opencode-go", name: "Beam Free" },
];
assert.deepEqual(filterChatModels(models, "").map((m) => m.id), models.map((m) => m.id));
assert.deepEqual(filterChatModels(models, "LUNA").map((m) => m.id), ["gpt-6-luna"]);
assert.deepEqual(filterChatModels(models, "deepseek").map((m) => m.id), ["deepseek-v4.1-flash"]);
assert.deepEqual(filterChatModels(models, "opencode-go").map((m) => m.id), ["deepseek-v4.1-flash", "beam-free"]);
assert.deepEqual(filterChatModels(models, "nothing"), []);
});
test("directory labels abbreviate the user's home to ~", () => {
const home = homeDirectoryFor(["/Users/alan/repos/pipelines", "/Users/alan/notes"]);
assert.equal(home, "/Users/alan");