Skip to content

Add wallet summary cards#489

Open
tinyopsstudio wants to merge 7 commits into
ramimbo:mainfrom
tinyopsstudio:tinyops-wallet-summary
Open

Add wallet summary cards#489
tinyopsstudio wants to merge 7 commits into
ramimbo:mainfrom
tinyopsstudio:tinyops-wallet-summary

Conversation

@tinyopsstudio
Copy link
Copy Markdown

@tinyopsstudio tinyopsstudio commented May 27, 2026

Bounty #427

Summary:

  • add scan-level summary cards to /wallets for wallets shown, linked GitHub wallets, and total wallet balance
  • compute the summary from the same wallet rows shown on the page
  • cover linked-wallet and funded-wallet summary rendering in the existing wallet page smoke test

Evidence:

  • distinct from current MRWK bounty: site UX and functional improvements #427 claims I saw: bounty card styling/back nav, filtered empty states, wallet private-key copy, sort controls, bounty next-steps, activity search empty states, and active-attempt display
  • no private keys, cookies, tokens, wallet JSON, or private material are added

Verification:

  • .venv/bin/python -m pytest tests/test_wallet_api.py::test_wallet_pages_expose_transfer_and_github_claim_flows -q
  • .venv/bin/python -m pytest tests/test_public_routes.py tests/test_wallet_api.py -q
  • .venv/bin/python -m ruff check app/public_routes.py tests/test_wallet_api.py
  • .venv/bin/python -m ruff format --check app/public_routes.py tests/test_wallet_api.py
  • .venv/bin/python scripts/docs_smoke.py
  • git diff --check

Summary by CodeRabbit

  • New Features
    • Wallets page shows a summary above the list with total wallets shown, number of wallets linked to GitHub, and the combined displayed balance (MRWK).
  • Tests
    • Wallet page tests expanded to verify the new summary display and linked-wallet balance totals.

Review Change Stack

Bounty ramimbo#427: app/public_routes.py
Bounty ramimbo#427: app/templates/wallets.html
Bounty ramimbo#427: tests/test_wallet_api.py
@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: 0c80ff36-e522-41b1-8796-c3f380c87c31

📥 Commits

Reviewing files that changed from the base of the PR and between 5e81c44 and a787012.

📒 Files selected for processing (1)
  • tests/test_wallet_api.py

📝 Walkthrough

Walkthrough

Backend adds Decimal formatting helper and includes a summary (wallets_shown, linked_github_wallets, displayed_balance_mrwk) in wallets_page_context(). Template renders that summary above the wallets table. Tests create a linked wallet and assert the summary and balance HTML appear.

Changes

Wallet Summary Display

Layer / File(s) Summary
Backend summary computation
app/public_routes.py
Decimal import added; _format_decimal_mrwk() helper normalizes and strips trailing zeros from Decimal formatting; wallets_page_context() extended to compute wallet count, linked GitHub wallet count, and aggregated displayed balance, returning summary with MRWK-formatted balance string.
Template rendering and test validation
app/templates/wallets.html, tests/test_wallet_api.py
Wallets template adds a summary UI block above the registered wallets table showing summary.wallets_shown, summary.linked_github_wallets, and summary.displayed_balance_mrwk. Test setup provisions a linked wallet with github_login and a funding ledger entry; assertions verify the summary section and balance-related HTML fragments.

Possibly related PRs

🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add wallet summary cards' directly and specifically names the main changed surface and aligns with the PR's core objective of adding summary cards to the wallets page.
Description check ✅ Passed The description covers the core changes, scopes out unrelated work, includes verification steps, and references the bounty. All required 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 PR adds wallet summary cards with factual data. No investment, price, cash-out claims, fabricated payouts, or private security details. MRWK appropriately described as native project coin.
Bounty Pr Focus ✅ Passed Diff matches stated objectives: 3 files modified with summary cards, test coverage with label-bound assertions, no excluded items, all validation passed (pytest, lint, type check, docs).

✏️ 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.

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.

Reviewed current head 0c375d3776c36c237541f815bad467772ee7e5f4 as a non-author reviewer.

I checked the wallet summary path in app/public_routes.py, app/templates/wallets.html, and tests/test_wallet_api.py. The new cards are derived from the same 100 displayed wallet rows, count linked GitHub wallets from wallet_to_dict() output, and sum the rendered MRWK balances with Decimal before formatting. The regression covers three displayed wallets, one linked wallet, and a combined 12.5 MRWK balance while leaving the existing wallet form/table flow intact.

Validation run locally:

  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python -m pytest tests/test_wallet_api.py -q -> 32 passed
  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python -m pytest -q -> 414 passed
  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python scripts/docs_smoke.py -> docs smoke ok
  • uv run --extra dev ruff check app/public_routes.py tests/test_wallet_api.py -> passed
  • uv run --extra dev ruff format --check app/public_routes.py tests/test_wallet_api.py -> 2 files already formatted
  • uv run --extra dev python -m mypy app -> success, 30 source files
  • git diff --check origin/main...HEAD -> clean
  • git diff --no-ext-diff origin/main..HEAD | gitleaks stdin --no-banner --redact --exit-code 1 -> no leaks

Limitation: GitHub check rollup still showed only CodeRabbit pending at readback, so this review is based on the source/test validation above.

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


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: d901226e-b3de-4269-acdd-93972ebe2313

📥 Commits

Reviewing files that changed from the base of the PR and between d8532d4 and 0c375d3.

📒 Files selected for processing (3)
  • app/public_routes.py
  • app/templates/wallets.html
  • tests/test_wallet_api.py

Comment thread app/public_routes.py
from __future__ import annotations

from collections.abc import Callable
from decimal import Decimal
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
ruff format --check .
ruff check .
mypy app

Repository: ramimbo/mergework

Length of output: 181


Blocker: required mypy app check didn’t run (mypy not installed)

  • ruff format --check . and ruff check . pass.
  • mypy app fails to execute in this environment (mypy: command not found), so the required type-checking gate isn’t satisfied.
  • Functional change in app/public_routes.py (e.g., added from decimal import Decimal) looks consistent with the intended formatting/helper usage.

Comment thread tests/test_wallet_api.py
Comment thread tests/test_wallet_api.py Outdated
Copy link
Copy Markdown
Contributor

@prettyboyvic prettyboyvic left a comment

Choose a reason for hiding this comment

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

Reviewed current head 0c375d3776c36c237541f815bad467772ee7e5f4 for the #447 review bounty.

I am requesting changes for one UX/data-contract issue in the new summary cards: the page only loads the newest 100 wallets, but the card label says Total wallet balance. In wallets_page_context(), the query is limited to 100 wallets, wallet_rows is built from those rows, and total_balance_mrwk is the sum of only that displayed slice. The template then renders it as Total wallet balance, which reads as an all-wallet ledger total.

Local repro on this head with 101 registered wallets funded at 1 MRWK each:

wallets_shown_card_100 True
total_card_contains_100 True
actual_wallets 101

So the page correctly says 100 wallets are shown, but the adjacent Total wallet balance card reports 100 MRWK even though the registered wallet balance total is 101 MRWK. That can mislead contributors or maintainers using the page as a public wallet overview once the registry exceeds the display limit.

Suggested fix: either rename the card to something explicitly scoped like Shown wallet balance, or compute true aggregate counts/balance across all registered wallets while keeping the table itself limited to 100 rows. Add a regression with more than 100 wallets so this label/aggregate behavior stays intentional.

Validation run locally on this head:

PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python -m pytest tests/test_wallet_api.py -q -> 32 passed
PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python -m pytest -q -> 414 passed
uv run --extra dev ruff check app/public_routes.py tests/test_wallet_api.py -> passed
uv run --extra dev ruff format --check app/public_routes.py tests/test_wallet_api.py -> 2 files already formatted
uv run --extra dev python -m mypy app -> success, no issues in 30 source files
PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python scripts/docs_smoke.py -> docs smoke ok
git diff --check d8532d4d909f47c689d3b88eb21461243097673f...HEAD -> clean

GitHub readback before posting: PR is open/non-draft at 0c375d3776c36c237541f815bad467772ee7e5f4; merge state is currently UNSTABLE while checks/CodeRabbit are still processing.

@tinyopsstudio
Copy link
Copy Markdown
Author

Follow-up for the wallet summary label finding:

  • changed the summary key to displayed_balance_mrwk
  • changed the card label to Displayed wallet balance
  • updated the wallet page smoke test to assert that wording

Validation after the update:

  • uv run --extra dev python -m pytest tests/test_wallet_api.py -q -> 32 passed
  • uv run --extra dev python -m pytest -q -> 414 passed
  • uv run --extra dev ruff check app/public_routes.py tests/test_wallet_api.py -> passed
  • uv run --extra dev ruff format --check app/public_routes.py tests/test_wallet_api.py -> already formatted
  • uv run --extra dev mypy app -> success
  • uv run --extra dev python scripts/docs_smoke.py -> docs smoke ok
  • git diff --check origin/main...HEAD -> passed

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.

Reviewed the updated head 5e81c44aeb322617c6f98820267dff3844264e14 after the wallet-summary follow-up. The previous stale-head UX concern is addressed: the context key and UI label now say displayed_balance_mrwk / Displayed wallet balance, so the card is explicitly scoped to the 100 rendered wallet rows rather than implying an all-wallet total.

Validation run locally on the updated head:

  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python -m pytest tests/test_wallet_api.py -q -> 32 passed
  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python -m pytest -q -> 414 passed
  • uv run --extra dev ruff check app/public_routes.py tests/test_wallet_api.py -> passed
  • uv run --extra dev ruff format --check app/public_routes.py tests/test_wallet_api.py -> 2 files already formatted
  • uv run --extra dev python -m mypy app -> success, 30 source files
  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python scripts/docs_smoke.py -> docs smoke ok
  • git diff --check origin/main...HEAD -> clean
  • git diff --no-ext-diff origin/main..HEAD | gitleaks stdin --no-banner --redact --exit-code 1 -> no leaks

GitHub readback before posting: PR open/non-draft, MERGEABLE, current head 5e81c44aeb322617c6f98820267dff3844264e14, CodeRabbit recent review has no actionable comments.

Copy link
Copy Markdown

@er1c-cartman er1c-cartman left a comment

Choose a reason for hiding this comment

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

Reviewed current head 5e81c44aeb322617c6f98820267dff3844264e14 for the #447 review bounty.

I would hold this for one small test-quality fix. The code behavior is now scoped correctly to displayed wallets: wallets_page_context() computes displayed_balance_mrwk from the same 100 rendered wallet rows, and the template labels it as Displayed wallet balance, so the earlier human concern about implying an all-wallet total is addressed.

The remaining issue is in tests/test_wallet_api.py: the new summary assertions check only loose fragments like "3</strong>", "1</strong>", and "12.5 MRWK</strong>". Those can pass if the values appear in the wrong card, or if a future template change renders misleading summary labels while the same numeric fragments still exist elsewhere in the page. Since the PR's main behavior is the wallet summary cards, the regression should bind each expected value to its label, for example by asserting scoped HTML/regex pairs for Wallets shown -> 3, Linked GitHub wallets -> 1, and Displayed wallet balance -> 12.5 MRWK.

Evidence checked:

  • Inspected app/public_routes.py, app/templates/wallets.html, and tests/test_wallet_api.py on current head.
  • Confirmed the summary is intentionally display-slice scoped, not all-wallet scoped.
  • Confirmed CodeRabbit status is success, but there are still unresolved review threads; the pytest/mypy environment comments are covered by the local validation below, while the assertion-strength issue remains actionable.

Validation run locally:

  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ./.venv/bin/python -m pytest tests/test_wallet_api.py::test_wallet_pages_expose_transfer_and_github_claim_flows -q -> 1 passed
  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ./.venv/bin/python -m pytest tests/test_wallet_api.py -q -> 32 passed
  • ./.venv/bin/python -m ruff check app/public_routes.py tests/test_wallet_api.py -> passed
  • ./.venv/bin/python -m ruff format --check app/public_routes.py tests/test_wallet_api.py -> 2 files already formatted
  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ./.venv/bin/python -m mypy app/public_routes.py -> success
  • git diff --check origin/main...HEAD -> clean

No secrets, wallet material, private data, production mutation, price/exchange/liquidity claim, or off-ramp claim was used.

Bind each summary value to its rendered label so the wallet summary regression cannot pass on loose numeric fragments.
@tinyopsstudio
Copy link
Copy Markdown
Author

Follow-up for the newer test-strength review:

  • added re and changed wallet summary assertions to bind each value to its label: Wallets shown -> 3, Linked GitHub wallets -> 1, and Displayed wallet balance -> 12.5 MRWK
  • updated branch commit: a787012
  • validation: focused wallet page test passed, full tests/test_wallet_api.py passed, Ruff check/format passed, docs smoke ok, and git diff --check is clean

This addresses the requested regression-strength issue without changing runtime behavior.

Copy link
Copy Markdown

@adliebe adliebe left a comment

Choose a reason for hiding this comment

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

Reviewed the current head a787012a44a677f1d7bf5a39fc0155b6501c852c after the wallet-summary assertion follow-up.

This resolves the remaining issue from the earlier reviews: tests/test_wallet_api.py now binds each summary value to its rendered label with scoped regex assertions, covering Wallets shown -> 3, Linked GitHub wallets -> 1, and Displayed wallet balance -> 12.5 MRWK. That prevents the regression from passing on loose numeric fragments or values appearing under the wrong card.

Evidence checked:

  • app/public_routes.py still computes the summary from the displayed 100 wallet rows and formats the displayed balance without implying an all-wallet total.
  • app/templates/wallets.html labels the balance as Displayed wallet balance.
  • tests/test_wallet_api.py now imports re and asserts label/value pairs in the rendered wallet summary.
  • GitHub readback before posting: PR is open, non-draft, current head a787012a44a677f1d7bf5a39fc0155b6501c852c, and CodeRabbit status is success.

Validation:

  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python -m pytest tests/test_wallet_api.py::test_wallet_pages_expose_transfer_and_github_claim_flows -q -> 1 passed
  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python -m pytest tests/test_wallet_api.py -q -> 32 passed
  • uv run --extra dev ruff check app/public_routes.py tests/test_wallet_api.py -> passed
  • uv run --extra dev ruff format --check app/public_routes.py tests/test_wallet_api.py -> 2 files already formatted
  • uv run --extra dev python -m mypy app/public_routes.py -> 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

No private wallet material, secrets, payout promises, exchange/off-ramp claims, or private data are introduced.

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.

5 participants