[dashboard-components] Extract view-formatters helper

Daily Dashboard Component Refactorer · pull request · closed

Filter2mode:review mode:live
All recorded Export JSON
github-actions[bot]

published Aug 30, 2026, 4:25 AM · updated Aug 30, 2026, 4:45 AM

Summary

  • extract shared custom-view aggregate formatting into src/view-formatters.js
  • replace the inline metric aggregate branch in src/presenter.js with the shared helper
  • add focused unit coverage for aggregate and numeric formatter edge cases and update the browser harness import rewrites

Duplication evidence

  • pages/dashboard/src/presenter.js:527 previously inlined the full count / distinct-count / sum / mean / min / max aggregate formatting branch inside renderMetricView(...)
  • pages/dashboard/src/presenter.js:636, pages/dashboard/src/presenter.js:683, and pages/dashboard/src/presenter.js:879 also reused the same numeric formatting helpers for chart point construction and text labels
  • this run collapses that repeated helper logic behind one shared presentation-only module for future custom metric and chart slices

Call sites collapsed

  • pages/dashboard/src/presenter.js:527 now calls formatAggregateValue(...) instead of rebuilding aggregate formatting inline
  • pages/dashboard/src/presenter.js chart helpers now import the same shared formatNumber(...) and toNumber(...) functions from src/view-formatters.js
  • pages/dashboard/test/e2e/smoke.spec.js browser harness now rewrites the new helper import so the same presenter behavior is exercised in browser tests

Tests added

  • pages/dashboard/test/unit/view-formatters.test.js
    • aggregate formatting for count, distinct-count, sum, mean, min, max, and default field access
    • empty, missing-field, and non-numeric inputs
    • deterministic shared numeric helper output

Behavior preservation proof

  • preserved existing DOM text, class names, and custom-view metric/chart behavior by extracting only formatting logic
  • compared the committed change scope with git diff --stat HEAD~1 HEAD and confirmed the affected files are limited to the presenter helper extraction, its tests, the Playwright module-rewrite harness, and PLAN.md
  • reran the existing presenter unit suite and browser suite after wiring the new module into the Playwright data-URL harness

Quality gates

Ran from pages/dashboard/:

  • npm install
  • npm run build
  • npm run typecheck
  • npm run lint
  • npm test
  • npx playwright test --config=playwright.config.mjs

Blockers

  • None

Next candidates

  • extract the repeated custom-view state-message plus affected-source/context composition in src/presenter.js
  • extract shared link-cell composition across custom metric and custom table views
  • extract shared chart-series grouping and textual legend helpers if upcoming feature slices add more chart variants

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • mtalk.google.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "mtalk.google.com"

See Network Configuration for more information.

Generated by ♻️ Daily Dashboard Component Refactorer · pi · gpt54 · 37.8 AIC · ⌖ 6.08 AIC · ⊞ 5.4K ·