Conversation
This adds a small message when a package decreases in size or dependency count beyond our thresholds, only if it had no increases. e.g. +1 deps, -200KB = no celebration, +0 deps, -200KB = celebration, etc
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughAdds directional install-size diff support and a new SizeDecrease component. The composable now returns diffs with a Changes
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
Lunaria Status Overview🌕 This pull request will trigger status changes. Learn moreBy default, every PR changing files present in the Lunaria configuration's You can change this by adding one of the keywords present in the Tracked Files
Warnings reference
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
app/composables/useInstallSizeDiff.ts (1)
93-110:⚠️ Potential issue | 🟡 MinorEdge case: zero baseline can incorrectly allow a “decrease” celebration.
When
previous.totalSizeis0, Line 94 setssizeRatioto0, which can hide a real size increase. In that case, Line 103-Line 104 may still classify the diff as a decrease if deps dropped enough.💡 Suggested fix
- const sizeRatio = - previous.totalSize > 0 ? (current.totalSize - previous.totalSize) / previous.totalSize : 0 + const sizeDelta = current.totalSize - previous.totalSize + const sizeRatio = previous.totalSize > 0 ? sizeDelta / previous.totalSize : 0 const depDiff = current.dependencyCount - previous.dependencyCount @@ - const isIncrease = increaseSize || increaseDeps - const isDecrease = - !isIncrease && sizeRatio <= 0 && depDiff <= 0 && (decreaseSize || decreaseDeps) + const isIncrease = increaseSize || increaseDeps + const hasAnyIncrease = sizeDelta > 0 || depDiff > 0 + const isDecrease = !hasAnyIncrease && (decreaseSize || decreaseDeps) @@ - sizeIncrease: current.totalSize - previous.totalSize, + sizeIncrease: sizeDelta,🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/composables/useInstallSizeDiff.ts` around lines 93 - 110, The code currently sets sizeRatio = 0 when previous.totalSize === 0 which can mask real increases and allow a false "decrease" classification; update the logic around sizeRatio, increaseSize and decreaseSize so the zero baseline is handled explicitly: compute sizeRatio only when previous.totalSize > 0, and when previous.totalSize === 0 set increaseSize = current.totalSize > 0 and always set decreaseSize = false (so a drop in deps alone cannot produce a "decrease" celebration when there was no prior size); ensure isDecrease uses this new decreaseSize behavior (references: sizeRatio, previous.totalSize, increaseSize, decreaseSize, isDecrease).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@app/composables/useInstallSizeDiff.ts`:
- Around line 93-110: The code currently sets sizeRatio = 0 when
previous.totalSize === 0 which can mask real increases and allow a false
"decrease" classification; update the logic around sizeRatio, increaseSize and
decreaseSize so the zero baseline is handled explicitly: compute sizeRatio only
when previous.totalSize > 0, and when previous.totalSize === 0 set increaseSize
= current.totalSize > 0 and always set decreaseSize = false (so a drop in deps
alone cannot produce a "decrease" celebration when there was no prior size);
ensure isDecrease uses this new decreaseSize behavior (references: sizeRatio,
previous.totalSize, increaseSize, decreaseSize, isDecrease).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: b76d888a-d379-4185-9399-1bb735ef9fdc
📒 Files selected for processing (5)
app/components/Package/SizeDecrease.vueapp/composables/useInstallSizeDiff.tsapp/pages/package/[[org]]/[name].vuei18n/locales/en.jsoni18n/schema.json
There was a problem hiding this comment.
🧹 Nitpick comments (3)
test/nuxt/composables/use-install-size-diff.spec.ts (3)
368-393: Consider tightening assertions to match the style of the other cases.The other increase/decrease tests in this file use a full
toEqual({...})ondiff.value, which catches unexpected field drift (e.g. a staledepDiffsign or a missingdirection). Here you only check three fields, so a regression todepDiff,currentDeps, orpreviousDeps(which flip sign in this scenario) wouldn't be caught. Consider extending to a full object assertion for consistency and stronger coverage.♻️ Example
- expect(diff.value?.direction).toBe('increase') - expect(diff.value?.sizeThresholdExceeded).toBe(true) - expect(diff.value?.depThresholdExceeded).toBe(false) + expect(diff.value).toEqual({ + direction: 'increase', + comparisonVersion: '1.0.0', + sizeRatio: 0.4, + sizeIncrease: 2000, + currentSize: 7000, + previousSize: 5000, + depDiff: -7, + currentDeps: 3, + previousDeps: 10, + sizeThresholdExceeded: true, + depThresholdExceeded: false, + })🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@test/nuxt/composables/use-install-size-diff.spec.ts` around lines 368 - 393, The test "reports increases even when the other metric decreased" only asserts three fields on diff.value which can miss regressions in other fields; update the assertions for useInstallSizeDiff's result (diff.value) to a full toEqual({...}) check matching all expected properties (direction, sizeDiff, depDiff, currentSize, previousSize, currentDeps, previousDeps, sizeThresholdExceeded, depThresholdExceeded, etc.) so the test mirrors the style of the other increase/decrease specs and will catch any unexpected field drift.
343-366: Consider making the "increase blocks celebration" intent more explicit.This case has size +10% (below the 25% increase threshold) and deps -7 (above the decrease threshold). Asserting only
diff.value === nullleaves ambiguity about why it's null — is it because any increase (even sub-threshold) suppresses a decrease diff, or because the net outcome isn't classifiable? A short inline comment clarifying the rule ("any size increase, even below threshold, prevents a decrease celebration") would make this test self-documenting and guard against regressions that silently change the semantics.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@test/nuxt/composables/use-install-size-diff.spec.ts` around lines 343 - 366, Update the test for useInstallSizeDiff to make the "increase blocks celebration" intent explicit: in the it('does not celebrate when any metric increased'...) case, add a short inline comment explaining that any increase in totalSize (even if below the 25% threshold) should suppress a dependency-decrease celebration, and optionally add an assertion that the fetched previousInstallSize has a smaller totalSize but larger dependencyCount to document inputs (e.g., assert previous.totalSize < current.totalSize and previous.dependencyCount > current.dependencyCount) before asserting diff.value === null so the reason for null is unambiguous; reference symbols: useInstallSizeDiff, diff.value, fetchSpy, current.
395-418: Good guard test — consider also covering the exact-threshold boundary.This verifies a decrease of 10% / 2 deps (below threshold) yields
null. A companion case exercising the threshold boundary itself (e.g. exactly −25% size or exactly −5 deps) would lock in whether the comparison is>or>=and prevent silent off-by-one regressions. Not a blocker.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@test/nuxt/composables/use-install-size-diff.spec.ts` around lines 395 - 418, Add a boundary test (in test/nuxt/composables/use-install-size-diff.spec.ts) that mirrors the existing case but sets the previous install size and dependency counts exactly at the decrease thresholds (e.g., size drop exactly 25% and dependency drop exactly 5) using createInstallSize/createPackage and fetchSpy, call useInstallSizeDiff('pkg-small-wins', '1.1.0', pkg, current), await vi.waitFor(() => expect(fetchSpy).toHaveBeenCalled()), and then assert the explicit expected behavior for diff.value (either expect(diff.value).toBeNull() or expect(diff.value).not.toBeNull()) to lock in whether the comparison in useInstallSizeDiff is inclusive or exclusive of the threshold.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@test/nuxt/composables/use-install-size-diff.spec.ts`:
- Around line 368-393: The test "reports increases even when the other metric
decreased" only asserts three fields on diff.value which can miss regressions in
other fields; update the assertions for useInstallSizeDiff's result (diff.value)
to a full toEqual({...}) check matching all expected properties (direction,
sizeDiff, depDiff, currentSize, previousSize, currentDeps, previousDeps,
sizeThresholdExceeded, depThresholdExceeded, etc.) so the test mirrors the style
of the other increase/decrease specs and will catch any unexpected field drift.
- Around line 343-366: Update the test for useInstallSizeDiff to make the
"increase blocks celebration" intent explicit: in the it('does not celebrate
when any metric increased'...) case, add a short inline comment explaining that
any increase in totalSize (even if below the 25% threshold) should suppress a
dependency-decrease celebration, and optionally add an assertion that the
fetched previousInstallSize has a smaller totalSize but larger dependencyCount
to document inputs (e.g., assert previous.totalSize < current.totalSize and
previous.dependencyCount > current.dependencyCount) before asserting diff.value
=== null so the reason for null is unambiguous; reference symbols:
useInstallSizeDiff, diff.value, fetchSpy, current.
- Around line 395-418: Add a boundary test (in
test/nuxt/composables/use-install-size-diff.spec.ts) that mirrors the existing
case but sets the previous install size and dependency counts exactly at the
decrease thresholds (e.g., size drop exactly 25% and dependency drop exactly 5)
using createInstallSize/createPackage and fetchSpy, call
useInstallSizeDiff('pkg-small-wins', '1.1.0', pkg, current), await vi.waitFor(()
=> expect(fetchSpy).toHaveBeenCalled()), and then assert the explicit expected
behavior for diff.value (either expect(diff.value).toBeNull() or
expect(diff.value).not.toBeNull()) to lock in whether the comparison in
useInstallSizeDiff is inclusive or exclusive of the threshold.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 5f9d3406-7823-438f-b79d-3096902e968a
📒 Files selected for processing (1)
test/nuxt/composables/use-install-size-diff.spec.ts
🔗 Linked issue
N/A
🧭 Context
We should celebrate wins as well as show negatives.
📚 Description
This adds a small message when a package decreases in size or dependency
count beyond our thresholds, only if it had no increases.
e.g. +1 deps, -200KB = no celebration, +0 deps, -200KB = celebration,
etc