* fix(agents): preserve Claude thinking selections Model switches now resolve thinking against the target model's saved preference instead of resetting to the catalog default. Claude owns its configured-model defaults and legacy Fable alias handling, while persisted permission modes remain unchanged. * chore(claude): tag Fable compatibility shim * fix(app): resolve persisted model aliases * fix(models): preserve aliases for older clients * fix(models): hide compatibility aliases from listings * fix(settings): hide compatibility model aliases * test(claude): cover legacy catalog entry * test(app): expect mock thinking controls in schedules * fix(app): preserve queued thinking preferences * fix(app): reconcile schedule provider snapshots * fix(app): preserve schedule model selections * fix(claude): preserve exact configured model ids * fix(app): preserve committed thinking preferences * fix(app): preserve aliased schedule thinking
87 lines
2.4 KiB
TypeScript
87 lines
2.4 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import type { AgentModelDefinition } from "@getpaseo/protocol/agent-types";
|
|
import {
|
|
resolveProviderDiscoveredModels,
|
|
type ProviderDiscoveredModelsCache,
|
|
} from "./provider-diagnostic-models";
|
|
|
|
const piModel: AgentModelDefinition = {
|
|
provider: "pi",
|
|
id: "pi/model",
|
|
label: "Pi Model",
|
|
};
|
|
|
|
const grokModel: AgentModelDefinition = {
|
|
provider: "grok",
|
|
id: "grok-build",
|
|
label: "Grok Build",
|
|
};
|
|
|
|
function resolveModels(input: {
|
|
serverId?: string;
|
|
provider: string;
|
|
currentModels?: AgentModelDefinition[];
|
|
loading?: boolean;
|
|
cache?: ProviderDiscoveredModelsCache | null;
|
|
}) {
|
|
return resolveProviderDiscoveredModels({
|
|
serverId: input.serverId ?? "local",
|
|
provider: input.provider,
|
|
currentModels: input.currentModels,
|
|
providerSnapshotRefreshing: input.loading === true,
|
|
previousCache: input.cache ?? null,
|
|
});
|
|
}
|
|
|
|
describe("resolveProviderDiscoveredModels", () => {
|
|
it("keeps a provider's cached discovered models visible while that provider refreshes", () => {
|
|
const ready = resolveModels({ provider: "grok", currentModels: [grokModel] });
|
|
|
|
const refreshing = resolveModels({ provider: "grok", loading: true, cache: ready.cache });
|
|
|
|
expect(refreshing.models).toEqual([grokModel]);
|
|
});
|
|
|
|
it("excludes compatibility-only models from display and cache", () => {
|
|
const compatibilityModel: AgentModelDefinition = {
|
|
...piModel,
|
|
id: "pi/model-legacy",
|
|
label: "Pi Model legacy",
|
|
isSelectable: false,
|
|
};
|
|
|
|
const result = resolveModels({
|
|
provider: "pi",
|
|
currentModels: [piModel, compatibilityModel],
|
|
});
|
|
|
|
expect(result.models).toEqual([piModel]);
|
|
expect(result.cache?.models).toEqual([piModel]);
|
|
});
|
|
|
|
it("does not show one provider's cached models while another provider loads", () => {
|
|
const ready = resolveModels({ provider: "pi", currentModels: [piModel] });
|
|
|
|
const refreshing = resolveModels({ provider: "grok", loading: true, cache: ready.cache });
|
|
|
|
expect(refreshing.models).toEqual([]);
|
|
});
|
|
|
|
it("does not show another server's cached models while the same provider loads", () => {
|
|
const ready = resolveModels({
|
|
serverId: "server-a",
|
|
provider: "grok",
|
|
currentModels: [grokModel],
|
|
});
|
|
|
|
const refreshing = resolveModels({
|
|
serverId: "server-b",
|
|
provider: "grok",
|
|
loading: true,
|
|
cache: ready.cache,
|
|
});
|
|
|
|
expect(refreshing.models).toEqual([]);
|
|
});
|
|
});
|