Skip to content

refactor: only send single plan comment to release pr#1009

Merged
adityachoudhari26 merged 1 commit intomainfrom
single-plan-pr-comment
Apr 17, 2026
Merged

refactor: only send single plan comment to release pr#1009
adityachoudhari26 merged 1 commit intomainfrom
single-plan-pr-comment

Conversation

@adityachoudhari26
Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings April 17, 2026 21:12
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 17, 2026

Warning

Rate limit exceeded

@adityachoudhari26 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 27 minutes and 17 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 27 minutes and 17 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 42aac6f0-bf10-4666-96d1-f8bfa5450602

📥 Commits

Reviewing files that changed from the base of the PR and between 6d8789c and fbea67e.

📒 Files selected for processing (10)
  • apps/workspace-engine/pkg/config/env.go
  • apps/workspace-engine/pkg/db/queries/workspaces.sql
  • apps/workspace-engine/pkg/db/workspaces.sql.go
  • apps/workspace-engine/svc/controllers/deploymentplan/controller.go
  • apps/workspace-engine/svc/controllers/deploymentplan/controller_test.go
  • apps/workspace-engine/svc/controllers/deploymentplan/getters.go
  • apps/workspace-engine/svc/controllers/deploymentplan/getters_postgres.go
  • apps/workspace-engine/svc/controllers/deploymentplan/github_comment.go
  • apps/workspace-engine/svc/controllers/deploymentplanresult/controller.go
  • apps/workspace-engine/svc/controllers/deploymentplanresult/github_comment.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch single-plan-pr-comment

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 and usage tips.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors GitHub PR commenting for deployment plans to post a single comment that links to the Ctrlplane plan detail page, instead of posting/updating per-target plan result comments.

Changes:

  • Remove per-target PR commenting from deploymentplanresult processing (and delete the old comment implementation).
  • Add a new deploymentplan PR comment writer that upserts one “plan link” comment per plan.
  • Add supporting plumbing: BASE_URL config, workspace lookup (GetWorkspaceByID) to obtain the workspace slug, and a new sqlc query.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
apps/workspace-engine/svc/controllers/deploymentplanresult/github_comment.go Removes the old per-target/agent PR comment implementation.
apps/workspace-engine/svc/controllers/deploymentplanresult/controller.go Stops emitting PR comments from plan-result processing paths.
apps/workspace-engine/svc/controllers/deploymentplan/github_comment.go Adds PR comment upsert logic that posts a single plan link comment.
apps/workspace-engine/svc/controllers/deploymentplan/controller.go Calls new plan-link commenting helper after processing targets.
apps/workspace-engine/svc/controllers/deploymentplan/getters.go Extends Getter interface with GetWorkspaceByID.
apps/workspace-engine/svc/controllers/deploymentplan/getters_postgres.go Implements GetWorkspaceByID for Postgres-backed getter.
apps/workspace-engine/svc/controllers/deploymentplan/controller_test.go Updates mocks to satisfy the extended Getter interface.
apps/workspace-engine/pkg/db/workspaces.sql.go Adds generated sqlc method GetWorkspaceByID.
apps/workspace-engine/pkg/db/queries/workspaces.sql Adds GetWorkspaceByID query definition.
apps/workspace-engine/pkg/config/env.go Introduces BaseURL (env BASE_URL) for building PR comment links.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +27 to +45
func buildPlanCommentBody(
marker, baseURL, workspaceSlug string,
plan db.DeploymentPlan,
) string {
planURL := fmt.Sprintf(
"%s/%s/deployments/%s/plans/%s",
strings.TrimRight(baseURL, "/"),
workspaceSlug,
plan.DeploymentID,
plan.ID,
)

var sb strings.Builder
sb.WriteString(marker)
sb.WriteString("\n")
sb.WriteString("### Ctrlplane Deployment Plan\n\n")
fmt.Fprintf(&sb, "**Version:** `%s`\n\n", plan.VersionTag)
fmt.Fprintf(&sb, "[View plan →](%s)\n", planURL)
return sb.String()
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

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

The PR-comment link generation is new behavior, but there’s no unit test coverage validating the constructed URL/comment body (e.g., baseURL trimming, workspace slug + deploymentId + planId path). Adding a focused test around buildPlanCommentBody (and/or marker format) would help prevent regressions and accidental route mismatches.

Copilot uses AI. Check for mistakes.
Comment on lines +141 to +145
workspace, err := c.getter.GetWorkspaceByID(ctx, plan.WorkspaceID)
if err != nil {
return fmt.Errorf("get workspace: %w", err)
}
return MaybeCommentPlanLink(ctx, plan, workspace.Slug)
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

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

commentPlanLink always queries GetWorkspaceByID even when PR commenting will be a no-op (e.g., missing github/owner/github/repo/git/sha in plan.VersionMetadata or when the GitHub bot isn’t configured). This adds an extra DB round-trip per plan unnecessarily. Consider short-circuiting before the workspace lookup when the required metadata/bot config is absent, and only fetching the workspace slug when you’re actually going to attempt the GitHub upsert.

Copilot uses AI. Check for mistakes.
@adityachoudhari26 adityachoudhari26 merged commit 4c03214 into main Apr 17, 2026
16 checks passed
@adityachoudhari26 adityachoudhari26 deleted the single-plan-pr-comment branch April 17, 2026 21:23
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.

2 participants