feat: add diff line count to plans table results view#1054
feat: add diff line count to plans table results view#1054adityachoudhari26 merged 4 commits intomainfrom
Conversation
Show +added/-removed line counts (via LCS diff) alongside the "View diff" button in the release target results table, similar to GitHub's diff display. Co-authored-by: Aditya Choudhari <adityachoudhari26@users.noreply.github.com>
|
|
|
Warning Rate limit exceeded
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 40 minutes and 1 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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 configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
…e-1036-20260423-1736
There was a problem hiding this comment.
Pull request overview
Adds GitHub-style +added/-removed diff line counts next to the “View diff” action in the deployment plan results table to better communicate change magnitude. Closes #1036.
Changes:
- Compute per-result diff stats (added/removed line counts) in the TRPC
deployment.plans.resultsresponse. - Render the diff stats next to the “View diff” button in the plan results table UI.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/trpc/src/routes/deployment-plans.ts | Fetches diff inputs and computes diffStats for each plan result returned by the results endpoint. |
| apps/web/app/routes/ws/deployments/page.$deploymentId.plans.$planId.tsx | Displays diffStats next to “View diff” in the Changes column. |
Comments suppressed due to low confidence (1)
packages/trpc/src/routes/deployment-plans.ts:229
diffStatsis computed for every row, even whenhasChangesisfalse/nullor the status isn’t completed. This adds unnecessary work and amplifies the cost ofcomputeDiffStats. Consider guarding the call (e.g., only compute whenr.hasChanges === true) and otherwise returnnull.
resource: { id: r.resourceId, name: r.resourceName },
agent: {
id: (agent.id as string | undefined) ?? "",
name: (agent.name as string | undefined) ?? "",
type: (agent.type as string | undefined) ?? "",
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| function computeDiffStats( | ||
| current: string | null, | ||
| proposed: string | null, | ||
| ): { added: number; removed: number } | null { | ||
| if (current == null || proposed == null) return null; | ||
| const a = current.split("\n"); | ||
| const b = proposed.split("\n"); | ||
| const m = a.length; | ||
| const n = b.length; | ||
| let prev = new Array<number>(n + 1).fill(0); | ||
| for (let i = 1; i <= m; i++) { | ||
| const curr = new Array<number>(n + 1).fill(0); | ||
| for (let j = 1; j <= n; j++) { | ||
| curr[j] = | ||
| a[i - 1] === b[j - 1] | ||
| ? (prev[j - 1] ?? 0) + 1 | ||
| : Math.max(prev[j] ?? 0, curr[j - 1] ?? 0); | ||
| } |
There was a problem hiding this comment.
computeDiffStats uses a dynamic-programming LCS over all lines, which is O(m*n) time per result. Since deployment.plans.results can return many rows and the UI polls it every 5s, large configs/diffs could cause significant CPU load (and potential DoS if someone can create very large current/proposed). Consider switching to a diff algorithm/library with better typical performance (e.g., Myers line diff) and/or enforcing a hard cap on max lines/bytes (returning null/omitting stats when exceeded).
| status: schema.deploymentPlanTargetResult.status, | ||
| hasChanges: schema.deploymentPlanTargetResult.hasChanges, | ||
| message: schema.deploymentPlanTargetResult.message, | ||
| contentHash: schema.deploymentPlanTargetResult.contentHash, | ||
| current: schema.deploymentPlanTargetResult.current, |
There was a problem hiding this comment.
The results query now selects current/proposed (potentially large TEXT blobs) for every row just to compute line counts. This increases DB I/O and memory/GC pressure even though the response doesn’t return these strings. To reduce load, consider avoiding selecting full contents here (e.g., store precomputed added/removed counts on the result, or fetch contents only for rows with hasChanges === true via a separate query).
Show +added/-removed line counts alongside the "View diff" button in the release target results table, similar to GitHub's diff display.
Closes #1036
Generated with Claude Code