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.

fix(webv2): collapse matching route icons

joshistoast79b5c3f0a6df
diff --git a/invokeai/frontend/webv2/src/workbench/shell/topbar/RoutingControl.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/shell/topbar/RoutingControl.browser.test.tsx
index 646e49f901..42678b3ef1 100644
--- a/invokeai/frontend/webv2/src/workbench/shell/topbar/RoutingControl.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/workbench/shell/topbar/RoutingControl.browser.test.tsx
@@ -56,6 +56,12 @@ const LOCKED_STATE = {
...BASE_STATE,
invocation: { ...BASE_STATE.invocation, destinationLocked: true, sourceLocked: true },
} satisfies InvocationState;
+const SAME_SOURCE_AND_DESTINATION_STATE = {
+ ...BASE_STATE,
+ invocation: { ...BASE_STATE.invocation, destination: 'canvas', sourceId: 'canvas' },
+ placedTypeIds: new Set(['canvas']),
+ visibleTypeIds: new Set(['canvas']),
+} satisfies InvocationState;
let host: HTMLDivElement | null = null;
let root: Root | null = null;
@@ -91,6 +97,22 @@ afterEach(async () => {
});
describe('RoutingControl', () => {
+ it('shows one centered icon when source and destination match', async () => {
+ await renderControl(SAME_SOURCE_AND_DESTINATION_STATE);
+
+ const button = document.querySelector<HTMLButtonElement>('[data-routing-control]');
+ const icon = button?.querySelector<SVGElement>('svg');
+
+ expect(button).not.toBeNull();
+ expect(icon).not.toBeNull();
+ expect(button?.querySelectorAll('svg')).toHaveLength(1);
+
+ const buttonBounds = button!.getBoundingClientRect();
+ const iconBounds = icon!.getBoundingClientRect();
+ expect(iconBounds.left + iconBounds.width / 2).toBeCloseTo(buttonBounds.left + buttonBounds.width / 2, 1);
+ expect(iconBounds.top + iconBounds.height / 2).toBeCloseTo(buttonBounds.top + buttonBounds.height / 2, 1);
+ });
+
it('uses narrow diagonal route geometry without an arrow and adds only a top-right dot when locked', async () => {
await renderControl(BASE_STATE);
diff --git a/invokeai/frontend/webv2/src/workbench/shell/topbar/RoutingControl.tsx b/invokeai/frontend/webv2/src/workbench/shell/topbar/RoutingControl.tsx
index 49472a4b45..21973ba75f 100644
--- a/invokeai/frontend/webv2/src/workbench/shell/topbar/RoutingControl.tsx
+++ b/invokeai/frontend/webv2/src/workbench/shell/topbar/RoutingControl.tsx
@@ -28,6 +28,7 @@ export const RoutingControl = ({ state }: { state: InvocationState }) => {
const isLocked = invocation.sourceLocked || invocation.destinationLocked;
const hasSource = placedTypeIds.has(getWidgetTypeIdForSourceId(invocation.sourceId));
const sourceTypeId = getWidgetTypeIdForSourceId(invocation.sourceId);
+ const isSameRoute = hasSource && sourceTypeId === invocation.destination;
const accessibleName = describeRoute({
destination: invocation.destination,
destinationLocked: invocation.destinationLocked,
@@ -67,22 +68,34 @@ export const RoutingControl = ({ state }: { state: InvocationState }) => {
w="34px"
display="grid"
>
- {hasSource ? (
- <WidgetIcon {...getWidgetIconProps('source')} />
- ) : (
- <Box
- borderColor="border.emphasized"
- borderStyle="dashed"
- borderWidth="1px"
+ {isSameRoute ? (
+ <WidgetIcon
boxSize="3.5"
- data-routing-source-icon=""
- left="4px"
- position="absolute"
- rounded="xs"
- top="4px"
+ color="fg.muted"
+ data-routing-shared-icon=""
+ icon={getWidgetById(sourceTypeId)?.manifest.icon}
+ placeSelf="center"
/>
+ ) : (
+ <>
+ {hasSource ? (
+ <WidgetIcon {...getWidgetIconProps('source')} />
+ ) : (
+ <Box
+ borderColor="border.emphasized"
+ borderStyle="dashed"
+ borderWidth="1px"
+ boxSize="3.5"
+ data-routing-source-icon=""
+ left="4px"
+ position="absolute"
+ rounded="xs"
+ top="4px"
+ />
+ )}
+ <WidgetIcon {...getWidgetIconProps('destination')} />
+ </>
)}
- <WidgetIcon {...getWidgetIconProps('destination')} />
{isLocked ? (
<Status.Root
colorPalette="accent"