mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-15 19:32:20 +03:00
Landed with the design call resolved per the owner's pick — **option 1**: the synced store is now endpoint-agnostic (persistDiscoveredModels and managedModelImport no longer drop non-chat models at write time), and chat selectability moved to read time (auto-pool expansion in autoStrategy applies filterChatSelectableModels; the models-route projection already had its chatOnly filter). Your discovery test now passes end-to-end (3/3): /api/show capabilities persist per connection and image/embedding requests route through the advertising host. Reconciliation notes: conflicted areas merged onto the current tip (adobe discovery import, requestedModel preflight signature, resolvedProvider fast-path coexists with the synced-route override — explicit resolution wins); carried base-red drains (#10055 memoization, #11071 test variants) dropped as already-landed; the managed-model-import exclusion test was propagated to the new contract (image/video models persist; the read filter still hides them from chat pickers — pinned by a new assertion). Full battery: 205/206 focused (the one red is a confirmed periodic-timer timing flake on the loaded devbox — 20/20 isolated), autoCombo vitest 30/30, combo suites 46/46, gates + typecheck clean. Thank you @yourspraveen — the capability probe + routing design was right; it just needed the store contract opened up. Fixes #11087.
68 lines
2.8 KiB
TypeScript
68 lines
2.8 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import {
|
|
parseHiddenModelsByProvider,
|
|
isProviderModelHidden,
|
|
} from "../../src/shared/components/modelSelectModalHelpers.ts";
|
|
|
|
// Regression guard for #9203: the Combo "Add model" picker must hide every
|
|
// model source (system, fallback, passthrough alias, node alias, custom,
|
|
// auto-fetched) that the operator flagged hidden. The API serializes the DB's
|
|
// unified map as `Record<providerId, string[]>`; these helpers normalize it
|
|
// and answer per-provider lookups on the raw model id (before prefixing), so
|
|
// the component can apply one filter rule across all sources.
|
|
|
|
test("parseHiddenModelsByProvider: normalizes a valid response into a map", () => {
|
|
const raw = {
|
|
openai: ["gpt-hidden-1", "gpt-hidden-2"],
|
|
claude: ["claude-sonnet-4-6"],
|
|
};
|
|
const parsed = parseHiddenModelsByProvider(raw);
|
|
|
|
assert.deepEqual([...parsed.get("openai")!], ["gpt-hidden-1", "gpt-hidden-2"]);
|
|
assert.deepEqual([...parsed.get("claude")!], ["claude-sonnet-4-6"]);
|
|
assert.equal(parsed.has("anthropic"), false);
|
|
});
|
|
|
|
test("parseHiddenModelsByProvider: drops non-string model ids and empty entries", () => {
|
|
const raw = {
|
|
openai: ["valid", 42, null, "", { id: "obj" }],
|
|
empty: [],
|
|
claude: undefined,
|
|
};
|
|
const parsed = parseHiddenModelsByProvider(raw);
|
|
|
|
assert.deepEqual([...parsed.get("openai")!], ["valid"]);
|
|
assert.equal(parsed.has("empty"), false);
|
|
assert.equal(parsed.has("claude"), false);
|
|
});
|
|
|
|
test("parseHiddenModelsByProvider: tolerates missing / null / malformed payloads", () => {
|
|
assert.equal(parseHiddenModelsByProvider(undefined).size, 0);
|
|
assert.equal(parseHiddenModelsByProvider(null).size, 0);
|
|
assert.equal(parseHiddenModelsByProvider("nope").size, 0);
|
|
assert.equal(parseHiddenModelsByProvider(["array"]).size, 0);
|
|
assert.equal(parseHiddenModelsByProvider(42).size, 0);
|
|
});
|
|
|
|
test("isProviderModelHidden: matches on the raw model id per provider", () => {
|
|
const parsed = parseHiddenModelsByProvider({
|
|
openai: ["gpt-hidden"],
|
|
claude: ["claude-sonnet-4-6"],
|
|
});
|
|
|
|
assert.equal(isProviderModelHidden(parsed, "openai", "gpt-hidden"), true);
|
|
assert.equal(isProviderModelHidden(parsed, "claude", "claude-sonnet-4-6"), true);
|
|
// Visible / different-provider / unknown ids are not hidden.
|
|
assert.equal(isProviderModelHidden(parsed, "openai", "gpt-visible"), false);
|
|
assert.equal(isProviderModelHidden(parsed, "claude", "gpt-hidden"), false);
|
|
assert.equal(isProviderModelHidden(parsed, "unknown", "gpt-hidden"), false);
|
|
});
|
|
|
|
test("isProviderModelHidden: empty map and malformed inputs are never hidden", () => {
|
|
const empty = new Map<string, Set<string>>();
|
|
assert.equal(isProviderModelHidden(empty, "openai", "anything"), false);
|
|
assert.equal(isProviderModelHidden(empty, "openai", ""), false);
|
|
assert.equal(isProviderModelHidden(empty, "", "x"), false);
|
|
});
|