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): keep focus on wheel, validate LoRA weights as typed, and verify IME entry
Josh Corbett84f652a3dc62
diff --git a/invokeai/frontend/webv2/src/features/workflow/core/fields.test.ts b/invokeai/frontend/webv2/src/features/workflow/core/fields.test.tsindex 3521c8c89f..cfa3dce7da 100644--- a/invokeai/frontend/webv2/src/features/workflow/core/fields.test.ts+++ b/invokeai/frontend/webv2/src/features/workflow/core/fields.test.ts@@ -1,3 +1,4 @@+import { DEFAULT_LORA_WEIGHT_CONFIG } from '@features/generation/settings';import { describe, expect, it } from 'vitest';import type { FieldInputTemplate, FieldType } from './types';@@ -8,12 +9,14 @@ import {getWorkflowFieldInvalidReason,isDirectInputField,isLoraFieldCollectionEntry,+ isLoraFieldWeightValid,isModelFieldType,isWorkflowCollectionItemValid,isWorkflowFieldValueValid,toLoraFieldCollectionList,getRandomWorkflowFieldValue,isShuffleableField,+ LORA_FIELD_WEIGHT_RANGE,} from './fields';const single = (name: string): FieldType => ({ batch: false, cardinality: 'SINGLE', name });@@ -266,6 +269,38 @@ describe('workflow field validation', () => {expect(getWorkflowFieldInvalidReason({ isConnected: false, template: loras, value: [] })).toBe(null);});+ it('keeps a cleared or out-of-range LoRA weight as a readable entry that names its own reason', () => {+ const loras = input({+ required: false,+ type: { batch: false, cardinality: 'SINGLE_OR_COLLECTION', name: 'LoRAField' },+ });+ const reasonFor = (value: unknown) => getWorkflowFieldInvalidReason({ isConnected: false, template: loras, value });++ // The range is restated from the Generate LoRA config rather than imported; keep the two together.+ expect(LORA_FIELD_WEIGHT_RANGE).toEqual({+ max: DEFAULT_LORA_WEIGHT_CONFIG.numberInputMax,+ min: DEFAULT_LORA_WEIGHT_CONFIG.numberInputMin,+ });+ expect(isLoraFieldWeightValid(LORA_FIELD_WEIGHT_RANGE.max)).toBe(true);+ expect(isLoraFieldWeightValid(LORA_FIELD_WEIGHT_RANGE.min)).toBe(true);+ expect(isLoraFieldWeightValid(LORA_FIELD_WEIGHT_RANGE.max + 0.01)).toBe(false);+ expect(isLoraFieldWeightValid(null)).toBe(false);++ // A cleared weight keeps its identity (the row still renders) but cannot run.+ expect(isLoraFieldCollectionEntry({ ...LORA_ENTRY, weight: null })).toBe(true);+ expect(isWorkflowFieldValueValid(loras, [LORA_ENTRY, { ...LORA_ENTRY, weight: null }])).toBe(false);+ expect(reasonFor([LORA_ENTRY, { ...LORA_ENTRY, weight: null }])).toBe('Item 2 has no weight.');+ expect(reasonFor([{ ...LORA_ENTRY, weight: 999 }])).toBe('Item 1 needs a weight from -10 to 10.');+ expect(reasonFor({ ...LORA_ENTRY, weight: -10.5 })).toBe('Item 1 needs a weight from -10 to 10.');+ expect(reasonFor([LORA_ENTRY, { lora: { key: 'ghost' }, weight: 1 }])).toBe('Item 2 is not a readable LoRA.');+ expect(+ reasonFor([+ { ...LORA_ENTRY, weight: -10 },+ { ...LORA_ENTRY, weight: 10 },+ ])+ ).toBeNull();+ });+it('rejects a LoRA identifier missing the fields the backend requires, rather than enqueuing a 422', () => {const loras = input({required: false,@@ -276,7 +311,7 @@ describe('workflow field validation', () => {expect(isWorkflowFieldValueValid(loras, [{ lora: { key: 'lora-key' }, weight: 0.75 }])).toBe(false);expect(isWorkflowFieldValueValid(loras, [{ ...LORA_ENTRY, lora: { ...LORA_ENTRY.lora, hash: '' } }])).toBe(false);expect(getWorkflowFieldInvalidReason({ isConnected: false, template: loras, value: [{ weight: 1 }] })).toBe(- 'Invalid value.'+ 'Item 1 is not a readable LoRA.');});diff --git a/invokeai/frontend/webv2/src/features/workflow/core/fields.ts b/invokeai/frontend/webv2/src/features/workflow/core/fields.tsindex a07c512b67..d6546d7ace 100644--- a/invokeai/frontend/webv2/src/features/workflow/core/fields.ts+++ b/invokeai/frontend/webv2/src/features/workflow/core/fields.ts@@ -147,12 +147,24 @@ const hasNonEmptyStringProp = (value: unknown, prop: string): boolean =>export const getFieldRecordId = (value: unknown, prop: string): string | null =>hasNonEmptyStringProp(value, prop) ? ((value as Record<string, string>)[prop] as string) : null;-/** A LoRA model identifier paired with its weight — one entry of a LoRA collection field. */+/** A LoRA model identifier paired with its weight — one entry of a LoRA collection field. `null` is a cleared weight. */export interface LoraFieldCollectionEntry {lora: { base: string; hash: string; key: string; name: string; type: string };- weight: number;+ weight: number | null;}+/**+ * The Generate LoRA weight bounds, restated: `@features/generation/settings` is side-effectful and would pull the+ * Generate settings core into the workflow boot graph. A core test pins the two together.+ */+export const LORA_FIELD_WEIGHT_RANGE = { max: 10, min: -10 } as const;++export const isLoraFieldWeightValid = (weight: unknown): weight is number =>+ typeof weight === 'number' &&+ Number.isFinite(weight) &&+ weight >= LORA_FIELD_WEIGHT_RANGE.min &&+ weight <= LORA_FIELD_WEIGHT_RANGE.max;+/** Require complete backend model identifiers; key-only entries cannot render meaningfully or enqueue successfully. */export const isLoraFieldCollectionEntry = (value: unknown): value is LoraFieldCollectionEntry => {if (typeof value !== 'object' || value === null) {@@ -163,11 +175,28 @@ export const isLoraFieldCollectionEntry = (value: unknown): value is LoraFieldCoreturn (['base', 'hash', 'key', 'name', 'type'].every((prop) => hasNonEmptyStringProp(entry.lora, prop)) &&- typeof entry.weight === 'number' &&- Number.isFinite(entry.weight)+ (entry.weight === null || (typeof entry.weight === 'number' && Number.isFinite(entry.weight))));};+const getLoraCollectionInvalidReason = (items: readonly unknown[]): string | null => {+ for (const [index, item] of items.entries()) {+ if (!isLoraFieldCollectionEntry(item)) {+ return `Item ${index + 1} is not a readable LoRA.`;+ }++ if (item.weight === null) {+ return `Item ${index + 1} has no weight.`;+ }++ if (!isLoraFieldWeightValid(item.weight)) {+ return `Item ${index + 1} needs a weight from ${LORA_FIELD_WEIGHT_RANGE.min} to ${LORA_FIELD_WEIGHT_RANGE.max}.`;+ }+ }++ return null;+};+/*** Normalize absent/scalar/list values into lists without discarding unreadable entries, which subsequent edits* must preserve.@@ -333,7 +362,10 @@ export const isWorkflowFieldValueValid = (template: FieldInputTemplate, value: ucase 'LoRAField':// An empty list is a legitimate value: a collection loader with no LoRAs passes its// models through untouched.- return Array.isArray(value) ? value.every(isLoraFieldCollectionEntry) : isLoraFieldCollectionEntry(value);+ return (+ (Array.isArray(value) || isLoraFieldCollectionEntry(value)) &&+ getLoraCollectionInvalidReason(toLoraFieldCollectionList(value)) === null+ );case 'SchedulerField':return isNonEmptyString(value);case 'StylePresetField':@@ -389,6 +421,10 @@ export const getWorkflowFieldInvalidReason = ({return getCollectionInvalidReason(template, value);}+ if (template.type.name === 'LoRAField' && isDirectInputField(template) && !isEmptyOptionalValue(value)) {+ return getLoraCollectionInvalidReason(toLoraFieldCollectionList(value));+ }+if (!template.required) {return isDirectInputField(template) && !isWorkflowFieldValueValid(template, value) ? 'Invalid value.' : null;}diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/fields/WorkflowFieldInput.browser.test.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/fields/WorkflowFieldInput.browser.test.tsxindex 48fa2f7965..88d4715eb9 100644--- a/invokeai/frontend/webv2/src/features/workflow/ui/fields/WorkflowFieldInput.browser.test.tsx+++ b/invokeai/frontend/webv2/src/features/workflow/ui/fields/WorkflowFieldInput.browser.test.tsx@@ -9,10 +9,16 @@ import { system } from '@theme/system';import { act, cloneElement, startTransition, useCallback, useState } from 'react';import { createRoot, type Root } from 'react-dom/client';import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';-import { userEvent } from 'vitest/browser';+import { server, userEvent } from 'vitest/browser';import { WorkflowFieldInput, type WorkflowFieldInputProps } from './WorkflowFieldInput';+declare module 'vitest/browser' {+ interface BrowserCommands {+ imeCompose: (steps: readonly { kind: 'commit' | 'compose'; text: string }[]) => Promise<void>;+ }+}+(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;const uploadImageMock = vi.fn();@@ -254,10 +260,7 @@ const renderField = async (});};-/**- * Use real keystrokes because the number-input state machine ignores direct DOM writes and the regression occurs- * between inputs.- */+/** Real keystrokes: the weight regressions live between inputs, where a direct DOM write never goes. */const typeWeight = async (input: HTMLInputElement, keys: string) => {await act(async () => {await userEvent.click(input);@@ -950,7 +953,9 @@ describe('WorkflowFieldInput LoRA collection', () => {await typeWeight(weight, '0');await pressKey('.');- expect(weight.value).toBe('0.');+ // A number input reports the trailing `.` as absent; the next digit landing after it is the proof.+ expect(weight.value).toBe('0');+ expect(onChange).toHaveBeenLastCalledWith([loraEntry({ weight: 0 })]);await pressKey('5');@@ -958,9 +963,14 @@ describe('WorkflowFieldInput LoRA collection', () => {expect(onChange).toHaveBeenLastCalledWith([loraEntry({ weight: 0.5 })]);// Nothing on the way there was ever an order of magnitude out.expect(onChange.mock.calls.every(([value]) => (value as { weight: number }[])[0]!.weight <= 0.5)).toBe(true);++ // The arrow keys step by the LoRA coarse step, not the number input's default of 1.+ await pressKey('{ArrowUp}');+ expect(weight.value).toBe('0.55');+ expect(onChange).toHaveBeenLastCalledWith([loraEntry({ weight: 0.55 })]);});- it('clamps a typed weight to the configured range on blur', async () => {+ it('keeps an out-of-range or cleared weight on screen and invalid instead of clamping or restoring it', async () => {const onChange = vi.fn();await renderStatefulLoras([loraEntry()], onChange);@@ -968,11 +978,25 @@ describe('WorkflowFieldInput LoRA collection', () => {const weight = host.querySelector<HTMLInputElement>('input')!;await typeWeight(weight, '999');+ expect(onChange).toHaveBeenLastCalledWith([loraEntry({ weight: 999 })]);+ expect(weight.getAttribute('aria-invalid')).toBe('true');await blurWeight(weight);-- await vi.waitFor(() => {- expect(onChange).toHaveBeenLastCalledWith([loraEntry({ weight: 10 })]);- });+ expect(weight.value).toBe('999');+ expect(weight.getAttribute('aria-invalid')).toBe('true');++ await typeWeight(weight, '2');+ expect(onChange).toHaveBeenLastCalledWith([loraEntry({ weight: 2 })]);+ expect(weight.getAttribute('aria-invalid')).toBeNull();++ // Clearing keeps the row (and its input) and reports through the field, not by snapping back to 2.+ await typeWeight(weight, '{Backspace}');+ expect(onChange).toHaveBeenLastCalledWith([loraEntry({ weight: null })]);+ expect(weight.value).toBe('');+ expect(weight.getAttribute('aria-invalid')).toBe('true');+ await blurWeight(weight);+ expect(host.querySelector<HTMLInputElement>('input')).toBe(weight);+ expect(weight.value).toBe('');+ expect(weight.getAttribute('aria-invalid')).toBe('true');});it('keeps an unreadable entry in the list and lets the user remove it', async () => {@@ -1353,6 +1377,43 @@ describe('WorkflowFieldInput text and number entry', () => {expect(onCommit).toHaveBeenLastCalledWith('world, again. ');});+ it('keeps a composed entry intact while each update echoes back, in the input and the textarea', async () => {+ const TEXTAREA = fullTemplate('StringField', { uiComponent: 'textarea' });++ for (const [template, echo] of [+ [TEXT, 'sync'],+ [TEXT, 'deferred'],+ [TEXTAREA, 'deferred'],+ ] as const) {+ const { input, onCommit } = await renderStateful(template, 'hello world', echo);++ await keys('{Home}{ArrowRight}{ArrowRight}');+ // Kana-style entry: every update replaces the candidate text; the commit inserts the converted form.+ await act(async () => {+ await server.commands.imeCompose([+ { kind: 'compose', text: 'n' },+ { kind: 'compose', text: 'に' },+ { kind: 'compose', text: 'にh' },+ { kind: 'compose', text: 'にほ' },+ { kind: 'compose', text: 'にほん' },+ ]);+ });+ expect(input.value).toBe('heにほんllo world');+ expect(caret(input)).toEqual([5, 5]);++ await act(async () => {+ await server.commands.imeCompose([{ kind: 'commit', text: '日本' }]);+ });+ expect(input.value).toBe('he日本llo world');+ expect(caret(input)).toEqual([4, 4]);+ expect(onCommit).toHaveBeenLastCalledWith('he日本llo world');++ await keys('!');+ expect(input.value).toBe('he日本!llo world');+ expect(onCommit).toHaveBeenLastCalledWith('he日本!llo world');+ }+ });+it('keeps newlines and cross-line replacements in a textarea', async () => {const { input, onCommit } = await renderStateful(fullTemplate('StringField', { uiComponent: 'textarea' }),@@ -1547,13 +1608,20 @@ describe('WorkflowFieldInput text and number entry', () => {expect(stepped.onCommit).toHaveBeenLastCalledWith(0.25);expect(document.activeElement).toBe(stepped.input);- // Chromium would step the focused value on wheel; the field gives up focus so the panel scrolls instead.+ // Chromium would step the focused value on wheel; the field lets the event through unfocused, then takes+ // focus back with the draft intact.+ await keys('{Control>}a{/Control}0.');+ expect(stepped.onCommit).toHaveBeenLastCalledWith(0);await act(async () => {await userEvent.wheel(stepped.input, { delta: { y: 100 } });});- expect(stepped.input.value).toBe('0.25');- expect(stepped.onCommit).toHaveBeenLastCalledWith(0.25);- expect(document.activeElement).not.toBe(stepped.input);+ await vi.waitFor(() => {+ expect(document.activeElement).toBe(stepped.input);+ });+ expect(stepped.onCommit).toHaveBeenLastCalledWith(0);+ await keys('5');+ expect(stepped.input.value).toBe('0.5');+ expect(stepped.onCommit).toHaveBeenLastCalledWith(0.5);const integer = await renderStateful(INTEGER, 3);diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/fields/WorkflowFieldInput.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/fields/WorkflowFieldInput.tsxindex 892bfe84a2..f4d373cece 100644--- a/invokeai/frontend/webv2/src/features/workflow/ui/fields/WorkflowFieldInput.tsx+++ b/invokeai/frontend/webv2/src/features/workflow/ui/fields/WorkflowFieldInput.tsx@@ -13,7 +13,6 @@ import {Icon,Image,Input,- NumberInput,SimpleGrid,Stack,Switch,@@ -63,8 +62,10 @@ import { useWorkflowProjectSelector, useWorkflowUi } from '@features/workflow/uiimport {getResolvedWorkflowEdges,isLoraFieldCollectionEntry,+ isLoraFieldWeightValid,isWorkflowCollectionItemValid,isWorkflowGeneratorFieldTypeName,+ LORA_FIELD_WEIGHT_RANGE,toLoraFieldCollectionList,} from '@features/workflow/utility';import { planSeedSubmission, type SeedMode, wrapSeed } from '@platform/core/seed';@@ -186,8 +187,11 @@ const useFocusedDraft = () => {return [draft, setDraft, clearDraft] as const;};-/** A row of a list names itself by position; a scalar field is named by its title. */-type ScalarInputProps = WorkflowFieldInputProps & { ariaLabel?: string };+/**+ * A row of a list names itself by position; a scalar field is named by its title. `step` is the arrow-key+ * increment when the template declares no `multipleOf`.+ */+type ScalarInputProps = WorkflowFieldInputProps & { ariaLabel?: string; step?: number };const StringInput = ({ ariaLabel, id, invalid, onChange, template, value }: ScalarInputProps) => {const [draft, setDraft, clearDraft] = useFocusedDraft();@@ -238,12 +242,11 @@ const StringInput = ({ ariaLabel, id, invalid, onChange, template, value }: Scal/** A double-click anywhere in the box selects the whole value, not just the word under the pointer. */const selectInputText = (event: MouseEvent<HTMLInputElement>) => event.currentTarget.select();-/** Chromium steps a focused number input on wheel and swallows the scroll; unfocused, the panel scrolls instead. */-const blurOnWheel = (event: WheelEvent<HTMLInputElement>) => event.currentTarget.blur();--const NumericInput = ({ ariaLabel, id, invalid, onChange, template, value }: ScalarInputProps) => {+const NumericInput = ({ ariaLabel, id, invalid, onChange, step, template, value }: ScalarInputProps) => {const isInteger = template.type.name === 'IntegerField';const [draft, setDraft, clearDraft] = useFocusedDraft();+ // Set while a wheel event passes through: the blur it causes must not end the draft.+ const wheelRefocus = useRef(false);// Chromium keeps an unparseable partial entry (`-`, `1e`) on screen but reports it as empty, so the empty commit// alone cannot tell the field apart from a cleared one.const [hasBadInput, setHasBadInput] = useState(false);@@ -265,11 +268,41 @@ const NumericInput = ({ ariaLabel, id, invalid, onChange, template, value }: Sca);const onBlur = useCallback((event: FocusEvent<HTMLInputElement>) => {+ if (wheelRefocus.current) {+ return;+ }+setHasBadInput(event.currentTarget.validity.badInput);clearDraft();},[clearDraft]);+ // Chromium steps a focused number input on wheel and swallows the scroll. Dropping focus for the event lets the+ // panel scroll instead; focus returns, with the draft and caret, once the scroll has been dispatched.+ const onWheel = useCallback(+ (event: WheelEvent<HTMLInputElement>) => {+ const input = event.currentTarget;++ if (document.activeElement !== input || wheelRefocus.current) {+ return;+ }++ wheelRefocus.current = true;+ input.blur();+ requestAnimationFrame(() => {+ wheelRefocus.current = false;++ if (input.isConnected && document.activeElement === document.body) {+ input.focus({ preventScroll: true });+ } else {+ // Focus went elsewhere within the frame (momentum wheel plus a click): finish the blur that was skipped.+ setHasBadInput(input.validity.badInput);+ clearDraft();+ }+ });+ },+ [clearDraft]+ );// Any non-empty text React writes replaces the bad entry on screen (a reset or undo landing a number), so the// flag cannot outlive it; while the entry is held the text is empty, so a lagging Canvas echo leaves it alone.@@ -285,7 +318,8 @@ const NumericInput = ({ ariaLabel, id, invalid, onChange, template, value }: Scamax={max !== undefined ? String(max) : undefined}min={min !== undefined ? String(min) : undefined}size="xs"- step={multipleOf !== undefined ? String(multipleOf) : isInteger ? '1' : 'any'}+ fontVariantNumeric="tabular-nums"+ step={multipleOf !== undefined ? String(multipleOf) : step !== undefined ? String(step) : isInteger ? '1' : 'any'}type="number"value={text}w="full"@@ -293,7 +327,7 @@ const NumericInput = ({ ariaLabel, id, invalid, onChange, template, value }: ScaonBlur={onBlur}onChange={onInputChange}onDoubleClick={selectInputText}- onWheel={blurOnWheel}+ onWheel={onWheel}/>);};@@ -1427,7 +1461,7 @@ const LoRACollectionInput = ({ id, invalid, onChange, template, value }: Workflo[commit, entries]);const onWeightChange = useCallback(- (index: number, weight: number) =>+ (index: number, weight: number | null) =>commit(entries.map((entry, entryIndex) =>entryIndex === index && isLoraFieldCollectionEntry(entry) ? { ...entry, weight } : entry@@ -1470,6 +1504,31 @@ const LoRACollectionInput = ({ id, invalid, onChange, template, value }: Workflo);};+/** The weight column edits a bounded float; the range is the same one the Generate LoRA controls use. */+const LORA_WEIGHT_TEMPLATE: FieldInputTemplate = {+ default: undefined,+ description: '',+ exclusiveMaximum: null,+ exclusiveMinimum: null,+ fieldKind: 'input',+ input: 'direct',+ maximum: LORA_FIELD_WEIGHT_RANGE.max,+ minimum: LORA_FIELD_WEIGHT_RANGE.min,+ multipleOf: null,+ name: 'weight',+ options: null,+ required: true,+ title: 'Weight',+ type: { batch: false, cardinality: 'SINGLE', name: 'FloatField' },+ uiChoiceLabels: null,+ uiComponent: null,+ uiHidden: false,+ uiModelBase: null,+ uiModelFormat: null,+ uiModelType: null,+ uiOrder: null,+};+const LoRACollectionRow = ({entry,id,@@ -1481,28 +1540,16 @@ const LoRACollectionRow = ({id?: string;index: number;onRemove: (index: number) => void;- onWeightChange: (index: number, weight: number) => void;+ onWeightChange: (index: number, weight: number | null) => void;}) => {const label = entry ? entry.lora.name : 'Unreadable entry';- // Keep raw weight drafts through typing so trailing decimals survive numeric commits; blur returns to the- // clamped committed value.- const [draft, setDraft] = useState<string | null>(null);const onRemoveClick = useCallback(() => onRemove(index), [index, onRemove]);+ // The shared numeric control commits as typed; a cleared or out-of-range weight stays on screen and blocks+ // invoking through the field's own reason instead of being clamped.const onValueChange = useCallback(- ({ value: valueAsText, valueAsNumber }: NumberInput.ValueChangeDetails) => {- setDraft(valueAsText);-- if (Number.isFinite(valueAsNumber)) {- onWeightChange(index, valueAsNumber);- }- },+ (weight: unknown) => onWeightChange(index, typeof weight === 'number' ? weight : null),[index, onWeightChange]);- const onFocusChange = useCallback(({ focused }: NumberInput.FocusChangeDetails) => {- if (!focused) {- setDraft(null);- }- }, []);return (<HStack gap="1" minW="0" w="full">@@ -1510,28 +1557,17 @@ const LoRACollectionRow = ({<MiddleTruncate color={entry ? undefined : 'fg.error'} flex="1" fontSize="2xs" minW="0" text={label} /></Tooltip>{entry ? (- <NumberInput.Root- className="nodrag"- // Stated rather than left to the default: `min`/`max` are otherwise advisory here, and a- // mistyped 999 would run — the backend takes an unbounded float and nothing downstream- // rejects it.- clampValueOnBlur- flexShrink="0"- max={DEFAULT_LORA_WEIGHT_CONFIG.numberInputMax}- min={DEFAULT_LORA_WEIGHT_CONFIG.numberInputMin}- size="xs"- step={DEFAULT_LORA_WEIGHT_CONFIG.coarseStep}- value={draft ?? String(entry.weight)}- w="16"- onFocusChange={onFocusChange}- onValueChange={onValueChange}- >- <NumberInput.Input- aria-label={`${label} weight`}- fontVariantNumeric="tabular-nums"- id={id ? `${id}-lora-${index}-weight` : undefined}+ <Box flexShrink="0" w="16">+ <NumericInput+ ariaLabel={`${label} weight`}+ id={id ? `${id}-lora-${index}` : undefined}+ invalid={!isLoraFieldWeightValid(entry.weight)}+ step={DEFAULT_LORA_WEIGHT_CONFIG.coarseStep}+ template={LORA_WEIGHT_TEMPLATE}+ value={entry.weight ?? undefined}+ onChange={onValueChange}/>- </NumberInput.Root>+ </Box>) : null}<IconButtonaria-label={`Remove ${label}`}diff --git a/invokeai/frontend/webv2/vitest.browser.config.mts b/invokeai/frontend/webv2/vitest.browser.config.mtsindex b0110e5b1b..b53bc413a2 100644--- a/invokeai/frontend/webv2/vitest.browser.config.mts+++ b/invokeai/frontend/webv2/vitest.browser.config.mts@@ -1,9 +1,35 @@+import type { BrowserCommand } from 'vitest/node';+import { playwright } from '@vitest/browser-playwright';import { mergeConfig } from 'vite';import { defineConfig } from 'vitest/config';import viteConfig from './vite.config.mts';+/** Drives Chromium's own IME over CDP: `compose` replaces the in-progress text, `commit` inserts the final text. */+const imeCompose: BrowserCommand<[steps: readonly { kind: 'commit' | 'compose'; text: string }[]]> = async (+ { context, page },+ steps+) => {+ const session = await context.newCDPSession(page);++ try {+ for (const step of steps) {+ if (step.kind === 'compose') {+ await session.send('Input.imeSetComposition', {+ selectionEnd: step.text.length,+ selectionStart: step.text.length,+ text: step.text,+ });+ } else {+ await session.send('Input.insertText', { text: step.text });+ }+ }+ } finally {+ await session.detach();+ }+};+export default mergeConfig(viteConfig,defineConfig({@@ -26,6 +52,7 @@ export default mergeConfig(},test: {browser: {+ commands: { imeCompose },enabled: true,headless: true,instances: [{ browser: 'chromium' }],