feat(gitlab): add publish_improve_as_thread option - #2723
Conversation
Post the /improve suggestions comment as a resolvable GitLab thread (discussion) instead of a plain note, mirroring the existing gitlab.publish_review_as_thread option for /review. The progress comment is threaded as well, since it is edited in place into the final suggestions comment. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
PR Summary by QodoGitLab: add publish_improve_as_thread for resolvable /improve discussions
AI Description
Diagram
High-Level Assessment
Files changed (4)
|
|
At Comgate we use modified /improve with extra instructions because /review was too heavy for use. |
There was a problem hiding this comment.
Pull request overview
Adds an opt-in GitLab behavior so /improve publishes its suggestions as a discussion thread (matching the existing /review threading support), wiring the option through settings and provider capabilities.
Changes:
- Add
gitlab.publish_improve_as_threadconfiguration flag. - Introduce
should_publish_improve_as_thread()capability onGitProvider+ GitLab implementation. - Update
/improvepublishing flow to optionally publish suggestions (and the progress comment) as a thread, including persistent-history publishing.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pr_agent/tools/pr_code_suggestions.py | Adds optional thread publishing for /improve output and threads the progress comment via shared kwargs/helper. |
| pr_agent/settings/configuration.toml | Documents and defaults the new publish_improve_as_thread GitLab setting. |
| pr_agent/git_providers/gitlab_provider.py | Implements should_publish_improve_as_thread() backed by Dynaconf setting lookup. |
| pr_agent/git_providers/git_provider.py | Adds base capability hook should_publish_improve_as_thread() (default false). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| def should_publish_improve_as_thread(self) -> bool: | ||
| return bool(get_settings().get("GITLAB.PUBLISH_IMPROVE_AS_THREAD", False)) |
| # The progress comment later becomes the final suggestions comment (edited in place), | ||
| # so it must already be a thread when threaded output is requested. | ||
| self.progress_response = self.git_provider.publish_comment(self.progress, | ||
| **self._improve_thread_kwargs()) | ||
| else: |
Code Review by Qodo
1.
|
The 'No code suggestions found' status message is not actionable, so it should never create a resolvable thread. When the progress comment was already published as a thread, replace it with a plain note instead of editing it in place. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Code review by qodo was updated up to the latest commit e15cb6e |
IsmaelMartinez
left a comment
There was a problem hiding this comment.
Thanks, this mirrors publish_review_as_thread cleanly and the full unit suite is green on e15cb6e1.
On scope, keeping it GitLab-only is right. The /improve summary is a top-level comment, and GitHub has no way to resolve one: IssueComment carries no resolution state, and the only resolvable object is the diff-anchored PullRequestReviewThread. So there is no cross-provider version of this to generalise to.
One gap: the feature this mirrors ships with tests (test_gitlab_provider.py:323, test_pr_reviewer_core.py:592) and a docs entry (additional_configurations.md:143), and this has neither.
| if self._improve_thread_kwargs(): | ||
| # A mere status message should not leave a resolvable thread behind; replace | ||
| # the threaded progress comment with a plain note. | ||
| self.git_provider.remove_comment(self.progress_response) |
There was a problem hiding this comment.
This is the part I would most want covered: it swaps an in-place edit for a delete plus a re-publish, so the comment id changes and a failed delete leaves two comments behind.
When the threaded /improve progress comment carries no suggestions, keep it as the resolvable thread and mark it resolved, rather than deleting it and re-posting as a plain note. Adds GitLabProvider.resolve_comment_thread, mirroring the existing unresolve_comment_thread. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Code review by qodo was updated up to the latest commit ffbfc07 |
There was a problem hiding this comment.
Everything I asked for is in, and the thread handling ended up better than what I suggested. Dropping the delete-and-republish for an in-place edit plus a resolve removes the comment-id churn entirely, and remove_comment.assert_not_called() pins it so it cannot come back. CI is green: the runs were gated because this is a fork PR, so I approved them.
One thing left, the docs entry. publish_review_as_thread has its own section in additional_configurations.md and this needs the sibling. Something like:
## Post the /improve suggestions as a GitLab thread
By default, PR-Agent posts the `/improve` suggestions as a plain note. To post them as a resolvable thread (GitLab discussion) instead, enable (default: `false`):
```toml
[gitlab]
publish_improve_as_thread = true
```
- A run that finds no suggestions edits the thread in place and resolves it, so a status message does not leave an open thread behind.Add that and I will approve. Thanks again!!
Post the /improve suggestions comment as a resolvable GitLab thread (discussion) instead of a plain note, mirroring the existing gitlab.publish_review_as_thread option for /review.
The progress comment is threaded as well, since it is edited in place into the final suggestions comment.