mirror of
https://github.com/openswarm-ai/openswarm.git
synced 2026-08-26 22:42:23 +02:00
[pierre] fix: persist selection on new-agent composer across collapse
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user