fix(dashboard): prevent foreign-branch diffs after worktree pool reuse
When the worktree-recycle pool reassigned a path to a new task, the old task's diff endpoints kept reading the new task's branch state — surfacing unrelated commits as the original task's "files changed" list. - Clear task.worktree/branch in the merger after the worktree is released to the pool or removed, so the path no longer points anywhere. - Validate the worktree's current branch matches task.branch in the three worktree-backed diff endpoints; on mismatch return empty rather than diffing against a foreign branch. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -47,6 +47,12 @@ export interface ResolveDiffBaseTaskInput {
|
||||
* 2. **Task-scoped baseCommitSha** — If merge-base is unavailable or equals
|
||||
* `headRef`, use `baseCommitSha` when still an ancestor of `headRef`.
|
||||
* 3. **headRef~1** — Last-resort fallback.
|
||||
*
|
||||
* Note: callers must validate the worktree still belongs to the task (e.g.
|
||||
* compare `git rev-parse --abbrev-ref HEAD` to `task.branch`) before invoking
|
||||
* this. After worktree-pool reassignment the same path may host a foreign
|
||||
* branch, in which case `baseCommitSha..HEAD` would surface other tasks'
|
||||
* commits and this function has no way to detect that.
|
||||
*/
|
||||
export async function resolveDiffBase(
|
||||
task: ResolveDiffBaseTaskInput,
|
||||
|
||||
Reference in New Issue
Block a user