Repository navigation
Add confirmation dialogs for contingency and study reload - #47
Merged
Merged
Conversation
The previous approach intercepted onChange on the datalist input, which was unreliable because each keystroke triggered the handler with partial text. The new approach intercepts at the N-1 diagram fetch useEffect: when a valid branch is selected and differs from the last committed branch, and analysis state exists, the dialog is shown and the input reverts to the current branch. A committedBranchRef tracks which branch was last confirmed/fetched. https://claude.ai/code/session_01YPX5uG246irRwHisuTu2Jo
Applies the same committedBranchRef pattern to the standalone HTML interface. Uses window.confirm() (matching the existing Load Study and Apply Settings dialogs) to warn the user when switching contingency with existing analysis state. https://claude.ai/code/session_01YPX5uG246irRwHisuTu2Jo
9 test cases covering: - No dialog when switching branch without analysis state - Dialog shown when switching branch after running analysis - State cleared and branch switched on confirm - Input reverts to old branch on cancel - No dialog triggered for partial/invalid branch text - Load Study loads directly with no analysis state - Dialog shown when clicking Load Study after analysis - Study reloads on confirm, state preserved on cancel Also fixes committedBranchRef to not reset when input is temporarily cleared while analysis state exists (allows proper revert on cancel). https://claude.ai/code/session_01YPX5uG246irRwHisuTu2Jo
marota
pushed a commit
that referenced
this pull request
Apr 30, 2026
Rewrites Phase 1 from the abstract CHANGELOG summary into a six-week chronology grounded in PR descriptions: - 1.1 Bootstrap (pre-#1) — scaffolding pushed direct to main - 1.2 End-to-end loop (PRs #1–#15) — NAD scaling, multi-tab pan/zoom, manual actions, action variants, action scoring, svgUtils + usePanZoom - 1.3 UX maturation (PRs #16–#24) — settings panel, OverloadPanel, monitoring factor, action filters, state-switching SLDs - 1.4 Robustness + CI (PRs #25–#46) — backend/frontend test suites, CircleCI + GitHub Actions, lazy loading, divergence UI - 1.5 Persistence + complex actions (PRs #47–#56) — save/reload sessions, combined actions w/ persistence, islanding MW, App.tsx Phase 1 hooks - 1.6 Two-step + replay logging + rebrand (PRs #57–#65) — split analysis, config.json persistence, load shedding, MW Start, SLD highlights, InteractionLogger, ExpertAssist → Co-Study4Grid Sections 2–4 left untouched (will be reconciled in a follow-up). https://claude.ai/code/session_01Pg7fuCUG2edfm5PyHS6SbN
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds confirmation dialogs to prevent accidental loss of analysis state when switching contingencies or reloading the study. The implementation uses a ref-based approach to track the "committed" branch and only prompts when the user attempts to change to a different valid branch while analysis results exist.
Key Changes
Contingency Change Confirmation: When a user selects a different branch after running analysis, a confirmation dialog appears. Confirming clears analysis state and switches branches; canceling reverts the input to the previously committed branch.
Study Reload Confirmation: When clicking "Load Study" after running analysis, a confirmation dialog appears to warn that the network will be reloaded from scratch. Confirming proceeds with reload; canceling preserves the current state.
Committed Branch Tracking: Introduced
committedBranchRefto track the last branch for which N-1 was successfully fetched. This allows the UI to distinguish between:State Management:
hasAnalysisState()helper to detect if any analysis results or manual selections existclearContingencyState()helper to clear analysis-related state while preserving network/config stateComprehensive Test Coverage: Added 347 lines of test cases covering:
Implementation Details
The confirmation logic is now integrated into the
useEffectthat fetches the N-1 diagram. When a valid branch is selected that differs fromcommittedBranchRef.currentand analysis state exists, the dialog is shown and the input is reverted. Only after user confirmation (or if no confirmation was needed) does the branch get committed and the N-1 diagram fetched.Both the React component (
App.tsx) and the standalone HTML interface have been updated with identical logic to maintain consistency.https://claude.ai/code/session_01YPX5uG246irRwHisuTu2Jo