Skip to content

Feat: Visualize session graph data using ArtifactForceGraph. - #16977

Merged
yingfeng merged 4 commits into
infiniflow:mainfrom
cike8899:feat-structure-wiki
Jul 16, 2026
Merged

yingfeng merged 4 commits into
infiniflow:mainfrom
cike8899:feat-structure-wiki

Conversation

@cike8899

Copy link
Copy Markdown
Contributor

Summary

Feat: Visualize session graph data using ArtifactForceGraph.

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jul 16, 2026
@cike8899
cike8899 marked this pull request as draft July 16, 2026 05:25
@cike8899
cike8899 marked this pull request as ready for review July 16, 2026 05:25
@coderabbitai

coderabbitai Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 489bf5b6-6a80-48c0-a6ec-c2bd51303dff

📥 Commits

Reviewing files that changed from the base of the PR and between 126bd8d and 1275d21.

📒 Files selected for processing (2)
  • lefthook.yml
  • web/.prettierrc
🚧 Files skipped from review as they are similar to previous changes (2)
  • web/.prettierrc
  • lefthook.yml

📝 Walkthrough

Walkthrough

Adds session graph and essence template support, routes new representations to graph components, defers mindmap rendering behind a skeleton, updates representation labels, changes toolbar styling, and revises web formatting and hook configuration.

Changes

Representation rendering

Layer / File(s) Summary
Template kinds and option labels
web/src/constants/compilation.ts, web/src/pages/chunk/representation/components/representation-select.tsx
Adds SessionGraph and SessionEssence kinds and formats option labels through formatKindLabel.
Graph representation dispatch
web/src/pages/chunk/representation/components/representation-renderer.tsx
Routes SessionGraph, SessionEssence, and Empty templates to the appropriate graph components.
Deferred mindmap graph rendering
web/src/pages/chunk/representation/components/mindmap-g6-graph/index.tsx
Precomputes graph data, defers G6 initialization, disables animation, uses fixed node widths, and shows a skeleton until rendering completes.

Tooling and styling

Layer / File(s) Summary
Toolbar and hook configuration
web/src/lib/editor/plugins/floating-selection-toolbar.tsx, lefthook.yml
Changes the toolbar background token and moves conditional web dependency installation into the web-eslint hook while keeping web-prettier independent of Node modules.
Prettier plugin configuration
web/.prettierrc
Replaces the configured Prettier plugins with an empty list.

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

Sequence Diagram(s)

sequenceDiagram
  participant RepresentationRenderer
  participant ArtifactForceGraph
  participant MindMapG6Graph
  participant G6
  RepresentationRenderer->>ArtifactForceGraph: Render SessionGraph or Empty with adapted knowledge graph
  RepresentationRenderer->>MindMapG6Graph: Render SessionEssence with template
  MindMapG6Graph->>G6: Create and render precomputed graph data
  G6-->>MindMapG6Graph: Complete rendering
  MindMapG6Graph-->>RepresentationRenderer: Hide loading skeleton
Loading

Possibly related PRs

Suggested labels: 💞 feature

Poem

I’m a rabbit with graphs in my hat,
Session paths now bloom where they sat.
A skeleton waits while mindmaps take flight,
Toolbar hues settle into base-light.
Hop, render, and click—what a sight!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: visualizing session graph data with ArtifactForceGraph.
Description check ✅ Passed The description includes the required Summary section and states the PR's purpose, though it is brief.
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.

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: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
web/src/pages/chunk/representation/components/representation-renderer.tsx (1)

142-204: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Collapse duplicate switch cases via fallthrough.

SessionGraph (173-183) and Empty (194-204) duplicate the KnowledgeGraph case (142-152) verbatim; SessionEssence (184-193) duplicates the MindMap case (163-172) verbatim. Stack the case labels instead of repeating the JSX.

As per coding guidelines, "Avoid duplicating component structures in JSX; prefer render props or reusable components."

♻️ Proposed fix
     case CompilationTemplateKind.KnowledgeGraph:
+    case CompilationTemplateKind.SessionGraph:
+    case CompilationTemplateKind.Empty:
       return (
         <div className="mt-6 flex-1 min-h-0">
           <ArtifactForceGraph
             data={adaptKnowledgeGraphToForceGraph(template)}
             show
             getNodeId={getArtifactNodeName}
             onNodeClick={handleArtifactNodeClick}
           />
         </div>
       );
     case CompilationTemplateKind.Timeline:
       return (
         <div className="mt-6 flex-1 min-h-0">
           <TimelineX6Graph
             data={adaptTimelineToX6Data(template)}
             show
             onNodeClick={handleTimelineNodeClick}
           />
         </div>
       );
     case CompilationTemplateKind.MindMap:
+    case CompilationTemplateKind.SessionEssence:
       return (
         <div className="mt-6 flex-1 min-h-0">
           <MindMapG6Graph
             template={template}
             show
             onNodeClick={handleMindMapNodeClick}
           />
         </div>
       );
-    case CompilationTemplateKind.SessionGraph:
-      return (
-        <div className="mt-6 flex-1 min-h-0">
-          <ArtifactForceGraph
-            data={adaptKnowledgeGraphToForceGraph(template)}
-            show
-            getNodeId={getArtifactNodeName}
-            onNodeClick={handleArtifactNodeClick}
-          />
-        </div>
-      );
-    case CompilationTemplateKind.SessionEssence:
-      return (
-        <div className="mt-6 flex-1 min-h-0">
-          <MindMapG6Graph
-            template={template}
-            show
-            onNodeClick={handleMindMapNodeClick}
-          />
-        </div>
-      );
-    case CompilationTemplateKind.Empty:
-      return (
-        <div className="mt-6 flex-1 min-h-0">
-          <ArtifactForceGraph
-            data={adaptKnowledgeGraphToForceGraph(template)}
-            show
-            getNodeId={getArtifactNodeName}
-            onNodeClick={handleArtifactNodeClick}
-          />
-        </div>
-      );
     default:
       return <UnsupportedPlaceholder kind={template.kind} />;
🤖 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/components/representation-renderer.tsx`
around lines 142 - 204, Collapse the duplicate switch branches in the renderer
by stacking CompilationTemplateKind.SessionGraph and
CompilationTemplateKind.Empty with KnowledgeGraph before its shared JSX, and
stacking SessionEssence with MindMap before the shared MindMapG6Graph JSX.
Remove the repeated component structures while preserving each case’s existing
data adapters, callbacks, and rendering behavior.

Source: Coding guidelines

🧹 Nitpick comments (1)
web/src/pages/chunk/representation/components/mindmap-g6-graph/index.tsx (1)

87-87: 🎯 Functional Correctness | 🔵 Trivial

Fixed node width may crowd/overlap long labels.

getWidth was changed from a label-length-based calculation to a constant 120. Longer entity names can now overflow the node width and overlap neighboring nodes/edges in the mindmap layout.

🤖 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/components/mindmap-g6-graph/index.tsx` at
line 87, Update the mindmap node width calculation in the graph configuration’s
getWidth callback to derive width from the label length, restoring sufficient
space for long entity names instead of returning the fixed value 120. Preserve
the existing sizing behavior and ensure the callback remains compatible with the
node data it receives.
🤖 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/components/mindmap-g6-graph/index.tsx`:
- Around line 143-154: Apply the show-based visibility condition to the outer
wrapper containing both the loading SkeletonCard and containerRef, matching
ArtifactForceGraph’s behavior. Remove the redundant inner visibility toggle if
appropriate, while preserving loading and container styling so show=false fully
hides the component, including the skeleton overlay.
- Around line 111-141: Update the graph creation/render flow in the effect
containing createGraph so the render promise handles rejection and only updates
loading while that effect run is still active. Track an active/stale flag,
invalidate it during cleanup, guard both success and failure state updates with
it, and ensure rejected renders set loading to false without affecting newer
graph instances.

---

Outside diff comments:
In `@web/src/pages/chunk/representation/components/representation-renderer.tsx`:
- Around line 142-204: Collapse the duplicate switch branches in the renderer by
stacking CompilationTemplateKind.SessionGraph and CompilationTemplateKind.Empty
with KnowledgeGraph before its shared JSX, and stacking SessionEssence with
MindMap before the shared MindMapG6Graph JSX. Remove the repeated component
structures while preserving each case’s existing data adapters, callbacks, and
rendering behavior.

---

Nitpick comments:
In `@web/src/pages/chunk/representation/components/mindmap-g6-graph/index.tsx`:
- Line 87: Update the mindmap node width calculation in the graph
configuration’s getWidth callback to derive width from the label length,
restoring sufficient space for long entity names instead of returning the fixed
value 120. Preserve the existing sizing behavior and ensure the callback remains
compatible with the node data it receives.
🪄 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: aff83703-3fa5-4334-ab84-2c76eb61f031

📥 Commits

Reviewing files that changed from the base of the PR and between d577b49 and 03707cb.

📒 Files selected for processing (5)
  • web/src/constants/compilation.ts
  • web/src/lib/editor/plugins/floating-selection-toolbar.tsx
  • web/src/pages/chunk/representation/components/mindmap-g6-graph/index.tsx
  • web/src/pages/chunk/representation/components/representation-renderer.tsx
  • web/src/pages/chunk/representation/components/representation-select.tsx

Comment on lines +111 to +141
void graph.render().then(() => {
setLoading(false);
});
};

observer = new ResizeObserver(() => {
if (!graph) {
createGraph();
return;
}
// Defer graph creation so the browser paints the skeleton before the
// heavy G6 layout + render starts.
const rafId = requestAnimationFrame(() => {
observer = new ResizeObserver(() => {
if (!graph) {
createGraph();
return;
}

const { width, height } = container.getBoundingClientRect();
if (width > 0 && height > 0) {
graph.resize(width, height);
}
});
const { width, height } = container.getBoundingClientRect();
if (width > 0 && height > 0) {
graph.resize(width, height);
}
});

observer.observe(container);
createGraph();
observer.observe(container);
createGraph();
});

return () => {
cancelAnimationFrame(rafId);
observer?.disconnect();
graph?.destroy();
graphRef.current = null;
};
}, [template, onNodeClick]);
}, [graphData, onNodeClick]);

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 | 🟡 Minor | ⚡ Quick win

Guard the deferred render promise against stale effect runs, and handle rejection.

graph.render().then(() => setLoading(false)) has no .catch, and nothing prevents this callback from firing after the effect has already been cleaned up (e.g., graphData or onNodeClick changes again, or the component unmounts) — the stale callback can flip loading to false prematurely for a graph/graphData that's no longer current, briefly hiding the skeleton before the correct graph is ready. A rejected render also leaves loading stuck at true indefinitely.

🔧 Proposed fix
+    let cancelled = false;
     const createGraph = () => {
       ...
       graph.on<IElementEvent>(NodeEvent.CLICK, handleNodeClick);
       graphRef.current = graph;

-      void graph.render().then(() => {
-        setLoading(false);
-      });
+      void graph
+        .render()
+        .then(() => {
+          if (!cancelled) setLoading(false);
+        })
+        .catch((err) => {
+          console.error('Failed to render mindmap graph', err);
+          if (!cancelled) setLoading(false);
+        });
     };
     ...
     return () => {
+      cancelled = true;
       cancelAnimationFrame(rafId);
       observer?.disconnect();
       graph?.destroy();
       graphRef.current = null;
     };
📝 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
void graph.render().then(() => {
setLoading(false);
});
};
observer = new ResizeObserver(() => {
if (!graph) {
createGraph();
return;
}
// Defer graph creation so the browser paints the skeleton before the
// heavy G6 layout + render starts.
const rafId = requestAnimationFrame(() => {
observer = new ResizeObserver(() => {
if (!graph) {
createGraph();
return;
}
const { width, height } = container.getBoundingClientRect();
if (width > 0 && height > 0) {
graph.resize(width, height);
}
});
const { width, height } = container.getBoundingClientRect();
if (width > 0 && height > 0) {
graph.resize(width, height);
}
});
observer.observe(container);
createGraph();
observer.observe(container);
createGraph();
});
return () => {
cancelAnimationFrame(rafId);
observer?.disconnect();
graph?.destroy();
graphRef.current = null;
};
}, [template, onNodeClick]);
}, [graphData, onNodeClick]);
let cancelled = false;
const createGraph = () => {
...
graph.on<IElementEvent>(NodeEvent.CLICK, handleNodeClick);
graphRef.current = graph;
void graph
.render()
.then(() => {
if (!cancelled) setLoading(false);
})
.catch((err) => {
console.error('Failed to render mindmap graph', err);
if (!cancelled) setLoading(false);
});
};
// Defer graph creation so the browser paints the skeleton before the
// heavy G6 layout + render starts.
const rafId = requestAnimationFrame(() => {
observer = new ResizeObserver(() => {
if (!graph) {
createGraph();
return;
}
const { width, height } = container.getBoundingClientRect();
if (width > 0 && height > 0) {
graph.resize(width, height);
}
});
observer.observe(container);
createGraph();
});
return () => {
cancelled = true;
cancelAnimationFrame(rafId);
observer?.disconnect();
graph?.destroy();
graphRef.current = null;
};
}, [graphData, onNodeClick]);
🤖 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/components/mindmap-g6-graph/index.tsx`
around lines 111 - 141, Update the graph creation/render flow in the effect
containing createGraph so the render promise handles rejection and only updates
loading while that effect run is still active. Track an active/stale flag,
invalidate it during cleanup, guard both success and failure state updates with
it, and ensure rejected renders set loading to false without affecting newer
graph instances.

Comment on lines 143 to +154
return (
<div
ref={containerRef}
className={cn('flex-1 min-h-0 h-full', !show && 'hidden')}
/>
<div className="relative flex-1 min-h-0 h-full">
{loading && (
<div className="absolute inset-0 flex items-center justify-center">
<SkeletonCard className="w-80" />
</div>
)}
<div
ref={containerRef}
className={cn('h-full', !show && 'hidden', loading && 'invisible')}
/>
</div>

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Skeleton overlay ignores the show prop.

Only the inner containerRef div toggles hidden on !show; the outer wrapper containing the SkeletonCard overlay does not. If show is ever false while loading is true, the skeleton renders anyway even though the component should be fully hidden. ArtifactForceGraph applies !show && 'hidden' on its single outer wrapper instead. All current call sites in representation-renderer.tsx pass show as always-true, so this is latent today but breaks the intended hide contract.

As per coding guidelines, "After React component extraction or structural refactoring, verify preserved props and behavior... responsive behavior."

🔧 Proposed fix
-    <div className="relative flex-1 min-h-0 h-full">
+    <div className={cn('relative flex-1 min-h-0 h-full', !show && 'hidden')}>
       {loading && (
         <div className="absolute inset-0 flex items-center justify-center">
           <SkeletonCard className="w-80" />
         </div>
       )}
       <div
         ref={containerRef}
-        className={cn('h-full', !show && 'hidden', loading && 'invisible')}
+        className={cn('h-full', loading && 'invisible')}
       />
     </div>
📝 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
return (
<div
ref={containerRef}
className={cn('flex-1 min-h-0 h-full', !show && 'hidden')}
/>
<div className="relative flex-1 min-h-0 h-full">
{loading && (
<div className="absolute inset-0 flex items-center justify-center">
<SkeletonCard className="w-80" />
</div>
)}
<div
ref={containerRef}
className={cn('h-full', !show && 'hidden', loading && 'invisible')}
/>
</div>
return (
<div className={cn('relative flex-1 min-h-0 h-full', !show && 'hidden')}>
{loading && (
<div className="absolute inset-0 flex items-center justify-center">
<SkeletonCard className="w-80" />
</div>
)}
<div
ref={containerRef}
className={cn('h-full', loading && 'invisible')}
/>
</div>
🤖 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/components/mindmap-g6-graph/index.tsx`
around lines 143 - 154, Apply the show-based visibility condition to the outer
wrapper containing both the loading SkeletonCard and containerRef, matching
ArtifactForceGraph’s behavior. Remove the redundant inner visibility toggle if
appropriate, while preserving loading and container styling so show=false fully
hides the component, including the skeleton overlay.

Source: Coding guidelines

@yingfeng yingfeng added the ci Continue Integration label Jul 16, 2026
@yingfeng
yingfeng marked this pull request as draft July 16, 2026 05:46
@yingfeng
yingfeng marked this pull request as ready for review July 16, 2026 05:47
@cike8899
cike8899 marked this pull request as draft July 16, 2026 09:09
@cike8899
cike8899 marked this pull request as ready for review July 16, 2026 09:09
@yingfeng
yingfeng force-pushed the feat-structure-wiki branch from e821771 to c62ed2f Compare July 16, 2026 12:29

@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

🧹 Nitpick comments (1)
web/.prettierrc (1)

7-7: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Remove the unused Prettier plugins

web/.prettierrc no longer loads the plugins, but web/package.json still installs prettier-plugin-organize-imports and prettier-plugin-packagejson. Drop those devDependencies unless you want to restore the plugin entries.

🤖 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/.prettierrc` at line 7, Remove the unused
prettier-plugin-organize-imports and prettier-plugin-packagejson devDependencies
from web/package.json, since the plugins array in web/.prettierrc is empty. Do
not restore plugin configuration.

Source: Coding guidelines

🤖 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 `@lefthook.yml`:
- Around line 86-99: Serialize web dependency installation before the parallel
web-prettier and web-eslint jobs begin; do not perform the npm_install_needed
check or remove web/node_modules from web-eslint while web-prettier may read it.
Restore or introduce a sequential web-deps pre-step, then have both jobs depend
on that completed setup and preserve the existing npm ci behavior.

---

Nitpick comments:
In `@web/.prettierrc`:
- Line 7: Remove the unused prettier-plugin-organize-imports and
prettier-plugin-packagejson devDependencies from web/package.json, since the
plugins array in web/.prettierrc is empty. Do not restore plugin configuration.
🪄 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: ce21e519-5f33-4a77-b95d-2f9c69ea93e5

📥 Commits

Reviewing files that changed from the base of the PR and between e821771 and c62ed2f.

📒 Files selected for processing (2)
  • lefthook.yml
  • web/.prettierrc

Comment thread lefthook.yml Resolved
@yingfeng
yingfeng force-pushed the feat-structure-wiki branch from c62ed2f to 126bd8d Compare July 16, 2026 12:35
@yingfeng
yingfeng force-pushed the feat-structure-wiki branch from 126bd8d to 1275d21 Compare July 16, 2026 12:38
@yingfeng

Copy link
Copy Markdown
Member

@CodeRabbit review

@coderabbitai

coderabbitai Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@yingfeng
yingfeng merged commit 548f296 into infiniflow:main Jul 16, 2026
3 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