Skip to content

fix(ui): format decimal values in memory diagnostics panel - #2201

Merged
zerob13 merged 2 commits into
ThinkInAIXYZ:devfrom
Dorence:fix/memory-diagnostics-number-formatting
Aug 21, 2026
Merged

fix(ui): format decimal values in memory diagnostics panel#2201
zerob13 merged 2 commits into
ThinkInAIXYZ:devfrom
Dorence:fix/memory-diagnostics-number-formatting

Conversation

@Dorence

@Dorence Dorence commented Aug 21, 2026

Copy link
Copy Markdown
Contributor
image

Avoid directly display numbers in memory diagnostics panel

Summary by CodeRabbit

  • Bug Fixes
    • Improved formatting for archive age, decay scores, and recall latency values.
    • Added locale-aware precision for diagnostic metrics, including fractional values.
    • Ensured percentile latency and archive-candidate metrics display consistently.
    • Preserved clear display of unavailable latency values and non-finite diagnostic values.

@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 10a0bf8b-3410-4da7-911a-97a2870c1d98

📥 Commits

Reviewing files that changed from the base of the PR and between 5f7d4f5 and 2e2d15d.

📒 Files selected for processing (4)
  • src/renderer/settings/components/MemoryDiagnosticsPanel.vue
  • src/renderer/settings/components/MemoryLifecyclePanel.vue
  • src/renderer/settings/lib/useMemoryNumberFormatters.ts
  • test/renderer/components/MemoryDiagnosticsPanel.test.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

Memory settings panels now share locale-aware decimal and day formatting. Diagnostics latency preserves em-dash fallbacks and displays non-finite values unchanged. Tests verify Infinity rendering and archive-candidate formatting.

Changes

Memory formatting

Layer / File(s) Summary
Shared number formatter contract
src/renderer/settings/lib/useMemoryNumberFormatters.ts
Adds locale-aware decimal and day formatters that preserve non-finite values as strings.
Memory panel formatting integration
src/renderer/settings/components/MemoryLifecyclePanel.vue, src/renderer/settings/components/MemoryDiagnosticsPanel.vue
Replaces local formatters with shared utilities for scores, days, archive age, and recall latency. Existing null and em-dash fallbacks remain. The archive-candidates test identifier remains.
Diagnostics rendering validation
test/renderer/components/MemoryDiagnosticsPanel.test.ts
Uses positive infinity for p95 latency and verifies that the rendered value is Infinity while retaining other formatting assertions.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 2e2d1

This localized formatting change leaves no actionable merge-blocking risk; it is merge-ready after normal checks and review.

Suggested reviewers: yyhhyyyyyy

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (2 skipped: 2 unsupported.) Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: formatting decimal values in the memory diagnostics panel.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@zerob13 zerob13 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review — format decimal values in memory diagnostics panel

Thanks for the fix. Using Intl.NumberFormat for locale-aware formatting is the right direction and consistent with the sibling MemoryLifecyclePanel.vue.

🔴 Must fix

1. Duplicated formatters with MemoryLifecyclePanel.vue

The newly added decimalFormatter, dayFormatter computeds and formatScore / formatDays functions are byte-for-byte identical to the ones already in MemoryLifecyclePanel.vue (L163–176, L257–269):

definition MemoryLifecyclePanel.vue MemoryDiagnosticsPanel.vue (this PR)
decimalFormatter L163–168 L345–351
dayFormatter L170–175 L352–358
formatScore L257–259 L489–491
formatDays L267–269 L493–495

Both components live in the same directory and operate on the same memory lifecycle/diagnostics domain. Please extract a shared composable (e.g. useMemoryNumberFormatters) into settings/lib/useMemoryInlineFeedback.ts there is a good precedent — and have both panels consume it. Otherwise the two copies will silently drift as formatting requirements evolve.

🟡 Suggestions (nits)

2. formatOptionalMilliseconds is misnamed

The function delegates to decimalFormatter (a generic decimal formatter), so "Milliseconds" in the name is misleading — nothing about it is millisecond-specific. The sibling component calls its nullable variant formatOptionalScore. Consider a domain-agnostic name like formatOptionalDecimal, or align with the sibling's naming once the shared composable lands.

3. Dropped Number.isFinite guard

The previous formatNumber guarded against NaN / Infinity and fell back to String(value). The new helpers pass straight to Intl.NumberFormat.format, so Infinity now renders as instead of Infinity. Realistic data is unlikely to hit this, but when extracting the shared composable, consider restoring a finite-check guard for robustness.

✅ Looks good

  • Intl.NumberFormat over toFixed — correct, locale-aware, consistent with MemoryLifecyclePanel / OcrSettings / DashboardSettings.
  • computed-cached formatter instances that rebuild on locale change — correct.
  • Test coverage for float truncation (685.716, 0.123, 12.3) and the fallback — solid, no over-testing.
  • Scope is tight and focused; no breaking changes.

Requested changes center on the duplication — once the shared composable is extracted and both panels consume it, this is good to go.

@zerob13
zerob13 merged commit 13a4c21 into ThinkInAIXYZ:dev Aug 21, 2026
12 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