Skip to content

Add budget window mode for economy reports#930

Draft
MaxGhenis wants to merge 7 commits intomainfrom
codex/budget-window-mode
Draft

Add budget window mode for economy reports#930
MaxGhenis wants to merge 7 commits intomainfrom
codex/budget-window-mode

Conversation

@MaxGhenis
Copy link
Copy Markdown
Contributor

Summary

  • add a first-class budget window mode to report setup with start-year and window controls
  • serialize budget windows into report timing and skip the single-year orchestrator for those reports
  • add a dedicated budget-window results flow that scores each year, persists the annual series, and renders a budget-first chart/table view

Testing

  • ./node_modules/.bin/tsc --noEmit
  • ./node_modules/.bin/eslint src/hooks/useCreateReport.ts src/pages/ReportOutput.page.tsx src/pages/report-output/ReportOutputLayout.tsx src/pages/report-output/SocietyWideReportOutput.tsx src/pages/report-output/BudgetWindowSubPage.tsx src/pages/report-output/budget-window/budgetWindowUtils.ts src/pages/report-output/hooks/useBudgetWindowCalculation.ts src/pages/reportBuilder/ModifyReportPage.tsx src/pages/reportBuilder/ReportBuilderPage.tsx src/pages/reportBuilder/components/ReportMetaPanel.tsx src/pages/reportBuilder/hooks/useModifyReportSubmission.ts src/pages/reportBuilder/hooks/useReportSubmission.ts src/pages/reportBuilder/types.ts src/pages/reportBuilder/utils/hydrateReportBuilderState.ts src/tests/fixtures/pages/reportBuilder/useReportSubmissionMocks.ts src/tests/unit/hooks/useCreateReport.test.tsx src/tests/unit/pages/reportBuilder/hooks/useReportSubmission.test.tsx src/tests/unit/utils/reportOutputSubpage.test.ts src/tests/unit/utils/reportTiming.test.ts src/types/calculation/CalcStatus.ts src/types/ingredients/Report.ts src/types/report/BudgetWindowReportOutput.ts src/utils/reportOutputSubpage.ts src/utils/reportTiming.ts
  • ./node_modules/.bin/vitest run src/tests/unit/utils/reportTiming.test.ts src/tests/unit/utils/reportOutputSubpage.test.ts src/tests/unit/pages/reportBuilder/hooks/useReportSubmission.test.tsx src/tests/unit/pages/reportBuilder/hooks/useModifyReportSubmission.test.tsx src/tests/unit/hooks/useCreateReport.test.tsx

Notes

  • src/tests/unit/pages/ReportOutput.page.test.tsx still fails in this worktree because of an existing @policyengine/design-system import-resolution issue before assertions run.

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 8, 2026

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

Project Deployment Actions Updated (UTC)
policyengine-app-v2 Ready Ready Preview, Comment Apr 9, 2026 1:52am
policyengine-calculator Ready Ready Preview, Comment Apr 9, 2026 1:52am
policyengine-website Ready Ready Preview, Comment Apr 9, 2026 1:52am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
policyengine-calculator-next Skipped Skipped Apr 9, 2026 1:52am

Request Review

Copy link
Copy Markdown

@policyengine policyengine bot 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 budget window mode implementation (~1,100 lines across 24 files). The code is well-structured and achieves its goals.

What this PR does well:

  1. Clean architecture - The budget window concept is properly isolated with dedicated types, utils, and components
  2. Good type safety - Added BudgetWindowReportOutput and BudgetWindowAnnualImpact types with proper discriminators
  3. Smart orchestration bypass - Budget window reports correctly skip the single-year orchestrator (useCreateReport.ts:100-102)
  4. Comprehensive tests - Added tests for reportTiming utils and useCreateReport budget window path
  5. UI polish - The BudgetWindowSubPage has good visual hierarchy with MetricCards, charts, and tables
  6. Proper state management - useBudgetWindowCalculation correctly polls for each year and persists results

No issues found:

  • Edge cases are handled (windowSize normalization with Math.max(2, windowSize))
  • Error handling is present (try/catch in useBudgetWindowCalculation)
  • Race conditions are prevented (runIdRef pattern)
  • Type guards are used correctly (isBudgetWindowReportOutput)
  • Tests cover the new budget window path

The implementation is production-ready.

@vercel vercel bot temporarily deployed to Preview – policyengine-calculator-next April 9, 2026 00:59 Inactive
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