feat(optimize): support state diagrams in the Optimize panel
Extend the Diagram Doctor beyond flowcharts to stateDiagram / stateDiagram-v2.
- New parseStateDiagram: states → nodes, transitions → edges in source order
(including `[*]` pseudo-transitions, so linkStyle indices stay aligned);
`[*]` itself is never a node. Composite states map to groups, notes are
skipped. A parseDiagram() dispatcher feeds analyze/transforms.
- Fixes are tailored per kind (verified empirically against Mermaid 11):
* ELK is flowchart-only (state diagrams reject `layout: elk`), so it's not
offered and the no-ELK score penalty is skipped for state diagrams.
* Spacing uses the `state` config key; direction is set via a `direction`
statement rather than the header.
* State diagrams can't style individual transitions — a `linkStyle` line
renders as a stray node — so the dim-hubs fix and focus mode fade the
busy *states* (e.g. CANCELLED) via classDef/class instead of dimming edges.
Flowcharts keep edge dimming via linkStyle.
- Panel notice now covers flowcharts & state diagrams.
Verified in-browser: state-diagram dim/focus render with zero junk nodes;
flowchart ELK + linkStyle dimming still intact.
This commit is contained in:
17
README.md
17
README.md
@@ -25,14 +25,15 @@ TypeScript** frontend using **CodeMirror 6** and **Mermaid 11**.
|
||||
counts. Network operations shell out to your system `git`, so they reuse your
|
||||
existing credentials (SSH agent, keychain / credential helpers) — no separate
|
||||
login.
|
||||
- **Optimize panel (Diagram Doctor)** — analyse a tangled flowchart and declutter
|
||||
it in one click: a readability score and metrics (hubs, density, cross-group
|
||||
edges), plus source rewrites for the **ELK layered layout**, extra
|
||||
spacing/curved edges, **de-emphasising cross-cutting hub edges** (event bus,
|
||||
audit, cost-style fan-ins), and removing duplicate edges. A non-destructive
|
||||
**focus mode** spotlights any node and its neighbours so you can read a dense
|
||||
graph without changing it. Every rewrite lands in the editor and is reversible
|
||||
with ⌘Z.
|
||||
- **Optimize panel (Diagram Doctor)** — analyse a tangled **flowchart or state
|
||||
diagram** and declutter it in one click: a readability score and metrics
|
||||
(hubs, density, cross-group edges), plus source rewrites for the **ELK layered
|
||||
layout** (flowcharts), extra spacing, a layout-direction toggle,
|
||||
**de-emphasising cross-cutting hubs** (event-bus / audit fan-ins on flowcharts;
|
||||
faded sink states like CANCELLED on state diagrams), and removing duplicate
|
||||
edges. A non-destructive **focus mode** spotlights any node/state and its
|
||||
neighbours so you can read a dense graph without changing it. Every rewrite
|
||||
lands in the editor and is reversible with ⌘Z.
|
||||
- **Export** the current diagram to **SVG** or **PNG** (2× scale), or **copy a
|
||||
PNG straight to the clipboard**. (PNG/clipboard re-render flowcharts with
|
||||
text labels so the bitmap rasterizes cleanly across platforms.)
|
||||
|
||||
Reference in New Issue
Block a user