Skip to content

feat: platform-specific code suggestion rendering (#42) - #50

Merged
brucearctor merged 2 commits into
mainfrom
feat/code-suggestions-42
Jul 26, 2026
Merged

feat: platform-specific code suggestion rendering (#42)#50
brucearctor merged 2 commits into
mainfrom
feat/code-suggestions-42

Conversation

@brucearctor

@brucearctor brucearctor commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Closes #42

Moves suggestion markdown rendering from formatInlineComment() into each platform client, enabling platform-specific syntax:

  • GitHub: suggestion (standard)
  • GitLab: suggestion:-0+0 (single-line syntax)

Changes

  • vcs/types.go: Added Suggestion field to ReviewComment
  • reviewer/output.go: Passes raw suggestion through; removed rendering from formatInlineComment()
  • github/client.go: Renders GitHub suggestion syntax in SubmitReview()
  • gitlab/client.go: Renders GitLab suggestion syntax in both draft notes and individual comment paths
  • Tests updated

Summary by CodeRabbit

  • New Features

    • Added configurable cleanup modes for previous review comments: delete or resolve.
    • Added support for resolving prior review discussions on GitLab.
    • Added inline code suggestions to review comments on GitHub and GitLab.
    • Added configuration through command-line flags, environment variables, and repository settings.
  • Bug Fixes

    • GitHub now clearly reports when resolve mode is unavailable and continues using deletion behavior.

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@brucearctor, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 46 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 070b4075-a689-4804-bdcc-d570803b9329

📥 Commits

Reviewing files that changed from the base of the PR and between dbead20 and 6da013f.

📒 Files selected for processing (7)
  • .code-reviewer.example.yaml
  • internal/config/config_test.go
  • internal/github/client.go
  • internal/gitlab/client.go
  • internal/reviewer/output.go
  • internal/reviewer/output_test.go
  • internal/vcs/types.go
📝 Walkthrough

Walkthrough

Changes

Review submission changes

Layer / File(s) Summary
Cleanup configuration contract
internal/config/config.go, internal/config/config_test.go, .code-reviewer.example.yaml
Adds delete and resolve cleanup modes with YAML, environment, flag, defaulting, validation, and loading tests.
Review comment data contract
internal/vcs/types.go, internal/reviewer/output.go, internal/reviewer/output_test.go
Carries raw suggestions separately from comment bodies and passes cleanup mode through review requests.
GitLab cleanup and suggestion delivery
internal/gitlab/client.go
Adds paginated discussion lookup, discussion resolution, cleanup routing, PUT support, and suggestion formatting for draft, inline, and fallback notes.
GitHub submission behavior
internal/github/client.go
Warns that resolve mode is unsupported and formats suggestions using GitHub suggestion blocks.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Reviewer
  participant GitLabClient
  participant GitLabAPI
  Reviewer->>GitLabClient: Submit review with cleanup mode and comments
  GitLabClient->>GitLabAPI: List prior MR discussions
  GitLabAPI-->>GitLabClient: Return bot-authored discussions
  GitLabClient->>GitLabAPI: Resolve discussions when cleanup mode is resolve
  GitLabClient->>GitLabAPI: Post notes with platform-specific suggestions
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (3 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning Description lacks the required What/Why/How/Testing sections from the template and omits the checklist details. Rewrite the PR description to use the template headings and fill in the testing checklist, build/lint status, config fields, and README notes if needed.
Out of Scope Changes check ⚠️ Warning The cleanup-mode config and previous-review resolution logic are unrelated to issue #42's suggestion-rendering scope. Move cleanup-mode and review-resolution work to a separate PR, or remove it here so this change stays focused on suggestion rendering.
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed Title clearly describes the main change: platform-specific suggestion rendering.
Linked Issues check ✅ Passed Changes align with issue #42 by keeping raw suggestions in ReviewComment and rendering platform-specific syntax in clients.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/code-suggestions-42

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
internal/config/config_test.go (1)

707-726: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add coverage for YAML and invalid cleanup modes.

These cases cover flag and environment loading, but the change also adds .code-reviewer.yaml parsing and validate() rejection. Add table cases for cleanup_mode: resolve, an invalid value, and flag-over-environment precedence.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/config/config_test.go` around lines 707 - 726, Add table-driven
cases in the config tests around the existing cleanup_mode_flag and
cleanup_mode_env cases covering YAML cleanup_mode: resolve, rejection of an
invalid cleanup mode during validate(), and flag-over-environment precedence.
Reuse the existing Config parsing test setup and assert the resolved CleanupMode
or validation error as appropriate.
internal/reviewer/output_test.go (1)

205-205: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Replace the deleted suggestion test with a submission-contract test.

Add a table-driven test that captures SubmitReviewRequest and verifies both raw Suggestion and CleanupMode survive PostReview; the current deletion removes the only suggestion-specific assertion.

As per path instructions, **/*_test.go changes should prefer table-driven tests and verify proper cleanup and race-condition safety.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/reviewer/output_test.go` at line 205, Add a table-driven
submission-contract test in the review output tests that intercepts
SubmitReviewRequest, calls PostReview with representative suggestion and
cleanup-mode values, and asserts both fields are preserved unchanged. Include
cleanup of any captured resources and structure the test to remain safe under
race detection.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/gitlab/client.go`:
- Around line 253-254: Replace the time.Sleep call after resolved++ in the
resolution flow with a cancellable timer/select that waits for apiRateDelay or
returns when ctx.Done() is signaled. Ensure the timer is stopped or cleaned up
appropriately while preserving the existing rate-limit delay after successful
resolution.
- Around line 334-335: Update the CreateDraftNoteRequest construction in the
draft inline-note flow to include the configured botMarker in Note, matching the
marker used by ResolvePreviousReviews. Preserve the existing note body while
ensuring every bot-generated draft inline note is identifiable for
discussion-level resolution in “resolve” mode.

---

Nitpick comments:
In `@internal/config/config_test.go`:
- Around line 707-726: Add table-driven cases in the config tests around the
existing cleanup_mode_flag and cleanup_mode_env cases covering YAML
cleanup_mode: resolve, rejection of an invalid cleanup mode during validate(),
and flag-over-environment precedence. Reuse the existing Config parsing test
setup and assert the resolved CleanupMode or validation error as appropriate.

In `@internal/reviewer/output_test.go`:
- Line 205: Add a table-driven submission-contract test in the review output
tests that intercepts SubmitReviewRequest, calls PostReview with representative
suggestion and cleanup-mode values, and asserts both fields are preserved
unchanged. Include cleanup of any captured resources and structure the test to
remain safe under race detection.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 561f4130-66dd-4e86-8bf5-0d075187d9e7

📥 Commits

Reviewing files that changed from the base of the PR and between d897a14 and dbead20.

📒 Files selected for processing (8)
  • .code-reviewer.example.yaml
  • internal/config/config.go
  • internal/config/config_test.go
  • internal/github/client.go
  • internal/gitlab/client.go
  • internal/reviewer/output.go
  • internal/reviewer/output_test.go
  • internal/vcs/types.go

Comment thread internal/gitlab/client.go Outdated
Comment thread internal/gitlab/client.go Outdated
@brucearctor
brucearctor force-pushed the feat/code-suggestions-42 branch from dbead20 to 8a31cf2 Compare July 26, 2026 23:35
1. Make rate-limit wait cancellable in ResolvePreviousReviews — use
   select on ctx.Done() instead of time.Sleep
2. Tag draft inline notes with botMarker — ensures resolve mode can
   identify bot discussions created via the draft notes path
3. Add submission-contract test verifying Suggestion and CleanupMode
   survive PostReview passthrough (table-driven)
4. Add config tests: invalid cleanup-mode validation, flag-over-env
   precedence
@brucearctor
brucearctor merged commit b098c9e into main Jul 26, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: code suggestions rendering (single-line)

1 participant