feat(undo-redo): unify field, code, and loop config edits into one stack#4875
feat(undo-redo): unify field, code, and loop config edits into one stack#4875waleedlatif1 wants to merge 3 commits into
Conversation
- Record block-level field edits (tools, model, prompts, dropdowns, sliders, tag/reference insertion) on the workflow undo stack - Consolidate the separate per-field code-editor stack into the workflow stack and delete it; route Cmd+Z/redo in every text editor to the workflow undo so native/editor undo is suppressed and there is one source of truth - Make loop/parallel config values (iterations, collection, condition, batch size) undoable; coalesce consecutive same-field edits into one step - Group the model->apiKey clear into a single undo step - Reveal the affected block (select + open its editor panel) on undo/redo so a reverted field change is never off-screen
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Editors: New Recording: Stack behavior: Persists to throttled IndexedDB; coalesces rapid single-field edits (~500ms); after undo/redo, reveals the affected block in the editor panel. Reviewed by Cursor Bugbot for commit 9a24aa9. Configure here. |
Greptile SummaryThis PR unifies block-level field edits, code editor keystrokes, and loop/parallel config changes into the single workflow undo stack, replaces per-field code undo and synchronous localStorage with a throttled IndexedDB adapter, and adds a "reveal" mechanism that opens the affected block's editor panel after an undo/redo.
Confidence Score: 4/5Safe to merge with one targeted fix: the condition-field undo writes to the wrong loop field when the user switches loop type between edit and undo. The overall architecture is solid — coalescing, IndexedDB throttling, reveal targeting, and keyboard routing all work correctly. The one concrete defect is in applySubflowUndoRedoUpdate: both whileCondition and doWhileCondition share the subflowCondition fieldId, so undo/redo resolves the target field from the current loopType rather than the loopType at record time. Changing the loop mode between an edit and its undo silently writes the condition value to the wrong field. apps/sim/hooks/use-undo-redo.ts — specifically applySubflowUndoRedoUpdate where condition undo/redo branches on current loopType. Important Files Changed
Reviews (2): Last reviewed commit: "fix(undo-redo): address PR review feedba..." | Re-trigger Greptile |
Code-field undo frames are large and accumulate quickly; keeping them in the synchronous localStorage-backed stack risked main-thread jank on every keystroke and the ~5MB quota. Move the unified undo store to async IndexedDB (idb-keyval), matching how the old separate code stack was persisted. - Replace the localStorage persist adapter with a throttled IndexedDB adapter (coalesces a burst of writes into one transaction; flushes on tab hide) - Delete the now-orphaned code-storage adapter
- collaborativeBatchSetSubblockValues: capture each field's real prior value before mutating instead of recording before: update.expectedValue, which was undefined when a caller omitted expectedValue (would undo a field to undefined) - List the stable recordSubflowFieldUpdate helper in the subflow methods' dependency arrays - Document that a multi-block batch undo reveals only its first block
|
Thanks for the review — addressed the two concerns from the summary in 9a24aa9:
The multi-block reveal note is addressed inline and resolved. |
|
@greptile |
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 9a24aa9. Configure here.
Summary
use-code-undo-redo,code-store); every text editor now routesCmd+Z/Cmd+Shift+Zto the workflow undo and suppresses native/editor-internal undo, so there is one source of truthuseParseIntRadix,useIterableCallbackReturn) in the touched files to keep the pre-commit hook greenType of Change
Testing
Checklist