Skip to content

Add always-visible version badge on simulation result pages#2832

Open
MaxGhenis wants to merge 1 commit intomainfrom
version-badge-on-result-pages
Open

Add always-visible version badge on simulation result pages#2832
MaxGhenis wants to merge 1 commit intomainfrom
version-badge-on-result-pages

Conversation

@MaxGhenis
Copy link
Copy Markdown
Contributor

Summary

  • New `src/layout/VersionBadge.jsx`: monospace strip on every simulation result showing `policyengine-@ · `. Clicking it opens a popover with the full identifiers and a cross-link to the forthcoming TRACE "Cite this result" flow ('Cite this result' button, version badge, and shareable TRO permalinks #2830).
  • Wired into policy output (`src/pages/policy/output/Display.jsx`, inline with the existing bottom text) and household output (`src/pages/household/output/HouseholdOutput.jsx`, bottom-aligned after computed panes).
  • Accepts optional `dataVersion` and `h5Sha` props so that when the api v4 migration (Migrate policyengine dep from 0.x to v4 (prereq for TRACE TRO emission) policyengine-api#3486) begins exposing the policyengine--data version and calibrated h5 SHA, the badge can consume them without component changes.
  • Five jest tests covering country-package labeling, dataset fallback, truncated h5 sha display, renders-nothing-when-missing, and composite output.
  • Gitignores `bun.lock` — this repo uses npm (`package-lock.json`), and contributors who use bun locally (per global tooling preference) shouldn't pollute the tracked state.

Why

Distinct from the TRACE cite-this-result flow (#2830, blocked on backend work). Per Casper at the 2026-04-21 meeting with Lars Vilhuber, plain version identification — "which pinned rules and which pinned data produced this number?" — is what every user needs. TRACE certification is what reviewers of papers citing runs need. This issue is the former, and it ships independently of any backend change.

Fixes #2831.

Test plan

  • `bun run test -- --testPathPattern="VersionBadge"` — 5/5 pass
  • `bun run lint` — clean
  • Prettier check clean
  • Visual: load a /us/policy result, confirm badge appears next to the bottom text; load a /us/household result, confirm badge appears at the bottom after computed panes; click badge, confirm popover opens
  • Mobile: confirm badge still renders (the badge is not gated on `!mobile` like the bottomText is on PolicyPage)

🤖 Generated with Claude Code

Implements #2831 — the plain version-
identification surface (distinct from the TRACE cite-this-result
flow in #2830, which is blocked on api backend work).

- Adds `src/layout/VersionBadge.jsx`: small monospace strip showing
  `policyengine-<country>@<version> · <dataset>` with a click-to-expand
  popover listing the full identifiers and cross-linking to #2830 for
  the forthcoming TRO citation flow.
- Wires the badge into policy output (`src/pages/policy/output/Display.jsx`,
  inline with the existing bottom text) and household output
  (`src/pages/household/output/HouseholdOutput.jsx`, bottom-aligned after
  computed panes).
- Accepts optional `dataVersion` and `h5Sha` props so that once the api
  v4 migration (PolicyEngine/policyengine-api#3486) exposes the
  policyengine-<country>-data version and calibrated h5 SHA, the badge
  can consume those fields without further component changes.
- Five jest tests covering: country-package labeling for us/uk, dataset
  fallback when not set, truncated h5 sha display, renders-nothing when
  modelVersion missing, and correct composite output when all fields
  are passed.

Based on feedback in the 2026-04-21 meeting with Lars Vilhuber and the
TRACE team: Casper explicitly distinguished version identification
(what every user needs) from TRACE certification (what reviewers of
papers citing runs need). This issue is the former.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 21, 2026 17:23
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 21, 2026

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

Project Deployment Actions Updated (UTC)
policyengine-app Ready Ready Preview, Comment Apr 21, 2026 5:25pm

Request Review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an always-visible “version badge” UI element to simulation result pages so users can quickly identify the model package/version and dataset used to generate a result, with a click-to-expand popover for more detail and future TRACE integration.

Changes:

  • Introduces src/layout/VersionBadge.jsx (badge + popover; optional dataVersion/h5Sha support).
  • Wires the badge into policy output (Display.jsx) and household output (HouseholdOutput.jsx) result pages.
  • Adds Jest coverage for the new component and updates .gitignore to ignore a Bun lockfile.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/pages/policy/output/Display.jsx Renders VersionBadge alongside the existing bottom text on policy result pages.
src/pages/household/output/HouseholdOutput.jsx Renders a compact VersionBadge footer on household result pages once results are available.
src/layout/VersionBadge.jsx New reusable badge component with antd Popover details panel.
src/tests/layout/VersionBadge.test.js Tests for rendering, fallbacks, and optional identifiers (data version + truncated SHA).
.gitignore Ignores Bun lockfile to avoid local tooling noise in git status.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -352,19 +353,34 @@ export function LowLevelDisplay(props) {
//eslint-disable-next-line
const bottomElements =
mobile & !embed ? null : (
onKeyDown={(event) => {
if (event.key === "Enter" || event.key === " ") {
event.preventDefault();
setPopoverOpen(!popoverOpen);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

Always-visible version badge on every simulation result (non-TRACE)

2 participants