Skip to content

Add visual highlighting for overloaded lines and action targets - #9

Merged
marota merged 27 commits into
mainfrom
claude/highlight-overloaded-lines-GAVr6
Feb 20, 2026
Merged

marota merged 27 commits into
mainfrom
claude/highlight-overloaded-lines-GAVr6

Conversation

@marota

@marota marota commented Feb 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR adds visual highlighting to network diagrams to help users identify overloaded transmission lines and the specific assets affected by selected actions. Overloaded lines are highlighted in orange, while assets targeted by actions receive a yellow fluorescent halo effect.

Key Changes

  • CSS Styling: Added .nad-overloaded and .nad-action-target classes to standalone_interface.html and App.css for orange highlighting and yellow halo effects respectively
  • Metadata Indexing: Implemented buildMetadataIndex() function to create efficient lookups from equipment IDs to SVG element IDs for both nodes and edges
  • Overload Highlighting: Added applyOverloadedHighlights() function to highlight lines exceeding 100% capacity in orange on N-1 and action diagrams
  • Action Target Detection: Implemented getActionTargetLines() to identify line-only actions (disconnections/reconnections) and getActionTargetVoltageLevel() to extract voltage level names from action descriptions for nodal actions
  • Action Target Highlighting: Added applyActionTargetHighlights() function to apply yellow halo to either line edges (for line actions) or voltage level nodes (for nodal actions)
  • React Integration: Added useEffect hook in VisualizationPanel.tsx to apply highlights based on selected action and overloaded lines data
  • Backend Enhancement: Modified recommender_service.py to extract and include action topology (lines_ex_bus, lines_or_bus, gens_bus, loads_bus) in the enriched action data
  • Type Definitions: Added ActionTopology interface to types.ts and extended ActionDetail to include topology information

Implementation Details

  • Highlights are dynamically applied/cleared based on selected action and diagram state
  • The system distinguishes between line-only actions (all values are -1 or only lines are affected) and nodal actions
  • Overload detection considers both initial overloaded lines and new overloads introduced by the action (via max_rho and max_rho_line)
  • SVG element selection uses equipment ID to SVG ID mapping from diagram metadata for reliable element targeting
  • Resolved merge conflict in standalone_interface.html by keeping both polyline and rect selectors in the vector-effect rule

https://claude.ai/code/session_01SWK3HZHgMPeghUrSmmjpV1

claude and others added 19 commits February 16, 2026 19:37
Use SVG metadata edge mappings to find overloaded line elements by
equipmentId and apply a .nad-overloaded CSS class (orange stroke) to
their SVG edge groups. Applied in both the standalone interface
(N-1 + Action tabs) and the React frontend (Action tab).

https://claude.ai/code/session_01SWK3HZHgMPeghUrSmmjpV1
For N-1 tab, all initially overloaded lines stay orange. For the
Action tab, filter to lines whose rho_after > 1.0, and include
max_rho_line if it is a new line above 100%.

https://claude.ai/code/session_01SWK3HZHgMPeghUrSmmjpV1
For line disconnection/reconnection actions, detect the target lines
from the action topology (lines_ex_bus/lines_or_bus with no gen/load
changes) and highlight their edges in yellow fluo (#ccff00).

Backend: extract action_topology (lines_ex_bus, lines_or_bus,
gens_bus, loads_bus) from the action object and send to frontend.

Frontend: detect line-only actions and apply .nad-action-target class
to SVG edge elements in both standalone and React interfaces.

https://claude.ai/code/session_01SWK3HZHgMPeghUrSmmjpV1
Replace stroke override with drop-shadow filter so the line keeps
its original color and gains a yellow glow around it.

https://claude.ai/code/session_01SWK3HZHgMPeghUrSmmjpV1
For nodal actions (not line-only), extract the voltage level name from
the last single-quoted string in description_unitaire and apply the
yellow fluo halo to the VL node's outer circle via .nad-action-target.

Also extends the CSS selector to include circle elements for the
drop-shadow filter.

https://claude.ai/code/session_01SWK3HZHgMPeghUrSmmjpV1
Three fixes for nodal action highlighting:

1. Couplers (e.g. COUCHP6_COUCH6COUPL) appear in lines_*_bus but are
   not diagram edges. Now verify topology line keys exist as actual
   edges in metadata before treating as a line action; otherwise fall
   through to VL node detection.

2. Parse unquoted "dans le poste VLNAME" in addition to quoted format.

3. When description is missing ("No description available"), fall back
   to extracting VL name from the action ID suffix (last _-segment),
   validated against metadata nodes.

https://claude.ai/code/session_01SWK3HZHgMPeghUrSmmjpV1
Couplers (e.g. COUCHP6_COUCH6COUPL) exist as edges in the NAD
metadata, so the previous "verify against edges" check passed and
highlighted them instead of the VL node.

Fix: always try VL detection first (from description or action ID
suffix). Only fall back to topology-based edge highlighting if no
VL node is found. This ensures coupler/nodal actions always get the
halo on the VL circle.

https://claude.ai/code/session_01SWK3HZHgMPeghUrSmmjpV1
Temporary console.log to debug why COUCHP6/PYMONP3/VIELMP6 halos
are not rendering correctly. Logs VL candidates, metadata lookups,
and SVG element hits.

https://claude.ai/code/session_01SWK3HZHgMPeghUrSmmjpV1
… existing in it, to be able to manually add and simulate them
@marota marota mentioned this pull request Feb 19, 2026
26 of 27 tasks
@marota
marota merged commit 5f3dc7e into main Feb 20, 2026
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.

2 participants