H-6281, FE-501: Add undo/redo support to Petrinaut demo app#8505
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
This stack of pull requests is managed by Graphite. Learn more about stacking. |
PR SummaryMedium Risk Overview Updates the demo app to track SDCPN snapshot history ( Fixes a drag bug by clearing per-node dragging state on drag end to avoid stale positions reapplying after undo, removes pre-delete Written by Cursor Bugbot for commit b765bb1. This will update automatically on new commits. Configure here. |
ec0176c to
5a2c7fb
Compare
4448449 to
0ad0be7
Compare
🤖 Augment PR SummarySummary: Adds optional undo/redo support to the Petrinaut demo/editor, including UI controls, keyboard shortcuts, and a simple version-history viewer. Changes:
Technical Notes: History entries store full SDCPN snapshots with ISO timestamps; the provider exposes 🤖 Was this summary useful? React with 👍 or 👎 |
libs/@hashintel/petrinaut/src/views/Editor/components/BottomBar/use-keyboard-shortcuts.ts
Show resolved
Hide resolved
libs/@hashintel/petrinaut/src/views/Editor/components/BottomBar/use-keyboard-shortcuts.ts
Show resolved
Hide resolved
0ad0be7 to
beffe8b
Compare
5a2c7fb to
363cd18
Compare
beffe8b to
fdf9954
Compare
363cd18 to
a15bf3d
Compare
libs/@hashintel/petrinaut/src/views/Editor/components/TopBar/version-history-button.tsx
Show resolved
Hide resolved
libs/@hashintel/petrinaut/src/views/Editor/components/TopBar/version-history-button.tsx
Outdated
Show resolved
Hide resolved
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Consumer-side history management via useUndoRedo hook with full SDCPN snapshots, 500ms debounce for drag coalescing, and no-op detection. Petrinaut library accepts optional undoRedo props and renders UI (toolbar buttons, keyboard shortcuts, version history popover) only when provided. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…store After undo, ReactFlow could re-apply the old dragged position because the draggingStateByNodeId entry persisted with the pre-undo coordinates. Now the entry is removed when drag completes, so subsequent position changes correctly bail out via the !lastPosition guard. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Now that undo/redo is available, confirmation prompts before deleting places, transitions, types, equations, parameters, and type elements are unnecessary friction — users can simply undo if needed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove standalone undo/redo icon buttons from the TopBar, keeping only the version history button. Rewrite VersionHistoryButton to use the Menu component instead of a custom Popover, with a checkmark icon on the current version and flex layout for menu item suffixes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Skip undo/redo shortcut when focus is in input/textarea/contentEditable so native text undo works in form fields - Clear debounce timer on undo/redo/goToIndex to prevent history corruption when editing within a debounce window after undoing - Compute new SDCPN synchronously via produce instead of reading from a ref in queueMicrotask, which could read stale state Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…hecks Use the setState updater form in mutatePetriNetDefinition so multiple calls before a re-render each see the latest state, fixing lost position updates during multi-node drag end. Merge duplicated isTextInput and isInputFocused checks into a single variable to prevent drift. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Show HH:mm:ss timestamps instead of labels, add scrollable max height, and keep menu open on item selection. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
5604e83 to
b765bb1
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

🌟 What is the purpose of this PR?
Adds undo/redo support to the Petrinaut demo app. Having history tracking is useful both for day-to-day model editing and as groundwork for upcoming versioning/diffing features.
🔗 Related links
🔍 What does this change?
useUndoRedohook in the demo app that manages a stack of full SDCPN snapshots (max 50), with 500ms debounce for drag coalescing and no-op detectionundoRedoprop to<Petrinaut>, gated behind a React context — UI only renders when providedIconButtons and a version history popover to the top barCmd/Ctrl+ZandCmd/Ctrl+Shift+Zkeyboard shortcuts (Monaco editors handle their own undo)EditorContextafter drag end, causing stale positions to reappear after undowindow.confirmdialogs before deletions — undo makes them unnecessaryPre-Merge Checklist 🚀
🚢 Has this modified a publishable library?
This PR:
📜 Does this require a change to the docs?
The changes in this PR:
🕸️ Does this require a change to the Turbo Graph?
The changes in this PR:
❓ How to test this?
cd libs/@hashintel/petrinaut && yarn devCmd+Zshould undo each edit;Cmd+Shift+Zshould redoCmd+Zshould undo within Monaco, not the SDCPN