Repository navigation
Add SLD impact highlights for contingencies, actions, and overloads - #63
Merged
Merged
Conversation
Add visual highlighting on Single Line Diagrams for contingency elements (orange glow on N-1 tab), action targets (yellow glow on action tab), overloaded lines (dashed orange), and affected breakers/switches (purple glow). Uses SLD metadata to map equipment IDs to SVG elements and walks up to cell ancestors for consistent highlighting. https://claude.ai/code/session_01CWNLrpSw2HRn1qURUo8cYX
Mirror the SLD highlight logic from the React app into the standalone HTML interface: contingency element (orange), action targets (yellow), overloaded lines (dashed orange), and affected breakers (purple). https://claude.ai/code/session_01CWNLrpSw2HRn1qURUo8cYX
…ction Three root causes for highlights not appearing on SLD diagrams: 1. Frontend used selectedActionId prop instead of vlOverlay.actionId to look up the action detail — these can differ. Fixed to use the overlay's own actionId. 2. Backend: grid2op Action objects don't carry a 'switches' attribute, so action_topology.switches was always empty. Added fallback to extract switches from the original action dictionary entry (self._dict_action). Also fixed simulate_manual_action path which only extracted 4 of 7 topology fields. 3. Added substring matching for equipment IDs in SLD metadata (e.g. switch ID "COUCHP6_COUCH6COUPL DJ_OC" containing metadata equipmentId "COUCH6COUPL DJ_OC"). Also added description-based breaker name parsing as fallback for coupling/line opening actions. https://claude.ai/code/session_01CWNLrpSw2HRn1qURUo8cYX
… detection SLD highlights now use background clones instead of directly styling original elements, preserving normal SLD rendering in Flows/Impacts modes. For coupling actions, only the coupling breaker is highlighted (not branches). https://claude.ai/code/session_01CWNLrpSw2HRn1qURUo8cYX
…highlight on action tab - Backend: compare pypowsybl switch states between N-1 and action variants in get_action_variant_sld() to robustly detect changed switches (works for coupling/node-merging actions where grid2op action object lacks switch data) - Frontend: use changed_switches from SLD response as primary source for breaker highlighting, falling back to action_topology.switches - Fix: only show overloaded lines (dashed orange) highlight on N-1 tab, not on action tab where it incorrectly altered non-action branches https://claude.ai/code/session_01CWNLrpSw2HRn1qURUo8cYX
…kers; 18 new tests - Fix highlights disappearing on pan/zoom: replace CTM-based background-layer approach with sibling-clone insertion (clone inserted immediately before its source element, same SVG parent group, so it moves with the source naturally) - Coupling action breaker highlights now use yellow (sld-highlight-action) to match standard action color, instead of purple (sld-highlight-breaker) - Add test_sld_highlight.py: 18 unit tests covering changed_switches diff logic, _enrich_actions switch fallback, coupling detection heuristic, and action_topology field completeness https://claude.ai/code/session_01CWNLrpSw2HRn1qURUo8cYX
marota
pushed a commit
that referenced
this pull request
Apr 30, 2026
Reconciliation of section 2 (0.5.0): - Drop misattributed PRs that were actually pre-rebrand: save/reload (#49/#52), MW Start (#62), interaction-logging (#64), SLD highlights (#63), load shedding initial integration (#61). All now properly cited in section 1.5–1.6. - Disambiguate App.tsx refactor history: PR #56 (hooks, 2100 → 800, pre-rebrand) vs PR #74 (components, 1000 → 650, 0.5.0) vs PR #75 (memoization Phase 2, same LoC). - Add accurate 0.5.0 PRs: #66 (vectorization w/ benchmark table), #69/#70/#71 (UI polish), #72 (curtailment), #73 (loads_p/gens_p format + configurable MW), #74/#75 (App.tsx decomposition), #78 (PST tap re-simulation), #84/#86/#87/#90 (detachable tabs). - Add a recap table summarizing what's truly new in 0.5.0. Diagrams added (Mermaid, GitHub-rendered): - Gantt timeline of all 4 phases (top of doc). - High-level architecture (frontend / backend / data). - Two-step analysis sequence diagram (section 1.6). - App.tsx LoC evolution flow (section 2.4). - Backend mixin decomposition before/after PR #104/#106 (section 3). - PyPSA-EUR pipeline flowchart (section 4). 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 visual highlighting of impacted assets on Single Line Diagrams (SLDs) to help users quickly identify which equipment is affected by contingencies, remedial actions, and overloaded lines. Four distinct visual styles are applied: orange glow for contingency elements, yellow glow for action targets, dashed orange for overloaded lines, and purple glow for affected breakers/switches.
Key Changes
CSS Styling (
App.cssandstandalone_interface.html):.sld-highlight-contingency: Orange glow (#ff9800) for N-1 contingency elements.sld-highlight-action: Yellow glow (#fffb00) for action target equipment.sld-highlight-overloaded: Dashed orange (#ff8c00) for overloaded lines.sld-highlight-breaker: Purple glow (#e040fb) for affected breakers/switchesFrontend Logic (
VisualizationPanel.tsx):useEffecthook to manage SLD impact highlights independently of delta flow coloringBackend Enhancement (
recommender_service.py):pst_tap,substations, andswitchesfieldsswitchesdata from the original action dictionary entry, since grid2op Action objects may not carry this attribute_enrich_actions()andget_action_detail()methodsType Updates:
ActionDetailimport to component type definitionsSldOverlayPropsinterface to includeselectedBranch,result, andselectedActionIdpropsImplementation Details
vlOverlay.actionId(set when overlay opens) rather than component-levelselectedActionIdto ensure consistencyhttps://claude.ai/code/session_01CWNLrpSw2HRn1qURUo8cYX