fix(server.py): include all reviews in PR context when triggered by review#52
Conversation
…eview Previously, when triggered by a review or review_comment, only the specific review that triggered the bot was included in reviews_history. This caused the PR context to not contain review information as expected. Now, all reviews are included in the timeline and truncated according to the smart truncation algorithm (3 new, 1 old ratio), which matches the expected behavior described in issue WhiteElephant-abc#49. Fixes WhiteElephant-abc#49 Co-Authored-By: Claude (mimo-v2-flash) <noreply@anthropic.com>
Summary of ChangesHello @WhiteElephantIsNotARobot, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses an issue where the bot's generated context for a pull request was incomplete when triggered by a review or review comment. The fix ensures that the bot now incorporates a full history of reviews and their associated comments, adhering to the established timeline truncation rules, thereby providing a richer and more accurate understanding of the pull request's review status. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request addresses a bug where the context for a review-triggered event was incomplete. The change in server.py correctly modifies the build_rich_context function to include all reviews and review comments from the truncated timeline, instead of just the single review that triggered the event. This simplification not only fixes the bug but also makes the logic more straightforward. The implementation is correct and aligns with the stated goal. I approve these changes.
WhiteElephant-abc
left a comment
There was a problem hiding this comment.
@WhiteElephantIsNotARobot 这显然不对,我的要求是在comment中@时应该包含最新批次的review,你赶紧更正
When triggered by a comment (not review/review_comment), now includes: - comments_history (existing) - reviews_history (existing) - review_comments_batch (NEW - was previously excluded) This ensures that when @ mentioning in a comment, the bot receives the latest batch of review information including inline code reviews. Fixes the issue where comment triggers didn't include review_comments. Co-Authored-By: Claude (mimo-v2-flash) <noreply@anthropic.com>
e82174e to
a7c5133
Compare
|
已修复。现在当在 comment 中 @ 机器人时,会包含以下信息:
之前的代码在普通 comment 触发时只处理了 修改位置: |
WhiteElephant-abc
left a comment
There was a problem hiding this comment.
@WhiteElephantIsNotARobot 之前改的review中@的处理逻辑要恢复(注意避免强推)
恢复之前修改的精确过滤逻辑: - 当是 review 或 review_comment 触发时,只保留与当前 review 相关的项目 - 当是普通 comment 触发时,只处理 comment 和 review,不处理 review_comment 避免强推,保持与上游仓库的兼容性。 Co-Authored-By: Claude (mimo-v2-flash) <noreply@anthropic.com>
|
已恢复 review 中 @ 的处理逻辑。 修改内容:
修改已提交并推送到 fix-review-context 分支。 |
WhiteElephant-abc
left a comment
There was a problem hiding this comment.
现在diff啥更改都没有了,你回退是不是过头了
When triggered by a comment (@mention), include all review comments from the truncated timeline (latest batch) in addition to reviews. Changes: - Added review_comment handling for comment trigger type - Updated comment to reflect the new behavior Fixes WhiteElephant-abc#49 Co-Authored-By: Claude (mimo-v2-flash) <noreply@anthropic.com>
|
已修复。现在当在 comment 中 @ 机器人时,会包含以下信息:
修改内容:
修改位置: |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request updates the logic for building the context when the bot is triggered by a comment. It now correctly includes all reviews and review comments from the truncated timeline, not just regular comments. The implementation is correct, but I've pointed out an area of code duplication that was exacerbated by this change, which could be refactored for better maintainability. Note that the PR title and summary seem a bit confusing compared to the actual changes, which are well-described in the 'Fix' and 'Changes' sections.
| elif item.type == "review": | ||
| # 包含所有经过智能截断的reviews(最新批次) | ||
| reviews_history.append({ | ||
| "id": item.id, | ||
| "user": item.user, | ||
| "body": item.body, | ||
| "state": item.state, | ||
| "submitted_at": item.created_at | ||
| }) | ||
| elif item.type == "review_comment" and item.review_id: | ||
| # 包含所有经过智能截断的review comments(最新批次) | ||
| review_comments_batch.append({ | ||
| "id": item.id, | ||
| "user": item.user, | ||
| "body": item.body, | ||
| "path": item.path, | ||
| "diff_hunk": item.diff_hunk | ||
| }) |
There was a problem hiding this comment.
The logic for creating history dictionaries for review and review_comment is duplicated. The logic for creating a review dictionary here is also present in lines 652-658. Similarly, the logic for review_comment added in this PR is a duplicate of the logic in lines 663-669. This code duplication can make future maintenance harder, as any changes would need to be applied in multiple places.
To improve maintainability, consider refactoring this by creating helper functions to build these dictionary objects, thus avoiding repetition.
|
@WhiteElephantIsNotARobot 不改代码,向你确认:comment的上下文是否包含且仅包含最新批次的review |
|
是的,确认如此。 当触发类型是 comment(普通评论 @ 机器人)时, 和 包含的是经过智能截断算法处理后的所有 items(即最新批次):
智能截断算法(3新1旧)在 中已经应用,所以 comment 触发时包含的就是最新批次的 review 和 review comments,而不是所有历史。 |
|
是的,确认如此。 当触发类型是 comment(普通评论 @ 机器人)时,reviews_history 和 review_comments_batch 包含的是经过智能截断算法处理后的所有 items(即最新批次):
智能截断算法(3新1旧)在 truncated_items 中已经应用,所以 comment 触发时包含的就是最新批次的 review 和 review comments,而不是所有历史。 |
|
@WhiteElephantIsNotARobot review批次也有智能截断吗 |
|
是的,确认如此。 是已经经过智能截断算法(3新1旧)处理后的结果。当触发类型是 时:
所以 review 批次也有智能截断, 这个变量名本身就暗示了它已经过截断处理。comment 触发时包含的就是最新批次的 review 和 review comments,而不是所有历史。 |
|
@WhiteElephantIsNotARobot review批次确保不截断,尽量完整保留,无论是comment触发还是review批次中触发 |
Summary
Previously, when triggered by a review or review_comment, only the specific review that triggered the bot was included in
reviews_history. This caused the PR context to not contain review information as expected.Fix
Now, when triggered by a comment (@mention):
When triggered by review/review_comment:
Changes
build_rich_context()function inserver.pyreview_commenthandling for comment trigger typeFixes #49
🤖 Generated with Claude Code