mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-27 08:03:37 +00:00
fix(agents): the generated commit message describes exactly what would be committed
The diff sent to the agent was every included file's whole working-tree change. With the staging area, or blocks left out of a partial commit, it also held changes the commit leaves out. It is now made the way Commit makes the commit (the index with the selection applied, partial files' chosen blocks only), through the new `vcs_pending_patch` command. Before filling in the message, the changes are read again: a file edited and saved while the agent worked, which changes neither the message nor the inclusion, no longer gets a message written for its earlier content.
This commit is contained in:
@@ -273,7 +273,15 @@ async function generate(): Promise<void> {
|
||||
await turnEnd(created.id);
|
||||
const message = commitMessageOf(replyOf(await call(commands.agentEntries(created.id, null))));
|
||||
if (!message) throw new Error(tx("The agent did not reply with a commit message"));
|
||||
if (!service.setMessage(changes.revision, message)) {
|
||||
// The files may have been edited since without touching the draft: the message must
|
||||
// still describe what would be committed.
|
||||
const unchanged = async () => {
|
||||
if (service.revision() !== changes.revision) return null;
|
||||
const now = await service.changes().catch(() => null);
|
||||
return now && now.patch === changes.patch ? now.revision : null;
|
||||
};
|
||||
const at = await unchanged();
|
||||
if (at === null || !service.setMessage(at, message)) {
|
||||
notify({
|
||||
level: "info",
|
||||
title: "Commit message not replaced",
|
||||
|
||||
Reference in New Issue
Block a user