-
Notifications
You must be signed in to change notification settings - Fork 229
[3/4] feat(scm): add Source Control button for commit message generation #1229
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
base: main
Are you sure you want to change the base?
Changes from all commits
7b5b435
2e6f3a3
f182cd6
abecfa0
e9841a2
e541e72
df8d7d1
b54c961
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| // npx vitest run src/__tests__/types.test.ts | ||
|
|
||
| import { contributesSchema } from "../types.js" | ||
|
|
||
| describe("contributes commands schema", () => { | ||
| // Reached through `.shape` so this stays focused on the icon field, without needing a whole | ||
| // valid `contributes` object around it. | ||
| const commandsSchema = contributesSchema.shape.commands | ||
|
|
||
| const command = (icon: unknown) => [ | ||
| { command: "zoo-code.generateCommitMessage", title: "%command.generateCommitMessage.title%", icon }, | ||
| ] | ||
|
|
||
| it("accepts a codicon reference", () => { | ||
| expect(commandsSchema.safeParse(command("$(edit)")).success).toBe(true) | ||
| }) | ||
|
|
||
| // The Source Control button ships a PNG per theme rather than a codicon. This field used to | ||
| // allow only a string, which rejected the manifest outright when generating the nightly build. | ||
| it("accepts a pair of theme-specific icon paths", () => { | ||
| const icon = { light: "assets/icons/panel_light.png", dark: "assets/icons/panel_dark.png" } | ||
|
|
||
| expect(commandsSchema.safeParse(command(icon)).success).toBe(true) | ||
| }) | ||
|
|
||
| it("rejects an icon pair that is missing a theme", () => { | ||
| expect(commandsSchema.safeParse(command({ light: "assets/icons/panel_light.png" })).success).toBe(false) | ||
| }) | ||
| }) | ||
|
|
||
| describe("contributes menus schema", () => { | ||
| const menusSchema = contributesSchema.shape.menus | ||
|
|
||
| it("accepts a grouped menu item", () => { | ||
| const menus = { | ||
| "scm/title": [ | ||
| { | ||
| command: "zoo-code.generateCommitMessage", | ||
| group: "navigation", | ||
| when: "scmProvider == git && !zoo-code.generatingCommitMessage", | ||
| }, | ||
| ], | ||
| } | ||
|
|
||
| expect(menusSchema.safeParse(menus).success).toBe(true) | ||
| }) | ||
|
|
||
| // `commandPalette` items have no group. This field used to be required, which rejected the | ||
| // manifest outright when generating the nightly build. | ||
| it("accepts a menu item with no group", () => { | ||
| const menus = { | ||
| commandPalette: [ | ||
| { command: "zoo-code.stopGeneratingCommitMessage", when: "zoo-code.generatingCommitMessage" }, | ||
| ], | ||
| } | ||
|
|
||
| expect(menusSchema.safeParse(menus).success).toBe(true) | ||
| }) | ||
| }) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2461,6 +2461,7 @@ export class ClineProvider | |
| customModePrompts, | ||
| customSupportPrompts, | ||
| enhancementApiConfigId, | ||
| commitMessageApiConfigId, | ||
| autoApprovalEnabled, | ||
| customModes, | ||
| experiments, | ||
|
|
@@ -2619,6 +2620,7 @@ export class ClineProvider | |
| customModePrompts: customModePrompts ?? {}, | ||
| customSupportPrompts: customSupportPrompts ?? {}, | ||
| enhancementApiConfigId, | ||
| commitMessageApiConfigId, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Add state-propagation coverage. This cohort adds no focused As per coding guidelines, “Add focused tests for … the value returned by 🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| autoApprovalEnabled: autoApprovalEnabled ?? false, | ||
| customModes, | ||
| experiments: experiments ?? experimentDefault, | ||
|
|
@@ -2852,6 +2854,7 @@ export class ClineProvider | |
| customModePrompts: stateValues.customModePrompts ?? {}, | ||
| customSupportPrompts: stateValues.customSupportPrompts ?? {}, | ||
| enhancementApiConfigId: stateValues.enhancementApiConfigId, | ||
| commitMessageApiConfigId: stateValues.commitMessageApiConfigId, | ||
| experiments: stateValues.experiments ?? experimentDefault, | ||
| autoApprovalEnabled: stateValues.autoApprovalEnabled ?? false, | ||
| customModes, | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would a package test with both
lightanddarkicon paths make sense here? The current string-codicon fixture would not catch this schema being narrowed again.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
packages/build/src/tests/types.test.ts covers a codicon string, a {light, dark} pair, and an incomplete pair that should be rejected. It reaches the commands schema through contributesSchema.shape.commands, so the test stays focused on the icon field without needing a whole valid contributes object