-
Notifications
You must be signed in to change notification settings - Fork 3.3k
feat(code): undo-redo state #3018
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile OverviewGreptile SummaryImplemented undo-redo functionality for code blocks in function blocks, enabling users to revert and reapply code changes with standard keyboard shortcuts. The implementation adds:
The architecture separates concerns well:
Key insight: The implementation uses Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant CodeEditor as Code Editor Component
participant Hook as useCodeUndoRedo Hook
participant Store as CodeUndoRedoStore
participant IDB as IndexedDB
participant Collab as Collaborative Workflow
User->>CodeEditor: Types code
CodeEditor->>Hook: recordChange(newValue)
Hook->>Hook: Set pendingBefore (if first change)
Hook->>Hook: Set pendingAfter
Hook->>Hook: Start 300ms debounce timer
Note over Hook: User continues typing...
User->>CodeEditor: Types more
CodeEditor->>Hook: recordChange(newerValue)
Hook->>Hook: Clear previous timer
Hook->>Hook: Update pendingAfter
Hook->>Hook: Restart 300ms timer
Note over Hook: Timer expires after 300ms of no edits
Hook->>Store: push(entry with before/after)
Store->>Store: Add to undo stack
Store->>Store: Clear redo stack
Store->>IDB: Persist state
User->>CodeEditor: Press Cmd+Z
CodeEditor->>Hook: undo()
Hook->>Store: undo(workflowId, blockId, subBlockId)
Store->>Store: Pop from undo stack
Store->>Store: Push to redo stack
Store-->>Hook: Return entry
Hook->>Hook: applyValue(entry.before)
Hook->>Collab: collaborativeSetSubblockValue()
Collab->>CodeEditor: Update code value
Note over User,Collab: Remote user edits same block
Collab->>Store: clear(workflowId, blockId, subBlockId)
Store->>Store: Delete undo/redo stacks
Store->>IDB: Persist cleared state
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 file reviewed, 1 comment
|
@cursor review |
...workflowId]/components/panel/components/editor/components/sub-block/components/code/code.tsx
Outdated
Show resolved
Hide resolved
|
@cursor review |
|
@cursor review |
...workflowId]/components/panel/components/editor/components/sub-block/components/code/code.tsx
Show resolved
Hide resolved
|
@cursor review |
|
@cursor review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Summary
Undo-Redo state maintained for code subblocks for better UX. Using Index DB for massive limit on num of stacks at once.
Type of Change
Testing
Tested with @Sg312
Checklist