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
feat(canvas): seed object tools from the color pair and add a Mask Tint target
Josh Corbett24427768d604
diff --git a/invokeai/frontend/webv2/performance/browser-baseline.json b/invokeai/frontend/webv2/performance/browser-baseline.jsonindex ca9f1adbba..e3f6ff3c17 100644--- a/invokeai/frontend/webv2/performance/browser-baseline.json+++ b/invokeai/frontend/webv2/performance/browser-baseline.json@@ -25,13 +25,13 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 113.5,+ "domContentLoadedMedianMs": 121.80000000074506,"id": "launchpad","layoutAckMedianMs": 0,"layoutReturnSwitchMedianMs": 0,"layoutSwitchMedianMs": 0,- "loadMedianMs": 113.60000000149012,- "longestTaskMaxMs": 68,+ "loadMedianMs": 122,+ "longestTaskMaxMs": 71,"owner": "app","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:launchpad",@@ -41,24 +41,24 @@"fontRawBytes": 23664,"imageRawBytes": 0,"largestAssetRawBytes": 746376,- "otherRawBytes": 157968,+ "otherRawBytes": 158124,"requestCount": 38,"scriptRawBytes": 1630506,"scriptRequestCount": 34,- "totalRawBytes": 1814297+ "totalRawBytes": 1814453},"resourceLimits": {"cssRawBytes": 2181,"fontRawBytes": 23901,"imageRawBytes": 0,"largestAssetRawBytes": 753840,- "otherRawBytes": 159548,+ "otherRawBytes": 159706,"requestCount": 38,"scriptRawBytes": 1646812,"scriptRequestCount": 34,- "totalRawBytes": 1832440+ "totalRawBytes": 1832598},- "routeReadyMedianMs": 248.10000000149012,+ "routeReadyMedianMs": 270.5999999977648,"scriptSourceOwnerSet": "launchpad-static","stateProfile": "empty"},@@ -85,13 +85,13 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 112.90000000037253,+ "domContentLoadedMedianMs": 120.5,"id": "launchpad","layoutAckMedianMs": 0,"layoutReturnSwitchMedianMs": 0,"layoutSwitchMedianMs": 0,- "loadMedianMs": 113,- "longestTaskMaxMs": 66,+ "loadMedianMs": 120.60000000149012,+ "longestTaskMaxMs": 73,"owner": "app","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:launchpad",@@ -101,24 +101,24 @@"fontRawBytes": 23664,"imageRawBytes": 0,"largestAssetRawBytes": 746376,- "otherRawBytes": 157968,+ "otherRawBytes": 158124,"requestCount": 38,"scriptRawBytes": 1630506,"scriptRequestCount": 34,- "totalRawBytes": 1814297+ "totalRawBytes": 1814453},"resourceLimits": {"cssRawBytes": 2181,"fontRawBytes": 23901,"imageRawBytes": 0,"largestAssetRawBytes": 753840,- "otherRawBytes": 159548,+ "otherRawBytes": 159706,"requestCount": 38,"scriptRawBytes": 1646812,"scriptRequestCount": 34,- "totalRawBytes": 1832440+ "totalRawBytes": 1832598},- "routeReadyMedianMs": 267.40000000037253,+ "routeReadyMedianMs": 288.80000000074506,"scriptSourceOwnerSet": "launchpad-static","stateProfile": "representative"},@@ -145,15 +145,15 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 111.30000000074506,+ "domContentLoadedMedianMs": 120.39999999850988,"id": "editor-minimal","layoutAckMedianMs": 0,"layoutReturnSwitchMedianMs": 0,"layoutSwitchMedianMs": 0,- "loadMedianMs": 111.40000000037253,- "longestTaskMaxMs": 94,+ "loadMedianMs": 120.5,+ "longestTaskMaxMs": 103,"owner": "workbench",- "projectSwitchMedianMs": 31.09999999962747,+ "projectSwitchMedianMs": 40.30000000074506,"readyMark": "invokeai:ready:widget:center:preview","remediationTicket": "deepen-widget-registry-loading","resourceBaseline": {@@ -161,24 +161,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746376,- "otherRawBytes": 157968,+ "otherRawBytes": 158124,"requestCount": 115,- "scriptRawBytes": 3261694,+ "scriptRawBytes": 3262124,"scriptRequestCount": 110,- "totalRawBytes": 3601861+ "totalRawBytes": 3602447},"resourceLimits": {"cssRawBytes": 2181,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 753840,- "otherRawBytes": 159548,+ "otherRawBytes": 159706,"requestCount": 115,- "scriptRawBytes": 3294311,+ "scriptRawBytes": 3294746,"scriptRequestCount": 110,- "totalRawBytes": 3637880+ "totalRawBytes": 3638472},- "routeReadyMedianMs": 646.5,+ "routeReadyMedianMs": 679.1999999992549,"scriptSourceOwnerSet": "editor-minimal-static","stateProfile": "empty"},@@ -205,15 +205,15 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 113.70000000111759,+ "domContentLoadedMedianMs": 120.59999999776483,"id": "editor-minimal","layoutAckMedianMs": 0,"layoutReturnSwitchMedianMs": 0,"layoutSwitchMedianMs": 0,- "loadMedianMs": 113.80000000074506,- "longestTaskMaxMs": 180,+ "loadMedianMs": 120.69999999925494,+ "longestTaskMaxMs": 190,"owner": "workbench",- "projectSwitchMedianMs": 68,+ "projectSwitchMedianMs": 77.19999999925494,"readyMark": "invokeai:ready:widget:center:preview","remediationTicket": "deepen-widget-registry-loading","resourceBaseline": {@@ -221,24 +221,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746376,- "otherRawBytes": 157968,+ "otherRawBytes": 158124,"requestCount": 115,- "scriptRawBytes": 3261694,+ "scriptRawBytes": 3262124,"scriptRequestCount": 110,- "totalRawBytes": 3601861+ "totalRawBytes": 3602447},"resourceLimits": {"cssRawBytes": 2181,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 753840,- "otherRawBytes": 159548,+ "otherRawBytes": 159706,"requestCount": 115,- "scriptRawBytes": 3294311,+ "scriptRawBytes": 3294746,"scriptRequestCount": 110,- "totalRawBytes": 3637880+ "totalRawBytes": 3638472},- "routeReadyMedianMs": 424.7000000011176,+ "routeReadyMedianMs": 465.6000000014901,"scriptSourceOwnerSet": "editor-minimal-static","stateProfile": "representative"},@@ -247,31 +247,31 @@"cssRawBytes": 0,"fontRawBytes": 0,"imageRawBytes": 0,- "largestAssetRawBytes": 251489,+ "largestAssetRawBytes": 257353,"otherRawBytes": 0,"requestCount": 7,- "scriptRawBytes": 407671,+ "scriptRawBytes": 414001,"scriptRequestCount": 7,- "totalRawBytes": 407671+ "totalRawBytes": 414001},"activatedResourceLimits": {"cssRawBytes": 0,"fontRawBytes": 0,"imageRawBytes": 0,- "largestAssetRawBytes": 254004,+ "largestAssetRawBytes": 259927,"otherRawBytes": 0,"requestCount": 7,- "scriptRawBytes": 411748,+ "scriptRawBytes": 418142,"scriptRequestCount": 7,- "totalRawBytes": 411748+ "totalRawBytes": 418142},- "domContentLoadedMedianMs": 112.5,+ "domContentLoadedMedianMs": 118.60000000149012,"id": "editor-canvas",- "layoutAckMedianMs": 2.099999999627471,- "layoutReturnSwitchMedianMs": 50.90000000037253,- "layoutSwitchMedianMs": 88.59999999962747,- "loadMedianMs": 112.59999999962747,- "longestTaskMaxMs": 115,+ "layoutAckMedianMs": 2.300000000745058,+ "layoutReturnSwitchMedianMs": 58.600000001490116,+ "layoutSwitchMedianMs": 96.5,+ "loadMedianMs": 118.70000000298023,+ "longestTaskMaxMs": 130,"owner": "canvas","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:canvas",@@ -281,24 +281,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746376,- "otherRawBytes": 157968,+ "otherRawBytes": 158124,"requestCount": 122,- "scriptRawBytes": 3669365,+ "scriptRawBytes": 3676125,"scriptRequestCount": 117,- "totalRawBytes": 4009532+ "totalRawBytes": 4016448},"resourceLimits": {"cssRawBytes": 2181,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 753840,- "otherRawBytes": 159548,+ "otherRawBytes": 159706,"requestCount": 122,- "scriptRawBytes": 3706059,+ "scriptRawBytes": 3712887,"scriptRequestCount": 117,- "totalRawBytes": 4049628+ "totalRawBytes": 4056613},- "routeReadyMedianMs": 1018,+ "routeReadyMedianMs": 1067,"scriptSourceOwnerSet": "editor-canvas-static","stateProfile": "empty"},@@ -307,31 +307,31 @@"cssRawBytes": 0,"fontRawBytes": 0,"imageRawBytes": 0,- "largestAssetRawBytes": 251489,+ "largestAssetRawBytes": 257353,"otherRawBytes": 0,"requestCount": 7,- "scriptRawBytes": 407671,+ "scriptRawBytes": 414001,"scriptRequestCount": 7,- "totalRawBytes": 407671+ "totalRawBytes": 414001},"activatedResourceLimits": {"cssRawBytes": 0,"fontRawBytes": 0,"imageRawBytes": 0,- "largestAssetRawBytes": 254004,+ "largestAssetRawBytes": 259927,"otherRawBytes": 0,"requestCount": 7,- "scriptRawBytes": 411748,+ "scriptRawBytes": 418142,"scriptRequestCount": 7,- "totalRawBytes": 411748+ "totalRawBytes": 418142},- "domContentLoadedMedianMs": 111.09999999962747,+ "domContentLoadedMedianMs": 120.30000000074506,"id": "editor-canvas",- "layoutAckMedianMs": 2.5,- "layoutReturnSwitchMedianMs": 40.59999999962747,- "layoutSwitchMedianMs": 84.70000000111759,- "loadMedianMs": 111.09999999962747,- "longestTaskMaxMs": 182,+ "layoutAckMedianMs": 2.699999999254942,+ "layoutReturnSwitchMedianMs": 49.30000000074506,+ "layoutSwitchMedianMs": 84.80000000074506,+ "loadMedianMs": 120.5,+ "longestTaskMaxMs": 200,"owner": "canvas","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:canvas",@@ -341,24 +341,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746376,- "otherRawBytes": 157968,+ "otherRawBytes": 158124,"requestCount": 122,- "scriptRawBytes": 3669365,+ "scriptRawBytes": 3676125,"scriptRequestCount": 117,- "totalRawBytes": 4009532+ "totalRawBytes": 4016448},"resourceLimits": {"cssRawBytes": 2181,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 753840,- "otherRawBytes": 159548,+ "otherRawBytes": 159706,"requestCount": 122,- "scriptRawBytes": 3706059,+ "scriptRawBytes": 3712887,"scriptRequestCount": 117,- "totalRawBytes": 4049628+ "totalRawBytes": 4056613},- "routeReadyMedianMs": 1090.2999999988824,+ "routeReadyMedianMs": 1168.5,"scriptSourceOwnerSet": "editor-canvas-static","stateProfile": "representative"},@@ -385,13 +385,13 @@"scriptRequestCount": 6,"totalRawBytes": 383457},- "domContentLoadedMedianMs": 112.09999999962747,+ "domContentLoadedMedianMs": 118.59999999776483,"id": "editor-workflow","layoutAckMedianMs": 2.300000000745058,- "layoutReturnSwitchMedianMs": 30.90000000037253,- "layoutSwitchMedianMs": 86.09999999962747,- "loadMedianMs": 112.19999999925494,- "longestTaskMaxMs": 89,+ "layoutReturnSwitchMedianMs": 34.599999997764826,+ "layoutSwitchMedianMs": 93.39999999850988,+ "loadMedianMs": 118.69999999925494,+ "longestTaskMaxMs": 102,"owner": "workflow","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:workflow",@@ -401,24 +401,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746376,- "otherRawBytes": 157968,+ "otherRawBytes": 158124,"requestCount": 122,- "scriptRawBytes": 3625941,+ "scriptRawBytes": 3626371,"scriptRequestCount": 116,- "totalRawBytes": 3981521+ "totalRawBytes": 3982107},"resourceLimits": {"cssRawBytes": 17748,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 753840,- "otherRawBytes": 159548,+ "otherRawBytes": 159706,"requestCount": 122,- "scriptRawBytes": 3662201,+ "scriptRawBytes": 3662635,"scriptRequestCount": 116,- "totalRawBytes": 4021337+ "totalRawBytes": 4021929},- "routeReadyMedianMs": 1009.0999999996275,+ "routeReadyMedianMs": 1060.800000000745,"scriptSourceOwnerSet": "editor-workflow-static","stateProfile": "empty"},@@ -445,13 +445,13 @@"scriptRequestCount": 6,"totalRawBytes": 383457},- "domContentLoadedMedianMs": 114.59999999962747,+ "domContentLoadedMedianMs": 122.40000000223517,"id": "editor-workflow",- "layoutAckMedianMs": 2.5,- "layoutReturnSwitchMedianMs": 38.59999999962747,- "layoutSwitchMedianMs": 122.80000000074506,- "loadMedianMs": 114.69999999925494,- "longestTaskMaxMs": 345,+ "layoutAckMedianMs": 3.100000001490116,+ "layoutReturnSwitchMedianMs": 42.399999998509884,+ "layoutSwitchMedianMs": 129.5,+ "loadMedianMs": 122.60000000149012,+ "longestTaskMaxMs": 365,"owner": "workflow","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:workflow",@@ -461,24 +461,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746376,- "otherRawBytes": 157968,+ "otherRawBytes": 158124,"requestCount": 122,- "scriptRawBytes": 3625941,+ "scriptRawBytes": 3626371,"scriptRequestCount": 116,- "totalRawBytes": 3981521+ "totalRawBytes": 3982107},"resourceLimits": {"cssRawBytes": 17748,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 753840,- "otherRawBytes": 159548,+ "otherRawBytes": 159706,"requestCount": 122,- "scriptRawBytes": 3662201,+ "scriptRawBytes": 3662635,"scriptRequestCount": 116,- "totalRawBytes": 4021337+ "totalRawBytes": 4021929},- "routeReadyMedianMs": 1133.7000000011176,+ "routeReadyMedianMs": 1210.3999999985099,"scriptSourceOwnerSet": "editor-workflow-static","stateProfile": "representative"},@@ -505,13 +505,13 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 109.80000000074506,+ "domContentLoadedMedianMs": 119,"id": "editor-gallery","layoutAckMedianMs": 0,"layoutReturnSwitchMedianMs": 0,- "layoutSwitchMedianMs": 25.90000000037253,- "loadMedianMs": 109.90000000037253,- "longestTaskMaxMs": 93,+ "layoutSwitchMedianMs": 27,+ "loadMedianMs": 119.19999999925494,+ "longestTaskMaxMs": 101,"owner": "gallery","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:gallery",@@ -521,24 +521,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746376,- "otherRawBytes": 157968,+ "otherRawBytes": 158124,"requestCount": 115,- "scriptRawBytes": 3261694,+ "scriptRawBytes": 3262124,"scriptRequestCount": 110,- "totalRawBytes": 3601861+ "totalRawBytes": 3602447},"resourceLimits": {"cssRawBytes": 2181,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 753840,- "otherRawBytes": 159548,+ "otherRawBytes": 159706,"requestCount": 115,- "scriptRawBytes": 3294311,+ "scriptRawBytes": 3294746,"scriptRequestCount": 110,- "totalRawBytes": 3637880+ "totalRawBytes": 3638472},- "routeReadyMedianMs": 1240.300000000745,+ "routeReadyMedianMs": 1284.1000000014901,"scriptSourceOwnerSet": "editor-minimal-static","stateProfile": "empty"},@@ -565,13 +565,13 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 113.40000000037253,+ "domContentLoadedMedianMs": 127.39999999850988,"id": "editor-gallery","layoutAckMedianMs": 0,"layoutReturnSwitchMedianMs": 0,- "layoutSwitchMedianMs": 84,- "loadMedianMs": 113.5,- "longestTaskMaxMs": 172,+ "layoutSwitchMedianMs": 101.40000000223517,+ "loadMedianMs": 127.5,+ "longestTaskMaxMs": 211,"owner": "gallery","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:gallery",@@ -581,24 +581,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746376,- "otherRawBytes": 157968,+ "otherRawBytes": 158124,"requestCount": 115,- "scriptRawBytes": 3261694,+ "scriptRawBytes": 3262124,"scriptRequestCount": 110,- "totalRawBytes": 3601861+ "totalRawBytes": 3602447},"resourceLimits": {"cssRawBytes": 2181,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 753840,- "otherRawBytes": 159548,+ "otherRawBytes": 159706,"requestCount": 115,- "scriptRawBytes": 3294311,+ "scriptRawBytes": 3294746,"scriptRequestCount": 110,- "totalRawBytes": 3637880+ "totalRawBytes": 3638472},- "routeReadyMedianMs": 1413.300000000745,+ "routeReadyMedianMs": 1555.699999999255,"scriptSourceOwnerSet": "editor-minimal-static","stateProfile": "representative"}@@ -2803,7 +2803,9 @@"source:src/workbench/widgets/canvas/checkerColors.ts","source:src/workbench/widgets/canvas/color-system/CanvasColorFeed.tsx","source:src/workbench/widgets/canvas/color-system/colorPair.ts",+ "source:src/workbench/widgets/canvas/color-system/maskTintTarget.ts","source:src/workbench/widgets/canvas/color-system/useActiveColors.ts",+ "source:src/workbench/widgets/canvas/color-system/useMaskTintEditor.ts","source:src/workbench/widgets/canvas/engineStoreHooks.ts","source:src/workbench/widgets/canvas/executeCanvasImageDropImport.ts","source:src/workbench/widgets/canvas/fitBbox.ts",diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.jsonindex b66f13f77c..814b999f3f 100644--- a/invokeai/frontend/webv2/public/locales/en.json+++ b/invokeai/frontend/webv2/public/locales/en.json@@ -2421,7 +2421,8 @@"textLineHeight": "Line height","textSize": "Font size","textStyle": "Style",- "textWeight": "Weight"+ "textWeight": "Weight",+ "gradientPairPreset": "Foreground to background preset"},"tools": {"bbox": "Generation frame",@@ -2902,7 +2903,8 @@"horizontal": "Horizontal","solid": "Solid","vertical": "Vertical"- }+ },+ "editInColorPane": "Edit tint in the Color pane"},"menuGroups": {"layers": "Layers",@@ -3009,7 +3011,8 @@"removeSwatchHint": "{{color}} — right-click or press Delete to remove","resize": "Resize color pane","swatches": "Swatches",- "tabs": "Color panes"+ "tabs": "Color panes",+ "maskTint": "Mask tint"},"historyPane": {"count_one": "{{count}} step",diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/capabilities.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/capabilities.tsindex ca69d04baa..f0fd133e17 100644--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/capabilities.ts+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/capabilities.ts@@ -18,6 +18,8 @@ import type { LayerStackKind } from './document/layerStacks';import type { CanvasTransactionOutcome, SubsetOf } from './editConcurrency';import type { CanvasEditGate } from './editGate';import type {+ TextStylePatch,+ ActiveColorPairState,BboxToolOptions,BrushOptions,CheckerColors,@@ -97,6 +99,8 @@ export interface CanvasInteractionState {checkerboard: boolean;checkerColors: CheckerColors;clipToBbox: boolean;+ /** The mirrored workbench pair; the engine reads it at gesture start, never writes it. */+ colorPair: ActiveColorPairState;documentEditingLocked: boolean;eraserOptions: EraserOptions;gradientOptions: GradientToolOptions;@@ -525,7 +529,7 @@ export interface CanvasEngineLayerCapability extends CanvasLayerCapability {openTextEdit(layerId: string): void;rasterizeLayer(layerId: string): boolean;setTextEditContentReader(reader: (() => string) | null): void;- updateTextEditStyle(patch: Partial<TextToolOptions>): void;+ updateTextEditStyle(patch: TextStylePatch): void;updateTransformSession(transform: LayerTransform): void;}diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/controllers/editingController.test.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/controllers/editingController.test.tsindex f815f3e84f..472ec700da 100644--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/controllers/editingController.test.ts+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/controllers/editingController.test.ts@@ -27,6 +27,7 @@ const createTextOptions = () => ({createLayerId: () => 'text-1',getDocument: () => null,invalidate: vi.fn(),+ colors: { get: () => ({ background: '#ffffff', foreground: '#000000' }) },isGestureActive: () => false,options: { get: () => ({}) as never },session: { get: () => null, set: vi.fn() },diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/controllers/textEditingController.test.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/controllers/textEditingController.test.tsindex 0fc968fa7c..3b01845553 100644--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/controllers/textEditingController.test.ts+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/controllers/textEditingController.test.ts@@ -19,6 +19,7 @@ const createHarness = (document: CanvasDocumentContractV3) => {const controller = new TextEditingController({canEdit: () => true,captureInsertionAnchor: createTestInsertionAnchorCapture('p', () => document?.stacks ?? EMPTY_STACKS),+ colors: { get: () => ({ background: '#ffffff', foreground: '#123456' }) },commitStructural,createLayerId: () => 'text-new',getDocument: () => document,@@ -48,6 +49,9 @@ describe('TextEditingController', () => {expect(h.getSession()).toBeNull();expect(h.commitStructural).toHaveBeenCalledOnce();expect(h.commitStructural.mock.calls[0]?.[0]).toBe('Add text');+ // The session's color is the active foreground at open, not a tool option.+ const forward = h.commitStructural.mock.calls[0]?.[1] as { layer?: { source?: { color?: string } } };+ expect(forward.layer?.source?.color).toBe('#123456');});it('uses the registered content reader and cancels empty creates', () => {diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/controllers/textEditingController.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/controllers/textEditingController.tsindex 44fb7e00f1..32ecf803e4 100644--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/controllers/textEditingController.ts+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/controllers/textEditingController.ts@@ -2,7 +2,13 @@ import type { StructuralCommitResult } from '@workbench/canvas-engine/capabilitiimport type { CanvasDocumentContractV3, CanvasLayerContract } from '@workbench/canvas-engine/contracts';import type { CanvasNodeInsertionAnchor } from '@workbench/canvas-engine/document/insertionAnchors';import type { LayerStackKind } from '@workbench/canvas-engine/document/layerStacks';-import type { TextEditSession, TextSource, TextToolOptions } from '@workbench/canvas-engine/engineStores';+import type {+ ActiveColorPairState,+ TextEditSession,+ TextSource,+ TextStylePatch,+ TextToolOptions,+} from '@workbench/canvas-engine/engineStores';import type { CanvasProjectMutation } from '@workbench/canvas-engine/mutationContracts';import type { Vec2 } from '@workbench/canvas-engine/types';@@ -16,6 +22,8 @@ export interface TextEditingControllerOptions {set(value: TextEditSession | null): void;};readonly options: { get(): TextToolOptions };+ /** The active pair; a new session's color is the foreground at open. */+ readonly colors: { get(): ActiveColorPairState };readonly getDocument: () => CanvasDocumentContractV3 | null;readonly canEdit: () => boolean;readonly isGestureActive: () => boolean;@@ -50,7 +58,7 @@ export class TextEditingController {const options = this.deps.options.get();return {align: options.align,- color: options.color,+ color: this.deps.colors.get().foreground,content,fontFamily: options.fontFamily,fontSize: options.fontSize,@@ -100,7 +108,7 @@ export class TextEditingController {this.deps.invalidate({ layers: [layerId] });}- updateStyle(patch: Partial<TextToolOptions>): void {+ updateStyle(patch: TextStylePatch): void {const session = this.deps.session.get();if (this.disposed || !session) {return;diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/engine.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/engine.tsindex a80029d01b..5361fc3cc4 100644--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/engine.ts+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/engine.ts@@ -119,7 +119,7 @@ import {createEngineStores,type EngineStores,type ScalarStore,- type TextToolOptions,+ type TextStylePatch,} from '@workbench/canvas-engine/engineStores';import {exportRasterComposite as exportRasterCompositeWithDeps,@@ -378,6 +378,7 @@ export const createCanvasEngine = (opts: CanvasEngineOptions): CanvasEngineCoreCcheckerboard: stores.checkerboard,checkerColors: stores.checkerColors,clipToBbox: stores.clipToBbox,+ colorPair: stores.colorPair,documentEditingLocked: stores.documentEditingLocked,eraserOptions: stores.eraserOptions,gradientOptions: stores.gradientOptions,@@ -944,6 +945,7 @@ export const createCanvasEngine = (opts: CanvasEngineOptions): CanvasEngineCoreCgetDocument: () => mirror.getDocument(),invalidate: (payload) => scheduler.invalidate(payload),isGestureActive: () => pipeline.isGestureActive(),+ colors: stores.colorPair,options: stores.textOptions,session: stores.textEditSession,},@@ -2430,9 +2432,9 @@ export const createCanvasEngine = (opts: CanvasEngineOptions): CanvasEngineCoreCeditingController.text.setContentReader(reader);const openTextCreate = (point: Vec2): void => editingController.text.openCreate(point);const openTextEdit = (layerId: string): void => editingController.text.openEdit(layerId);- const updateTextEditStyle = (patch: Partial<TextToolOptions>): void => editingController.text.updateStyle(patch);+ const updateTextEditStyle = (patch: TextStylePatch): void => editingController.text.updateStyle(patch);const cancelTextEdit = (): void => editingController.text.cancel();- const commitTextEdit = (content: string, styleChanges?: Partial<TextToolOptions>): StructuralCommitResult | null =>+ const commitTextEdit = (content: string, styleChanges?: TextStylePatch): StructuralCommitResult | null =>editingController.text.commit(content, styleChanges);const commitOpenTextSession = (): boolean => editingController.text.commitOpen();diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/engineStores.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/engineStores.tsindex c0287fe24f..b734a78de4 100644--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/engineStores.ts+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/engineStores.ts@@ -88,22 +88,23 @@ export interface GradientStop {}/**- * Shape tool options: the kind drawn on the next drag, and the fill/stroke- * style applied to it (and, when a shape layer is selected, edited live on it).- * `fill`/`stroke` are `null` for "none".+ * Shape tool options: the kind drawn on the next drag, plus whether the new+ * shape gets a fill and a stroke. The colors themselves come from the active+ * foreground/background pair at gesture start — there is no second global+ * shape color; a selected shape's explicit fill/stroke is document state.*/export interface ShapeToolOptions {kind: 'rect' | 'ellipse';- fill: string | null;- stroke: string | null;+ fillEnabled: boolean;+ strokeEnabled: boolean;strokeWidth: number;}-/** Sensible starting shape options: a filled black rect, no stroke. */+/** Sensible starting shape options: a filled rect, no stroke. */export const DEFAULT_SHAPE_OPTIONS: ShapeToolOptions = {- fill: '#000000',+ fillEnabled: true,kind: 'rect',- stroke: null,+ strokeEnabled: false,strokeWidth: 8,};@@ -111,27 +112,36 @@ export const DEFAULT_SHAPE_OPTIONS: ShapeToolOptions = {export const MAX_SHAPE_STROKE_WIDTH = 2000;/**- * Gradient tool options: the kind, the linear angle (degrees), and the stops.- * The minimal two-stop editor edits `stops[0]` (start) and the last stop (end);+ * Gradient tool options: the kind, the linear angle (degrees), the preset, and+ * the explicit custom stops. The `pair` preset resolves the foreground →+ * background pair at gesture start; `custom` uses `stops` verbatim. The+ * minimal two-stop editor edits `stops[0]` (start) and the last stop (end);* a full multi-stop editor is a follow-up.*/export interface GradientToolOptions {kind: 'linear' | 'radial';angle: number;+ /** `pair` = the built-in FG→BG preset, resolved when the drag starts. */+ preset: 'pair' | 'custom';stops: GradientStop[];}-/** Sensible starting gradient options: black→transparent, horizontal linear. */+/** Sensible starting gradient options: the FG→BG preset, horizontal linear. */export const DEFAULT_GRADIENT_OPTIONS: GradientToolOptions = {angle: 0,kind: 'linear',+ preset: 'pair',stops: [{ color: '#000000ff', offset: 0 },{ color: '#00000000', offset: 1 },],};-/** The text style the text tool applies to a newly created layer (and edits live). */+/**+ * The text style the text tool applies to a newly created layer (and edits+ * live). A new session's color comes from the active foreground at open; the+ * session's and a selected layer's color are document/session state.+ */export interface TextToolOptions {fontFamily: string;fontSize: number;@@ -140,7 +150,6 @@ export interface TextToolOptions {/** Unitless line-height multiplier over `fontSize`. */lineHeight: number;align: 'left' | 'center' | 'right';- color: string;}/**@@ -162,10 +171,12 @@ export const TEXT_FONT_WEIGHTS: readonly number[] = [400, 500, 600, 700];export const MIN_TEXT_FONT_SIZE = 1;export const MAX_TEXT_FONT_SIZE = 2000;-/** Sensible starting text options: black left-aligned Inter at 48px. */+/** What a live text session (or a selected text layer) can restyle: the options plus its explicit color. */+export type TextStylePatch = Partial<TextToolOptions> & { color?: string };++/** Sensible starting text options: left-aligned Inter at 48px. */export const DEFAULT_TEXT_OPTIONS: TextToolOptions = {align: 'left',- color: '#000000',fontFamily: TEXT_FONT_FAMILIES[0]!.value,fontSize: 48,fontWeight: 400,@@ -193,6 +204,15 @@ export const DEFAULT_BBOX_OPTIONS: BboxToolOptions = {export const MIN_BRUSH_SIZE = 0.1;export const MAX_BRUSH_SIZE = 2000;+/** The mirrored foreground/background pair the object tools read at gesture start. */+export interface ActiveColorPairState {+ foreground: string;+ background: string;+}++/** Matches the workbench pair's default: black on white. */+export const DEFAULT_COLOR_PAIR_STATE: ActiveColorPairState = { background: '#ffffff', foreground: '#000000' };+/** Sensible starting brush options. */export const DEFAULT_BRUSH_OPTIONS: BrushOptions = {color: '#000000',@@ -410,6 +430,12 @@ export interface EngineStores {rasterContentEpoch: ScalarStore<number>;/** Brush tool options (size / color / opacity / pressure). */brushOptions: ScalarStore<BrushOptions>;+ /**+ * The workbench's foreground/background pair, mirrored in for gesture-start+ * reads (new shapes, text sessions, the gradient pair preset). One-way: the+ * engine never writes it.+ */+ colorPair: ScalarStore<ActiveColorPairState>;/** Eraser tool options (size / opacity). */eraserOptions: ScalarStore<EraserOptions>;/** Whether the engine-owned canvas history has an entry to undo. */@@ -424,11 +450,11 @@ export interface EngineStores {lassoOptions: ScalarStore<LassoToolOptions>;/** Marquee tool options (shape kind / the committed boolean op mode). */marqueeOptions: ScalarStore<MarqueeToolOptions>;- /** Shape tool options (kind / fill / stroke / stroke width). */+ /** Shape tool options (kind / fill and stroke enablement / stroke width). */shapeOptions: ScalarStore<ShapeToolOptions>;- /** Gradient tool options (kind / angle / stops). */+ /** Gradient tool options (kind / angle / preset / stops). */gradientOptions: ScalarStore<GradientToolOptions>;- /** Text tool options (font family / size / weight / line-height / align / color). */+ /** Text tool options (font family / size / weight / line-height / align). */textOptions: ScalarStore<TextToolOptions>;/*** The active text-editing session, or `null`. React reads it to render the@@ -579,13 +605,19 @@ const marqueeOptionsEqual = (a: MarqueeToolOptions, b: MarqueeToolOptions): boola.kind === b.kind && a.mode === b.mode;const shapeOptionsEqual = (a: ShapeToolOptions, b: ShapeToolOptions): boolean =>- a.kind === b.kind && a.fill === b.fill && a.stroke === b.stroke && a.strokeWidth === b.strokeWidth;+ a.kind === b.kind &&+ a.fillEnabled === b.fillEnabled &&+ a.strokeEnabled === b.strokeEnabled &&+ a.strokeWidth === b.strokeWidth;++const colorPairEqual = (a: ActiveColorPairState, b: ActiveColorPairState): boolean =>+ a.foreground === b.foreground && a.background === b.background;const stopsEqual = (a: readonly GradientStop[], b: readonly GradientStop[]): boolean =>a.length === b.length && a.every((stop, i) => stop.offset === b[i]?.offset && stop.color === b[i]?.color);const gradientOptionsEqual = (a: GradientToolOptions, b: GradientToolOptions): boolean =>- a.kind === b.kind && a.angle === b.angle && stopsEqual(a.stops, b.stops);+ a.kind === b.kind && a.angle === b.angle && a.preset === b.preset && stopsEqual(a.stops, b.stops);/** Shared by the shape and marquee previews — both are a rect plus a shape kind. */const rectShapePreviewEqual = (@@ -637,8 +669,7 @@ const textOptionsEqual = (a: TextToolOptions, b: TextToolOptions): boolean =>a.fontSize === b.fontSize &&a.fontWeight === b.fontWeight &&a.lineHeight === b.lineHeight &&- a.align === b.align &&- a.color === b.color;+ a.align === b.align;const textSourceEqual = (a: TextSource, b: TextSource): boolean =>a.content === b.content &&@@ -670,6 +701,7 @@ export const createEngineStores = (initialTool: ToolId = 'view'): EngineStores =bboxPreview: createScalarStore<Rect | null>(null, bboxPreviewEqual),bboxOverlay: createScalarStore<boolean>(false),brushOptions: createScalarStore<BrushOptions>({ ...DEFAULT_BRUSH_OPTIONS }, brushOptionsEqual),+ colorPair: createScalarStore<ActiveColorPairState>({ ...DEFAULT_COLOR_PAIR_STATE }, colorPairEqual),canRedo: createScalarStore<boolean>(false),canUndo: createScalarStore<boolean>(false),historyEpoch: createScalarStore<number>(0),diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/gradientTool.test.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/gradientTool.test.tsindex e705bbb3df..61a849d243 100644--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/gradientTool.test.ts+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/gradientTool.test.ts@@ -133,6 +133,63 @@ describe('gradient tool: create when no gradient selected', () => {expect(h.commits[0]?.inverse).toEqual({ ids: ['grad-1'], type: 'removeCanvasLayers' });expect(h.previewOf()).toBeNull();});++ it('resolves the FG→BG pair preset at gesture start', () => {+ const h = createHarness(makeDoc());+ h.stores.colorPair.set({ background: '#0000ff', foreground: '#ff0000' });+ const tool = createGradientTool();++ down(tool, h.ctx, pointer(0, 0));+ move(tool, h.ctx, pointer(100, 0));+ up(tool, h.ctx, pointer(100, 0));++ const forward = h.commits[0]?.forward;+ if (+ forward?.type === 'addCanvasLayer' &&+ forward.layer.type === 'raster' &&+ forward.layer.source.type === 'gradient'+ ) {+ expect(forward.layer.source.stops).toEqual([+ { color: '#ff0000ff', offset: 0 },+ { color: '#0000ffff', offset: 1 },+ ]);+ } else {+ throw new Error('expected a gradient layer');+ }+ });++ it('uses the explicit custom stops verbatim, independent of the pair', () => {+ const h = createHarness(makeDoc());+ h.stores.colorPair.set({ background: '#0000ff', foreground: '#ff0000' });+ h.stores.gradientOptions.set({+ angle: 0,+ kind: 'linear',+ preset: 'custom',+ stops: [+ { color: '#11223344', offset: 0 },+ { color: '#55667788', offset: 1 },+ ],+ });+ const tool = createGradientTool();++ down(tool, h.ctx, pointer(0, 0));+ move(tool, h.ctx, pointer(100, 0));+ up(tool, h.ctx, pointer(100, 0));++ const forward = h.commits[0]?.forward;+ if (+ forward?.type === 'addCanvasLayer' &&+ forward.layer.type === 'raster' &&+ forward.layer.source.type === 'gradient'+ ) {+ expect(forward.layer.source.stops).toEqual([+ { color: '#11223344', offset: 0 },+ { color: '#55667788', offset: 1 },+ ]);+ } else {+ throw new Error('expected a gradient layer');+ }+ });});describe('gradient tool: edit selected gradient layer', () => {diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/gradientTool.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/gradientTool.tsindex 8ee8b8bdd4..2c3185edc6 100644--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/gradientTool.ts+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/gradientTool.ts@@ -150,12 +150,22 @@ export const createGradientTool = (): Tool => {// positioned at the bbox origin via the layer transform. Angle-drag edits on// an existing gradient preserve its extent (the `...old` spread above).const options = ctx.stores.gradientOptions.get();+ // The built-in FG→BG preset resolves the pair now; custom stops are+ // explicit and independent of later pair edits.+ const pair = ctx.stores.colorPair.get();+ const stops =+ options.preset === 'pair'+ ? [+ { color: `${pair.foreground}ff`, offset: 0 },+ { color: `${pair.background}ff`, offset: 1 },+ ]+ : options.stops.map((stop) => ({ ...stop }));const layerId = ctx.createLayerId();const source: CanvasLayerSourceContract = {angle,height: doc.bbox.height,kind: options.kind,- stops: options.stops.map((stop) => ({ ...stop })),+ stops,type: 'gradient',width: doc.bbox.width,};diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/shapeTool.test.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/shapeTool.test.tsindex a53248b242..e7f5a98f03 100644--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/shapeTool.test.ts+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/shapeTool.test.ts@@ -129,9 +129,10 @@ describe('shape tool: creation', () => {expect(h.previewOf()).toBeNull();});- it('uses the shape options kind/fill/stroke for the created layer', () => {+ it('resolves the pair at gesture start for the enabled fill and stroke', () => {const h = createHarness(makeDoc());- h.stores.shapeOptions.set({ fill: '#ff0000', kind: 'ellipse', stroke: '#0000ff', strokeWidth: 4 });+ h.stores.shapeOptions.set({ fillEnabled: true, kind: 'ellipse', strokeEnabled: true, strokeWidth: 4 });+ h.stores.colorPair.set({ background: '#0000ff', foreground: '#ff0000' });const tool = createShapeTool();down(tool, h.ctx, pointer(0, 0));diff --git a/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/shapeTool.ts b/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/shapeTool.tsindex b51e3cadb9..0abf052338 100644--- a/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/shapeTool.ts+++ b/invokeai/frontend/webv2/src/workbench/canvas-engine/tools/shapeTool.ts@@ -131,6 +131,9 @@ export const createShapeTool = (): Tool => {}const options = ctx.stores.shapeOptions.get();+ // The active pair, resolved now: the new shape gets explicit document+ // colors; later pair edits never rewrite them.+ const pair = ctx.stores.colorPair.get();const layerId = ctx.createLayerId();const layer: CanvasRasterLayerContractV2 = {blendMode: 'normal',@@ -140,10 +143,10 @@ export const createShapeTool = (): Tool => {name: `Shape ${getDocumentLeaves(doc).length + 1}`,opacity: 1,source: {- fill: options.fill,+ fill: options.fillEnabled ? pair.foreground : null,height: rect.height,kind: options.kind,- stroke: options.stroke,+ stroke: options.strokeEnabled ? pair.background : null,strokeWidth: options.strokeWidth,type: 'shape',width: rect.width,diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/color-system/CanvasColorFeed.tsx b/invokeai/frontend/webv2/src/workbench/widgets/canvas/color-system/CanvasColorFeed.tsxindex fa7b18d3fd..ea3ed5edf3 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/canvas/color-system/CanvasColorFeed.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/color-system/CanvasColorFeed.tsx@@ -30,6 +30,15 @@ export const CanvasColorFeed = ({ engine }: { engine: CanvasEngineHandle | null}}, [engine, colorPair.foreground]);+ // The whole pair, for gesture-start reads: new shapes and text sessions+ // capture it when they begin, and the gradient FG→BG preset resolves it.+ useEffect(() => {+ if (!engine) {+ return;+ }+ engine.interaction.set('colorPair', { background: colorPair.background, foreground: colorPair.foreground });+ }, [engine, colorPair.background, colorPair.foreground]);+useEffect(() => {if (!engine) {return;diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/color-system/maskTintTarget.ts b/invokeai/frontend/webv2/src/workbench/widgets/canvas/color-system/maskTintTarget.tsnew file mode 100644index 0000000000..e355c20491--- /dev/null+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/color-system/maskTintTarget.ts@@ -0,0 +1,31 @@+import { registerAccountOwnedResource } from '@platform/state/accountLifecycle';+import { createExternalStore } from '@platform/state/externalStore';++/**+ * The Color pane's one non-pair target: a mask layer's tint, armed explicitly+ * from a compatible Layer property or the pane's own chip. Transient by+ * design — the tint itself is document state; this only names which layer the+ * pane is currently editing. Cleared whenever the armed layer stops being the+ * selected mask, so the pane falls back to the foreground/background target.+ */+export const maskTintTargetStore = createExternalStore<{ layerId: string | null }>({ layerId: null });++registerAccountOwnedResource({+ clear: () => {+ maskTintTargetStore.setSnapshot({ layerId: null });+ },+ name: 'mask-tint-target',+});++export const armMaskTintTarget = (layerId: string): void => {+ maskTintTargetStore.setSnapshot({ layerId });+};++export const clearMaskTintTarget = (): void => {+ if (maskTintTargetStore.getSnapshot().layerId !== null) {+ maskTintTargetStore.setSnapshot({ layerId: null });+ }+};++export const useMaskTintTargetLayerId = (): string | null =>+ maskTintTargetStore.useSelector((snapshot) => snapshot.layerId, Object.is);diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/color-system/useMaskTintEditor.ts b/invokeai/frontend/webv2/src/workbench/widgets/canvas/color-system/useMaskTintEditor.tsnew file mode 100644index 0000000000..e78ad6c1f1--- /dev/null+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/color-system/useMaskTintEditor.ts@@ -0,0 +1,149 @@+import type { CanvasLayerContract, CanvasMaskFillContract } from '@workbench/canvas-engine/api';+import type { CanvasEngineHandle } from '@workbench/widgets/canvas/useCanvasEngine';++import { getDocumentLayer } from '@workbench/canvas-engine/api';+import { usePreparedCommit } from '@workbench/widgets/canvas/useStructuralCommit';+import { applyStructuralPreview } from '@workbench/widgets/layers/layerOps';+import { useActiveProjectSelector } from '@workbench/WorkbenchContext';+import { useCallback, useEffect, useMemo, useRef } from 'react';+import { useTranslation } from 'react-i18next';++import { clearMaskTintTarget, useMaskTintTargetLayerId } from './maskTintTarget';++type MaskTintEngine = Pick<CanvasEngineHandle, 'document' | 'exports' | 'interaction' | 'layers'>;+type MaskLayer = Extract<CanvasLayerContract, { type: 'inpaint_mask' | 'regional_guidance' }>;++/** Key repeats and drag releases coalesce into one entry after this idle gap. */+const COMMIT_SETTLE_MS = 400;++export interface MaskTintEditor {+ layerId: string;+ /** The armed mask's current tint. */+ color: string;+ /** Live, un-recorded preview during a drag. */+ preview: (hex: string) => void;+ /** Applies the color and records the gesture's ONE history entry once it settles. */+ commit: (hex: string) => void;+}++/**+ * A gesture in flight: the layer and fill captured before the first preview+ * (the entry's undo target), the latest applied hex, and the settle timer.+ * Holding these in one ref keeps the eventual commit closure-safe — the+ * gesture can outlive re-renders, a disarm, and even the pane unmounting.+ */+interface TintGesture {+ layer: MaskLayer;+ before: CanvasMaskFillContract;+ latestHex: string;+ timer: ReturnType<typeof setTimeout> | null;+}++const configFor = (layer: MaskLayer, fill: CanvasMaskFillContract) =>+ layer.type === 'inpaint_mask'+ ? ({ layerType: 'inpaint_mask', mask: { fill } } as const)+ : ({ layerType: 'regional_guidance', mask: { fill } } as const);++/**+ * The armed mask-tint target as an editor, or `null` when no target is armed.+ * Watches the document: if the armed layer disappears, stops being a mask, or+ * stops being the selected layer, the target clears itself and the Color pane+ * returns to the foreground/background pair. A pending gesture always settles+ * into exactly one history entry — on the idle timer, on disarm, or on+ * unmount — so a preview can never outlive its commit.+ */+export const useMaskTintEditor = (engine: MaskTintEngine | null): MaskTintEditor | null => {+ const { t } = useTranslation();+ const commitPrepared = usePreparedCommit(engine);+ const armedLayerId = useMaskTintTargetLayerId();+ const layer = useActiveProjectSelector((project): MaskLayer | null => {+ if (!armedLayerId || project.canvas.document.selectedLayerId !== armedLayerId) {+ return null;+ }+ const node = getDocumentLayer(project.canvas.document, armedLayerId);+ return node && (node.type === 'inpaint_mask' || node.type === 'regional_guidance') ? node : null;+ });++ const gestureRef = useRef<TintGesture | null>(null);+ const settle = useCallback(() => {+ const gesture = gestureRef.current;+ gestureRef.current = null;+ if (!gesture) {+ return;+ }+ if (gesture.timer !== null) {+ clearTimeout(gesture.timer);+ }+ if (gesture.before.color === gesture.latestHex) {+ return;+ }+ commitPrepared(t('widgets.layers.maskFill.fill'), (model) =>+ model.prepare({+ before: configFor(gesture.layer, gesture.before),+ config: configFor(gesture.layer, { ...gesture.before, color: gesture.latestHex }),+ id: gesture.layer.id,+ type: 'patch-config',+ })+ );+ }, [commitPrepared, t]);+ const settleRef = useRef(settle);+ useEffect(() => {+ settleRef.current = settle;+ }, [settle]);++ useEffect(() => {+ if (armedLayerId && !layer) {+ clearMaskTintTarget();+ }+ }, [armedLayerId, layer]);+ // Disarm and unmount both flush the pending gesture; the gesture carries its+ // own layer, so this works even after the selection has moved on.+ useEffect(() => {+ if (!armedLayerId) {+ settleRef.current();+ }+ return () => settleRef.current();+ }, [armedLayerId]);++ const preview = useCallback(+ (hex: string) => {+ if (!layer) {+ return;+ }+ if (+ !applyStructuralPreview(engine, {+ config: configFor(layer, { ...layer.mask.fill, color: hex }),+ id: layer.id,+ type: 'updateCanvasLayerConfig',+ })+ ) {+ return;+ }+ if (gestureRef.current === null) {+ gestureRef.current = { before: layer.mask.fill, latestHex: hex, layer, timer: null };+ } else {+ gestureRef.current.latestHex = hex;+ }+ },+ [engine, layer]+ );+ const commit = useCallback(+ (hex: string) => {+ preview(hex);+ const gesture = gestureRef.current;+ if (!gesture) {+ return;+ }+ if (gesture.timer !== null) {+ clearTimeout(gesture.timer);+ }+ gesture.timer = setTimeout(() => settleRef.current(), COMMIT_SETTLE_MS);+ },+ [preview]+ );++ return useMemo(+ () => (layer ? { color: layer.mask.fill.color, commit, layerId: layer.id, preview } : null),+ [commit, layer, preview]+ );+};diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/GradientOptions.tsx b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/GradientOptions.tsxindex 7c94c71ace..bd75f398f1 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/GradientOptions.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/GradientOptions.tsx@@ -6,14 +6,17 @@ import type {} from '@workbench/widgets/canvas/tool-presentation/toolbarContracts';import { createListCollection } from '@chakra-ui/react';+import { ToggleIconButton } from '@platform/ui/Button';import { ColorPicker } from '@platform/ui/ColorPicker';import { Select } from '@platform/ui/Select';import { getDocumentLayer } from '@workbench/canvas-engine/api';+import { useActiveColorPair } from '@workbench/widgets/canvas/color-system/useActiveColors';import { useGradientOptions } from '@workbench/widgets/canvas/engineStoreHooks';import { ToolbarNumberField, useNumberCommit } from '@workbench/widgets/canvas/tool-presentation/ToolbarPrimitives';import { useColorSampler } from '@workbench/widgets/canvas/useColorSampler';import { usePreparedCommit } from '@workbench/widgets/canvas/useStructuralCommit';import { useActiveProjectSelector } from '@workbench/WorkbenchContext';+import { PaletteIcon } from 'lucide-react';import { useCallback, useMemo } from 'react';import { useTranslation } from 'react-i18next';@@ -30,13 +33,16 @@ const SELECT_TRIGGER_PROPS = { minW: '6rem', w: '6rem' } as const;/*** Kind, angle and a minimal two-stop editor. Displayed values follow the- * selected gradient layer, else the tool defaults; edits set the defaults AND- * commit to a selected gradient layer (colors once on release).+ * selected gradient layer, else the tool defaults — where the built-in FG→BG+ * preset shows the live pair (resolved for real at gesture start) and editing+ * a stop switches to explicit custom stops, independent of later pair edits.+ * Edits commit to a selected gradient layer (colors once on release).*/const useGradientEditor = (engine: ToolbarRegionProps['engine']) => {const { t } = useTranslation();const commitPrepared = usePreparedCommit(engine);const options = useGradientOptions(engine);+ const pair = useActiveColorPair();const selected = useActiveProjectSelector((project): SelectedGradient | null => {const { document } = project.canvas;@@ -49,11 +55,18 @@ const useGradientEditor = (engine: ToolbarRegionProps['engine']) => {);const kind: GradientKind = selected ? selected.source.kind : options.kind;const angle = selected ? selected.source.angle : options.angle;- const stops = selected ? selected.source.stops : options.stops;+ const pairStops = useMemo<GradientStop[]>(+ () => [+ { color: `${pair.foreground}ff`, offset: 0 },+ { color: `${pair.background}ff`, offset: 1 },+ ],+ [pair.background, pair.foreground]+ );+ const stops = selected ? selected.source.stops : options.preset === 'pair' ? pairStops : options.stops;const apply = useCallback((next: { angle: number; kind: GradientKind; stops: GradientStop[] }, commit: boolean) => {- engine.interaction.set('gradientOptions', next);+ engine.interaction.set('gradientOptions', { ...options, angle: next.angle, kind: next.kind });if (selected && commit) {const after: GradientSource = { ...selected.source, ...next };commitPrepared(t('widgets.canvas.toolOptions.gradientEdit'), (model) =>@@ -61,9 +74,27 @@ const useGradientEditor = (engine: ToolbarRegionProps['engine']) => {);}},- [commitPrepared, engine, selected, t]+ [commitPrepared, engine, options, selected, t]+ );+ const setCustomStops = useCallback(+ (nextStops: GradientStop[]) => {+ engine.interaction.set('gradientOptions', { ...options, preset: 'custom', stops: nextStops });+ },+ [engine, options]+ );+ const setPreset = useCallback(+ (preset: 'pair' | 'custom') => {+ // Leaving the preset keeps what the chips currently show as the custom set.+ engine.interaction.set('gradientOptions', {+ ...options,+ preset,+ stops:+ preset === 'custom' && options.preset === 'pair' ? pairStops.map((stop) => ({ ...stop })) : options.stops,+ });+ },+ [engine, options, pairStops]);- return { angle, apply, kind, stops };+ return { angle, apply, kind, preset: selected ? null : options.preset, setCustomStops, setPreset, stops };};const GradientAngle = ({ engine }: ToolbarRegionProps) => {@@ -131,15 +162,24 @@ const GradientKindSelect = ({ engine }: ToolbarRegionProps) => {const GradientStops = ({ engine }: ToolbarRegionProps) => {const { t } = useTranslation();- const { angle, apply, kind, stops } = useGradientEditor(engine);+ const { angle, apply, kind, preset, setCustomStops, setPreset, stops } = useGradientEditor(engine);const sampleColor = useColorSampler(engine);const start = stops[0] ?? { color: '#000000ff', offset: 0 };const end = stops[stops.length - 1] ?? { color: '#ffffffff', offset: 1 };const setStop = useCallback(- (index: number, color: string, commit: boolean) =>- apply({ angle, kind, stops: stops.map((stop, i) => (i === index ? { ...stop, color } : stop)) }, commit),- [angle, apply, kind, stops]+ (index: number, color: string, commit: boolean) => {+ const nextStops = stops.map((stop, i) => (i === index ? { ...stop, color } : stop));+ if (preset === null) {+ // A selected gradient: explicit document stops, one entry on release.+ apply({ angle, kind, stops: nextStops }, commit);+ return;+ }+ // No selection: stop edits make the custom set explicit.+ setCustomStops(nextStops);+ },+ [angle, apply, kind, preset, setCustomStops, stops]);+ const onPresetToggle = useCallback((checked: boolean) => setPreset(checked ? 'pair' : 'custom'), [setPreset]);const last = stops.length - 1;const onStart = useCallback((color: string) => setStop(0, color, false), [setStop]);const onStartEnd = useCallback((color: string) => setStop(0, color, true), [setStop]);@@ -147,6 +187,14 @@ const GradientStops = ({ engine }: ToolbarRegionProps) => {const onEndEnd = useCallback((color: string) => setStop(last, color, true), [last, setStop]);return (<>+ {/* Disabled, never removed, when a selected gradient owns the stops: the row keeps its geometry. */}+ <ToggleIconButton+ checked={preset === 'pair'}+ disabled={preset === null}+ icon={PaletteIcon}+ label={t('widgets.canvas.toolOptions.gradientPairPreset')}+ onCheckedChange={onPresetToggle}+ /><ColorPickeraria-label={t('widgets.canvas.toolOptions.gradientStart')}value={start.color}diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/ShapeOptions.tsx b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/ShapeOptions.tsxindex 680e041e5c..da6aa0fc03 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/ShapeOptions.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/ShapeOptions.tsx@@ -10,6 +10,7 @@ import { ToggleIconButton } from '@platform/ui/Button';import { ColorPicker } from '@platform/ui/ColorPicker';import { Select } from '@platform/ui/Select';import { MAX_SHAPE_STROKE_WIDTH, getDocumentLayer } from '@workbench/canvas-engine/api';+import { useActiveColorCommands, useActiveColorPair } from '@workbench/widgets/canvas/color-system/useActiveColors';import { useShapeOptions } from '@workbench/widgets/canvas/engineStoreHooks';import {ToolbarHint,@@ -36,15 +37,19 @@ const SELECT_POSITIONING = { placement: 'bottom-start', sameWidth: false } as coconst SELECT_TRIGGER_PROPS = { minW: '6rem', w: '6rem' } as const;/**- * Displayed values follow the selected shape layer, else the tool defaults.- * Edits set the defaults for the next shape AND, when a shape layer is- * selected, commit to it: colors record one history entry on release, discrete- * edits commit at once. C2 splits these two owners into Properties sections.+ * Displayed values follow the selected shape layer, else the creation defaults+ * — kind/width/enablement from the tool options and colors from the active+ * pair (fill = foreground, stroke = background). A selected shape's edits+ * commit to the document (colors record one history entry on release); with+ * nothing selected the color chips edit the pair itself, so there is no second+ * global shape color.*/const useShapeEditor = (engine: ToolbarRegionProps['engine']) => {const { t } = useTranslation();const commitPrepared = usePreparedCommit(engine);const options = useShapeOptions(engine);+ const pair = useActiveColorPair();+ const colorCommands = useActiveColorCommands();const selected = useActiveProjectSelector((project): SelectedShape | null => {const { document } = project.canvas;@@ -56,30 +61,99 @@ const useShapeEditor = (engine: ToolbarRegionProps['engine']) => {(a, b) => a?.id === b?.id && a?.source === b?.source);const kind: ShapeKind = selected ? (selected.source.kind === 'ellipse' ? 'ellipse' : 'rect') : options.kind;- const fill = selected ? selected.source.fill : options.fill;- const stroke = selected ? selected.source.stroke : options.stroke;+ const fill = selected ? selected.source.fill : options.fillEnabled ? pair.foreground : null;+ const stroke = selected ? selected.source.stroke : options.strokeEnabled ? pair.background : null;const strokeWidth = selected ? selected.source.strokeWidth : options.strokeWidth;- const applyEdit = useCallback(- (patch: Partial<ShapeToolOptions>, commit: boolean) => {- engine.interaction.set('shapeOptions', { fill, kind, stroke, strokeWidth, ...patch });- if (selected && commit) {- const after: ShapeSource = { ...selected.source, ...patch };- commitPrepared(t('widgets.canvas.toolOptions.shapeEdit'), (model) =>- model.prepare({ id: selected.id, source: after, type: 'patch-source' })- );+ const commitSource = useCallback(+ (patch: Partial<ShapeSource>) => {+ if (!selected) {+ return;}+ const after: ShapeSource = { ...selected.source, ...patch };+ commitPrepared(t('widgets.canvas.toolOptions.shapeEdit'), (model) =>+ model.prepare({ id: selected.id, source: after, type: 'patch-source' })+ );},- [commitPrepared, engine, fill, kind, selected, stroke, strokeWidth, t]+ [commitPrepared, selected, t]);- return { applyEdit, fill, kind, stroke, strokeWidth };+ const setOptions = useCallback(+ (patch: Partial<ShapeToolOptions>) => {+ engine.interaction.set('shapeOptions', { ...options, ...patch });+ },+ [engine, options]+ );+ const setKind = useCallback(+ (next: ShapeKind) => {+ setOptions({ kind: next });+ commitSource({ kind: next });+ },+ [commitSource, setOptions]+ );+ const setStrokeWidth = useCallback(+ (value: number) => {+ setOptions({ strokeWidth: value });+ commitSource({ strokeWidth: value });+ },+ [commitSource, setOptions]+ );+ const setFillEnabled = useCallback(+ (checked: boolean) => {+ setOptions({ fillEnabled: checked });+ commitSource({ fill: checked ? (selected?.source.fill ?? pair.foreground) : null });+ },+ [commitSource, pair.foreground, selected, setOptions]+ );+ const setStrokeEnabled = useCallback(+ (checked: boolean) => {+ setOptions({ strokeEnabled: checked });+ commitSource({ stroke: checked ? (selected?.source.stroke ?? pair.background) : null });+ },+ [commitSource, pair.background, selected, setOptions]+ );+ const setFillColor = useCallback(+ (hex: string, commit: boolean) => {+ if (selected) {+ if (commit) {+ commitSource({ fill: hex });+ }+ return;+ }+ colorCommands.setPairColor('foreground', hex);+ },+ [colorCommands, commitSource, selected]+ );+ const setStrokeColor = useCallback(+ (hex: string, commit: boolean) => {+ if (selected) {+ if (commit) {+ commitSource({ stroke: hex });+ }+ return;+ }+ colorCommands.setPairColor('background', hex);+ },+ [colorCommands, commitSource, selected]+ );+ return {+ fill,+ kind,+ setFillColor,+ setFillEnabled,+ setKind,+ setStrokeColor,+ setStrokeEnabled,+ setStrokeWidth,+ stroke,+ strokeWidth,+ };};const ShapeStrokeWidth = ({ engine }: ToolbarRegionProps) => {const { t } = useTranslation();- const { applyEdit, stroke, strokeWidth } = useShapeEditor(engine);+ const { setStrokeWidth, stroke, strokeWidth } = useShapeEditor(engine);const onCommit = useNumberCommit(- useCallback((value: number) => applyEdit({ strokeWidth: Math.max(0, Math.round(value)) }, true), [applyEdit])+ useCallback((value: number) => setStrokeWidth(Math.max(0, Math.round(value))), [setStrokeWidth]));return (<ToolbarNumberField@@ -96,7 +170,7 @@ const ShapeStrokeWidth = ({ engine }: ToolbarRegionProps) => {const ShapeModes = ({ engine }: ToolbarRegionProps) => {const { t } = useTranslation();- const { applyEdit, fill, kind, stroke } = useShapeEditor(engine);+ const { fill, kind, setFillEnabled, setKind, setStrokeEnabled, stroke } = useShapeEditor(engine);const kindCollection = useMemo(() =>createListCollection<{ label: string; value: ShapeKind }>({@@ -112,19 +186,13 @@ const ShapeModes = ({ engine }: ToolbarRegionProps) => {({ value }: SelectValueChangeDetails<{ label: string; value: ShapeKind }>) => {const next = value[0] as ShapeKind | undefined;if (next && next !== kind) {- applyEdit({ kind: next }, true);+ setKind(next);}},- [applyEdit, kind]- );- const onFillToggle = useCallback(- (checked: boolean) => applyEdit({ fill: checked ? (fill ?? FALLBACK_COLOR) : null }, true),- [applyEdit, fill]- );- const onStrokeToggle = useCallback(- (checked: boolean) => applyEdit({ stroke: checked ? (stroke ?? FALLBACK_COLOR) : null }, true),- [applyEdit, stroke]+ [kind, setKind]);+ const onFillToggle = useCallback((checked: boolean) => setFillEnabled(checked), [setFillEnabled]);+ const onStrokeToggle = useCallback((checked: boolean) => setStrokeEnabled(checked), [setStrokeEnabled]);return (<><Select@@ -161,12 +229,12 @@ const ShapeModes = ({ engine }: ToolbarRegionProps) => {/** Fill and stroke chips; a `none` fill or stroke shows a disabled chip so the slots keep their place. */const ShapeColors = ({ engine }: ToolbarRegionProps) => {const { t } = useTranslation();- const { applyEdit, fill, stroke } = useShapeEditor(engine);+ const { fill, setFillColor, setStrokeColor, stroke } = useShapeEditor(engine);const sampleColor = useColorSampler(engine);- const onFillChange = useCallback((hex: string) => applyEdit({ fill: hex }, false), [applyEdit]);- const onFillChangeEnd = useCallback((hex: string) => applyEdit({ fill: hex }, true), [applyEdit]);- const onStrokeChange = useCallback((hex: string) => applyEdit({ stroke: hex }, false), [applyEdit]);- const onStrokeChangeEnd = useCallback((hex: string) => applyEdit({ stroke: hex }, true), [applyEdit]);+ const onFillChange = useCallback((hex: string) => setFillColor(hex, false), [setFillColor]);+ const onFillChangeEnd = useCallback((hex: string) => setFillColor(hex, true), [setFillColor]);+ const onStrokeChange = useCallback((hex: string) => setStrokeColor(hex, false), [setStrokeColor]);+ const onStrokeChangeEnd = useCallback((hex: string) => setStrokeColor(hex, true), [setStrokeColor]);return (<><ColorPickerdiff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/TextOptions.tsx b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/TextOptions.tsxindex d7a0b506c9..c8ca13317f 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/TextOptions.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/TextOptions.tsx@@ -16,6 +16,7 @@ import {TEXT_FONT_WEIGHTS,getDocumentLayer,} from '@workbench/canvas-engine/api';+import { useActiveColorCommands, useActiveColorPair } from '@workbench/widgets/canvas/color-system/useActiveColors';import { useTextEditSession, useTextOptions } from '@workbench/widgets/canvas/engineStoreHooks';import { ToolbarNumberField, useNumberCommit } from '@workbench/widgets/canvas/tool-presentation/ToolbarPrimitives';import { useColorSampler } from '@workbench/widgets/canvas/useColorSampler';@@ -78,14 +79,18 @@ const AlignButton = ({/*** Displayed values: an open editing session's live source, else the selected- * text layer, else the tool defaults. Edits always update the defaults, then- * restyle the live session (folded into its single commit) or commit one- * history entry on the selected layer; colors commit on release.+ * text layer, else the tool defaults — with color from the active foreground+ * when neither a session nor a selection owns one, so there is no second+ * global text color. Style edits update the defaults, then restyle the live+ * session (folded into its single commit) or commit one history entry on the+ * selected layer; color edits with nothing to own them edit the pair.*/const useTextEditor = (engine: ToolbarRegionProps['engine']) => {const { t } = useTranslation();const commitPrepared = usePreparedCommit(engine);const options = useTextOptions(engine);+ const pair = useActiveColorPair();+ const colorCommands = useActiveColorCommands();const session = useTextEditSession(engine);const selected = useActiveProjectSelector((project): SelectedText | null => {@@ -97,23 +102,41 @@ const useTextEditor = (engine: ToolbarRegionProps['engine']) => {},(a, b) => a?.id === b?.id && a?.source === b?.source);- const active: TextToolOptions = session ? session.source : (selected?.source ?? options);- const { align, color, fontFamily, fontSize, fontWeight, lineHeight } = active;+ const styleSource = session ? session.source : (selected?.source ?? null);+ const align = styleSource?.align ?? options.align;+ const fontFamily = styleSource?.fontFamily ?? options.fontFamily;+ const fontSize = styleSource?.fontSize ?? options.fontSize;+ const fontWeight = styleSource?.fontWeight ?? options.fontWeight;+ const lineHeight = styleSource?.lineHeight ?? options.lineHeight;+ const color = styleSource?.color ?? pair.foreground;+ const active = useMemo(+ () => ({ align, color, fontFamily, fontSize, fontWeight, lineHeight }),+ [align, color, fontFamily, fontSize, fontWeight, lineHeight]+ );const applyEdit = useCallback(- (patch: Partial<TextToolOptions>, commit: boolean) => {- engine.interaction.set('textOptions', { align, color, fontFamily, fontSize, fontWeight, lineHeight, ...patch });+ (patch: Partial<TextSource>, commit: boolean) => {+ const { color: colorPatch, ...stylePatch } = patch;+ if (Object.keys(stylePatch).length > 0) {+ engine.interaction.set('textOptions', { align, fontFamily, fontSize, fontWeight, lineHeight, ...stylePatch });+ }if (session) {engine.layers.updateTextEditStyle(patch);return;}- if (selected && commit) {- const after: TextSource = { ...selected.source, ...patch };- commitPrepared(t('widgets.canvas.toolOptions.textEdit'), (model) =>- model.prepare({ id: selected.id, source: after, type: 'patch-source' })- );+ if (selected) {+ if (commit) {+ const after: TextSource = { ...selected.source, ...patch };+ commitPrepared(t('widgets.canvas.toolOptions.textEdit'), (model) =>+ model.prepare({ id: selected.id, source: after, type: 'patch-source' })+ );+ }+ return;+ }+ if (colorPatch !== undefined) {+ colorCommands.setPairColor('foreground', colorPatch);}},- [align, color, commitPrepared, engine, fontFamily, fontSize, fontWeight, lineHeight, selected, session, t]+ [align, colorCommands, commitPrepared, engine, fontFamily, fontSize, fontWeight, lineHeight, selected, session, t]);return { active, applyEdit };};diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/InpaintMaskSettings.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/InpaintMaskSettings.tsxindex e6b3fdc0bd..d2eb41b9b8 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/InpaintMaskSettings.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/InpaintMaskSettings.tsx@@ -3,8 +3,10 @@ import type { CanvasInpaintMaskLayerContract, CanvasMaskFillContract } from '@woimport type { CanvasStructuralEngine } from '@workbench/widgets/layers/layerOps';import { createListCollection, HStack, Stack } from '@chakra-ui/react';-import { Button, ColorPicker, Field, Select, Slider } from '@platform/ui';+import { Button, ColorPicker, Field, IconButton, Select, Slider, Tooltip } from '@platform/ui';+import { armMaskTintTarget } from '@workbench/widgets/canvas/color-system/maskTintTarget';import { type CanvasPreparedEngine, usePreparedCommit } from '@workbench/widgets/canvas/useStructuralCommit';+import { PaletteIcon } from 'lucide-react';import { useCallback, useMemo, useRef } from 'react';import { useTranslation } from 'react-i18next';@@ -93,6 +95,7 @@ export const InpaintMaskSettings = ({ engine, layer }: InpaintMaskSettingsProps)[engine, fill, layer.id]);+ const handleArmTint = useCallback(() => armMaskTintTarget(layer.id), [layer.id]);const handleColorChangeEnd = useCallback((hex: string) => {const before = fillBeforeRef.current ?? fill;@@ -209,6 +212,18 @@ export const InpaintMaskSettings = ({ engine, layer }: InpaintMaskSettingsProps)onValueChangeEnd={handleColorChangeEnd}/></Field>+ <Tooltip content={t('widgets.layers.maskFill.editInColorPane')}>+ <IconButton+ aria-label={t('widgets.layers.maskFill.editInColorPane')}+ alignSelf="flex-end"+ color="fg.muted"+ size="2xs"+ variant="ghost"+ onClick={handleArmTint}+ >+ <PaletteIcon size={14} />+ </IconButton>+ </Tooltip><Field flex="1" label={t('widgets.layers.maskFill.style')} minW="0"><Selectaria-label={t('widgets.layers.maskFill.style')}diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/RegionalGuidanceSettings.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/RegionalGuidanceSettings.tsxindex 664860ffe8..3bbee73924 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/RegionalGuidanceSettings.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/RegionalGuidanceSettings.tsx@@ -23,12 +23,13 @@ import {captureAccountScope,isAccountScopeCurrent,} from '@platform/state/accountLifecycle';-import { Button, ColorPicker, DropZone, Field, Select, Slider } from '@platform/ui';+import { Button, ColorPicker, DropZone, Field, Select, Slider, Tooltip } from '@platform/ui';import { useQueryClient } from '@tanstack/react-query';import { useWorkbenchPreferenceSelector } from '@workbench/settings/store';+import { armMaskTintTarget } from '@workbench/widgets/canvas/color-system/maskTintTarget';import { type CanvasPreparedEngine, usePreparedCommit } from '@workbench/widgets/canvas/useStructuralCommit';import { useWorkbenchCommands } from '@workbench/WorkbenchContext';-import { ImageIcon, PlusIcon, XIcon } from 'lucide-react';+import { ImageIcon, PlusIcon, XIcon, PaletteIcon } from 'lucide-react';import { useCallback, useMemo, useRef, useState } from 'react';import { useTranslation } from 'react-i18next';@@ -219,6 +220,7 @@ export const RegionalGuidanceSettings = ({ engine, layer }: RegionalGuidanceSett[engine, fill, layer.id]);+ const handleArmTint = useCallback(() => armMaskTintTarget(layer.id), [layer.id]);const handleColorChangeEnd = useCallback((hex: string) => {const before = fillBeforeRef.current ?? fill;@@ -415,6 +417,18 @@ export const RegionalGuidanceSettings = ({ engine, layer }: RegionalGuidanceSettonValueChangeEnd={handleColorChangeEnd}/></Field>+ <Tooltip content={t('widgets.layers.maskFill.editInColorPane')}>+ <IconButton+ aria-label={t('widgets.layers.maskFill.editInColorPane')}+ alignSelf="flex-end"+ color="fg.muted"+ size="2xs"+ variant="ghost"+ onClick={handleArmTint}+ >+ <PaletteIcon size={14} />+ </IconButton>+ </Tooltip><Field flex="1" label={t('widgets.layers.maskFill.style')} minW="0"><Selectaria-label={t('widgets.layers.maskFill.style')}diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/ColorPane.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/ColorPane.tsxindex 6ace31c40d..be83890552 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/ColorPane.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/ColorPane.tsx@@ -18,13 +18,17 @@ import { HsvBoxPicker } from '@platform/ui/HsvBoxPicker';import { HsvWheelPicker } from '@platform/ui/HsvWheelPicker';import { Scrollable } from '@platform/ui/Scrollable';import { Tooltip } from '@platform/ui/Tooltip';+import { getDocumentLayer } from '@workbench/canvas-engine/api';+import { armMaskTintTarget, clearMaskTintTarget } from '@workbench/widgets/canvas/color-system/maskTintTarget';import {useActiveColorCommands,useActiveColorPair,useActiveColorTarget,} from '@workbench/widgets/canvas/color-system/useActiveColors';+import { useMaskTintEditor, type MaskTintEditor } from '@workbench/widgets/canvas/color-system/useMaskTintEditor';import { ToolbarNumberField } from '@workbench/widgets/canvas/tool-presentation/ToolbarPrimitives';import { useCanvasEngine } from '@workbench/widgets/canvas/useCanvasEngine';+import { useActiveProjectSelector } from '@workbench/WorkbenchContext';import { ArrowLeftRightIcon, CircleIcon, PipetteIcon, RotateCcwIcon, SquareIcon } from 'lucide-react';import { useCallback, useEffect, useMemo, useRef, useState } from 'react';import { useTranslation } from 'react-i18next';@@ -48,7 +52,17 @@ export const ColorPane = () => {const target = useActiveColorTarget();const commands = useActiveColorCommands();const mode = useColorPickerMode();- const activeHex = pair[target];+ // The explicit non-pair target: the selected mask's tint, when armed. Its+ // edits commit through the document seam — live preview, one entry a gesture.+ const maskTint = useMaskTintEditor(engine);+ const selectedMask = useActiveProjectSelector((project) => {+ const { document } = project.canvas;+ const layer = document.selectedLayerId ? getDocumentLayer(document, document.selectedLayerId) : null;+ return layer && (layer.type === 'inpaint_mask' || layer.type === 'regional_guidance')+ ? { color: layer.mask.fill.color, id: layer.id }+ : null;+ }, areSelectedMasksEqual);+ const activeHex = maskTint ? maskTint.color : pair[target];// The picker holds HSV so hue survives greys; it resyncs from the pair only// when the pair changed to something the current HSV does not already mean.@@ -66,9 +80,13 @@ export const ColorPane = () => {setHsv(next);const hex = hsvToHex(next);setSyncedHex(hex);+ if (maskTint) {+ maskTint.preview(hex);+ return;+ }commands.setPairColor(target, hex);},- [commands, target]+ [commands, maskTint, target]);// Held arrow keys commit per repeat; the recents shelf hears only the// settled color, not two dozen intermediate hues. An immediate record (hex@@ -89,10 +107,11 @@ export const ColorPane = () => {(next: HsvColor) => {applyHsv(next);const hex = hsvToHex(next);+ maskTint?.commit(hex);settlePendingRecent(false);pendingRecent.current = { hex, timer: setTimeout(() => settlePendingRecent(true), 500) };},- [applyHsv, settlePendingRecent]+ [applyHsv, maskTint, settlePendingRecent]);const applyHex = useCallback((hex: string) => {@@ -102,10 +121,14 @@ export const ColorPane = () => {// Flattened like the pair itself, so a recent swatch always matches what it sets.const opaque = formatHexColor(parseHexColor(hex));settlePendingRecent(false);- commands.setPairColor(target, opaque);+ if (maskTint) {+ maskTint.commit(opaque);+ } else {+ commands.setPairColor(target, opaque);+ }recordRecentColor(opaque);},- [commands, settlePendingRecent, target]+ [commands, maskTint, settlePendingRecent, target]);const sampleFromCanvas = useCallback(async () => {if (!engine) {@@ -114,12 +137,17 @@ export const ColorPane = () => {const hex = await engine.tools.requestColorSample();if (hex) {// Routed through the command so the target is read when the sample lands,- // not when the pipette was armed.+ // not when the pipette was armed. The pane's pipette is the mask tint's+ // editor-specific sampler; the standing router never writes the tint.settlePendingRecent(false);- commands.applySampledColor(hex);+ if (maskTint) {+ maskTint.commit(hex);+ } else {+ commands.applySampledColor(hex);+ }recordRecentColor(hex);}- }, [commands, engine, settlePendingRecent]);+ }, [commands, engine, maskTint, settlePendingRecent]);const toggleMode = useCallback(() => setColorPickerMode(mode === 'wheel' ? 'box' : 'wheel'), [mode]);const modeLabel =mode === 'wheel' ? t('widgets.layers.colorPane.pickerModeBox') : t('widgets.layers.colorPane.pickerModeWheel');@@ -136,7 +164,13 @@ export const ColorPane = () => {</Box><Stack flex="1" gap="2" minW="0"><HStack gap="1">- <TargetChips pair={pair} target={target} onSelectTarget={commands.setTarget} />+ <TargetChips+ maskTint={maskTint}+ pair={pair}+ selectedMask={selectedMask}+ target={target}+ onSelectTarget={commands.setTarget}+ /><Tooltip content={t('widgets.canvas.commands.swapColors')}><IconButtonaria-label={t('widgets.canvas.commands.swapColors')}@@ -186,32 +220,64 @@ export const ColorPane = () => {);};+const areSelectedMasksEqual = (+ a: { color: string; id: string } | null,+ b: { color: string; id: string } | null+): boolean => a?.id === b?.id && a?.color === b?.color;+const TargetChips = ({+ maskTint,onSelectTarget,pair,+ selectedMask,target,}: {+ maskTint: MaskTintEditor | null;onSelectTarget: (target: ActiveColorTarget) => void;pair: { foreground: string; background: string };+ selectedMask: { color: string; id: string } | null;target: ActiveColorTarget;}) => {const { t } = useTranslation();+ const selectPairTarget = useCallback(+ (next: ActiveColorTarget) => {+ // A pair chip always returns the pane to the pair, disarming the tint.+ clearMaskTintTarget();+ onSelectTarget(next);+ },+ [onSelectTarget]+ );+ const armTint = useCallback(() => {+ if (selectedMask) {+ armMaskTintTarget(selectedMask.id);+ }+ }, [selectedMask]);return (<HStack flexShrink={0} gap="1" mr="1"><TargetChipcolorHex={pair.foreground}- isActive={target === 'foreground'}+ isActive={!maskTint && target === 'foreground'}label={t('widgets.layers.colorPane.foreground')}target="foreground"- onSelect={onSelectTarget}+ onSelect={selectPairTarget}/><TargetChipcolorHex={pair.background}- isActive={target === 'background'}+ isActive={!maskTint && target === 'background'}label={t('widgets.layers.colorPane.background')}target="background"- onSelect={onSelectTarget}+ onSelect={selectPairTarget}/>+ {selectedMask ? (+ // Revealed by a compatible selection, activated only explicitly.+ <TargetChip+ colorHex={maskTint?.color ?? selectedMask.color}+ isActive={maskTint !== null}+ label={t('widgets.layers.colorPane.maskTint')}+ target="foreground"+ onSelect={armTint}+ />+ ) : null}</HStack>);};diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerEditorPanes.browser.test.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerEditorPanes.browser.test.tsxindex 3af266199f..0190e2cad4 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerEditorPanes.browser.test.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/LayerEditorPanes.browser.test.tsx@@ -75,6 +75,8 @@ vi.mock('@workbench/useCanvasProjectMutationDispatch', () => ({}));vi.mock('@workbench/widgets/canvas/useCanvasEngine', () => ({ useCanvasEngine: () => harness.engine }));+import { clearMaskTintTarget } from '@workbench/widgets/canvas/color-system/maskTintTarget';+import type { LayerEditorPaneLayout, LayerTreeTabId } from './editorPaneLayout';import { ColorPane } from './ColorPane';@@ -174,7 +176,7 @@ const settle = () =>const IDENTITY = { rotation: 0, scaleX: 1, scaleY: 1, x: 0, y: 0 };-type Selection = 'none' | 'layer' | 'group';+type Selection = 'none' | 'layer' | 'group' | 'mask';const mount = async (View: typeof PropertiesPane, selection: Selection = 'none') => {const base = { ...createInitialWorkbenchState().projects[0]!, id: 'p' };@@ -183,11 +185,13 @@ const mount = async (View: typeof PropertiesPane, selection: Selection = 'none')? []: selection === 'layer'? [layerContract('l0', 'raster', { name: 'Paint', transform: { ...IDENTITY, rotation: 0.5, x: 10.4 } })]- : [groupContract('g0', [layerContract('l0', 'raster', { name: 'Paint' })], { name: 'Folder' })];+ : selection === 'mask'+ ? [layerContract('m0', 'inpaint_mask', { name: 'Mask' })]+ : [groupContract('g0', [layerContract('l0', 'raster', { name: 'Paint' })], { name: 'Folder' })];harness.project = applyCanvasProjectMutation(base, {document: {...createEmptyCanvasDocument(),- selectedLayerId: selection === 'none' ? null : selection === 'layer' ? 'l0' : 'g0',+ selectedLayerId: selection === 'none' ? null : selection === 'layer' ? 'l0' : selection === 'mask' ? 'm0' : 'g0',stacks: stacksFrom(nodes),},type: 'replaceCanvasDocument',@@ -399,6 +403,32 @@ describe('Color pane', () => {expect(canvasValues().activeColors).toEqual({ background: '#000000', foreground: '#ffffff' });});+ it('reveals the Mask Tint target for a selected mask and arms it only explicitly', async () => {+ clearMaskTintTarget();+ await mount(ColorPane, 'mask');+ const tintChip = page.getByRole('button', { exact: true, name: 'Mask tint' });+ await expect.element(tintChip).toBeVisible();+ // Revealed, not switched: the pair target keeps the wheel until armed.+ await expect.element(tintChip).toHaveAttribute('aria-pressed', 'false');+ const foreground = page.getByRole('button', { exact: true, name: 'Foreground color' });+ await expect.element(foreground).toHaveAttribute('aria-pressed', 'true');+ await act(async () => {+ await userEvent.click(tintChip);+ });+ await expect.element(tintChip).toHaveAttribute('aria-pressed', 'true');+ await expect.element(foreground).toHaveAttribute('aria-pressed', 'false');+ // The armed target shows the mask's tint, not the pair.+ expect((page.getByRole('textbox', { exact: true, name: 'Hex color' }).element() as HTMLInputElement).value).toBe(+ '#e07575'+ );+ // A pair chip disarms the tint and returns to the pair.+ await act(async () => {+ await userEvent.click(foreground);+ });+ await expect.element(tintChip).toHaveAttribute('aria-pressed', 'false');+ await expect.element(foreground).toHaveAttribute('aria-pressed', 'true');+ });+it('writes swatch picks to the active target', async () => {await mount(SwatchesPane);await act(async () => {diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/SwatchesPane.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/SwatchesPane.tsxindex a9330b14b0..d61508d2d6 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/SwatchesPane.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/SwatchesPane.tsx@@ -13,6 +13,8 @@ import {useActiveColorTarget,useColorPalette,} from '@workbench/widgets/canvas/color-system/useActiveColors';+import { useMaskTintEditor } from '@workbench/widgets/canvas/color-system/useMaskTintEditor';+import { useCanvasEngine } from '@workbench/widgets/canvas/useCanvasEngine';import { PlusIcon } from 'lucide-react';import { useCallback, useMemo } from 'react';import { useTranslation } from 'react-i18next';@@ -24,12 +26,15 @@ import { useTranslation } from 'react-i18next';*/export const SwatchesPane = () => {const { t } = useTranslation();+ const engine = useCanvasEngine();const pair = useActiveColorPair();const target = useActiveColorTarget();const palette = useColorPalette();const commands = useActiveColorCommands();const recents = useRecentColors();- const activeHex = pair[target];+ // The shelves write the pane's active target — the armed mask tint included.+ const maskTint = useMaskTintEditor(engine);+ const activeHex = maskTint ? maskTint.color : pair[target];const applyHex = useCallback((hex: string) => {@@ -39,10 +44,14 @@ export const SwatchesPane = () => {// Flattened like the pair itself, so a pick (even of a legacy alpha// recent) records what it actually sets.const opaque = formatHexColor(parseHexColor(hex));- commands.setPairColor(target, opaque);+ if (maskTint) {+ maskTint.commit(opaque);+ } else {+ commands.setPairColor(target, opaque);+ }recordRecentColor(opaque);},- [commands, target]+ [commands, maskTint, target]);const addToPalette = useCallback(() => commands.addPaletteColor(activeHex), [activeHex, commands]);const removeFromPalette = useCallback((color: string) => commands.removePaletteColor(color), [commands]);