Commit 2671f43
feat(ui): implement action router pattern for canvas workflow fields
Implements a Symbol-based action routing system to resolve field mutation conflicts between canvas workflows and nodes workflows. This allows both workflows to share the same field action creators while ensuring updates are routed to the correct slice.
## Changes
### Core Action Router System
- Add `actionRouter.ts` with Symbol-based metadata injection and checking utilities
- Add `workflowContext.ts` to provide workflow context and avoid circular dependencies
- Enhance `useAppDispatch` to automatically inject workflow routing metadata based on context
### Canvas Workflow Integration
- Add `CanvasWorkflowElementProvider` wrapping `WorkflowContext` for canvas tab
- Refactor `canvasWorkflowNodesSlice` to use `extraReducers` instead of local reducers
- Listen for `nodesSlice` field actions and filter by workflow routing metadata
- Update persistence config to persist nodes/edges while excluding workflow metadata
- Filter out input node fields from workflow form (populated by graph builder)
### Nodes Workflow Integration
- Add `NodesWorkflowProvider` to mark nodes/workflow editor context
- Wrap `NodeEditor` with provider in workflows tab layout
- Add workflow routing check in `nodesSlice` field reducers
### DND Image Drop Fixes
- Enhance `setNodeImageFieldImage` to check active tab when routing DND actions
- Pass `getState` through DND handler to enable routing logic
- Ensure drops are routed to correct slice based on active tab
### Validation Improvements
- Refactor canvas workflow validation to use existing `getInvocationNodeErrors` utility
- Skip validation for input node's image field (populated at runtime)
- Remove custom validation logic in favor of shared validator
### Cleanup
- Remove `canvasWorkflowFieldChanged` listener (replaced by action router)
- Remove unused metadata code from canvas workflow graph builder
- Fix TypeScript type assertions in workflow selection handlers
## Fixes
- Field inputs now work correctly in canvas workflow panel
- DND image drops now route to correct workflow based on active tab
- Canvas workflow validation properly handles runtime-populated fields
- Persistence config correctly saves field changes while excluding metadata
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>1 parent 6299db7 commit 2671f43
File tree
17 files changed
+296
-283
lines changed- invokeai/frontend/web/src
- app/store
- middleware/listenerMiddleware/listeners
- features
- controlLayers
- components
- store
- dnd
- imageActions
- nodes
- components
- store
- util/graph/generation
- queue/components
- ui
- components/ParametersPanels
- layouts
17 files changed
+296
-283
lines changedLines changed: 0 additions & 112 deletions
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
61 | 60 | | |
62 | 61 | | |
63 | 62 | | |
| |||
299 | 298 | | |
300 | 299 | | |
301 | 300 | | |
302 | | - | |
303 | 301 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
2 | 5 | | |
3 | 6 | | |
4 | 7 | | |
5 | 8 | | |
6 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
7 | 30 | | |
8 | 31 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
Lines changed: 10 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
18 | | - | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | | - | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
28 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
29 | 36 | | |
30 | 37 | | |
31 | 38 | | |
| |||
Lines changed: 8 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
40 | 43 | | |
41 | 44 | | |
42 | 45 | | |
0 commit comments