Skip to content

feat(action-card): SLD chips for line openings, the PST card shows its start tap - #228

Merged
marota merged 2 commits into
ainetus:mainfrom
marota:feat/action-card-branch-chips-tap-start
Nov 25, 2026
Merged

marota merged 2 commits into
ainetus:mainfrom
marota:feat/action-card-branch-chips-tap-start

Conversation

@marota

@marota marota commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Two gaps on the unfolded action card, reported on the deployed Space after #227:

  1. Branch actions had no SLD chip — couplings, transformers, phase shifters, loads and productions did, but a line opening offered none (feat(action-card): SLD chip after the description, for couplers and transformers too #226 left it out: "a line has two substations and no obvious one").
  2. The PST card did not show the tap it starts from. The editor shows the tap the action sets (tap: [29] [0..32]), while the Manual Selection table has the Tap Start column.

Changes

Line openings get their SLD chips (utils/actionLabels.ts): the unfolded card offers the voltage levels at both ends of every branch the title names — line, transformer or PST — resolved through the NAD metadata (so once the diagram is loaded). A voltage level two branches share is offered once: the combined BERG9L61CANTE + CANTEL61MARSI opening shows BERG9 225kV · CANTE 225kV · MARSI 225kV.

The PST card shows its start tap (ActionCard.tsx, backend):

  • compute_pst_details takes the taps snapshotted at network load (_initial_pst_taps) as an optional argument and sets pst_details[].tap_start per PST — the N-state tap before the action. The key is left out when unknown.
  • The card reads tap: [29] [0..32] start 24 (tooltip: the phase shifter's tap before the action (N state)).
  • Because it rides on pst_details, it follows the action through manual simulation, combined actions and session save / reload with no extra plumbing (sessionUtils / useSession copy the array as is). A session saved before this change simply shows no start tap.

Fix found while trying it on the real grid (317b2af): the card first showed start 0 for .ARKA TD 661 where the Manual Selection table shows 27. Cause: _capture_initial_pst_taps read tap_position / low_tap_position / high_tap_position, columns pypowsybl's get_phase_tap_changers() does not have (they are tap / low_tap / high_tap, as NetworkManager.get_pst_tap_info reads them), so every PST was snapshotted at tap 0 with no bounds. That bug predates this PR; the table hid it by reading the recommender's previous tap first, but the snapshot is also the fallback of the table's tap_start and of the un-simulated pin tooltip. read_pst_taps (analysis/mw_start_scoring.py) now reads the right columns and leaves a PST with no tap out of the snapshot instead of inventing a 0. Checked on the France 2024-08-28 grid: .ARKA TD 661 → 27 [0..32], PRAGNY661 → 19, the table's values.

Docs: action-card.md, save-results.md, interaction-logging.md, curtailment-loadshedding-pst-actions.md, changelog.

Test plan

  • backend: new specs for compute_pst_details (per-PST start tap incl. 0, unknown start), the mixin wiring and the tap snapshot (pypowsybl's column names, a real tap of 0 kept, a PST without a tap left out — they fail on the previous code); full pytest 1403 passed, 5 skipped
  • on the France 2024-08-28 grid with the py310 venv: snapshot .ARKA TD 661 → 27, pst_details carries tap_start: 27
  • scripts/check_openapi_contract.py — contract unchanged (pst_details is not in the snapshot)
  • tsc -b, eslint on the touched files
  • full Vitest suite: 2223 passed, 3 skipped
  • scripts/check_code_quality.py — gate OK
  • layout checked in headless Chrome: combined branch opening with three chips, PST card with and without tap_start
  • not run against a live backend with the France 2025 situation

expert_backend/tests/test_stream_pdf_integration.py::test_stream_pdf_integration fails with a 422 on run-analysis-step1; it fails the same way on untouched main (244e45a), so it is excluded from the run above and unrelated to this PR.

Choices worth a look

  • Start tap source: _initial_pst_taps (snapshot at network load), not the previous tap the score table prefers. With the snapshot fixed both give the N-state tap (27 and 19 on the two PSTs checked); the card does not depend on the recommender's score params, so it also works for a manually simulated PST.
  • Both ends for every line: the alternative is one chip for the branch itself (zoom only, the title link already does it); both end voltage levels keep the chips uniform with transformers and PSTs.
  • MW start (shed / curtail / redispatch) is still not on the card; it has the same shape of fix if wanted.

🤖 Generated with Claude Code

Antoine Marot and others added 2 commits November 24, 2026 10:40
…s start tap

Two gaps on the unfolded action card:

- a line opening offered no SLD chip (only couplings, transformers, phase
  shifters, loads and productions did). It now offers the voltage levels at
  both ends of every branch the title names — line, transformer or PST — a
  voltage level two branches share being offered once. They come from the
  NAD metadata, so they appear once the diagram is loaded
- the PST editor showed the tap the action sets but not the one it starts
  from (the Manual Selection table has it as "Tap Start"). The backend now
  sends it as pst_details[].tap_start — the N-state tap snapshotted at
  network load (_initial_pst_taps), per PST — so it follows the action
  through manual simulation, combined actions and session save / reload.
  The card reads "tap: [29] [0..32] start 24"; the key is left out when the
  start tap is unknown and on sessions saved before it existed

compute_pst_details takes the initial taps as an optional argument, so
existing callers are unchanged. Specs for the branch chips (single line,
combined, no metadata yet), the start tap (shown, 0, absent) and the
backend (per-PST start tap, unknown start); docs/features/action-card.md,
save-results.md, interaction-logging.md and the changelog follow.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Antoine Marot <amarot91@gmail.com>
_capture_initial_pst_taps read tap_position / low_tap_position /
high_tap_position, columns get_phase_tap_changers() does not have (they are
tap / low_tap / high_tap, as NetworkManager.get_pst_tap_info reads them), so
every PST was snapshotted at tap 0 with no bounds. The PST card's new
"start" showed that 0 (.ARKA TD 661: 0 instead of 27); the snapshot is also
the fallback of the Manual Selection table's tap_start and of the
un-simulated pin tooltip, where it hid behind the recommender's
"previous tap".

- read_pst_taps (analysis/mw_start_scoring.py, next to get_pst_tap_start)
  does the read, with the right columns; a PST without a tap is left out
  rather than given a made-up 0, so the readers fall back on the live
  network. _capture_initial_pst_taps delegates to it (also keeps
  recommender_service.py under its module-size ceiling)
- specs with pypowsybl's column names: tap and bounds read, a real tap of 0
  kept, a PST with no tap left out; they fail on the previous code
- checked on the France 2024-08-28 grid: .ARKA TD 661 -> 27 [0..32],
  PRAGNY661 -> 19, as the Manual Selection table; pst_details carries
  tap_start 27

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Antoine Marot <amarot91@gmail.com>
@marota
marota merged commit 04d6005 into ainetus:main Nov 25, 2026
6 checks passed
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