Repository navigation
Feat: Visualize session graph data using ArtifactForceGraph. - #16977
Conversation
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdds 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. ChangesRepresentation rendering
Tooling and styling
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
Possibly related PRs
Suggested labels: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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. Comment |
There was a problem hiding this comment.
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 winCollapse duplicate switch cases via fallthrough.
SessionGraph(173-183) andEmpty(194-204) duplicate theKnowledgeGraphcase (142-152) verbatim;SessionEssence(184-193) duplicates theMindMapcase (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 | 🔵 TrivialFixed node width may crowd/overlap long labels.
getWidthwas changed from a label-length-based calculation to a constant120. 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
📒 Files selected for processing (5)
web/src/constants/compilation.tsweb/src/lib/editor/plugins/floating-selection-toolbar.tsxweb/src/pages/chunk/representation/components/mindmap-g6-graph/index.tsxweb/src/pages/chunk/representation/components/representation-renderer.tsxweb/src/pages/chunk/representation/components/representation-select.tsx
| 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]); |
There was a problem hiding this comment.
🩺 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.
| 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.
| 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> |
There was a problem hiding this comment.
🎯 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.
| 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
e821771 to
c62ed2f
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
web/.prettierrc (1)
7-7: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove the unused Prettier plugins
web/.prettierrcno longer loads the plugins, butweb/package.jsonstill installsprettier-plugin-organize-importsandprettier-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
📒 Files selected for processing (2)
lefthook.ymlweb/.prettierrc
c62ed2f to
126bd8d
Compare
126bd8d to
1275d21
Compare
|
@CodeRabbit review |
✅ Action performedReview finished.
|
Summary
Feat: Visualize session graph data using ArtifactForceGraph.