Skip to content

Commit fc7e7ce

Browse files
bhowiebkrBryan Howard
andauthored
Implement Story 3.1: Basic Group Creation and Selection (#40)
Complete implementation of core node grouping functionality with context menu integration, keyboard shortcuts, and comprehensive validation system. Features: - Context menu 'Group Selected' option with validation - Ctrl+G keyboard shortcut for group creation - Group class with visual representation and persistence - Group creation dialog with automatic naming - CreateGroupCommand for undo/redo support - Comprehensive validation system - Complete testing infrastructure Files Added: - src/core/group.py - Group class and validation functions - src/ui/dialogs/group_creation_dialog.py - Group configuration dialog - src/commands/create_group_command.py - Undo/redo command implementation - tests/test_group_system.py - Unit tests for group functionality - tests/test_group_ui_integration.py - UI integration tests - docs/stories/3.1.story.md - Story documentation Files Modified: - src/core/node_graph.py - Added Ctrl+G shortcut and group creation workflow - src/ui/editor/node_editor_view.py - Added context menu group option All acceptance criteria met with professional validation and testing coverage. Co-authored-by: Bryan Howard <[email protected]>
1 parent f47e00a commit fc7e7ce

File tree

9 files changed

+1664
-0
lines changed

9 files changed

+1664
-0
lines changed

docs/stories/3.1.story.md

Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
---
2+
id: "3.1"
3+
title: "Basic Group Creation and Selection"
4+
type: "Feature"
5+
priority: "High"
6+
status: "Draft"
7+
assigned_agent: "dev"
8+
epic_id: "3"
9+
sprint_id: ""
10+
created_date: "2025-01-20"
11+
updated_date: "2025-01-20"
12+
estimated_effort: "L"
13+
dependencies: ["Complete undo/redo system (Epic 2)"]
14+
tags: ["grouping", "selection", "context-menu", "keyboard-shortcuts", "multi-select"]
15+
16+
user_type: "End User"
17+
component_area: "Node Grouping System"
18+
technical_complexity: "Medium"
19+
business_value: "High"
20+
---
21+
22+
# Story 3.1: Basic Group Creation and Selection
23+
24+
## Story Description
25+
26+
**As a** user, **I want** to select multiple nodes and create a group, **so that** I can organize related functionality into manageable containers.
27+
28+
### Context
29+
This story begins Epic 3 - Core Node Grouping System, building on the complete undo/redo infrastructure from Epic 2. This establishes the fundamental grouping capability that allows users to organize complex graphs into logical containers. This is the foundation for all future grouping features including visual representation, pin generation, and persistence.
30+
31+
### Background
32+
The node selection system already exists and supports multi-selection via Ctrl+Click and selectedItems(). The command pattern infrastructure from Epic 2 provides the foundation for undoable group operations. This story extends the existing selection and context menu systems to add group creation functionality.
33+
34+
## Acceptance Criteria
35+
36+
### AC1: Multi-select nodes using Ctrl+Click and drag-rectangle selection
37+
**Given** multiple nodes exist in the graph
38+
**When** user holds Ctrl and clicks nodes or uses drag-rectangle selection
39+
**Then** multiple nodes are selected and visually highlighted
40+
41+
### AC2: Right-click context menu "Group Selected" option on valid selections
42+
**Given** multiple nodes are selected
43+
**When** user right-clicks on selection
44+
**Then** context menu shows "Group Selected" option when valid selection exists
45+
46+
### AC3: Keyboard shortcut Ctrl+G for grouping selected nodes
47+
**Given** multiple nodes are selected
48+
**When** user presses Ctrl+G
49+
**Then** group creation dialog appears for selected nodes
50+
51+
### AC4: Group creation validation preventing invalid selections (isolated nodes, etc.)
52+
**Given** user attempts to group nodes
53+
**When** selection contains invalid combinations
54+
**Then** validation prevents grouping and shows appropriate error message
55+
56+
### AC5: Automatic group naming with user override option in creation dialog
57+
**Given** user creates a group
58+
**When** group creation dialog appears
59+
**Then** default name is generated with option for user to customize
60+
61+
## Tasks / Subtasks
62+
63+
### Implementation Tasks
64+
- [ ] **Task 1**: Extend existing context menu system for group operations (AC: 2)
65+
- [ ] Subtask 1.1: Add "Group Selected" option to NodeEditorView.show_context_menu()
66+
- [ ] Subtask 1.2: Implement group validation logic for context menu enabling
67+
- [ ] Subtask 1.3: Connect context menu action to group creation workflow
68+
- [ ] Subtask 1.4: Add proper icon and styling for group menu option
69+
70+
- [ ] **Task 2**: Implement keyboard shortcut system (AC: 3)
71+
- [ ] Subtask 2.1: Add Ctrl+G handling to NodeGraph.keyPressEvent()
72+
- [ ] Subtask 2.2: Integrate with existing keyboard shortcut patterns
73+
- [ ] Subtask 2.3: Ensure proper event propagation and handling
74+
- [ ] Subtask 2.4: Add shortcut documentation and tooltips
75+
76+
- [ ] **Task 3**: Create Group class and basic data model (AC: 1, 4, 5)
77+
- [ ] Subtask 3.1: Design Group class inheriting from QGraphicsItem
78+
- [ ] Subtask 3.2: Implement group data structure with member nodes tracking
79+
- [ ] Subtask 3.3: Add serialization/deserialization for group persistence
80+
- [ ] Subtask 3.4: Integrate with existing node identification system (UUID)
81+
82+
- [ ] **Task 4**: Implement group creation validation (AC: 4)
83+
- [ ] Subtask 4.1: Create validation rules for groupable selections
84+
- [ ] Subtask 4.2: Check for minimum node count and connectivity requirements
85+
- [ ] Subtask 4.3: Validate node types and prevent invalid combinations
86+
- [ ] Subtask 4.4: Implement user-friendly error messaging
87+
88+
- [ ] **Task 5**: Create Group Creation Dialog (AC: 5)
89+
- [ ] Subtask 5.1: Design GroupCreationDialog class inheriting from QDialog
90+
- [ ] Subtask 5.2: Implement automatic name generation based on selected nodes
91+
- [ ] Subtask 5.3: Add user input validation and name override functionality
92+
- [ ] Subtask 5.4: Integrate with existing dialog patterns and styling
93+
94+
- [ ] **Task 6**: Implement CreateGroupCommand for undo/redo (AC: 1-5)
95+
- [ ] Subtask 6.1: Create CreateGroupCommand following established command pattern
96+
- [ ] Subtask 6.2: Implement proper state preservation for undo operations
97+
- [ ] Subtask 6.3: Handle group creation, node membership, and state transitions
98+
- [ ] Subtask 6.4: Integrate with existing command history system
99+
100+
### Testing Tasks
101+
- [ ] **Task 7**: Create unit tests for group functionality (AC: 1, 4, 5)
102+
- [ ] Test Group class creation and data management
103+
- [ ] Test group validation logic with various node combinations
104+
- [ ] Test automatic naming generation and customization
105+
- [ ] Test serialization and persistence of group data
106+
107+
- [ ] **Task 8**: Create integration tests for UI interactions (AC: 2, 3)
108+
- [ ] Test context menu integration and option enabling/disabling
109+
- [ ] Test keyboard shortcut handling and event propagation
110+
- [ ] Test dialog workflow and user input validation
111+
- [ ] Test command pattern integration and undo/redo functionality
112+
113+
- [ ] **Task 9**: Add user workflow tests (AC: 1-5)
114+
- [ ] Test complete group creation workflow from selection to completion
115+
- [ ] Test error handling and user feedback for invalid selections
116+
- [ ] Test integration with existing selection and clipboard systems
117+
- [ ] Test undo/redo behavior for group operations
118+
119+
### Documentation Tasks
120+
- [ ] **Task 10**: Update user documentation
121+
- [ ] Document group creation workflow and keyboard shortcuts
122+
- [ ] Add group creation tutorial and best practices
123+
- [ ] Update UI documentation for new context menu options
124+
125+
## Dev Notes
126+
127+
### Previous Story Insights
128+
Key learnings from Epic 2 (Undo/Redo System):
129+
- Command pattern integration works smoothly with existing infrastructure
130+
- PySide6 signal/slot connections require careful setup and proper disconnection
131+
- Real-time UI updates need proper event handling and state synchronization
132+
- Context menu patterns are established in NodeEditorView.show_context_menu()
133+
- Testing GUI components requires careful mocking and QTest framework consideration
134+
[Source: docs/stories/2.4.story.md#previous-story-insights]
135+
136+
### Technical Implementation Details
137+
138+
#### Existing Selection Infrastructure
139+
- **Selection System**: NodeGraph.selectedItems() provides multi-selection capability
140+
- **Copy System**: copy_selected() method shows pattern for working with selected nodes
141+
- **Key Handling**: keyPressEvent() in NodeGraph handles Ctrl+Z/Y shortcuts, pattern for Ctrl+G
142+
- **Context Menu**: NodeEditorView.show_context_menu() provides right-click menu framework
143+
[Source: src/core/node_graph.py lines 161-195, 105-159; src/ui/editor/node_editor_view.py lines 54-83]
144+
145+
#### Command System Integration Points
146+
- **Command History**: CommandHistory class in `src/commands/command_history.py` manages undoable operations
147+
- **NodeGraph Integration**: NodeGraph.command_history provides access to command operations
148+
- **Existing Commands**: DeleteNodeCommand, CompositeCommand patterns established
149+
- **State Methods**: execute_command(), undo_last_command(), redo_last_command() available
150+
[Source: src/commands/command_history.py, src/core/node_graph.py lines 54-91]
151+
152+
#### File Locations & Structure
153+
- **Main Graph**: `src/core/node_graph.py` - Add group creation and management methods
154+
- **View System**: `src/ui/editor/node_editor_view.py` - Extend context menu for group options
155+
- **New Group Class**: `src/core/group.py` - Create new group data model and QGraphicsItem
156+
- **New Dialog**: `src/ui/dialogs/group_creation_dialog.py` - Create group configuration dialog
157+
- **New Command**: `src/commands/create_group_command.py` - Implement undoable group creation
158+
- **Test Files**: `tests/test_group_system.py` (new), extend existing command tests
159+
[Source: docs/architecture/source-tree.md#user-interface, docs/architecture/source-tree.md#core-application-files]
160+
161+
#### Data Models and Integration
162+
- **Node Objects**: Node class with UUID-based identification system
163+
- **Selection Access**: selectedItems() returns list of QGraphicsItem objects for processing
164+
- **UUID System**: Existing node.uuid pattern for unique identification
165+
- **Serialization**: Existing node.serialize() pattern for data persistence
166+
[Source: src/core/node.py, src/core/node_graph.py lines 161-195]
167+
168+
#### Context Menu Architecture Patterns
169+
- **Menu Creation**: QMenu and QAction patterns established in show_context_menu()
170+
- **Action Enabling**: Dynamic enabling/disabling based on selection state
171+
- **Icon Integration**: Font Awesome icon creation via create_fa_icon() function
172+
- **Signal Connections**: Action triggered signals connected to methods
173+
[Source: src/ui/editor/node_editor_view.py lines 54-83, src/ui/utils/ui_utils.py]
174+
175+
#### Dialog Architecture Patterns
176+
- **Base Pattern**: Inherit from QDialog (established pattern in project)
177+
- **Existing Examples**: SettingsDialog, EnvironmentManagerDialog, GraphPropertiesDialog, UndoHistoryDialog
178+
- **Layout**: Use QVBoxLayout and QHBoxLayout for responsive design
179+
- **Integration**: Parent to main window for proper modal behavior
180+
- **Resource Management**: Proper Qt object parenting for automatic cleanup
181+
[Source: docs/architecture/coding-standards.md#widget-structure, docs/architecture/source-tree.md#user-interface]
182+
183+
#### Group Data Structure Requirements
184+
- **Member Tracking**: List of member node UUIDs for group membership
185+
- **Metadata**: Group name, description, creation timestamp
186+
- **State Management**: Expanded/collapsed state, position, size
187+
- **Serialization**: JSON-compatible format for file persistence
188+
- **Validation**: Rules for valid group compositions and member types
189+
190+
#### Performance Considerations
191+
- **Selection Performance**: Existing selectedItems() optimized for large graphs
192+
- **Memory Usage**: Group metadata lightweight, references not copies of nodes
193+
- **Response Time**: Group creation must remain under 100ms for responsiveness (NFR1)
194+
- **Large Selections**: Efficient handling of 50+ node selections
195+
[Source: docs/prd.md#non-functional-requirements]
196+
197+
#### Technical Constraints
198+
- **Windows Platform**: Use Windows-compatible commands and paths, no Unicode characters
199+
- **PySide6 Framework**: Follow established Qt patterns and QGraphicsItem architecture
200+
- **Existing Patterns**: Leverage established command pattern and UUID systems
201+
- **Error Handling**: Graceful handling of invalid selections with user feedback
202+
[Source: docs/architecture/coding-standards.md#prohibited-practices, CLAUDE.md]
203+
204+
### Testing
205+
206+
#### Test File Locations
207+
- **Unit Tests**: `tests/test_group_system.py` (new) - Group class and validation logic
208+
- **Integration Tests**: Extend existing `tests/test_command_system.py` for group commands
209+
- **UI Tests**: `tests/test_group_ui_integration.py` (new) - Context menu and dialog testing
210+
- **Test Naming**: Follow `test_{behavior}_when_{condition}` pattern
211+
[Source: docs/architecture/coding-standards.md#testing-standards]
212+
213+
#### Testing Framework and Patterns
214+
- **Framework**: Python unittest (established pattern in project)
215+
- **Test Runner**: Custom PySide6 GUI test runner for interactive testing
216+
- **Timeout**: All tests must complete within 10 seconds maximum
217+
- **Coverage**: Focus on group creation logic, selection validation, and command integration
218+
[Source: docs/architecture/tech-stack.md#testing-framework, CLAUDE.md#testing]
219+
220+
#### Specific Testing Requirements
221+
- Test group creation with various node selection combinations
222+
- Test validation logic for invalid selections and edge cases
223+
- Test context menu integration and proper enabling/disabling
224+
- Test keyboard shortcut handling and event propagation
225+
- Test dialog workflow, input validation, and user feedback
226+
- Test command pattern integration and undo/redo functionality
227+
- Test group data serialization and persistence
228+
- Test integration with existing selection and clipboard systems
229+
230+
## Change Log
231+
232+
| Date | Version | Description | Author |
233+
| ---------- | ------- | --------------------------- | --------- |
234+
| 2025-01-20 | 1.0 | Initial story creation based on PRD Epic 3 | Bob (SM) |

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

0 commit comments

Comments
 (0)