fix(azure): render /improve suggestions as a diff block - #2718
fix(azure): render /improve suggestions as a diff block#2718IsmaelMartinez wants to merge 1 commit into
Conversation
Azure DevOps has no committable suggestion blocks, so the fence /improve emits was published verbatim and rendered as a raw, uneditable block. Rewrite it as a diff block, matching what the Bitbucket providers already do. Refs: The-PR-Agent#2110 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
PR Summary by QodoRender Azure /improve Suggestions as Diff Blocks
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
Code Review by Qodo
1. Diff conversion drops changed lines
|
| patch = "\n".join(patch_orig.splitlines()[5:]).strip('\n') | ||
| diff_code = f"\n\n```diff\n{patch.rstrip()}\n```" |
There was a problem hiding this comment.
4. Diff conversion drops changed lines 🐞 Bug ≡ Correctness
The renderer removes the first five splitlines() entries, but existing_code and improved_code are each forced to end in a newline and then split on \n, so difflib.unified_diff includes a sixth blank-context line after the -/+ lines. Consequently the slice keeps only that blank line and Azure receives an empty diff block instead of showing the old and new code.
Agent Prompt
## Issue description
The generated unified diff contains a trailing empty-line context entry because both snippets are appended with `\n` and split using `split('\\n')`. Slicing from index 5 therefore discards the `-` and `+` lines, producing an empty diff block.
## Issue Context
The regression test expects `-values = []` and `+values = set()` in the Azure comment, but the current slicing removes them. Build the patch from the actual unified-diff hunk lines (or change the input splitting/slicing) while preserving the existing fallback behavior when the original suggestion is unusable.
## Fix Focus Areas
- pr_agent/git_providers/azuredevops_provider.py[116-123]
- tests/unittest/test_azure_devops_provider.py[482-492]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
Hi @naorpeled, last of this batch, ready for review. Azure DevOps has no committable suggestions, but |
Azure DevOps has no committable suggestion blocks, but
/improveemits GitHub's suggestion fence unconditionally and the Azure provider posts that body verbatim, so it renders as a raw uneditable block. Every other platform without native support rewrites the fence first: both Bitbucket providers swap in a diff block, GitLab rewrites the info string, Gerrit special-cases it.This applies the Bitbucket treatment to Azure, including the PR-level fallback path. When
original_suggestionis missing or unusable the body is left exactly as it is today. Four regression tests, two of which fail onmain.Refs #2110.