Skip to content

Commit 87961b6

Browse files
saphidclaude
authored andcommitted
fix(web): picking a custom model named like a Codex alias keeps that model
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent d8a829e commit 87961b6

2 files changed

Lines changed: 22 additions & 4 deletions

File tree

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,6 +1754,7 @@ describe("composerDraftStore modelSelection", () => {
17541754
).toEqual(
17551755
expect.objectContaining({
17561756
instanceId: CODEX_SECONDARY_INSTANCE,
1757+
model: "gpt-5-codex",
17571758
options: [{ id: "reasoningEffort", value: "low" }],
17581759
}),
17591760
);
@@ -1770,6 +1771,19 @@ describe("composerDraftStore modelSelection", () => {
17701771
options: [{ id: "reasoningEffort", value: "low" }],
17711772
}),
17721773
);
1774+
expect(
1775+
useComposerDraftStore.getState().stickyOptionsByModelByProvider[CODEX_SECONDARY_INSTANCE],
1776+
).toEqual({ "gpt-5-codex": [{ id: "reasoningEffort", value: "low" }] });
1777+
1778+
// A custom slug that matches a Codex alias stays exact; the picker already resolved it.
1779+
store.setModelSelection(threadRef, createModelSelection(CODEX_SECONDARY_INSTANCE, "gpt-5.3"), {
1780+
explicit: true,
1781+
replaceOptions: true,
1782+
});
1783+
expect(
1784+
draftFor(threadId, TEST_ENVIRONMENT_ID)?.modelSelectionByProvider[CODEX_SECONDARY_INSTANCE]
1785+
?.model,
1786+
).toBe("gpt-5.3");
17731787
});
17741788
});
17751789

‎apps/web/src/composerDraftStore.ts‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import { DeepMutable } from "effect/Types";
4242
import {
4343
createModelSelection,
4444
draftModelPickMatchesThread,
45+
normalizeCustomModelSlug,
4546
normalizeModelSlug,
4647
} from "@t3tools/shared/model";
4748
import { AsyncResult, Atom, type AtomRegistry } from "effect/reactivity";
@@ -990,7 +991,11 @@ function normalizeModelSelection(
990991
const driverKindHint =
991992
normalizeProviderDriverKind(candidate?.provider ?? legacy?.provider) ??
992993
ProviderDriverKind.make("codex");
993-
const model = normalizeModelSlug(rawModel, driverKindHint);
994+
// Instance-scoped picks are already resolved slugs; a custom slug can match a static alias.
995+
const model =
996+
candidate?.instanceId === undefined
997+
? normalizeModelSlug(rawModel, driverKindHint)
998+
: normalizeCustomModelSlug(rawModel);
994999
if (!model) {
9951000
return null;
9961001
}
@@ -3051,7 +3056,7 @@ const composerDraftStore = create<ComposerDraftStoreState>()(
30513056
}
30523057
const instanceKey = options?.instanceId ?? defaultInstanceIdForDriver(normalizedProvider);
30533058
const fallbackModel =
3054-
normalizeModelSlug(options?.model, normalizedProvider) ??
3059+
normalizeCustomModelSlug(options?.model) ??
30553060
DEFAULT_MODEL_BY_PROVIDER[normalizedProvider] ??
30563061
DEFAULT_MODEL;
30573062
const providerOpts =
@@ -3083,8 +3088,7 @@ const composerDraftStore = create<ComposerDraftStoreState>()(
30833088
nextStickyMap[instanceKey] ??
30843089
base.modelSelectionByProvider[instanceKey] ??
30853090
createModelSelection(instanceKey, fallbackModel);
3086-
const rememberedModel =
3087-
normalizeModelSlug(options?.model, normalizedProvider) ?? stickyBase.model;
3091+
const rememberedModel = normalizeCustomModelSlug(options?.model) ?? stickyBase.model;
30883092
if (providerOpts) {
30893093
nextStickyMap[instanceKey] = createModelSelection(
30903094
instanceKey,

0 commit comments

Comments
 (0)