Skip to content

GridForge: Main is read-only, always-on chrome with separate winter/summer imports - #8

Closed
Rupper02 wants to merge 13 commits into
mainfrom
cursor/fix-main-readonly-status-display-5c8f
Closed

Rupper02 wants to merge 13 commits into
mainfrom
cursor/fix-main-readonly-status-display-5c8f

Conversation

@Rupper02

@Rupper02 Rupper02 commented Oct 3, 2026 •

Copy link
Copy Markdown
Owner

Fixes the GridForge planner glass app to ensure main branch is read-only and critical readings are always visible, even on short/narrow laptop windows.

Changes

Always-on chrome readings (visible on short windows < 760px tall)

The planner now shows three separate GSP figures, each with its own limit scale:

  • GSP export against 527 MW export limit
  • Winter import against 320.2 MW (2×160.1 MW) limit
  • Summer import against 221.6 MW (2×110.8 MW) limit
    • Shows actual import (0 or positive)
    • When summer case exports, displays 0 / 221.6 MW (not negative)

Voltage range shows each case's own voltages with season labels:

  • Full Readings: Displays winter range and summer range separately
    • Example: 0.985 (W) to 1.042 pu (W) · 0.992 (S) to 1.038 pu (S)
  • CompactReadings and narrow-pill: Compact format showing both ranges
    • Example: 0.985(W)–1.042(W) 0.992(S)–1.038(S)
  • Each W or S letter sits on that case's own voltage, not the envelope

Worst element shows the season's actual percentage:

  • When both cases available: W92% S87% (each season's own percentage)
  • When one case known: 92%(W) (that season's actual percentage)
  • Never shows envelope percentage with a guessed season label

Computing state: During refresh (refreshing or running), figures show ... placeholders instead of stale values that look finished.

Responsive layout:

  • Full Readings card: visible when viewport height ≥ 760px
  • CompactReadings: shown when viewport height < 760px (short windows)
  • narrow-pill: shown when viewport width < 1100px (narrow windows)

Element cards show separate winter and summer loadings

Lines and transformers display:

  • Winter peak: X% (with color coding)
  • Summer min: Y% (with color coding)

Each percentage is the actual loading from that study case, not an envelope.

Main branch is read-only

  • Profile control (Low/Standard/High) is disabled on main, enabled on branches
  • Element cards on main have no maintenance schedule form. Branches can still schedule works.
  • Matches the Outages tab which already says "main is read-only"

Technical implementation

Backend (packages/optimizer):

  • network.py: feasibility() captures per-case winter/summer imports and per-case voltage extrema
  • types.py: Added seasonal fields to PhaseResult
  • years.py: evaluate_year() populates these fields from feasibility metrics

Frontend (apps/web):

  • types.ts: Extended PhaseResult with optional winter/summer fields
  • derive.ts: Enhanced WorstElement interface with per-case loadings and winning case
  • LeftCards.tsx:
    • Three separate gauges with their own limits
    • Each voltage letter sits on that case's own voltage
    • Worst element shows the percentage that matches its season label
    • Summer import displays 0 (not negative) when summer case exports
    • Treats undefined as missing data; 0 is valid for import (0 pu invalid for voltage)
  • DetailCards.tsx: Two-row loading display for winter peak and summer min
  • Header.tsx: Profile control disabled when derived.onMain

Tests

  • Backend: 109 tests pass
  • Frontend: 86 tests pass, typecheck passes
  • No changes to power-flow calculations or optimizer logic
Open in Web Open in Cursor 

Glass app updates (current main at 87aa7a5):

- Always-visible readings on narrow windows (< 1100px wide):
  The narrow pill now shows GSP export, voltage range, and worst loading
  alongside the profile label. These stay visible during refreshes and
  update when quiet maintenance re-solves replace results.

- Main is read-only:
  - Profile control (Low/Standard/High) disabled on main
  - Title changes to 'main is read-only' when hovering
  - Schedule works form hidden on element cards when viewing main
  - Branches can still change profile and schedule maintenance windows

- Loading shows case context:
  Element cards (lines, transformers) now label loading as 'worst case'
  to clarify it's the envelope across both study cases (winter peak and
  summer minimum), not a single-case figure.

All tests pass (86 tests, 9 test files)

Co-authored-by: Roberto Aguilar <Rupper02@users.noreply.github.com>
@cursor
cursor Bot force-pushed the cursor/fix-main-readonly-status-display-5c8f branch from fee4e6b to 8069a3a Compare October 3, 2026 15:33
@cursor cursor Bot changed the title Fix main read-only status and add always-visible status display Fix main read-only and show critical readings on narrow windows (glass app) Oct 3, 2026
Two critical fixes:

1. Show readings on short windows (< 760px tall):
   Added CompactReadings component that displays when layout.showReadings
   is false (viewport height < 760px). Shows GSP export, voltage range,
   and worst loading in a minimal single-line card. These stay visible
   and show computing state ('...') during refreshes.

2. Name both study cases in element loading:
   Changed loading labels from 'Loading in {year} (worst case)' to
   'Loading · winter peak & summer min' to accurately reflect that the
   backend returns the envelope across both study cases. Both cases are
   always evaluated (winter_peak and summer_min per config.CASE_SPECS).

The narrow pill (< 1100px wide) already had the readings.
Now short windows (< 760px tall) also show them via CompactReadings.

All tests pass.

Co-authored-by: Roberto Aguilar <Rupper02@users.noreply.github.com>
@cursor cursor Bot changed the title Fix main read-only and show critical readings on narrow windows (glass app) Fix main read-only and show critical readings on all window sizes Oct 3, 2026
Backend (packages/optimizer):
- network.py: Capture per-case winter/summer imports and voltages in feasibility()
- types.py: Add gsp_import_winter_mw, gsp_import_summer_mw, min_vm_winter/summer, max_vm_winter/summer to PhaseResult
- years.py: Populate new fields in YearResult with per-case metrics

Frontend (apps/web):
- types.ts: Add optional winter/summer fields to PhaseResult
- derive.ts: Add winterLoadPct, summerLoadPct to ElementInfo
- LeftCards.tsx: Show three separate figures with their own limits:
  * GSP export vs 527 MW
  * Winter import vs 320.2 MW (2×160.1 MW)
  * Summer import vs 221.6 MW (2×110.8 MW)
  * Voltage range with season labels (e.g. 0.985 (summer min) to 1.042 (winter peak))
  * Show computing state (...) during refresh
- DetailCards.tsx: Show separate Winter peak and Summer min percentages for lines and transformers

All tests pass (optimizer: 109 passed, web: 86 passed, typecheck: pass)

Co-authored-by: Roberto Aguilar <Rupper02@users.noreply.github.com>
@cursor cursor Bot changed the title Fix main read-only and show critical readings on all window sizes GridForge: Main is read-only, always-on chrome with separate winter/summer imports Oct 3, 2026
Frontend (apps/web):
- derive.ts: Enhanced WorstElement interface with winterPct, summerPct, and case fields
- worstElement(): Now captures per-case loadings and determines which case won
- LeftCards.tsx: Updated all three views (narrow pill, full Readings, CompactReadings):
  * Voltage range shows season for min and max (e.g. '0.985(S)–1.042(W)')
  * Worst element shows the winning case (e.g. '92% (W)') or both when available
  * Treat undefined or 0 as no data (old cached results default to 0.0)
- derive.test.ts: Updated test to match new WorstElement interface

All three layouts now correctly label which season each metric came from.
Cached years from before these fields were added display '–' instead of '0'.

Tests: 109 backend passed, 86 frontend passed, typecheck pass

Co-authored-by: Roberto Aguilar <Rupper02@users.noreply.github.com>

@Rupper02 Rupper02 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a sign-off. Summer import is the slack power as pandapower reports it: positive is import, negative is export. The summer case is the export case, so gsp_import_summer_mw is negative and the gauge draws that against 2×110.8 MW. That is the export a second time. Store the positive draw only (zero when the GSP is exporting).

The 1864060 check value ? value : null hides a zero and still draws a negative. The voltage letter names which case extreme won, then the number beside it is the envelope (furthest from 1.0 pu), not that extreme.

cursoragent and others added 8 commits October 3, 2026 16:35
Frontend (apps/web/src/components/LeftCards.tsx):
- Summer import: Always show import (0 when exporting), never flip row to export
  * When summer case exports, display '0 / 221.6 MW', not negative value
  * Solved 0 MW import is valid and stays visible
  * Only undefined fields are treated as missing
- Voltage: Each letter (W/S) now sits on that case's own voltage
  * Full Readings: Show winter range + summer range separately when both available
  * CompactReadings: Display both ranges in compact format
  * Narrow pill: Same compact format with both winter and summer ranges
  * No longer show envelope voltage with a guessed season letter
- Worst element: Percent now matches the season it names
  * Show both seasons' own percentages when available (e.g. 'W92% S87%')
  * Or show single season's actual percentage with its label (e.g. '92%(W)')
  * Never show envelope percent next to a guessed season
- Winter import unchanged: Still against 2×160.1 MW limit
- Summer import: Against 2×110.8 MW limit (showing 0 when case exports)

Tests: 86 passed, typecheck pass

Co-authored-by: Roberto Aguilar <Rupper02@users.noreply.github.com>
Backend (packages/optimizer):
- types.py: Add gsp_export_case field to PhaseResult (records which case produced export)
- network.py: Populate gsp_export_case in feasibility metrics
- years.py: Include gsp_export_case in YearResult

Frontend (apps/web):
- types.ts: Add optional gsp_export_case field to PhaseResult
- LeftCards.tsx Readings:
  * Export row now shows season: 'GSP export · winter' or 'GSP export · summer'
  * Removed 'Worst case' text (replaced with actual season from result)
  * Worst element displays both percentages when available: 'W92% S87%'
  * Never shows envelope percentage with a guessed season
  * Matches narrow pill and CompactReadings behavior

All three views now show both winter and summer percentages for worst element.
Export row names the season that produced the export figure.

Tests: 109 backend passed, 86 frontend passed, typecheck pass

Co-authored-by: Roberto Aguilar <Rupper02@users.noreply.github.com>
Frontend (apps/web/src/components/LeftCards.tsx):
- Narrow pill: Export now shows '(W)' or '(S)' when gsp_export_case available
  * Example: 'Export (W) 224/527' for winter export
- CompactReadings: GSP export label shows season
  * Example: 'GSP export (W)' or 'GSP export (S)'
- Uses recorded gsp_export_case field from result
  * Winter only when case is 'winter_peak'
  * Summer only when case is 'summer_min'
  * No season label when field is missing (old cached results)

All three views (full Readings, CompactReadings, narrow pill) now
consistently show which season produced the export figure.

Tests: 86 passed, typecheck pass

Co-authored-by: Roberto Aguilar <Rupper02@users.noreply.github.com>
Frontend (apps/web):
- derive.ts: worstElement() now finds worst winter and worst summer separately
  * Previously: Found element with highest envelope, returned that element's winter & summer
  * Now: Finds actual worst winter element and actual worst summer element
  * Winter percent is the highest winter loading across all elements
  * Summer percent is the highest summer loading across all elements
  * Can be different elements (e.g., W53% on Sleaford, S93% on different element)
  * Returns winterName and summerName to identify each element
- LeftCards.tsx Readings: Display both element names when they differ
  * Same element: Shows just the element name
  * Different: 'winter ElementA · summer ElementB'
- Import denominators: Show full precision (320.2 and 221.6, not 320 and 222)
  * Narrow pill and CompactReadings now use fmtMw() for limits
  * Shows 2×160.1 MW (320.2) for winter, 2×110.8 MW (221.6) for summer

Fixes issue where worst loading showed W1% S93% while Sleaford card showed W53%.
Now worst winter shows ≥53%, worst summer shows ≥93%, each from the actual worst element.

Tests: 86 passed, typecheck pass

Co-authored-by: Roberto Aguilar <Rupper02@users.noreply.github.com>
Frontend (apps/web/src/components/LeftCards.tsx):
1. Full Readings: Two separate readings for worst winter and worst summer
   - Each shows its own percentage with its element name
   - Not combined as 'W% S%' - each stands on its own
   - Winter: percentage + element name on one reading
   - Summer: percentage + element name on separate reading

2. Narrow pill: Added element identification
   - Shows 'W.worst X%' and 'S.worst Y%' as separate lines
   - Each percentage clearly from its own worst element

3. Import captions: Changed to show '2×160.1' and '2×110.8'
   - Full Readings: '2×160.1 MW' for winter, '2×110.8 MW' for summer
   - Narrow pill: '2×160.1' and '2×110.8' (no MW, space constrained)
   - CompactReadings: '2×160.1' and '2×110.8'
   - Gauge fill, ticks, and numeric limits unchanged (still 320.2 and 221.6)
   - Caption only changed, matching export format (already shows '2×263.5')

Each worst percentage now clearly identifies which element it came from.
Winter worst ≥53% with its element, summer worst 93% with its element.

Tests: 86 passed, typecheck pass

Co-authored-by: Roberto Aguilar <Rupper02@users.noreply.github.com>
Frontend (apps/web/src/components/LeftCards.tsx):
- Narrow pill: Added element names to worst winter and summer
  * Was: 'W.worst 53%' and 'S.worst 93%' (no element)
  * Now: 'W 53% ElementName' and 'S 93% ElementName'
  * Uses worst.winterName and worst.summerName

- CompactReadings: Added element names to worst displays
  * Was: 'Worst winter 53%' and 'Worst summer 93%' (no element)
  * Now: 'Worst winter 53% ElementName' and 'Worst summer 93% ElementName'
  * Uses worst.winterName and worst.summerName
  * Reduced font size to 10 to fit element names

Each worst percentage now clearly shows which element it came from,
not pasting from open/selected card.

Tests: 86 passed, typecheck pass

Co-authored-by: Roberto Aguilar <Rupper02@users.noreply.github.com>
Frontend (apps/web/src/components/LeftCards.tsx):
- Narrow pill: Added flexWrap, height auto, and whiteSpace normal
  * Was: Fixed height 34px, nowrap - content clipped off screen
  * Now: Wraps onto multiple lines, all content visible
  * Import captions '2×110.8' fully readable (was cut to '2×11')
  * Element names 'Woodhall Spa 33/11 kV' and 'Skegness to Middlemarsh 132 kV' visible

Inline style overrides narrow-pill CSS to allow wrapping:
- flexWrap: 'wrap' (overrides implicit nowrap)
- height: 'auto' (overrides fixed 34px)
- minHeight: 34 (maintains minimum height)
- whiteSpace: 'normal' (overrides nowrap from CSS)

Full card and short line unchanged (already approved by QA).

Tests: 86 passed, typecheck pass

Co-authored-by: Roberto Aguilar <Rupper02@users.noreply.github.com>
Frontend (apps/web/src/components/LeftCards.tsx):
- Narrow pill: Added maxWidth constraint
  * Was: No right boundary - grew wider than viewport, clipped by stage
  * Now: maxWidth 'calc(100vw - 20px)' forces wrap before edge
  * Content wraps to multiple lines instead of overflowing

With flexWrap + maxWidth, all content now stays within viewport:
- Import caption '2×110.8' fully readable (not cut to '2×11')
- Winter winner: percent + winterName visible
- Summer winner: percent + summerName visible

The pill wraps but stays inside the viewport.
Full card and short line unchanged.

Tests: 86 passed, typecheck pass

Co-authored-by: Roberto Aguilar <Rupper02@users.noreply.github.com>

@Rupper02 Rupper02 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screen sign on b879f9f.

Live narrow layout (<1100px): S.import shows full 2×110.8 (not clipped). Both season winners readable: W 81% Woodhall Spa 33/11 kV transformer and S 93% Skegness to Middlemarsh 132 kV, circuit 1. maxWidth wrap on the narrow pill holds.

On narrow viewports (< 1100px) with the side panel open, the .narrow-pill
at top:68px left:10px was overlapping the .layers panel (Flow/Loading/etc)
also at top:68px, causing the first line of the pill to be covered/clipped.

The pill's maxWidth now accounts for layout.layers.right + LAYERS_W (196px)
plus margin (20px), so when the side panel is open the pill stops before
the layers panel starts, leaving both winter and summer winner names
(with percents) and the full '2×110.8' caption visible and un-obscured.

Co-authored-by: Roberto Aguilar <Rupper02@users.noreply.github.com>
@Rupper02 Rupper02 closed this Nov 19, 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