diff --git a/frontend/src/app/pages/Dashboard/DashboardToolbar.tsx b/frontend/src/app/pages/Dashboard/DashboardToolbar.tsx index 46e2493c..bedf49b5 100644 --- a/frontend/src/app/pages/Dashboard/DashboardToolbar.tsx +++ b/frontend/src/app/pages/Dashboard/DashboardToolbar.tsx @@ -290,14 +290,17 @@ const DashboardToolbar = React.forwardRef( const autoSelectOnNew = useAppSelector((s) => s.settings.data.auto_select_mode_on_new_agent); const prevInputOpenRef = useRef(inputOpen); useEffect(() => { + // Collapsing the composer drops the selecting cursor but KEEPS the selected + // elements, so they persist across collapse/reopen like the draft text does. + // The selection is cleared on send via ChatInput's clearOwnerElements(ownerId). if (prevInputOpenRef.current && !inputOpen && elementSelection) { - elementSelection.clearOwnerElements(TOOLBAR_OWNER_ID); if (elementSelection.selectMode && elementSelection.activeOwnerId === TOOLBAR_OWNER_ID) { elementSelection.setSelectMode(false); } } + // Re-arm select mode on reopen without wiping any in-progress selection + // (mirrors the selector button, which only clears when switching owners). if (!prevInputOpenRef.current && inputOpen && autoSelectOnNew && elementSelection) { - elementSelection.clearOwnerElements(TOOLBAR_OWNER_ID); elementSelection.setActiveOwnerId(TOOLBAR_OWNER_ID); elementSelection.setExcludeSelectId(null); elementSelection.setSelectMode(true);