Skip to content

Refactor action feed display with structured rho data - #6

Merged
marota merged 7 commits into
mainfrom
claude/update-run-analysis-usage-G5B1p
Feb 16, 2026
Merged

marota merged 7 commits into
mainfrom
claude/update-run-analysis-usage-G5B1p

Conversation

@marota

@marota marota commented Feb 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR refactors the action feed display to show structured rho (congestion) data and overloaded line information. The backend now returns pre-processed action details with rho arrays and reduction status, while the frontend displays this data in a more user-friendly format with visual indicators.

Key Changes

Backend (recommender_service.py):

  • Removed manual regex parsing of rho values from analysis output
  • Simplified action enrichment to use pre-computed data from the analysis result
  • Now extracts prioritized_actions and lines_overloaded_names directly from the result object
  • Returns structured action details with rho_before, rho_after, max_rho, max_rho_line, and is_rho_reduction fields
  • Removed dependency on external action description file parsing

Frontend (ActionFeed.tsx):

  • Added ActionDetail type import for type safety
  • Introduced linesOverloaded prop to display overloaded transmission lines
  • Added warning banner showing overloaded lines when present
  • Implemented formatRhoArray() helper to display rho values as human-readable percentages with line names
  • Enhanced action card styling with:
    • Color-coded left border (green for rho reduction, red for no reduction)
    • Action numbering and status badge
    • Structured display of rho before/after values
    • Max rho percentage with color coding (red if overloaded, green if not)
    • Line name reference for max rho value

Type Definitions (types.ts):

  • Added ActionDetail interface with typed fields for rho data
  • Updated AnalysisResult interface to include lines_overloaded array and message/dc_fallback fields
  • Changed actions field type from Record<string, any> to Record<string, ActionDetail>

Other:

  • Updated import statements to use TypeScript type keyword for type-only imports
  • Removed unused imports (useEffect from ConfigurationPanel, queue and re from backend)

Implementation Details

  • Rho values are displayed as percentages with one decimal place
  • Line names are pulled from the linesOverloaded array by index, with fallback to generic "line N" labels
  • Action cards are visually prioritized with numbering and status indicators
  • The overloaded lines warning uses a yellow/amber color scheme to indicate caution

https://claude.ai/code/session_01WoJya26bEC3W5yUuBJLXWb

Replace stdout regex parsing and manual action description loading with
direct use of the new run_analysis return dict (lines_overloaded_names,
prioritized_actions with rho_before/after, max_rho, is_rho_reduction).
Update frontend ActionFeed to render structured action cards with
overload status badges, rho comparisons, and overloaded lines banner.

https://claude.ai/code/session_01WoJya26bEC3W5yUuBJLXWb
…nature

Align the standalone HTML interface with the updated API response:
- Use max_rho/is_rho_reduction instead of new_max_rho null checks
- Use rho_before/rho_after arrays instead of old_rho/new_rho strings
- Add overloaded lines banner from lines_overloaded field
- Add priority numbering and reduction badge to action cards

https://claude.ai/code/session_01WoJya26bEC3W5yUuBJLXWb
Keep N and N-1 SVG containers always mounted in the DOM, using CSS
visibility/pointer-events/z-index to show/hide them instead of
conditional rendering. This preserves the usePanZoom hook's viewBox
state when switching to the Overflow Analysis tab and back.

Also re-apply saved viewBox when a tab becomes active again, and only
cross-sync zoom between N and N-1 when switching directly between them
(not when returning from the overflow tab).

https://claude.ai/code/session_01WoJya26bEC3W5yUuBJLXWb
The synchronization logic block (added in 9ed46c6) re-declared
`const prevTabRef = useRef(activeTab)` which already existed earlier
in the component. This caused a SyntaxError that prevented the
entire React app from rendering, resulting in a blank page.

https://claude.ai/code/session_01WoJya26bEC3W5yUuBJLXWb
Zoom persistence fix:
The "reinit on overflow exit" effect (dead code — reinitCount was never
consumed) was overwriting prevTabRef before the sync effect could read
it.  When switching overflow → N-1, the sync effect saw prevTab='n-1'
instead of 'overflow', so the guard didn't fire and it overwrote the
N-1 zoom with the N full-grid viewBox.  Removed the dead reinitCount
state and the conflicting effect so prevTabRef is managed in one place.

Action card tri-color severity:
Cards were colored only by is_rho_reduction (green/red).  An action
that reduces rho but leaves max_rho > 100% (e.g. 108.3%) still showed
green, which is misleading.  Now uses max_rho thresholds:
 - Green  (<=90%):  "Solves overload"
 - Orange (90-100%): "Partial reduction"
 - Red    (>100%):   "Still overloaded" / "No reduction"

Applied to both standalone_interface.html and ActionFeed.tsx.

https://claude.ai/code/session_01WoJya26bEC3W5yUuBJLXWb
90-100% max_rho means the overload is actually solved, but with little
headroom. The new label makes this clear while still flagging it for
supervision.

https://claude.ai/code/session_01WoJya26bEC3W5yUuBJLXWb
@marota
marota merged commit 2511e62 into main Feb 16, 2026
marota pushed a commit that referenced this pull request Jun 18, 2026
…casts 19→12

Target #6 from the code-quality review.

The SVG getScreenCTM / .style casts used `as unknown as SVGGraphicsElement`
where the source is already an `Element` (e.g. from querySelector) — a plain
downcast suffices (highlights.ts:74 already did `as SVGGraphicsElement` right
beside one). Simplified the 7 such casts in highlights.ts (3) and
actionPinRender.ts (4). Type-only assertions — erased at runtime, tsc +
eslint clean, zero behaviour change.

(ActionOverviewDiagram's `HTMLElement`→`SVGSVGElement` cast genuinely needs
`as unknown as` — sibling types — and is left.)

Lowers the `as unknown as` ratchet 19 → 12. The 46 `Record<string, unknown>`
remain the next weak-typing target.

https://claude.ai/code/session_0185GQf52QDpMM4zRDmGVN8X
marota pushed a commit that referenced this pull request Jun 18, 2026
Persists the measured scorecard and the outcomes of targets #1/#2/#3/#5/#6
(and the deliberate #4 deferral) in the analysis doc, and bumps the
"Last updated" header.

https://claude.ai/code/session_0185GQf52QDpMM4zRDmGVN8X
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