Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
8 changes: 4 additions & 4 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# CLAUDE.md - ExpertAssist
# CLAUDE.md - Co-Study4Grid

## Project Overview

ExpertAssist is a full-stack web application for **power grid contingency analysis and N-1 planning**. It provides an interface to the `expert_op4grid_recommender` library, allowing operators to simulate element disconnections, visualize network overflow graphs, and receive prioritized remedial action recommendations.
Co-Study4Grid is a full-stack web application for **power grid contingency analysis and N-1 planning**. It provides an interface to the `expert_op4grid_recommender` library, allowing operators to simulate element disconnections, visualize network overflow graphs, and receive prioritized remedial action recommendations.

## Architecture

**Monorepo** with two main components:

```
ExpertAssist/
Co-Study4Grid/
├── .gitignore # Excludes __pycache__/, *.pyc, *.pyo
├── CLAUDE.md # Project documentation for AI assistants
├── expert_backend/ # Python FastAPI backend
Expand Down Expand Up @@ -190,7 +190,7 @@ npm run test # Run Vitest test suite
### Session Save/Load
- **Save**: `buildSessionResult()` in `sessionUtils.ts` serializes all state (config, contingency, actions with status tags, combined pairs) -> `POST /api/save-session` writes to disk
- **Load**: `POST /api/load-session` reads `session.json` -> frontend restores all state without re-simulating actions
- **Output folder**: `<output_folder>/expertassist_session_<contingency>_<timestamp>/` contains `session.json` + overflow PDF
- **Output folder**: `<output_folder>/costudy4grid_session_<contingency>_<timestamp>/` contains `session.json` + overflow PDF
- **Interaction logging**: Every user interaction is logged as a timestamped, replay-ready event via `interactionLogger`. Saved as `interaction_log.json` alongside `session.json`.
- See `docs/save-results.md` for session save/load and `docs/interaction-logging.md` for the replay contract

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# ExpertAssist
# Co-Study4Grid

A full-stack web application for **power grid contingency analysis and N-1 planning**. ExpertAssist provides an interface to the [`expert_op4grid_recommender`](https://github.com/rte-france/expert_op4grid_recommender) library, allowing grid operators to:
A full-stack web application for **power grid contingency analysis and N-1 planning**. Co-Study4Grid provides an interface to the [`expert_op4grid_recommender`](https://github.com/rte-france/expert_op4grid_recommender) library, allowing grid operators to:

- Simulate element disconnections (N-1 contingency analysis)
- Visualize network overflow graphs and network-area diagrams
- Receive prioritized remedial action recommendations

## Architecture

ExpertAssist is a monorepo with a **Python FastAPI backend** and a **React + TypeScript frontend**.
Co-Study4Grid is a monorepo with a **Python FastAPI backend** and a **React + TypeScript frontend**.

```
ExpertAssist/
Co-Study4Grid/
├── expert_backend/ # FastAPI backend (Python)
│ ├── main.py # API endpoints and app configuration
│ └── services/
Expand Down
6 changes: 3 additions & 3 deletions docs/interaction-logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Overview

ExpertAssist logs every user interaction during a session as a timestamped, **replay-ready** event log. The log contains enough data for an automated agent (e.g. browser automation) to deterministically reproduce the exact same session — same clicks, same selections, same analysis runs — without human input.
Co-Study4Grid logs every user interaction during a session as a timestamped, **replay-ready** event log. The log contains enough data for an automated agent (e.g. browser automation) to deterministically reproduce the exact same session — same clicks, same selections, same analysis runs — without human input.

The log is saved as a dedicated `interaction_log.json` file alongside `session.json` when saving results.

Expand Down Expand Up @@ -229,7 +229,7 @@ After saving, the session folder contains:

```
<output_folder>/
expertassist_session_LINE_XYZ_2026-03-18T10-30-00/
costudy4grid_session_LINE_XYZ_2026-03-18T10-30-00/
session.json ← full state snapshot
interaction_log.json ← replay-ready event log
overflow_abc123.pdf ← overflow graph copy
Expand Down Expand Up @@ -363,7 +363,7 @@ After saving, the session folder contains:
"type": "session_saved",
"correlation_id": "e1f2a3b4",
"details": {
"session_name": "expertassist_session_LINE_XYZ_2026-03-18T10-25-00",
"session_name": "costudy4grid_session_LINE_XYZ_2026-03-18T10-25-00",
"output_folder": "/data/output"
}
}
Expand Down
2 changes: 1 addition & 1 deletion docs/rendering-optimization-plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Overview

ExpertAssist renders pypowsybl Network Area Diagrams (NAD) for power grids with 11,000+ lines and 500+ voltage levels. At this scale, naive rendering causes multi-second tab switches, invisible line colors at zoom-out, and zoom lag/crashes. This document traces the critical rendering features, their rationale, and regression risks.
Co-Study4Grid renders pypowsybl Network Area Diagrams (NAD) for power grids with 11,000+ lines and 500+ voltage levels. At this scale, naive rendering causes multi-second tab switches, invisible line colors at zoom-out, and zoom lag/crashes. This document traces the critical rendering features, their rationale, and regression risks.

## Critical CSS Properties

Expand Down
4 changes: 2 additions & 2 deletions docs/save-results.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Co-Study4Grid supports **saving** and **reloading** full analysis sessions:
- **`interaction_log.json`** — timestamped log of every user interaction, suitable for automated session replay (see [docs/interaction-logging.md](interaction-logging.md))
- **`<overflow>.pdf`** — a copy of the overflow graph PDF (when an analysis has been run)

All files are written to a **session folder** named `expertassist_session_<contingency>_<timestamp>/` inside the configured **Output Folder Path**.
All files are written to a **session folder** named `costudy4grid_session_<contingency>_<timestamp>/` inside the configured **Output Folder Path**.

---

Expand Down Expand Up @@ -52,7 +52,7 @@ Settings → gear icon → Paths tab → Output Folder Path

```
<output_folder_path>/
expertassist_session_LINE_XYZ_2026-03-11T14-23-05/
costudy4grid_session_LINE_XYZ_2026-03-11T14-23-05/
session.json
interaction_log.json <- replay-ready event log
overflow_abc123.pdf <- copy of the overflow graph
Expand Down
2 changes: 1 addition & 1 deletion docs/state-reset-and-confirmation-dialogs.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Overview

ExpertAssist manages complex analysis state across contingency selections, N-1 simulations, manual action simulations, and prioritized action results. To prevent stale data from interfering with new analyses, the application implements two complementary mechanisms:
Co-Study4Grid manages complex analysis state across contingency selections, N-1 simulations, manual action simulations, and prioritized action results. To prevent stale data from interfering with new analyses, the application implements two complementary mechanisms:

1. **Confirmation dialogs** when switching contingency or reloading a study with existing analysis state
2. **Full state reset** when loading a new study or applying new settings
Expand Down
2 changes: 1 addition & 1 deletion expert_backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ def list_sessions(folder_path: str = Query(...)):
try:
for entry in os.listdir(folder_path):
entry_path = os.path.join(folder_path, entry)
if os.path.isdir(entry_path) and entry.startswith("expertassist_session"):
if os.path.isdir(entry_path) and (entry.startswith("costudy4grid_session") or entry.startswith("expertassist_session")):
json_path = os.path.join(entry_path, "session.json")
if os.path.isfile(json_path):
sessions.append(entry)
Expand Down
2 changes: 1 addition & 1 deletion expert_backend/tests/test_environment_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def test_non_reconnectable_detection_with_date():
Verify that non-reconnectable lines are detected correctly even when an analysis_date is provided.
This was previously a bug where the detection was bypassed if analysis_date was not None.
"""
# 1. Setup paths relative to ExpertAssist root
# 1. Setup paths relative to Co-Study4Grid root
project_root = Path(__file__).parent.parent.parent
test_env_path = project_root / "data" / "bare_env_small_grid_test"

Expand Down
2 changes: 1 addition & 1 deletion frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>frontend</title>
<title>Co-Study4Grid</title>
</head>
<body>
<div id="root"></div>
Expand Down
13 changes: 0 additions & 13 deletions frontend/lint_output.txt

This file was deleted.

2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "frontend",
"name": "co-study4grid",
"private": true,
"version": "0.0.0",
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/App.settings.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ describe('Save Results button', () => {
expect(createObjectURL).toHaveBeenCalledOnce();
expect(anchorClicks).toHaveLength(1);
const anchor = anchorClicks[0];
expect(anchor.download).toMatch(/^expertassist_session_BRANCH_A_/);
expect(anchor.download).toMatch(/^costudy4grid_session_BRANCH_A_/);
expect(anchor.download).toMatch(/\.json$/);
});

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@
const e = err as { response?: { data?: { detail?: string } }; message?: string };
setError('Failed to apply settings: ' + (e.response?.data?.detail || e.message));
}
}, [networkPath, actionPath, buildConfigRequest, applyConfigResponse, createCurrentBackup, setResult, setError, setShowMonitoringWarning, setSettingsBackup, setIsSettingsOpen, actionsHook, analysis, diagrams]);

Check warning on line 229 in frontend/src/App.tsx

View workflow job for this annotation

GitHub Actions / test-frontend

React Hook useCallback has missing dependencies: 'changeConfigFilePath', 'configFilePath', and 'lastActiveConfigFilePath'. Either include them or remove the dependency array


const handleLoadConfig = useCallback(async () => {
Expand Down Expand Up @@ -286,7 +286,7 @@
} finally {
setConfigLoading(false);
}
}, [buildConfigRequest, applyConfigResponse, setResult, setError, setShowMonitoringWarning, actionsHook, analysis, diagrams]);

Check warning on line 289 in frontend/src/App.tsx

View workflow job for this annotation

GitHub Actions / test-frontend

React Hook useCallback has missing dependencies: 'actionPath', 'changeConfigFilePath', 'configFilePath', 'lastActiveConfigFilePath', and 'networkPath'. Either include them or remove the dependency array

const handleLoadStudyClick = useCallback(() => {
if (hasAnalysisState()) {
Expand Down Expand Up @@ -617,7 +617,7 @@
value={configFilePath}
onChange={e => setConfigFilePath(e.target.value)}
onBlur={e => changeConfigFilePath(e.target.value).catch(() => { })}
placeholder="e.g. /home/user/my_expertassist_config.json"
placeholder="e.g. /home/user/my_costudy4grid_config.json"
style={{ flex: 1, padding: '8px', border: '1px solid #ccc', borderRadius: '4px' }}
/>
<button
Expand Down
Loading
Loading