Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

feat(workflow): option to keep highlighted connections behind nodes

Josh Corbettfd0b0f2a2166
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.json
index f3aeafefc2..8c8238aa6d 100644
--- a/invokeai/frontend/webv2/public/locales/en.json
+++ b/invokeai/frontend/webv2/public/locales/en.json
@@ -1544,6 +1544,10 @@
"label": "Always snap to grid",
"description": "Snap nodes to the grid while dragging. When off, hold Ctrl to snap temporarily."
},
+ "workflowEdgesBehindNodes": {
+ "label": "Keep highlighted connections behind nodes",
+ "description": "Connections to a selected node normally rise above other nodes. Keep them beneath so they never cover node controls."
+ },
"workflowShowMinimap": {
"label": "Show minimap",
"description": "Show an overview in the corner of the workflow editor."
diff --git a/invokeai/frontend/webv2/src/app/WorkflowUiAdapter.tsx b/invokeai/frontend/webv2/src/app/WorkflowUiAdapter.tsx
index 9e5572984b..a6a92c4c55 100644
--- a/invokeai/frontend/webv2/src/app/WorkflowUiAdapter.tsx
+++ b/invokeai/frontend/webv2/src/app/WorkflowUiAdapter.tsx
@@ -43,6 +43,7 @@ const selectWorkflowPreferences = (preferences: WorkbenchPreferences) => ({
reduceMotion: preferences.reduceMotion,
themeId: preferences.themeId,
workflowEdgeStyle: preferences.workflowEdgeStyle,
+ workflowEdgesBehindNodes: preferences.workflowEdgesBehindNodes,
workflowShowMinimap: preferences.workflowShowMinimap,
workflowSnapToGrid: preferences.workflowSnapToGrid,
workflowValidateConnections: preferences.workflowValidateConnections,
diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/WorkflowUiContext.browser.test.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/WorkflowUiContext.browser.test.tsx
index 037d8ab625..216236440a 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/WorkflowUiContext.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/WorkflowUiContext.browser.test.tsx
@@ -52,6 +52,7 @@ const preferencesState = () => ({
reduceMotion: false,
themeId: 'classic' as const,
workflowEdgeStyle: 'curved' as const,
+ workflowEdgesBehindNodes: false,
workflowShowMinimap: true,
workflowSnapToGrid: false,
workflowValidateConnections: true,
diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/WorkflowUiContext.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/WorkflowUiContext.tsx
index e2a7a2f56e..9f6df95175 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/WorkflowUiContext.tsx
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/WorkflowUiContext.tsx
@@ -16,6 +16,7 @@ export interface WorkflowPreferences {
reduceMotion: boolean;
themeId: 'classic' | 'light' | 'osakaJade' | 'mono' | 'ultradark';
workflowEdgeStyle: 'curved' | 'square';
+ workflowEdgesBehindNodes: boolean;
workflowShowMinimap: boolean;
workflowSnapToGrid: boolean;
workflowValidateConnections: boolean;
diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/editor/WorkflowEditorView.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/editor/WorkflowEditorView.tsx
index 6974e01555..a5f9099741 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/editor/WorkflowEditorView.tsx
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/editor/WorkflowEditorView.tsx
@@ -227,6 +227,7 @@ const WorkflowFlow = ({ runtime }: { runtime: WorkflowRuntimeApi }) => {
reduceMotion,
themeId,
workflowEdgeStyle,
+ workflowEdgesBehindNodes,
workflowShowMinimap,
workflowSnapToGrid,
workflowValidateConnections,
@@ -235,6 +236,7 @@ const WorkflowFlow = ({ runtime }: { runtime: WorkflowRuntimeApi }) => {
reduceMotion: preferences.reduceMotion,
themeId: preferences.themeId,
workflowEdgeStyle: preferences.workflowEdgeStyle,
+ workflowEdgesBehindNodes: preferences.workflowEdgesBehindNodes,
workflowShowMinimap: preferences.workflowShowMinimap,
workflowSnapToGrid: preferences.workflowSnapToGrid,
workflowValidateConnections: preferences.workflowValidateConnections,
@@ -972,12 +974,15 @@ const WorkflowFlow = ({ runtime }: { runtime: WorkflowRuntimeApi }) => {
animation: 'dashdraw var(--wb-motion-duration-slow) linear var(--wb-motion-animation-iteration-count)',
strokeDasharray: '5',
},
+ // The edge layer is a stacking context of its own, so sinking it keeps
+ // every edge (including ones xyflow elevates for a selection) under nodes.
+ ...(workflowEdgesBehindNodes ? { '& .react-flow__edges': { zIndex: -1 } } : {}),
...(tool === 'eraser'
? { '& .react-flow__edge, & .react-flow__node, & .react-flow__pane': { cursor: 'crosshair' } }
: {}),
...(tool === 'lasso' ? { '& .react-flow__pane': { cursor: 'crosshair' } } : {}),
}),
- [nodeOpacity, tool]
+ [nodeOpacity, tool, workflowEdgesBehindNodes]
);
const panOnDrag = useMemo(() => (tool === 'pan' ? true : [1, 2]), [tool]);
const proOptions = useMemo(() => ({ hideAttribution: true }), []);
@@ -1035,7 +1040,7 @@ const WorkflowFlow = ({ runtime }: { runtime: WorkflowRuntimeApi }) => {
defaultEdgeOptions={DEFAULT_EDGE_OPTIONS}
defaultViewport={defaultViewport}
deleteKeyCode={DELETE_KEY_CODES}
- elevateEdgesOnSelect
+ elevateEdgesOnSelect={!workflowEdgesBehindNodes}
edges={renderedFlowEdges}
edgeTypes={edgeTypes}
isValidConnection={isValidConnection}
diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/graph-preview/GraphPreviewDialog.browser.test.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/graph-preview/GraphPreviewDialog.browser.test.tsx
index 87c7e3ca18..1b8b3c504a 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/graph-preview/GraphPreviewDialog.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/graph-preview/GraphPreviewDialog.browser.test.tsx
@@ -300,6 +300,7 @@ const preferencesSnapshot = {
reduceMotion: false,
themeId: 'classic' as const,
workflowEdgeStyle: 'curved' as const,
+ workflowEdgesBehindNodes: false,
workflowShowMinimap: true,
workflowSnapToGrid: false,
workflowValidateConnections: true,
diff --git a/invokeai/frontend/webv2/src/workbench/settings/applicationContributions.ts b/invokeai/frontend/webv2/src/workbench/settings/applicationContributions.ts
index 009b495739..fb42b1e0bc 100644
--- a/invokeai/frontend/webv2/src/workbench/settings/applicationContributions.ts
+++ b/invokeai/frontend/webv2/src/workbench/settings/applicationContributions.ts
@@ -76,6 +76,11 @@ export const workflowSettings = section('workflow', 'Workflow', [
{ value: 'square', label: text('options.square', 'Square') },
],
},
+ preference(
+ 'workflowEdgesBehindNodes',
+ 'Keep highlighted connections behind nodes',
+ 'workflow edges wires links z-order'
+ ),
preference('workflowSnapToGrid', 'Always snap to grid', 'workflow nodes'),
preference('workflowShowMinimap', 'Show minimap'),
preference('workflowValidateConnections', 'Validate connections', 'workflow edges'),
diff --git a/invokeai/frontend/webv2/src/workbench/settings/contracts.ts b/invokeai/frontend/webv2/src/workbench/settings/contracts.ts
index fe15207d63..3ab191adb8 100644
--- a/invokeai/frontend/webv2/src/workbench/settings/contracts.ts
+++ b/invokeai/frontend/webv2/src/workbench/settings/contracts.ts
@@ -82,6 +82,8 @@ export interface WorkbenchPreferences {
workflowValidateConnections: boolean;
/** Connection line rendering in the workflow editor. */
workflowEdgeStyle: 'curved' | 'square';
+ /** Keep connections of a selected node beneath nodes instead of raising them over node controls. */
+ workflowEdgesBehindNodes: boolean;
/** Account-bound overrides keyed by hotkey id (`app.invoke`, `gallery.galleryNavLeft`, etc.). */
customHotkeys: Record<string, string[]>;
/** Generate panel section open/closed overrides keyed by section id; absent = section default. */
diff --git a/invokeai/frontend/webv2/src/workbench/settings/store.test.ts b/invokeai/frontend/webv2/src/workbench/settings/store.test.ts
index 1efc3c7736..45d28e8f7e 100644
--- a/invokeai/frontend/webv2/src/workbench/settings/store.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/settings/store.test.ts
@@ -381,6 +381,16 @@ describe('normalizeWorkbenchPreferences prompt editing', () => {
});
});
+describe('normalizeWorkbenchPreferences workflow editor', () => {
+ it('keeps connections above nodes unless the preference is explicitly on', () => {
+ expect(store.normalizeWorkbenchPreferences({}).workflowEdgesBehindNodes).toBe(false);
+ expect(
+ store.normalizeWorkbenchPreferences({ workflowEdgesBehindNodes: 'yes' as never }).workflowEdgesBehindNodes
+ ).toBe(false);
+ expect(store.normalizeWorkbenchPreferences({ workflowEdgesBehindNodes: true }).workflowEdgesBehindNodes).toBe(true);
+ });
+});
+
describe('normalizeWorkbenchPreferences diagnostics', () => {
it('heals invalid diagnostics preferences to defaults', () => {
expect(
diff --git a/invokeai/frontend/webv2/src/workbench/settings/store.ts b/invokeai/frontend/webv2/src/workbench/settings/store.ts
index c75843446b..0f0dd84422 100644
--- a/invokeai/frontend/webv2/src/workbench/settings/store.ts
+++ b/invokeai/frontend/webv2/src/workbench/settings/store.ts
@@ -77,6 +77,7 @@ export const DEFAULT_PREFERENCES: WorkbenchPreferences = {
showFocusRegionHighlight: true,
themeId: DEFAULT_THEME_ID,
workflowEdgeStyle: 'curved',
+ workflowEdgesBehindNodes: false,
workflowShowMinimap: true,
workflowSnapToGrid: false,
workflowValidateConnections: true,
@@ -358,6 +359,10 @@ export const normalizeWorkbenchPreferences = (preferences?: WorkbenchPreferences
: preferences?.workflowEdgeStyle === 'curved'
? preferences.workflowEdgeStyle
: DEFAULT_PREFERENCES.workflowEdgeStyle,
+ workflowEdgesBehindNodes:
+ typeof preferences?.workflowEdgesBehindNodes === 'boolean'
+ ? preferences.workflowEdgesBehindNodes
+ : DEFAULT_PREFERENCES.workflowEdgesBehindNodes,
workflowShowMinimap:
typeof preferences?.workflowShowMinimap === 'boolean'
? preferences.workflowShowMinimap