Skip to content

Fix SLD highlighting for manual actions - #72

Merged
marota merged 12 commits into
mainfrom
feature/renewable-curtailment-integration
Apr 1, 2026
Merged

marota merged 12 commits into
mainfrom
feature/renewable-curtailment-integration

Conversation

@marota

@marota marota commented Apr 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR resolves a persistent issue where manually simulated renewable curtailment and load shedding actions failed to trigger Single Line Diagram (SLD) highlighting. It also aligns the manual action metadata and presentation with the automated "suggested" actions for a consistent user experience.

Key Changes

Backend (recommender_service.py)

  • Enriched Simulation Response: simulate_manual_action now includes the action_topology in its immediate response, allowing the frontend to sync state instantly.
  • Rich Descriptions: Manual actions now generate descriptions using the standard quoted format (e.g., 'GEN_NAME' at voltage level 'VL_ID'), which assists the frontend in asset discovery.
  • Global Registry Integration: All manual actions are now registered in the backend's central action dictionary, enabling the SLD generator to identify change-impacted switches.
  • MW Calculation Consistency: Fixed a bug where curtailed/shed MW could sometimes be reported as negative.

Frontend (standalone_interface.html)

  • State Propagation: Updated all manual simulation handlers to correctly propagate action_topology to the application state.
  • Ultra-Robust SLD Highlighting: Implemented a multi-level fuzzy matching logic in findCellForEquipment, including case-insensitive prefix matching and direct SVG text searching, to resolve naming discrepancies between Grid2Op and Pypowsybl.
  • Interactive Asset Badges: Manual actions now display clickable badges for generators, loads, and voltage levels, matching the rich UI of suggested actions.

Verification Results

  • Regression Tests: Added expert_backend/tests/test_manual_action_enrichment.py verifying description enrichment, topology propagation, and registry integration. All tests passed.
  • Manual Verification: Confirmed that simulating curtail_VIELMIN3 results in a yellow glow on the generator in the SLD and a light blue MW box in the action card.

marota added 12 commits April 1, 2026 20:41
- Enrichment: Updated simulate_manual_action to return action_topology and rich descriptions (quotes + VL IDs).
- Registry: Ensured manual actions are registered in the global self._dict_action for SLD generation.
- Frontend: Propagated action_topology in all simulation handlers and robustified findCellForEquipment with fuzzy/SVG matching.
- Testing: Added regression tests in expert_backend/tests/test_manual_action_enrichment.py.
- Fixed missing dependencies in App.tsx useCallback hooks.
- Updated simulateManualAction return type in api.ts to include curtailment_details.
- Removed explicit 'any' cast in ActionFeed.tsx.
- Restored 'content' key in _dict_action for manual actions (required by superposition and tests).
- Added string robustness for description fields to prevent TypeError in ActionClassifier.
- Verified all 17 failing tests pass in a batch run.
- Resolved UnboundLocalError by initializing 'content' and 'topo' before simulation logic.
- Fixed AttributeError by adding dictionary type checks during topology reconstruction.
- Ensured 'action_topology' is always returned for all manual actions (fixes LINE_1_OPEN test).
- Verified all 28 backend tests pass in a single batch run.
@marota
marota merged commit 297bf38 into main Apr 1, 2026
2 checks passed
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
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.

1 participant