Skip to content

Commit dca7dde

Browse files
committed
fix(web): composer fallback keeps the effort of a model saved under an alias
1 parent 1854e14 commit dca7dde

2 files changed

Lines changed: 79 additions & 5 deletions

File tree

‎apps/web/src/composerDraftStore.ts‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,12 +1204,13 @@ function withFallbackInstanceOptions(input: {
12041204
(provider) => provider.instanceId === requestedInstanceId,
12051205
)?.driver;
12061206
// The model of the selection the options came from, which can differ from the shown model's source.
1207+
// It can be a driver alias such as "5.4" for "gpt-5.4". Catalog aliases are not used: Antigravity's
1208+
// "antigravity-default" names a different model on each instance.
12071209
const requestedModel = input.optionSelections?.[requestedInstanceId]?.model;
1208-
if (
1209-
!requestedOptions ||
1210-
requestedDriver !== input.selectedProvider ||
1211-
requestedModel !== input.selectedModel
1212-
) {
1210+
const sameModel =
1211+
requestedModel === input.selectedModel ||
1212+
normalizeModelSlug(requestedModel, input.selectedProvider) === input.selectedModel;
1213+
if (!requestedOptions || requestedDriver !== input.selectedProvider || !sameModel) {
12131214
return modelOptions;
12141215
}
12151216
return { ...modelOptions, [selectedInstanceId]: requestedOptions };

‎apps/web/src/modelSelection.test.ts‎

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,79 @@ describe("composer fallback to another instance of the same driver", () => {
923923
expect(traits.modelOptionsForDispatch).toBeUndefined();
924924
});
925925

926+
describe("with model aliases", () => {
927+
const reasoningModel = (
928+
slug: string,
929+
id: string,
930+
extra: Partial<ServerProvider["models"][number]> = {},
931+
): ServerProvider["models"][number] => ({
932+
slug,
933+
name: slug,
934+
isCustom: false,
935+
...extra,
936+
capabilities: {
937+
optionDescriptors: [
938+
{
939+
id,
940+
label: id,
941+
type: "select",
942+
options: ["medium", "high", "xhigh"].map((value) => ({
943+
id: value,
944+
label: value,
945+
isDefault: value === "medium",
946+
})),
947+
},
948+
],
949+
},
950+
});
951+
952+
it("keeps the effort of a thread saved under a driver alias", () => {
953+
const disabledCodex = ProviderInstanceId.make("codex");
954+
const fallbackCodex = ProviderInstanceId.make("codex_team");
955+
const models = [reasoningModel("gpt-5.4", "reasoningEffort")];
956+
const { selectedInstanceId, state, traits } = composerFor({
957+
providers: [
958+
{ ...provider({ provider: codex, instanceId: disabledCodex }), enabled: false, models },
959+
{ ...provider({ provider: codex, instanceId: fallbackCodex }), models },
960+
],
961+
// "5.4" is the driver alias of gpt-5.4.
962+
threadModelSelection: createModelSelection(disabledCodex, "5.4", [
963+
{ id: "reasoningEffort", value: "xhigh" },
964+
]),
965+
});
966+
967+
expect(selectedInstanceId).toBe(fallbackCodex);
968+
expect(state.selectedModel).toBe("gpt-5.4");
969+
expect(traits.promptEffort).toBe("xhigh");
970+
});
971+
972+
it("does not carry options through an alias that names another model per instance", () => {
973+
// "antigravity-default" is each Antigravity instance's current model.
974+
const antigravity = ProviderDriverKind.make("antigravity");
975+
const disabledAntigravity = ProviderInstanceId.make("antigravity");
976+
const current = { isDefault: true, aliases: [ANTIGRAVITY_DEFAULT_MODEL] };
977+
const { state, traits } = composerFor({
978+
providers: [
979+
{
980+
...provider({ provider: antigravity, instanceId: disabledAntigravity }),
981+
enabled: false,
982+
models: [reasoningModel("gemini-3-pro", "thinking", current)],
983+
},
984+
{
985+
...provider({ provider: antigravity, instanceId: "antigravity_work" }),
986+
models: [reasoningModel("claude-sonnet-4-6", "thinking", current)],
987+
},
988+
],
989+
threadModelSelection: createModelSelection(disabledAntigravity, ANTIGRAVITY_DEFAULT_MODEL, [
990+
{ id: "thinking", value: "high" },
991+
]),
992+
});
993+
994+
expect(state.selectedModel).toBe("claude-sonnet-4-6");
995+
expect(traits.modelOptionsForDispatch).toBeUndefined();
996+
});
997+
});
998+
926999
it("does not carry options to another driver", () => {
9271000
const codexOnly: ReadonlyArray<ServerProvider> = [
9281001
{

0 commit comments

Comments
 (0)