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): centralize image outlines

joshistoasta0788b13c5b9
diff --git a/invokeai/frontend/webv2/src/features/generation/ui/promptFields/PromptTemplateEditor.tsx b/invokeai/frontend/webv2/src/features/generation/ui/promptFields/PromptTemplateEditor.tsx
index 68372f3515..c74c58ea2f 100644
--- a/invokeai/frontend/webv2/src/features/generation/ui/promptFields/PromptTemplateEditor.tsx
+++ b/invokeai/frontend/webv2/src/features/generation/ui/promptFields/PromptTemplateEditor.tsx
@@ -285,8 +285,6 @@ export const PromptTemplateEditor = ({
<PromptTemplateImage
alt=""
boxSize="12"
- borderColor="border.emphasized"
- borderWidth="1px"
flexShrink="0"
fallback={null}
localPreviewUrl={draft.imagePreviewUrl}
diff --git a/invokeai/frontend/webv2/src/features/generation/ui/promptFields/PromptTemplateImage.tsx b/invokeai/frontend/webv2/src/features/generation/ui/promptFields/PromptTemplateImage.tsx
index d24620c771..5ce88d02ca 100644
--- a/invokeai/frontend/webv2/src/features/generation/ui/promptFields/PromptTemplateImage.tsx
+++ b/invokeai/frontend/webv2/src/features/generation/ui/promptFields/PromptTemplateImage.tsx
@@ -10,6 +10,7 @@ import { useState } from 'react';
const blobKeys = new WeakMap<Blob, number>();
let nextBlobKey = 1;
+const IMAGE_OUTLINE_PROPS = { outline: '1px solid {colors.border.image}', outlineOffset: '-1px' };
const getBlobKey = (blob: Blob): number => {
const existing = blobKeys.get(blob);
@@ -48,7 +49,7 @@ export const PromptTemplateImage = ({
});
if (hasLocalOverride) {
- return localPreviewUrl ? <Image {...imageProps} src={localPreviewUrl} /> : fallback;
+ return localPreviewUrl ? <Image {...IMAGE_OUTLINE_PROPS} {...imageProps} src={localPreviewUrl} /> : fallback;
}
if (!query.data) {
@@ -63,5 +64,5 @@ const BlobImage = ({ blob, imageProps }: { blob: Blob; imageProps: Omit<ImagePro
useMountEffect(() => () => URL.revokeObjectURL(src));
- return <Image {...imageProps} src={src} />;
+ return <Image {...IMAGE_OUTLINE_PROPS} {...imageProps} src={src} />;
};
diff --git a/invokeai/frontend/webv2/src/features/generation/ui/promptFields/PromptTemplates.browser.test.tsx b/invokeai/frontend/webv2/src/features/generation/ui/promptFields/PromptTemplates.browser.test.tsx
index 6796ea065d..f4f2fb60b0 100644
--- a/invokeai/frontend/webv2/src/features/generation/ui/promptFields/PromptTemplates.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/features/generation/ui/promptFields/PromptTemplates.browser.test.tsx
@@ -184,6 +184,8 @@ afterEach(async () => {
host?.remove();
host = null;
root = null;
+ document.documentElement.className = '';
+ delete document.documentElement.dataset.theme;
});
describe('the prompt templates panel', () => {
@@ -608,3 +610,50 @@ it('revokes a fetched template image blob URL when it unmounts', async () => {
createObjectUrl.mockRestore();
revokeObjectUrl.mockRestore();
});
+
+describe('prompt template image outlines', () => {
+ const modes = [
+ ['light', 'light', 'oklch(0 0 0 / 0.1)'],
+ ['dark', 'classic', 'oklch(1 0 0 / 0.1)'],
+ ] as const;
+
+ for (const [mode, theme, outlineColor] of modes) {
+ it(`gives local preview images a one-pixel inset outline in ${mode} mode`, async () => {
+ document.documentElement.className = mode;
+ document.documentElement.dataset.theme = theme;
+
+ await render(
+ <PromptTemplateImage
+ alt="Local preview"
+ fallback={IMAGE_FALLBACK}
+ localPreviewUrl="data:image/png;base64,iVBORw0KGgo="
+ template={templateWithImage}
+ />
+ );
+
+ const image = host!.querySelector<HTMLImageElement>('img[alt="Local preview"]')!;
+
+ expect(getComputedStyle(image).outlineStyle).toBe('solid');
+ expect(getComputedStyle(image).outlineWidth).toBe('1px');
+ expect(getComputedStyle(image).outlineOffset).toBe('-1px');
+ expect(getComputedStyle(image).outlineColor).toBe(outlineColor);
+ });
+ }
+
+ it('allows callers to override the default outline', async () => {
+ await render(
+ <PromptTemplateImage
+ alt="Overridden preview"
+ fallback={IMAGE_FALLBACK}
+ localPreviewUrl="data:image/png;base64,iVBORw0KGgo="
+ outline="2px dotted red"
+ outlineOffset="0"
+ template={templateWithImage}
+ />
+ );
+
+ const image = host!.querySelector<HTMLImageElement>('img[alt="Overridden preview"]')!;
+ expect(getComputedStyle(image).outline).toBe('rgb(255, 0, 0) dotted 2px');
+ expect(getComputedStyle(image).outlineOffset).toBe('0px');
+ });
+});
diff --git a/invokeai/frontend/webv2/src/features/upscale/ui/UpscaleWidgetView.tsx b/invokeai/frontend/webv2/src/features/upscale/ui/UpscaleWidgetView.tsx
index 8d43f3b43c..b5539c8edd 100644
--- a/invokeai/frontend/webv2/src/features/upscale/ui/UpscaleWidgetView.tsx
+++ b/invokeai/frontend/webv2/src/features/upscale/ui/UpscaleWidgetView.tsx
@@ -453,11 +453,11 @@ const UpscaleImageField = ({
alt={t('widgets.upscale.inputImageAlt')}
boxSize="full"
objectFit="contain"
- outline="1px solid rgba(0, 0, 0, 0.1)"
+ outline="1px solid"
+ outlineColor="border.image"
outlineOffset="-1px"
rounded="sm"
src={galleryImageUrls.thumbnail(inputImage.image_name)}
- _dark={{ outlineColor: 'rgba(255, 255, 255, 0.1)' }}
/>
</Box>
<Stack align="start" flex="1" gap="1" justify="center" minW="0">
diff --git a/invokeai/frontend/webv2/src/platform/ui/theme/system.test.ts b/invokeai/frontend/webv2/src/platform/ui/theme/system.test.ts
index a4c76d9de1..37d377b319 100644
--- a/invokeai/frontend/webv2/src/platform/ui/theme/system.test.ts
+++ b/invokeai/frontend/webv2/src/platform/ui/theme/system.test.ts
@@ -55,6 +55,13 @@ describe('ramp + mapping structure', () => {
expect(resolveToken(sys, 'classic', 'border')).toBe(resolveToken(sys, 'classic', 'neutral.600'));
});
+ it('uses pure black/white low-opacity image outlines by color mode', () => {
+ expect(resolveToken(sys, 'light', 'border.image')).toBe('oklch(0 0 0 / 0.1)');
+ for (const theme of ['classic', 'forest', 'mono', 'ultradark']) {
+ expect(resolveToken(sys, theme, 'border.image')).toBe('oklch(1 0 0 / 0.1)');
+ }
+ });
+
it('emits surface/text/border tokens via per-theme conditions only — never the leaky mode selectors', () => {
// Chakra's `_light` selector (`:root &, .light &`) matches under EVERY theme via its
// `:root &` arm. A surface token placed there leaks its light value into the dark
diff --git a/invokeai/frontend/webv2/src/platform/ui/theme/system.ts b/invokeai/frontend/webv2/src/platform/ui/theme/system.ts
index 4d78d644fc..2dc4dd7058 100644
--- a/invokeai/frontend/webv2/src/platform/ui/theme/system.ts
+++ b/invokeai/frontend/webv2/src/platform/ui/theme/system.ts
@@ -145,6 +145,7 @@ const semanticColors = {
'border.muted': stepRef(600, 300),
'border.emphasized': stepRef(500, 400),
'border.error': colorToken(danger),
+ 'border.image': colorToken((theme) => (theme.colorScheme === 'light' ? 'oklch(0 0 0 / 0.1)' : 'oklch(1 0 0 / 0.1)')),
/**
* Chakra's default `colorPalette` is `gray`; re-pointing its virtual-palette