Skip to content

FIX: Guard preset save races - #3819

Open
Roman Lutz (romanlutz) wants to merge 3 commits into
microsoft:mainfrom
romanlutz:romanlutz-preset-selection-guard
Open

Roman Lutz (romanlutz) wants to merge 3 commits into
microsoft:mainfrom
romanlutz:romanlutz-preset-selection-guard

Conversation

@romanlutz

@romanlutz Roman Lutz (romanlutz) commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Description

Switching scenarios in the preset editor could leave the previous scenario and configuration available to Save while the new metadata was loading.

Fixes #3755

Track the selected scenario separately from its resolved metadata. Disable and guard Save until the selected configuration is ready, including programmatic submits fired before React commits the selection change. Ignore outdated metadata responses after another selection or unmount. Failed loads retain the selection and show the existing error UI; already accepted saves are left alone.

This is limited to the selection/save race. Shared preset/form serialization, loaded-list values, and launch behavior are unchanged.

Tests and Documentation

Added focused regressions for pending replacements, direct and same-event submissions, reversed responses, failure/retry, navigation/unmount, accepted saves, and edit-mode list preservation. Following review, removed the added loading/error detail to keep the GUI guide high level.

Implementation validation below ran on 4fd746a72eb536f749396000363239ec98afc7f0 before opening this PR. The documentation-only follow-up passed uv run --no-sync python -m build_scripts.validate_docs (169 references, no orphaned files) and commit hooks. Frontend commands below ran from frontend.

npm test -- --runInBand --runTestsByPath src\components\ScenarioPresets\ScenarioPresetEditor.test.tsx src\components\ScenarioPresets\scenarioPresetForm.test.ts src\components\Parameters\parameterForm.test.ts src\components\Scenarios\ScenarioDetail.test.tsx --silent

Passed: 4 suites, 287 tests. Includes the existing ScenarioDetail and shared preset/form parameter coverage.

Command Result
npm run type-check Passed
npm exec -- tsc --noEmit --project tsconfig.test.json Passed
npm exec -- eslint src\components\ScenarioPresets\ScenarioPresetEditor.tsx src\components\ScenarioPresets\ScenarioPresetEditor.test.tsx --report-unused-disable-directives --max-warnings 0 Passed
npm run build Passed; compatibility stamps matched the tested implementation commit
npm exec -- playwright test numeric-controls.spec.ts --project mock --workers 1 --grep "scenario steppers|native shared dynamic parameter controls step once" --reporter=list

Passed: 5 existing offline browser tests. A separate offline Chromium check against the built editor also passed at 1440x1000 and 390x844, covering keyboard selection, pending submissions, reversed responses, error retention, and retry. These were fixture-backed browser observations, not live backend saves. All verification helpers are stopped.

JupyText: Not run; no notebook or Python documentation changes.

Keep the selected scenario separate from resolved metadata and reject superseded requests, including programmatic submits before selection state commits. Preserve failed selections, loaded preset values, and already accepted saves.

Fixes microsoft#3755

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 2, 2026 08:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues were identified for the change addressing stale-scenario saves in the preset editor.

No open issues 🎉

What changed in this PR

Addresses #3755 by preventing the preset editor from saving the previous scenario’s configuration while a new selection loads.

Changes:

  • Tracks the selected scenario separately from loaded metadata, guards submissions, and ignores stale responses.
  • Adds regression coverage for selection races, failures and retries, unmounting, accepted saves, and stored list preservation.
  • Documents Save availability and failed-load behavior without changing shared serialization or launch behavior.
File Description
frontend/​src/​components/​ScenarioPresets/​ScenarioPresetEditor.tsx Adds selection tracking, request guards, and Save readiness checks.
frontend/​src/​components/​ScenarioPresets/​ScenarioPresetEditor.test.tsx Covers race conditions and preservation of existing save behavior.
doc/​gui/​0_gui.md Explains loading and failure behavior in the preset editor.

Review effort: Balanced

Comment thread doc/gui/0_gui.md Resolved
Remove preset loading and error details from the overview.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

# Conflicts:
#	frontend/src/components/ScenarioPresets/ScenarioPresetEditor.test.tsx

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Automated review completed. No blocking concerns remain. This review records source coverage; it does not authorize merge.

This branch has not been deployed

No deployments
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.

Saving during a scenario switch creates the preset for the previous scenario

3 participants