Repository navigation
Web UI: year navigator for Spending's by-month grouping - #10
Conversation
There was a problem hiding this comment.
Pull request overview
Adjusts the web UI date navigator so Spending’s group_by=month view uses year-sized windows (and year-stepping arrows) to make month grouping meaningful across the full calendar year, and adds deterministic invariant guards to prevent regressions.
Changes:
- Add
yearNav:"month"to the Spending (summary) tab descriptor to enable year-mode when themonthsubtab is active. - Introduce
yearBounds(y)and updaterenderMonthNavto resolve whole-year bounds and step the navigator by year when in year-mode. - Register/enforce INV-WEBUI-006 via docs updates and new/expanded deterministic tests (structural + Node-driven behavioral/integration).
Show a summary per file
| File | Description |
|---|---|
tests/test_webui_design_guards.py |
Adds INV-WEBUI-006 guards, including a Node integration harness for renderMonthNav year-mode behavior. |
src/finance_mcp/webui.py |
Implements year-mode navigation (helper + wiring) and adds yearNav to the Spending tab config. |
docs/design/webui-date-navigation.md |
Updates design doc to describe year-mode behavior for Spending’s month grouping and references INV-WEBUI-006. |
docs/architecture/INVARIANTS.md |
Registers INV-WEBUI-006 in the invariant table. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 4/4 changed files
- Comments generated: 2
- Review effort level: Low
| // When a subtab toggles the navigator's granularity (month vs year), | ||
| // rebuild the filter row so the navigator re-renders in the right mode. | ||
| if (t.subtabs.yearNav) { buildFilters(); load(); return; } |
There was a problem hiding this comment.
Good catch — this was a real regression. Fixed: the filter row now rebuilds only when a subtab change crosses the month↔year granularity boundary, and manual filter values (e.g. exclude_income) are captured and re-applied across that rebuild. Non-crossing subtab changes take the fast path and leave manual inputs untouched. Verified across all transitions.
When the Spending tab's active subtab groups by month, a single-month window makes the grouping meaningless. Switch the navigator to year granularity in that mode: ‹ YYYY › steps by year and scopes the query to whole-calendar-year bounds (YYYY-01-01..YYYY-12-31), so the by-month view shows every month of the selected year. Other subtabs keep month granularity. The custom-range calendar picker is unchanged and seeds from the current year when entered in year mode. Adds INV-WEBUI-006 (register + structural and behavioral guards) and documents the behavior in the date-navigation design doc. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ac70e9d to
b909af0
Compare
What
When the Spending tab's active subtab groups by month, a single-month date window makes the grouping meaningless (you'd see one row). This switches the navigator to year granularity in that mode:
< YYYY >steps by year and scopes the query to whole-calendar-year bounds (YYYY-01-01..YYYY-12-31), so the by-month view shows every month of the selected year. All other subtabs keep month granularity. The custom-range calendar picker is unchanged (seeds from the current year when entered in year mode).How
subtabsdescriptor gainsyearNav:"month"(the subtab value that triggers year mode).yearBounds(y).renderMonthNavcomputesyearModeand, when active, resolves whole-year bounds and renders year-stepping arrows.renderSubtabsrebuilds the filter row when ayearNavtab's subtab changes, so the navigator re-renders at the correct granularity.Enforcement
Adds INV-WEBUI-006 to the architecture invariant register with three deterministic guards in
tests/test_webui_design_guards.py: a structural check (yearNav:"month"declared), a unit check (yearBounds), and an integration guard that drives the realrenderMonthNavagainst a DOM stub — asserting both the resolved year bounds and that the arrows actually step by year. Design doc updated.Verification