Skip to content

feat(web): add solver selection to optimize page - #38

Open
szuyu0408 wants to merge 1 commit into
j3soon:devfrom
szuyu0408:feat/solver-selection
Open

feat(web): add solver selection to optimize page#38
szuyu0408 wants to merge 1 commit into
j3soon:devfrom
szuyu0408:feat/solver-selection

Conversation

@szuyu0408

@szuyu0408 szuyu0408 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a frontend-only solver selector to the Optimize and Export page.

Users can now choose between:

  • OR-Tools / CP-SAT (CPU) -> ortools/cp-sat
  • PuLP / cuOpt (GPU) -> pulp/cuopt

The selected solver is submitted through the existing /optimize FormData request.

Changes

  • Added a Solver dropdown to the existing Configuration section.
  • Preserved ortools/cp-sat as the default solver.
  • Included solver=<selected solver> in the existing /optimize FormData.
  • Kept the existing backend, SSE flow, XLSX download flow, timeout, prettify, and YAML behavior unchanged.
  • Did not expose pulp/cbc in 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/cuopt requires 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

    • Added a solver selection dropdown to the Optimize and Export page.
    • Users can now choose between CPU and GPU solver options before starting an optimization.
    • The selected solver is included in the optimization request.
  • Tests

    • Updated coverage to verify the solver dropdown options, default selection, and submitted request data.

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Adds a Solver selection dropdown to the Optimize and Export page, introducing a solverArg state defaulting to ortools/cp-sat, including it in the optimization request FormData as solver, and updates the existing test to verify solver options and the submitted payload.

Changes

Solver Selection Feature

Layer / File(s) Summary
Solver state, UI, and payload wiring
web-frontend/src/app/optimize-and-export/page.tsx
Adds solverArg state (default ortools/cp-sat), a "Solver" dropdown with OR-Tools/CP-SAT and PuLP/cuOpt options, and appends solver field to the optimization request FormData.
Solver dropdown and payload test coverage
web-frontend/src/app/optimize-and-export/page.test.tsx
Updates the optimization workflow test to assert default solver value, verify available/excluded solver options, select pulp/cuopt, and validate the POST request FormData contains solver = 'pulp/cuopt'.

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
Loading

Poem

A dropdown hops into the scene,
OR-Tools or cuOpt, pick your machine!
I nibble a carrot, submit the form,
Solver in FormData, safe and warm.
Hop, test, and check — all tests confirm! 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding solver selection to the optimize page.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
web-frontend/src/app/optimize-and-export/page.tsx (1)

275-275: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider a typed union for solver values.

solverArg is inferred as string, 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

📥 Commits

Reviewing files that changed from the base of the PR and between 8bbb152 and dadd623.

📒 Files selected for processing (2)
  • web-frontend/src/app/optimize-and-export/page.test.tsx
  • web-frontend/src/app/optimize-and-export/page.tsx

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