mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-23 08:49:33 -10:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2aa46f21bf | ||
|
|
7310d0ab01 |
No files matched your search
@@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -850,6 +850,7 @@ mod tests {
|
||||
"agent": "",
|
||||
"agentModel": "",
|
||||
"agentEffort": "",
|
||||
"agentButton": true,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -200,5 +200,4 @@ describe("appearance & behavior settings", () => {
|
||||
|
||||
it("loads an old attach setting as ask", () => {
|
||||
expect(validateGeneralExtras({ openProjectIn: "attach" }).openProjectIn).toBe("ask");
|
||||
expect(validateGeneralExtras({ openProjectIn: "tab" }).openProjectIn).toBe("tab");
|
||||
});
|
||||
@@ -10,7 +10,7 @@ import { ZOOM_LIMITS } from "@/platform/zoom";
|
||||
import { validateIconThemeOptionsMap } from "@/platform/iconThemeOptions";
|
||||
|
||||
export type Antialiasing = "subpixel" | "greyscale" | "none";
|
||||
export type OpenProjectIn = "ask" | "new" | "same" | "tab";
|
||||
export type OpenProjectIn = "ask" | "new" | "same";
|
||||
export type NotificationDisplay = "balloon" | "sticky" | "none";
|
||||
export type NavigationBarPosition = "top" | "statusBar" | "hidden";
|
||||
export type BackgroundImageFill = "scale" | "plain" | "tile";
|
||||
@@ -306,7 +306,7 @@ export function validateGeneralExtras(raw: unknown): GeneralExtras {
|
||||
const d = DEFAULT_GENERAL_EXTRAS;
|
||||
const df = obj(g.dateFormat);
|
||||
return {
|
||||
openProjectIn: oneOf(g.openProjectIn, ["ask", "new", "same", "tab"] as const, d.openProjectIn),
|
||||
openProjectIn: oneOf(g.openProjectIn, ["ask", "new", "same"] as const, d.openProjectIn),
|
||||
updateSource: oneOf(g.updateSource, ["auto", "github", "cnb"] as const, d.updateSource),
|
||||
autoCheckUpdates: bool(g.autoCheckUpdates, d.autoCheckUpdates),
|
||||
showWhatsNewAfterUpdate: bool(g.showWhatsNewAfterUpdate, d.showWhatsNewAfterUpdate),
|
||||
|
||||
@@ -575,7 +575,6 @@ function ToolWindowsGrid() {
|
||||
const OPEN_IN: Array<{ value: OpenProjectIn; label: string }> = [
|
||||
{ value: "new", label: "New window" },
|
||||
{ value: "same", label: "Current window" },
|
||||
{ value: "tab", label: "New tab in current window" },
|
||||
{ value: "ask", label: "Ask" },
|
||||
];
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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.",
|
||||
@@ -2632,7 +2633,6 @@
|
||||
"Hot reload on save failed: {0}": "Hot reload on save failed: {0}",
|
||||
"Projects can be opened in a new window, replace the current project, be attached to the already opened projects, or open as a new tab of this window.\nHow would you like to open \"{name}\"?": "Projects can be opened in a new window, replace the current project, be attached to the already opened projects, or open as a new tab of this window.\nHow would you like to open \"{name}\"?",
|
||||
"New Tab": "New Tab",
|
||||
"New tab in current window": "New tab in current window",
|
||||
"Show Only Widgets": "Show Only Widgets",
|
||||
"Update failed": "Update failed",
|
||||
"Updating branches": "Updating branches",
|
||||
|
||||
@@ -1911,7 +1911,6 @@
|
||||
"New name": "新名称",
|
||||
"New terminal sessions run the interpreter's virtualenv activate script.": "新的终端会话会运行解释器的 virtualenv 激活脚本。",
|
||||
"New window": "新窗口",
|
||||
"New tab in current window": "当前窗口的新标签页",
|
||||
"New…": "新建…",
|
||||
"Next Bookmark": "下一个书签",
|
||||
"Next Change": "下一个更改",
|
||||
@@ -8667,6 +8666,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.": "请先在提交中包含更改。",
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -23,8 +23,7 @@ beforeEach(() => {
|
||||
lightEdit: false,
|
||||
});
|
||||
});
|
||||
it("offers attach for this open without remembering it", async () => {
|
||||
const button = "attach";
|
||||
it.each(["attach", "tab"] as const)("offers %s for this open without remembering it", async (button) => {
|
||||
vi.mocked(ask).mockResolvedValue({ button, checked: true });
|
||||
expect(await chooseProjectWindow("B")).toBe(button);
|
||||
const prompt = vi.mocked(ask).mock.calls[0]![0];
|
||||
@@ -50,18 +49,8 @@ it("treats a stored attach policy as ask", () => {
|
||||
useProject.setState({ settings: { general: { openProjectIn: "attach" } } } as never);
|
||||
expect(openPolicy()).toBe("ask");
|
||||
});
|
||||
it.each(["new", "same", "tab"] as const)("remembers %s", async (mode) => {
|
||||
it.each(["new", "same"] as const)("remembers %s", async (mode) => {
|
||||
vi.mocked(ask).mockResolvedValue({ button: mode, checked: true });
|
||||
await chooseProjectWindow("B");
|
||||
expect(commands.settingsSet).toHaveBeenCalledWith("global", "general.openProjectIn", JSON.stringify(mode));
|
||||
});
|
||||
|
||||
it("opens a project tab by policy, or a new window when this one can't take one", async () => {
|
||||
useProject.setState({ settings: { general: { openProjectIn: "tab" } } } as never);
|
||||
expect(openPolicy()).toBe("tab");
|
||||
expect(await chooseProjectWindow("B")).toBe("tab");
|
||||
expect(await chooseProjectWindow("remote", false)).toBe("new");
|
||||
useProject.setState({ project: null, lightEdit: true });
|
||||
expect(await chooseProjectWindow("B")).toBe("new");
|
||||
expect(ask).not.toHaveBeenCalled();
|
||||
});
|
||||
@@ -7,9 +7,9 @@ import { ask } from "./messages";
|
||||
import { maybeEditorService } from "./contributions";
|
||||
|
||||
/** "Open project in": `new` | `same` | `ask`. */
|
||||
export function openPolicy(): "ask" | "new" | "same" | "tab" {
|
||||
export function openPolicy(): "ask" | "new" | "same" {
|
||||
const v = useProject.getState().settings?.general?.openProjectIn;
|
||||
return v === "new" || v === "same" || v === "tab" ? v : "ask";
|
||||
return v === "new" || v === "same" ? v : "ask";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -26,8 +26,6 @@ export async function chooseProjectWindow(
|
||||
// Both ways of keeping this window's project: a workspace folder, or a project tab of this window.
|
||||
const canAdd = allowAttach && !!project && !isRemoteWindow();
|
||||
const mode = openPolicy();
|
||||
// A project tab needs this window's project beside it; without one, a new window is the closest.
|
||||
if (mode === "tab") return canAdd ? "tab" : "new";
|
||||
if (mode !== "ask") return mode;
|
||||
const r = await ask({
|
||||
title: t("app.window.askTitle"),
|
||||
@@ -48,9 +46,9 @@ export async function chooseProjectWindow(
|
||||
],
|
||||
checkbox: t("app.window.askRemember"),
|
||||
});
|
||||
// "Attach" is one-off, as in IDEA: "Open project in" has no value for it, so Don't ask again ignores it.
|
||||
// "Attach" and "New Tab" are one-off: "Open project in" has no value for them, so Don't ask again ignores both.
|
||||
if (r.button !== "same" && r.button !== "new" && r.button !== "attach" && r.button !== "tab") return null;
|
||||
if (r.checked && r.button !== "attach") {
|
||||
if (r.checked && (r.button === "same" || r.button === "new")) {
|
||||
try {
|
||||
useProject.setState({
|
||||
settings: await call(commands.settingsSet("global", "general.openProjectIn", JSON.stringify(r.button))),
|
||||
|
||||
Reference in new issue
Block a user