Skip to content

Loading % view, readable flow labels and branch hover on the network diagrams + consigned twin on the Context map - #230

Merged
marota merged 15 commits into
ainetus:mainfrom
marota:feat/loading-rate-view
Nov 27, 2026
Merged

marota merged 15 commits into
ainetus:mainfrom
marota:feat/loading-rate-view

Conversation

@marota

@marota marota commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Network diagrams (N, N-1, action): a Loading % view, readable flow labels, a branch hover

  • Views.
    • Each NAD tab reads in MW | Loading % × Flows | Impacts. The two toggles are stacked at the top right, per tab and per window.
    • The N tab has no Flows / Impacts: it is the reference the Impacts compare against.
    • The toggles and the legend keep clear of the kV filter strip, folded or open (--kv-filter-w).
  • Loading %.
    • Each branch end's current is read in % of that end's permanent limit. A line's single-side limit holds for both ends; a transformer's unlimited side has none. RTE grids limit most transformers on side 2 only: CANTEY761 reads [—, 109.1 %].
    • A branch reads its more loaded end: grey below 50 %, five pale yellow → orange steps up to the monitoring factor, vivid orange at or above it.
    • Impacts show the change in percentage points vs N (N-1 tab) or vs N-1 (action tab), orange up / blue down.
  • Readable flow labels (BranchLabelLayer, utils/svg/branchLabels.ts).
    • pypowsybl's user-unit values are specks on a large grid until the operator zooms far in. They are hidden (their arrows stay) and the values are written in 11–12 px pills over the diagram, at any zoom.
    • Placement: one label at the middle of a branch short on screen (its larger end), one per end beside the arrow once the branch is ≥ 180 px.
    • Which branches:
      • Loading %: the coloured branches only.
      • Impacts (MW or Loading %): the significant changes only.
      • MW Flows: the branches long enough on screen.
    • Order: coloured labels first, by value; none over another (collision grid).
    • Voltage colour: every label is outlined in its line's voltage colour, read from the diagram, with a transformer's ends each in their own. MW Flows also writes the value in that colour.
    • Format: loading floored (88%); changes rounded with their sign alone (+40%, -58).
    • Timing: laid out when the view settles (≈ 5–25 ms on the 11 k-branch RTE grid), hidden during a pan / zoom gesture.
  • 🏷 Values toggle beside 🏷 VL: off, no value label at all; the colours and the hover stay.
  • Branch hover (within 8 px, a grid lookup, no hit test of the diagram).
    • Shows both ends: voltage level, MW and loading, plus the Impacts change.
    • Parallel circuits drawn over each other are all listed, the most loaded first.
  • Backend data.
    • Every NAD response, full and patch, carries branch_loading ({branch: [end1 %, end2 %]}) and, for N-1 / action, loading_deltas.
    • The limits are read once per network: ~0.2 s, cached in _side_limits_cache, cleared by reset().
  • Logged: flow_metric_changed { metric, tab, scope } and value_labels_toggled { show }.
  • Fixes on the way.
    • The svgPatch clone of the N diagram drops the N tab's decoration, so it no longer leaks the N labels into the N-1 / action flows. The action overview's clone of the N-1 does the same.
    • The N-1 and action patch paths share one copy of the patch's data fields (patchDiagramFields).

Context tab: a consignation twin of the contingency or of an overload (parallel transformers CANTEY762 / CANTEY761) is pulled aside into the same lens as twin contingency / overload circuits, instead of hiding under the highlight.

Reference doc: docs/features/loading-view-and-flow-labels.md. CHANGELOG, root / frontend / backend CLAUDE.md, the state-reset and canvas-proxy docs are updated. Merged with main after #231, conflict in CHANGELOG resolved by keeping both sections.

Test plan

  • pytest expert_backend/tests: 1448 passed; the 2 failures are the ones already on main (test_independent_actions_simulation, test_stream_pdf_integration).
  • npx vitest run: 2284 passed. tsc -b, eslint (no errors), npm run build, scripts/check_code_quality.py and scripts/check_openapi_contract.py are clean.
  • New coverage:
    • per-end / per-side loading and its deltas;
    • the payloads (N diagram, N-1 patch, action patch);
    • the limits cache and its reset;
    • label geometry, texts per view, placement, overlap, voltage colours;
    • the layer's hover, gestures and Values off;
    • the toggles (no Impacts on N, kV strip offset);
    • the legend's Loading scale;
    • patchDiagramFields and the clone reset.
  • Manual check on the RTE 7000 grid (2024-08-28 01:00, contingency ARGIAL71CANTE):
    • zoomed out, the ≥ 50 % branches carry yellow → orange pills and 109 % reads in vivid orange;
    • zoomed in, the labels split per end;
    • the hover lists CANTEY761 (749 / −747 MW, 109.1 %) and its consigned twin CANTEY762;
    • in Impacts, +40.2 / −39.4 pts.
  • Manual check on pypsa_eur_fr225_400 (contingency way_121500507-225):
    • N-1 at 129 / 130 %;
    • load-shedding action at 98 % / 90 %;
    • MW on the N-1 tab shows the N-1 flows.

🤖 Generated with Claude Code

Antoine Marot and others added 5 commits November 26, 2026 15:45
The N, N-1 and action NADs get an MW / Loading % toggle beside Flows /
Impacts, scoped the same way (per tab, per window). In Loading % the
branches read their loading rate - max(|i1|, |i2|) in % of the permanent
limit, as the overload scan - instead of their active power: grey below
50 %, five pale yellow -> orange steps up to the monitoring factor, vivid
orange at or above it; an open branch is greyed too, one without a limit
reads a dash. In Impacts, the loading change vs the reference state (N for
the N-1, N-1 for an action) in percentage points, coloured like the flow
deltas.

Backend: every NAD response (full and patch) carries branch_loading and
loading_deltas. Frontend: utils/svg/loadingVisuals.ts, FlowViewToggles
(extracted from VisualizationPanel, at its size ceiling), the legend, and
the flow_metric_changed interaction event.

Fix on the way: the svgPatch clone of the N diagram, and the action
overview's clone of the N-1, drop the source tab's decoration - otherwise a
decorated N restored its own labels over the N-1 / action flows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Antoine Marot <amarot91@gmail.com>
…rcuit

A consignation whose ends are those of the contingency or of an overload
(parallel transformers, one consigned, the other overloaded - CANTEY762 /
CANTEY761 on the RTE grid) was drawn under the highlight and hidden. It now
joins the lens that already separates twin contingency / overload circuits:
the contingency keeps the middle, then the overloads, and a consignation
moves only beside a highlighted twin.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Antoine Marot <amarot91@gmail.com>
On a large grid pypowsybl's flow values are user-unit specks until the
operator zooms far in. A BranchLabelLayer now writes them in CSS px over
the N, N-1 and action NADs (pypowsybl's text hidden, its arrows kept):
one label at the middle of a branch short on screen - its larger end -
and one beside each arrow once the branch is long enough. Coloured
branches (loaded from 50 %, a significant Impacts change) are labelled
first and always, a grey / MW one once long enough on screen, none over
another. Laid out when the view settles, hidden during a gesture; for MW,
Loading % and Impacts alike.

Hovering a branch (within 8 px, a grid lookup, no hit test of the
diagram) shows both its ends - voltage level, active power, loading - and
its Impacts change; parallel circuits drawn over each other are all
listed, the most loaded first.

branch_loading becomes a pair per branch: each end's current against its
own side's permanent limit (a line's single-side limit holds for both
ends; a transformer's unlimited side has none - RTE grids limit most
transformers on side 2 only). Colour, label and delta use the more loaded
end. The limits are read once per network object.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Antoine Marot <amarot91@gmail.com>
Below the colouring threshold (50 %, or an insignificant change in
Impacts) a branch's loading only crowds the reading: the Loading % view
labels the coloured branches only, the hover still tells the others. MW
keeps its labels on the branches long enough on screen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Antoine Marot <amarot91@gmail.com>
Beside the VL names toggle, `🏷 Values` hides the values the label layer
writes at the middle of the branches short on screen - the zoomed-out
reading - for a lighter view: the colours stay, a branch long enough on
screen still shows its ends' values, and the hover tells any branch. Every
tab and window alike, logged as value_labels_toggled { show }. Both
toggles move to DiagramLabelToggles (VisualizationPanel at its ceiling).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Antoine Marot <amarot91@gmail.com>
Antoine Marot and others added 9 commits November 27, 2026 14:53
- 🏷 Values off now hides every value label, not just the zoomed-out
  mid-branch ones: a light reading at any zoom, the colours and the hover
  stay.
- The N tab has no Flows / Impacts: it is the state the Impacts compare
  against. viewModeForTab('n') is always 'network' and a change for it is
  ignored.
- The two top-right toggles stack one under the other (MW / Loading %,
  then Flows / Impacts) instead of side by side, clear of the panel edge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Antoine Marot <amarot91@gmail.com>
Like the Loading % view, the MW Impacts view now labels the significant
changes only (orange / blue): the grey ones, below 5 % of the largest
change, only crowded the reading - the hover still tells them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Antoine Marot <amarot91@gmail.com>
In MW Flows the branches keep pypowsybl's voltage colours, so their value
labels now read in the same colour (text and outline): each half's
`--nad-vl-color`, read once per voltage class from the mounted diagram, a
transformer's two ends each in their own, the middle label in its larger
end's. The Loading % and Impacts labels keep their scale's colours.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Antoine Marot <amarot91@gmail.com>
The kV filter strip on the diagram's right edge (24 px folded, 62 px
open) covered the right end of the MW / Loading % and Flows / Impacts
toggles and of the legend pill. The diagram area now sets
`--kv-filter-w` to the strip's width, from the same CSS values as the
strip, and those controls offset their right edge by it; in a detached
window, where there is no strip, it is unset and they keep their margin.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Antoine Marot <amarot91@gmail.com>
So the voltage still reads in the Loading % and Impacts views, where the
lines are recoloured by the scale, each value pill is now outlined in its
line's voltage colour (a transformer's ends each in theirs; a middle label
in the colour of the end it reads). MW Flows, where the lines keep their
voltage colours, also writes the value in it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Antoine Marot <amarot91@gmail.com>
The Impacts labels on the map now read rounded, their sign alone telling
up from down (+40%, -58 instead of Δ +40.2%, Δ -58.0); the hover tooltip
keeps the decimal. The voltage-coloured outline of every label goes from
1.5 to 2.5 px.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Antoine Marot <amarot91@gmail.com>
…tch copy

- Backend: the N diagram, the N-1 patch and the action patch each carry
  branch_loading / loading_deltas (the patch paths are the frontend's
  default, not only the helpers were covered).
- Frontend: the N-1 and action svgPatch paths copied the patch's data
  fields by hand, each its own list; patchDiagramFields is now the one
  copy, tested field by field, so a field the patch gains cannot reach
  one path and miss the other.
- DiagramLegend: the Loading % scale rows, and their absence in MW.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Antoine Marot <amarot91@gmail.com>
- docs/features/loading-view-and-flow-labels.md: the reference - views
  and toggles, colour scale, label rules (where, which, order, format,
  voltage colours, when), hover, the branch_loading / loading_deltas
  contract and its per-end limits, the frontend pieces, measured costs,
  the tests, the limits and next levers. Indexed in docs/README.md and
  the root CLAUDE.md (docs table, API rows, source tree).
- CHANGELOG: the section rewritten as one current description (the first
  bullets still said max(|i1|, |i2|) over one limit).
- expert_backend/CLAUDE.md + state-reset doc: the Loading view data and
  _side_limits_cache, now initialised in __init__ and cleared by reset()
  like every per-study cache (test_reset_clears_all_caches covers it).
- frontend/CLAUDE.md and canvas-gesture-proxy.md: the label layer, and
  why the proxy no longer draws the NAD tabs' flow values.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Antoine Marot <amarot91@gmail.com>
…ng-rate-view

CHANGELOG: both sides add sections under [Unreleased]; kept both, this
branch's (Loading view, Context twin consignation) first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Antoine Marot <amarot91@gmail.com>
@marota marota changed the title Loading % view on the network diagrams + consigned twin on the Context map Loading % view, readable flow labels and branch hover on the network diagrams + consigned twin on the Context map Nov 27, 2026
mypy (gating in CI) read the attribute's type off DiagramMixin's
assignment (a tuple) and refused the None that RecommenderService's
__init__ / reset() give it. Declared in RecommenderState with the rest of
the cross-mixin state, as Any, like its siblings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Antoine Marot <amarot91@gmail.com>
@marota
marota merged commit 2cf118b into ainetus:main Nov 27, 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