Config Reverting [SYNTH-201]#1425
Conversation
0xda157
left a comment
There was a problem hiding this comment.
there's a lot going on here that seems unrelated to the goal of the pr and makes it quite difficult to review imo. splitting this up into a few commits would make me a lot more confident about reviewing it
| import type SynthesisBrain from "@/systems/simulation/synthesis_brain/SynthesisBrain.ts" | ||
| import type WPILibBrain from "@/systems/simulation/wpilib_brain/WPILibBrain.ts" | ||
|
|
||
| export type BrainType = "synthesis" | "wpilib" | "unknown" |
There was a problem hiding this comment.
is braintype ever unknown? I only seen WPILibBrain and SynthesisBrain as implementations of this class.
|
I had Claude split my commit up into features (as it saw fit). I checked that the diff is the same, and it should be easier for you to review. The groups were made by Claude though, so they are a little off, but I don't think putting more effort into that is a good use of time. |
|
oh didn't mean to close this let me work on that |
Rename the public field to a private `_brainIndexSchemeMap` with a public getter, and add `getBrainIndexSchemeMapping()` alongside the existing `setBrainIndexSchemeMapping()` so all map access goes through explicit methods.
Replace `instanceof` and `brainType ===` checks with narrowing type guards on Brain. Also rename `getPositionTransform` to `getXZPositionTransform` for clarity, add `getRootBody()` helper to MirabufSceneObject, and remove the AutoTestPanel shortcut from the WPILib context menu.
Makes SelectMenu<OptionType> type-safe so callers no longer need to cast `val as SomeSelectionOption`. Removes redundant key prop from ItemCard in ImportMirabufPanel and updates WiringPanel accept text.
Add CleanupRegisterFunction, ConfigurationSubpanelProps, and ConfigurationSubpanelComponent types that all config subpanels will implement. Rename SUBSYSTEMS→JOINT_SUBSYSTEMS and SEQUENTIAL→JOINT_SEQUENCE for clarity. Move the per-configuration-type mode lists (synthesisRobotConfigModes, wpilibRobotConfigModes, fieldConfigModes) out of ConfigurePanel into ConfigTypes.
… system Remove the monolithic ConfigInterface switch and the per-panel originalPrefs refs. Replace with a registerCleanupFunction callback that each subpanel calls to register its own apply/revert logic. ConfigurePanel accumulates these and runs them in FIFO order on accept or LIFO on cancel. Extract MoveInterface and ControlsConfigInterface as standalone subpanel components. Add ConfirmChangesModal for the case where the user navigates away from Controls with unsaved changes.
…a panels Convert each panel to ConfigurationSubpanelComponent and register a revert callback that restores the original value when the user cancels.
Convert ConfigureGamepiecePickupInterface and ConfigureShotTrajectoryInterface to ConfigurationSubpanelComponent and register revert callbacks that restore intake/ejector preferences on cancel.
Convert ConfigureSubsystemsInterface and SequentialBehaviorsInterface to ConfigurationSubpanelComponent with revert callbacks. Fix SubsystemRowInterface to track invertMotor state locally and restrict the unstick-force slider to the drivetrain group only.
Convert ConfigureScoringZonesInterface, ConfigureProtectedZonesInterface, and ConfigureCameraPointsInterface to ConfigurationSubpanelComponent. Each registers a revert callback that restores the original zone/camera point lists and re-syncs the scene on cancel.
Convert SimulationInterface to ConfigurationSubpanelComponent and register a revert callback for SimAutoReconnect. Thread registerCleanupFunction through ConfigureInputsInterface and ConfigureSchemeInterface so input binding changes can also be reverted on cancel.
4bf06af to
68ac376
Compare
AlexD717
left a comment
There was a problem hiding this comment.
The inputs configuration do not revert when opening a panel that closes the configure panel. Also if a panel were to close the configure panel the ConfirmChangesModal should probably open.
Screen.Recording.2026-07-22.at.1.20.37.PM.mov
|
These can't use the "correct" react pattern of setting to new objects because I'm trying to mutate the underlying objects that selectedAssembly and selectedScheme reference. Ideally they would be keyed and the react state is based on that key, but I think that's out of scope for this PR (SYNTH-251 tracks this for schemes) |
|
@AlexD717, rather than try to interrupt the panel closing process, which would be rather obnoxious, I reframed the language and behavior so that save is the default and reverting is explicitly "revert" instead of "cancel." Does that seem like an appropriate way to deal with this? |
2e78e6e to
28a2c4d
Compare
|
That seems reasonable |
AlexD717
left a comment
There was a problem hiding this comment.
lotm
Note: there are some merge conflicts
Task
SYNTH-201
Symptom
Previously, config reverting was somewhat suspicious and didn't always revert everything as would be expected
Solution
Added a
registerCleanupCallbackfunction to all configuration subpanels, which allows revert callbacks to be applied locally within each subpanel. This means each subpanel is responsible for reverting its own changes, making it much clearer what's going on. The system also supports confirm callbacks, but as most changes are applied immediately, this is only used for some memory freeing right now.Verification
Spawn an asset, change config things, and try to find a way to have changes not revert on cancel.
Before merging, ensure the following criteria are met: