diff --git a/crates/ide-core/src/workflow_settings.rs b/crates/ide-core/src/workflow_settings.rs index 8c326ae92..6d422dc87 100644 --- a/crates/ide-core/src/workflow_settings.rs +++ b/crates/ide-core/src/workflow_settings.rs @@ -176,6 +176,8 @@ pub struct CommitSettings { pub agent_model: String, /// That model's thinking level for commit messages; empty keeps the agent's. pub agent_effort: String, + /// Show the Generate Commit Message with Agent button above the commit message. + pub agent_button: bool, } impl Default for CommitSettings { @@ -201,6 +203,7 @@ impl Default for CommitSettings { agent: String::new(), agent_model: String::new(), agent_effort: String::new(), + agent_button: true, } } } diff --git a/crates/ide-workspace/src/settings.rs b/crates/ide-workspace/src/settings.rs index 2981bc7c8..e03ad95b9 100644 --- a/crates/ide-workspace/src/settings.rs +++ b/crates/ide-workspace/src/settings.rs @@ -850,6 +850,7 @@ mod tests { "agent": "", "agentModel": "", "agentEffort": "", + "agentButton": true, }) ); } diff --git a/src/bindings.ts b/src/bindings.ts index 53dc5457c..c73a8bdcf 100644 --- a/src/bindings.ts +++ b/src/bindings.ts @@ -3770,6 +3770,8 @@ export type CommitSettings = { agentModel?: string, /** That model's thinking level for commit messages; empty keeps the agent's. */ agentEffort?: string, + /** Show the Generate Commit Message with Agent button above the commit message. */ + agentButton?: boolean, }; export type Commit_Deserialize = { diff --git a/src/features/agents/index.ts b/src/features/agents/index.ts index 6e4f01083..206ea3dc2 100644 --- a/src/features/agents/index.ts +++ b/src/features/agents/index.ts @@ -6,6 +6,8 @@ import { createElement } from "react"; import { registerActions } from "@/platform/actions"; import { useProject } from "@/platform/project"; +import { clearContext, setContext } from "@/platform/context"; +import { onWorkflowSettingsChange, workflowSettings } from "@/platform/workflowSettings"; import { executeAction } from "@/platform/actions"; import { lazyComponent, lazyWhen } from "@/ui"; import { isVirtualUri } from "@/platform/virtualDocs"; @@ -47,6 +49,18 @@ import { replyActions } from "./replyActions"; export { activateSettingsPages } from "./settingsPages"; +function trackAgentButtonSetting(): () => void { + setContext("commitAgentButton", workflowSettings().vcs.commit.agentButton); + const stop = onWorkflowSettingsChange( + (s) => s.vcs.commit.agentButton, + (on) => setContext("commitAgentButton", on), + ); + return () => { + stop(); + clearContext("commitAgentButton"); + }; +} + export function activate(): () => void { const sync = (root: string | null | undefined) => { disconnect(); @@ -153,12 +167,13 @@ export function activate(): () => void { accepts: (type) => type === TASK_DRAG, drop: ({ payload }) => void executeAction("agents.openTaskInEditor", payload), }), - // The button above the commit message (the Commit tool window and dialog). + // The button above the commit message (the Commit tool window and dialog), unless turned off. + trackAgentButtonSetting(), registerMenuSlotItem("commitMessage", { action: "agents.generateCommitMessage", label: "Generate Commit Message with Agent", icon: "toolwindow-agents", - when: "projectOpen && vcsAvailable", + when: "projectOpen && vcsAvailable && commitAgentButton", }), registerStatusItem({ id: "agents.status", align: "right", priority: 3, title: "Agents", component: AgentsStatus }), registerMenuGroup({ diff --git a/src/features/settings/pages/vcs.tsx b/src/features/settings/pages/vcs.tsx index d27ff8cf8..9e591e24d 100644 --- a/src/features/settings/pages/vcs.tsx +++ b/src/features/settings/pages/vcs.tsx @@ -643,6 +643,11 @@ export const VCS_PAGES: PageSpec[] = [ { title: "Commit Message Generation", options: [ + { + kind: "toggle", + key: "vcs.commit.agentButton", + label: "Show the Generate Commit Message with Agent button", + }, { kind: "custom", label: "Agent", diff --git a/src/platform/locales/text/en.json b/src/platform/locales/text/en.json index f7b345b5e..c32dda360 100644 --- a/src/platform/locales/text/en.json +++ b/src/platform/locales/text/en.json @@ -2265,6 +2265,7 @@ "Finished": "Finished", "Only while the tab cannot be seen. A command stopped with Ctrl-C, shell startup and short commands stay quiet; a non-zero exit always reports its code.": "Only while the tab cannot be seen. A command stopped with Ctrl-C, shell startup and short commands stay quiet; a non-zero exit always reports its code.", "Generate Commit Message with Agent": "Generate Commit Message with Agent", + "Show the Generate Commit Message with Agent button": "Show the Generate Commit Message with Agent button", "Has the coding agent you work with review the changes about to be committed and write the commit message.": "Has the coding agent you work with review the changes about to be committed and write the commit message.", "No changes to describe": "No changes to describe", "Include changes in the commit first.": "Include changes in the commit first.", diff --git a/src/platform/locales/text/zh.json b/src/platform/locales/text/zh.json index f65fe281f..cd63d8809 100644 --- a/src/platform/locales/text/zh.json +++ b/src/platform/locales/text/zh.json @@ -8667,6 +8667,7 @@ "Exited with code {code}": "退出代码 {code}", "Only while the tab cannot be seen. A command stopped with Ctrl-C, shell startup and short commands stay quiet; a non-zero exit always reports its code.": "仅当标签页不可见时通知。用 Ctrl-C 停止的命令、shell 启动和短命令保持安静;非零退出始终报告退出代码。", "Generate Commit Message with Agent": "使用智能体生成提交消息", + "Show the Generate Commit Message with Agent button": "显示“使用智能体生成提交消息”按钮", "Has the coding agent you work with review the changes about to be committed and write the commit message.": "让您正在使用的编程智能体审查即将提交的更改并撰写提交消息。", "No changes to describe": "没有可描述的更改", "Include changes in the commit first.": "请先在提交中包含更改。", diff --git a/src/platform/workflowSettings.ts b/src/platform/workflowSettings.ts index 10b2a175d..ce601d029 100644 --- a/src/platform/workflowSettings.ts +++ b/src/platform/workflowSettings.ts @@ -69,6 +69,8 @@ export interface CommitSettingsValid { agentModel: string; /** That model's thinking level for commit messages; empty keeps the agent's. */ agentEffort: string; + /** Show the Generate Commit Message with Agent button above the commit message. */ + agentButton: boolean; } export interface VcsSettingsValid { @@ -316,6 +318,7 @@ export const DEFAULT_WORKFLOW: WorkflowSettings = { agent: "", agentModel: "", agentEffort: "", + agentButton: true, }, confirmation: { onCreate: "ask", @@ -488,6 +491,7 @@ export function validateVcs(raw: unknown): VcsSettingsValid { agent: text(c.agent, d.commit.agent), agentModel: text(c.agentModel, d.commit.agentModel), agentEffort: text(c.agentEffort, d.commit.agentEffort), + agentButton: bool(c.agentButton, d.commit.agentButton), }, confirmation: { onCreate: oneOf(conf.onCreate, confirm, d.confirmation.onCreate),