You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Summary
Adds undo/redo functionality to the Explore Page, allowing users to
navigate through their query building history. Users can now undo and
redo actions using keyboard shortcuts (Ctrl+Z, Ctrl+Shift+Z, Ctrl+Y) or
clickable buttons in the UI.
## Changes
### New Features
- **History tracking**: All state changes are automatically tracked,
including node creation, deletion, connection changes, and property
modifications
- **Keyboard shortcuts**:
- `Ctrl+Z` (or `Cmd+Z` on Mac) for undo
- `Ctrl+Shift+Z` or `Ctrl+Y` for redo
- **Visual controls**: Floating undo/redo buttons in the bottom-right
corner with enabled/disabled states
- **Smart filtering**: Layout-only changes (dragging nodes) are excluded
from history to avoid polluting the undo stack
- **Granular tracking**: Individual property changes (e.g., selecting
group by columns) are captured as separate history entries
### Implementation Details
#### Core Components
- **`HistoryManager`** (`history_manager.ts`): Manages history stack
with:
- Max history size of 10 states to prevent unbounded memory growth
- State serialization for comparison (excluding layout changes)
- Undo/redo operations with circular history prevention
- **Integration** (`explore_page.ts`):
- Wraps `onStateUpdate` callback to intercept all state changes
- Handles keyboard shortcuts at the page level
- Prevents recording of undo/redo-triggered changes
#### UI Components
- Added undo/redo buttons to query builder (`builder.ts`)
- Buttons show enabled/disabled state based on history availability
- Positioned in bottom-right corner with floating style (`builder.scss`)
### Testing
- Comprehensive unit tests in `history_manager_unittest.ts` covering:
- Basic undo/redo operations
- Granular property change tracking
- Layout-only change filtering
- Redo stack clearing on new actions
- History size limits
- Complex node graphs with multiple connections
## Test plan
### Manual Testing
1. **Basic undo/redo**:
- Open Explore Page
- Add a table source node
- Press Ctrl+Z → node should disappear
- Press Ctrl+Shift+Z → node should reappear
2. **Granular changes**:
- Create a table source node
- Add an aggregation node
- Check first group by column
- Check second group by column
- Press Ctrl+Z twice → both columns should uncheck in reverse order
3. **Layout filtering**:
- Add a node
- Drag it to a different position
- Press Ctrl+Z → node position should stay, but the node itself should
disappear (proving layout changes don't create history entries)
4. **UI buttons**:
- Verify undo/redo buttons appear in bottom-right corner
- Verify buttons are disabled when no undo/redo is available
- Click buttons to undo/redo actions
5. **History limit**:
- Perform more than 10 distinct actions
- Attempt to undo → should only undo last 10 actions
6. **Redo stack clearing**:
- Add a node
- Press Ctrl+Z (undo)
- Add a different node
- Press Ctrl+Shift+Z → redo should not be available
### Automated Testing
```bash
ui/run-unittests history_manager_unittest
0 commit comments