-
-
Notifications
You must be signed in to change notification settings - Fork 241
feat(git): add model selection for commit message generation #451
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
Dimillian
merged 4 commits into
Dimillian:main
from
joshhbk:feature/model-selection-git-commit-messages
Feb 20, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
5fe8a93
feat(git): add model selection for commit message generation
joshhbk 8bd315f
refactor: move model picker to Settings and fix runtime validation
joshhbk 3572101
Merge branch 'main' into feature/model-selection-git-commit-messages
Dimillian 86a0174
Merge branch 'main' into feature/model-selection-git-commit-messages
Dimillian 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
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
42 changes: 42 additions & 0 deletions
42
src/features/git/utils/commitMessageModelSelection.test.ts
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,42 @@ | ||
| import { describe, expect, it } from "vitest"; | ||
| import type { ModelOption } from "@/types"; | ||
| import { effectiveCommitMessageModelId } from "./commitMessageModelSelection"; | ||
|
|
||
| const MODELS: ModelOption[] = [ | ||
| { | ||
| id: "m-1", | ||
| model: "gpt-5.1", | ||
| displayName: "GPT-5.1", | ||
| description: "", | ||
| supportedReasoningEfforts: [], | ||
| defaultReasoningEffort: null, | ||
| isDefault: false, | ||
| }, | ||
| { | ||
| id: "m-2", | ||
| model: "gpt-5.2", | ||
| displayName: "GPT-5.2", | ||
| description: "", | ||
| supportedReasoningEfforts: [], | ||
| defaultReasoningEffort: null, | ||
| isDefault: true, | ||
| }, | ||
| ]; | ||
|
|
||
| describe("effectiveCommitMessageModelId", () => { | ||
| it("passes through null when no model is saved", () => { | ||
| expect(effectiveCommitMessageModelId(MODELS, null)).toBeNull(); | ||
| }); | ||
|
|
||
| it("returns the saved model when it exists in the workspace", () => { | ||
| expect(effectiveCommitMessageModelId(MODELS, "gpt-5.1")).toBe("gpt-5.1"); | ||
| }); | ||
|
|
||
| it("falls back to null when saved model is unavailable in the workspace", () => { | ||
| expect(effectiveCommitMessageModelId(MODELS, "gpt-4.1")).toBeNull(); | ||
| }); | ||
|
|
||
| it("falls back to null when no models are available", () => { | ||
| expect(effectiveCommitMessageModelId([], "gpt-5.1")).toBeNull(); | ||
| }); | ||
| }); |
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,15 @@ | ||
| import type { ModelOption } from "@/types"; | ||
|
|
||
| /** | ||
| * Returns the saved commit-message model ID when available for the active | ||
| * workspace, or `null` to let the backend fall back to the workspace default. | ||
| * | ||
| * This is a pure runtime guard — it never mutates the persisted setting. | ||
| */ | ||
| export function effectiveCommitMessageModelId( | ||
| models: ModelOption[], | ||
| savedModelId: string | null, | ||
| ): string | null { | ||
| if (savedModelId == null) return null; | ||
| return models.some((m) => m.model === savedModelId) ? savedModelId : null; | ||
| } |
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,98 @@ | ||
| import { describe, expect, it } from "vitest"; | ||
| import { formatModelSlug, parseModelListResponse } from "./modelListResponse"; | ||
|
|
||
| describe("formatModelSlug", () => { | ||
| it("capitalizes plain segments", () => { | ||
| expect(formatModelSlug("codex-mini")).toBe("Codex-Mini"); | ||
| }); | ||
|
|
||
| it("uppercases known acronyms", () => { | ||
| expect(formatModelSlug("gpt-5.3-codex")).toBe("GPT-5.3-Codex"); | ||
| }); | ||
|
|
||
| it("leaves version-like segments unchanged", () => { | ||
| expect(formatModelSlug("gpt-5.1-codex-max")).toBe("GPT-5.1-Codex-Max"); | ||
| }); | ||
|
|
||
| it("handles a version-only slug", () => { | ||
| expect(formatModelSlug("gpt-5.2")).toBe("GPT-5.2"); | ||
| }); | ||
| it("is case-insensitive for acronym detection", () => { | ||
| expect(formatModelSlug("GPT-5.3-codex")).toBe("GPT-5.3-Codex"); | ||
| expect(formatModelSlug("Gpt-5.3-codex")).toBe("GPT-5.3-Codex"); | ||
| }); | ||
|
|
||
| it("returns empty string for non-string input", () => { | ||
| expect(formatModelSlug(null)).toBe(""); | ||
| expect(formatModelSlug(undefined)).toBe(""); | ||
| expect(formatModelSlug(42)).toBe(""); | ||
| }); | ||
|
|
||
| it("returns empty string for blank strings", () => { | ||
| expect(formatModelSlug("")).toBe(""); | ||
| expect(formatModelSlug(" ")).toBe(""); | ||
| }); | ||
|
|
||
| it("handles a single segment", () => { | ||
| expect(formatModelSlug("codex")).toBe("Codex"); | ||
| expect(formatModelSlug("gpt")).toBe("GPT"); | ||
| }); | ||
| }); | ||
|
|
||
| describe("parseModelListResponse", () => { | ||
| it("uses displayName when present", () => { | ||
| const response = { | ||
| result: { | ||
| data: [ | ||
| { id: "m1", model: "gpt-5.3-codex-spark", displayName: "GPT-5.3-Codex-Spark" }, | ||
| ], | ||
| }, | ||
| }; | ||
| const [model] = parseModelListResponse(response); | ||
| expect(model.displayName).toBe("GPT-5.3-Codex-Spark"); | ||
| }); | ||
|
|
||
| it("formats the slug when displayName is missing", () => { | ||
| const response = { | ||
| result: { | ||
| data: [{ id: "m1", model: "gpt-5.3-codex" }], | ||
| }, | ||
| }; | ||
| const [model] = parseModelListResponse(response); | ||
| expect(model.displayName).toBe("GPT-5.3-Codex"); | ||
| }); | ||
|
|
||
| it("formats the slug when displayName is an empty string", () => { | ||
| const response = { | ||
| result: { | ||
| data: [{ id: "m1", model: "gpt-5.1-codex-mini", displayName: "" }], | ||
| }, | ||
| }; | ||
| const [model] = parseModelListResponse(response); | ||
| expect(model.displayName).toBe("GPT-5.1-Codex-Mini"); | ||
| }); | ||
|
|
||
| it("formats the slug when displayName equals the model slug", () => { | ||
| const response = { | ||
| result: { | ||
| data: [{ id: "m1", model: "gpt-5.3-codex", displayName: "gpt-5.3-codex" }], | ||
| }, | ||
| }; | ||
| const [model] = parseModelListResponse(response); | ||
| expect(model.displayName).toBe("GPT-5.3-Codex"); | ||
| }); | ||
|
|
||
| it("preserves displayName when it differs from the slug", () => { | ||
| const response = { | ||
| result: { | ||
| data: [ | ||
| { id: "m1", model: "gpt-5.3-codex-spark", displayName: "GPT-5.3-Codex-Spark" }, | ||
| { id: "m2", model: "gpt-5.2-codex", displayName: "gpt-5.2-codex" }, | ||
| ], | ||
| }, | ||
| }; | ||
| const models = parseModelListResponse(response); | ||
| expect(models[0].displayName).toBe("GPT-5.3-Codex-Spark"); | ||
| expect(models[1].displayName).toBe("GPT-5.2-Codex"); | ||
| }); | ||
| }); |
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.