Skip to content

Commit ccc7558

Browse files
only21milclaude
andcommitted
fix(web): picking the canonical model of a thread's stored alias keeps its options
The pick builder now matches the thread's model with the same alias-aware check as the composer's stored options, so a thread stored as gpt-5-codex keeps its effort when GPT-5.4 is picked. Custom model slugs still match only exactly. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent fa16e57 commit ccc7558

3 files changed

Lines changed: 31 additions & 5 deletions

File tree

‎apps/web/src/components/ChatView.modelPick.browser.test.tsx‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ProviderInstanceId } from "@t3tools/contracts";
33
import { DEFAULT_CLIENT_SETTINGS } from "@t3tools/contracts/settings";
44
import type * as Context from "effect/Context";
55
import { expect, it, vi } from "vite-plus/test";
6-
import { page } from "vite-plus/test/browser";
6+
import { page, userEvent } from "vite-plus/test/browser";
77

88
import { AppRoot } from "~/AppRoot";
99
// The route loads ChatView lazily, and its first transform (React Compiler over ~4k lines)
@@ -43,7 +43,11 @@ it("a model picked for an existing thread reaches the server before any message
4343
options: [{ id: "reasoningEffort", value: "high" }],
4444
};
4545
const thread = { ...threadWithHistory("thread-model-pick", 1), modelSelection: stored };
46-
using _environment = installFakeEnvironment([thread], { acceptCommands: true });
46+
const aliasThread = {
47+
...threadWithHistory("thread-model-alias", 1),
48+
modelSelection: { ...stored, model: "gpt-5-codex" },
49+
};
50+
using _environment = installFakeEnvironment([thread, aliasThread], { acceptCommands: true });
4751
__setClientSettingsForTests({
4852
...DEFAULT_CLIENT_SETTINGS,
4953
onboardingCompletedAt: "2026-01-01T00:00:00.000Z",
@@ -80,4 +84,16 @@ it("a model picked for an existing thread reaches the server before any message
8084
}),
8185
),
8286
);
87+
88+
// A thread stored under an alias keeps its options when its canonical model is picked.
89+
await userEvent.keyboard("{Escape}");
90+
await router.navigate({ href: `/${ENVIRONMENT_ID}/${aliasThread.id}` });
91+
await expect.element(page.getByText("Answer 0 for thread-model-alias.")).toBeVisible();
92+
await page.getByRole("button", { name: "GPT-5.4", exact: true }).click();
93+
await page.getByRole("option", { name: /GPT-5\.4/ }).click();
94+
await vi.waitFor(() =>
95+
expect(modelSets().at(-1)).toEqual(
96+
expect.objectContaining({ threadId: aliasThread.id, modelSelection: stored }),
97+
),
98+
);
8399
});

‎apps/web/src/components/chat/useComposerSelection.ts‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ import { useNavigate } from "@tanstack/react-router";
1919
import { toastManager } from "../ui/toast";
2020
import { resolveAppModelSelectionForInstance } from "../../modelSelection";
2121
import { resolveNewDraftStartFromOrigin } from "../../lib/chatThreadActions";
22-
import { type DraftThreadEnvMode, useComposerDraftStore } from "../../composerDraftStore";
22+
import {
23+
type DraftThreadEnvMode,
24+
isSameModel,
25+
useComposerDraftStore,
26+
} from "../../composerDraftStore";
2327
import {
2428
getStartedThreadModelChangeBlockReason,
2529
deriveLockedProvider,
@@ -169,7 +173,13 @@ export function useComposerSelection(input: ComposerSelectionInput) {
169173
const pickOptions =
170174
rememberedOptions !== undefined && rememberedOptions.length > 0
171175
? rememberedOptions
172-
: threadSelection.instanceId === instanceId && threadSelection.model === resolvedModel
176+
: threadSelection.instanceId === instanceId &&
177+
entry !== undefined &&
178+
isSameModel(
179+
{ providers: providerStatuses, selectedProvider: entry.driver, settings },
180+
threadSelection,
181+
{ instanceId, model: resolvedModel },
182+
)
173183
? threadSelection.options
174184
: undefined;
175185
const nextModelSelection: ModelSelection =

‎apps/web/src/composerDraftStore.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,7 @@ interface InstanceModel {
12411241
readonly model: string | undefined;
12421242
}
12431243

1244-
function isSameModel(
1244+
export function isSameModel(
12451245
input: {
12461246
readonly providers: ReadonlyArray<ServerProvider>;
12471247
readonly selectedProvider: ProviderDriverKind;

0 commit comments

Comments
 (0)