Skip to content

Commit 62e136d

Browse files
committed
fix: infer provider from thread model when no session or explicit selection exists
When a thread has a Claude model slug but no active session and no entry in selectedProviderByThread (e.g., after a page refresh), selectedProvider incorrectly fell back to 'codex'. This caused resolveModelSlugForProvider to resolve the Claude slug against the codex model catalog, showing the wrong model/provider and sending turns to the wrong provider. Use the existing inferProviderForThreadModel helper (now exported from store.ts) to infer the correct provider from the thread's model slug before falling back to the 'codex' default.
1 parent 6d47c75 commit 62e136d

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

apps/web/src/components/ChatView.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ import {
5151
formatTimestamp,
5252
} from "../session-logic";
5353
import { isScrollContainerNearBottom } from "../chat-scroll";
54-
import { useStore } from "../store";
54+
import { inferProviderForThreadModel, useStore } from "../store";
5555
import { truncateTitle } from "../truncateTitle";
5656
import {
5757
DEFAULT_THREAD_TERMINAL_ID,
@@ -413,7 +413,12 @@ export default function ChatView({ threadId }: ChatViewProps) {
413413
const selectedProvider: ProviderKind =
414414
(activeThread?.id ? selectedProviderByThread[activeThread.id] : undefined) ??
415415
sessionProvider ??
416-
"codex";
416+
(activeThread?.model
417+
? inferProviderForThreadModel({
418+
model: activeThread.model,
419+
sessionProviderName: activeThread.session?.provider ?? null,
420+
})
421+
: "codex");
417422
const selectedModel = resolveModelSlugForProvider(
418423
selectedProvider,
419424
activeThread?.model ?? activeProject?.model ?? getDefaultModel(selectedProvider) ?? DEFAULT_MODEL,

apps/web/src/store.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ function toLegacyProvider(providerName: string | null): "codex" | "claudeCode" {
198198
const CODEX_MODEL_SLUGS = new Set(getModelOptions("codex").map((option) => option.slug));
199199
const CLAUDE_MODEL_SLUGS = new Set(getModelOptions("claudeCode").map((option) => option.slug));
200200

201-
function inferProviderForThreadModel(input: {
201+
export function inferProviderForThreadModel(input: {
202202
readonly model: string;
203203
readonly sessionProviderName: string | null;
204204
}): "codex" | "claudeCode" {

0 commit comments

Comments
 (0)