Skip to content

Add Code Graph visualization for AST-based dependency mapping#73

Merged
peterjthomson merged 4 commits intomasterfrom
feature/ast-graph
Jan 23, 2026
Merged

Add Code Graph visualization for AST-based dependency mapping#73
peterjthomson merged 4 commits intomasterfrom
feature/ast-graph

Conversation

@peterjthomson
Copy link
Owner

@peterjthomson peterjthomson commented Jan 20, 2026

Summary

  • Adds a new Code Graph visualization panel that parses code dependencies using AST and displays them as a force-directed network graph
  • Supports PHP (Laravel), Ruby (Rails), and TypeScript codebases with zero-touch parsing (no modifications needed to target repo)
  • Framework-aware optimization for Laravel/Rails - only scans Models, Controllers, and Services directories for performance
  • D3 force-directed layout with landscape oval spread and category-based coloring (Models=green, Controllers=blue, Services=amber)
  • Filters nodes with fewer than 2 connections to reduce visual noise

New Files

  • lib/services/codegraph/ - Parser service and type definitions
  • resources/scripts/php-ast-parser.php - Bundled PHP parser with nikic/php-parser
  • resources/scripts/ruby-ast-parser.rb - Regex-based Ruby parser (no gem dependencies)
  • app/components/panels/viz/codegraph/ - React components and D3/JSON renderers

Test Plan

  • Lint passes
  • All 35 E2E tests pass
  • Tested on Laravel codebase (ventures) - shows 219 nodes, 681 edges
  • Verified no disconnected nodes in graph
  • JSON inspector view works for debugging

Note

Adds an end-to-end Code Graph feature for visualizing code dependencies across PHP, Ruby, and TypeScript.

  • New codegraph viz panel with D3 force graph and JSON inspector (app/components/panels/viz/codegraph/*), wired into CanvasRenderer and styled in app/styles/app.css
  • Parsing service in lib/services/codegraph/ (TS via ts-morph, PHP via bundled nikic/php-parser, Ruby via regex), plus vendor scripts in resources/scripts/*
  • IPC/types plumbing: new schemas/handlers (lib/conveyor/schemas/codegraph-schema.ts, lib/conveyor/handlers/codegraph-handler.ts), API exposed in lib/preload/preload.ts, and renderer types in app/types/electron.d.ts
  • Build packaging updated to include parser scripts (electron-builder.yml); dependencies added (d3, ts-morph, @types/d3)
  • Docs updated (AGENTS.md), and VizPanelType extended to include codegraph

Written by Cursor Bugbot for commit ae00285. This will update automatically on new commits. Configure here.

Introduces a new visualization panel that parses code dependencies using AST
and displays them as a force-directed network graph. Supports PHP (Laravel),
Ruby (Rails), and TypeScript codebases.

Key features:
- Zero-touch parsing (no modifications needed to target repo)
- Framework-aware optimization for Laravel/Rails (scans Models/Controllers/Services)
- D3 force-directed layout with landscape oval spread
- Category-based coloring (Models=green, Controllers=blue, Services=amber)
- Filters nodes with <2 connections to reduce noise
- JSON inspector view for debugging

New files:
- lib/services/codegraph/ - Parser service and type definitions
- resources/scripts/php-ast-parser.php - Bundled PHP parser with nikic/php-parser
- resources/scripts/ruby-ast-parser.rb - Regex-based Ruby parser
- app/components/panels/viz/codegraph/ - React components and renderers
cursor[bot]

This comment was marked as outdated.

When enabled, nodes are colored based on their git status:
- Green: new or modified files (uncommitted changes)
- Red: deleted files

The diff status is fetched via a new IPC handler that queries git status.
Toggle is available in the Code Graph panel header as "Diff" checkbox.
- Add slider to filter top N nodes by connection count (default: 5)
- Rank nodes by total connections and show most connected first
- Preserve viewport zoom/pan when slider changes using D3 best practices
- Store and restore node positions across data updates
- Frame initial view to fit ~100 nodes so revealing more doesn't reframe
- Wider slider (180px) for easier control
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

const { nodes: initialNodes, edges: initialEdges } = useMemo(
() => (schema ? schemaToFlow(schema) : { nodes: [], edges: [] }),
[]
)
Copy link

Choose a reason for hiding this comment

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

useMemo has empty deps but references schema

Low Severity

The useMemo at line 127-130 has an empty dependency array [] but references schema in its callback. This means initialNodes and initialEdges are computed only once at mount time, regardless of the initial schema value. While the useEffect at lines 136-142 compensates for this by updating state when schema changes, the current pattern causes duplicate schemaToFlow calls when schema is initially non-null and creates confusing code that violates React's exhaustive-deps rule.

Fix in Cursor Fix in Web

@peterjthomson peterjthomson merged commit 869b637 into master Jan 23, 2026
3 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.

1 participant