From 2dd1bc54c909b5ec40e07c7f2b6f8a59e8a5dcab Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 1 Jul 2025 20:14:01 +0000 Subject: [PATCH] Set brush tool automatically when sending image to canvas Co-authored-by: kent --- .../components/ImageViewer/CurrentImageButtons.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/invokeai/frontend/web/src/features/gallery/components/ImageViewer/CurrentImageButtons.tsx b/invokeai/frontend/web/src/features/gallery/components/ImageViewer/CurrentImageButtons.tsx index aaf0e5e08b..4c1b3d7517 100644 --- a/invokeai/frontend/web/src/features/gallery/components/ImageViewer/CurrentImageButtons.tsx +++ b/invokeai/frontend/web/src/features/gallery/components/ImageViewer/CurrentImageButtons.tsx @@ -1,6 +1,7 @@ import { Button, Divider, IconButton, Menu, MenuButton, MenuList } from '@invoke-ai/ui-library'; import { useStore } from '@nanostores/react'; import { useAppSelector, useAppStore } from 'app/store/storeHooks'; +import { useCanvasManagerSafe } from 'features/controlLayers/contexts/CanvasManagerProviderGate'; import { selectIsStaging } from 'features/controlLayers/store/canvasStagingAreaSlice'; import { DeleteImageButton } from 'features/deleteImageModal/components/DeleteImageButton'; import SingleSelectionMenuItems from 'features/gallery/components/ImageContextMenu/SingleSelectionMenuItems'; @@ -44,6 +45,7 @@ export const CurrentImageButtons = memo(() => { const isStaging = useAppSelector(selectIsStaging); const isUpscalingEnabled = useFeatureStatus('upscaling'); const { getState, dispatch } = useAppStore(); + const canvasManager = useCanvasManagerSafe(); const handleEdit = useCallback(async () => { if (!imageDTO) { @@ -58,12 +60,18 @@ export const CurrentImageButtons = memo(() => { dispatch, }); navigationApi.focusPanelInTab('canvas', WORKSPACE_PANEL_ID); + + // Automatically select the brush tool when editing an image + if (canvasManager) { + canvasManager.tool.$tool.set('brush'); + } + toast({ id: 'SENT_TO_CANVAS', title: t('toast.sentToCanvas'), status: 'success', }); - }, [imageDTO, getState, dispatch, t]); + }, [imageDTO, getState, dispatch, t, canvasManager]); return ( <>