From fa62aff82274bd56039e0dedf9226995d90ef09f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Flor=C3=AAncio?= Date: Tue, 10 Mar 2026 22:32:17 +0000 Subject: [PATCH] fix(review): use merge-base for PR review prompts to avoid reviewing unrelated changes (#412) --- apps/backend/internal/prompts/store/sqlite.go | 5 ++++- apps/backend/internal/workflow/repository/sqlite.go | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/backend/internal/prompts/store/sqlite.go b/apps/backend/internal/prompts/store/sqlite.go index ea37ef4964..4ca17ebe2e 100644 --- a/apps/backend/internal/prompts/store/sqlite.go +++ b/apps/backend/internal/prompts/store/sqlite.go @@ -219,7 +219,10 @@ func (r *sqliteRepository) builtinCodeReviewPrompt(now time.Time) *models.Prompt STEP 1: Determine what to review - First, check if there are any uncommitted changes (dirty working directory) - If there are uncommitted/staged changes: review those files -- If the working directory is clean: review the commits that have diverged from the master/main branch +- If the working directory is clean: review ONLY the commits from this branch + - Use: git log --oneline $(git merge-base origin/main HEAD)..HEAD to list the branch commits + - Use: git diff $(git merge-base origin/main HEAD) to see the cumulative changes + - Do NOT diff directly against origin/main or master — that would include unrelated changes if the branch is outdated STEP 2: Review the changes, then output your findings in EXACTLY 4 sections: BUG, IMPROVEMENT, NITPICK, PERFORMANCE. diff --git a/apps/backend/internal/workflow/repository/sqlite.go b/apps/backend/internal/workflow/repository/sqlite.go index 4b03eb2e2c..b9b36628c4 100644 --- a/apps/backend/internal/workflow/repository/sqlite.go +++ b/apps/backend/internal/workflow/repository/sqlite.go @@ -444,7 +444,7 @@ func (r *Repository) getPRReviewTemplate(now time.Time) *models.WorkflowTemplate Position: 1, Color: "bg-yellow-500", ShowInCommandPanel: true, - Prompt: "Please review the changed files in the current git worktree.\n\nSTEP 1: Determine what to review\n- First, check if there are any uncommitted changes (dirty working directory)\n- If there are uncommitted/staged changes: review those files\n- If the working directory is clean: review the commits that have diverged from the master/main branch\n\nSTEP 2: Review the changes, then output your findings in EXACTLY 4 sections: BUG, IMPROVEMENT, NITPICK, PERFORMANCE.\n\nRules:\n- Each section is OPTIONAL — only include it if you have findings for that category\n- If a section has no findings, omit it entirely\n- Format each finding as: filename:line_number - Description\n- Be specific and reference exact line numbers\n- Keep descriptions concise but actionable\n\n{{task_prompt}}", + Prompt: "Please review the changed files in the current git worktree.\n\nSTEP 1: Determine what to review\n- First, check if there are any uncommitted changes (dirty working directory)\n- If there are uncommitted/staged changes: review those files\n- If the working directory is clean: review ONLY the commits from this branch\n - Use: git log --oneline $(git merge-base origin/main HEAD)..HEAD to list the branch commits\n - Use: git diff $(git merge-base origin/main HEAD) to see the cumulative changes\n - Do NOT diff directly against origin/main or master — that would include unrelated changes if the branch is outdated\n\nSTEP 2: Review the changes, then output your findings in EXACTLY 4 sections: BUG, IMPROVEMENT, NITPICK, PERFORMANCE.\n\nRules:\n- Each section is OPTIONAL — only include it if you have findings for that category\n- If a section has no findings, omit it entirely\n- Format each finding as: filename:line_number - Description\n- Be specific and reference exact line numbers\n- Keep descriptions concise but actionable\n\n{{task_prompt}}", Events: models.StepEvents{ OnEnter: []models.OnEnterAction{ {Type: models.OnEnterAutoStartAgent},