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(webv2): add focusSource and openWorkflowEditor to graph preview port

joshistoast131d0cfda73e
diff --git a/invokeai/frontend/webv2/src/app/WorkflowUiAdapter.tsx b/invokeai/frontend/webv2/src/app/WorkflowUiAdapter.tsx
index 16e427c57d..a4ebcfe65c 100644
--- a/invokeai/frontend/webv2/src/app/WorkflowUiAdapter.tsx
+++ b/invokeai/frontend/webv2/src/app/WorkflowUiAdapter.tsx
@@ -27,6 +27,7 @@ import {
import { markWorkbenchPerf, measureWorkbenchPerf, timeWorkbenchPerf } from '@workbench/performanceMarks';
import { getWorkbenchPreferences, subscribeWorkbenchPreferences } from '@workbench/settings/store';
import { useNotify } from '@workbench/useNotify';
+import { useOpenWorkbenchWidget } from '@workbench/useOpenWorkbenchWidget';
import { getProjectWidgetValues } from '@workbench/widgetState';
import {
useActiveProjectSelector,
@@ -54,9 +55,15 @@ const WorkflowGraphPreviewAdapterProvider = ({ children }: { children: ReactNode
const availabilityModels = modelsStatus === 'loaded' ? models : undefined;
const commands = useWorkbenchCommands();
const queries = useWorkbenchQueries();
+ const openWidget = useOpenWorkbenchWidget();
const adapter = useMemo<WorkflowGraphPreviewPort>(
() => ({
+ focusSource: (sourceId) => {
+ if (sourceId) {
+ openWidget(sourceId);
+ }
+ },
getRoute: (sourceId) => {
if (!sourceId) {
return null;
@@ -98,8 +105,11 @@ const WorkflowGraphPreviewAdapterProvider = ({ children }: { children: ReactNode
throw error;
}
},
+ openWorkflowEditor: () => {
+ openWidget('workflow');
+ },
}),
- [availabilityModels, commands, queries, routeInput]
+ [availabilityModels, commands, openWidget, queries, routeInput]
);
return <WorkflowGraphPreviewProvider adapter={adapter}>{children}</WorkflowGraphPreviewProvider>;
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 b0d0e521d4..e403236d73 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
@@ -94,8 +94,10 @@ describe('Workflow UI read-port isolation', () => {
let setGraphPreview: ((adapter: WorkflowGraphPreviewPort) => void) | null = null;
const initialGraphPreview: WorkflowGraphPreviewPort = {
+ focusSource: () => {},
getRoute: () => null,
invoke: () => Promise.resolve(false),
+ openWorkflowEditor: () => {},
};
const GraphPreviewHarness = ({ children }: { children: ReactNode }) => {
const [graphPreview, setGraphPreviewState] = useState(initialGraphPreview);
@@ -161,8 +163,22 @@ describe('Workflow UI read-port isolation', () => {
await act(() => capabilities.setSnapshot({ canUseCache: false }));
expect(counts).toEqual({ capability: 2, graph: 1, preferences: 2, project: 2, projectEqual: 1, services: 1 });
- await act(() => setGraphPreview?.({ getRoute: () => null, invoke: () => Promise.resolve(true) }));
- await act(() => setGraphPreview?.({ getRoute: () => null, invoke: () => Promise.resolve(false) }));
+ await act(() =>
+ setGraphPreview?.({
+ focusSource: () => {},
+ getRoute: () => null,
+ invoke: () => Promise.resolve(true),
+ openWorkflowEditor: () => {},
+ })
+ );
+ await act(() =>
+ setGraphPreview?.({
+ focusSource: () => {},
+ getRoute: () => null,
+ invoke: () => Promise.resolve(false),
+ openWorkflowEditor: () => {},
+ })
+ );
expect(counts).toEqual({ capability: 2, graph: 3, preferences: 2, project: 2, projectEqual: 1, services: 1 });
});
});
diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/WorkflowUiContext.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/WorkflowUiContext.tsx
index a603a42d7e..7385ee8533 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/WorkflowUiContext.tsx
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/WorkflowUiContext.tsx
@@ -45,6 +45,8 @@ export interface WorkflowGraphPreviewPort {
sourceId?: WorkflowInvocationSourceId
): { canInvoke: boolean; label: string; validationMessage?: string } | null;
invoke(sourceId?: WorkflowInvocationSourceId): Promise<boolean>;
+ focusSource(sourceId?: WorkflowInvocationSourceId): void; // reveal the source's widget (provenance links)
+ openWorkflowEditor(): void; // reveal the workflow editor widget
}
/**