Skip to content

feat: celebrate size decreases#2620

Merged
43081j merged 3 commits intomainfrom
jg/ultimate-shrinkage
Apr 25, 2026
Merged

feat: celebrate size decreases#2620
43081j merged 3 commits intomainfrom
jg/ultimate-shrinkage

Conversation

@43081j
Copy link
Copy Markdown
Contributor

@43081j 43081j commented Apr 23, 2026

🔗 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

image

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
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Apr 23, 2026 6:40pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Apr 23, 2026 6:40pm
npmx-lunaria Ignored Ignored Apr 23, 2026 6:40pm

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 23, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3fc5cd1e-69e9-40bb-bf32-4afa40a877fa

📥 Commits

Reviewing files that changed from the base of the PR and between cdf7245 and 5280447.

📒 Files selected for processing (1)
  • test/nuxt/a11y.spec.ts

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added package size and dependency decrease notifications with percent, byte and count reductions; UI now shows increase or decrease-specific messages and a new decrease component where applicable.
  • Documentation

    • Added localisation entries and schema to support decrease messaging.
  • Tests

    • Expanded unit and accessibility tests to cover decrease scenarios, the new direction field and regressions for increases.

Walkthrough

Adds directional install-size diff support and a new SizeDecrease component. The composable now returns diffs with a direction ('increase' | 'decrease'); package page renders increase/decrease components accordingly. New i18n entries and schema plus updated tests (unit and a11y) for decrease handling were added.

Changes

Cohort / File(s) Summary
Components & Page
app/components/Package/SizeDecrease.vue, app/pages/package/[[org]]/[name].vue
New SizeDecrease component implemented; package page rendering switched to direction-aware branches (direction === 'increase'PackageSizeIncrease, direction === 'decrease'SizeDecrease).
Composable & Types
app/composables/useInstallSizeDiff.ts
Composable expanded to detect both increases and decreases, adds `direction: 'increase'
Internationalisation
i18n/locales/en.json, i18n/schema.json
Adds package.size_decrease translation templates for size-only, deps-only, and combined decrease messages; updates JSON Schema to require title_size, title_deps, title_both, size, and deps keys.
Tests — Composable
test/nuxt/composables/use-install-size-diff.spec.ts
Expanded unit tests to assert diff.value.direction for increases and decreases, cover decrease-specific thresholds and edge cases, and preserve existing increase behaviour.
Tests — Accessibility
test/nuxt/a11y.spec.ts
Adds SizeDecrease to a11y suite with three decrease scenarios (axe checks); updates SizeIncrease fixtures to include direction: 'increase' in props.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: celebrate size decreases' accurately and directly reflects the main change: introducing celebration messaging for package size/dependency decreases beyond configured thresholds.
Description check ✅ Passed The description is clearly related to the changeset, providing context, rationale, and concrete examples of when the celebration messaging appears versus when it does not.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jg/ultimate-shrinkage

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.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 23, 2026

Lunaria Status Overview

🌕 This pull request will trigger status changes.

Learn more

By default, every PR changing files present in the Lunaria configuration's files property will be considered and trigger status changes accordingly.

You can change this by adding one of the keywords present in the ignoreKeywords property in your Lunaria configuration file in the PR's title (ignoring all files) or by including a tracker directive in the merged commit's description.

Tracked Files

File Note
i18n/locales/en.json Source changed, localizations will be marked as outdated.
Warnings reference
Icon Description
🔄️ The source for this localization has been updated since the creation of this pull request, make sure all changes in the source have been applied.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

❌ Patch coverage is 93.93939% with 2 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
app/pages/package/[[org]]/[name].vue 0.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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 | 🟡 Minor

Edge case: zero baseline can incorrectly allow a “decrease” celebration.

When previous.totalSize is 0, Line 94 sets sizeRatio to 0, 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

📥 Commits

Reviewing files that changed from the base of the PR and between 3c3bfeb and af81566.

📒 Files selected for processing (5)
  • app/components/Package/SizeDecrease.vue
  • app/composables/useInstallSizeDiff.ts
  • app/pages/package/[[org]]/[name].vue
  • i18n/locales/en.json
  • i18n/schema.json

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 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({...}) on diff.value, which catches unexpected field drift (e.g. a stale depDiff sign or a missing direction). Here you only check three fields, so a regression to depDiff, currentDeps, or previousDeps (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 === null leaves 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

📥 Commits

Reviewing files that changed from the base of the PR and between af81566 and cdf7245.

📒 Files selected for processing (1)
  • test/nuxt/composables/use-install-size-diff.spec.ts

@43081j 43081j added this pull request to the merge queue Apr 25, 2026
Merged via the queue into main with commit ebcfc01 Apr 25, 2026
24 checks passed
@43081j 43081j deleted the jg/ultimate-shrinkage branch April 25, 2026 10:57
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