fix: use merge-base for diffStat in merger and show files changed on done task cards

The merger was using `git diff HEAD..branch --stat` which includes
artifacts from other tasks when branches fork from older main commits.
Switch to `git diff $(merge-base)..branch --stat` so commit messages
only describe the branch's own changes.

Also surface the "files changed" button on done task cards using
mergeDetails, opening the same ChangedFilesModal with commit-backed
diffs (matching the Changes tab in the task modal).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsxdsm
2026-04-04 08:33:53 -07:00
parent f882c5aed9
commit d3a3cc71d6
9 changed files with 74 additions and 17 deletions

View File

@@ -1,6 +1,6 @@
import { execSync } from "node:child_process";
import { existsSync } from "node:fs";
import type { TaskStore, MergeResult } from "@fusion/core";
import { getTaskMergeBlocker, type TaskStore, type MergeResult } from "@fusion/core";
import { createKbAgent, promptWithFallback } from "./pi.js";
import type { WorktreePool } from "./worktree-pool.js";
import { AgentLogger } from "./agent-logger.js";
@@ -585,10 +585,9 @@ export async function aiMergeTask(
): Promise<MergeResult> {
// 1. Validate task state
const task = await store.getTask(taskId);
if (task.column !== "in-review") {
throw new Error(
`Cannot merge ${taskId}: task is in '${task.column}', must be in 'in-review'`,
);
const mergeBlocker = getTaskMergeBlocker(task);
if (mergeBlocker) {
throw new Error(`Cannot merge ${taskId}: ${mergeBlocker}`);
}
const branch = task.branch || `kb/${taskId.toLowerCase()}`;
@@ -635,7 +634,11 @@ export async function aiMergeTask(
commitLog = "(unable to read commit log)";
}
try {
diffStat = execSync(`git diff HEAD..${branch} --stat`, {
const mergeBase = execSync(`git merge-base HEAD ${branch}`, {
cwd: rootDir,
encoding: "utf-8",
}).trim();
diffStat = execSync(`git diff ${mergeBase}..${branch} --stat`, {
cwd: rootDir,
encoding: "utf-8",
}).trim();