You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[One Workflow] Optimistic approach for updates in workflows (#240722)
_LLM Generated Summary_
### Summary
Implements optimistic UI updates for workflow bulk actions (delete,
enable, disable) to provide immediate user feedback and eliminate laggy
interactions.
### 🎯 Problem
Bulk delete operations kept the modal/popover open while processing,
with no clear feedback
Enable/disable actions felt slow and unresponsive
Users had to wait for server responses before seeing any UI changes
No clear success/failure indicators for batch operations
### ✨ Solution
Implemented optimistic updates using React Query's mutation lifecycle
hooks (onMutate, onError, onSettled) to:
Update the UI immediately when actions are triggered
Automatically rollback changes if operations fail
Show error toasts only when failures occur (no success toasts to reduce
noise)
### 📝 Modified Files
#### 1. use_workflow_actions.ts
Added optimistic updates to updateWorkflow mutation:
Optimistically updates workflow list data (for table view)
Optimistically updates individual workflow detail data (for YAML editor
view)
Stores previous state for automatic rollback on errors
Added optimistic updates to deleteWorkflows mutation:
Immediately removes workflows from list
Updates pagination counts
Reverts on failure
#### 2. use_workflow_bulk_actions.tsx
Refactored bulk enable/disable to leverage optimistic updates
Added comprehensive error handling with toast notifications:
Total failure: danger toast
Partial failure: warning toast with counts
Success: no toast (silent success for better UX)
Immediate modal/popover closing and selection clearing
Added TODO comment about potential bulk delete endpoint optimization
#### 3. workflows_utility_bar.tsx
Pass deselectWorkflows callback to bulk actions for immediate selection
clearing
### 🎨 User Experience Improvements
Before:
- ⏳ Popover/modal stayed open during operations
- ⏳ No immediate feedback on actions
- ⏳ Laggy enabled toggle in both list and detail views
- ❌ No clear success/failure indicators
After:
- ✅ Instant UI updates (workflows disappear/update immediately)
- ✅ Modal/popover close right away
- ✅ Selection clears instantly
- ✅ Smooth enabled toggle in both list and YAML editor
- ✅ Clear error feedback with detailed toast messages
- ✅ Automatic rollback on failures
https://github.com/user-attachments/assets/8322839c-792f-40f7-a8b2-4499092e9dda
Copy file name to clipboardExpand all lines: src/platform/plugins/shared/workflows_management/public/features/workflow_list/ui/use_workflow_bulk_actions.tsx
Copy file name to clipboardExpand all lines: src/platform/plugins/shared/workflows_management/public/features/workflow_list/ui/workflows_utility_bar.tsx
0 commit comments