Skip to content

feat(dashboard): monthly-cost + requests-by-provider widgets - #131

Merged
CybotTM merged 3 commits into
mainfrom
feature/dashboard-widgets
Apr 22, 2026
Merged

feat(dashboard): monthly-cost + requests-by-provider widgets#131
CybotTM merged 3 commits into
mainfrom
feature/dashboard-widgets

Conversation

@CybotTM

@CybotTM CybotTM commented Apr 22, 2026

Copy link
Copy Markdown
Member

Summary

Two TYPO3 dashboard widgets surfacing data from the existing tx_nrllm_service_usage table:

  • AI cost this monthNumberWithIconWidget with MonthlyCostDataProvider. Returns USD floored to an integer (glance value, not accounting).
  • AI requests by provider (7d)BarChartWidget with RequestsByProviderDataProvider. Chart.js bar chart of requests per provider over the last 7 days, aggregated across all service types.

Both reuse TYPO3's built-in widget classes; no custom widget PHP needed. Registration lives in Configuration/Services.Dashboard.yaml, imported conditionally from Services.php only when typo3/cms-dashboard is installed. Without that guard, installs without dashboard would fail to compile the container on unresolvable widget class references.

composer.json

typo3/cms-dashboard moved to require-dev (so PHPStan resolves WidgetInterface) and added to a new suggest block for consumers. Classes/Widgets/* excluded from the main Services.yaml autoload glob for the same "only load when dashboard present" reason.

Test plan

  • 12 new unit tests (data-shape helpers extracted as static for unit-testability)
  • PHPStan level 10 clean
  • Architecture (PHPat) + CGL + Rector clean
  • Manual: widgets render when dashboard is installed; extension loads cleanly when dashboard is absent

See ADR-024 for the "two widgets vs. one combined tile" decision and the cost-flooring trade-off.

Register two TYPO3 dashboard widgets sourced from tx_nrllm_service_usage:

- MonthlyCostDataProvider feeds a NumberWithIconWidget with the floored
  USD total for the current calendar month.
- RequestsByProviderDataProvider feeds a BarChartWidget with request
  counts per provider over the last seven days (chart.js format).

Both reuse TYPO3's built-in widget classes; no custom widget PHP needed.
Registration lives in Configuration/Services.Dashboard.yaml, imported
conditionally from Services.php only when typo3/cms-dashboard is present
— installs without dashboard see no container errors and simply lose the
widgets. Classes/Widgets/* excluded from the Services.yaml autoload glob
for the same reason.

composer.json: dashboard moved to require-dev (so PHPStan resolves
WidgetInterface) and added to a new suggest block for consumers.

See ADR-024 for shape rationale (two separate widgets rather than one
combined tile) and the flooring trade-off on the cost value.

Signed-off-by: Sebastian Mendel <github@sebastianmendel.de>
Copilot AI review requested due to automatic review settings April 22, 2026 11:38
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@github-actions github-actions Bot added documentation Improvements or additions to documentation tests Test-related changes configuration Configuration changes labels Apr 22, 2026
@github-actions

github-actions Bot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails
composer/typo3/cms-dashboard >= 13.4, < 14.0 || >= 14.0, < 15.0 UnknownUnknown

Scanned Files

  • composer.json

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Automated approval for maintainer PR

All automated quality gates passed. See SECURITY_CONTROLS.md for compensating controls.

@codecov

codecov Bot commented Apr 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 58.53659% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.49%. Comparing base (b584bcf) to head (ed93f2d).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
...ts/DataProvider/RequestsByProviderDataProvider.php 54.05% 17 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main     #131      +/-   ##
============================================
- Coverage     93.67%   93.49%   -0.18%     
- Complexity     2209     2218       +9     
============================================
  Files            87       89       +2     
  Lines          8109     8150      +41     
============================================
+ Hits           7596     7620      +24     
- Misses          513      530      +17     
Flag Coverage Δ
unit 93.49% <58.53%> (-0.18%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...s/Widgets/DataProvider/MonthlyCostDataProvider.php 100.00% <100.00%> (ø)
...ts/DataProvider/RequestsByProviderDataProvider.php 54.05% <54.05%> (ø)
🚀 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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Signed-off-by: Sebastian Mendel <github@sebastianmendel.de>
github-actions[bot]
github-actions Bot previously approved these changes Apr 22, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Automated approval for maintainer PR

All automated quality gates passed. See SECURITY_CONTROLS.md for compensating controls.

Mutation testing burns ~15 min and emits a signal PR authors can't act
on locally — most mutants live in code the PR didn't touch. Keep it on
main / merge_group / schedule events so the MSI regression bar stays
enforced, but drop it from PR CI. Fuzz tests still run on every event.

Signed-off-by: Sebastian Mendel <github@sebastianmendel.de>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Automated approval for maintainer PR

All automated quality gates passed. See SECURITY_CONTROLS.md for compensating controls.

@CybotTM
CybotTM added this pull request to the merge queue Apr 22, 2026
Merged via the queue into main with commit dc656a5 Apr 22, 2026
42 checks passed
@CybotTM
CybotTM deleted the feature/dashboard-widgets branch April 22, 2026 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci CI/CD changes configuration Configuration changes documentation Improvements or additions to documentation tests Test-related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants