mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-06 08:18:39 +00:00
fix: apply versioned settings on nightly builds (#9997)
This commit is contained in:
parent
2a70a2ec0e
commit
483e70c47b
3 changed files with 82 additions and 0 deletions
|
|
@ -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<string, unknown>
|
||||
|
||||
// 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
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -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", () => {
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue