From d846b4bb6f9527cdd0a4e784dcd1e99fdc498e9f Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Sun, 5 Apr 2026 04:36:26 +0200 Subject: [PATCH] Enhance duplication logic with transform session handling --- src/app/App.tsx | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/app/App.tsx b/src/app/App.tsx index 9e4321cf..4be49a4e 100644 --- a/src/app/App.tsx +++ b/src/app/App.tsx @@ -2811,13 +2811,40 @@ export function App({ store, initialStatusMessage }: AppProps) { try { store.executeCommand(createDuplicateSelectionCommand()); - const duplicatedSelection = store.getState().selection; + const duplicatedState = store.getState(); + const duplicatedSelection = duplicatedState.selection; const canGrabDuplicatedSelection = (duplicatedSelection.kind === "brushes" || duplicatedSelection.kind === "entities" || duplicatedSelection.kind === "modelInstances") && duplicatedSelection.ids.length === 1; if (canGrabDuplicatedSelection) { - beginTransformOperation("translate", "keyboard"); + const transformSourcePanelId = layoutMode === "quad" ? hoveredViewportPanelId ?? activePanelId : activePanelId; + const transformTargetResult = resolveTransformTarget(duplicatedState.document, duplicatedSelection, whiteboxSelectionMode); + const transformTarget = transformTargetResult.target; + + if (transformTarget === null) { + setStatusMessage(transformTargetResult.message ?? "Duplicated selection, but could not start move transform."); + return true; + } + + if (duplicatedState.activeViewportPanelId !== transformSourcePanelId) { + store.setActiveViewportPanel(transformSourcePanelId); + } + + store.setTransformSession( + createTransformSession({ + source: "keyboard", + sourcePanelId: transformSourcePanelId, + operation: "translate", + target: transformTarget + }) + ); + + setStatusMessage( + `Move ${getTransformTargetLabel(transformTarget).toLowerCase()} in ${getViewportPanelLabel( + transformSourcePanelId + )}. Move the pointer, press X/Y/Z to constrain, click or press Enter to commit, Escape cancels.` + ); } else { setStatusMessage("Duplicated selection."); }