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(canvas): arm the eyedropper from the tool under a held key
Josh Corbetta11beee8bca8
diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/engine.test.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/engine.test.tsindex a13b83a1d4..92448b3a0b 100644--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/engine.test.ts+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/engine.test.ts@@ -18397,6 +18397,29 @@ describe('Select Object canvas engine integration', () => {h.engine.lifecycle.dispose();});+ it('arms the eyedropper over a Space hold and returns to the tool the user was really on', async () => {+ const h = await createSamHarness();+ h.overlay.fire('pointerenter', {});+ const initial = h.engine.stores.activeTool.get();+ h.fireKey('keydown', 'Space', ' ');+ expect(h.engine.stores.activeTool.get()).toBe('view');++ let settled: string | null | undefined;+ void h.engine.tools.requestColorSample().then((hex) => {+ settled = hex;+ });+ h.fireKey('keyup', 'Space', ' ');+ expect(h.engine.stores.activeTool.get()).toBe('colorPicker');+ await flushMicrotasks();+ expect(settled).toBeUndefined();++ h.engine.tools.handleEscapePriority({ gestureWasActive: false });+ await flushMicrotasks();+ expect(settled).toBeNull();+ expect(h.engine.stores.activeTool.get()).toBe(initial);+ h.engine.lifecycle.dispose();+ });+it('does not restore sessionless sam when Escape closes the session during a Space hold', async () => {const h = await createSamHarness();getCanvasOperations(h.engine).startSelectObject('source');diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/engine.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/engine.tsindex 9021f62134..58c1edbb12 100644--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/engine.ts+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/engine.ts@@ -1747,6 +1747,8 @@ export const createCanvasEngine = (opts: CanvasEngineOptions): CanvasEngineCoreCconst requestColorSample = (): Promise<string | null> => {// A second request supersedes the first; the earlier caller gets a cancel.settleColorSample(null, false);+ // End any held temporary tool first, so the request records the tool the user was really on.+ pipeline.endForToolSwitch();return new Promise<string | null>((resolve) => {pendingColorSample = { previousToolId: interactionController.getActiveToolId(), resolve, sampledHex: null };diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/input/pointerPipeline.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/input/pointerPipeline.tsindex cb498d17c7..188496e2ca 100644--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/input/pointerPipeline.ts+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/input/pointerPipeline.ts@@ -174,7 +174,8 @@ export const createPointerPipeline = (deps: PointerPipelineDeps): PointerPipelin// A cancelled gesture's pointer keeps reporting pressed moves; they reach a tool only as hover until release.let cancelledPointerId: number | null = null;// The control focus last landed on by pointer; keyboard navigation (`:focus-visible` on arrival) clears it.- let pointerFocused: EventTarget | null = null;+ // Held weakly: a focused row may be removed (virtualized) without another focusin.+ let pointerFocused: WeakRef<EventTarget> | null = null;/*** Reads the input element's viewport offset. Hoisted out of@@ -228,7 +229,7 @@ export const createPointerPipeline = (deps: PointerPipelineDeps): PointerPipelin}return (event.target !== null &&- event.target === pointerFocused &&+ event.target === pointerFocused?.deref() &&!(event.target as KeyTarget)?.closest?.(OVERLAY_SELECTOR));};@@ -404,7 +405,7 @@ export const createPointerPipeline = (deps: PointerPipelineDeps): PointerPipelin},isGestureActive: () => gestureActive,onFocusIn: (event) => {- pointerFocused = arrivedByPointer(event.target) ? event.target : null;+ pointerFocused = event.target && arrivedByPointer(event.target) ? new WeakRef(event.target) : null;},onKeyUp: (event) => {if (event.code === 'Space' && tempHold === 'space') {