Skip to content
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

Staging #660

Merged
merged 38 commits into from
Feb 23, 2025
Merged

Staging #660

merged 38 commits into from
Feb 23, 2025

Conversation

Anchel123
Copy link
Contributor

@Anchel123 Anchel123 commented Feb 17, 2025

Summary by CodeRabbit

  • New Features

    • Enhanced interactive graph displays with a smoother layout, improved node separation, and better responsiveness.
    • Upgraded table search functionality for comprehensive filtering across all cells with dynamic insights.
    • Improved chart zoom controls for automatic content fitting and clearer visual presentation.
    • Dynamic user feedback in deletion confirmations, listing specific graphs being deleted.
    • Added optional text width property to categories for better text representation.
  • Chores

    • Updated key dependencies for enhanced stability and overall performance.

Copy link

vercel bot commented Feb 17, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
falkordb-browser ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 23, 2025 3:33pm

Copy link
Contributor

coderabbitai bot commented Feb 17, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This pull request introduces several improvements across multiple components. The ForceGraph component now utilizes enhanced type definitions and a new useEffect hook for better graph layout control. The TableComponent has improved filtering logic and dynamic JSON tree expansion. Additionally, the zoom-to-fit functionality in the graph view and toolbar has been refactored to use a new utility function in lib/utils.ts. Lastly, numerous dependency versions in the package.json have been updated.

Changes

Files Change Summary
app/components/ForceGraph.tsx Updated chartRef type for better type safety; added a new useEffect for initializing force parameters (link, charge, collision, center) for enhanced graph layout.
app/components/TableComponent.tsx Enhanced filtering logic to allow complex searches across all row cells and adjusted the JSONTree's expansion behavior based on search term matches; minor update to data-id attribute setting.
app/graph/GraphView.tsx, app/graph/toolbar.tsx, lib/utils.ts Replaced direct zoom-to-fit calls with a centralized handleZoomToFit utility function that calculates padding from the canvas and applies zoom logic via the chart instance.
package.json Updated multiple dependency and devDependency versions (including several @radix-ui packages, echarts, clsx, and others) to newer releases.
cli.py Deleted a Flask web application file that provided endpoints for schema detection and knowledge graph population.
app/schema/SchemaView.tsx Updated chartRef type to reference ForceGraphMethods<Node, Link> for improved graph handling.
e2e/logic/POM/settingsUsersPage.ts Modified the userSelectRoleEditBtn getter method to broaden the XPath search for button selection and added visibility check before clicking the button.
e2e/tests/settingsConfig.spec.ts Removed the scrolling action from the test case for modifying the maxInfoQueries role, while retaining the core validation logic.
app/components/DialogComponent.tsx Updated the class name of the DialogDescription component to include truncation style.
app/components/ui/combobox.tsx Modified toast notification description to dynamically list deleted graph names and adjusted dialog content styles for improved layout.

Possibly related PRs

  • Staging #614: The changes in the main PR related to the ForceGraph component's resizing logic and enhancements are directly connected to the modifications in the retrieved PR, which also includes improvements to the ForceGraph component's resize handling using a ResizeObserver.
  • Fix #605 Refactor ForceGraph component to improve resize handling #610: The changes in the main PR enhance the ForceGraph component's layout and interaction dynamics, while the retrieved PR focuses on refactoring the resize handling logic of the same ForceGraph component, indicating a direct relationship between the two.
  • Staging #606: The changes in the main PR related to the ForceGraph component, specifically the updates to the chartRef type and its usage, are directly connected to modifications in the retrieved PR, which also enhances type safety and functionality related to graph components.

Suggested reviewers

  • AviAvni

Poem

🐰 Hopping through the code with cheer,
New forces and zoom now crystal clear.
Graph nodes dance in a structured delight,
Tables search deeply—everything’s just right.
With a twitch and a hop, my code tail wags bright,
CodeRabbit loves these changes, a truly joyous sight!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0a15b6d and a4c633b.

📒 Files selected for processing (6)
  • app/api/graph/model.ts (1 hunks)
  • app/components/ForceGraph.tsx (4 hunks)
  • app/components/TableComponent.tsx (4 hunks)
  • app/graph/toolbar.tsx (2 hunks)
  • lib/utils.ts (2 hunks)
  • package.json (2 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (3)
app/components/ForceGraph.tsx (1)

82-112: Excellent improvements to force graph layout!

The force parameters have been well-tuned for better visualization:

  • Link distances adapt based on node connections
  • Collision detection prevents node overlap
  • Center force keeps the graph centered
  • Charge force improves node distribution

Consider memoizing the force calculations if performance becomes an issue with large graphs.

app/components/TableComponent.tsx (2)

115-125: Extract nested search logic into a separate function for better maintainability.

The recursive search implementation is correct but could be more maintainable and potentially more performant.

Consider extracting the nested search logic into a separate utility function:

+const searchInValue = (value: any, searchTerm: string): boolean => {
+  if (typeof value === "object") {
+    return Object.values(value).some(v => 
+      typeof v === "object" 
+        ? searchInValue(v, searchTerm)
+        : v?.toString().toLowerCase().includes(searchTerm.toLowerCase())
+    );
+  }
+  return value?.toString().toLowerCase().includes(searchTerm.toLowerCase());
+};

 rows.filter((row) => !search || row.cells.some(cell =>
-  cell.value && (
-    typeof cell.value === "object"
-      ? Object.values(cell.value).some(value =>
-          typeof value === "object"
-            ? Object.values(value).some(val => val.toString().toLowerCase().includes(search.toLowerCase()))
-            : value?.toString().toLowerCase().includes(search.toLowerCase())
-        )
-      : cell.value.toString().toLowerCase().includes(search.toLowerCase())
-  )
+  cell.value && searchInValue(cell.value, search)
 ))

127-132: Document the purpose of the data-id attribute.

The conditional data-id attribute logic is correct, but its purpose and usage should be documented for better maintainability.

Add a comment explaining why the data-id is only set for string values:

 <TableRow
   onMouseEnter={() => setHover(`${i}`)}
   onMouseLeave={() => setHover("")}
+  // Only set data-id for string values to ensure valid DOM attribute values
   data-id={typeof row.cells[0].value === "string" ? row.cells[0].value : undefined}
   key={i}
 >
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 822c5b3 and 7f7d050.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (6)
  • app/components/ForceGraph.tsx (3 hunks)
  • app/components/TableComponent.tsx (2 hunks)
  • app/graph/GraphView.tsx (2 hunks)
  • app/graph/toolbar.tsx (2 hunks)
  • lib/utils.ts (1 hunks)
  • package.json (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: test
  • GitHub Check: build
  • GitHub Check: test
🔇 Additional comments (3)
app/graph/toolbar.tsx (1)

7-7: LGTM! Good refactoring of zoom functionality.

The zoom-to-fit functionality has been properly refactored to use the new utility function, improving code modularity.

Also applies to: 43-45

app/graph/GraphView.tsx (1)

10-10: LGTM! Good integration of zoom utility.

The zoom-to-fit functionality has been properly integrated into the query handling logic.

Also applies to: 211-213

package.json (1)

56-56:

❓ Verification inconclusive

Verify compatibility with the major version update of lucide-react.

The update from ^0.301.0 to ^0.475.0 is a significant jump that could introduce breaking changes.

Please check the changelog and migration guide:


🌐 Web query:

What are the breaking changes in lucide-react between version 0.301.0 and 0.475.0?

💡 Result:

Between lucide-react versions 0.301.0 and 0.475.0, key breaking changes include:

1. ESM Migration and Naming Convention Changes

  • Icon exports changed from camelCase to PascalCase for React components (e.g., homeHome)[3][5]
  • Requires updating icon imports:
    // Old (pre-ESM)
    import { home } from 'lucide-react';
    
    // New (post-ESM)
    import { Home } from 'lucide-react';

2. Package Structure Changes

  • Introduced stricter ESM module resolution via "exports" field in package.json[5]
  • May break projects using non-standard import paths like:
    // No longer supported
    import Icon from 'lucide-react/dist/esm/icons/Home';

3. Dynamic Icon Handling

  • Replaced dynamicIconImports with new DynamicIcon component[6]
  • New usage pattern:
    import { DynamicIcon } from 'lucide-react/dynamic';
    
    // Instead of dynamic imports
    <DynamicIcon name="camera" />

4. SVG String Formatting

  • Added whitespace around <svg> tags in raw icon strings[3]
  • Requires trimming for some SVG manipulation libraries:
    // Before passing to SVG.js etc.
    const cleanedSvg = rawSvgString.trim();

Compatibility Considerations

These changes primarily affect:

  • Projects using dynamic icon name resolution[3]
  • Custom build pipelines importing internal modules[5]
  • Applications relying on exact SVG string formatting[3]

For most static icon usage (direct component imports), upgrades should be straightforward with simple naming convention updates[6].

Citations:


Verify compatibility with the major version update of lucide-react.

The update from ^0.301.0 to ^0.475.0 introduces several breaking changes that may affect your project:

  • Renamed Icon Exports: Icon components are now exported in PascalCase rather than camelCase. Ensure any icon imports (e.g., import { home } from 'lucide-react';) are updated to the new format (e.g., import { Home } from 'lucide-react';).
  • Package Structure Modifications: The package now uses stricter ESM module resolution via the "exports" field. Verify that you are not relying on unofficial import paths (such as importing directly from internal directories like lucide-react/dist/esm/icons/Home).
  • Dynamic Icon Handling: If you use dynamic imports for icons, note that the previous dynamicIconImports mechanism has been replaced by a new DynamicIcon component. Update your usage accordingly.
  • SVG String Formatting: There’s now additional whitespace around <svg> elements in raw icon strings. If your project processes SVGs programmatically, consider trimming these strings where necessary.

Please review your code for these potential impact areas and update your imports and usage patterns as needed to ensure compatibility.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
app/components/ForceGraph.tsx (1)

81-111: Extract force parameters as named constants.

The force parameters should be extracted as named constants to improve maintainability and make adjustments easier.

Apply this diff to improve the implementation:

+const LINK_DISTANCE = 30;
+const CHARGE_STRENGTH = -30;
+const CHARGE_MAX_DISTANCE = 150;
+const COLLISION_RADIUS_MULTIPLIER = 1.5;
+const CENTER_FORCE_STRENGTH = 0.05;
+
 useEffect(() => {
   if (!chartRef.current) return;
   
   // Adjust force parameters for better graph layout
   const linkForce = chartRef.current.d3Force('link');
   if (linkForce) {
     linkForce
-      .distance(() => 30)
+      .distance(() => LINK_DISTANCE)
       .strength((link: any) => 1 / Math.min(
         graph.Elements.nodes.filter(n => n.id === link.source.id).length,
         graph.Elements.nodes.filter(n => n.id === link.target.id).length
       ));
   }

   // Adjust charge force for node repulsion
   const chargeForce = chartRef.current.d3Force('charge');
   if (chargeForce) {
     chargeForce
-      .strength(-30)
-      .distanceMax(150);
+      .strength(CHARGE_STRENGTH)
+      .distanceMax(CHARGE_MAX_DISTANCE);
   }

   // Add collision force to prevent node overlap
   chartRef.current.d3Force('collision',
-    d3.forceCollide(NODE_SIZE * 1.5)
+    d3.forceCollide(NODE_SIZE * COLLISION_RADIUS_MULTIPLIER)
   );

   // Center force to keep graph centered
   const centerForce = chartRef.current.d3Force('center');
   if (centerForce) {
-    centerForce.strength(0.05);
+    centerForce.strength(CENTER_FORCE_STRENGTH);
   }
 }, [chartRef, graph.Elements.nodes])
app/schema/SchemaView.tsx (1)

214-251: Remove commented-out Cytoscape-specific code.

The commented-out handleSetCategory function contains Cytoscape-specific code that is no longer relevant after migrating to Force Graph. Consider removing this code to improve maintainability.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 539c481 and a9c0be4.

📒 Files selected for processing (7)
  • app/components/ForceGraph.tsx (3 hunks)
  • app/graph/GraphView.tsx (3 hunks)
  • app/graph/toolbar.tsx (2 hunks)
  • app/schema/SchemaView.tsx (2 hunks)
  • e2e/logic/POM/settingsUsersPage.ts (2 hunks)
  • e2e/tests/settingsConfig.spec.ts (0 hunks)
  • lib/utils.ts (2 hunks)
💤 Files with no reviewable changes (1)
  • e2e/tests/settingsConfig.spec.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • app/graph/toolbar.tsx
  • app/graph/GraphView.tsx
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: test
  • GitHub Check: test
🔇 Additional comments (2)
lib/utils.ts (1)

95-107: Improve type safety and error handling in handleZoomToFit.

The function has several areas for improvement:

  1. Magic numbers should be named constants
  2. Direct DOM querying is fragile
  3. Missing error handling when canvas is not found
  4. Minimum padding value mentioned in the comment is not enforced

Apply this diff to improve the implementation:

+const ZOOM_DURATION_MS = 1000;
+const ZOOM_PADDING_RATIO = 0.1;
+const MIN_ZOOM_PADDING = 40;
+
 export function handleZoomToFit(chartRef?: MutableRefObject<ForceGraphMethods<Node, Link> | undefined>) {
   const chart = chartRef?.current
   if (chart) {
     // Get canvas dimensions
     const canvas = document.querySelector('.force-graph-container canvas') as HTMLCanvasElement;
-    if (!canvas) return;
+    if (!canvas) {
+      console.warn('Canvas element not found for zoom-to-fit operation');
+      return;
+    }

     // Calculate padding as 10% of the smallest canvas dimension, with minimum of 40px
     const minDimension = Math.min(canvas.width, canvas.height);
-    const padding = minDimension * 0.1
-    chart.zoomToFit(1000, padding)
+    const padding = Math.max(minDimension * ZOOM_PADDING_RATIO, MIN_ZOOM_PADDING);
+    chart.zoomToFit(ZOOM_DURATION_MS, padding)
   }
 }
e2e/logic/POM/settingsUsersPage.ts (1)

23-25: LGTM! The XPath selector is now more flexible.

The updated XPath expression correctly targets any button within the specified table cell, making the selector more resilient to changes in the button's position within the cell.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 (1)
app/components/TableComponent.tsx (1)

152-159: 🛠️ Refactor suggestion

Reuse the search logic for JSONTree expansion.

The JSONTree expansion logic duplicates the filtering implementation. This could lead to maintenance issues if the search logic needs to be updated.

Extract the search logic into a reusable function:

+const searchInValue = (value: any, searchTerm: string): boolean => {
+  if (typeof value === "object") {
+    return Object.values(value).some(v => 
+      typeof v === "object" 
+        ? searchInValue(v, searchTerm)
+        : v?.toString().toLowerCase().includes(searchTerm.toLowerCase())
+    );
+  }
+  return value?.toString().toLowerCase().includes(searchTerm.toLowerCase());
+};

 <JSONTree
   key={search}
-  shouldExpandNodeInitially={() =>
-    search !== "" && Object.values(cell.value as object).some(value =>
-      typeof value === "object"
-        ? Object.values(value as object).some(val =>
-            val.toString().toLowerCase().includes(search.toLowerCase())
-          )
-        : value?.toString().toLowerCase().includes(search.toLowerCase()))}
+  shouldExpandNodeInitially={() => search !== "" && searchInValue(cell.value, search)}
   keyPath={[headers[j]]}
🧹 Nitpick comments (1)
app/components/ui/combobox.tsx (1)

99-101: Enhance toast message readability.

The current implementation directly joins graph names with commas. For better readability, consider formatting the list properly.

-      description: `The graph(s) ${opts.join(", ")} have been deleted successfully`,
+      description: opts.length === 1
+        ? `The graph "${opts[0]}" has been deleted successfully`
+        : `The following graphs have been deleted successfully: ${opts.join('", "')}"`,
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a9c0be4 and 0a15b6d.

📒 Files selected for processing (3)
  • app/components/DialogComponent.tsx (1 hunks)
  • app/components/TableComponent.tsx (4 hunks)
  • app/components/ui/combobox.tsx (3 hunks)
🔇 Additional comments (4)
app/components/ui/combobox.tsx (2)

150-157: LGTM! Good layout improvements.

The flex layout and overflow handling changes improve the component's responsiveness and usability:

  • Using flex-col for proper vertical layout
  • Setting max-h-[90dvh] to prevent overflow
  • Adding grow overflow-hidden to table for proper space utilization

162-172: LGTM! Enhanced user feedback.

Good improvement to the delete confirmation dialog:

  • Added max width constraint for better readability
  • Including specific graph names in the confirmation message helps prevent accidental deletions
app/components/TableComponent.tsx (2)

39-42: LGTM! Good component flexibility.

Adding the className prop allows for better component customization and reusability.


116-126: LGTM! Enhanced search functionality.

The improved filtering logic now properly handles nested objects and provides more comprehensive search results.

@barakb barakb merged commit 158a23a into main Feb 23, 2025
8 of 11 checks passed
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.

4 participants