fix(web): keep model selector visible after model switches (#3349)
This commit is contained in:
@@ -435,17 +435,60 @@ describe("cross-agent persisted config reconciliation", () => {
|
||||
expect(hasCompleteDynamicConfig(session, catalogEntry(advertised, true), noAgents)).toBe(true);
|
||||
});
|
||||
|
||||
it("keeps a profile-snapshot key required even when the agent has not advertised it", () => {
|
||||
it("keeps an unadvertised profile-snapshot key required while the catalog is unsettled", () => {
|
||||
const session = makeSession({
|
||||
metadata: { runtime_config: { config_options: { model: providerModelId } } },
|
||||
agent_profile_snapshot: { config_options: { verbosity: "terse" } },
|
||||
});
|
||||
|
||||
expect(
|
||||
hasCompleteDynamicConfig(session, catalogEntry([modelConfigOption], true), noAgents),
|
||||
hasCompleteDynamicConfig(session, catalogEntry([modelConfigOption], false), noAgents),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("hydrates when a settled model catalog omits profile options from a prior model", () => {
|
||||
const session = makeSession({
|
||||
metadata: {
|
||||
runtime_config: {
|
||||
config_options: {
|
||||
effort: "high",
|
||||
fast: "false",
|
||||
mode: "agent",
|
||||
model: providerModelId,
|
||||
optimize_for: "balanced",
|
||||
},
|
||||
},
|
||||
runtime_config_overrides: {
|
||||
model: providerModelId,
|
||||
config_options: { model: providerModelId },
|
||||
},
|
||||
},
|
||||
agent_profile_snapshot: { config_options: { fast: "false" } },
|
||||
});
|
||||
const advertised = [
|
||||
selectOption("mode", "agent"),
|
||||
modelConfigOption,
|
||||
selectOption("optimize_for", "balanced"),
|
||||
];
|
||||
|
||||
expect(hasCompleteDynamicConfig(session, catalogEntry(advertised, true), noAgents)).toBe(true);
|
||||
});
|
||||
|
||||
it("hydrates when a settled model catalog omits a profile-only option", () => {
|
||||
const session = makeSession({
|
||||
metadata: { runtime_config: { config_options: { model: providerModelId } } },
|
||||
agent_profile_snapshot: { config_options: { fast: "false" } },
|
||||
});
|
||||
|
||||
expect(
|
||||
hasCompleteDynamicConfig(
|
||||
session,
|
||||
catalogEntry([modelConfigOption, selectOption("mode", "agent")], true),
|
||||
noAgents,
|
||||
),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("still requires persisted-only unadvertised keys while the catalog is unsettled", () => {
|
||||
const session = makeSession({
|
||||
metadata: { runtime_config: { config_options: { model: providerModelId, effort: "x" } } },
|
||||
|
||||
@@ -141,19 +141,16 @@ export function hasCompleteDynamicConfig(
|
||||
const hasFlatModelList = !!sessionModelsData.models.length;
|
||||
const catalogSettled = sessionModelsData.configOptionsSettled === true;
|
||||
const hasLegacyAgentConfig = catalogSettled && isLegacyAgentConfig(session, agents);
|
||||
// Keys written only by a prior agent type into persisted runtime metadata are
|
||||
// not required for the selector to render: once the current agent's catalog
|
||||
// has settled without advertising them, they are stale cross-agent leftovers
|
||||
// that the backend replay also drops.
|
||||
const profileRequired = session ? profileRequiredConfigKeys(session, agents) : new Set<string>();
|
||||
const isPersistedOnlyStaleKey = (key: string): boolean =>
|
||||
key !== AGENT_CONFIG_KEY && catalogSettled && !available.has(key) && !profileRequired.has(key);
|
||||
// A settled catalog is authoritative for which non-agent config keys apply
|
||||
// to the selected model.
|
||||
const isUnadvertisedSettledKey = (key: string): boolean =>
|
||||
key !== AGENT_CONFIG_KEY && catalogSettled && !available.has(key);
|
||||
return required.every(
|
||||
(key) =>
|
||||
available.has(key) ||
|
||||
(key === AGENT_CONFIG_KEY && hasLegacyAgentConfig) ||
|
||||
(key === MODEL_CONFIG_KEY && hasFlatModelList) ||
|
||||
isPersistedOnlyStaleKey(key),
|
||||
isUnadvertisedSettledKey(key),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user