Skip to content

v3 Household tab: a household switcher, results first, full-width charts - #1511

Merged
PavelMakarchuk merged 13 commits into
mainfrom
household-tab-results-first
Nov 3, 2026
Merged

PavelMakarchuk merged 13 commits into
mainfrom
household-tab-results-first

Conversation

@PavelMakarchuk

@PavelMakarchuk PavelMakarchuk commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

What changes

The v3 report's Household tab (US and UK share one component) stacked one card per household: the form, then Calculate, then the result under the form in the same card. With two or more households, a result sat between forms, and the result was a card inside a card, so its tables and charts got the narrowest width on the page.

This PR keeps several households and makes the results a primary screen.

  • A row of household tiles above the panel switches between households. Each tile shows the household's name, who it is (with its earnings, so households that differ only in income read apart) and its change in annual net income, or "Calculating…", "Could not calculate" or "Not calculated". The row is above the panel on every width, not a side column, so the panel keeps the full width.
  • Compare all (two or more households): a button at the right of the Household heading (pressed while open; no tile is selected then). It shows one table with each household's baseline net income, reform net income and change. A household's name, a tile or pressing the button again opens a household.
  • One household at a time, with Results and Inputs. Inputs lead until the household first runs; Results lead from then on. A result for inputs changed since says so and offers "Calculate again". Households are renamed in place (an emptied name goes back to "Household 2").
  • Full-width results and charts. The result has no frame or title of its own any more, so the summary tables and the Net income, Varying earnings and Marginal tax rates views take the panel's full width.
  • A small tip on each variable. Each builder field (v3 columns layout only) and each result line has an "i" tip: the period the amount covers first, then the model's description. Money inputs read "Per year: enter the total for the year"; result lines read "Per year". It opens on hover, keyboard focus, click and tap (phones).
  • Input formatting (v3 columns layout only; v2's stacked layout is unchanged): labels above the inputs in the person cards (they wrapped in a fixed narrow column), whole amounts without cents ("45,000", not "45,000.00"), add links that wrap instead of being cut off ("Add variable to your second depende…"), and "Household details" under the tab's own "Household" heading on a phone.

Every household stays mounted while another shows, so a run carries on in the background; only the shown household renders its form and result.

Layout options, the audit and before screenshots: https://claude.ai/artifact/W6yZMdAFQQzpxWo9pXVhm1 (Pavel picked option A; the switcher sits above the panel rather than beside it so charts keep the full width).

  • Varying earnings and Marginal tax rates run in the background. As soon as the API stores a calculated household, its variation run starts beside the household's own run, so either tab opens on the chart or on a bar that is already running. The run carries on while another household or tab is open, and "Calculate again" with changed inputs starts a new one and lets the old one go. v3 only (HouseholdVariationKeeper); the v2 hook and pages are unchanged.
    • Cost: 2 extra calculate-full requests (baseline and reform) per calculated household, also when the reader never opens those tabs.

Overlap and scope split

Saving households stays in Anthony's PRs; this PR has the layout, formatting and comparison only, and saves nothing.

Not in this PR

On the live API today, a new household's reform call (GET /us/household/{id}/policy/{reform}) and the reform variation (POST /us/calculate-full) timed out at 240 s and 300 s with no status, and the tab kept "Calculating…" with no error. That is a separate issue in how a run that ends without a response is shown; it is not changed here.

Tests

  • HouseholdImpactSection.test.tsx: switching, renaming, Compare all, the changed-inputs notice, and the existing run, result, failure and breakdown tests moved to the tiles and the Results/Inputs switch.
  • HouseholdBuilderForm.test.tsx: whole amounts without cents in the columns layout, cents kept in the stacked layout; "Household details".
  • bunx tsc --noEmit, ESLint and Prettier pass.

How to check

  1. Open a US or UK v3 report, then its Household tab.
  2. Add a household, rename it, set inputs and calculate: Results open, and the tile shows the change.
  3. Add another household and calculate it; open Compare all.
  4. On a result, open Net income, Varying earnings and Marginal tax rates: each takes the panel's full width.
  5. Repeat at phone width: the tiles scroll sideways; Results and Inputs stay one tap apart.

🤖 Generated with Claude Code

PavelMakarchuk and others added 2 commits November 1, 2026 15:20
The Household tab stacked one card per household, each with its form and
then its result under the form, so results sat between forms and the
charts got the narrowest width on the page.

- A row of tiles switches between the households (name, who they are,
  earnings and the change in net income) and "Compare all", one table of
  every household's baseline, reform and change.
- One household shows at a time, with Results and Inputs. Results lead
  once it runs; a result for changed inputs says so and offers to
  calculate again. Households can be renamed in place.
- The result has no frame or title of its own, so its tables and the
  net income, earnings and marginal tax rate charts take the panel's full
  width.
- Inputs (v3 columns layout only): labels above inputs in the person
  cards, whole amounts without cents, add links that wrap, and
  "Household details" under the tab's own Household heading.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
policyengine-calculator-next Ready Ready Preview Nov 3, 2026 5:32pm UTC
policyengine-website Ready Ready Preview Nov 3, 2026 5:32pm UTC

Request Review

…-first

# Conflicts:
#	app/src/components/flagship/report/household/HouseholdImpactSection.tsx
Each builder field (v3 columns layout only) and each result line gets a
small info tip: the period the amount covers first, then the model's
description. Money inputs read "Per year: enter the total for the year",
by #1360's rule (utils/variablePeriod.ts, copied unchanged): the builder
sends every amount for the year, and core divides it for month-defined
variables. Result lines read "Per year". The tip opens on hover, keyboard
focus, click and tap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The tile row now holds only the households and "Add another household".
"Compare all (N)" is a button at the right of the Household heading,
shown with two or more households: pressed while the comparison shows,
when no tile is selected. Pressing it again, or a tile, opens a
household again. The section draws the heading's line, so ReportView
passes its heading in.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d runs

With an amount still being typed, the inputs read as calculated, so the
button was disabled. A press on it blurred the field, which committed the
amount and enabled the button, but a browser drops the click of a press
that landed on a disabled button: a second click was needed. The button
is now marked unavailable (aria-disabled, dimmed) rather than disabled,
and checks again on the click, after the commit. It is still disabled
while a run is on its way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… opened again

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tab is open

The v2 outputs fetch the variation themselves, and TanStack Query cancels a
fetch that loses its last reader, so the run started again from 0. The
household's card now holds the same two variation queries once either
output opens, with the run's start time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… range

Behind a tidyChart prop the v3 household tab sets; the v2 report pages keep
their charts as they are.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PavelMakarchuk and others added 2 commits November 3, 2026 11:01
The card's bars do not yet read clearly. The chart, its CSV rows and its
tests stay, so a one-line change shows it again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… is stored

Varying earnings and Marginal tax rates now open on the chart, or on a bar
already running, without waiting for the reader to open them. Costs 2
calculate-full requests per calculated household.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Net income's tree, followed down to the deepest lines whose amount
changes, signed by what each does to net income; up to 4, then a link to
the Net income view, and a total when there is more than one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@PavelMakarchuk
PavelMakarchuk marked this pull request as ready for review November 3, 2026 20:43
@PavelMakarchuk
PavelMakarchuk merged commit 1f43dce into main Nov 3, 2026
10 checks passed
anth-volk added a commit that referenced this pull request Nov 27, 2026
…report-saved-households

Brings in #1386's branch at d0c1608, which has main (de9c9e5) merged
in, including the Household tab's household switcher and its
background variation run (#1511).

Conflicts, resolved keeping main's behavior in the Household tab and
this branch's shared parts:

- HouseholdImpactSection: main's panel (switcher, results and inputs
  views, Calculate again, the variation run started once the household
  is stored), with this branch's HouseholdBuilderPanel,
  useRequestedHouseholdRun (now passed main's onCreated), the shared
  run progress and failure, and newV3Household. The household's summary
  with its earnings is worked out from the household asked for, as the
  run hook keeps it.
- useFlagshipHousehold: main's onCreated callback and v2 policies, with
  useRequestedHouseholdRun, which passes onCreated through.
- HouseholdImpactResult: main's result without a frame or title, its
  tips and programmes; this branch's shared headline styles and output
  tabs; main's householdMoney.ts for money, so householdResultParts no
  longer keeps its own copy (HouseholdNetIncomeResult reads main's).
- HouseholdBreakdowns and EarningsVariationSubPage: both props kept
  (tidyChart from main, alsoOfferInputs from this branch).
- HouseholdRunProgress takes the run's start time, as main's section
  passes it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch was successfully deployed

2 active deployments
Preview – policyengine-website — 4581db04 Deployed Nov 3, 2026 by vercel[bot]
Preview – policyengine-calculator-next — 4581db04 Deployed Nov 3, 2026 by vercel[bot]
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