-
Notifications
You must be signed in to change notification settings - Fork 3.3k
fix(editor): block rename applies to correct block when selection changes #3129
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 SummaryThis PR fixes a critical bug where block rename would apply to the wrong block if the user changed selection mid-rename, and ensures cancelled executions display correct status and duration in terminal logs. Key Changes:
Architecture: Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant Workflow
participant EditorStore
participant Editor
participant WorkflowStore
participant CollabAPI
Note over User,CollabAPI: Block Rename Flow (Fixed Race Condition)
User->>Workflow: Right-click → Rename
Workflow->>EditorStore: setCurrentBlockId(blockA)
Workflow->>EditorStore: triggerRename()
EditorStore->>Editor: invoke registered callback
Editor->>EditorStore: getState().currentBlockId
Editor->>WorkflowStore: getState().blocks[blockA]
Note over Editor: Capture blockA in renamingBlockIdRef
Editor->>Editor: setIsRenaming(true)
Editor->>Editor: setEditedName(blockA.name)
Note over User,Editor: User clicks different block mid-rename
User->>Workflow: Click blockB
Workflow->>EditorStore: setCurrentBlockId(blockB)
Note over Editor: renamingBlockIdRef still holds blockA
User->>Editor: Complete rename
Editor->>Editor: Read renamingBlockIdRef (blockA)
Editor->>WorkflowStore: getState().blocks[blockA]
Editor->>CollabAPI: updateBlockName(blockA, newName)
Note over Editor: ✅ Correct block renamed!
Note over User,CollabAPI: Execution Cancellation Flow
User->>Workflow: Cancel execution
Workflow->>Engine: cancel()
Engine->>Engine: finalizeIncompleteLogs()
Note over Engine: Set endedAt, calculate durationMs
Engine->>Hook: onExecutionCancelled()
Hook->>TerminalStore: cancelRunningEntries(workflowId)
Note over TerminalStore: Calculate duration, set isCanceled
TerminalStore->>UI: Update entries
UI->>Formatting: formatDuration(durationMs)
Note over Formatting: Return actual duration or "—" for NaN
|
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.
4 files reviewed, 1 comment
Additional Comments (1)
According to the Zustand store patterns guide, stores should use the Context Used: Context from Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! Prompt To Fix With AIThis is a comment left during a code review.
Path: apps/sim/stores/panel/editor/store.ts
Line: 37:38
Comment:
Missing `devtools` middleware wrapping the `persist` middleware
According to the Zustand store patterns guide, stores should use the `devtools` middleware. Other persisted stores in the codebase follow the pattern: `devtools(persist(...), { name: 'store-name' })`
**Context Used:** Context from `dashboard` - Zustand store patterns ([source](https://app.greptile.com/review/custom-context?memory=b1b216e7-c04e-4351-9ea0-47c57790a11a))
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise. |
Summary
Type of Change
Testing
Tested manually
Checklist