[pierre] fix: persist selection on new-agent composer across collapse

This commit is contained in:
SirKentut
2026-06-22 02:08:59 -07:00
parent c64ccf3834
commit 2b6a8d337f
@@ -290,14 +290,17 @@ const DashboardToolbar = React.forwardRef<HTMLDivElement, Props>(
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);