Skip to content

feat: domain-node Mermaid flowchart popup#100

Closed
lxb12123 wants to merge 28 commits into
Egonex-AI:mainfrom
lxb12123:feat/domain-mermaid-popup
Closed

feat: domain-node Mermaid flowchart popup#100
lxb12123 wants to merge 28 commits into
Egonex-AI:mainfrom
lxb12123:feat/domain-mermaid-popup

Conversation

@lxb12123

@lxb12123 lxb12123 commented Apr 21, 2026

Copy link
Copy Markdown

Summary

  • Click a domain node on the Domain graph → 480×260 slide-up popup with a Mermaid flowchart of the node's internal business logic (nodes = logical steps, arrows labeled with API calls where applicable)
  • Fullscreen modal with Copy source and Open in Mermaid Live (pako-encoded URL); popup + modal close via ✕ / Esc (modal only)
  • Source is generated offline by domain-analyzer and persisted to domainMeta.mermaid; assemble-reviewer dry-run-validates via new scripts/validate-mermaid.mjs; dashboard lazy-imports mermaid so the main bundle is unaffected
  • Small-window scroll area supports drag-to-pan for oversized diagrams
  • Theme-reactive: onThemeChange subscription re-renders the SVG when the user switches themes

Design docs

  • Spec: docs/superpowers/specs/2026-04-20-mermaid-service-flowchart-design.md
  • Plan: docs/superpowers/plans/2026-04-20-mermaid-service-flowchart.md

What's new

  • Schema (packages/core): optional DomainMeta.mermaid: string field (z.string().min(1).optional(), .passthrough() preserves it through sanitization)
  • Plugin (understand-anything-plugin/): scripts/validate-mermaid.mjs JSONL-in/out dry-run parser
  • Agents: domain-analyzer.md emits Mermaid flowcharts with API labels on edges (5–15 nodes per domain); assemble-reviewer.md strips invalid entries with [mermaid-invalid] log
  • Dashboard (packages/dashboard):
    • New components: MermaidRenderer, MermaidFlowchartPopup, MermaidFlowchartModal
    • New hook: useMermaidPopupPosition (5-candidate collision avoidance; reactive to ReactFlow viewport)
    • New theme helper: themes/mermaid-theme.ts (CSS vars → Mermaid themeVariables)
    • Store slice: mermaidPopupNodeId, mermaidModalOpen + 4 actions
    • Integration: DomainClusterNode triggers popup; DomainGraphView mounts popup/modal; setViewMode auto-closes on non-domain view
    • Theme engine now emits onThemeChange notifications
    • New test infrastructure (Vitest + JSDOM + @testing-library) — dashboard had no tests before this PR
    • aria-modal=\"true\" on both dialogs; modal focuses close button on open and restores focus on close

Test plan

  • Core tests: 659 pass (+5 new)
  • Dashboard tests: 28 pass (new infrastructure)
  • pnpm --filter @understand-anything/core build — success
  • pnpm --filter @understand-anything/dashboard build — success; `mermaid` is in a separate lazy chunk (verified by inspecting dist/assets/)
  • Manual: Mermaid popup renders on domain click; fullscreen modal copy + Live link work; Esc closes modal; ✕ closes popup; empty-state when mermaid field missing; <pre> fallback on parse error
  • Drag-to-pan inside scroll container (both horizontal and vertical)
  • (Reviewer to verify) Re-run /understand --full on a real project and confirm agent emits domainMeta.mermaid

Non-goals / known limitations

  • Only domain node type in v1 (not flow/step)
  • Only flowchart TD diagram type; sequenceDiagram/classDiagram/stateDiagram deferred
  • No pinch/zoom inside the modal (relies on browser scroll + drag-to-pan)
  • mermaid is a production dep of dashboard — acceptable while dashboard is \"private\": true

Version

Bumped 2.3.1 → 2.4.0 across all four version files per CLAUDE.md §Versioning.

result

img_v3_02111_0973e23c-bb2f-40cd-9e4a-774a60bf982g img_v3_02111_8716c4cc-07a2-4718-9202-b8184c528deg

🤖 Generated with Claude Code

lxb12123 and others added 25 commits April 21, 2026 22:39
…popup

Introduces the design for a bottom slide-up popup that renders a Mermaid
flowchart of each domain node's internal business logic. Source is generated
offline by the domain-analyzer agent and persisted under
domainMeta.mermaid; dashboard is a pure renderer with lazy-imported mermaid.
Covers schema extension, agent pipeline changes, popup collision avoidance,
fullscreen modal, error handling and fallbacks, theme integration, and
testing strategy.

Also ignores .superpowers/ (Visual Companion session artifacts).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
20 tasks across 14 phases covering schema extension, agent prompts,
dashboard test infrastructure bootstrap, mermaid rendering, popup/modal
components, collision-avoiding position hook, integration wiring, and
manual acceptance. Follows TDD with commits per task.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds onThemeChange subscription API to allow components to react when theme
changes. Listeners are called after applyTheme() updates CSS variables, enabling
re-renders of theme-dependent content like Mermaid SVGs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Implements MermaidRenderer with loading, success (SVG), parse-error (pre+copy), and chunk-error (retry) states; dynamic mermaid import for lazy chunking; theme-reactive via onThemeChange.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Implements the MermaidFlowchartPopup component with header (node name, enlarge/close buttons), mermaid rendering via MermaidRenderer, empty state, and slide-up animation. Adds ResizeObserver polyfill to test setup.ts for JSDOM compatibility.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ivity

- Add aria-modal to popup and modal dialogs
- Add focus trap in modal (focuses close button on open, restores on close)
- Add test for chunk load error fallback path
- Subscribe popup position hook to ReactFlow viewport state so it re-runs on pan/zoom

Addresses Important issues 1, 2, 4 from the final code review.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… cleaner modal labels

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add PanZoomScroll wrapper component that enables click-and-drag panning
of the Mermaid SVG in both the popup and fullscreen modal, while
preserving existing scroll-wheel and scrollbar behavior.
useMaxWidth:true was forcing SVG to shrink-fit container width — wide diagrams
never actually overflowed horizontally, so scrollLeft stayed at 0 and the pan
handler could only move vertically.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Lum1104

Lum1104 commented Apr 21, 2026

Copy link
Copy Markdown
Collaborator

@codex review this

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4c48501726

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +61 to +65
const topLeft = rf.flowToScreenPosition({
x: n.position.x,
y: n.position.y,
});
const bottomRight = rf.flowToScreenPosition({

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Normalize node coords to popup container before intersecting

This collision check mixes coordinate spaces: flowToScreenPosition returns screen/viewport pixels, while popupRect is computed in popup-container local coordinates (0..container.width/height). When the ReactFlow canvas is offset from the page origin, intersections are miscomputed, so the hook can pick a “free” candidate that still overlaps nodes (or reject valid positions). Convert node bounds into the same container-local space (for example by subtracting the container's bounding rect) before calling aabbIntersect.

Useful? React with 👍 / 👎.

Comment thread understand-anything-plugin/package.json Outdated
},
"devDependencies": {
"@types/node": "^22.0.0",
"mermaid": "^10.9.0",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Promote mermaid to runtime dependency for validator script

The new scripts/validate-mermaid.mjs imports mermaid at runtime, and assemble-reviewer now invokes that script during graph assembly, but mermaid is declared only in devDependencies. In installs that omit dev deps (common for packaged/production usage), the validator fails with ERR_MODULE_NOT_FOUND, which breaks Mermaid dry-run validation in this feature path. mermaid should be listed under dependencies for this package.

Useful? React with 👍 / 👎.

lxb12123 and others added 3 commits April 23, 2026 01:57
validate-mermaid.mjs imports mermaid at runtime and assemble-reviewer
invokes that script during graph assembly, so mermaid cannot live in
devDependencies — installs that omit dev deps would fail with
ERR_MODULE_NOT_FOUND. Regenerated pnpm-lock.yaml to match (also
unblocks CI's --frozen-lockfile install).

Addresses Codex review P1.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
flowToScreenPosition returns viewport pixels; popupRect was built in
popup-container local space. When the ReactFlow canvas was offset from
the page origin the AABB intersect mixed coordinate frames — some
candidates that still overlapped a node tested as "free", others that
were actually free were rejected.

Extend ContainerBounds with optional left/top (container viewport
origin) and subtract that offset from each node rect before the
intersect. MermaidFlowchartPopup now passes getBoundingClientRect()
origin and refreshes it on window scroll/resize so the offset stays
current when the page shifts.

Addresses Codex review P2.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Without an include filter, vitest run from the skill package root
walks into packages/dashboard and executes its tests under the default
node env. The dashboard tests (new in this PR) use @testing-library/
react and assume JSDOM, so they all failed with "document is not
defined" once CI got past the frozen-lockfile install.

Restrict discovery to src/**/*.test.ts — dashboard tests keep running
under their own packages/dashboard/vitest.config.ts via
`pnpm --filter @understand-anything/dashboard test`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@lxb12123 lxb12123 closed this Apr 22, 2026
@lxb12123 lxb12123 reopened this Apr 22, 2026
@Lum1104

Lum1104 commented Apr 23, 2026

Copy link
Copy Markdown
Collaborator

Awesome, it would be nice if you can have the pop out frame larger. Like half 3/5 of the full screen? Then the expand version bigger.

@Lum1104
Lum1104 marked this pull request as draft April 23, 2026 02:09
@Lum1104

Lum1104 commented Apr 24, 2026

Copy link
Copy Markdown
Collaborator

Hi, seems that you miss understand the /understand command, I think you should add the workflow to /understand-domain or add a new command like /understand-{xxx}. Feel free to open a new pr, I'll close this for the commit history cleanning.

@Lum1104 Lum1104 closed this Apr 24, 2026
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