perf(DesignerV2): Undo/Redo improvements + enabling#9027
Conversation
🤖 AI PR Validation ReportPR Review ResultsThank you for your submission! Here's detailed feedback on your PR title and body compliance:✅ PR Title
|
| Section | Status | Recommendation |
|---|---|---|
| Title | ✅ | Make title slightly more descriptive (see example). |
| Commit Type | Explain why both refactor and perf are selected or pick one primary type. |
|
| Risk Level | Repo label = risk:medium, but advised risk = High — please re-evaluate. | |
| What & Why | ✅ | Good detail. Add an explicit "breaking behavior" note for the default history-size change. |
| Impact of Change | ✅ | Add explicit dev migration note about middleware ordering and memory expectations. |
| Test Plan | ✅ | Unit tests present. Consider adding E2E/integration or explain manual coverage. |
| Contributors | ✅ | Good. Optionally list additional reviewers/contributors. |
| Screenshots/Videos | Optional; consider a short GIF for easier review. |
Final notes and action items
- Advised risk: High. The PR currently has
risk:mediumand the body selects Medium. Because this PR changes default runtime behavior (DEFAULT_MAX_STATE_HISTORY_SIZE from 0→20), refactors the middleware ordering to action-first (which can change the timing of side effects), and introduces a new compression/caching layer for undo history, I recommend updating the risk label torisk:highor explicitly documenting why you believe Medium is sufficient. Please update the PR labels if you accept this advice. - Please update the Commit Type to a single primary type or add a short note in the PR explaining that both
refactorandperfapply (which parts are refactor vs perf). This reduces ambiguity for release notes and changelogs. - Emphasize the behavioral change in the PR summary and release notes about the default history size (20) and how to disable it with
maxStateHistorySize: 0. This is a user-visible default change that hosts and integrators need to be aware of. - Add either an E2E/integration test or an explicit manual testing checklist (e.g., steps to reproduce undo/redo with panel state restored, memory profiling notes, and what was verified) to reassure reviewers that cross-slice restore works under realistic conditions.
- Verify the numeric claims in the PR body ("76 tests across 6 test files") match the actual updated tests in the diff; update the wording if the numbers differ.
Please update the PR title/body/labels as recommended above. Once you've updated the risk label and clarified the commit type and testing coverage (or added an E2E), this PR should be in good shape for a deeper code review. Thanks for the detailed write-up and tests — the change is valuable, but because it affects core behavior I'm advising higher risk and extra attention during review.
Last updated: Tue, 07 Apr 2026 22:10:12 GMT
There was a problem hiding this comment.
Pull request overview
Enables usable undo/redo in DesignerV2 by wiring keyboard shortcuts and VS Code UI triggers, and by making state history non-empty by default while refactoring the undo/redo history middleware ordering.
Changes:
- Added Ctrl/Cmd+Z and Ctrl/Cmd+Y (incl. Shift+Z) hotkeys to dispatch undo/redo actions in DesignerV2.
- Added Undo/Redo items to the VS Code designer command bar overflow menu with localization strings.
- Increased default undo/redo state history size from 0 to 20 and refactored middleware to process actions before persisting history snapshots.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| Localize/lang/strings.json | Adds localized string entries for Undo/Redo labels. |
| libs/designer-v2/src/lib/ui/Designer.tsx | Registers undo/redo hotkeys gated by read-only state and canUndo/canRedo selectors. |
| libs/designer-v2/src/lib/core/utils/middleware.ts | Refactors history-saving middleware to capture pre-state, run next(action) first, then persist snapshot. |
| libs/designer-v2/src/lib/core/utils/test/middleware.spec.ts | Updates/expands unit tests for the refactored middleware behavior and ordering. |
| libs/designer-v2/src/lib/core/state/designerOptions/designerOptionsInterfaces.ts | Updates documentation comment to reflect new default history size. |
| libs/designer-v2/src/lib/common/constants.ts | Changes DEFAULT_MAX_STATE_HISTORY_SIZE from 0 to 20. |
| apps/vs-code-react/src/intl/messages.ts | Adds UNDO/REDO message definitions for VS Code React UI. |
| apps/vs-code-react/src/app/designer/DesignerCommandBar/indexV2.tsx | Adds Undo/Redo overflow menu items and icons. |
| apps/Standalone/src/designer/state/workflowLoadingSlice.ts | Updates Standalone hostOptions default maxStateHistorySize to 20. |
📊 Coverage CheckThe following changed files need attention:
Please add tests for the uncovered files before merging. |
Commit Type
Risk Level
What & Why
Undo/redo existed but was unusable: no triggers (keyboard or UI), and the default history size was 0 so state was never saved. This PR wires it up, fixes the defaults, and optimizes snapshot compression.
Enabling & Triggers
Ctrl+Z/Ctrl+Y(+Ctrl+Shift+Z) viareact-hotkeys-hookinDesigner.tsx. Disabled in read-only/monitoring mode.DesignerCommandBar/indexV2.tsx. Disabled when there is nothing to undo/redo or when not in designer view.DEFAULT_MAX_STATE_HISTORY_SIZE: Changed from0→20so history is actually saved by default.Middleware Refactor
storeStateToUndoRedoHistory) with an inline synchronous middleware that callsnext(action)first (so the UI updates immediately), then captures and compresses the pre-mutation state snapshot. Eliminates a Redux dispatch round-trip on every undoable action.Compression Optimizations
workflow.originalDefinition,workflow.runInstance,operations.loadStatus,operations.errors,settings.expandedSections,connections.loading, etc.). Restored from live state on undo/redo.Uint8Arraybytes. Only the 1–2 slices that actually changed getJSON.stringify+deflate. State history items now store aCompressedSliceMap(per-sliceUint8Arrays) instead of a single blob.Bug Fixes
notesSlice.initialStatenot exported: Addedexportso the mock root state can import it for tests.Compression Performance
deflateover full JSONdeflateover only changed slices + stripped fieldsUint8ArrayUint8Arrayrefs for unchanged slices across history entriesinflateone blobinflateonly stored slices; unchanged slices fall back to live stateImpact of Change
Ctrl+Z/Ctrl+Ynow work in the designer canvas. Undo/Redo added to the VS Code command bar overflow menu. Both disabled in read-only/monitoring mode.DEFAULT_MAX_STATE_HISTORY_SIZEchanged from0→20. SetmaxStateHistorySize: 0to explicitly disable. Uses??so0is respected.StateHistoryItem.compressedState→StateHistoryItem.compressedSlices. New util functions:getCompressedSlicesFromRootState,getRootStateFromCompressedSlices,stripSliceForSnapshot,restoreStrippedFields.Test Plan
Contributors
@rllyy97
Screenshots/Videos
N/A