-
Notifications
You must be signed in to change notification settings - Fork 29
feat: integrate @falkordb/canvas for schema visualization and remove … #351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: staging
Are you sure you want to change the base?
Conversation
…react-force-graph-2d - Added @falkordb/canvas dependency to package.json and package-lock.json. - Refactored SchemaViewer component to utilize FalkorDBCanvas for rendering schema data. - Updated schema data handling to remap node IDs and create a nodesMap for efficient access. - Removed all references and dependencies related to react-force-graph-2d. - Implemented dynamic loading of canvas and adjusted theme colors for better visualization. - Enhanced zoom and center functionalities to work with the new canvas implementation.
Completed Working on "Code Review"✅ Workflow completed successfully. |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the 📝 WalkthroughWalkthroughReplaces ForceGraph2D with FalkorDBCanvas for schema visualization; node IDs remapped to sequential numbers, links reference numeric IDs, a nodesMap added, and SchemaViewer props now include isOpen, onClose, onWidthChange?, and sidebarWidth. Canvas is dynamically loaded and theme-aware. Changes
Sequence Diagram(s)sequenceDiagram
participant Viewer as SchemaViewer
participant Loader as DataLoader
participant CanvasLib as FalkorDBCanvas
participant Theme as ThemeProvider
Note over Viewer,Loader: Initialization & data remapping
Viewer->>Loader: loadSchemaData(raw)
Loader-->>Viewer: SchemaData (nodes remapped, nodesMap, links)
Viewer->>CanvasLib: dynamic import & init()
CanvasLib-->>Viewer: canvas instance (canvasLoaded)
Viewer->>CanvasLib: render(convertToCanvasData(SchemaData))
Viewer->>CanvasLib: setBackgroundColor / setForegroundColor (Theme colors)
Theme->>CanvasLib: onThemeChange -> update colors
CanvasLib-->>Viewer: user interactions (zoom/center events)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
Dependency ReviewThe following issues were found:
|
|
Static Code Review 📊 ✅ All quality checks passed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary
- Findings: BLOCKER 1 · CRITICAL 0 · MAJOR 5 · MINOR 0 · SUGGESTION 0 · PRAISE 0 across 3 files.
Key themes
- SchemaViewer’s new canvas integration still has correctness gaps: color setters never run once the canvas finally mounts, link remapping leaves some edges pointing at old node IDs, and the UI shows a blank panel while the canvas bundle loads.
- The app-level lockfile was regenerated against a local @falkordb/[email protected] tarball, leaving it inconsistent with package.json/root lock and making fresh installs fail (BLOCKER) plus a second warning about the stale version record.
- Adding @falkordb/canvas introduces a second React 19 tree because the library lists React as a dependency rather than a peer, risking invalid hook calls when mixed with the app’s React 18 runtime.
Next steps
- Regenerate both app/package-lock.json and the root lockfile against the published @falkordb/[email protected], ensuring the dependency resolves from npm and React is declared as a compatible peer so installs/CI stay reproducible.
- Fix SchemaViewer initialization by reapplying colors when the canvas ref becomes ready, normalizing link endpoints to the remapped IDs, and keeping a loading indicator visible until the canvas bundle reports ready.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AI Code Review 🤖
Files Reviewed: 4
Comments Added: 1
Lines of Code Analyzed: 933
Critical Issues: 1
PR Health: Needs Attention❗
Give 👍 or 👎 on each review comment to help us improve.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (2)
app/src/components/schema/SchemaViewer.tsx (2)
161-166: Links keep old identifiers when lookup fails.This issue was already flagged in previous reviews. The fallback
|| link.sourcepreserves the original string ID when the lookup fails, which will cause rendering issues in the canvas that expects numeric IDs.
455-472: Blank panel when canvas import lags after data loads.This issue was already flagged in previous reviews. When schema data finishes loading but
canvasLoadedis still false, the UI shows neither a loading indicator nor the canvas, resulting in a blank panel.
🧹 Nitpick comments (2)
app/src/components/schema/SchemaViewer.tsx (2)
200-208: Remove debug console.log statement.The
console.log("Stop")appears to be a leftover debug statement that should be removed.🔎 Proposed fix
const handleCenter = useCallback(() => { - console.log("Stop"); - const canvas = canvasRef.current; if (canvas) { canvas.zoomToFit(); } }, []);
92-96: MissingloadSchemaDatain useEffect dependency array.The effect calls
loadSchemaDatabut doesn't include it in the dependency array. This can cause stale closure issues whereselectedGraphortoastreferences become outdated.🔎 Proposed fix
Wrap
loadSchemaDatainuseCallback:- const loadSchemaData = async () => { + const loadSchemaData = useCallback(async () => { if (!selectedGraph) return; // ... rest of function - }; + }, [selectedGraph, toast]); useEffect(() => { if (isOpen && selectedGraph) { loadSchemaData(); } - }, [isOpen, selectedGraph]); + }, [isOpen, selectedGraph, loadSchemaData]);
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
app/package-lock.jsonis excluded by!**/package-lock.jsonpackage-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (2)
app/package.jsonapp/src/components/schema/SchemaViewer.tsx
🧰 Additional context used
📓 Path-based instructions (1)
app/**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Frontend source changes in app/**/*.{ts,tsx} must be compiled before production runs
Files:
app/src/components/schema/SchemaViewer.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: test
- GitHub Check: unit-tests
🔇 Additional comments (5)
app/src/components/schema/SchemaViewer.tsx (4)
9-25: LGTM! Type definitions properly updated for canvas integration.The updated interfaces correctly:
- Change
idtonumberfor canvas compatibility- Add
userIdto preserve the original string identifier- Include
nodesMapfor O(1) node lookups in rendering callbacks
210-249: LGTM! Data transformation is well-structured.The
convertToCanvasDatafunction correctly:
- Computes node sizes based on column count for proper collision detection
- Applies theme-aware colors consistently
- Maps links with sequential IDs
300-304: Verifynode.displayName[1]access is safe.The code accesses
node.displayName[1]without checking ifdisplayNameexists or has sufficient length. IfdisplayNameis undefined or has fewer than 2 elements, this will cause a runtime error or displayundefined.Consider adding a defensive check or using a fallback:
🔎 Proposed fix
ctx.fillText( - node.displayName[1], + node.displayName?.[1] ?? node.data?.name ?? '', node.x || 0, (node.y || 0) - nodeHeight / 2 + headerHeight / 2 + padding / 2 );
461-461: The component already imports and correctly uses theFalkorDBCanvastype from@falkordb/canvas. ThecanvasRefis properly typed at line 35, and the<falkordb-canvas>element at line 461 uses the correctly-typed ref. The package provides the necessary type definitions, so no additional TypeScript declarations are required.Likely an incorrect or invalid review comment.
app/package.json (1)
14-14: Verify the @falkordb/canvas package version and consider pinning.The package version
0.0.12is a pre-1.0 release where semver conventions allow breaking changes in patch versions. Using caret (^) versioning will permit updates to any0.0.xrelease, which could introduce unexpected breaking changes on updates.Consider pinning to an exact version (
"0.0.12") for stability until the library reaches a stable release.
…ckage.json and package-lock.json
…e.json and package-lock.json
…e.json and package-lock.json
…react-force-graph-2d
PR Summary by Typo
Overview
This PR refactors the database schema visualization component by replacing
react-force-graph-2dwith the new@falkordb/canvaslibrary. This change aims to leverage a more specialized and potentially optimized library for graph rendering, improving the schema viewer's performance and maintainability.Key Changes
react-force-graph-2dwith@falkordb/canvasas the primary graph visualization library.SchemaViewer.tsxto integrate the@falkordb/canvascomponent, including dynamic loading and configuration.nodesMap.nodeCanvasObject,nodePointerAreaPaint) to the@falkordb/canvasconfiguration, maintaining theme-aware styling.Work Breakdown
To turn off PR summary, please visit Notification settings.
Summary by CodeRabbit
New Features
Updates
✏️ Tip: You can customize this high-level summary in your review settings.