feat(web): add solver selection to optimize page - #38
Conversation
WalkthroughAdds a Solver selection dropdown to the Optimize and Export page, introducing a ChangesSolver Selection Feature
Estimated code review effort: 1 (Trivial) | ~5 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant OptimizePage
participant FormData
participant API as /optimize endpoint
User->>OptimizePage: Select solver option
OptimizePage->>OptimizePage: Update solverArg state
User->>OptimizePage: Submit optimization
OptimizePage->>FormData: Append solver = solverArg
OptimizePage->>API: POST FormData
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
web-frontend/src/app/optimize-and-export/page.tsx (1)
275-275: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider a typed union for solver values.
solverArgis inferred asstring, and the two option values (ortools/cp-sat,pulp/cuopt) are duplicated as literals between the state default and the<option>elements. A shared union type would give compile-time safety against typos and keep the default/options in sync if a solver id changes.♻️ Suggested refactor
+type SolverOption = 'ortools/cp-sat' | 'pulp/cuopt'; + +const SOLVER_OPTIONS: { value: SolverOption; label: string }[] = [ + { value: 'ortools/cp-sat', label: 'OR-Tools / CP-SAT (CPU)' }, + { value: 'pulp/cuopt', label: 'PuLP / cuOpt (GPU)' }, +]; + - const [solverArg, setSolverArg] = useState('ortools/cp-sat'); + const [solverArg, setSolverArg] = useState<SolverOption>('ortools/cp-sat');<select id="solver-select" value={solverArg} - onChange={(e) => setSolverArg(e.target.value)} + onChange={(e) => setSolverArg(e.target.value as SolverOption)} className="block w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm text-gray-900 shadow-sm transition-colors focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200" > - <option value="ortools/cp-sat">OR-Tools / CP-SAT (CPU)</option> - <option value="pulp/cuopt">PuLP / cuOpt (GPU)</option> + {SOLVER_OPTIONS.map(({ value, label }) => ( + <option key={value} value={value}>{label}</option> + ))} </select>Also applies to: 886-899
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@web-frontend/src/app/optimize-and-export/page.tsx` at line 275, The solver selection in optimize-and-export/page.tsx uses raw string literals, so typos and drift between the default state and the option values are not type-checked. Introduce a shared typed union for the solver ids and use it in the solverArg state initialized in the useState call, then reuse the same typed values for the option entries in the solver selector so the default and dropdown stay in sync.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@web-frontend/src/app/optimize-and-export/page.tsx`:
- Line 275: The solver selection in optimize-and-export/page.tsx uses raw string
literals, so typos and drift between the default state and the option values are
not type-checked. Introduce a shared typed union for the solver ids and use it
in the solverArg state initialized in the useState call, then reuse the same
typed values for the option entries in the solver selector so the default and
dropdown stay in sync.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e2d1bc30-624c-47ea-a014-bb3c2ef5e198
📒 Files selected for processing (2)
web-frontend/src/app/optimize-and-export/page.test.tsxweb-frontend/src/app/optimize-and-export/page.tsx
Summary
Adds a frontend-only solver selector to the Optimize and Export page.
Users can now choose between:
ortools/cp-satpulp/cuoptThe selected solver is submitted through the existing
/optimizeFormData request.Changes
ortools/cp-satas the default solver.solver=<selected solver>in the existing/optimizeFormData.pulp/cbcin the UI.Tests
./node_modules/.bin/vitest related --reporter=dot --silent=passed-only --bail=1 --passWithNoTests src/app/optimize-and-export/page.tsx./node_modules/.bin/eslint .Note: ESLint may print an existing TypeScript version support warning, but lint completes successfully.
Notes
pulp/cuoptrequires backend runtime support for cuOpt/GPU. If the backend environment does not support it, the existing backend error message is shown.Summary by CodeRabbit
New Features
Tests