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.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
fix(webv2): name the media source on the locked video aspect-ratio control
Lincoln Steine21037300f70
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.jsonindex ed6414547a..3d55701e36 100644--- a/invokeai/frontend/webv2/public/locales/en.json+++ b/invokeai/frontend/webv2/public/locales/en.json@@ -3866,6 +3866,11 @@"last-frame": "from the last frame","source-video": "from the initial video"},+ "dimensionSourceValue": {+ "first-frame": "From the first frame",+ "last-frame": "From the last frame",+ "source-video": "From the initial video"+ },"firstFrame": "First Frame","firstFrameBlocked": "Clear the initial video to start from a frame instead.","firstFrameHelp": "The video starts on this image.",diff --git a/invokeai/frontend/webv2/src/features/video/ui/VideoWidgetView.tsx b/invokeai/frontend/webv2/src/features/video/ui/VideoWidgetView.tsxindex 537bc63d1e..5c6c6e4ebc 100644--- a/invokeai/frontend/webv2/src/features/video/ui/VideoWidgetView.tsx+++ b/invokeai/frontend/webv2/src/features/video/ui/VideoWidgetView.tsx@@ -458,6 +458,24 @@ export const VideoWidgetView = () => {!canPlaceReferenceExtendAnchor(values.references, values.sourceVideo?.video_name, maxVideoReferences);const hasConditioningMedia = Boolean(values.firstFrameImage || values.lastFrameImage || values.sourceVideo);const derivedSourceText = dimensions ? t(`widgets.video.dimensionSource.${dimensions.source}`) : undefined;+ // Media pins the canvas to its own proportions, so the stored preset is not what the output will+ // be: leaving it on the trigger of a disabled control states a ratio the render will not use. The+ // preset itself is kept, not rewritten -- it is what the panel goes back to when the media is+ // removed -- and the trigger names the source instead. Deliberately not the nearest standard+ // preset: media rarely lands exactly on one, so that would swap one wrong ratio for another.+ // Truncating, like the Generate panel's own aspect-ratio trigger: the slot clips its value text+ // rather than wrapping it, so a phrase wider than the control ends mid-word in a docked panel+ // instead of in an ellipsis.+ const dimensionSource = dimensions?.source;+ const derivedSourceValueText = useMemo(+ () =>+ dimensionSource && dimensionSource !== 'aspect-ratio' ? (+ <Text as="span" fontSize="xs" truncate>+ {t(`widgets.video.dimensionSourceValue.${dimensionSource}`)}+ </Text>+ ) : undefined,+ [dimensionSource, t]+ );const derivedSizeText = dimensions? `${t('widgets.video.derivedSize', { height: dimensions.height, width: dimensions.width })}${derivedSourceText ? ` — ${derivedSourceText}` : ''@@ -614,6 +632,7 @@ export const VideoWidgetView = () => {flex="1"size="xs"value={aspectRatioValue}+ valueText={derivedSourceValueText}onValueChange={set.aspectRatio}/><IconButtondiff --git a/invokeai/frontend/webv2/src/platform/ui/Select.browser.test.tsx b/invokeai/frontend/webv2/src/platform/ui/Select.browser.test.tsxindex 13f6509161..dd345f6054 100644--- a/invokeai/frontend/webv2/src/platform/ui/Select.browser.test.tsx+++ b/invokeai/frontend/webv2/src/platform/ui/Select.browser.test.tsx@@ -6,6 +6,12 @@ import { afterEach, beforeEach, describe, expect, it } from 'vitest';import { Select } from './Select';+const RATIO_ITEMS = [+ { label: '16:9', value: '16:9' },+ { label: '1:1', value: '1:1' },+];+const RATIO_VALUE = ['16:9'];+(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;describe('Select', () => {@@ -32,6 +38,40 @@ describe('Select', () => {host.remove();});+ it('shows the selected label by default and lets a caller name the value instead', async () => {+ // Callers that override the trigger text rely on omitting the prop falling back to the+ // selection rather than rendering an empty trigger -- a Select whose value is still meaningful+ // but whose display is not (a disabled control whose size comes from elsewhere, a preset list+ // with no exact match) states something the selection alone cannot.+ await act(() => {+ root.render(+ <ChakraProvider value={system}>+ <Select+ aria-label="Aspect ratio"+ collection={createListCollection({ items: RATIO_ITEMS })}+ value={RATIO_VALUE}+ />+ </ChakraProvider>+ );+ });+ expect(trigger().textContent).toContain('16:9');++ await act(() => {+ root.render(+ <ChakraProvider value={system}>+ <Select+ aria-label="Aspect ratio"+ collection={createListCollection({ items: RATIO_ITEMS })}+ value={RATIO_VALUE}+ valueText="From the first frame"+ />+ </ChakraProvider>+ );+ });+ expect(trigger().textContent).toContain('From the first frame');+ expect(trigger().textContent).not.toContain('16:9');+ });+it('disables the trigger while the collection is empty, and opens once it has items', async () => {await mount([]);expect(trigger().disabled).toBe(true);