Skip to content

[WIP] Refactor VisualScriptEditorPanel.cpp into focused modules#482

Draft
Copilot wants to merge 2 commits into
masterfrom
copilot/refactor-visual-script-editor-panel
Draft

[WIP] Refactor VisualScriptEditorPanel.cpp into focused modules#482
Copilot wants to merge 2 commits into
masterfrom
copilot/refactor-visual-script-editor-panel

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 29, 2026

  • Analyze CI failure (missing CMakeLists.txt at project root)
  • Analyze dependency chains for test compilation
  • Create SDL3 test stubs (minimal types for compilation without SDL runtime)
  • Create root CMakeLists.txt to fix CI build
  • Verify split files (VisualScriptEditorPanel_*.cpp) completeness
  • Run local compilation check
Original prompt

Problem

The file Source/BlueprintEditor/VisualScriptEditorPanel.cpp has grown to 6220 lines of code, making it difficult to maintain, navigate, and test. The file contains multiple distinct feature areas that would benefit from being split into specialized, focused modules.

Root Causes

  1. Monolithic structure: All functionality (rendering, file I/O, graph synchronization, UI, properties, verification) is in a single file
  2. Mixed responsibilities: Lifecycle, canvas rendering, node properties UI, blackboard management, and verification are all intertwined
  3. Poor navigation: Developers must search through 6000+ lines to find related functionality
  4. Harder testing: Cannot test individual subsystems independently

Proposed Solution

Split VisualScriptEditorPanel.cpp into 11 focused files according to feature domains:

Core Architecture (4 files)

  1. _Core.cpp (350 LOC): Constructor, Initialize/Shutdown, main Render dispatcher
  2. _Canvas.cpp (800 LOC): Graph sync, link rebuilding, canvas rendering, node/link management helpers
  3. _Connections.cpp (200 LOC): Connect/Disconnect operations between nodes
  4. _Interaction.cpp (400 LOC): AddNode, RemoveNode, Undo/Redo, node position sync

UI Rendering (2 files)

  1. _Rendering.cpp (600 LOC): Toolbar, node palette, context menus, save dialog, validation overlay
  2. _FileOps.cpp (500 LOC): Save, Load, Serialize operations with pre-save validation

State Management (3 files)

  1. _Blackboard.cpp (300 LOC): Local/Global variable panel rendering
  2. _Verification.cpp (200 LOC): Graph verification and test execution UI
  3. _NodeProperties.cpp (400 LOC): Properties panel dispatcher and common property helpers

Property-Specific UI (2 files)

  1. _NodeProperties_Branch.cpp (350 LOC): Branch/While node condition editor UI
  2. _NodeProperties_MathOp.cpp (200 LOC): MathOp node operand editor UI

Expected Outcomes

  • ✅ Each file has clear, single responsibility
  • ✅ No circular dependencies (acyclic dependency graph)
  • ✅ Improved code maintainability and testability
  • ✅ Faster compilation (modular structure)
  • ✅ Better IDE navigation and code discovery

Implementation Notes

  • Zero functional changes: All code logic remains identical
  • Incremental migration: Each file is migrated, commented in source, and compilation-verified
  • Header only: Only VisualScriptEditorPanel.h remains as the public interface
  • All methods remain private except public API: No new public methods introduced

Files to Create

Source/BlueprintEditor/
  ├─ VisualScriptEditorPanel.h (existing, unchanged)
  ├─ VisualScriptEditorPanel_Core.cpp (ALREADY EXISTS, verify completeness)
  ├─ VisualScriptEditorPanel_Canvas.cpp (NEW)
  ├─ VisualScriptEditorPanel_Connections.cpp (NEW)
  ├─ VisualScriptEditorPanel_Interaction.cpp (NEW)
  ├─ VisualScriptEditorPanel_Rendering.cpp (NEW)
  ├─ VisualScriptEditorPanel_FileOps.cpp (NEW)
  ├─ VisualScriptEditorPanel_Blackboard.cpp (NEW)
  ├─ VisualScriptEditorPanel_Verification.cpp (NEW)
  ├─ VisualScriptEditorPanel_NodeProperties.cpp (NEW)
  ├─ VisualScriptEditorPanel_NodeProperties_Branch.cpp (NEW)
  ├─ VisualScriptEditorPanel_NodeProperties_MathOp.cpp (NEW)
  └─ VisualScriptEditorPanel.cpp (DEPRECATED - converted to stub includes all above files)

Compilation Verification

Each migration will be tested by:

  1. Verifying function definitions exist in new files
  2. Checking include paths are correct
  3. Ensuring no forward declaration issues
  4. Confirming all state member access is legal

Testing Strategy

  • Unit test each subsystem independently
  • Integration test the full VisualScriptEditorPanel behavior
  • Verify no behavioral changes from refactoring

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: Scinder le fichier VisualScriptEditorPanel.cpp (+6220 LOC) en plusieurs fichiers qui regroupent les fonctionnalités ou des objectifs similaires et/ou communs. Tu analyseras le header et le cpp pour identifier les fonction et methodes similaires qui pourront être scindées dans des fichiers cpp isolés par typologies de features. tu analysera scrupuleusement le header .h et toutes les fonction.cpp pour voir comment les regrouper tout en prenant en compte les fonction helper et les methodes dans chaque fonctions. propose moi un plan de decoupage et regroupement que je validerai. pour chaque fichier tu feras : une mise en commentaire dans le fichier cpp source des méthodes migrées ainsiq qu'un check de compilation systematique. tu ne modifieras pas la nature du code dans les fonctions sans m'en avertir au préalable.

Assistant: Je vais analyser le fichier VisualScriptEditorPanel.cpp et son header pour proposer un plan de découpage stratégique.

Assistant: Merci pour le contexte détaillé. J'ai examiné le fichier VisualScriptEditorPanel.cpp (6220 LOC) et le header correspondant. Je vais vous prop...

This pull request was created from Copilot chat.


⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with Raycast.

Agent-Logs-Url: https://github.com/Atlasbruce/Olympe-Engine/sessions/1f11d791-0c54-47a8-9a82-019435431195

Co-authored-by: Atlasbruce <2962180+Atlasbruce@users.noreply.github.com>
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.

2 participants