Skip to content

feat(billing): sidenav compute gauge above sign-out row (meter mode)#4126

Merged
PierreBrisorgueil merged 1 commit into
masterfrom
feat-sidenav-compute-gauge
May 11, 2026
Merged

feat(billing): sidenav compute gauge above sign-out row (meter mode)#4126
PierreBrisorgueil merged 1 commit into
masterfrom
feat-sidenav-compute-gauge

Conversation

@PierreBrisorgueil
Copy link
Copy Markdown
Collaborator

Summary

  • Add `BillingComputeGaugeComponent` in `src/modules/billing/components/` — compact `meterUsed / meterQuota` bar with color thresholds (primary < 80%, warning ≥ 80%, error ≥ 100%).
  • Hover OR keyboard focus reveals detail: `{remaining} remaining · resets {date}`.
  • Gated on `serverConfig.billing.meterMode === true` + `isLoggedIn` + `usageMeter` non-null; dormant in non-billing apps.
  • Mount in `core.navigation.component.vue` `#append` slot, above the Sign out divider.
  • 11 unit tests: visibility gate (3 conditions), render, 3 color thresholds, division-by-zero, clamped remaining (used > quota), null reset date, valid reset date.

Boundary note

The `core.navigation.component.vue` (core module) imports `BillingComputeGaugeComponent` (billing module). This crosses the core/billing boundary the same way `user.view.vue` already imports `BillingSubscriptionsComponent`. Billing is a devkit core dependency (not optional) — all downstream projects include it. A consolidated cross-module refactor is tracked as tech debt; this PR does not introduce a new pattern.

Test plan

  • `npm run test:unit -- billing.computeGauge` → 11/11 pass
  • `npm run test:unit -- src/modules/billing` → 492/492 pass
  • `npm run test:unit -- src/modules/core` → 111/111 pass
  • Visual: sidenav above sign-out shows gauge for meter-mode users, hidden for others

Add BillingComputeGaugeComponent in billing/components showing meterUsed/meterQuota
with a color-coded progress bar (primary < 80 %, warning >= 80 %, error >= 100 %).
Hover reveals remaining units + reset date. Gated on meterMode + isLoggedIn so
non-billing apps stay dormant. Mounted in core.navigation.component.vue above
the Sign out row, following the same cross-module import pattern as
user.view.vue importing BillingSubscriptionsComponent. 10 unit tests added.
Copilot AI review requested due to automatic review settings May 11, 2026 19:36
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 11, 2026

Warning

Rate limit exceeded

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

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ 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: ASSERTIVE

Plan: Pro

Run ID: 07d439f3-bb4c-4c68-acdb-f2c31e08ee10

📥 Commits

Reviewing files that changed from the base of the PR and between 5a3425a and 040b124.

📒 Files selected for processing (3)
  • src/modules/billing/components/billing.computeGauge.component.vue
  • src/modules/billing/tests/billing.computeGauge.component.unit.tests.js
  • src/modules/core/components/core.navigation.component.vue
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat-sidenav-compute-gauge

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.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.54%. Comparing base (5a3425a) to head (040b124).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4126   +/-   ##
=======================================
  Coverage   99.54%   99.54%           
=======================================
  Files          31       31           
  Lines        1089     1089           
  Branches      302      302           
=======================================
  Hits         1084     1084           
  Misses          5        5           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown

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

Adds a compact “compute usage” gauge to the sidenav’s bottom section (above Sign out) for meter-mode billing apps, plus a new billing component and unit tests to validate visibility and display behavior.

Changes:

  • Mount a billing compute gauge in the core navigation drawer append slot.
  • Add BillingComputeGaugeComponent to render meterUsed / meterQuota with threshold-based coloring and an expanded detail line.
  • Add unit tests for visibility gating, thresholds, and edge cases.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
src/modules/core/components/core.navigation.component.vue Mounts the compute gauge in the sidenav and registers the billing component.
src/modules/billing/components/billing.computeGauge.component.vue Implements the compact meter gauge UI + computed state (visibility, percent, color, reset date).
src/modules/billing/tests/billing.computeGauge.component.unit.tests.js Adds unit tests covering gating, rendering, thresholds, and edge cases.

</v-list>
</template>
<!-- Compute usage gauge — visible only in meter-mode apps -->
<billingComputeGauge />
Comment on lines +6 to +16
tabindex="0"
role="region"
aria-label="Compute usage"
@mouseenter="isExpanded = true"
@mouseleave="isExpanded = false"
@focus="isExpanded = true"
@blur="isExpanded = false"
>
<div class="d-flex align-center justify-space-between mb-1">
<span id="compute-gauge-label" class="text-label-small text-medium-emphasis">Compute</span>
<span class="text-label-small font-weight-medium">{{ meterUsed }} / {{ meterQuota }}</span>
Comment on lines +73 to +88
* @desc Progress as a 0–100 percentage. Guards against division by zero when
* meterQuota is 0 (e.g. free plan before any grant lands).
* @returns {number}
*/
const progressPercent = computed(() => {
const quota = meterQuota.value;
if (!quota) return 0;
return Math.min(100, Math.round((meterUsed.value / quota) * 100));
});

/**
* @desc Bar color — primary below 80 %, warning at 80–99 %, error at 100 %+.
* @returns {'primary'|'warning'|'error'}
*/
const barColor = computed(() => {
const pct = progressPercent.value;
Comment on lines +95 to +103
* @desc Human-readable reset date derived from the current meter week.
* Falls back to an em-dash when the billing store has no reset date yet.
* @returns {string}
*/
const resetDate = computed(() => {
const d = billingStore.usageMeter?.weekResetAt;
if (!d) return '—';
return new Date(d).toLocaleDateString(undefined, { month: 'short', day: 'numeric' });
});
const wrapper = mountComponent();
expect(wrapper.vm.barColor).toBe('primary');
});

@PierreBrisorgueil PierreBrisorgueil merged commit fe1497f into master May 11, 2026
10 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.

2 participants