fix(commit): created commits before agent teardown

- Ran commit host completion before commit-agent session disposal so mnemopi/autolearn teardown cannot preempt a valid proposal.

- Converted missing commit-agent host outputs and split-plan gaps into thrown errors so omp commit cannot resolve into exit 0 without creating a commit.

- Preserved caller GPG_TTY state instead of forcing a bogus signing TTY in git and non-interactive subprocess environments.

Fixes #4794
This commit is contained in:
roboomp
2026-07-11 00:58:34 +00:00
parent ac2ea80fa3
commit 159484ca6f
9 changed files with 170 additions and 23 deletions
@@ -46,4 +46,50 @@ describe("commit agent prompt attribution", () => {
expect(prompt.options?.expandPromptTemplates).toBe(false);
}
});
it("runs completion before session disposal", async () => {
const events: string[] = [];
const session = {
prompt: async () => {},
subscribe: () => () => {},
dispose: async () => {
events.push("dispose");
},
};
vi.spyOn(sdkModule, "createAgentSession").mockResolvedValue({ session } as unknown as CreateAgentSessionResult);
vi.spyOn(toolsModule, "createCommitTools").mockImplementation(options => {
options.state.proposal = {
analysis: {
type: "fix",
scope: "commit",
details: [],
issueRefs: [],
},
summary: "create commit before teardown",
warnings: [],
};
return [];
});
const model = getBundledModel("anthropic", "claude-sonnet-4-5");
if (!model) {
throw new Error("Expected claude-sonnet-4-5 model to exist");
}
await runCommitAgentSession({
cwd: "/tmp",
model,
settings: Settings.isolated(),
modelRegistry: {} as never,
authStorage: {} as never,
changelogTargets: [],
requireChangelog: false,
onComplete: state => {
events.push(state.proposal?.summary ?? "missing proposal");
},
});
expect(events).toEqual(["create commit before teardown", "dispose"]);
});
});