feat(vcs): add commit body field and AI generation for commit description and PR title (#465)

* feat(vcs): add commit body/description field to commit dialog

Add an optional description textarea below the commit title in both
desktop and mobile commit dialogs, with a dedicated AI generate button
for the description. Add builtin-commit-description utility agent and
E2E test.

* style: fix prettier formatting in mobile git controls and E2E test

* fix(e2e): use specific testid selectors for commit dialog inputs

The commit dialog now has two textboxes (title + body), so
getByRole("textbox") is ambiguous. Use getByTestId selectors
and add exact match for the Commit button.

* fix(ui): add cursor-pointer to mobile commit button

* fix(ui): remove "(optional)" from description label and "Generate" text from button

* fix(ui): match PR dialog style for commit description generate button

* feat(vcs): add AI generate button for PR title

Add builtin-pr-title utility agent and wire up a generate button
inside the PR title input, matching the commit title pattern.
Extract shared dialog field components into vcs-dialog-fields.tsx
to stay within the 600-line file limit.

* refactor(ui): unify generate buttons as icon-only sparkles inside inputs

Move AI generate buttons inside both title inputs and description
textareas (top-right corner) for a consistent look. Remove the
"Generate" label variant — all buttons are now icon-only sparkles.

* style: fix prettier formatting in utility agent generator hook

* fix(a11y): add aria-labels to generate buttons and PR title input

* ci: retrigger E2E tests

* fix(e2e): improve commit dialog button click reliability

Add exact match and enabled check before clicking the dialog
Commit button, increase close timeout.

* ci: retrigger checks

* fix(e2e): improve pre-hooks test commit button reliability

Add exact match, enabled check, and longer dialog timeout to match
the commit-body test pattern.

* fix(ui): prevent dialog field overflow and improve commit description prompt

- Add min-w-0 to relative wrappers in commit and PR dialog fields to
  prevent text inputs/textareas from overflowing the dialog bounds
- Rewrite commit description prompt to use system-role framing that
  prevents weaker models from adding conversational preamble
This commit is contained in:
José Almeida
2026-03-26 13:24:30 +00:00
committed by GitHub
parent ec01a55354
commit 7d900fea91
7 changed files with 620 additions and 167 deletions
@@ -91,6 +91,42 @@ function useGitToast() {
);
}
function useCommitDialogForm(
onOpenChange: (open: boolean) => void,
onCommit: (message: string, stageAll: boolean) => void,
) {
const [commitMessage, setCommitMessage] = useState("");
const [commitBody, setCommitBody] = useState("");
const [stageAll, setStageAll] = useState(true);
const handleOpen = (isOpen: boolean) => {
if (isOpen) {
setCommitMessage("");
setCommitBody("");
setStageAll(true);
}
onOpenChange(isOpen);
};
const handleCommit = () => {
const title = commitMessage.trim();
const body = commitBody.trim();
const fullMessage = body ? `${title}\n\n${body}` : title;
onCommit(fullMessage, stageAll);
};
return {
commitMessage,
setCommitMessage,
commitBody,
setCommitBody,
stageAll,
setStageAll,
handleOpen,
handleCommit,
};
}
export function CommitDialog({
open,
onOpenChange,
@@ -108,19 +144,10 @@ export function CommitDialog({
isGitLoading: boolean;
onCommit: (message: string, stageAll: boolean) => void;
}) {
const [commitMessage, setCommitMessage] = useState("");
const [stageAll, setStageAll] = useState(true);
const handleOpen = (isOpen: boolean) => {
if (isOpen) {
setCommitMessage("");
setStageAll(true);
}
onOpenChange(isOpen);
};
const form = useCommitDialogForm(onOpenChange, onCommit);
return (
<Dialog open={open} onOpenChange={handleOpen}>
<Dialog open={open} onOpenChange={form.handleOpen}>
<DialogContent className="max-w-[90vw] sm:max-w-[500px]">
<DialogHeader>
<DialogTitle className="flex items-center gap-2">
@@ -137,16 +164,31 @@ export function CommitDialog({
/>
</div>
<Input
data-testid="commit-title-input"
placeholder="Enter commit message..."
value={commitMessage}
onChange={(e) => setCommitMessage(e.target.value)}
value={form.commitMessage}
onChange={(e) => form.setCommitMessage(e.target.value)}
autoFocus
/>
<div className="space-y-2">
<Label htmlFor="commit-body-mobile" className="text-sm">
Description
</Label>
<Textarea
id="commit-body-mobile"
data-testid="commit-body-input"
placeholder="Add details about this change..."
value={form.commitBody}
onChange={(e) => form.setCommitBody(e.target.value)}
rows={3}
className="resize-none max-h-[200px] overflow-y-auto"
/>
</div>
<div className="flex items-center gap-2">
<Checkbox
id="stage-all-mobile"
checked={stageAll}
onCheckedChange={(checked) => setStageAll(checked === true)}
checked={form.stageAll}
onCheckedChange={(checked) => form.setStageAll(checked === true)}
/>
<Label
htmlFor="stage-all-mobile"
@@ -163,8 +205,9 @@ export function CommitDialog({
</Button>
</DialogClose>
<Button
onClick={() => onCommit(commitMessage.trim(), stageAll)}
disabled={!commitMessage.trim() || isGitLoading}
className="cursor-pointer"
onClick={form.handleCommit}
disabled={!form.commitMessage.trim() || isGitLoading}
>
{isGitLoading ? (
<>