Skip to content

fix(ui): duplicate trainFamily binding breaks forecast page render #307

@w7-mgfcode

Description

@w7-mgfcode

Summary

frontend/src/pages/visualize/forecast.tsx declares trainFamily twice — once via useState at L68 (PRP-37 Slice C train-card form state) and once via const at L120 (PRP-31 derived value from a loaded predict job's training metadata). Babel/Vite reject this as Cannot redeclare block-scoped variable 'trainFamily'; TypeScript also reports TS2451 at both sites.

Effect: the Forecast page (/visualize/forecast) cannot compile in the browser. Vite returns 500 on GET /src/pages/visualize/forecast.tsx, the React tree never mounts.

Discovered while running the PRP-37 Task 26 dogfood against the merged dev (5e86b6f).

Repro

  1. cd frontend && ./node_modules/.bin/vite --host 0.0.0.0
  2. Browse http://localhost:5173/visualize/forecast
  3. React error boundary fires; console shows Identifier 'trainFamily' has already been declared. (120:8)
  4. ./node_modules/.bin/tsc --noEmit -p ./tsconfig.app.json reports:
    • src/pages/visualize/forecast.tsx(68,10): error TS2451: Cannot redeclare block-scoped variable 'trainFamily'.
    • src/pages/visualize/forecast.tsx(120,9): error TS2451: Cannot redeclare block-scoped variable 'trainFamily'.

Fix

Rename the L120 derived value to loadedTrainFamily (distinct from the train-form state, which keeps the trainFamily name). Update its single consumer at L497–498 (the ModelFamilyBadge in the "Model details" collapsible).

The two values are semantically distinct:

  • trainFamily (L68) is the user-selected family for the Train-a-new-model card (PRP-37 Slice C).
  • loadedTrainFamily (L120) is the family derived from a loaded predict job's training metadata (PRP-31, shown as a badge in the "Model details" panel).

Why this slipped through

PRP-37's per-task validation gates reported pnpm tsc --noEmit clean, but the merged file fails both Babel parse and tsc. Possibly run against a different staged tree or the duplicate was introduced in a late edit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingscope:forecastTouches the forecast area (commit-format scope)scope:uiTouches the ui area (commit-format scope)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions