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(properties): geometry and selection forms with a sticky transform footer (U2)
Josh Corbett4c01eb026bf9
diff --git a/invokeai/frontend/webv2/performance/browser-baseline.json b/invokeai/frontend/webv2/performance/browser-baseline.jsonindex 04acd3439a..738c92612a 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": 117.29999999701977,+ "domContentLoadedMedianMs": 117.59999999403954,"id": "launchpad","layoutAckMedianMs": 0,"layoutReturnSwitchMedianMs": 0,"layoutSwitchMedianMs": 0,- "loadMedianMs": 117.40000000596046,- "longestTaskMaxMs": 80,+ "loadMedianMs": 117.69999998807907,+ "longestTaskMaxMs": 72,"owner": "app","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:launchpad",@@ -41,24 +41,24 @@"fontRawBytes": 23664,"imageRawBytes": 0,"largestAssetRawBytes": 746376,- "otherRawBytes": 161604,+ "otherRawBytes": 161666,"requestCount": 38,"scriptRawBytes": 1636198,"scriptRequestCount": 34,- "totalRawBytes": 1823625+ "totalRawBytes": 1823687},"resourceLimits": {"cssRawBytes": 2181,"fontRawBytes": 23901,"imageRawBytes": 0,"largestAssetRawBytes": 753840,- "otherRawBytes": 163221,+ "otherRawBytes": 163283,"requestCount": 38,"scriptRawBytes": 1652560,"scriptRequestCount": 34,- "totalRawBytes": 1841862+ "totalRawBytes": 1841924},- "routeReadyMedianMs": 261.29999999701977,+ "routeReadyMedianMs": 260.8999999910593,"scriptSourceOwnerSet": "launchpad-static","stateProfile": "empty"},@@ -85,13 +85,13 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 116,+ "domContentLoadedMedianMs": 112.5,"id": "launchpad","layoutAckMedianMs": 0,"layoutReturnSwitchMedianMs": 0,"layoutSwitchMedianMs": 0,- "loadMedianMs": 116.09999999403954,- "longestTaskMaxMs": 70,+ "loadMedianMs": 112.6000000089407,+ "longestTaskMaxMs": 68,"owner": "app","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:launchpad",@@ -101,24 +101,24 @@"fontRawBytes": 23664,"imageRawBytes": 0,"largestAssetRawBytes": 746376,- "otherRawBytes": 161604,+ "otherRawBytes": 161666,"requestCount": 38,"scriptRawBytes": 1636198,"scriptRequestCount": 34,- "totalRawBytes": 1823625+ "totalRawBytes": 1823687},"resourceLimits": {"cssRawBytes": 2181,"fontRawBytes": 23901,"imageRawBytes": 0,"largestAssetRawBytes": 753840,- "otherRawBytes": 163221,+ "otherRawBytes": 163283,"requestCount": 38,"scriptRawBytes": 1652560,"scriptRequestCount": 34,- "totalRawBytes": 1841862+ "totalRawBytes": 1841924},- "routeReadyMedianMs": 279,+ "routeReadyMedianMs": 269,"scriptSourceOwnerSet": "launchpad-static","stateProfile": "representative"},@@ -145,15 +145,15 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 116.70000000298023,+ "domContentLoadedMedianMs": 114.90000000596046,"id": "editor-minimal","layoutAckMedianMs": 0,"layoutReturnSwitchMedianMs": 0,"layoutSwitchMedianMs": 0,- "loadMedianMs": 116.70000000298023,- "longestTaskMaxMs": 97,+ "loadMedianMs": 114.90000000596046,+ "longestTaskMaxMs": 93,"owner": "workbench",- "projectSwitchMedianMs": 36.20000000298023,+ "projectSwitchMedianMs": 35.70000000298023,"readyMark": "invokeai:ready:widget:center:preview","remediationTicket": "deepen-widget-registry-loading","resourceBaseline": {@@ -161,24 +161,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746376,- "otherRawBytes": 161604,+ "otherRawBytes": 161666,"requestCount": 115,"scriptRawBytes": 3286480,"scriptRequestCount": 110,- "totalRawBytes": 3630283+ "totalRawBytes": 3630345},"resourceLimits": {"cssRawBytes": 2181,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 753840,- "otherRawBytes": 163221,+ "otherRawBytes": 163283,"requestCount": 115,"scriptRawBytes": 3319345,"scriptRequestCount": 110,- "totalRawBytes": 3666586+ "totalRawBytes": 3666649},- "routeReadyMedianMs": 667.0999999940395,+ "routeReadyMedianMs": 659.9000000059605,"scriptSourceOwnerSet": "editor-minimal-static","stateProfile": "empty"},@@ -205,15 +205,15 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 114.40000000596046,+ "domContentLoadedMedianMs": 115.09999999403954,"id": "editor-minimal","layoutAckMedianMs": 0,"layoutReturnSwitchMedianMs": 0,"layoutSwitchMedianMs": 0,- "loadMedianMs": 114.6000000089407,- "longestTaskMaxMs": 178,+ "loadMedianMs": 115.20000000298023,+ "longestTaskMaxMs": 179,"owner": "workbench",- "projectSwitchMedianMs": 71.40000000596046,+ "projectSwitchMedianMs": 67.79999999701977,"readyMark": "invokeai:ready:widget:center:preview","remediationTicket": "deepen-widget-registry-loading","resourceBaseline": {@@ -221,24 +221,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746376,- "otherRawBytes": 161604,+ "otherRawBytes": 161666,"requestCount": 115,"scriptRawBytes": 3286480,"scriptRequestCount": 110,- "totalRawBytes": 3630283+ "totalRawBytes": 3630345},"resourceLimits": {"cssRawBytes": 2181,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 753840,- "otherRawBytes": 163221,+ "otherRawBytes": 163283,"requestCount": 115,"scriptRawBytes": 3319345,"scriptRequestCount": 110,- "totalRawBytes": 3666586+ "totalRawBytes": 3666649},- "routeReadyMedianMs": 445,+ "routeReadyMedianMs": 428.79999999701977,"scriptSourceOwnerSet": "editor-minimal-static","stateProfile": "representative"},@@ -247,31 +247,31 @@"cssRawBytes": 0,"fontRawBytes": 0,"imageRawBytes": 0,- "largestAssetRawBytes": 313135,+ "largestAssetRawBytes": 311835,"otherRawBytes": 0,"requestCount": 7,- "scriptRawBytes": 472760,+ "scriptRawBytes": 471460,"scriptRequestCount": 7,- "totalRawBytes": 472760+ "totalRawBytes": 471460},"activatedResourceLimits": {"cssRawBytes": 0,"fontRawBytes": 0,"imageRawBytes": 0,- "largestAssetRawBytes": 316267,+ "largestAssetRawBytes": 314954,"otherRawBytes": 0,"requestCount": 7,- "scriptRawBytes": 477488,+ "scriptRawBytes": 476175,"scriptRequestCount": 7,- "totalRawBytes": 477488+ "totalRawBytes": 476175},- "domContentLoadedMedianMs": 120.3999999910593,+ "domContentLoadedMedianMs": 113.20000000298023,"id": "editor-canvas",- "layoutAckMedianMs": 2.2000000029802322,- "layoutReturnSwitchMedianMs": 55,- "layoutSwitchMedianMs": 86.70000000298023,- "loadMedianMs": 120.59999999403954,- "longestTaskMaxMs": 124,+ "layoutAckMedianMs": 2.1000000089406967,+ "layoutReturnSwitchMedianMs": 52.6000000089407,+ "layoutSwitchMedianMs": 82,+ "loadMedianMs": 113.30000001192093,+ "longestTaskMaxMs": 122,"owner": "canvas","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:canvas",@@ -281,24 +281,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746376,- "otherRawBytes": 161604,+ "otherRawBytes": 161666,"requestCount": 122,- "scriptRawBytes": 3759240,+ "scriptRawBytes": 3757940,"scriptRequestCount": 117,- "totalRawBytes": 4103043+ "totalRawBytes": 4101805},"resourceLimits": {"cssRawBytes": 2181,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 753840,- "otherRawBytes": 163221,+ "otherRawBytes": 163283,"requestCount": 122,- "scriptRawBytes": 3796833,+ "scriptRawBytes": 3795520,"scriptRequestCount": 117,- "totalRawBytes": 4144074+ "totalRawBytes": 4142824},- "routeReadyMedianMs": 1056.2999999970198,+ "routeReadyMedianMs": 1037.4000000059605,"scriptSourceOwnerSet": "editor-canvas-static","stateProfile": "empty"},@@ -307,31 +307,31 @@"cssRawBytes": 0,"fontRawBytes": 0,"imageRawBytes": 0,- "largestAssetRawBytes": 313135,+ "largestAssetRawBytes": 311835,"otherRawBytes": 0,"requestCount": 7,- "scriptRawBytes": 472760,+ "scriptRawBytes": 471460,"scriptRequestCount": 7,- "totalRawBytes": 472760+ "totalRawBytes": 471460},"activatedResourceLimits": {"cssRawBytes": 0,"fontRawBytes": 0,"imageRawBytes": 0,- "largestAssetRawBytes": 316267,+ "largestAssetRawBytes": 314954,"otherRawBytes": 0,"requestCount": 7,- "scriptRawBytes": 477488,+ "scriptRawBytes": 476175,"scriptRequestCount": 7,- "totalRawBytes": 477488+ "totalRawBytes": 476175},- "domContentLoadedMedianMs": 114.90000000596046,+ "domContentLoadedMedianMs": 111.6000000089407,"id": "editor-canvas",- "layoutAckMedianMs": 2.5,- "layoutReturnSwitchMedianMs": 45.70000000298023,- "layoutSwitchMedianMs": 83.5,- "loadMedianMs": 115,- "longestTaskMaxMs": 182,+ "layoutAckMedianMs": 2.7000000029802322,+ "layoutReturnSwitchMedianMs": 43.79999999701977,+ "layoutSwitchMedianMs": 92.20000000298023,+ "loadMedianMs": 111.70000000298023,+ "longestTaskMaxMs": 179,"owner": "canvas","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:canvas",@@ -341,24 +341,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746376,- "otherRawBytes": 161604,+ "otherRawBytes": 161666,"requestCount": 122,- "scriptRawBytes": 3759240,+ "scriptRawBytes": 3757940,"scriptRequestCount": 117,- "totalRawBytes": 4103043+ "totalRawBytes": 4101805},"resourceLimits": {"cssRawBytes": 2181,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 753840,- "otherRawBytes": 163221,+ "otherRawBytes": 163283,"requestCount": 122,- "scriptRawBytes": 3796833,+ "scriptRawBytes": 3795520,"scriptRequestCount": 117,- "totalRawBytes": 4144074+ "totalRawBytes": 4142824},- "routeReadyMedianMs": 1137.5,+ "routeReadyMedianMs": 1120.5,"scriptSourceOwnerSet": "editor-canvas-static","stateProfile": "representative"},@@ -385,13 +385,13 @@"scriptRequestCount": 6,"totalRawBytes": 383447},- "domContentLoadedMedianMs": 115,+ "domContentLoadedMedianMs": 112.19999998807907,"id": "editor-workflow",- "layoutAckMedianMs": 2.2000000029802322,- "layoutReturnSwitchMedianMs": 33.6000000089407,- "layoutSwitchMedianMs": 91.6000000089407,- "loadMedianMs": 115,- "longestTaskMaxMs": 97,+ "layoutAckMedianMs": 2.3999999910593033,+ "layoutReturnSwitchMedianMs": 32.5,+ "layoutSwitchMedianMs": 90.6000000089407,+ "loadMedianMs": 112.3999999910593,+ "longestTaskMaxMs": 98,"owner": "workflow","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:workflow",@@ -401,24 +401,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746376,- "otherRawBytes": 161604,+ "otherRawBytes": 161666,"requestCount": 122,"scriptRawBytes": 3650717,"scriptRequestCount": 116,- "totalRawBytes": 4009933+ "totalRawBytes": 4009995},"resourceLimits": {"cssRawBytes": 17748,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 753840,- "otherRawBytes": 163221,+ "otherRawBytes": 163283,"requestCount": 122,"scriptRawBytes": 3687225,"scriptRequestCount": 116,- "totalRawBytes": 4050033+ "totalRawBytes": 4050095},- "routeReadyMedianMs": 1042,+ "routeReadyMedianMs": 1049.699999988079,"scriptSourceOwnerSet": "editor-workflow-static","stateProfile": "empty"},@@ -445,13 +445,13 @@"scriptRequestCount": 6,"totalRawBytes": 383447},- "domContentLoadedMedianMs": 114.80000001192093,+ "domContentLoadedMedianMs": 114,"id": "editor-workflow",- "layoutAckMedianMs": 2.5999999940395355,- "layoutReturnSwitchMedianMs": 40.3999999910593,- "layoutSwitchMedianMs": 122.40000000596046,- "loadMedianMs": 114.80000001192093,- "longestTaskMaxMs": 343,+ "layoutAckMedianMs": 2.300000011920929,+ "layoutReturnSwitchMedianMs": 39.6000000089407,+ "layoutSwitchMedianMs": 123.59999999403954,+ "loadMedianMs": 114.1000000089407,+ "longestTaskMaxMs": 333,"owner": "workflow","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:workflow",@@ -461,24 +461,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746376,- "otherRawBytes": 161604,+ "otherRawBytes": 161666,"requestCount": 122,"scriptRawBytes": 3650717,"scriptRequestCount": 116,- "totalRawBytes": 4009933+ "totalRawBytes": 4009995},"resourceLimits": {"cssRawBytes": 17748,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 753840,- "otherRawBytes": 163221,+ "otherRawBytes": 163283,"requestCount": 122,"scriptRawBytes": 3687225,"scriptRequestCount": 116,- "totalRawBytes": 4050033+ "totalRawBytes": 4050095},- "routeReadyMedianMs": 1184.300000011921,+ "routeReadyMedianMs": 1172.699999988079,"scriptSourceOwnerSet": "editor-workflow-static","stateProfile": "representative"},@@ -505,13 +505,13 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 117.59999999403954,+ "domContentLoadedMedianMs": 115.90000000596046,"id": "editor-gallery","layoutAckMedianMs": 0,"layoutReturnSwitchMedianMs": 0,- "layoutSwitchMedianMs": 26.799999997019768,- "loadMedianMs": 117.79999999701977,- "longestTaskMaxMs": 95,+ "layoutSwitchMedianMs": 25.299999997019768,+ "loadMedianMs": 116,+ "longestTaskMaxMs": 96,"owner": "gallery","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:gallery",@@ -521,24 +521,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746376,- "otherRawBytes": 161604,+ "otherRawBytes": 161666,"requestCount": 115,"scriptRawBytes": 3286480,"scriptRequestCount": 110,- "totalRawBytes": 3630283+ "totalRawBytes": 3630345},"resourceLimits": {"cssRawBytes": 2181,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 753840,- "otherRawBytes": 163221,+ "otherRawBytes": 163283,"requestCount": 115,"scriptRawBytes": 3319345,"scriptRequestCount": 110,- "totalRawBytes": 3666586+ "totalRawBytes": 3666649},- "routeReadyMedianMs": 1267.9000000059605,+ "routeReadyMedianMs": 1259.2999999970198,"scriptSourceOwnerSet": "editor-minimal-static","stateProfile": "empty"},@@ -565,13 +565,13 @@"scriptRequestCount": 0,"totalRawBytes": 0},- "domContentLoadedMedianMs": 116.6000000089407,+ "domContentLoadedMedianMs": 113.79999999701977,"id": "editor-gallery","layoutAckMedianMs": 0,"layoutReturnSwitchMedianMs": 0,- "layoutSwitchMedianMs": 88.5,- "loadMedianMs": 116.70000000298023,- "longestTaskMaxMs": 174,+ "layoutSwitchMedianMs": 84,+ "loadMedianMs": 113.79999999701977,+ "longestTaskMaxMs": 175,"owner": "gallery","projectSwitchMedianMs": 0,"readyMark": "invokeai:ready:widget:center:gallery",@@ -581,24 +581,24 @@"fontRawBytes": 23664,"imageRawBytes": 156376,"largestAssetRawBytes": 746376,- "otherRawBytes": 161604,+ "otherRawBytes": 161666,"requestCount": 115,"scriptRawBytes": 3286480,"scriptRequestCount": 110,- "totalRawBytes": 3630283+ "totalRawBytes": 3630345},"resourceLimits": {"cssRawBytes": 2181,"fontRawBytes": 23901,"imageRawBytes": 157940,"largestAssetRawBytes": 753840,- "otherRawBytes": 163221,+ "otherRawBytes": 163283,"requestCount": 115,"scriptRawBytes": 3319345,"scriptRequestCount": 110,- "totalRawBytes": 3666586+ "totalRawBytes": 3666649},- "routeReadyMedianMs": 1447.1000000089407,+ "routeReadyMedianMs": 1426.5,"scriptSourceOwnerSet": "editor-minimal-static","stateProfile": "representative"}@@ -2823,22 +2823,19 @@"source:src/workbench/widgets/canvas/manifest.ts","source:src/workbench/widgets/canvas/stagingPreview.ts","source:src/workbench/widgets/canvas/surfaceFocus.ts",- "source:src/workbench/widgets/canvas/tool-options/BboxOptions.tsx","source:src/workbench/widgets/canvas/tool-options/BrushOptions.tsx","source:src/workbench/widgets/canvas/tool-options/CanvasOptionsBar.tsx","source:src/workbench/widgets/canvas/tool-options/FilterOptions.tsx","source:src/workbench/widgets/canvas/tool-options/GradientOptions.tsx",- "source:src/workbench/widgets/canvas/tool-options/LassoOptions.tsx",- "source:src/workbench/widgets/canvas/tool-options/MarqueeOptions.tsx",- "source:src/workbench/widgets/canvas/tool-options/MoveOptions.tsx","source:src/workbench/widgets/canvas/tool-options/OperationStatusSlot.tsx","source:src/workbench/widgets/canvas/tool-options/SamOptions.tsx","source:src/workbench/widgets/canvas/tool-options/SelectionOptionsRow.tsx","source:src/workbench/widgets/canvas/tool-options/ShapeOptions.tsx","source:src/workbench/widgets/canvas/tool-options/TextOptions.tsx",- "source:src/workbench/widgets/canvas/tool-options/TransformOptions.tsx",+ "source:src/workbench/widgets/canvas/tool-options/geometryForm.tsx","source:src/workbench/widgets/canvas/tool-options/gradientStops.ts","source:src/workbench/widgets/canvas/tool-options/paintForm.tsx",+ "source:src/workbench/widgets/canvas/tool-options/selectionForm.tsx","source:src/workbench/widgets/canvas/tool-options/useBboxEditor.ts","source:src/workbench/widgets/canvas/tool-presentation/PropertyPrimitives.tsx","source:src/workbench/widgets/canvas/tool-presentation/ToolbarPrimitives.tsx",diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.jsonindex ac94beb327..327f002518 100644--- a/invokeai/frontend/webv2/public/locales/en.json+++ b/invokeai/frontend/webv2/public/locales/en.json@@ -1531,7 +1531,9 @@"gradient": "Gradient","stops": "Stops","font": "Font",- "paragraph": "Paragraph"+ "paragraph": "Paragraph",+ "frame": "Frame",+ "selection": "Selection"},"foreground": "Foreground","target": {@@ -1554,7 +1556,10 @@"size": "Size","weight": "Weight","lineHeight": "Leading",- "align": "Align"+ "align": "Align",+ "aspect": "Aspect",+ "shape": "Shape",+ "mode": "Mode"},"sections": {"operation": "Operation",@@ -2315,7 +2320,6 @@"fitBboxToLayers": "Fit frame to layers","fitBboxToMasks": "Fit frame to masks","fitToView": "Fit to view",- "frameSize": "Generation frame size","newCanvas": "New canvas","newCanvasConfirm": "Clear all layers and start a fresh canvas? This cannot be undone.","newSession": "New session",@@ -2421,7 +2425,6 @@"eraserSize": "Eraser size","fillSelection": "Fill","frameHeight": "H",- "frameSize": "Frame","frameWidth": "W","gradientAngle": "Angle","gradientEdit": "Edit gradient",diff --git a/invokeai/frontend/webv2/src/workbench/canvasDimsSync.ts b/invokeai/frontend/webv2/src/workbench/canvasDimsSync.tsindex ba732b183a..8deccd72bc 100644--- a/invokeai/frontend/webv2/src/workbench/canvasDimsSync.ts+++ b/invokeai/frontend/webv2/src/workbench/canvasDimsSync.ts@@ -5,7 +5,7 @@** Legacy-compatible geometry: the generation frame remains the exact final* canvas footprint, including off-grid sizes. Resizing the bbox (tool gesture,- * BboxOptions, undo/redo) drives width/height snapped to the selected model's+ * the frame form, undo/redo) drives width/height snapped to the selected model's* hard processing grid; the canvas graph resizes inputs to that processing size* and the result back to the bbox. Unlike legacy's optional "Scale Before* Processing" policy, this does not silently upscale small bboxes to an optimaldiff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/BboxOptions.tsx b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/BboxOptions.tsxdeleted file mode 100644index 41e78c6acd..0000000000--- a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/BboxOptions.tsx+++ /dev/null@@ -1,114 +0,0 @@-import type { AspectRatioId } from '@features/generation/contracts';-import type {- ToolbarRegionProps,- ToolPresentationAdapter,-} from '@workbench/widgets/canvas/tool-presentation/toolbarContracts';--import { AspectRatioLockButton, AspectRatioSelect } from '@features/generation/components';-import { ASPECT_RATIO_MAP, deriveAspectRatioId } from '@features/generation/settings';-import { constrainBboxToRatio } from '@workbench/canvas-engine/api';-import { ToolbarNumberField, useNumberCommit } from '@workbench/widgets/canvas/tool-presentation/ToolbarPrimitives';-import { useCallback } from 'react';-import { useTranslation } from 'react-i18next';--import { useBboxEditor } from './useBboxEditor';--const ASPECT_TRIGGER_PROPS = { minW: '7.5rem' } as const;--/** X / Y share the Move and Transform slots. Every edit is one undoable frame commit. */-const FramePosition = ({ engine }: ToolbarRegionProps) => {- const { t } = useTranslation();- const { bbox, setX, setY } = useBboxEditor(engine);- const onX = useNumberCommit(setX);- const onY = useNumberCommit(setY);- return (- <>- <ToolbarNumberField- aria-label={t('widgets.canvas.toolOptions.positionX')}- label={t('widgets.canvas.toolOptions.positionX')}- value={String(bbox.x)}- onValueCommit={onX}- />- <ToolbarNumberField- aria-label={t('widgets.canvas.toolOptions.positionY')}- label={t('widgets.canvas.toolOptions.positionY')}- value={String(bbox.y)}- onValueCommit={onY}- />- </>- );-};--/**- * Frame size, aspect preset and lock; the preset controls are the generate- * widget's, so both surfaces offer the same presets (`canvasDimsSync` keeps- * them aligned). The lock is an engine setting; choosing a preset also- * reshapes the frame in place as one undoable commit.- */-const FrameSize = ({ engine }: ToolbarRegionProps) => {- const { t } = useTranslation();- const { bbox, commitBbox, grid, options, setHeight, setWidth } = useBboxEditor(engine);- const onWidth = useNumberCommit(setWidth);- const onHeight = useNumberCommit(setHeight);- const bboxRatio = bbox.height > 0 ? bbox.width / bbox.height : 1;- // Derived from the live frame so a lock captured from a hand-drawn bbox reports the preset it matches.- const selectedId: AspectRatioId = options.aspectLocked ? deriveAspectRatioId(bbox.width, bbox.height) : 'Free';-- const onAspectPresetChange = useCallback(- (id: AspectRatioId) => {- if (id === 'Free') {- engine.interaction.set('bboxOptions', { ...options, aspectLocked: false });- return;- }- const ratio = ASPECT_RATIO_MAP[id].ratio;- engine.interaction.set('bboxOptions', { aspectLocked: true, aspectRatio: ratio });- commitBbox(constrainBboxToRatio(bbox, ratio, grid));- },- [bbox, commitBbox, engine, grid, options]- );-- const onLockToggle = useCallback(() => {- const checked = !options.aspectLocked;- // Locking a frame that matches no preset captures its current ratio.- const aspectRatio =- checked && bbox.height > 0 && deriveAspectRatioId(bbox.width, bbox.height) === 'Free'- ? bboxRatio- : options.aspectRatio > 0- ? options.aspectRatio- : 1;- engine.interaction.set('bboxOptions', { aspectLocked: checked, aspectRatio });- }, [bbox, bboxRatio, engine, options.aspectLocked, options.aspectRatio]);-- return (- <>- <ToolbarNumberField- aria-label={t('widgets.canvas.toolOptions.frameWidth')}- label={t('widgets.canvas.toolOptions.frameWidth')}- min={1}- value={String(bbox.width)}- onValueCommit={onWidth}- />- <ToolbarNumberField- aria-label={t('widgets.canvas.toolOptions.frameHeight')}- label={t('widgets.canvas.toolOptions.frameHeight')}- min={1}- value={String(bbox.height)}- onValueCommit={onHeight}- />- <AspectRatioSelect- fallbackRatio={bboxRatio}- triggerProps={ASPECT_TRIGGER_PROPS}- value={selectedId}- onChange={onAspectPresetChange}- />- <AspectRatioLockButton isLocked={options.aspectLocked} onToggle={onLockToggle} />- </>- );-};--export const bboxAdapter: ToolPresentationAdapter = {- rowLabels: { geometry: 'widgets.transform.position', modes: 'widgets.canvas.toolOptions.frameSize' },- geometry: FramePosition,- id: 'bbox',- modes: FrameSize,-};diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/LassoOptions.tsx b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/LassoOptions.tsxdeleted file mode 100644index 66204e6f6f..0000000000--- a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/LassoOptions.tsx+++ /dev/null@@ -1,82 +0,0 @@-import type { SelectValueChangeDetails } from '@chakra-ui/react';-import type { LassoToolOptions, SelectionOp } from '@workbench/canvas-engine/api';-import type {- ToolbarRegionProps,- ToolPresentationAdapter,-} from '@workbench/widgets/canvas/tool-presentation/toolbarContracts';--import { createListCollection } from '@chakra-ui/react';-import { Select } from '@platform/ui/Select';-import { useLassoOptions } from '@workbench/widgets/canvas/engineStoreHooks';-import { useCallback, useMemo } from 'react';-import { useTranslation } from 'react-i18next';--import { SelectionActions, SelectionModes } from './SelectionOptionsRow';--type LassoShape = LassoToolOptions['shape'];--const SELECT_POSITIONING = { placement: 'bottom-start', sameWidth: false } as const;-const SELECT_TRIGGER_PROPS = { minW: '6rem', w: '6rem' } as const;--/** How the path is drawn (freehand drag / polygon clicks), then the shared selection op mode. */-const LassoModes = ({ engine, isSurfaceInteractionLocked }: ToolbarRegionProps) => {- const { t } = useTranslation();- const options = useLassoOptions(engine);- const shapeCollection = useMemo(- () =>- createListCollection<{ label: string; value: LassoShape }>({- items: [- { label: t('widgets.canvas.toolOptions.lassoFreehand'), value: 'freehand' },- { label: t('widgets.canvas.toolOptions.lassoPolygon'), value: 'polygon' },- ],- }),- [t]- );- const shapeValue = useMemo(() => [options.shape], [options.shape]);- const onShapeChange = useCallback(- ({ value }: SelectValueChangeDetails<{ label: string; value: LassoShape }>) => {- const next = value[0] as LassoShape | undefined;- if (next && next !== options.shape) {- engine.interaction.set('lassoOptions', { ...options, shape: next });- }- },- [engine, options]- );- const onModeChange = useCallback(- (mode: SelectionOp) => engine.interaction.set('lassoOptions', { ...options, mode }),- [engine, options]- );- return (- <>- <Select- aria-label={t('widgets.canvas.toolOptions.lassoShape')}- collection={shapeCollection}- positioning={SELECT_POSITIONING}- size="xs"- flexShrink={0}- triggerProps={SELECT_TRIGGER_PROPS}- w="6rem"- value={shapeValue}- onValueChange={onShapeChange}- />- <SelectionModes- engine={engine}- hintKey={- options.shape === 'polygon'- ? 'widgets.canvas.toolOptions.lassoPolygonHint'- : 'widgets.canvas.toolOptions.lassoHint'- }- isSurfaceInteractionLocked={isSurfaceInteractionLocked}- mode={options.mode}- onModeChange={onModeChange}- />- </>- );-};--export const lassoAdapter: ToolPresentationAdapter = {- rowLabels: { modes: 'widgets.canvas.toolOptions.selectionMode', more: 'widgets.canvas.toolOptions.selectionActions' },- id: 'lasso',- modes: LassoModes,- more: SelectionActions,-};diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/MarqueeOptions.tsx b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/MarqueeOptions.tsxdeleted file mode 100644index 1340e81082..0000000000--- a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/MarqueeOptions.tsx+++ /dev/null@@ -1,78 +0,0 @@-import type { SelectValueChangeDetails } from '@chakra-ui/react';-import type { MarqueeToolOptions, SelectionOp } from '@workbench/canvas-engine/api';-import type {- ToolbarRegionProps,- ToolPresentationAdapter,-} from '@workbench/widgets/canvas/tool-presentation/toolbarContracts';--import { createListCollection } from '@chakra-ui/react';-import { Select } from '@platform/ui/Select';-import { useMarqueeOptions } from '@workbench/widgets/canvas/engineStoreHooks';-import { useCallback, useMemo } from 'react';-import { useTranslation } from 'react-i18next';--import { SelectionActions, SelectionModes } from './SelectionOptionsRow';--type MarqueeKind = MarqueeToolOptions['kind'];--const SELECT_POSITIONING = { placement: 'bottom-start', sameWidth: false } as const;-const SELECT_TRIGGER_PROPS = { minW: '6rem', w: '6rem' } as const;--/** The shape the next drag traces (rectangle / ellipse), then the shared selection op mode. */-const MarqueeModes = ({ engine, isSurfaceInteractionLocked }: ToolbarRegionProps) => {- const { t } = useTranslation();- const options = useMarqueeOptions(engine);- const kindCollection = useMemo(- () =>- createListCollection<{ label: string; value: MarqueeKind }>({- items: [- { label: t('widgets.canvas.toolOptions.shapeRect'), value: 'rect' },- { label: t('widgets.canvas.toolOptions.shapeEllipse'), value: 'ellipse' },- ],- }),- [t]- );- const kindValue = useMemo(() => [options.kind], [options.kind]);- const onKindChange = useCallback(- ({ value }: SelectValueChangeDetails<{ label: string; value: MarqueeKind }>) => {- const next = value[0] as MarqueeKind | undefined;- if (next && next !== options.kind) {- engine.interaction.set('marqueeOptions', { ...options, kind: next });- }- },- [engine, options]- );- const onModeChange = useCallback(- (mode: SelectionOp) => engine.interaction.set('marqueeOptions', { ...options, mode }),- [engine, options]- );- return (- <>- <Select- aria-label={t('widgets.canvas.toolOptions.marqueeKind')}- collection={kindCollection}- positioning={SELECT_POSITIONING}- size="xs"- flexShrink={0}- triggerProps={SELECT_TRIGGER_PROPS}- w="6rem"- value={kindValue}- onValueChange={onKindChange}- />- <SelectionModes- engine={engine}- hintKey="widgets.canvas.toolOptions.marqueeHint"- isSurfaceInteractionLocked={isSurfaceInteractionLocked}- mode={options.mode}- onModeChange={onModeChange}- />- </>- );-};--export const marqueeAdapter: ToolPresentationAdapter = {- rowLabels: { modes: 'widgets.canvas.toolOptions.selectionMode', more: 'widgets.canvas.toolOptions.selectionActions' },- id: 'marquee',- modes: MarqueeModes,- more: SelectionActions,-};diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/MoveOptions.tsx b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/MoveOptions.tsxdeleted file mode 100644index a797ab14d8..0000000000--- a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/MoveOptions.tsx+++ /dev/null@@ -1,85 +0,0 @@-import type {- ToolbarRegionProps,- ToolPresentationAdapter,-} from '@workbench/widgets/canvas/tool-presentation/toolbarContracts';--import { lookupDocumentLeaf } from '@workbench/canvas-engine/api';-import { ToolbarNumberField, useNumberCommit } from '@workbench/widgets/canvas/tool-presentation/ToolbarPrimitives';-import { usePreparedCommit } from '@workbench/widgets/canvas/useStructuralCommit';-import { useActiveProjectSelector } from '@workbench/WorkbenchContext';-import { useCallback } from 'react';-import { useTranslation } from 'react-i18next';--interface SelectedTransform {- id: string;- x: number;- y: number;-}--/**- * Numeric X / Y of the selected layer in document pixels. Reads the committed- * transform and writes each edit through the engine's structural history, so- * it shares the undo stack with drags and nudges. Disabled with no editable- * selection.- */-const MovePosition = ({ engine }: ToolbarRegionProps) => {- const { t } = useTranslation();- const commitPrepared = usePreparedCommit(engine);- const selected = useActiveProjectSelector(- (project): SelectedTransform | null => {- const { document } = project.canvas;- const leaf = document.selectedLayerId ? lookupDocumentLeaf(document, document.selectedLayerId) : null;- return leaf && !leaf.effectiveLocked- ? { id: leaf.id, x: leaf.layer.transform.x, y: leaf.layer.transform.y }- : null;- },- (a, b) => a?.id === b?.id && a?.x === b?.x && a?.y === b?.y- );-- const commitAxis = useCallback(- (axis: 'x' | 'y', value: number) => {- if (!selected) {- return;- }- const next = Math.round(value);- if (next === selected[axis]) {- return;- }- commitPrepared(t('widgets.canvas.toolOptions.movePosition'), (model) =>- model.prepare({- id: selected.id,- patch: { transform: axis === 'x' ? { x: next } : { y: next } },- type: 'patch',- })- );- },- [commitPrepared, selected, t]- );- const onX = useNumberCommit(useCallback((value: number) => commitAxis('x', value), [commitAxis]));- const onY = useNumberCommit(useCallback((value: number) => commitAxis('y', value), [commitAxis]));-- return (- <>- <ToolbarNumberField- aria-label={t('widgets.canvas.toolOptions.positionX')}- disabled={!selected}- label={t('widgets.canvas.toolOptions.positionX')}- value={selected ? String(Math.round(selected.x)) : ''}- onValueCommit={onX}- />- <ToolbarNumberField- aria-label={t('widgets.canvas.toolOptions.positionY')}- disabled={!selected}- label={t('widgets.canvas.toolOptions.positionY')}- value={selected ? String(Math.round(selected.y)) : ''}- onValueCommit={onY}- />- </>- );-};--export const moveAdapter: ToolPresentationAdapter = {- rowLabels: { geometry: 'widgets.transform.position' },- geometry: MovePosition,- id: 'move',-};diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/SelectionOptionsRow.tsx b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/SelectionOptionsRow.tsxindex 1d9fca5232..41d4a86a3a 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/SelectionOptionsRow.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/SelectionOptionsRow.tsx@@ -6,7 +6,6 @@ import { Button, IconButton } from '@platform/ui/Button';import { Tooltip } from '@platform/ui/Tooltip';import { isLeafPixelEditEligible, lookupDocumentLeaf } from '@workbench/canvas-engine/api';import { useCanvasHasSelection } from '@workbench/widgets/canvas/engineStoreHooks';-import { ToolbarHint } from '@workbench/widgets/canvas/tool-presentation/ToolbarPrimitives';import { useActiveProjectSelector } from '@workbench/WorkbenchContext';import { SquareIcon, SquareMinusIcon, SquarePlusIcon, SquaresIntersectIcon } from 'lucide-react';import { useCallback } from 'react';@@ -61,27 +60,21 @@ const OpModeButton = ({* transiently with shift / alt while committing), plus the gesture hint while* no selection exists. The mode lives in each tool's own options store.*/-export const SelectionModes = ({- engine,- hintKey,+/** The four op-mode toggles alone; the form places them in a labelled row. */+export const SelectionOpModeButtons = ({mode,onModeChange,-}: ToolbarRegionProps & {- hintKey: string;+}: {mode: SelectionOp;onModeChange: (mode: SelectionOp) => void;}) => {const { t } = useTranslation();- const hasSelection = useCanvasHasSelection(engine);return (- <>- <HStack aria-label={t('widgets.canvas.toolOptions.selectionMode')} flexShrink={0} gap="1" role="group">- {OP_MODES.map((opMode) => (- <OpModeButton key={opMode} active={mode === opMode} mode={opMode} onSelect={onModeChange} />- ))}- </HStack>- {hasSelection ? null : <ToolbarHint>{t(hintKey)}</ToolbarHint>}- </>+ <HStack aria-label={t('widgets.canvas.toolOptions.selectionMode')} flexShrink={0} gap="1" role="group">+ {OP_MODES.map((opMode) => (+ <OpModeButton key={opMode} active={mode === opMode} mode={opMode} onSelect={onModeChange} />+ ))}+ </HStack>);};diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/TransformOptions.tsx b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/TransformOptions.tsxdeleted file mode 100644index de87412bf1..0000000000--- a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/TransformOptions.tsx+++ /dev/null@@ -1,137 +0,0 @@-import type { NumberInput as ChakraNumberInput } from '@chakra-ui/react';-import type { LayerTransform } from '@workbench/canvas-engine/api';-import type {- ToolbarRegionProps,- ToolbarStatusProps,- ToolPresentationAdapter,-} from '@workbench/widgets/canvas/tool-presentation/toolbarContracts';--import { useCanvasHasFloatingSelection, useTransformSession } from '@workbench/widgets/canvas/engineStoreHooks';-import { ToolbarNumberField, ToolbarStatus } from '@workbench/widgets/canvas/tool-presentation/ToolbarPrimitives';-import { useCallback } from 'react';-import { useTranslation } from 'react-i18next';--const RAD_TO_DEG = 180 / Math.PI;-const DEG_TO_RAD = Math.PI / 180;--const round2 = (n: number): number => Math.round(n * 100) / 100;--/**- * Edits go to the session preview through the engine; nothing reaches the- * document until Apply, and the whole session is one undo entry. Scale is a- * percent of the layer's native size because the session carries only the- * transform, not the source pixel dimensions.- */-const useTransformPatch = (engine: ToolbarRegionProps['engine']) => {- const session = useTransformSession(engine);- const transform = session?.transform ?? null;- const patch = useCallback(- (next: Partial<LayerTransform>) => {- if (transform) {- engine.layers.updateTransformSession({ ...transform, ...next });- }- },- [engine, transform]- );- return { patch, transform };-};--type NumberChange = ChakraNumberInput.ValueChangeDetails;--const TransformPosition = ({ engine }: ToolbarRegionProps) => {- const { t } = useTranslation();- const { patch, transform } = useTransformPatch(engine);- const onX = useCallback(- ({ valueAsNumber }: NumberChange) => Number.isFinite(valueAsNumber) && patch({ x: Math.round(valueAsNumber) }),- [patch]- );- const onY = useCallback(- ({ valueAsNumber }: NumberChange) => Number.isFinite(valueAsNumber) && patch({ y: Math.round(valueAsNumber) }),- [patch]- );- return (- <>- <ToolbarNumberField- aria-label={t('widgets.canvas.toolOptions.positionX')}- disabled={!transform}- label={t('widgets.canvas.toolOptions.positionX')}- value={transform ? String(Math.round(transform.x)) : ''}- onValueChange={onX}- />- <ToolbarNumberField- aria-label={t('widgets.canvas.toolOptions.positionY')}- disabled={!transform}- label={t('widgets.canvas.toolOptions.positionY')}- value={transform ? String(Math.round(transform.y)) : ''}- onValueChange={onY}- />- </>- );-};--const TransformScale = ({ engine }: ToolbarRegionProps) => {- const { t } = useTranslation();- const { patch, transform } = useTransformPatch(engine);- const onScaleX = useCallback(- ({ valueAsNumber }: NumberChange) =>- Number.isFinite(valueAsNumber) && valueAsNumber !== 0 && patch({ scaleX: valueAsNumber / 100 }),- [patch]- );- const onScaleY = useCallback(- ({ valueAsNumber }: NumberChange) =>- Number.isFinite(valueAsNumber) && valueAsNumber !== 0 && patch({ scaleY: valueAsNumber / 100 }),- [patch]- );- const onRotation = useCallback(- ({ valueAsNumber }: NumberChange) =>- Number.isFinite(valueAsNumber) && patch({ rotation: valueAsNumber * DEG_TO_RAD }),- [patch]- );- return (- <>- <ToolbarNumberField- aria-label={t('widgets.canvas.toolOptions.scaleWidth')}- disabled={!transform}- label={t('widgets.canvas.toolOptions.frameWidth')}- value={transform ? String(round2(transform.scaleX * 100)) : ''}- onValueChange={onScaleX}- />- <ToolbarNumberField- aria-label={t('widgets.canvas.toolOptions.scaleHeight')}- disabled={!transform}- label={t('widgets.canvas.toolOptions.frameHeight')}- value={transform ? String(round2(transform.scaleY * 100)) : ''}- onValueChange={onScaleY}- />- <ToolbarNumberField- aria-label={t('widgets.canvas.toolOptions.rotation')}- disabled={!transform}- suffix="°"- value={transform ? String(round2(transform.rotation * RAD_TO_DEG)) : ''}- onValueChange={onRotation}- />- </>- );-};--/**- * Apply / Cancel stay live for a floating selection, which frames its own- * pixels instead of opening a layer session; the numerics stay disabled- * because the float's transform is layer-local, not document space.- */-const TransformStatus = ({ engine }: ToolbarStatusProps) => {- const session = useTransformSession(engine);- const hasFloat = useCanvasHasFloatingSelection(engine);- const disabled = !session && !hasFloat;- const onApply = useCallback(() => engine.layers.applyTransform(), [engine]);- const onCancel = useCallback(() => engine.layers.cancelTransform(), [engine]);- return <ToolbarStatus applyDisabled={disabled} cancelDisabled={disabled} onApply={onApply} onCancel={onCancel} />;-};--export const transformAdapter: ToolPresentationAdapter = {- rowLabels: { geometry: 'widgets.transform.position', modes: 'widgets.transform.scale' },- geometry: TransformPosition,- id: 'transform',- modes: TransformScale,- status: TransformStatus,-};diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/geometryForm.tsx b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/geometryForm.tsxnew file mode 100644index 0000000000..4c4442ece5--- /dev/null+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/geometryForm.tsx@@ -0,0 +1,297 @@+import type { AspectRatioId } from '@features/generation/contracts';+import type { LayerTransform } from '@workbench/canvas-engine/api';+import type {+ ToolbarRegionProps,+ ToolbarStatusProps,+ ToolPropertyForm,+ ToolPropertyGroup,+} from '@workbench/widgets/canvas/tool-presentation/toolbarContracts';++import { Flex } from '@chakra-ui/react';+import { AspectRatioLockButton, AspectRatioSelect } from '@features/generation/components';+import { ASPECT_RATIO_MAP, deriveAspectRatioId } from '@features/generation/settings';+import { constrainBboxToRatio, lookupDocumentLeaf } from '@workbench/canvas-engine/api';+import {+ useCanvasActiveTool,+ useCanvasHasFloatingSelection,+ useTransformSession,+} from '@workbench/widgets/canvas/engineStoreHooks';+import { PropertyControlRow } from '@workbench/widgets/canvas/tool-presentation/PropertyPrimitives';+import {+ ToolbarNumberField,+ ToolbarStatus,+ useNumberCommit,+} from '@workbench/widgets/canvas/tool-presentation/ToolbarPrimitives';+import { usePreparedCommit } from '@workbench/widgets/canvas/useStructuralCommit';+import { useActiveProjectSelector } from '@workbench/WorkbenchContext';+import { useCallback } from 'react';+import { useTranslation } from 'react-i18next';++import { useBboxEditor } from './useBboxEditor';++const RAD_TO_DEG = 180 / Math.PI;+const DEG_TO_RAD = Math.PI / 180;+const MIN_SCALE_PERCENT = 1;+const ASPECT_TRIGGER_PROPS = { minW: '7.5rem' } as const;++export const round2 = (n: number): number => Math.round(n * 100) / 100;+/** Degrees in (-180, 180], so 270 reads and stores as -90. */+export const wrapDegrees = (degrees: number): number => {+ const wrapped = ((((degrees + 180) % 360) + 360) % 360) - 180;+ return wrapped === -180 ? 180 : wrapped;+};+/** A flip is a negative scale; a zero or near-zero one is not a transform anyone can undo by eye. */+export const clampScalePercent = (percent: number): number =>+ percent < 0 ? Math.min(percent, -MIN_SCALE_PERCENT) : Math.max(percent, MIN_SCALE_PERCENT);++interface SelectedLeafTransform {+ id: string;+ locked: boolean;+ transform: LayerTransform;+}++/**+ * The one layer-transform write path the Move and Transform tools (and the+ * Transform pane) share: a live transform session absorbs edits into its+ * single Apply commit; otherwise each settled field is one undoable patch on+ * the selected, unlocked leaf.+ */+export const useLayerTransformEditor = (engine: ToolbarRegionProps['engine'], labelKey = 'widgets.transform.edit') => {+ const { t } = useTranslation();+ const commitPrepared = usePreparedCommit(engine);+ const session = useTransformSession(engine);+ const selected = useActiveProjectSelector(+ (project): SelectedLeafTransform | null => {+ const { document } = project.canvas;+ const leaf = document.selectedLayerId ? lookupDocumentLeaf(document, document.selectedLayerId) : null;+ return leaf ? { id: leaf.id, locked: leaf.effectiveLocked, transform: leaf.layer.transform } : null;+ },+ (a, b) => a?.id === b?.id && a?.locked === b?.locked && a?.transform === b?.transform+ );+ const transform = session?.transform ?? (selected && !selected.locked ? selected.transform : null);+ const patch = useCallback(+ (next: Partial<LayerTransform>) => {+ if (session) {+ engine.layers.updateTransformSession({ ...session.transform, ...next });+ return;+ }+ if (!selected || selected.locked) {+ return;+ }+ commitPrepared(t(labelKey), (model) =>+ model.prepare({ id: selected.id, patch: { transform: next }, type: 'patch' })+ );+ },+ [commitPrepared, engine, labelKey, selected, session, t]+ );+ return { patch, transform };+};++/**+ * The shared Position rows: the frame's document bbox under the Frame tool,+ * else the selected layer / transform session. One component for every+ * geometry tool, so the X/Y fields keep DOM identity across tool switches.+ */+const GeometryPositionSettings = ({ engine }: ToolbarRegionProps) => {+ const { t } = useTranslation();+ const activeTool = useCanvasActiveTool(engine);+ const isFrame = activeTool === 'bbox';+ // The move tool keeps its own undo verbiage; everything else is a transform edit.+ const layerEditor = useLayerTransformEditor(+ engine,+ activeTool === 'move' ? 'widgets.canvas.toolOptions.movePosition' : undefined+ );+ const bboxEditor = useBboxEditor(engine);+ const x = isFrame ? bboxEditor.bbox.x : layerEditor.transform ? Math.round(layerEditor.transform.x) : null;+ const y = isFrame ? bboxEditor.bbox.y : layerEditor.transform ? Math.round(layerEditor.transform.y) : null;+ const onX = useNumberCommit(+ useCallback(+ (value: number) => (isFrame ? bboxEditor.setX(value) : layerEditor.patch({ x: Math.round(value) })),+ [bboxEditor, isFrame, layerEditor]+ )+ );+ const onY = useNumberCommit(+ useCallback(+ (value: number) => (isFrame ? bboxEditor.setY(value) : layerEditor.patch({ y: Math.round(value) })),+ [bboxEditor, isFrame, layerEditor]+ )+ );+ // The group header already says Position; the fields carry their own X/Y+ // prefixes, so a row label would just repeat it.+ return (+ <Flex gap="2" w="full">+ <ToolbarNumberField+ aria-label={t('widgets.canvas.toolOptions.positionX')}+ disabled={x === null}+ label={t('widgets.canvas.toolOptions.positionX')}+ value={x === null ? '' : String(x)}+ onValueCommit={onX}+ />+ <ToolbarNumberField+ aria-label={t('widgets.canvas.toolOptions.positionY')}+ disabled={y === null}+ label={t('widgets.canvas.toolOptions.positionY')}+ value={y === null ? '' : String(y)}+ onValueCommit={onY}+ />+ </Flex>+ );+};++/** Scale percent pair and rotation for the transform session / selected leaf. */+export const TransformScaleSettings = ({ engine }: ToolbarRegionProps) => {+ const { t } = useTranslation();+ const { patch, transform } = useLayerTransformEditor(engine);+ const onScaleX = useNumberCommit(+ useCallback((value: number) => patch({ scaleX: clampScalePercent(value) / 100 }), [patch])+ );+ const onScaleY = useNumberCommit(+ useCallback((value: number) => patch({ scaleY: clampScalePercent(value) / 100 }), [patch])+ );+ const onRotation = useNumberCommit(+ useCallback((value: number) => patch({ rotation: wrapDegrees(value) * DEG_TO_RAD }), [patch])+ );+ return (+ <>+ <PropertyControlRow label={t('widgets.transform.scale')}>+ <Flex gap="2" gridColumn="2 / -1">+ <ToolbarNumberField+ aria-label={t('widgets.canvas.toolOptions.scaleWidth')}+ disabled={!transform}+ label={t('widgets.canvas.toolOptions.frameWidth')}+ suffix="%"+ value={transform ? String(round2(transform.scaleX * 100)) : ''}+ onValueCommit={onScaleX}+ />+ <ToolbarNumberField+ aria-label={t('widgets.canvas.toolOptions.scaleHeight')}+ disabled={!transform}+ label={t('widgets.canvas.toolOptions.frameHeight')}+ suffix="%"+ value={transform ? String(round2(transform.scaleY * 100)) : ''}+ onValueCommit={onScaleY}+ />+ </Flex>+ </PropertyControlRow>+ <PropertyControlRow label={t('widgets.transform.rotation')}>+ <ToolbarNumberField+ aria-label={t('widgets.canvas.toolOptions.rotation')}+ disabled={!transform}+ suffix="°"+ value={transform ? String(round2(wrapDegrees(transform.rotation * RAD_TO_DEG))) : ''}+ onValueCommit={onRotation}+ />+ </PropertyControlRow>+ </>+ );+};++/** Frame width/height plus the aspect preset and lock, as form rows. */+const FrameSizeSettings = ({ engine }: ToolbarRegionProps) => {+ const { t } = useTranslation();+ const { bbox, commitBbox, grid, options, setHeight, setWidth } = useBboxEditor(engine);+ const onWidth = useNumberCommit(setWidth);+ const onHeight = useNumberCommit(setHeight);+ const bboxRatio = bbox.height > 0 ? bbox.width / bbox.height : 1;+ // Derived from the live frame so a lock captured from a hand-drawn bbox reports the preset it matches.+ const selectedId: AspectRatioId = options.aspectLocked ? deriveAspectRatioId(bbox.width, bbox.height) : 'Free';++ const onAspectPresetChange = useCallback(+ (id: AspectRatioId) => {+ if (id === 'Free') {+ engine.interaction.set('bboxOptions', { ...options, aspectLocked: false });+ return;+ }+ const ratio = ASPECT_RATIO_MAP[id].ratio;+ engine.interaction.set('bboxOptions', { aspectLocked: true, aspectRatio: ratio });+ commitBbox(constrainBboxToRatio(bbox, ratio, grid));+ },+ [bbox, commitBbox, engine, grid, options]+ );++ const onLockToggle = useCallback(() => {+ const checked = !options.aspectLocked;+ // Locking a frame that matches no preset captures its current ratio.+ const aspectRatio =+ checked && bbox.height > 0 && deriveAspectRatioId(bbox.width, bbox.height) === 'Free'+ ? bboxRatio+ : options.aspectRatio > 0+ ? options.aspectRatio+ : 1;+ engine.interaction.set('bboxOptions', { aspectLocked: checked, aspectRatio });+ }, [bbox, bboxRatio, engine, options.aspectLocked, options.aspectRatio]);++ return (+ <>+ <PropertyControlRow label={t('widgets.properties.rows.size')}>+ <Flex gap="2" gridColumn="2 / -1">+ <ToolbarNumberField+ aria-label={t('widgets.canvas.toolOptions.frameWidth')}+ label={t('widgets.canvas.toolOptions.frameWidth')}+ min={1}+ value={String(bbox.width)}+ onValueCommit={onWidth}+ />+ <ToolbarNumberField+ aria-label={t('widgets.canvas.toolOptions.frameHeight')}+ label={t('widgets.canvas.toolOptions.frameHeight')}+ min={1}+ value={String(bbox.height)}+ onValueCommit={onHeight}+ />+ </Flex>+ </PropertyControlRow>+ <PropertyControlRow label={t('widgets.properties.rows.aspect')}>+ <Flex align="center" gap="2" gridColumn="2 / -1">+ <AspectRatioSelect+ fallbackRatio={bboxRatio}+ triggerProps={ASPECT_TRIGGER_PROPS}+ value={selectedId}+ onChange={onAspectPresetChange}+ />+ <AspectRatioLockButton isLocked={options.aspectLocked} onToggle={onLockToggle} />+ </Flex>+ </PropertyControlRow>+ </>+ );+};++/**+ * Apply / Cancel stay live for a floating selection, which frames its own+ * pixels instead of opening a layer session; the numerics meanwhile edit the+ * settled selected layer, matching the Transform pane.+ */+const TransformFooter = ({ engine }: ToolbarStatusProps) => {+ const session = useTransformSession(engine);+ const hasFloat = useCanvasHasFloatingSelection(engine);+ const disabled = !session && !hasFloat;+ const onApply = useCallback(() => engine.layers.applyTransform(), [engine]);+ const onCancel = useCallback(() => engine.layers.cancelTransform(), [engine]);+ return <ToolbarStatus applyDisabled={disabled} cancelDisabled={disabled} onApply={onApply} onCancel={onCancel} />;+};++/** Shared literal: the same object in every geometry form, so the rows' DOM survives tool switches. */+const POSITION_GROUP: ToolPropertyGroup = {+ body: GeometryPositionSettings,+ id: 'geometry-position',+ labelKey: 'widgets.transform.position',+};++export const moveForm: ToolPropertyForm = {+ groups: [POSITION_GROUP],+ id: 'move',+};++export const bboxForm: ToolPropertyForm = {+ groups: [POSITION_GROUP, { body: FrameSizeSettings, id: 'frame-size', labelKey: 'widgets.properties.groups.frame' }],+ id: 'bbox',+};++export const transformForm: ToolPropertyForm = {+ footer: TransformFooter,+ groups: [+ POSITION_GROUP,+ { body: TransformScaleSettings, id: 'transform-scale', labelKey: 'widgets.transform.scale' },+ ],+ id: 'transform',+};diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/selectionForm.tsx b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/selectionForm.tsxnew file mode 100644index 0000000000..1857b2da97--- /dev/null+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-options/selectionForm.tsx@@ -0,0 +1,119 @@+import type { SelectionOp } from '@workbench/canvas-engine/api';+import type {+ ToolbarRegionProps,+ ToolPropertyForm,+ ToolPropertyGroup,+} from '@workbench/widgets/canvas/tool-presentation/toolbarContracts';++import { Text } from '@chakra-ui/react';+import {+ useCanvasActiveTool,+ useCanvasHasSelection,+ useLassoOptions,+ useMarqueeOptions,+} from '@workbench/widgets/canvas/engineStoreHooks';+import {+ PropertyControlRow,+ PropertySegmentedRow,+} from '@workbench/widgets/canvas/tool-presentation/PropertyPrimitives';+import { useCallback, useMemo } from 'react';+import { useTranslation } from 'react-i18next';++import { SelectionActions, SelectionOpModeButtons } from './SelectionOptionsRow';++/**+ * The shared selection form: the path shape (lasso freehand/polygon or marquee+ * rectangle/ellipse), the op mode, and the command cluster. One component set+ * reading the active tool, so the rows keep DOM identity lasso↔marquee.+ */+const SelectionModeSettings = ({ engine, isSurfaceInteractionLocked }: ToolbarRegionProps) => {+ const { t } = useTranslation();+ const activeTool = useCanvasActiveTool(engine);+ const isMarquee = activeTool === 'marquee';+ const lasso = useLassoOptions(engine);+ const marquee = useMarqueeOptions(engine);+ const hasSelection = useCanvasHasSelection(engine);+ void isSurfaceInteractionLocked;++ const shapeOptions = useMemo(+ () =>+ isMarquee+ ? [+ { label: t('widgets.canvas.toolOptions.shapeRect'), value: 'rect' },+ { label: t('widgets.canvas.toolOptions.shapeEllipse'), value: 'ellipse' },+ ]+ : [+ { label: t('widgets.canvas.toolOptions.lassoFreehand'), value: 'freehand' },+ { label: t('widgets.canvas.toolOptions.lassoPolygon'), value: 'polygon' },+ ],+ [isMarquee, t]+ );+ const shapeValue = isMarquee ? marquee.kind : lasso.shape;+ const onShapeChange = useCallback(+ (next: string) => {+ if (isMarquee) {+ engine.interaction.set('marqueeOptions', { ...marquee, kind: next as typeof marquee.kind });+ } else {+ engine.interaction.set('lassoOptions', { ...lasso, shape: next as typeof lasso.shape });+ }+ },+ [engine, isMarquee, lasso, marquee]+ );+ const mode = isMarquee ? marquee.mode : lasso.mode;+ const onModeChange = useCallback(+ (next: SelectionOp) => {+ if (isMarquee) {+ engine.interaction.set('marqueeOptions', { ...marquee, mode: next });+ } else {+ engine.interaction.set('lassoOptions', { ...lasso, mode: next });+ }+ },+ [engine, isMarquee, lasso, marquee]+ );+ const hintKey = isMarquee+ ? 'widgets.canvas.toolOptions.marqueeHint'+ : lasso.shape === 'polygon'+ ? 'widgets.canvas.toolOptions.lassoPolygonHint'+ : 'widgets.canvas.toolOptions.lassoHint';++ return (+ <>+ <PropertySegmentedRow+ label={t('widgets.properties.rows.shape')}+ options={shapeOptions}+ value={shapeValue}+ onValueChange={onShapeChange}+ />+ <PropertyControlRow label={t('widgets.properties.rows.mode')}>+ <SelectionOpModeButtons mode={mode} onModeChange={onModeChange} />+ </PropertyControlRow>+ {hasSelection ? null : (+ <Text color="fg.muted" fontSize="2xs">+ {t(hintKey)}+ </Text>+ )}+ </>+ );+};++/** Shared literals: the same objects in both forms, so the rows' DOM survives the switch. */+const MODE_GROUP: ToolPropertyGroup = {+ body: SelectionModeSettings,+ id: 'selection-mode',+ labelKey: 'widgets.properties.groups.selection',+};+const ACTIONS_GROUP: ToolPropertyGroup = {+ body: SelectionActions,+ id: 'selection-actions',+ labelKey: 'widgets.canvas.toolOptions.selectionActions',+};++export const lassoForm: ToolPropertyForm = {+ groups: [MODE_GROUP, ACTIONS_GROUP],+ id: 'lasso',+};++export const marqueeForm: ToolPropertyForm = {+ groups: [MODE_GROUP, ACTIONS_GROUP],+ id: 'marquee',+};diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-presentation/toolAdapters.ts b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-presentation/toolAdapters.tsindex 77af73587b..63d91243cf 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-presentation/toolAdapters.ts+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-presentation/toolAdapters.ts@@ -1,16 +1,13 @@import type { ToolId } from '@workbench/canvas-engine/api';-import { bboxAdapter } from '@workbench/widgets/canvas/tool-options/BboxOptions';import { filterOperationAdapter } from '@workbench/widgets/canvas/tool-options/FilterOptions';+import { bboxForm, moveForm, transformForm } from '@workbench/widgets/canvas/tool-options/geometryForm';import { gradientForm } from '@workbench/widgets/canvas/tool-options/GradientOptions';-import { lassoAdapter } from '@workbench/widgets/canvas/tool-options/LassoOptions';-import { marqueeAdapter } from '@workbench/widgets/canvas/tool-options/MarqueeOptions';-import { moveAdapter } from '@workbench/widgets/canvas/tool-options/MoveOptions';import { brushForm, eraserForm } from '@workbench/widgets/canvas/tool-options/paintForm';import { selectObjectOperationAdapter } from '@workbench/widgets/canvas/tool-options/SamOptions';+import { lassoForm, marqueeForm } from '@workbench/widgets/canvas/tool-options/selectionForm';import { shapeForm } from '@workbench/widgets/canvas/tool-options/ShapeOptions';import { textForm } from '@workbench/widgets/canvas/tool-options/TextOptions';-import { transformAdapter } from '@workbench/widgets/canvas/tool-options/TransformOptions';import type {CanvasOperationKind,@@ -25,18 +22,18 @@ import { isToolPropertyForm } from './toolbarContracts';const hintOnly = (id: ToolId): ToolPresentationAdapter => ({ id });export const TOOL_PRESENTATION_ADAPTERS: Readonly<Record<ToolId, ToolPanePresentation>> = {- bbox: bboxAdapter,+ bbox: bboxForm,brush: brushForm,colorPicker: hintOnly('colorPicker'),eraser: eraserForm,gradient: gradientForm,- lasso: lassoAdapter,- marquee: marqueeAdapter,- move: moveAdapter,+ lasso: lassoForm,+ marquee: marqueeForm,+ move: moveForm,sam: hintOnly('sam'),shape: shapeForm,text: textForm,- transform: transformAdapter,+ transform: transformForm,view: hintOnly('view'),};diff --git a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-presentation/toolbarContracts.ts b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-presentation/toolbarContracts.tsindex a585a56fae..cc8725d96d 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-presentation/toolbarContracts.ts+++ b/invokeai/frontend/webv2/src/workbench/widgets/canvas/tool-presentation/toolbarContracts.ts@@ -62,8 +62,6 @@ export interface OperationPresentationAdapter {export interface ToolPropertyGroup {id: string;labelKey: string;- /** 'actions' renders a command cluster, visually distinct from settings. */- kind?: 'settings' | 'actions';/** Present makes the header a disclosure; the value is the default state. */collapsible?: 'open' | 'collapsed';body: ToolbarRegionComponent;@@ -80,6 +78,8 @@ export interface ToolPropertyForm {paintsLeaf?: boolean;preview?: ComponentType<ToolbarStatusProps>;groups: readonly ToolPropertyGroup[];+ /** Sticks to the pane's bottom edge while the form scrolls: session status, Apply, Cancel. */+ footer?: ComponentType<ToolbarStatusProps>;}export type ToolPanePresentation = ToolPresentationAdapter | ToolPropertyForm;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 99592d1972..2ae71b3156 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@@ -358,6 +358,44 @@ describe('Properties pane', () => {await expect.element(page.getByRole('button', { exact: true, name: 'Gradient stop at 1%' })).toBeVisible();});+ it('keeps the Position row identity across move, frame and transform, with the transform footer live', async () => {+ await mount(PropertiesPane, 'layer');+ await act(() => engine!.tools.setTool('move'));+ await settle();+ const xField = page.getByRole('spinbutton', { exact: true, name: 'X' }).element();+ await act(() => engine!.tools.setTool('bbox'));+ await settle();+ // Same DOM node: the shared Position group survives the switch, now+ // editing the frame; the frame's Size and Aspect rows appear.+ expect(page.getByRole('spinbutton', { exact: true, name: 'X' }).element()).toBe(xField);+ await expect.element(page.getByRole('spinbutton', { exact: true, name: 'W' })).toBeVisible();++ await act(() => engine!.tools.setTool('transform'));+ await settle();+ expect(page.getByRole('spinbutton', { exact: true, name: 'X' }).element()).toBe(xField);+ // No session and no float: Apply/Cancel are pinned but disabled.+ await expect.element(page.getByRole('button', { exact: true, name: 'Apply' })).toBeDisabled();+ await expect.element(page.getByRole('button', { exact: true, name: 'Cancel' })).toBeDisabled();+ });++ it('shares the selection form between lasso and marquee with the actions cluster', async () => {+ await mount(PropertiesPane);+ await act(() => engine!.tools.setTool('lasso'));+ await settle();+ const freehand = page.getByRole('radio', { exact: true, name: 'Freehand' });+ await expect.element(freehand).toBeVisible();+ const modeGroup = host!.querySelector<HTMLElement>('[role="group"][aria-label="Selection mode"]')!;+ expect(modeGroup).not.toBeNull();+ await expect.element(page.getByRole('button', { exact: true, name: 'Deselect' })).toBeDisabled();++ await act(() => engine!.tools.setTool('marquee'));+ await settle();+ // The op-mode buttons keep DOM identity; the shape choices swap per tool.+ expect(host!.querySelector('[role="group"][aria-label="Selection mode"]')).toBe(modeGroup);+ await expect.element(page.getByRole('radio', { exact: true, name: 'Rectangle' })).toBeVisible();+ expect(page.getByRole('radio', { exact: true, name: 'Freehand' }).query()).toBeNull();+ });+it('remembers a group collapse per user across remounts', async () => {await mount(PropertiesPane);await act(() => engine!.tools.setTool('brush'));diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/PropertiesPane.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/PropertiesPane.tsxindex c1b9607d2b..319b488e93 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/PropertiesPane.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/PropertiesPane.tsx@@ -122,6 +122,20 @@ const ConnectedProperties = ({<group.body {...regionProps} /></PropertyGroup>))}+ {form.footer ? (+ <Flex+ bg="bg.panel"+ borderColor="border.subtle"+ borderTopWidth="1px"+ bottom="0"+ mx="-3"+ position="sticky"+ px="3"+ py="1.5"+ >+ <form.footer engine={engine} isExternalInteractionLocked={isSurfaceInteractionLocked} />+ </Flex>+ ) : null}</>) : legacy && hasToolRegions(legacy) ? (rows.map(([region, Region]) => (diff --git a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/TransformPane.tsx b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/TransformPane.tsxindex 245e038a12..3326d6b604 100644--- a/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/TransformPane.tsx+++ b/invokeai/frontend/webv2/src/workbench/widgets/layers/panes/TransformPane.tsx@@ -5,6 +5,7 @@ import { Button } from '@platform/ui/Button';import { Scrollable } from '@platform/ui/Scrollable';import { getDocumentNode, lookupDocumentLeaf } from '@workbench/canvas-engine/api';import { useCanvasHasFloatingSelection, useTransformSession } from '@workbench/widgets/canvas/engineStoreHooks';+import { clampScalePercent, round2, wrapDegrees } from '@workbench/widgets/canvas/tool-options/geometryForm';import { ToolbarNumberField, useNumberCommit } from '@workbench/widgets/canvas/tool-presentation/ToolbarPrimitives';import { useCanvasEngine, type CanvasEngineHandle } from '@workbench/widgets/canvas/useCanvasEngine';import { usePreparedCommit } from '@workbench/widgets/canvas/useStructuralCommit';@@ -17,16 +18,6 @@ import { PropertiesRow, PropertiesSection } from './PropertiesSection';const RAD_TO_DEG = 180 / Math.PI;const DEG_TO_RAD = Math.PI / 180;-const MIN_SCALE_PERCENT = 1;-const round2 = (n: number): number => Math.round(n * 100) / 100;-/** Degrees in (-180, 180], so 270 reads and stores as -90. */-const wrapDegrees = (degrees: number): number => {- const wrapped = ((((degrees + 180) % 360) + 360) % 360) - 180;- return wrapped === -180 ? 180 : wrapped;-};-/** A flip is a negative scale; a zero or near-zero one is not a transform anyone can undo by eye. */-const clampScalePercent = (percent: number): number =>- percent < 0 ? Math.min(percent, -MIN_SCALE_PERCENT) : Math.max(percent, MIN_SCALE_PERCENT);interface SelectedNode {id: string;