From 0cebffe67a5456565c2ad147380d5155dc7b40ed Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Mon, 16 Mar 2026 18:20:19 +0000 Subject: [PATCH] fix: snapshot Map before iteration, preserve raw custom model slugs, remove wrong model assertion - Snapshot sessions Map with Array.from() in stopAll and finalizer to prevent entries being skipped when stopSessionInternal deletes during iteration (ClaudeCodeAdapter.ts) - Stop resolving aliases in normalizeCustomModelSlugs so dated model versions like claude-sonnet-4-6-20251117 are not silently dropped as built-in duplicates (appSettings.ts) - Remove incorrect model: gpt-5-codex assertion from claudeCode provider test since the test validates provider selection, not model resolution (ProviderCommandReactor.test.ts) Co-authored-by: Julius Marminge --- .../Layers/ProviderCommandReactor.test.ts | 1 - .../src/provider/Layers/ClaudeCodeAdapter.ts | 4 ++-- apps/web/src/appSettings.test.ts | 9 +++++---- apps/web/src/appSettings.ts | 15 ++++++++------- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/apps/server/src/orchestration/Layers/ProviderCommandReactor.test.ts b/apps/server/src/orchestration/Layers/ProviderCommandReactor.test.ts index 308205193d..dd25775cac 100644 --- a/apps/server/src/orchestration/Layers/ProviderCommandReactor.test.ts +++ b/apps/server/src/orchestration/Layers/ProviderCommandReactor.test.ts @@ -416,7 +416,6 @@ describe("ProviderCommandReactor", () => { expect(harness.startSession.mock.calls[0]?.[1]).toMatchObject({ provider: "claudeCode", cwd: "/tmp/provider-project", - model: "gpt-5-codex", runtimeMode: "approval-required", }); diff --git a/apps/server/src/provider/Layers/ClaudeCodeAdapter.ts b/apps/server/src/provider/Layers/ClaudeCodeAdapter.ts index c4bc93a9fe..7e21884b8f 100644 --- a/apps/server/src/provider/Layers/ClaudeCodeAdapter.ts +++ b/apps/server/src/provider/Layers/ClaudeCodeAdapter.ts @@ -1816,7 +1816,7 @@ function makeClaudeCodeAdapter(options?: ClaudeCodeAdapterLiveOptions) { const stopAll: ClaudeCodeAdapterShape["stopAll"] = () => Effect.forEach( - sessions, + Array.from(sessions), ([, context]) => stopSessionInternal(context, { emitExitEvent: true, @@ -1826,7 +1826,7 @@ function makeClaudeCodeAdapter(options?: ClaudeCodeAdapterLiveOptions) { yield* Effect.addFinalizer(() => Effect.forEach( - sessions, + Array.from(sessions), ([, context]) => stopSessionInternal(context, { emitExitEvent: false, diff --git a/apps/web/src/appSettings.test.ts b/apps/web/src/appSettings.test.ts index da55af6ff7..60054264a6 100644 --- a/apps/web/src/appSettings.test.ts +++ b/apps/web/src/appSettings.test.ts @@ -8,12 +8,11 @@ import { } from "./appSettings"; describe("normalizeCustomModelSlugs", () => { - it("normalizes aliases, removes built-ins, and deduplicates values", () => { + it("removes literal built-ins, trims whitespace, and deduplicates values", () => { expect( normalizeCustomModelSlugs([ " custom/internal-model ", "gpt-5.3-codex", - "5.3", "custom/internal-model", "", null, @@ -21,8 +20,10 @@ describe("normalizeCustomModelSlugs", () => { ).toEqual(["custom/internal-model"]); }); - it("normalizes provider-specific aliases for claude", () => { - expect(normalizeCustomModelSlugs(["sonnet"], "claudeCode")).toEqual([]); + it("preserves aliases and dated versions as custom models", () => { + expect(normalizeCustomModelSlugs(["claude-sonnet-4-6-20251117"], "claudeCode")).toEqual([ + "claude-sonnet-4-6-20251117", + ]); expect(normalizeCustomModelSlugs(["claude/custom-sonnet"], "claudeCode")).toEqual([ "claude/custom-sonnet", ]); diff --git a/apps/web/src/appSettings.ts b/apps/web/src/appSettings.ts index 5c3e80ff77..40b267f810 100644 --- a/apps/web/src/appSettings.ts +++ b/apps/web/src/appSettings.ts @@ -57,18 +57,19 @@ export function normalizeCustomModelSlugs( const builtInModelSlugs = BUILT_IN_MODEL_SLUGS_BY_PROVIDER[provider]; for (const candidate of models) { - const normalized = normalizeModelSlug(candidate, provider); + if (typeof candidate !== "string") continue; + const trimmed = candidate.trim(); if ( - !normalized || - normalized.length > MAX_CUSTOM_MODEL_LENGTH || - builtInModelSlugs.has(normalized) || - seen.has(normalized) + !trimmed || + trimmed.length > MAX_CUSTOM_MODEL_LENGTH || + builtInModelSlugs.has(trimmed) || + seen.has(trimmed) ) { continue; } - seen.add(normalized); - normalizedModels.push(normalized); + seen.add(trimmed); + normalizedModels.push(trimmed); if (normalizedModels.length >= MAX_CUSTOM_MODEL_COUNT) { break; }