Skip to content

Adaptation to moving DS Params to DS server#3827

Open
thangqp wants to merge 2 commits intomainfrom
ds_moving_param_to_ds_server
Open

Adaptation to moving DS Params to DS server#3827
thangqp wants to merge 2 commits intomainfrom
ds_moving_param_to_ds_server

Conversation

@thangqp
Copy link
Contributor

@thangqp thangqp commented Mar 20, 2026

PR Summary

  • Do not send overriding parameters Json to back
  • Adapt types of params with field id

Signed-off-by: Thang PHAM <phamthang37@gmail.com>
@coderabbitai
Copy link

coderabbitai bot commented Mar 20, 2026

📝 Walkthrough

Walkthrough

This pull request refactors the dynamic simulation configuration flow by removing automatic parameter passing through callbacks, introducing mapping-based model filtering, and adopting type-safe solver selection via an updated SolverType enum instead of string-based identifiers.

Changes

Cohort / File(s) Summary
Solver Type System
src/services/study/dynamic-simulation.type.ts, src/components/dialogs/parameters/dynamicsimulation/dynamic-simulation-utils.ts
Renamed SolverTypeInfos enum to SolverType; changed CommonSolverInfos.id from string to UUID; updated DynamicSimulationParametersInfos to use solver: SolverType instead of solverId: string.
Solver Form Handling
src/components/dialogs/parameters/dynamicsimulation/solver-parameters.tsx, src/components/dialogs/parameters/dynamicsimulation/dynamic-simulation-parameters.tsx
Updated solver form field key from Solver.ID ('solverId') to Solver.SOLVER ('solver'); changed solver selection logic to match by type instead of id; updated dependency tracking and TabPanel indexing to use SolverType values.
Parameter Callback Refactoring
src/components/dialogs/dynamicsimulation/dynamic-simulation-parameters-selector.tsx, src/components/run-button-container.jsx
Changed onStart callback from (params: any) => void to () => void; removed passing dynamicSimulationConfiguration through the start flow; updated handleStartDynamicSimulation to accept only debug parameter.
Mapping Parameter Threading
src/components/dialogs/parameters/dynamicsimulation/curve-parameters.tsx, src/components/dialogs/parameters/dynamicsimulation/curve/dialog/curve-selector-dialog.tsx, src/components/dialogs/parameters/dynamicsimulation/curve/dialog/curve-selector.tsx, src/components/dialogs/parameters/dynamicsimulation/curve/dialog/model-filter.tsx
Added optional mapping parameter through component chain; CurveParameters now accepts mappingPath prop and retrieves mapping value; ModelFilter uses mapping in fetchDynamicSimulationModels call and includes mapping in fetch dependency list.
Service Layer Updates
src/services/study/dynamic-simulation.ts
Removed dynamicSimulationConfiguration parameter from startDynamicSimulation function and POST request body; updated fetchDynamicSimulationModels to require mapping parameter and conditionally add it as query parameter.
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adapting the codebase to move Dynamic Simulation parameters to the DS server, removing parameter override passing.
Description check ✅ Passed The description is related to the changeset, covering the key objectives: stopping parameter JSON being sent to backend and adapting parameter types.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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 and usage tips.

Tip

CodeRabbit can use Trivy to scan for security misconfigurations and secrets in Infrastructure as Code files.

Add a .trivyignore file to your project to customize which findings Trivy reports.

Signed-off-by: Thang PHAM <phamthang37@gmail.com>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/components/dialogs/parameters/dynamicsimulation/dynamic-simulation-parameters.tsx (1)

175-175: Unnecessary type assertion.

If the form is properly typed, newParams.solver.solver should already be of type SolverType. The as SolverType cast may be masking a typing issue in the form schema.

♻️ Suggested fix
-[Solver.SOLVER]: newParams.solver.solver as SolverType,
+[Solver.SOLVER]: newParams.solver.solver,

If this causes a type error, the form schema definition should be updated to properly type the solver field.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/components/dialogs/parameters/dynamicsimulation/dynamic-simulation-parameters.tsx`
at line 175, The assignment using the unnecessary type assertion "as SolverType"
on newParams.solver.solver (mapped to Solver.SOLVER) masks a typing problem;
remove the cast and ensure the form schema/types declare the solver field as
SolverType (or update the type of newParams/newParams.solver) so
newParams.solver.solver is already SolverType at compile time; adjust the form
field type definition or the interface that defines newParams (and any related
form schema/type for the solver field) instead of keeping the runtime cast.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/components/dialogs/parameters/dynamicsimulation/curve-parameters.tsx`:
- Around line 179-186: The CurveSelectorDialog is passing
mapping={getValues(mappingPath)} which may be an empty string and ModelFilter
uses nullish coalescing (??) so empty strings reach
fetchDynamicSimulationModels; update the value passed to CurveSelectorDialog (or
inside ModelFilter) to normalize falsy/empty-string mappings to undefined/null
before calling fetchDynamicSimulationModels (i.e., coerce getValues(mappingPath)
with a check such as mappingValue => mappingValue ? mappingValue : undefined) so
fetchDynamicSimulationModels receives a clear "no mapping" sentinel; search for
CurveSelectorDialog, getValues(mappingPath), ModelFilter, and
fetchDynamicSimulationModels to apply this normalization.

In `@src/components/dialogs/parameters/dynamicsimulation/solver-parameters.tsx`:
- Around line 61-66: The TabPanel children use hardcoded indices ([0] and [1])
which can write form data to the wrong solver; compute the actual index of
selectedSolver (e.g., using solvers.findIndex(s => s === selectedSolver) with a
safe default) and use that index in the form path passed to IdaSolverParameters
and SimplifiedSolverParameters instead of the literal 0/1 so the path becomes
${path}.${Solver.SOLVERS}[selectedSolverIndex]; update references to
selectedSolver, Solver.SOLVERS, IdaSolverParameters, and
SimplifiedSolverParameters accordingly.

---

Nitpick comments:
In
`@src/components/dialogs/parameters/dynamicsimulation/dynamic-simulation-parameters.tsx`:
- Line 175: The assignment using the unnecessary type assertion "as SolverType"
on newParams.solver.solver (mapped to Solver.SOLVER) masks a typing problem;
remove the cast and ensure the form schema/types declare the solver field as
SolverType (or update the type of newParams/newParams.solver) so
newParams.solver.solver is already SolverType at compile time; adjust the form
field type definition or the interface that defines newParams (and any related
form schema/type for the solver field) instead of keeping the runtime cast.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3f6717a2-b985-4e39-9972-0e85f6061a79

📥 Commits

Reviewing files that changed from the base of the PR and between 275edae and dcca8dd.

📒 Files selected for processing (11)
  • src/components/dialogs/dynamicsimulation/dynamic-simulation-parameters-selector.tsx
  • src/components/dialogs/parameters/dynamicsimulation/curve-parameters.tsx
  • src/components/dialogs/parameters/dynamicsimulation/curve/dialog/curve-selector-dialog.tsx
  • src/components/dialogs/parameters/dynamicsimulation/curve/dialog/curve-selector.tsx
  • src/components/dialogs/parameters/dynamicsimulation/curve/dialog/model-filter.tsx
  • src/components/dialogs/parameters/dynamicsimulation/dynamic-simulation-parameters.tsx
  • src/components/dialogs/parameters/dynamicsimulation/dynamic-simulation-utils.ts
  • src/components/dialogs/parameters/dynamicsimulation/solver-parameters.tsx
  • src/components/run-button-container.jsx
  • src/services/study/dynamic-simulation.ts
  • src/services/study/dynamic-simulation.type.ts

Comment on lines +179 to +186
{open && (
<CurveSelectorDialog
open={open}
onClose={handleClose}
onSave={handleAppend}
mapping={getValues(mappingPath)}
/>
)}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Potential issue: Empty string may not be handled as expected.

When the form initializes, mapping defaults to an empty string (''). The nullish coalescing operator (??) in ModelFilter passes empty strings through to fetchDynamicSimulationModels rather than converting them to null. If the backend API distinguishes between empty string and null for "no mapping selected", this could cause unexpected behavior.

Consider explicitly converting empty/falsy values to undefined:

 <CurveSelectorDialog
     open={open}
     onClose={handleClose}
     onSave={handleAppend}
-    mapping={getValues(mappingPath)}
+    mapping={getValues(mappingPath) || undefined}
 />
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{open && (
<CurveSelectorDialog
open={open}
onClose={handleClose}
onSave={handleAppend}
mapping={getValues(mappingPath)}
/>
)}
{open && (
<CurveSelectorDialog
open={open}
onClose={handleClose}
onSave={handleAppend}
mapping={getValues(mappingPath) || undefined}
/>
)}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/dialogs/parameters/dynamicsimulation/curve-parameters.tsx`
around lines 179 - 186, The CurveSelectorDialog is passing
mapping={getValues(mappingPath)} which may be an empty string and ModelFilter
uses nullish coalescing (??) so empty strings reach
fetchDynamicSimulationModels; update the value passed to CurveSelectorDialog (or
inside ModelFilter) to normalize falsy/empty-string mappings to undefined/null
before calling fetchDynamicSimulationModels (i.e., coerce getValues(mappingPath)
with a check such as mappingValue => mappingValue ? mappingValue : undefined) so
fetchDynamicSimulationModels receives a clear "no mapping" sentinel; search for
CurveSelectorDialog, getValues(mappingPath), ModelFilter, and
fetchDynamicSimulationModels to apply this normalization.

Comment on lines +61 to 66
<TabPanel value={selectedSolver?.type} index={SolverType.IDA}>
<IdaSolverParameters path={`${path}.${Solver.SOLVERS}[0]`} />
</TabPanel>
<TabPanel value={selectedSolver?.type} index={SolverTypeInfos.SIM}>
<TabPanel value={selectedSolver?.type} index={SolverType.SIM}>
<SimplifiedSolverParameters path={`${path}.${Solver.SOLVERS}[1]`} />
</TabPanel>
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for solver array construction or ordering guarantees
rg -n -C3 'solvers' --type=ts --glob '**/*dynamic-simulation*' | head -100

Repository: gridsuite/gridstudy-app

Length of output: 7662


🏁 Script executed:

cat -n src/components/dialogs/parameters/dynamicsimulation/solver-parameters.tsx | head -100

Repository: gridsuite/gridstudy-app

Length of output: 3170


🏁 Script executed:

# Look for how solvers are fetched/initialized from backend
rg -n "getSolverParameters|fetchSolver|parameters.*solvers" --type=ts --glob '**/*dynamic-simulation*' | head -50

Repository: gridsuite/gridstudy-app

Length of output: 528


🏁 Script executed:

# Check SolverInfos type definition and how it's structured
rg -n "SolverInfos\|type SolverInfos\|interface SolverInfos" --type=ts | head -30

Repository: gridsuite/gridstudy-app

Length of output: 49


🏁 Script executed:

rg -A 5 "type SolverInfos|interface SolverInfos" --type=ts

Repository: gridsuite/gridstudy-app

Length of output: 453


🏁 Script executed:

# Also check how selectedSolver is used in the code
rg -n "selectedSolver" src/components/dialogs/parameters/dynamicsimulation/solver-parameters.tsx

Repository: gridsuite/gridstudy-app

Length of output: 268


🏁 Script executed:

# Check the IdaSolverParameters and SimplifiedSolverParameters to understand what they expect
head -50 src/components/dialogs/parameters/dynamicsimulation/solver/ida-solver-parameters.tsx

Repository: gridsuite/gridstudy-app

Length of output: 1425


🏁 Script executed:

# Search for backend API calls that return solvers
rg -n "getDynamicSimulationParameters|getSolverParameters" --type=ts -A 5 | head -50

Repository: gridsuite/gridstudy-app

Length of output: 49


🏁 Script executed:

# Check dynamic-simulation service to see how solvers are fetched
rg -n "solvers" src/services/study/dynamic-simulation.ts | head -30

Repository: gridsuite/gridstudy-app

Length of output: 49


🏁 Script executed:

# Look at the initial data structure and how solvers array is set up
rg -n "getSolverInfos\|solvers.*=" --type=ts | head -40

Repository: gridsuite/gridstudy-app

Length of output: 49


🏁 Script executed:

# Look at the complete type definitions
rg -A 15 "type IdaSolverInfos|type SimSolverInfos" --type=ts

Repository: gridsuite/gridstudy-app

Length of output: 1902


🏁 Script executed:

# Check the form schema and how solvers are validated
rg -n "solverFormSchema\|SolverInfos" src/components/dialogs/parameters/dynamicsimulation/dynamic-simulation-utils.ts -A 10 | head -60

Repository: gridsuite/gridstudy-app

Length of output: 49


🏁 Script executed:

# Search for where solvers array is actually constructed or initialized
rg -n "solvers.*\[\|new.*solvers\|solvers.*push\|solvers.*concat" --type=ts | head -40

Repository: gridsuite/gridstudy-app

Length of output: 49


🏁 Script executed:

# Check for any test files or comments about solver ordering
fd -e test.ts -e spec.ts -e test.tsx -e spec.tsx | xargs grep -l "solvers\|SolverType" 2>/dev/null | head -5

Repository: gridsuite/gridstudy-app

Length of output: 49


🏁 Script executed:

# Look at how the form handles solver updates to understand the data flow
rg -B 5 -A 15 "newParams.solver.solvers" src/components/dialogs/parameters/dynamicsimulation/dynamic-simulation-parameters.tsx

Repository: gridsuite/gridstudy-app

Length of output: 888


🏁 Script executed:

# Check if there's a backend configuration or constant that defines solver order
rg -n "SolverType\." src/services/study/dynamic-simulation.type.ts -B 2 -A 2 | head -40

Repository: gridsuite/gridstudy-app

Length of output: 318


🏁 Script executed:

# Look at the enum definition for SolverType
rg -B 5 -A 10 "enum SolverType" --type=ts

Repository: gridsuite/gridstudy-app

Length of output: 1185


🏁 Script executed:

# Check if the component receives solvers in a guaranteed order from parent
rg -B 10 -A 5 "SolverParameters.*solvers\|solver.*solvers" src/components/dialogs/parameters/dynamicsimulation/dynamic-simulation-parameters.tsx | head -60

Repository: gridsuite/gridstudy-app

Length of output: 49


🏁 Script executed:

# Look at the complete parent component to see how SolverParameters is used
sed -n '250,290p' src/components/dialogs/parameters/dynamicsimulation/dynamic-simulation-parameters.tsx

Repository: gridsuite/gridstudy-app

Length of output: 2025


🏁 Script executed:

# Verify that selectedSolver has all needed properties and confirm the bug
rg -A 20 "const selectedSolver = useMemo" src/components/dialogs/parameters/dynamicsimulation/solver-parameters.tsx

Repository: gridsuite/gridstudy-app

Length of output: 667


Use the actual index of the selected solver instead of hardcoded indices.

The current implementation has a logic mismatch: selectedSolver is correctly identified by type matching (via .find()), and the TabPanel visibility is correctly based on selectedSolver?.type. However, the form paths passed to child components ([0] and [1]) assume IDA is always at index 0 and SIM is always at index 1. If the backend returns solvers in a different order, the correct parameter panel would display but form updates would target the wrong solver, causing data to be written to the wrong solver type.

Since selectedSolver is already available, find its actual index and use it in the paths:

const selectedSolverIndex = solvers?.findIndex(s => s === selectedSolver) ?? 0;

Then pass this index to the child components instead of hardcoding [0] and [1].

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/dialogs/parameters/dynamicsimulation/solver-parameters.tsx`
around lines 61 - 66, The TabPanel children use hardcoded indices ([0] and [1])
which can write form data to the wrong solver; compute the actual index of
selectedSolver (e.g., using solvers.findIndex(s => s === selectedSolver) with a
safe default) and use that index in the form path passed to IdaSolverParameters
and SimplifiedSolverParameters instead of the literal 0/1 so the path becomes
${path}.${Solver.SOLVERS}[selectedSolverIndex]; update references to
selectedSolver, Solver.SOLVERS, IdaSolverParameters, and
SimplifiedSolverParameters accordingly.

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