Files
aimsight-app/app/README.md
T

45 lines
5.8 KiB
Markdown
Raw Normal View History

# The AIMsight web app
The tool of the manual diagnostic: a single page, **Data**.
## The Data page
- **The plots**: one at the start (displacements, camera, image quality, system metrics), "Add a plot" to see several, aligned in time, the cross to remove one; a click on a curve sets the images to the image nearest to that moment. The zones of the labels are barely visible there (opacity 0.05, 0.07 in dark mode).
- **The labels**, under the plots, and their bar, according to the chosen source:
- **Detectors** (default): the detectors' events (`detectors/scripts/categories.py`, `events`), read-only. The bar carries only their family, the tooltip their targets; on click: their dates, their sensors (targets and references), the message (the first sentence of the text of the event, `categories.sentence`) and the action (the "For the client" column of `labeling/families.md`, refined per kind, `station.ACTION_KIND`);
- **LLM**: `labeling/auto/<STATION>.jsonl`, read-only;
- **Analysis**: the same labels, to edit or delete; writes in `labeling/auto/<STATION>.jsonl`.
With Detectors and LLM, dragging on the bar zooms in time; with Analysis, it selects a range to analyze. A click highlights a label on the plots and the bar, sets the images to its start and opens it (with Analysis: bounds, family, text, Save, Delete); a click elsewhere on the bar closes it. The page does not show `labeling/manual/`.
- **The camera images**, on the right, on the same station and the same range: slider, ◀ ▶ and keyboard arrows; wheel to zoom, drag to move, double click for the whole image; Names box; a range on the bar under the slider draws the displacement arrow of each sensor. An arrow at the top left enlarges the image and pushes the plots to the left; the reverse arrow brings it back.
- **The diagnostic settings**, under the image: "Focus on event curves" (with an event open, the plots show only its sensors: those of the detectors, or those the text of a label names), the families shown and, for Detectors only, the targets considered, the others removed before the detectors ("Rerun the detectors", parameter `targets` of `/api/detectors`).
The address keeps the station and the range (UTC, `end` excluded): `#/data?station=NIEDERHORN&start=2026-09-25&end=2026-10-08`; without dates, the last 5 UTC days, today included.
## The Analysis tab
- **Analyze the range**: a range selected, optional hints, then `server/analysis.py` launches the analyst of the agents repository by `claude -p` (non-interactive), with its instructions (`instructions/analyst.md`) and without the detectors (`DETECTORS: no`). It writes in `labeling/auto/analyses/<STATION>_<start>_<end>/` its labels and a diagnostic report (`report.md` and its figures; its work and claude's log in `work/`, outside git). The page follows its progress, then shows the report; the server submits its labels to `labeling/auto/<STATION>.jsonl` (field `analysis`). "View the report" on such a label opens it again.
- **The sidebar** sorts the analyses of `labeling/auto/analyses/` into folders, one per station (open by default if it has one running), and inside one analysis per range, the most recent first, with its state; a click opens Data on it.
- **The messages**: after the report, the user writes to the analyst, the same session resumes (`--resume`). An analysis stops with the server ("interrupted"); "continue" in the message field resumes it.
- **Optimize the detectors**, on a finished analysis: `/optimize` in Optimizer (`optimizer/`, with the plugin `agents/`) on the analysis: the detectors, then the reading tools; the detectors committed in `detectors/`, the reading tools in `tools/`, each on its current branch. The page follows the thread of the session (`work/optimization.jsonl`), then shows its summary under the report (`optimizer/sessions/<analysis>_<time>/summary.md`, and the `<analysis>/tools.md` of an older session). One optimization at a time; meanwhile, no analysis and no message to the analyst; an optimization cut by the server stopping is rerun with the button. The detectors' events are kept in memory until the end of an optimization: after an `/optimize` run outside the app, restart the server.
## Launch
The VS Code task **Run app** (`.vscode/tasks.json`), or by hand (Node 22 for the front end):
```bash
cd app/web && npm install && npm run build # once, and after each change of the page
.venv/bin/python app/server/server.py # .venv: see the README at the root
```
The page opens on `http://127.0.0.1:8770`. Settings by variables: `AIMSIGHT_DATA` (data, default `data/`), `AIMSIGHT_LABELS` (labels, default `labeling/`), `AIMSIGHT_PORT` (8770). To work on the page: `npm run dev` in `app/web/` (http://localhost:5173), the Python server launched next to it.
## The folders
- `server/server.py`: FastAPI; serves the built page and the API under `/api` (stations, images, curves, detectors, labels, analyses); answers only the pages of the workstation (local Host, declared JSON).
- `server/station.py`: the data of the Data page; read-only on `data/` (through `tools/scripts/data.py`), writes only in `labeling/{auto,manual}/`.
- `server/analysis.py`: the Analysis tab; launches `claude` with the agent `agents:analyst` (Read, Write, Bash allowed without asking); and the optimization, `/optimize` in Optimizer (Read, Write, Edit, Bash, Agent).
- `server/check.py`: checks, without calling claude: `.venv/bin/python app/server/check.py`.
- `web/`: React (Vite) and Mantine; `src/App.jsx` (header, sidebar, address), `src/pages/Data.jsx` (the page), `src/pages/Images.jsx` (the images, in Data), `src/common.jsx` (requests, selector), `src/main.jsx` (theme). Plotly, dressed in Mantine's colours, loads only with Data. `dist/` and `node_modules/` outside git.
The computation of `server/station.py` (images, curves, labels) comes from tools of the Support-Agent repository, copied on 2026-11-05 (commit 6e9f69a); it now evolves here.