/** * Commit Options popup (the gear next to Commit, after IDEA's): Git author and * sign-off, before-commit modifications, Git hooks and the commit checks. The * checks are the Settings › Version Control › Commit values, edited in place. */ import type { ReactNode, RefObject } from "react"; import { executeAction } from "@/platform/actions"; import { call, commands, isTauri } from "@/platform/ipc"; import { loadSettings } from "@/platform/project"; import { useWorkflowSettings } from "@/platform/workflowSettings"; import { Checkbox, Input, Popup, T } from "@/ui"; import { useCommit } from "./commitStore"; import styles from "./CommitView.module.css"; type CommitCheck = "reformat" | "optimizeImports" | "cleanup" | "analyzeCode" | "checkTodo"; async function setCheck(key: CommitCheck, value: boolean) { if (!isTauri()) return; try { await call(commands.settingsSet("global", `vcs.commit.${key}`, JSON.stringify(value))); await loadSettings(); } catch { // keep the previous value } } function Section({ title, children }: { title: string; children: ReactNode }) { return (

{title}

{children}
); } function Configure() { return ( ); } /** The options themselves: in the popup, and inline beside the Commit dialog's message. */ export function CommitOptionsBody() { const author = useCommit((s) => s.author); const signOff = useCommit((s) => s.signOff); const runHooks = useCommit((s) => s.runHooks); const c = useWorkflowSettings((s) => s.vcs.commit); const check = (key: CommitCheck, label: string, extra?: ReactNode) => (
void setCheck(key, v)} label={label} /> {extra}
); return ( <>
useCommit.setState({ signOff: v })} label="Sign-off commit" />
{check("reformat", "Reformat code")} {check("optimizeImports", "Optimize imports")} {check("cleanup", "Cleanup")} useCommit.setState({ runHooks: v })} label="Run Git hooks" />
{check("analyzeCode", "Analyze code")} {check("checkTodo", "Check TODO", )}
); } export function CommitOptionsPopup({ anchor, onClose, }: { anchor: RefObject; onClose: () => void; }) { return ( {/* IDEA opens the options without focusing the Author field. */}
); }