Repository navigation
fix(vscode): preserve model variants on switch #12944
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
1e17055
fix(vscode): preserve model variants on switch
marius-kilocode 40f2c13
fix(cli): preserve explicit variant priority
marius-kilocode 230f158
Merge branch 'main' into persist-model-variant-selection
marius-kilocode 1e779b5
Merge branch 'main' into persist-model-variant-selection
marius-kilocode File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "kilo-code": patch | ||
| --- | ||
|
|
||
| Preserve the selected reasoning effort when switching to a model that supports the same or nearest available variant. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| const effort = ["none", "minimal", "low", "medium", "high", "xhigh", "max"] | ||
|
|
||
| /** Keep the selected effort when possible, falling back to the nearest known effort. */ | ||
| export function preserveVariant(current: string | undefined, variants: string[]): string | undefined { | ||
| if (!current || variants.length === 0) return undefined | ||
| if (variants.includes(current)) return current | ||
|
|
||
| const rank = effort.indexOf(current) | ||
| if (rank === -1) return undefined | ||
|
|
||
| return variants | ||
| .map((value, index) => ({ | ||
| value, | ||
| index, | ||
| rank: effort.indexOf(value), | ||
| distance: Math.abs(effort.indexOf(value) - rank), | ||
| })) | ||
| .filter((item) => effort.includes(item.value)) | ||
| .sort((a, b) => a.distance - b.distance || b.rank - a.rank || a.index - b.index)[0]?.value | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import { describe, expect, test } from "bun:test" | ||
| import { preserveVariant } from "@/kilocode/cli/cmd/run/variant" | ||
|
|
||
| describe("Kilo CLI variant preservation", () => { | ||
| test("keeps exact variants across supported families", () => { | ||
| expect(preserveVariant("high", ["low", "high"])).toBe("high") | ||
| expect(preserveVariant("thinking", ["instant", "thinking"])).toBe("thinking") | ||
| expect(preserveVariant("default", ["default", "thinking"])).toBe("default") | ||
| }) | ||
|
|
||
| test("falls back to the nearest supported reasoning effort", () => { | ||
| expect(preserveVariant("max", ["high", "xhigh"])).toBe("xhigh") | ||
| expect(preserveVariant("high", ["low", "medium"])).toBe("medium") | ||
| expect(preserveVariant("max", ["none", "low"])).toBe("low") | ||
| }) | ||
|
|
||
| test("does not cross binary or custom variant families", () => { | ||
| expect(preserveVariant("thinking", ["low", "high"])).toBeUndefined() | ||
| expect(preserveVariant("instant", ["low", "high"])).toBeUndefined() | ||
| expect(preserveVariant("turbo", ["low", "high"])).toBeUndefined() | ||
| expect(preserveVariant("high", ["instant", "thinking"])).toBeUndefined() | ||
| }) | ||
| }) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.