Skip to content

docs: Update CLAUDE.md, README.md, and backend/frontend guides for 0.6.5 - #115

Merged
marota merged 4 commits into
mainfrom
claude/update-documentation-files-j6MnU
Apr 24, 2026
Merged

marota merged 4 commits into
mainfrom
claude/update-documentation-files-j6MnU

Conversation

@marota

@marota marota commented Apr 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR updates project documentation to reflect the current state of Co-Study4Grid at release 0.6.5, including recent architectural decompositions (PR #104/#106), SVG DOM recycling optimization (PR #108), hook extraction (PR #109), and the auto-generated standalone UI (PR #101).

Key Changes

CLAUDE.md (root project overview)

  • Expanded directory tree with new subdirectories: services/diagram/, services/analysis/, services/simulation_helpers.py, frontend/src/utils/svg/, and scripts/pypsa_eur/
  • Documented mixin decomposition: clarified that DiagramMixin, AnalysisMixin, and SimulationMixin are now thin orchestrators delegating to helper packages
  • Added SVG DOM recycling pattern: documented /api/n1-diagram-patch and /api/action-variant-diagram-patch endpoints and utils/svgPatch.ts fast-path
  • Updated dependencies section: replaced framer-motion and lucide-react with vite-plugin-singlefile and Vitest
  • Expanded API table: added new patch endpoints, user-config endpoints, and /api/simulate-and-variant-diagram
  • Updated conventions: replaced "no formal linter" with "Ruff-gated" (E9 + F ruleset only)
  • Clarified standalone UI: documented auto-generation via npm run build:standalone and decommissioning of hand-maintained standalone_interface.html
  • Updated test commands: reorganized scripts under scripts/pypsa_eur/ with their own pytest coverage

README.md (user-facing guide)

  • Updated release badge from 0.5.0 to 0.6.5
  • Expanded frontend engineering section: documented Phase 2 hook extraction (useN1Fetch, useDiagramHighlights), SVG DOM recycling performance gains (~80% faster), and code-quality gate
  • Added 0.6.5 performance table: showed /api/n1-diagram-patch speedup (−83.8% cold, −79.1% warm) vs. full endpoint
  • Reorganized performance section: split into 0.6.5 (DOM recycling) and 0.5.0 (vectorization) subsections
  • Updated directory tree: added dist-standalone/, benchmarks/, and scripts/ with PyPSA-EUR pipeline
  • Clarified standalone UI build: documented npm run build:standalone output and parity guards
  • Updated test instructions: separated backend pytest, code-quality gate, and ad-hoc integration scripts
  • Updated API table: added patch endpoints and /api/simulate-and-variant-diagram

expert_backend/CLAUDE.md (backend guide)

  • Expanded services tree: documented new diagram/, analysis/ subdirectories and simulation_helpers.py
  • Detailed mixin decomposition: explained how mixins delegate to helper packages while preserving @patch test compatibility
  • Added SVG patch endpoints: documented /api/n1-diagram-patch and /api/action-variant-diagram-patch with performance context
  • Updated conventions: replaced "no formal linter" with Ruff configuration details and enforcement of no print() / bare except / any / @ts-ignore
  • Clarified standalone UI: removed manual-mirroring requirement, documented auto-generation and decommissioning of legacy HTML
  • Updated CORS documentation: noted CORS_ALLOWED_ORIGINS env var configuration (PR Code-quality gate + decomposition sweep (5 modules) #104)

frontend/CLAUDE.md (frontend guide)

  • Expanded utils tree: documented svg/ subdirectory with 8 focused modules (idMap, metadataIndex, svgBoost, fitRect, deltaVisuals, actionPin*, highlights)
  • Added svgPatch documentation: explained DOM recycling strategy and fallback behavior
  • Documented actionTypes utility: noted shared filter logic across UI surfaces
  • **Added

https://claude.ai/code/session_01RsvHjjFbAauF3NvD9BNT5V

claude added 4 commits April 24, 2026 05:50
The four top-level docs had drifted since their last respective
updates (root from PR #104, frontend from PR #109, backend + README
from PR #103). Bring them in line with the main branch as of 0.6.5.

Root CLAUDE.md:
- Architecture tree now lists services/analysis, services/diagram
  and simulation_helpers.py (PR #104 / #106 decomposition), plus
  frontend/src/utils/svg/ modules, svgPatch.ts, actionTypes.ts,
  fileRegistry.ts, and the new hooks (useN1Fetch, useDiagramHighlights)
  and components (AppSidebar, SidebarSummary, StatusToasts, …).
- Tech Stack drops framer-motion + lucide-react (removed in PR #104)
  and surfaces vite-plugin-singlefile + Vitest.
- API table adds /api/n1-diagram-patch, /api/action-variant-diagram-patch,
  /api/simulate-and-variant-diagram, /api/user-config and
  /api/config-file-path.
- Integration-script paths moved under scripts/pypsa_eur/; App.tsx
  size bumped to ~1150 lines to match the hook extraction.

Frontend CLAUDE.md:
- Layout tree now enumerates utils/svg/* submodules, utils/svgPatch.ts,
  utils/actionTypes.ts, utils/fileRegistry.ts and the new shared
  ActionTypeFilterChips component.
- SVG-handling section gains the DOM-recycling fast path.

Backend CLAUDE.md:
- services/ tree now includes the diagram/ (7 modules) and
  analysis/ (4 modules) subpackages plus simulation_helpers.py,
  with a new paragraph describing the mixin → helper-package
  decomposition and @patch-compatibility contract.
- API surface adds the new patch endpoints.
- Conventions note the narrow E9/F ruff ruleset and the
  CORS_ALLOWED_ORIGINS env var; drops the manual standalone mirror
  requirement.

README.md:
- Release badge 0.5.0 → 0.6.5.
- Frontend engineering section replaces Phase 2 state-management
  wording with the Phase 2 hook extraction + SVG DOM recycling
  highlights; drops framer-motion / lucide-react.
- Performance Highlights gains a dedicated 0.6.5 table
  (patch endpoints, cold/warm/payload) above the 0.5.0 one.
- Architecture snippet updated with the new subfolders and new
  frontend components.
- Backend test-command block replaced with the real test story
  (pytest + code-quality gate + profiling scripts + pypsa_eur
  pipeline) — the previous block referenced files that no longer
  exist (test_api_stream.py, test_n1_api.py, …).
- API Reference gains the three new endpoints from the patch flow.
- Standalone section rewritten to describe the auto-generated
  dist-standalone/standalone.html bundle + the four parity layers.

https://claude.ai/code/session_01RsvHjjFbAauF3NvD9BNT5V
The kV filter is a vertical dual-range slider with two stacked
<input type="range"> elements. The high handle sits on top by default
(zIndex 4 above zIndex 3). When the user pulls both handles together
at the top of the scale — e.g. voltageRange = [400, 400] with
maxV = 400 — the range becomes inescapable:

- The high handle is clamped by `snapped >= voltageRange[0] = maxV`,
  so it cannot move up (already at max) and cannot move down (the
  low handle blocks it at maxV).
- The low handle, which could still be dragged down to expand the
  range, is hidden beneath the high handle and unreachable.

Swap the z-order exactly when the range collapses at maxV: raise the
low handle to zIndex 5 so the user can grab it and drag it back down.
Every other state (open range, collapsed at minV, collapsed at an
intermediate value where the high handle can still move up) keeps
the default z-order.

Added three regression tests in VisualizationPanel.test.tsx covering
the default, maxV-collapse and minV-collapse cases.

https://claude.ai/code/session_01RsvHjjFbAauF3NvD9BNT5V
… when range reopens

`applyVoltageFilter` had an early-return when the current range was
"fully open" (minKv ≤ uniqueVoltages[0] && maxKv ≥ uniqueVoltages[last]):

    if (minKv <= uniqueVoltages[0] && maxKv >= ...) return;

That short-circuited the reset pass whenever the user expanded a
previously narrow range back out. Scenario that motivated this fix
(PyPSA-EUR fr225_400, uniqueVoltages = [225, 400]):

1. User collapses the filter to [225, 225] — every 400 kV node, legend
   entry and edge gets `display:none`.
2. User drags the low handle back down to 225 (range becomes
   [225, 400], i.e. fully open).
3. Effect fires, applyVoltageFilter early-returns, and the 400 kV
   elements stay hidden. The map only shows 225 kV lines — the user
   sees a broken redraw even though "no filter is applied".

Fix: track per-tab whether the last applied filter actually hid
anything (`prevFilterHadHidden`). The fully-open short-circuit now
only fires when the PREVIOUS range was also fully open — otherwise we
run the loop once to reset `display` back to '' on everything and
clear the flag. Filter still skips the redundant DOM walk on the
normal "never filtered" startup path, so there's no perf regression.

Added two regression tests in useDiagrams.test.ts covering the
narrow-range hide and the reopen-resets-display paths.

https://claude.ai/code/session_01RsvHjjFbAauF3NvD9BNT5V
Follow-up to the root/frontend/backend CLAUDE.md + README refresh.
Audits the remaining project docs against PRs merged 2026-04-21 →
2026-04-23 and updates the eight that had actually drifted.

frontend/README.md (HIGH)
  Replaced the stock Vite-template boilerplate with a real frontend
  orientation: npm scripts, source-tree map (hooks, components,
  utils incl. the utils/svg/* split from PR #104), pointer to the
  auto-generated standalone bundle, testing + lint commands, and
  cross-refs to CLAUDE.md / PARITY_AUDIT.md / docs/README.md.

expert_backend/tests/CLAUDE.md (MEDIUM)
  Full rewrite of the test-file inventory: added the PR #104
  decomposition suites (test_simulation_helpers.py,
  test_analysis_helpers.py, test_diagram_helpers.py), the patch-
  endpoint coverage (test_diagram_patch_helpers.py,
  test_n1_diagram_fast_path.py) from PR #108, the regression
  guards (test_resimulate_regression.py,
  test_second_contingency_reset.py,
  test_get_n1_variant_clones_from_n_state.py,
  test_configurable_mw.py) that were added since 2026-04-11, and
  the dynamic reco_* reconnection path from PR #110. Replaced the
  frontend inventory with a structural summary matching the
  current ~60-file Vitest layout, listed the scripts/pypsa_eur
  pytest coverage, and documented the tests removed by PR #103 /
  #104 (test_ui_regressions.py, standaloneInterface.test.ts,
  cssRegression.test.ts).

docs/features/combined-actions.md (MEDIUM)
  Added a "Recent updates (PR #114, release 0.6.5)" section
  covering LS/curtailment in combined pairs, Simulate Combined
  moved out of the card + clickable sub-action badges,
  target_max_rho on the user-selected overload set, and Explore-
  Pairs re-estimation aligned with the pre-computed betas.
  Rewrote the "Standalone Interface" section to describe the
  auto-generated bundle, and dropped the checklist line that
  required manual standalone_interface.html mirroring. Added a
  row to the key-files table for the ActionCard sub-action badges
  and the ComputedPairsTable / ExplorePairsTab split.

docs/features/state-reset-and-confirmation-dialogs.md (MEDIUM)
  Replaced the standalone_interface.html section with a pointer
  to the auto-generated bundle, and expanded the "What reset()
  clears" list to match the current RecommenderService.reset()
  implementation (drain order + fast-path caches +
  _layout_cache + NAD-prefetch state, with the
  add-a-new-cache-goes-here guardrail).

docs/features/detachable-viz-tabs.md (MEDIUM)
  Removed the "standalone_interface.html mirror" row and the
  follow-up caveat that said the single-file interface doesn't
  support detaching — both are obsolete now that the bundle is
  auto-generated from the React tree.

docs/architecture/app-refactoring-plan.md (MEDIUM)
  Added a "Status: SHIPPED" banner at the top summarising both
  refactor waves (Phase 1 via PR #74, Phase 2 hook extraction
  via PR #109) and pointing readers at the current source of
  truth (frontend/CLAUDE.md + CHANGELOG.md 0.6.5). Preserved the
  original plan below the banner for historical value.

docs/architecture/phase2-state-management-optimization.md (LOW)
  Added a "Status: Partially shipped" banner — memoization +
  React.memo pass shipped under PR #75, superseded in part by
  PR #109 (useN1Fetch / useDiagramHighlights extractions),
  orchestrator hooks still deferred.

docs/features/frontend-ui-improvements.md (LOW)
  Scope header now names `frontend/dist-standalone/standalone.html`
  (auto-generated, PR #101) instead of the decommissioned
  hand-maintained file.

https://claude.ai/code/session_01RsvHjjFbAauF3NvD9BNT5V
@marota
marota merged commit 393df52 into main Apr 24, 2026
8 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.

2 participants