дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-05 01:31:41 +02: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.
Цей коміт міститься в:
1 джерело
dfbe87161b
коміт
0cd7d9c30e
11 files changed
+84
-27
No files matched your search
@@ -20,6 +20,7 @@ const backend = vi.hoisted(() => ({
|
||||
notify: vi.fn(),
|
||||
changes: vi.fn(),
|
||||
setMessage: vi.fn(),
|
||||
revision: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("@/platform/ipc", async (original) => ({
|
||||
@@ -35,7 +36,12 @@ vi.mock("@/platform/ipc", async (original) => ({
|
||||
vi.mock("@/workbench/contributions", async (original) => ({
|
||||
...(await original<typeof import("@/workbench/contributions")>()),
|
||||
notifications: () => ({ notify: backend.notify }),
|
||||
maybeCommitService: () => ({ changes: backend.changes, setMessage: backend.setMessage, selection: vi.fn() }),
|
||||
maybeCommitService: () => ({
|
||||
changes: backend.changes,
|
||||
setMessage: backend.setMessage,
|
||||
revision: backend.revision,
|
||||
selection: vi.fn(),
|
||||
}),
|
||||
}));
|
||||
|
||||
const ok = (data: unknown) => Promise.resolve({ status: "ok" as const, data });
|
||||
@@ -283,6 +289,7 @@ describe("generateCommitMessage", () => {
|
||||
vi.clearAllMocks();
|
||||
backend.changes.mockResolvedValue(changes);
|
||||
backend.setMessage.mockReturnValue(true);
|
||||
backend.revision.mockReturnValue(changes.revision);
|
||||
backend.log.mockImplementation(() => ok([{ summary: "feat: earlier" }]));
|
||||
backend.cancel.mockImplementation(() => ok(null));
|
||||
backend.remove.mockImplementation(() => ok(null));
|
||||
@@ -382,6 +389,14 @@ describe("generateCommitMessage", () => {
|
||||
expect(backend.remove).toHaveBeenCalledWith("new", false);
|
||||
});
|
||||
|
||||
it("does not fill in a message for changes edited in the files while the agent worked", async () => {
|
||||
createdTask("ready");
|
||||
backend.changes.mockResolvedValueOnce(changes).mockResolvedValue({ ...changes, patch: changes.patch + "+more\n" });
|
||||
await generateCommitMessage();
|
||||
expect(backend.setMessage).not.toHaveBeenCalled();
|
||||
expect(notified()).toEqual([expect.objectContaining({ level: "info", title: "Commit message not replaced" })]);
|
||||
});
|
||||
|
||||
it("runs once at a time", async () => {
|
||||
createdTask("ready");
|
||||
await Promise.all([generateCommitMessage(), generateCommitMessage()]);
|
||||
|
||||
Reference in new issue
Заблокувати користувача