@devries-cameron20 / t3code Mirror · read-only / commits / 820f620e3d
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 16:00 UTC

fix(web): model picks no longer inherit another model’s traits (#36621)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

Wout Stiens committed Nov 14, 2026 at 11:11 UTC 820f620e3d63cfb03f3587aa2c6844b9c57295bb
2 files changed +60 -18
apps/web/src/composerDraftStore.test.ts
+26 -2
@@ -1877,14 +1877,14 @@ describe("composerDraftStore modelSelection", () => {
1877 const threadSelection = modelSelection(CODEX_DRIVER, "gpt-5.3-codex", {
1878 reasoningEffort: "low",
1879 });
1880 - const effective = (threadStarted: boolean) => {
1880 + const effective = (threadStarted: boolean, baseSelection = threadSelection) => {
1881 const state = deriveEffectiveComposerModelState({
1882 draft: useComposerDraftStore.getState().getComposerDraft(threadRef),
1883 threadStarted,
1884 providers,
1885 selectedProvider: CODEX_DRIVER,
1886 selectedInstanceId: CODEX_INSTANCE,
1887 - threadModelSelection: threadSelection,
1887 + threadModelSelection: baseSelection,
1888 projectModelSelection: null,
1889 settings: DEFAULT_UNIFIED_SETTINGS,
1890 });
@@ -1921,6 +1921,30 @@ describe("composerDraftStore modelSelection", () => {
1921 });
1922 });
1923
1924 + it.each([false, true])(
1925 + "an explicit optionless pick overrides base traits when threadStarted=%s",
1926 + (threadStarted) => {
1927 + const store = useComposerDraftStore.getState();
1928 + store.setModelSelection(threadRef, modelSelection(CODEX_DRIVER, "gpt-5.4"), {
1929 + explicit: true,
1930 + replaceOptions: true,
1931 + });
1932 + expect(effective(threadStarted)).toEqual({ model: "gpt-5.4", options: [] });
1933 + },
1934 + );
1935 +
1936 + it("restores saved traits when the base model uses an alias", () => {
1937 + useComposerDraftStore
1938 + .getState()
1939 + .setModelSelection(threadRef, modelSelection(CODEX_DRIVER, "gpt-5.4"), {
1940 + explicit: true,
1941 + replaceOptions: true,
1942 + });
1943 + expect(
1944 + effective(true, modelSelection(CODEX_DRIVER, "5.4", { reasoningEffort: "low" })),
1945 + ).toEqual({ model: "gpt-5.4", options: toSelections({ reasoningEffort: "low" }) });
1946 + });
1947 +
1948 it("keeps the thread's model when traits change over a seed", () => {
1949 const store = useComposerDraftStore.getState();
1950 store.setModelSelection(threadRef, modelSelection(CODEX_DRIVER, "gpt-5.4"));
apps/web/src/composerDraftStore.ts
+34 -16
@@ -1235,6 +1235,26 @@ function legacyToModelSelectionByProvider(
1235 return result;
1236 }
1237
1238 +// Static aliases are shared across instances; exact custom slugs and catalog aliases are not.
1239 +function composerModelIdentity(
1240 + input: {
1241 + providers: ReadonlyArray<ServerProvider>;
1242 + settings: UnifiedSettings;
1243 + selectedProvider: ProviderDriverKind;
1244 + },
1245 + instanceId: ProviderInstanceId,
1246 + model: string | undefined,
1247 +) {
1248 + const isCustom =
1249 + input.providers
1250 + .find((provider) => provider.instanceId === instanceId)
1251 + ?.models.some((entry) => entry.slug === model && entry.isCustom) ||
1252 + readInstanceCustomModels(input.settings, instanceId, input.selectedProvider).some(
1253 + (entry) => entry.slug === model,
1254 + );
1255 + return isCustom ? model : normalizeModelSlug(model, input.selectedProvider);
1256 +}
1257 +
1258 export function deriveEffectiveComposerModelState(input: {
1259 draft:
1260 | Pick<
@@ -1254,8 +1274,8 @@ export function deriveEffectiveComposerModelState(input: {
1274 settings: UnifiedSettings;
1275 }): EffectiveComposerModelState {
1276 const draft = draftModelSelectionApplies(input.draft, input.threadStarted) ? input.draft : null;
1257 - const baseModelCandidate =
1258 - input.threadModelSelection?.model ?? input.projectModelSelection?.model ?? null;
1277 + const baseSelection = input.threadModelSelection ?? input.projectModelSelection;
1278 + const baseModelCandidate = baseSelection?.model ?? null;
1279 const preserveThreadModel =
1280 input.selectedInstanceId !== null &&
1281 input.selectedInstanceId !== undefined &&
@@ -1309,12 +1329,21 @@ export function deriveEffectiveComposerModelState(input: {
1329 activeSelection.model,
1330 ))
1331 : baseModel;
1332 + // Base options belong to the base model, so a draft pick of another model gets none of them.
1333 + const draftPicksOtherModel =
1334 + !!activeSelection?.model &&
1335 + composerModelIdentity(input, activeSelectionInstanceId, activeSelection.model) !==
1336 + composerModelIdentity(
1337 + input,
1338 + baseSelection?.instanceId ?? activeSelectionInstanceId,
1339 + baseSelection?.model,
1340 + );
1341 // Draft options win; otherwise an existing thread's options, even none, outrank the project's.
1342 // Selections stay with them, so a fallback instance can check which model the options belong to.
1343 const optionSelections =
1344 [
1345 draft?.modelSelectionByProvider,
1317 - selectionsByInstance(input.threadModelSelection ?? input.projectModelSelection),
1346 + draftPicksOtherModel ? null : selectionsByInstance(baseSelection),
1347 ].find((selections) => modelSelectionByProviderToOptions(selections) !== null) ?? null;
1348 const modelOptions = modelSelectionByProviderToOptions(optionSelections);
1349
@@ -1359,21 +1388,10 @@ function withFallbackInstanceOptions(input: {
1388 (provider) => provider.instanceId === requestedInstanceId,
1389 );
1390 const requestedModel = input.optionSelections?.[requestedInstanceId]?.model;
1362 - // Static aliases are shared across instances; exact custom slugs and catalog aliases are not.
1363 - const modelIdentity = (instanceId: ProviderInstanceId, model: string | undefined) => {
1364 - const isCustom =
1365 - input.providers
1366 - .find((provider) => provider.instanceId === instanceId)
1367 - ?.models.some((entry) => entry.slug === model && entry.isCustom) ||
1368 - readInstanceCustomModels(input.settings, instanceId, input.selectedProvider).some(
1369 - (entry) => entry.slug === model,
1370 - );
1371 - return isCustom ? model : normalizeModelSlug(model, input.selectedProvider);
1372 - };
1391 const sameModel =
1392 requestedModel === input.selectedModel ||
1375 - modelIdentity(requestedInstanceId, requestedModel) ===
1376 - modelIdentity(selectedInstanceId, input.selectedModel);
1393 + composerModelIdentity(input, requestedInstanceId, requestedModel) ===
1394 + composerModelIdentity(input, selectedInstanceId, input.selectedModel);
1395 if (!requestedOptions || requestedProvider?.driver !== input.selectedProvider || !sameModel) {
1396 return modelOptions;
1397 }