# Canvas Visualization Views - Cline Implementation Guide ## Quick Start **READ THIS FIRST before starting any implementation work.** This project adds 7 visualization views to help users navigate complex Noodl projects. The views are divided into three types: | Type | What It Does | Examples | |------|--------------|----------| | πŸ—ΊοΈ **Meta Views** | Replace canvas with project-wide view | Topology Map, Trigger Chain | | πŸ“‹ **Sidebar Panels** | Open alongside canvas | X-Ray, Census | | 🎨 **Canvas Overlays** | Enhance canvas with persistent highlighting | Layers, Lineage, Impact | --- ## ⚠️ CRITICAL: Prerequisites First! **DO NOT START VIEW IMPLEMENTATION until prerequisites are complete.** ### Prerequisite Order ``` PREREQ-001: Fix Webpack Caching ──────┐ β”œβ”€β”€β–Ί PREREQ-002 + PREREQ-003 (parallel) β”‚ β”‚ β”‚ β–Ό β”‚ VIEW-000: Foundation β”‚ β”‚ β”‚ β–Ό β”‚ First Views (002, 004) β”‚ β”‚ β”‚ β–Ό └──► PREREQ-004: Canvas Highlighting β”‚ β–Ό Canvas Overlays (005, 006, 007) β”‚ β–Ό Meta Views (001, 003) ``` ### PREREQ-001: Webpack 5 Caching Fix (CRITICAL) **Problem:** Webpack 5 persistent caching prevents code changes from loading during development. **Location of issue documentation:** `dev-docs/tasks/phase-2/TASK-004B-componentsPanel-react-migration/STATUS-BLOCKED.md` **Must fix before:** Any development work **Potential solutions:** 1. Disable persistent caching in dev mode (`cache: false` in webpack config) 2. Configure proper cache invalidation 3. Add cache-busting to development build ### PREREQ-002: React 19 Debug Fixes **Problem:** Legacy `ReactDOM.render()` calls crash debug infrastructure. **Files to fix:** ``` nodegrapheditor.debuginspectors.js β†’ Replace ReactDOM.render() with createRoot() commentlayer.ts β†’ Reuse existing root instead of creating new one TextStylePicker.jsx β†’ Replace ReactDOM.render() with createRoot() ``` **Pattern:** ```javascript // Before (broken): ReactDOM.render(, container); ReactDOM.unmountComponentAtNode(container); // After (correct): if (!this.root) { this.root = createRoot(container); } this.root.render(); // On dispose: this.root.unmount(); ``` ### PREREQ-003: Document Canvas Overlay Pattern **Good news:** CommentLayer already works as a React overlay on the canvas! **Task:** Study and document how CommentLayer works: 1. How it renders React over the canvas 2. How it responds to pan/zoom 3. How it integrates with selection 4. Extract reusable patterns for other overlays **Key file:** `packages/noodl-editor/src/editor/src/views/nodegrapheditor/commentlayer.ts` ### PREREQ-004: Canvas Highlighting API **Needed for:** VIEW-005 (Lineage), VIEW-006 (Impact), VIEW-007 (Layers) **Create API for persistent, multi-channel highlighting:** ```typescript interface CanvasHighlightAPI { highlightNodes(nodeIds: string[], options: HighlightOptions): HighlightHandle; highlightConnections(connections: ConnectionRef[], options: HighlightOptions): HighlightHandle; highlightPath(path: PathDefinition, options: HighlightOptions): HighlightHandle; clearChannel(channel: string): void; clearAll(): void; } interface HighlightOptions { channel: string; // 'lineage', 'impact', 'selection' color?: string; style?: 'solid' | 'pulse' | 'glow'; persistent?: boolean; // Stay until dismissed } ``` **Key behavior:** Highlights persist across component navigation! --- ## Implementation Order ### Phase 1: Foundation (After Prerequisites) **Start with VIEW-000** - this blocks everything else. ``` VIEW-000: Foundation & Shared Utilities β”œβ”€β”€ Graph traversal utilities β”œβ”€β”€ Cross-component resolution β”œβ”€β”€ View infrastructure (Meta Views, Overlays, Panels) β”œβ”€β”€ Navigation helpers └── Debug infrastructure documentation ``` ### Phase 2: Quick Wins (Can parallelize) These are low complexity and don't need canvas overlays: ``` VIEW-002: Component X-Ray (Sidebar Panel) VIEW-004: Node Census (Sidebar Panel) ``` ### Phase 3: Canvas Overlays (After PREREQ-004) ``` VIEW-007: Semantic Layers (Canvas Overlay - simplest) VIEW-005: Data Lineage (Canvas Overlay + panel) VIEW-006: Impact Radar (Canvas Overlay + panel) ``` ### Phase 4: Meta Views (Most complex) ``` VIEW-001: Project Topology Map (Meta View) VIEW-003: Trigger Chain Debugger (Meta View - needs runtime integration) ``` --- ## Key Architectural Decisions ### 1. Three View Types **πŸ—ΊοΈ Meta Views** replace the canvas entirely: - Tab in header: `[πŸ—ΊοΈ Canvas] [πŸ“Š Topology] [⚑ Triggers]` - Full-screen project-wide or timeline view - Component panel still exists but works differently **πŸ“‹ Sidebar Panels** open alongside canvas: - Use existing SidebarModel (already React-ready) - Click items to navigate/highlight on canvas **🎨 Canvas Overlays** enhance the beloved canvas: - Toggle buttons in canvas area: `[Layers] [Lineage] [Impact]` - Based on CommentLayer pattern (already works!) - Persistent highlighting until dismissed ### 2. Persistent Highlighting (Level 5000 Feature) When user traces lineage: 1. Path lights up with glowing connections 2. User navigates to parent component 3. **Path STAYS LIT** on visible nodes 4. Indicator shows "Path continues in child: [Component Name]" 5. Click [Γ—] to dismiss ### 3. Real-Time Updates All views sync in real-time with: - Canvas changes (add/remove nodes) - Runtime state (live values) - Preview interactions ### 4. State Persistence View state persists across sessions: - Active overlays - Filter settings - Traced paths --- ## Key Files & Locations ### Existing Code to Leverage ``` packages/noodl-editor/src/editor/src/ β”œβ”€β”€ contexts/ β”‚ └── NodeGraphContext/ # Already provides switchToComponent() β”œβ”€β”€ models/ β”‚ β”œβ”€β”€ sidebar/sidebarmodel.tsx # Already supports React panels β”‚ └── componentmodel.ts # Component data β”œβ”€β”€ views/ β”‚ └── nodegrapheditor/ β”‚ β”œβ”€β”€ nodegrapheditor.ts # Main canvas (2000+ lines) β”‚ └── commentlayer.ts # TEMPLATE for overlays! ``` ### New Code Locations ``` packages/noodl-editor/src/editor/src/ β”œβ”€β”€ utils/ β”‚ └── graphAnalysis/ # VIEW-000 utilities β”‚ β”œβ”€β”€ traversal.ts β”‚ β”œβ”€β”€ crossComponent.ts β”‚ β”œβ”€β”€ categorization.ts β”‚ └── duplicateDetection.ts β”œβ”€β”€ views/ β”‚ β”œβ”€β”€ MetaViews/ # Meta view tab system β”‚ β”‚ β”œβ”€β”€ MetaViewTabs.tsx β”‚ β”‚ β”œβ”€β”€ TopologyMapView/ β”‚ β”‚ └── TriggerChainView/ β”‚ β”œβ”€β”€ CanvasOverlays/ # Canvas overlay system β”‚ β”‚ β”œβ”€β”€ CanvasOverlayManager.tsx β”‚ β”‚ β”œβ”€β”€ LayersOverlay/ β”‚ β”‚ β”œβ”€β”€ LineageOverlay/ β”‚ β”‚ └── ImpactOverlay/ β”‚ └── panels/ # Sidebar panels (existing pattern) β”‚ β”œβ”€β”€ XRayPanel/ β”‚ └── CensusPanel/ ``` --- ## Testing Strategy ### For Each View 1. **Unit tests** for graph analysis utilities 2. **Integration tests** for view rendering 3. **Manual testing** with complex real projects ### Test Projects Use projects with: - Deep component nesting (5+ levels) - Cross-component data flow - Duplicate node names - Complex event chains --- ## Common Patterns ### Registering a Sidebar Panel ```typescript SidebarModel.instance.register({ id: 'xray', name: 'X-Ray', icon: IconName.Search, panel: ComponentXRayPanel // React component }); ``` ### Navigating to Canvas ```typescript import { NodeGraphContextTmp } from '@noodl-contexts/NodeGraphContext'; // Switch to component NodeGraphContextTmp.switchToComponent(component, { node: nodeId, // Optional: select specific node zoomToFit: true }); ``` ### Accessing Project Data ```typescript import { ProjectModel } from '@noodl-models/projectmodel'; // Get all components ProjectModel.instance.getComponents(); // Get component by name ProjectModel.instance.getComponentWithName('/MyComponent'); // Get current component nodeGraph.activeComponent; ``` --- ## Troubleshooting ### "Changes not loading" β†’ Webpack caching issue. See PREREQ-001. ### "ReactDOM.render is not a function" β†’ React 19 migration incomplete. See PREREQ-002. ### "Debug inspector crashes" β†’ Legacy React patterns in debug code. See PREREQ-002. ### "Canvas overlay not responding to zoom" β†’ Check CommentLayer pattern for transform handling. --- ## Success Criteria For the complete project: - [ ] Prerequisites resolved (webpack, React 19, overlay pattern, highlighting API) - [ ] VIEW-000 foundation complete and tested - [ ] All 7 views implemented and functional - [ ] Persistent highlighting works across component navigation - [ ] Real-time updates working - [ ] State persists across sessions - [ ] No regressions in existing canvas functionality - [ ] Performance acceptable with large projects (100+ components) --- ## Reference Documents - **[README.md](./README.md)** - Project overview and architecture - **[VIEW-PREREQ-modernization-roadmap.md](./VIEW-PREREQ-modernization-roadmap.md)** - Prerequisites detail - **[VIEW-000-foundation/README.md](./VIEW-000-foundation/README.md)** - Foundation implementation - **Individual VIEW-XXX folders** - Detailed specs for each view --- ## Questions? If you encounter blockers or need clarification: 1. Check the individual VIEW-XXX README for detailed specs 2. Reference existing patterns in codebase (CommentLayer, SidebarModel) 3. Document discoveries in a LEARNINGS.md file for future reference