fix(coding-agent): signalled fallback commits with a non-zero exit code

This commit is contained in:
zhang17-24
2026-08-06 23:03:25 +08:00
parent 3a8591a8af
commit ec0253effd
7 changed files with 161 additions and 17 deletions
@@ -11,7 +11,7 @@ describe("omp commit command lifecycle (issue #1041)", () => {
it("forces process exit after the commit pipeline resolves", async () => {
const initThemeSpy = vi.spyOn(themeModule, "initTheme").mockResolvedValue(undefined);
const runCommitSpy = vi.spyOn(commitModule, "runCommitCommand").mockResolvedValue(undefined);
const runCommitSpy = vi.spyOn(commitModule, "runCommitCommand").mockResolvedValue({ usedFallback: false });
// Stub postmortem.quit so it records the exit code without actually
// terminating the test runner. Resolves immediately — the production
// implementation never returns, but the contract under test is that
@@ -33,6 +33,24 @@ describe("omp commit command lifecycle (issue #1041)", () => {
expect(quitSpy).toHaveBeenCalledWith(0);
});
it("exits non-zero when the commit pipeline used the mechanical fallback", async () => {
const initThemeSpy = vi.spyOn(themeModule, "initTheme").mockResolvedValue(undefined);
const runCommitSpy = vi.spyOn(commitModule, "runCommitCommand").mockResolvedValue({ usedFallback: true });
const quitSpy = vi.spyOn(postmortem, "quit").mockResolvedValue(undefined);
const command = new CommitCommand([], {
bin: "omp",
version: "0.0.0-test",
commands: new Map(),
});
await command.run();
expect(initThemeSpy).toHaveBeenCalledTimes(1);
expect(runCommitSpy).toHaveBeenCalledTimes(1);
expect(quitSpy).toHaveBeenCalledWith(1);
});
it("does not convert commit pipeline failures into exit 0", async () => {
const initThemeSpy = vi.spyOn(themeModule, "initTheme").mockResolvedValue(undefined);
const runCommitSpy = vi