Skip to content

Feat: Use G6 to display mind map data. - #16899

Merged
yingfeng merged 1 commit into
infiniflow:mainfrom
cike8899:feat-structure-wiki
Jul 14, 2026
Merged

yingfeng merged 1 commit into
infiniflow:mainfrom
cike8899:feat-structure-wiki

Conversation

@cike8899

Copy link
Copy Markdown
Contributor

Summary

Feat: Use G6 to display mind map data.

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jul 14, 2026
@cike8899 cike8899 added the ci Continue Integration label Jul 14, 2026
@cike8899
cike8899 marked this pull request as draft July 14, 2026 06:49
@cike8899
cike8899 marked this pull request as ready for review July 14, 2026 06:49
@coderabbitai

coderabbitai Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

Mind map rendering

Layer / File(s) Summary
Cycle-aware mind-map tree adaptation
web/src/pages/chunk/representation/utils/adapters.ts
Mind-map hierarchy construction now deduplicates nodes, prevents cycles and multiple parents, and includes node names in G6 data.
G6 graph component
web/src/pages/chunk/representation/components/mindmap-g6-graph/*
Adds typed props and a memoized G6 graph component with styling, labels, click handling, resize observation, visibility, and cleanup.
Mind-map renderer wiring
web/src/pages/chunk/representation/components/representation-renderer.tsx
Renders MindMapG6Graph for mind-map templates and forwards eligible node clicks to the renderer callback.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant RepresentationRenderer
  participant MindMapG6Graph
  participant TreeAdapter
  participant G6Graph
  RepresentationRenderer->>MindMapG6Graph: pass mind-map template
  MindMapG6Graph->>TreeAdapter: adapt template to graph data
  TreeAdapter-->>MindMapG6Graph: return tree data
  MindMapG6Graph->>G6Graph: configure and render graph
  G6Graph-->>MindMapG6Graph: emit node click
  MindMapG6Graph-->>RepresentationRenderer: forward node payload
Loading

Poem

A rabbit hops where mind maps grow,
With tidy roots in rows below.
G6 draws branches, neat and bright,
Clicks and resizing keep them right.
“Hop hooray!” the bunny sings.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description includes the required Summary section, but it lacks background context and detail about the purpose of the change. Expand the Summary with a short background and the user-facing problem this G6 mind map rendering solves.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly matches the main change: adding G6-based rendering for mind map data.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@web/src/pages/chunk/representation/utils/adapters.ts`:
- Around line 101-112: Update the cycle detection loop around relation.from,
parentMap, and child.id to check whether the initial/current cursor already
equals child.id before traversing its parent. Mark self-loops and descendant
cycles as wouldCycle and skip them, while preserving the existing ancestor
traversal for non-cyclic relations.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cbbb5d9f-53b0-4fa6-9421-b07d8819bf19

📥 Commits

Reviewing files that changed from the base of the PR and between 654fc88 and 8c12b91.

📒 Files selected for processing (4)
  • web/src/pages/chunk/representation/components/mindmap-g6-graph/index.tsx
  • web/src/pages/chunk/representation/components/mindmap-g6-graph/types.ts
  • web/src/pages/chunk/representation/components/representation-renderer.tsx
  • web/src/pages/chunk/representation/utils/adapters.ts

Comment on lines +101 to +112
// Avoid cycles: do not attach a node under one of its descendants.
let cursor = relation.from;
let wouldCycle = false;
while (parentMap.has(cursor)) {
const ancestor = parentMap.get(cursor)!;
if (ancestor === child.id) {
wouldCycle = true;
break;
}
cursor = ancestor;
}
if (wouldCycle) continue;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🔴 Critical | ⚡ Quick win

Fix cycle detection to handle self-loops and prevent stack overflows.

The current cycle detection logic fails to catch self-loops (where relation.from === relation.to) because it only checks ancestors (parentMap.get(cursor)) and doesn't verify the initial cursor against child.id. A self-loop will bypass this check, adding the node to its own children array, which later causes an infinite recursion (stack overflow) in treeDataItemToG6TreeData.

Check the current node before traversing up the parent map.

🐛 Proposed fix
-    let cursor = relation.from;
+    let cursor: string | undefined = relation.from;
     let wouldCycle = false;
-    while (parentMap.has(cursor)) {
-      const ancestor = parentMap.get(cursor)!;
-      if (ancestor === child.id) {
+    while (cursor) {
+      if (cursor === child.id) {
         wouldCycle = true;
         break;
       }
-      cursor = ancestor;
+      cursor = parentMap.get(cursor);
     }
     if (wouldCycle) continue;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Avoid cycles: do not attach a node under one of its descendants.
let cursor = relation.from;
let wouldCycle = false;
while (parentMap.has(cursor)) {
const ancestor = parentMap.get(cursor)!;
if (ancestor === child.id) {
wouldCycle = true;
break;
}
cursor = ancestor;
}
if (wouldCycle) continue;
// Avoid cycles: do not attach a node under one of its descendants.
let cursor: string | undefined = relation.from;
let wouldCycle = false;
while (cursor) {
if (cursor === child.id) {
wouldCycle = true;
break;
}
cursor = parentMap.get(cursor);
}
if (wouldCycle) continue;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/src/pages/chunk/representation/utils/adapters.ts` around lines 101 - 112,
Update the cycle detection loop around relation.from, parentMap, and child.id to
check whether the initial/current cursor already equals child.id before
traversing its parent. Mark self-loops and descendant cycles as wouldCycle and
skip them, while preserving the existing ancestor traversal for non-cyclic
relations.

@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (654fc88) to head (8c12b91).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #16899   +/-   ##
=======================================
  Coverage   93.16%   93.16%           
=======================================
  Files          10       10           
  Lines         717      717           
  Branches      118      118           
=======================================
  Hits          668      668           
  Misses         29       29           
  Partials       20       20           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yingfeng
yingfeng merged commit ee14279 into infiniflow:main Jul 14, 2026
9 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants