Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,5 @@ generated_readme.md
python_runtime

# Ignore Claude AI files
.claude/
.claude/
.claude_code/
15 changes: 13 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ PyFlowGraph is a universal node-based visual scripting editor built with Python
- **python_code_editor.py**: Core editor widget with line numbers and smart indentation
- **python_syntax_highlighter.py**: Python syntax highlighting implementation

### Event System

- **event_system.py**: Event-driven execution system for interactive applications with live mode support

### Utilities

- **color_utils.py**: Color manipulation utilities
Expand All @@ -73,6 +77,7 @@ PyFlowGraph is a universal node-based visual scripting editor built with Python
- Nodes execute when all input dependencies are satisfied
- Each node runs in an isolated subprocess for security
- Pin values are serialized/deserialized as JSON between nodes
- Supports both **Batch Mode** (traditional sequential execution) and **Live Mode** (event-driven interactive execution)

### Graph Persistence

Expand All @@ -93,10 +98,16 @@ PyFlowGraph is a universal node-based visual scripting editor built with Python

The README mentions `socket_type.py` and `default_graphs.py` but these files don't exist in the current codebase. The socket type functionality appears to be implemented directly in other modules.

## Testing

- **test_execution_flow.py**: Simple test script for validating node execution flow and architecture
- No formal test suite exists - testing is primarily done through example graphs in the `examples/` directory
- Use `python test_execution_flow.py` to run basic execution tests

## Development Notes

- This is an experimental AI-generated codebase for learning purposes
- No formal test suite exists - testing is done through example graphs
- The application uses PySide6 for the Qt-based GUI
- The application uses PySide6 for the Qt-based GUI
- Font Awesome integration provides professional iconography
- All nodes execute in isolated environments for security
- Dependencies are managed via `requirements.txt` (PySide6, Nuitka for compilation)
71 changes: 71 additions & 0 deletions FINAL_TEST_SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Final Test Summary - GUI Loading Bug Investigation

## Issue Report
**Original Problem**: "Any node that has a GUI doesn't load correctly" from `text_processing_pipeline.md`

## Investigation Results

After comprehensive testing, I discovered that the issue is **NOT** a GUI rendering problem, but a **pin categorization bug**.

### ✅ What Works Correctly

1. **GUI Components ARE Loading**: All GUI nodes show:
- Widgets created properly (3-4 widgets per node)
- Proxy widgets visible and correctly sized
- GUI code executing without errors
- GUI state being applied correctly

2. **Examples from text_processing_pipeline.md**:
- "Text Input Source": 3 widgets, 276×317px, visible ✅
- "Text Cleaner & Normalizer": 4 widgets, 250×123px, visible ✅
- "Keyword & Phrase Extractor": 2 widgets, 250×96px, visible ✅
- "Processing Report Generator": 3 widgets, 276×313px, visible ✅

### ❌ The Real Bug: Pin Direction Categorization

**Root Cause**: Nodes loaded from markdown have pins, but the pins lack proper `pin_direction` attributes.

**Evidence**:
- Node shows "Total pins: 9" ✅
- But "Input pins: 0" and "Output pins: 0" ❌
- Pin direction filtering `[p for p in pins if p.pin_direction == 'input']` returns empty arrays

**This explains the reported symptoms**:
1. **"GUI doesn't show"** → Actually, connections don't work because pins aren't categorized properly
2. **"Pins stuck in top-left"** → Pin positioning fails when pin_direction is undefined
3. **"Zero height nodes"** → Layout calculations fail without proper pin categorization

### Test Files Created

1. **`test_gui_loading_bugs.py`** - Basic GUI loading tests (7 tests)
2. **`test_gui_rendering.py`** - Visual rendering verification (5 tests)
3. **`test_specific_gui_bugs.py`** - Targeted bug reproduction (3 tests)
4. **`test_pin_creation_bug.py`** - Root cause identification (3 tests)

### Recommended Fix

The issue is in the pin creation/categorization during markdown deserialization. Need to investigate:

1. **`node.py`** - `update_pins_from_code()` method
2. **`pin.py`** - Pin direction assignment during creation
3. **`node_graph.py`** - Pin handling during `deserialize()`

The pin direction attributes (`pin_direction = "input"/"output"`) are not being set correctly when nodes are loaded from markdown format.

### Test Commands

To reproduce the bug:
```bash
python test_pin_creation_bug.py
```

To verify GUI components work correctly:
```bash
python test_gui_rendering.py
```

## Conclusion

The "GUI loading bug" is actually a **pin categorization bug** that makes the nodes appear broken because connections don't work properly. The GUI components themselves are loading and rendering correctly.

**Next Steps**: Fix the pin direction assignment during markdown deserialization process.
145 changes: 145 additions & 0 deletions TEST_GUI_LOADING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
# GUI Loading Tests for PyFlowGraph

This document describes the unit tests created to detect GUI-related loading issues in markdown graphs.

## Problem Statement

The issue reported was: "any node that has a GUI doesn't load correctly" when loading markdown graphs. This suggests systematic problems with GUI component initialization during the markdown-to-graph deserialization process.

## Test Files Created

### 1. `test_gui_loading_bugs.py` - Core Bug Detection Tests

This is the main test file focused specifically on GUI loading issues. It contains targeted tests for:

- **Basic GUI Loading**: Verifies that nodes with GUI components load and rebuild successfully
- **Zero Height Bug**: Tests for the specific bug mentioned in git commits where nodes had zero height after loading
- **GUI Code Execution Errors**: Ensures that syntax errors in GUI code are handled gracefully
- **Proxy Widget Creation**: Verifies that QGraphicsProxyWidget objects are properly created for GUI nodes
- **GUI State Handling**: Tests that saved GUI state is properly applied during loading
- **Reroute Node Loading**: Ensures reroute nodes don't cause GUI-related errors
- **Real File Loading**: Tests loading actual markdown example files

### 2. `test_gui_loading.py` - Comprehensive Test Suite

This is a more extensive test suite that includes:

- Complex GUI layout testing
- Malformed JSON handling
- Missing GUI state handlers
- FileOperations integration testing
- GUI refresh mechanisms

## Key Testing Areas

### GUI Component Lifecycle

1. **Loading Phase**: Markdown → JSON → Node deserialization
2. **GUI Rebuild Phase**: Executing `gui_code` to create Qt widgets
3. **State Application Phase**: Applying saved `gui_state` to widgets
4. **Rendering Phase**: QGraphicsProxyWidget integration

### Common Failure Points Tested

1. **Syntax Errors in GUI Code**: Invalid Python code in GUI Definition sections
2. **Missing Dependencies**: Qt widgets not properly imported
3. **Widget Creation Failures**: Errors during widget instantiation
4. **State Application Errors**: GUI state not matching widget structure
5. **Height/Sizing Issues**: Nodes with zero or negative dimensions
6. **Proxy Widget Failures**: QGraphicsProxyWidget not created properly

### Error Handling Verification

The tests verify that:
- Invalid GUI code doesn't crash the application
- Missing GUI components are handled gracefully
- Malformed metadata doesn't prevent loading
- Error nodes still maintain basic functionality

## Running the Tests

### Quick GUI Bug Detection
```bash
python test_gui_loading_bugs.py
```

### Comprehensive GUI Testing
```bash
python test_gui_loading.py
```

### Test Output Interpretation

- **All tests pass**: No GUI loading bugs detected
- **Test failures**: Specific GUI loading issues identified
- **Error output**: Details about what failed and where

## Test Strategy

### Unit Test Approach
- Each test focuses on a specific aspect of GUI loading
- Tests use synthetic markdown content to isolate issues
- Real file testing validates against actual usage

### Synthetic Test Data
- Minimal markdown content that exercises specific features
- Controlled scenarios for reproducing bugs
- Known-good and known-bad test cases

### Error Simulation
- Deliberately malformed GUI code
- Missing required components
- Invalid metadata structures

## Integration with Development Workflow

### Pre-commit Testing
Add to git hooks or CI/CD pipeline:
```bash
python test_gui_loading_bugs.py && echo "GUI loading tests passed"
```

### Regression Testing
Run these tests whenever:
- GUI-related code is modified
- Markdown loading logic is changed
- Node serialization/deserialization is updated
- Qt widget handling is modified

### Bug Reproduction
When GUI loading issues are reported:
1. Create a test case that reproduces the issue
2. Fix the underlying problem
3. Verify the test now passes
4. Add the test to the suite permanently

## Future Enhancements

### Additional Test Coverage
- Performance testing for large graphs with many GUI nodes
- Memory leak detection during repeated load/unload cycles
- Cross-platform GUI rendering differences
- Complex widget interaction testing

### Automated Testing
- Integration with CI/CD systems
- Automated testing of example files
- Performance benchmarking
- Visual regression testing

## Maintenance

### Updating Tests
When new GUI features are added:
1. Add corresponding test cases
2. Update test documentation
3. Verify backwards compatibility

### Test Data Maintenance
- Keep synthetic test markdown in sync with format changes
- Update expected behaviors when GUI system evolves
- Maintain test examples that cover edge cases

## Conclusion

These test suites provide comprehensive coverage for GUI loading issues in PyFlowGraph's markdown format. They serve as both regression prevention and debugging tools, helping maintain reliable GUI functionality as the codebase evolves.
85 changes: 85 additions & 0 deletions TEST_RUNNER_README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Test Runner Scripts

This directory contains helper scripts to easily run the GUI loading tests.

## Quick Start

### Option 1: Quick Test (Recommended)
```batch
run_quick_test.bat
```
- Runs the 2 most important tests
- Identifies the core issues quickly
- Shows clear diagnosis and recommendations
- Takes ~1-2 minutes

### Option 2: Interactive Test Menu
```batch
run_tests.bat
```
- Interactive menu to choose specific tests
- Run individual test suites
- Option to run all tests
- More detailed testing options

## Test Files Overview

### Core Issue Detection
- **`test_specific_gui_bugs.py`** - Tests your exact reported issue with text_processing_pipeline.md
- **`test_pin_creation_bug.py`** - Identifies the root cause (pin direction bug)

### Comprehensive Testing
- **`test_gui_rendering.py`** - Verifies visual GUI rendering works
- **`test_gui_loading.py`** - Full GUI loading test suite
- **`test_gui_loading_bugs.py`** - Basic GUI bug detection
- **`test_execution_flow.py`** - Original execution test

## Test Results Interpretation

### ✅ If Tests Pass
- **GUI Tests Pass**: GUI components are working correctly
- **Pin Tests Pass**: Pin creation and categorization is working

### ❌ If Tests Fail
- **GUI Tests Fail**: GUI rendering issues detected
- **Pin Tests Fail**: Pin direction categorization bug (likely root cause)

## Current Known Issue

Based on test results, the issue is:
- **NOT** a GUI rendering problem
- **IS** a pin direction categorization bug during markdown loading
- Nodes have pins but `pin_direction` attributes aren't set properly
- This makes connections fail, causing GUI to appear broken

## Commands Quick Reference

```batch
# Quick diagnosis (recommended)
run_quick_test.bat

# Interactive menu
run_tests.bat

# Run specific tests manually
python test_specific_gui_bugs.py # Your reported issue
python test_pin_creation_bug.py # Root cause
python test_gui_rendering.py # Visual verification
python test_gui_loading.py # Comprehensive suite
```

## Troubleshooting

If tests fail to run:
1. Ensure you're in the PyFlowGraph directory
2. Check that Python is in your PATH
3. Verify PySide6 is installed: `pip install PySide6`
4. Make sure virtual environment is activated if used

## Next Steps

Once you confirm the pin direction bug:
1. Investigate `node.py` - `update_pins_from_code()` method
2. Check `pin.py` - Pin direction assignment during creation
3. Review `node_graph.py` - Pin handling during `deserialize()`
4. Focus on markdown loading vs JSON loading differences
Loading