Skip to content

Bounty #427: Add ledger row limit controls#490

Open
akmhatey-ai wants to merge 2 commits into
ramimbo:mainfrom
akmhatey-ai:codex/ledger-limit-controls-427
Open

Bounty #427: Add ledger row limit controls#490
akmhatey-ai wants to merge 2 commits into
ramimbo:mainfrom
akmhatey-ai:codex/ledger-limit-controls-427

Conversation

@akmhatey-ai
Copy link
Copy Markdown

@akmhatey-ai akmhatey-ai commented May 27, 2026

Bounty #427

Summary

  • Add row-count controls to the public /ledger page so contributors can choose how many recent ledger entries to inspect.
  • Reuse the existing /api/v1/ledger limit bounds and link the rendered page to the matching JSON response.
  • Preserve non-standard valid limits by adding the current limit to the selector when needed.

Before / After

  • Before: /ledger rendered the default recent ledger window with no page-level way to inspect a smaller or larger recent set.
  • After: /ledger?limit=N shows the number of rendered entries, offers common row limits, rejects out-of-range limits through the existing FastAPI 1..200 validation, and links to /api/v1/ledger?limit=N.
  • Screenshot evidence was captured locally from /ledger?limit=25 in the Money workspace receipt; I did not commit the binary screenshot into this repository.

Duplicate / Scope Notes

Validation

  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python -m pytest tests/test_api_mcp.py::test_ledger_api_rejects_out_of_range_limits tests/test_api_mcp.py::test_ledger_page_exposes_limit_controls tests/test_api_mcp.py::test_ledger_page_highlights_bounty_payment_and_release tests/test_api_mcp.py::test_ledger_page_uses_wrapping_entry_cards -q -> 6 passed
  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python -m pytest -q -> 415 passed
  • uv run --extra dev ruff check app tests -> passed
  • uv run --extra dev ruff format --check app tests -> 67 files already formatted
  • uv run --extra dev python -m mypy app -> success
  • uv run --extra dev python scripts/docs_smoke.py -> docs smoke ok
  • git diff --check -> exit 0; Git only printed Windows LF-to-CRLF working-copy warnings
  • git diff | gitleaks stdin --redact --no-banner --no-color -> no leaks found

Limitations

  • This PR does not change ledger ordering or the API response schema.
  • The local screenshot was kept out of the repo to avoid adding a binary proof artifact to source control.
  • No wallet material, private keys, cookies, OAuth state, access tokens, signatures, private vulnerability details, deployment credentials, price claims, liquidity claims, exchange claims, or fabricated payout claims are included.

Summary by CodeRabbit

  • New Features

    • Ledger page now includes pagination controls with a dropdown to set how many entries are shown and accepts a limit via query parameter
    • Toolbar shows current ledger size and a direct JSON export link
  • Style

    • Added styling for the ledger toolbar and its controls
  • Tests

    • Added tests verifying limit controls, selection behavior, and validation of allowed limits

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: cc0a5340-0309-46cd-ab76-042be87c459b

📥 Commits

Reviewing files that changed from the base of the PR and between 307cb15 and 82f18c3.

📒 Files selected for processing (2)
  • app/static/style.css
  • tests/test_api_mcp.py

📝 Walkthrough

Walkthrough

The PR adds ledger page pagination via a validated limit query parameter. LEDGER_LIMIT_OPTIONS and ledger_page_context() compute and expose selectable limits. The /ledger endpoint now accepts limit, calls api_ledger(limit), and renders the template. A toolbar UI and CSS were added, and tests verify valid/invalid limits.

Changes

Ledger pagination feature

Layer / File(s) Summary
Limit options and context helper
app/public_routes.py
LEDGER_LIMIT_OPTIONS constant and ledger_page_context() package entries with the current limit and compute the sorted set of limit options for the dropdown.
Ledger endpoint with limit parameter
app/public_routes.py
api_ledger dependency signature changes to accept int limit; Annotated is imported; /ledger validates limit (ge=1, le=200), calls api_ledger(limit), and renders via ledger_page_context().
Ledger toolbar UI and CSS
app/templates/ledger.html, app/static/style.css
Template adds a toolbar showing entry count, a limit dropdown, Update button, and JSON link. CSS adds .ledger-toolbar rules and styles nested form controls.
Test coverage for limit controls
tests/test_api_mcp.py
Imports add_ledger_entry and adds test_ledger_page_exposes_limit_controls() which seeds entries and asserts dropdown selection, pagination links, and HTTP 422 for out-of-range limits.

Possibly related PRs

  • ramimbo/mergework#394: Modifies the /ledger page wiring and api_ledger callable signature in app/public_routes.py.
🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly names the changed surface and main feature: adding row limit controls to the ledger page.
Description check ✅ Passed The description covers summary, evidence, scope clarity, validation steps with test results, and limitations. All required template sections are present and substantive.
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.
Mergework Public Artifact Hygiene ✅ Passed No investment, price, cash-out claims, fabricated payouts, or private security details found. MRWK correctly described as native ledger coin.
Bounty Pr Focus ✅ Passed PR diff matches stated files with ledger limit controls, API validation (1–200), helper function, UI/CSS, and comprehensive tests without scope creep.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@Thanhdn1984
Copy link
Copy Markdown

Reviewed PR #490 against bounty #427. Evidence: inspected app/public_routes.py, app/templates/ledger.html, app/static/style.css, and existing/new ledger tests in tests/test_api_mcp.py around /ledger?limit=. Diff adds bounded FastAPI Query(ge=1, le=200), propagates the selected limit into api_ledger(limit), exposes stable 25/50/100/200 options plus custom valid limits, and links the matching JSON endpoint. This is a useful focused UX improvement for scanning the ledger/explorer.

Local verification note: I attempted focused pytest runs, but the local checkout currently reports found no collectors for direct node ids even though the test functions are present; broad run also showed a mistaken local path for tests/test_public_pages.py from my first command. So I treated this as static review + test inspection, not passing local test proof.

Minor non-blocking suggestion: consider adding an aria-live/status copy only if future updates become async. For current full-page form submit, the implementation looks coherent.

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: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: da651210-f202-4275-bd93-af61a942e2bc

📥 Commits

Reviewing files that changed from the base of the PR and between d8532d4 and 307cb15.

📒 Files selected for processing (4)
  • app/public_routes.py
  • app/static/style.css
  • app/templates/ledger.html
  • tests/test_api_mcp.py

Comment thread app/static/style.css
Comment thread tests/test_api_mcp.py
Copy link
Copy Markdown
Contributor

@GHX5T-SOL GHX5T-SOL left a comment

Choose a reason for hiding this comment

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

I reviewed current head 307cb1582c9b9388caa8ef34256f3152be05badf and I think this needs two small fixes before merge.

  1. app/static/style.css: the new .ledger-toolbar button rule does not override the later global input, textarea, button { width: 100%; }, so the toolbar submit button inherits full width instead of staying inline with the select and JSON link. Add an explicit toolbar override such as width: auto or scope the global form-button rule away from the toolbar.

  2. tests/test_api_mcp.py: the page route is capped at limit <= 200, but the new regression only asserts the lower rejection case (limit=0). Please add an upper-bound assertion for /ledger?limit=201 so the UI/page contract is pinned on both sides of the accepted range.

Validation I ran on this head:

  • MERGEWORK_DATABASE_URL=sqlite:////tmp/mergework-pr490-test.sqlite3 PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python -m pytest tests/test_api_mcp.py::test_ledger_page_exposes_limit_controls tests/test_api_mcp.py::test_ledger_api_rejects_out_of_range_limits -q -> 4 passed
  • MERGEWORK_DATABASE_URL=sqlite:////tmp/mergework-pr490-test2.sqlite3 PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python -m pytest tests/test_api_mcp.py -q -> 77 passed
  • MERGEWORK_DATABASE_URL=sqlite:////tmp/mergework-pr490-full.sqlite3 PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python -m pytest -q -> 415 passed
  • uv run --extra dev ruff check app/public_routes.py tests/test_api_mcp.py -> passed
  • uv run --extra dev ruff format --check app/public_routes.py tests/test_api_mcp.py -> already formatted
  • uv run --extra dev python -m mypy app -> success
  • uv run --extra dev python scripts/docs_smoke.py -> docs smoke ok
  • git diff --check origin/main...HEAD -> clean
  • gitleaks detect --no-banner --redact --source . --log-opts origin/main..HEAD --exit-code 1 -> no leaks found

No secrets or private data were used.

@akmhatey-ai
Copy link
Copy Markdown
Author

Pushed follow-up 82f18c324206d62008495bc52ba2f30326b48006 for the current review notes.

Changes:

  • keep the ledger toolbar submit button inline by overriding the inherited full-width button rule
  • add /ledger?limit=201 page-route rejection coverage next to the lower-bound check

Validation:

  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python -m pytest tests/test_api_mcp.py -q -> 77 passed
  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python -m pytest -q -> 415 passed
  • uv run --extra dev ruff check . -> passed
  • uv run --extra dev ruff format --check . -> 79 files already formatted
  • uv run --extra dev python -m mypy app -> success
  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python scripts/docs_smoke.py -> docs smoke ok
  • git diff --check origin/main...HEAD -> clean
  • staged diff gitleaks scan -> no leaks

Post-push GitHub CI and CodeRabbit are still pending at readback.

@tinyopsstudio
Copy link
Copy Markdown

Current-head review for PR #490 at 82f18c324206d62008495bc52ba2f30326b48006.

I reviewed the ledger limit controls after the follow-up commit. The two issues called out in the earlier stale-head review appear addressed: .ledger-toolbar button { width: auto; } prevents the toolbar submit button from inheriting the later full-width global button rule, and the regression test now covers both lower and upper FastAPI bounds with /ledger?limit=0 and /ledger?limit=201.

Files inspected: app/public_routes.py, app/templates/ledger.html, app/static/style.css, and tests/test_api_mcp.py. The public page route now delegates to the existing validated /api/v1/ledger limit path, carries non-standard valid values like 10 into the selector, and links the rendered view to the matching JSON endpoint.

Validation I ran locally:

  • .venv/bin/python -m pytest tests/test_api_mcp.py::test_ledger_page_exposes_limit_controls tests/test_api_mcp.py::test_ledger_page_highlights_bounty_payment_and_release tests/test_api_mcp.py::test_ledger_page_uses_wrapping_entry_cards -q -> 3 passed
  • .venv/bin/python -m pytest tests/test_api_mcp.py tests/test_docs_public_urls.py -q -> 100 passed
  • .venv/bin/python -m ruff check app/public_routes.py tests/test_api_mcp.py -> passed
  • .venv/bin/python -m ruff format --check app/public_routes.py tests/test_api_mcp.py -> 2 files already formatted
  • .venv/bin/python -m mypy app -> success
  • .venv/bin/python scripts/docs_smoke.py -> docs smoke ok
  • git diff --check d8532d4d909f47c689d3b88eb21461243097673f...HEAD -> clean

Assessment: this is a useful #427 site/workflow improvement. It is small, test-backed, reuses the existing API limit contract, and makes the public ledger easier to inspect without widening the API surface or adding MRWK price/liquidity claims.

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.

4 participants