diff --git a/src/api/providers/fetchers/__tests__/roo.spec.ts b/src/api/providers/fetchers/__tests__/roo.spec.ts index 0ee7d8e3ed8..cd86be0b692 100644 --- a/src/api/providers/fetchers/__tests__/roo.spec.ts +++ b/src/api/providers/fetchers/__tests__/roo.spec.ts @@ -1,5 +1,6 @@ import { describe, it, expect, vi, beforeEach, afterEach } from "vitest" import { getRooModels } from "../roo" +import { Package } from "../../../../shared/package" // Mock fetch globally const mockFetch = vi.fn() @@ -976,4 +977,53 @@ describe("getRooModels", () => { // Should use 3.0.0 version settings (highest that's <= current plugin version) expect(model.feature).toBe("current") }) + + it("should apply highest versionedSettings for nightly builds (package name)", async () => { + const mockResponse = { + object: "list", + data: [ + { + id: "test/nightly-version-model", + object: "model", + created: 1234567890, + owned_by: "test", + name: "Nightly Model", + description: "Model with multiple versioned settings", + context_window: 128000, + max_tokens: 8192, + type: "language", + pricing: { + input: "0.0001", + output: "0.0002", + }, + settings: { + feature: "plain", + }, + versionedSettings: { + "3.36.3": { feature: "v3" }, + "2.0.0": { feature: "v2" }, + }, + }, + ], + } + + mockFetch.mockResolvedValueOnce({ + ok: true, + json: async () => mockResponse, + }) + + // Simulate nightly build via package name + const originalName = Package.name + ;(Package as { name: string }).name = "roo-code-nightly" + + try { + const models = await getRooModels(baseUrl, apiKey) + const model = models["test/nightly-version-model"] as Record + + // Should pick the highest available versionedSettings even though 3.36.3 > 0.0.7465 + expect(model.feature).toBe("v3") + } finally { + ;(Package as { name: string }).name = originalName + } + }) }) diff --git a/src/api/providers/fetchers/__tests__/versionedSettings.spec.ts b/src/api/providers/fetchers/__tests__/versionedSettings.spec.ts index 029f92b3017..9422c012678 100644 --- a/src/api/providers/fetchers/__tests__/versionedSettings.spec.ts +++ b/src/api/providers/fetchers/__tests__/versionedSettings.spec.ts @@ -5,6 +5,7 @@ import { resolveVersionedSettings, type VersionedSettings, } from "../versionedSettings" +import { Package } from "../../../../shared/package" describe("versionedSettings", () => { describe("compareSemver", () => { @@ -113,6 +114,23 @@ describe("versionedSettings", () => { const result = findHighestMatchingVersion(versionedSettings, "3.36.4") expect(result).toBeUndefined() }) + + it("should treat nightly builds (by package name) as always eligible and pick highest version", () => { + const versionedSettings: VersionedSettings = { + "3.36.3": { feature: "v3" }, + "2.0.0": { feature: "v2" }, + } + + const originalName = Package.name + ;(Package as { name: string }).name = "roo-code-nightly" + + try { + const result = findHighestMatchingVersion(versionedSettings, "1.0.0") + expect(result).toBe("3.36.3") + } finally { + ;(Package as { name: string }).name = originalName + } + }) }) describe("resolveVersionedSettings", () => { diff --git a/src/api/providers/fetchers/versionedSettings.ts b/src/api/providers/fetchers/versionedSettings.ts index 50ec0b89732..d644c683d35 100644 --- a/src/api/providers/fetchers/versionedSettings.ts +++ b/src/api/providers/fetchers/versionedSettings.ts @@ -2,6 +2,10 @@ import cmp from "semver-compare" import { Package } from "../../../shared/package" +function isNightlyBuild(): boolean { + return Package.name.toLowerCase().includes("nightly") +} + /** * Type for versioned settings where the version is the key. * Each version key maps to a settings object that should be used @@ -68,6 +72,16 @@ export function findHighestMatchingVersion( ): string | undefined { const versions = Object.keys(versionedSettings) + if (versions.length === 0) { + return undefined + } + + // Nightly builds should always pick the highest available versioned settings + if (isNightlyBuild()) { + versions.sort((a, b) => compareSemver(b, a)) + return versions[0] + } + // Filter to versions that are <= currentVersion const matchingVersions = versions.filter((version) => meetsMinimumVersion(version, currentVersion))