History

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)

Cursor Agent committed 8 months ago

Commit 0cebffe1 parent d2b00e64 files · +15 −14Browse files

Unified · Split

4 files
  1. apps/server/src/orchestration/Layers/ProviderCommandReactor.test.ts +0 −1
  2. apps/server/src/provider/Layers/ClaudeCodeAdapter.ts +2 −2
  3. apps/web/src/appSettings.test.ts +5 −4
  4. apps/web/src/appSettings.ts +8 −7
apps/server/src/orchestration/Layers/ProviderCommandReactor.test.ts+0−1
@@ -416,7 +416,6 @@ describe("ProviderCommandReactor", () => { · 415 unmodified lines
416416 expect(harness.startSession.mock.calls[0]?.[1]).toMatchObject({
417417 provider: "claudeCode",
418418 cwd: "/tmp/provider-project",
419− model: "gpt-5-codex",
420419 runtimeMode: "approval-required",
421420 });
422421
apps/server/src/provider/Layers/ClaudeCodeAdapter.ts+2−2
@@ -1816,7 +1816,7 @@ function makeClaudeCodeAdapter(options?: ClaudeCodeAdapterLiveOptions) { · 1815 unmodified lines
18161816
18171817 const stopAll: ClaudeCodeAdapterShape["stopAll"] = () =>
18181818 Effect.forEach(
1819− sessions,
1819+ Array.from(sessions),
18201820 ([, context]) =>
18211821 stopSessionInternal(context, {
18221822 emitExitEvent: true,
@@ -1826,7 +1826,7 @@ function makeClaudeCodeAdapter(options?: ClaudeCodeAdapterLiveOptions) { · 3 unmodified lines
18261826
18271827 yield* Effect.addFinalizer(() =>
18281828 Effect.forEach(
1829− sessions,
1829+ Array.from(sessions),
18301830 ([, context]) =>
18311831 stopSessionInternal(context, {
18321832 emitExitEvent: false,
apps/web/src/appSettings.test.ts+5−4
@@ -8,12 +8,11 @@ import { · 7 unmodified lines
88 } from "./appSettings";
99
1010 describe("normalizeCustomModelSlugs", () => {
11− it("normalizes aliases, removes built-ins, and deduplicates values", () => {
11+ it("removes literal built-ins, trims whitespace, and deduplicates values", () => {
1212 expect(
1313 normalizeCustomModelSlugs([
1414 " custom/internal-model ",
1515 "gpt-5.3-codex",
16− "5.3",
1716 "custom/internal-model",
1817 "",
1918 null,
@@ -21,8 +20,10 @@ describe("normalizeCustomModelSlugs", () => { · 1 unmodified line
2120 ).toEqual(["custom/internal-model"]);
2221 });
2322
24− it("normalizes provider-specific aliases for claude", () => {
25− expect(normalizeCustomModelSlugs(["sonnet"], "claudeCode")).toEqual([]);
23+ it("preserves aliases and dated versions as custom models", () => {
24+ expect(normalizeCustomModelSlugs(["claude-sonnet-4-6-20251117"], "claudeCode")).toEqual([
25+ "claude-sonnet-4-6-20251117",
26+ ]);
2627 expect(normalizeCustomModelSlugs(["claude/custom-sonnet"], "claudeCode")).toEqual([
2728 "claude/custom-sonnet",
2829 ]);
apps/web/src/appSettings.ts+8−7
@@ -57,18 +57,19 @@ export function normalizeCustomModelSlugs( · 56 unmodified lines
5757 const builtInModelSlugs = BUILT_IN_MODEL_SLUGS_BY_PROVIDER[provider];
5858
5959 for (const candidate of models) {
60− const normalized = normalizeModelSlug(candidate, provider);
60+ if (typeof candidate !== "string") continue;
61+ const trimmed = candidate.trim();
6162 if (
62− !normalized ||
63− normalized.length > MAX_CUSTOM_MODEL_LENGTH ||
64− builtInModelSlugs.has(normalized) ||
65− seen.has(normalized)
63+ !trimmed ||
64+ trimmed.length > MAX_CUSTOM_MODEL_LENGTH ||
65+ builtInModelSlugs.has(trimmed) ||
66+ seen.has(trimmed)
6667 ) {
6768 continue;
6869 }
6970
70− seen.add(normalized);
71− normalizedModels.push(normalized);
71+ seen.add(trimmed);
72+ normalizedModels.push(trimmed);
7273 if (normalizedModels.length >= MAX_CUSTOM_MODEL_COUNT) {
7374 break;
7475 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t