Compare commits

...
Author SHA1 Message Date
Cursor AgentandJulius Marminge 0cebffe67a 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 <[email protected]>
2026-03-16 18:20:19 +00:00
4 changed files with 15 additions and 14 deletions

No files matched your search

@@ -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",
});
@@ -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,
+5 -4
View File
@@ -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",
]);
+8 -7
View File
@@ -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;
}