Skip to content

feat: add benchmark diagnostics dashboard#604

Merged
jtn0123 merged 2 commits into
mainfrom
codex/benchmark-dashboard
Apr 28, 2026
Merged

feat: add benchmark diagnostics dashboard#604
jtn0123 merged 2 commits into
mainfrom
codex/benchmark-dashboard

Conversation

@jtn0123
Copy link
Copy Markdown
Owner

@jtn0123 jtn0123 commented Apr 28, 2026

Summary

  • Adds a selectable benchmark diagnostics dashboard in Settings with p50/p95 timing, per-plugin timing, recent refreshes, and stage drill-downs.
  • Registers benchmark refresh/stage APIs in response schemas and OpenAPI so frontend-consumed routes stay covered by contract checks.
  • Hardens benchmark pagination parsing and documents the runtime dashboard.

Base Branch Confirmation

  • This PR is based on origin/main (not a stale long-lived branch)
  • I rebased/merged latest origin/main before opening

Parent-Fork Sync Checklist

  • If this PR syncs from fatihak/InkyPi, changes were cherry-picked by feature
  • Relevant upstream behavior differences were documented in PR description
  • Plugin/add-to-playlist/update flows were smoke-tested after sync

Compatibility/Release Checklist

  • pytest relevant suites pass locally
  • No breaking API route/path changes
  • Error responses follow JSON contract (success:false,error,code,details,request_id)
  • Docs updated for new flags/endpoints/UI
  • Frontend changes (src/static/**, src/templates/**): ran browser tests (SKIP_BROWSER=0 .venv/bin/python -m pytest tests/) and all passed

Testing

  • PYTHONPATH=src pytest -q tests/unit/test_settings_blueprint.py::TestBenchmarkAPIs tests/contract/test_response_shapes.py::test_benchmarks_summary_shape tests/contract/test_response_shapes.py::test_benchmarks_plugins_shape tests/contract/test_response_shapes.py::test_benchmarks_refreshes_shape tests/contract/test_response_shapes.py::test_benchmarks_stages_shape tests/contract/test_frontend_api_contract_coverage.py tests/static/test_benchmark_display.py tests/integration/test_observability_api.py
  • python3 -m ruff check src/blueprints/settings/_benchmarks.py src/schemas/responses.py src/schemas/endpoint_map.py tests/contract/test_response_shapes.py tests/unit/test_settings_blueprint.py tests/static/test_benchmark_display.py
  • python3 -m black --check src/blueprints/settings/_benchmarks.py src/schemas/responses.py src/schemas/endpoint_map.py tests/contract/test_response_shapes.py tests/unit/test_settings_blueprint.py tests/static/test_benchmark_display.py
  • PYTHONPATH=src python3 -m mypy src/blueprints/settings/_benchmarks.py src/schemas/responses.py src/schemas/endpoint_map.py
  • node --check src/static/scripts/settings/diagnostics.js
  • python3 -m json.tool src/static/openapi.json >/tmp/inkypi-openapi-check.json
  • python3 scripts/build_css.py
  • bash scripts/lint.sh

Summary by CodeRabbit

  • New Features

    • Benchmarking dashboard now includes time window filtering, refresh history with pagination, per-stage timing drill-down, and per-plugin average timings.
    • Added /api/benchmarks/refreshes and /api/benchmarks/stages endpoints for querying benchmark data.
  • Documentation

    • Updated benchmarking documentation with dashboard UI behavior and API endpoint specifications.
  • Bug Fixes

    • Improved query parameter validation for safer limit and cursor parsing.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 28, 2026

Warning

Rate limit exceeded

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

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 30523e14-620b-4478-8fbc-7b8c2c42c31b

📥 Commits

Reviewing files that changed from the base of the PR and between 4d430a2 and 38b50bd.

📒 Files selected for processing (2)
  • src/static/scripts/settings/diagnostics.js
  • tests/static/test_benchmark_display.py
📝 Walkthrough

Walkthrough

Adds two new benchmarking API endpoints (/api/benchmarks/refreshes and /api/benchmarks/stages) to expose runtime benchmark data, with query parameter parsing and validation. Includes response schema definitions, OpenAPI documentation, and comprehensive frontend UI components that support time-window selection, pagination, and stage drill-down viewing in the diagnostics dashboard. Covers changes with tests validating contract compliance and behavior.

Changes

Cohort / File(s) Summary
Backend API Implementation
src/blueprints/settings/_benchmarks.py
Adds query parameter helpers: limit clamped to 1–200 (default 50), cursor validated as positive integer. Removes inline int() casting, delegating to typed helpers while preserving conditional if cursor: branch logic.
API Schemas & Documentation
src/schemas/responses.py, src/schemas/endpoint_map.py, src/static/openapi.json
Introduces four new TypedDict response types (BenchmarksRefreshEntry, BenchmarksRefreshesResponse, BenchmarksStageEntry, BenchmarksStagesResponse) with envelope structure (success, request_id, items, optional next_cursor). Registers schema mappings and documents two new Health-tagged GET endpoints with pagination and stage drill-down parameters in OpenAPI.
Frontend UI & Styling
src/static/scripts/settings/diagnostics.js, src/templates/settings.html, src/static/styles/main.css, src/static/styles/partials/_settings-console.css
Adds benchmark control row with time-window select (24h default), three result panels (timing summary, per-plugin averages, refresh list with View actions, and stage details). Implements table builders, fetch logic using selected window, empty-state handling, and stage-loading flow. Introduces CSS classes for control layout, window select sizing, refresh table dimensions, and stage button styling (border, hover/focus accent, disabled opacity).
Documentation
docs/benchmarking.md
Describes dashboard UI behavior fetching from runtime benchmark database via /api/benchmarks/* endpoints, enumerating views (stage timing for window, per-plugin averages, recent refreshes, stage drill-down). Removes "next" roadmap item for endpoints/dashboard as they are now documented and implemented.
Test Coverage
tests/contract/test_frontend_api_contract_coverage.py, tests/contract/test_response_shapes.py, tests/static/test_benchmark_display.py, tests/unit/test_settings_blueprint.py
Expands contract tests to cover two new endpoints in Flask routes and ENDPOINT_SCHEMAS. Adds SQLite-backed response-shape contract tests seeding refresh_events and stage_events, validating JSON envelope structure and success flag. Validates JavaScript function presence (buildRefreshesTable, buildStagesTable) and HTML element IDs (benchmarkWindow, benchRefreshes, benchStages). Includes unit test for invalid query parameters (non-integer cursor, invalid limit).

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Poem

🐰 Hop along, dear benchmark hops,
Time windows now from bottom to tops!
Refresh your data, stage by stage,
Pagination writes a wondrous page,
The dashboard dances, no more delays—
Performance shines in diagnostic ways!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 3.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title 'feat: add benchmark diagnostics dashboard' clearly summarizes the main change, uses the proper Conventional Commits format, and is specific enough for version bumping and history scanning.
Description check ✅ Passed The description follows the template with completed summary, base branch confirmation, parent-fork sync checklist, and detailed compatibility/release verification with specific testing commands provided.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/benchmark-dashboard

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 28, 2026

Memory diff vs base

Metric Base PR Delta
Peak RSS 29.04 MB 28.99 MB -52.0 KB
sys.modules count 592 592 0
Top 20 startup allocators
# Location Base PR Delta
1 <frozen importlib._bootstrap_external>:757 7.56 MB 4.46 MB -3.10 MB ⚠️
2 parsers/lalr_parser_state.py:105 4.00 MB 1.00 MB -3.00 MB ⚠️
3 <frozen importlib._bootstrap>:488 5.63 MB 7.93 MB +2.30 MB ⚠️
4 python3.12/functools.py:58 0 B 2.00 MB +2.00 MB ⚠️
5 lark/lexer.py:215 3.00 MB 1.00 MB -2.00 MB ⚠️
6 lark/visitors.py:180 1.00 MB 3.00 MB +2.00 MB ⚠️
7 attr/_make.py:226 0 B 1.03 MB +1.03 MB ⚠️
8 parsers/lalr_analysis.py:299 1.00 MB 0 B -1.00 MB ⚠️
9 <frozen importlib._bootstrap_external>:1577 1.00 MB 0 B -1.00 MB ⚠️
10 python3.12/ast.py:52 1.00 MB 0 B -1.00 MB ⚠️
11 arrow/locales.py:3019 1.00 MB 0 B -1.00 MB ⚠️
12 lark/load_grammar.py:559 1.00 MB 0 B -1.00 MB ⚠️
13 <string>:1 1.00 MB 0 B -1.00 MB ⚠️
14 sansio/response.py:476 0 B 1.00 MB +1.00 MB ⚠️
15 parsers/lalr_analysis.py:137 0 B 1.00 MB +1.00 MB ⚠️
16 flask/sessions.py:323 0 B 1.00 MB +1.00 MB ⚠️
17 lark/grammar.py:115 0 B 1.00 MB +1.00 MB ⚠️
18 lark/load_grammar.py:537 0 B 1.00 MB +1.00 MB ⚠️
19 lark/load_grammar.py:914 0 B 1.00 MB +1.00 MB ⚠️
20 werkzeug/http.py:1200 0 B 1.00 MB +1.00 MB ⚠️

JTN-610 · backend=base:memray, pr:memray · informational only, does not block merge. Hard RSS budgets are enforced separately by JTN-608.

Copy link
Copy Markdown

@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.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/static/scripts/settings/diagnostics.js`:
- Around line 349-405: refreshBenchmarks can complete out-of-order and overwrite
the UI for a newer benchmark window selection; modify refreshBenchmarks to
ignore stale responses by associating each invocation with a unique token (e.g.,
incrementing requestId or an AbortController) and checking that token before
applying results (use getBenchmarkWindow() at start to capture the intended
window and compare before render) or abort previous fetches when starting a new
call; apply the same pattern to the other similar function referenced around
lines 545-547 so only the latest request updates the DOM (reference
refreshBenchmarks, getBenchmarkWindow, renderPanel, setPanelFailure).
- Around line 307-311: The benchStages panel can hold a stale drill-down
selection when the refresh list changes; update the code that toggles benchmark
panels (e.g., setBenchmarkPanelsLoading) and the refresh-list update path (the
block around lines 380-398) to explicitly reset/clear the benchStages state
whenever the refresh list is reloaded or becomes empty—call the UI helper that
clears selections or resets panel content for "benchStages" (e.g.,
ui.clearPanel?, ui.resetPanel?, or ui.setPanelContent with an empty state) right
after updating benchSummary/benchPlugins/benchRefreshes so the stage drill-down
is cleared whenever the refresh window or rows change.
- Around line 329-340: The fetch handler that populates the stage panel treats
any JSON body as success; change the logic after calling
fetch(`/api/benchmarks/stages?...`) to check resp.ok and handle non-OK responses
by reading the JSON error (or resp.statusText) and displaying a clear failure
message in the same panel instead of calling buildStagesTable; specifically,
after const resp = await fetch(...) and const data = await resp.json(), if
(!resp.ok) set panel.textContent (or append an error div) to include the
returned error message/status and return early so
buildStagesTable(Array.isArray(data?.items) ? data.items : []) is not called for
error responses.
- Around line 353-388: The fetch results for summaryResp, pluginsResp, and
refreshesResp are treated as successful even when the server returns errors,
causing 404/500 pages to appear as an empty benchmark state; update the code
after the Promise.all to check each response.ok, parse any error JSON (or text)
from summaryResp, pluginsResp, and refreshesResp when not ok, and render an
error panel via renderPanel("benchSummary"/"benchPlugins"/"benchRefreshes") with
the extracted error message instead of collapsing into the empty-state path;
keep the existing logic that uses summary, plugins, refreshes when responses are
ok (variables summary, plugins, refreshes) and only fall back to the empty
message when all three are OK but contain no data.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: c4c1fcb5-2ea5-4594-8f52-8413cb3cb7b8

📥 Commits

Reviewing files that changed from the base of the PR and between 6c3a318 and 4d430a2.

📒 Files selected for processing (13)
  • docs/benchmarking.md
  • src/blueprints/settings/_benchmarks.py
  • src/schemas/endpoint_map.py
  • src/schemas/responses.py
  • src/static/openapi.json
  • src/static/scripts/settings/diagnostics.js
  • src/static/styles/main.css
  • src/static/styles/partials/_settings-console.css
  • src/templates/settings.html
  • tests/contract/test_frontend_api_contract_coverage.py
  • tests/contract/test_response_shapes.py
  • tests/static/test_benchmark_display.py
  • tests/unit/test_settings_blueprint.py

Comment thread src/static/scripts/settings/diagnostics.js
Comment thread src/static/scripts/settings/diagnostics.js
Comment thread src/static/scripts/settings/diagnostics.js
Comment thread src/static/scripts/settings/diagnostics.js
@sonarqubecloud
Copy link
Copy Markdown

@jtn0123 jtn0123 merged commit c18e2f0 into main Apr 28, 2026
34 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.

1 participant