Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

feat(web): improve roster dragging and pinned bots (#272)

Leo3f169b06153d
diff --git a/apps/web/src/components/roster/BotRosterSidebar.tsx b/apps/web/src/components/roster/BotRosterSidebar.tsx
index 08d08ced2..d9425e8e3 100644
--- a/apps/web/src/components/roster/BotRosterSidebar.tsx
+++ b/apps/web/src/components/roster/BotRosterSidebar.tsx
@@ -6,7 +6,7 @@ import {
useSensor,
useSensors,
} from "@dnd-kit/core";
-import { restrictToFirstScrollableAncestor, restrictToVerticalAxis } from "@dnd-kit/modifiers";
+import { restrictToFirstScrollableAncestor } from "@dnd-kit/modifiers";
import { SortableContext, useSortable } from "@dnd-kit/sortable";
import { CSS } from "@dnd-kit/utilities";
import { useAtomValue } from "@effect/atom-react";
@@ -18,13 +18,9 @@ import {
ArrowUpIcon,
BotIcon,
ChevronDownIcon,
- ChevronRightIcon,
- FolderInputIcon,
PinIcon,
- PinOffIcon,
PlusIcon,
SearchIcon,
- Trash2Icon,
UsersIcon,
} from "lucide-react";
import {
@@ -56,15 +52,7 @@ import { selectThreadTerminalUiState, useTerminalUiStateStore } from "../../term
import { SidebarChromeFooter } from "../sidebar/SidebarChrome";
import { AkeruWordmark } from "../AkeruWordmark";
import { Button } from "../ui/button";
-import {
- Menu,
- MenuItem,
- MenuPopup,
- MenuSub,
- MenuSubPopup,
- MenuSubTrigger,
- MenuTrigger,
-} from "../ui/menu";
+import { Menu, MenuItem, MenuPopup, MenuTrigger } from "../ui/menu";
import { SidebarContent, SidebarGroup, SidebarHeader, SidebarTrigger } from "../ui/sidebar";
import { toastManager } from "../ui/toast";
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
@@ -83,25 +71,17 @@ import {
formatRosterTimestamp,
isRecordableChatPath,
parseChatPath,
- parseRosterEntryId,
- parseRosterSectionHeaderId,
planRosterDrop,
- planRosterSectionDrop,
resolveLatestRosterMessage,
resolveRosterDropTarget,
- resolveRosterDropVerb,
resolveRosterIndicator,
rosterItemKey,
rosterItemsEqual,
rosterItemsForZone,
rosterListItemId,
rosterMarkerId,
- rosterSectionItems,
- rosterZoneHasVisibleEntries,
- rosterZonesEqual,
orderRosterBotsForShortcuts,
resolveRosterShortcutBot,
- type RosterDropVerb,
type RosterItemRef,
type RosterLastMessage,
type RosterListMarker,
@@ -113,10 +93,11 @@ import {
createRosterCollisionDetection,
createRosterSortingStrategy,
restrictBelowRosterLabel,
+ restrictRosterDragAxis,
} from "./roster.drag";
import { createRosterListMotion } from "./roster.motion";
import { RosterDragLifecycle, RosterPointerSensor } from "./roster.pointer";
-import { useRosterStore, type RosterSection } from "./rosterStore";
+import { useRosterStore } from "./rosterStore";
import type { Bot, BotAvatar, Group } from "./types";
import { useBotThreadRef } from "./useBotThreadRef";
@@ -161,11 +142,9 @@ function RosterAvatar({
const RosterSidebarHeader = memo(function RosterSidebarHeader({
onNewBot,
onNewGroup,
- onNewSection,
}: {
onNewBot: () => void;
onNewGroup: () => void;
- onNewSection: () => void;
}) {
return (
<SidebarHeader
@@ -208,10 +187,6 @@ const RosterSidebarHeader = memo(function RosterSidebarHeader({
<UsersIcon />
New group
</MenuItem>
- <MenuItem onClick={onNewSection}>
- <FolderInputIcon />
- New section
- </MenuItem>
</MenuPopup>
</Menu>
</div>
@@ -279,27 +254,6 @@ function sortableRootProps(sortable: SortableRosterRowBag) {
};
}
-const dropVerbBadge: Record<RosterDropVerb, ReactNode> = {
- pin: (
- <>
- <PinIcon aria-hidden className="size-3" />
- Pin
- </>
- ),
- unpin: (
- <>
- <PinOffIcon aria-hidden className="size-3" />
- Unpin
- </>
- ),
- move: (
- <>
- <FolderInputIcon aria-hidden className="size-3" />
- Move
- </>
- ),
-};
-
const ROSTER_DRAG_LABEL_HEIGHT = 24;
const BotRosterRow = memo(function BotRosterRow({
@@ -308,28 +262,22 @@ const BotRosterRow = memo(function BotRosterRow({
isActive,
onSelect,
pinned,
- sections,
onPin,
- onMove,
canMoveUp,
canMoveDown,
onNudge,
sortable,
- dropVerb,
}: {
bot: Bot;
lastMessage: RosterLastMessage | null;
isActive: boolean;
onSelect: (bot: Bot) => void;
pinned: boolean;
- sections: readonly RosterSection[];
onPin: (pinned: boolean) => void;
- onMove: (sectionId: string | null) => void;
canMoveUp: boolean;
canMoveDown: boolean;
onNudge: (delta: -1 | 1) => void;
sortable: SortableRosterRowBag;
- dropVerb: RosterDropVerb | null;
}) {
const menuTriggerRef = useRef<HTMLButtonElement>(null);
const timestampFormat = useClientSettings((s) => s.timestampFormat);
@@ -339,7 +287,12 @@ const BotRosterRow = memo(function BotRosterRow({
<li
role="listitem"
data-roster-item
- className={cn("list-none touch-pan-y", sortable.isDragging && "z-50")}
+ data-pinned={pinned || undefined}
+ className={cn(
+ "list-none touch-pan-y",
+ pinned ? "my-2 w-18 flex-none" : "w-full flex-none",
+ sortable.isDragging && "z-50",
+ )}
{...sortableRootProps(sortable)}
>
<div
@@ -350,45 +303,48 @@ const BotRosterRow = memo(function BotRosterRow({
menuTriggerRef.current?.click();
}}
className={cn(
- "relative flex w-full items-center rounded-lg outline-none select-none",
+ "relative flex w-full items-center outline-none select-none",
+ pinned ? "rounded-xl" : "rounded-lg",
sortable.isDragging
? "bg-[linear-gradient(var(--sidebar-row-active),var(--sidebar-row-active)),linear-gradient(var(--sidebar),var(--sidebar))] text-sidebar-foreground shadow-lg"
: isActive
? "bg-sidebar-row-active text-sidebar-foreground"
- : "bg-transparent text-sidebar-foreground hover:bg-sidebar-row-hover",
+ : pinned
+ ? "bg-sidebar-row-hover/50 text-sidebar-foreground hover:bg-sidebar-row-hover"
+ : "bg-transparent text-sidebar-foreground hover:bg-sidebar-row-hover",
)}
>
<button
type="button"
aria-current={isActive || undefined}
onClick={() => onSelect(bot)}
- className="flex min-w-0 flex-1 cursor-grab items-center gap-2.5 rounded-lg px-2 py-1.5 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring active:cursor-grabbing"
+ className={cn(
+ "flex min-w-0 flex-1 cursor-grab outline-none focus-visible:ring-2 focus-visible:ring-ring active:cursor-grabbing",
+ pinned
+ ? "min-h-20 flex-col items-center justify-center gap-1.5 rounded-xl px-2 py-2 text-center"
+ : "items-center gap-2.5 rounded-lg px-2 py-1.5 text-left",
+ )}
>
- <RosterAvatar bot={bot} presence={presence} className="size-10" />
- <span className="flex min-w-0 flex-1 flex-col">
- <span className="flex items-baseline gap-2">
- <span className="min-w-0 flex-1 truncate text-sm font-semibold">{bot.name}</span>
+ <RosterAvatar bot={bot} presence={presence} className={pinned ? "size-12" : "size-10"} />
+ {pinned ? (
+ <span className="max-w-full truncate text-xs font-medium">{bot.name}</span>
+ ) : (
+ <span className="flex min-w-0 flex-1 flex-col">
+ <span className="flex items-baseline gap-2">
+ <span className="min-w-0 flex-1 truncate text-sm font-semibold">{bot.name}</span>
+ {latestMessage ? (
+ <span className="shrink-0 text-xs tabular-nums text-sidebar-muted-foreground">
+ {formatRosterTimestamp(latestMessage.at, timestampFormat)}
+ </span>
+ ) : null}
+ </span>
{latestMessage ? (
- <span className="shrink-0 text-xs tabular-nums text-sidebar-muted-foreground">
- {formatRosterTimestamp(latestMessage.at, timestampFormat)}
+ <span className="truncate text-[13px] text-sidebar-muted-foreground">
+ {latestMessage.text}
</span>
) : null}
</span>
- {latestMessage ? (
- <span className="truncate text-[13px] text-sidebar-muted-foreground">
- {latestMessage.text}
- </span>
- ) : null}
- </span>
- {sortable.isDragging && dropVerb !== null ? (
- <span
- role="status"
- data-testid="roster-drop-verb"
- className="pointer-events-none ml-auto inline-flex h-5 shrink-0 items-center gap-1 rounded-sm border border-primary/40 bg-primary/10 px-1.5 text-[11px] font-medium text-primary"
- >
- {dropVerbBadge[dropVerb]}
- </span>
- ) : null}
+ )}
</button>
<Menu>
<MenuTrigger
@@ -414,20 +370,6 @@ const BotRosterRow = memo(function BotRosterRow({
<ArrowDownIcon />
Move down
</MenuItem>
- <MenuSub>
- <MenuSubTrigger>
- <FolderInputIcon />
- Move to
- </MenuSubTrigger>
- <MenuSubPopup>
- {sections.map((section) => (
- <MenuItem key={section.id} onClick={() => onMove(section.id)}>
- {section.name}
- </MenuItem>
- ))}
- <MenuItem onClick={() => onMove(null)}>Unassigned</MenuItem>
- </MenuSubPopup>
- </MenuSub>
</MenuPopup>
</Menu>
</div>
@@ -481,13 +423,10 @@ function GroupRosterRow({
onSelect,
pinned,
onPin,
- sections,
- onMove,
canMoveUp,
canMoveDown,
onNudge,
sortable,
- dropVerb,
}: {
group: Group;
bots: readonly Bot[];
@@ -495,13 +434,10 @@ function GroupRosterRow({
onSelect: () => void;
pinned: boolean;
onPin: (pinned: boolean) => void;
- sections: readonly RosterSection[];
- onMove: (sectionId: string | null) => void;
canMoveUp: boolean;
canMoveDown: boolean;
onNudge: (delta: -1 | 1) => void;
sortable: SortableRosterRowBag;
- dropVerb: RosterDropVerb | null;
}) {
const menuTriggerRef = useRef<HTMLButtonElement>(null);
const members = group.members.filter(
@@ -513,14 +449,18 @@ function GroupRosterRow({
role="listitem"
data-roster-item
data-testid="roster-group-card"
+ data-pinned={pinned || undefined}
onContextMenu={(event) => {
event.preventDefault();
menuTriggerRef.current?.click();
}}
className={cn(
- "relative flex touch-pan-y items-center rounded-lg",
+ "relative flex touch-pan-y items-center",
+ pinned ? "my-2 w-18 flex-none rounded-xl" : "w-full flex-none rounded-lg",
sortable.isDragging && "z-50 bg-sidebar shadow-xl",
- isActive && "bg-sidebar-row-active",
+ isActive
+ ? "bg-sidebar-row-active"
+ : pinned && "bg-sidebar-row-hover/50 hover:bg-sidebar-row-hover",
)}
{...sortableRootProps(sortable)}
>
@@ -528,20 +468,27 @@ function GroupRosterRow({
type="button"
aria-current={isActive || undefined}
onClick={onSelect}
- className="flex min-w-0 flex-1 cursor-grab items-center gap-2.5 rounded-lg px-2 py-1.5 text-left outline-none hover:bg-sidebar-row-hover focus-visible:ring-2 focus-visible:ring-ring active:cursor-grabbing"
+ className={cn(
+ "flex min-w-0 flex-1 cursor-grab outline-none focus-visible:ring-2 focus-visible:ring-ring active:cursor-grabbing",
+ pinned
+ ? "min-h-20 flex-col items-center justify-center gap-1.5 rounded-xl px-2 py-2 text-center"
+ : "items-center gap-2.5 rounded-lg px-2 py-1.5 text-left hover:bg-sidebar-row-hover",
+ )}
>
- <GroupMemberStack group={group} bots={bots} sizeClassName="size-10" />
- <span className="min-w-0 flex-1 truncate text-sm font-semibold">{group.name}</span>
- <span className="text-xs text-sidebar-muted-foreground">{members}</span>
- {sortable.isDragging && dropVerb !== null ? (
- <span
- role="status"
- data-testid="roster-drop-verb"
- className="pointer-events-none ml-auto inline-flex h-5 shrink-0 items-center gap-1 rounded-sm border border-primary/40 bg-primary/10 px-1.5 text-[11px] font-medium text-primary"
- >
- {dropVerbBadge[dropVerb]}
- </span>
- ) : null}
+ <GroupMemberStack
+ group={group}
+ bots={bots}
+ sizeClassName={pinned ? "size-12" : "size-10"}
+ />
+ <span
+ className={cn(
+ "min-w-0 max-w-full truncate",
+ pinned ? "text-xs font-medium" : "flex-1 text-sm font-semibold",
+ )}
+ >
+ {group.name}
+ </span>
+ {pinned ? null : <span className="text-xs text-sidebar-muted-foreground">{members}</span>}
</button>
<Menu>
<MenuTrigger
@@ -567,20 +514,6 @@ function GroupRosterRow({
<ArrowDownIcon />
Move down
</MenuItem>
- <MenuSub>
- <MenuSubTrigger>
- <FolderInputIcon />
- Move to
- </MenuSubTrigger>
- <MenuSubPopup>
- {sections.map((section) => (
- <MenuItem key={section.id} onClick={() => onMove(section.id)}>
- {section.name}
- </MenuItem>
- ))}
- <MenuItem onClick={() => onMove(null)}>Unassigned</MenuItem>
- </MenuSubPopup>
- </MenuSub>
</MenuPopup>
</Menu>
</li>
@@ -623,7 +556,7 @@ function SortableRosterMarker(props: {
function RosterDragBoundary(props: {
marker: "pinned-header" | "pinned-divider";
- label: string;
+ label: string | null;
visible: boolean;
isDropTarget: boolean;
}) {
@@ -631,25 +564,35 @@ function RosterDragBoundary(props: {
<SortableRosterMarker
marker={props.marker}
data-testid={`roster-${props.marker}`}
- className="pointer-events-none relative mx-0.5 -mb-px h-0"
+ className="pointer-events-none relative mx-0.5 -mb-px h-0 w-full flex-none"
>
{props.visible ? (
- <div className="roster-drag-boundary-label absolute inset-x-2 top-1 flex h-4 items-center gap-2">
- <span
- className={cn(
- "shrink-0 text-xs font-medium",
- props.isDropTarget ? "text-primary" : "text-sidebar-foreground/80",
- )}
- >
- {props.label}
- </span>
- <span
- aria-hidden
- className={cn(
- "h-px flex-1",
- props.isDropTarget ? "bg-primary/50" : "bg-sidebar-foreground/25",
- )}
- />
+ <div
+ aria-hidden={props.label === null ? true : undefined}
+ className={cn(
+ "roster-drag-boundary-label absolute inset-x-2 top-1 h-4",
+ props.label !== null && "flex items-center gap-2",
+ )}
+ >
+ {props.label !== null ? (
+ <>
+ <span
+ className={cn(
+ "shrink-0 text-xs font-medium",
+ props.isDropTarget ? "text-primary" : "text-sidebar-foreground/80",
+ )}
+ >
+ {props.label}
+ </span>
+ <span
+ aria-hidden
+ className={cn(
+ "h-px flex-1",
+ props.isDropTarget ? "bg-primary/50" : "bg-sidebar-foreground/25",
+ )}
+ />
+ </>
+ ) : null}
</div>
) : null}
</SortableRosterMarker>
@@ -666,7 +609,7 @@ function RosterSectionPlaceholder(props: {
<SortableRosterMarker
marker={props.marker}
data-testid="roster-section-placeholder"
- className="relative mx-0.5 -mb-px h-0"
+ className="relative mx-0.5 -mb-px h-0 w-full flex-none"
>
{props.showHint ? (
<div
@@ -693,25 +636,17 @@ export default function BotRosterSidebar() {
reportFailure: false,
});
const pathname = useLocation({ select: (location) => location.pathname });
- const {
- bots,
- groups,
- lastMessageByBotId,
- selectedBotId,
- sections,
- pinnedItems,
- unassignedItems,
- } = useRosterStore(
- useShallow((state) => ({
- bots: state.bots,
- groups: state.groups,
- lastMessageByBotId: state.lastMessageByBotId,
- selectedBotId: state.selectedBotId,
- sections: state.sections,
- pinnedItems: state.pinnedItems,
- unassignedItems: state.unassignedItems,
- })),
- );
+ const { bots, groups, lastMessageByBotId, selectedBotId, pinnedItems, unassignedItems } =
+ useRosterStore(
+ useShallow((state) => ({
+ bots: state.bots,
+ groups: state.groups,
+ lastMessageByBotId: state.lastMessageByBotId,
+ selectedBotId: state.selectedBotId,
+ pinnedItems: state.pinnedItems,
+ unassignedItems: state.unassignedItems,
+ })),
+ );
const [query, setQuery] = useState("");
const activeBotThreadRef = useBotThreadRef(
pathname.startsWith("/bots/") ? (selectedBotId ?? "") : "",
@@ -750,27 +685,9 @@ export default function BotRosterSidebar() {
[visibleBots, visibleGroups],
);
const visiblePinnedItems = useMemo(() => pinnedItems.filter(liveItem), [liveItem, pinnedItems]);
- const visibleSectionLayouts = useMemo(
- () =>
- sections.map((section) => ({
- id: section.id,
- name: section.name,
- collapsed: !searching && section.collapsed,
- items: rosterSectionItems(section).filter(
- (item) => liveItem(item) && !pinnedKeys.has(rosterItemKey(item)),
- ),
- })),
- [liveItem, pinnedKeys, searching, sections],
- );
- const assignedKeys = useMemo(
- () => new Set(sections.flatMap((section) => rosterSectionItems(section).map(rosterItemKey))),
- [sections],
- );
const visibleUnassignedItems = useMemo(() => {
const remaining = (item: RosterItemRef) =>
- liveItem(item) &&
- !pinnedKeys.has(rosterItemKey(item)) &&
- !assignedKeys.has(rosterItemKey(item));
+ liveItem(item) && !pinnedKeys.has(rosterItemKey(item));
if (unassignedItems.length > 0) {
const ordered = unassignedItems.filter(remaining);
const seen = new Set(ordered.map(rosterItemKey));
@@ -788,17 +705,16 @@ export default function BotRosterSidebar() {
...visibleGroups.map((group) => ({ kind: "group" as const, id: group.id })),
...visibleBots.map((bot) => ({ kind: "bot" as const, id: bot.id })),
].filter(remaining);
- }, [assignedKeys, liveItem, pinnedKeys, unassignedItems, visibleBots, visibleGroups]);
+ }, [liveItem, pinnedKeys, unassignedItems, visibleBots, visibleGroups]);
const rosterListItems = useMemo(
() =>
buildRosterListItems({
pinnedItems: visiblePinnedItems,
- sections: visibleSectionLayouts,
+ sections: [],
unassignedItems: visibleUnassignedItems,
}),
- [visiblePinnedItems, visibleSectionLayouts, visibleUnassignedItems],
+ [visiblePinnedItems, visibleUnassignedItems],
);
- const firstSectionId = sections[0]?.id ?? null;
const zoneByEntryId = useMemo(() => {
const map = new Map<string, RosterZone>();
for (const item of rosterListItems) {
@@ -808,7 +724,7 @@ export default function BotRosterSidebar() {
}, [rosterListItems]);
const [dragState, setDragState] = useState<{
readonly activeId: string;
- readonly from: RosterZone | "section";
+ readonly from: RosterZone;
readonly targetZone: RosterZone | null;
readonly activationY: number | null;
} | null>(null);
@@ -847,11 +763,15 @@ export default function BotRosterSidebar() {
restrictBelowRosterLabel(args, dragLabelOffsetRef.current),
[],
);
+ const restrictRosterAxis = useCallback(
+ (args: Parameters<typeof restrictRosterDragAxis>[0]) =>
+ restrictRosterDragAxis(args, zoneByEntryId.get(String(args.active?.id)) ?? null),
+ [zoneByEntryId],
+ );
const handleRosterDragStart = useCallback(
(event: DragStartEvent) => {
const activeId = String(event.active.id);
- const sectionId = parseRosterSectionHeaderId(activeId);
- const from = sectionId ? ("section" as const) : zoneByEntryId.get(activeId);
+ const from = zoneByEntryId.get(activeId);
if (from === undefined) return;
listMotionRef.current?.suspend();
const list = rosterListRef.current;
@@ -867,7 +787,7 @@ export default function BotRosterSidebar() {
setDragState({
activeId,
from,
- targetZone: from === "section" ? null : from,
+ targetZone: from,
activationY:
event.activatorEvent instanceof PointerEvent ? event.activatorEvent.clientY : null,
});
@@ -877,9 +797,8 @@ export default function BotRosterSidebar() {
const handleRosterDragOver = useCallback(
(event: DragOverEvent) => {
const activeId = String(event.active.id);
- if (parseRosterSectionHeaderId(activeId)) return;
const target = event.over
- ? resolveRosterDropTarget(rosterListItems, activeId, String(event.over.id), firstSectionId)
+ ? resolveRosterDropTarget(rosterListItems, activeId, String(event.over.id), null)
: null;
setDragState((current) =>
current === null || current.activeId !== activeId
@@ -887,26 +806,15 @@ export default function BotRosterSidebar() {
: { ...current, targetZone: target?.zone ?? null },
);
},
- [firstSectionId, rosterListItems],
+ [rosterListItems],
);
const handleRosterDragEnd = useCallback(
(event: DragEndEvent) => {
const activeId = String(event.active.id);
const overId = event.over ? String(event.over.id) : null;
if (overId === null) return;
- const sectionId = parseRosterSectionHeaderId(activeId);
- if (sectionId) {
- useRosterStore.getState().applyRosterDrop(
- planRosterSectionDrop({
- sectionIds: sections.map((section) => section.id),
- activeSectionId: sectionId,
- overId,
- }),
- );
- return;
- }
const from = zoneByEntryId.get(activeId);
- const target = resolveRosterDropTarget(rosterListItems, activeId, overId, firstSectionId);
+ const target = resolveRosterDropTarget(rosterListItems, activeId, overId, null);
if (from === undefined || target === null) return;
useRosterStore.getState().applyRosterDrop(
planRosterDrop({
@@ -917,7 +825,7 @@ export default function BotRosterSidebar() {
}),
);
},
- [firstSectionId, rosterListItems, sections, visiblePinnedItems, zoneByEntryId],
+ [rosterListItems, visiblePinnedItems, zoneByEntryId],
);
useEffect(() => {
if (
@@ -948,41 +856,25 @@ export default function BotRosterSidebar() {
() =>
createRosterSortingStrategy({
items: rosterListItems,
- firstSectionId,
boundaryLabelHeight: ROSTER_DRAG_LABEL_HEIGHT,
}),
- [firstSectionId, rosterListItems],
+ [rosterListItems],
);
const dndCollisionDetection = useMemo(
() =>
createRosterCollisionDetection(
(id) => {
if (dragState === null) return true;
- if (dragState.from === "section") {
- return (
- parseRosterSectionHeaderId(id) !== null || id === rosterMarkerId("unassigned-header")
- );
- }
- return (
- resolveRosterDropTarget(rosterListItems, dragState.activeId, id, firstSectionId) !==
- null
- );
+ return resolveRosterDropTarget(rosterListItems, dragState.activeId, id, null) !== null;
},
{
items: rosterListItems,
activationY: dragState?.activationY ?? null,
- firstSectionId,
},
),
- [dragState, firstSectionId, rosterListItems],
+ [dragState, rosterListItems],
);
const dragTargetZone = dragState?.targetZone ?? null;
- const dropVerbFor = (id: string): RosterDropVerb | null => {
- if (dragState === null || dragState.activeId !== id || dragState.from === "section")
- return null;
- return resolveRosterDropVerb(dragState.from, dragTargetZone);
- };
-
// Remember the chat route the selected bot lands on, so re-selecting the
// bot returns to its conversation. The first run after a selection change
// is skipped: the route still belongs to the previously selected bot.
@@ -1005,8 +897,8 @@ export default function BotRosterSidebar() {
};
const shortcutBots = useMemo(
- () => orderRosterBotsForShortcuts(bots, pinnedItems, sections),
- [bots, pinnedItems, sections],
+ () => orderRosterBotsForShortcuts(bots, pinnedItems, []),
+ [bots, pinnedItems],
);
useEffect(() => {
const onWindowKeyDown = (event: KeyboardEvent) => {
@@ -1098,11 +990,6 @@ export default function BotRosterSidebar() {
void navigate({ to: "/groups/$groupId", params: { groupId } });
};
- const handleNewSection = () => {
- const name = window.prompt("Section name");
- if (name) useRosterStore.getState().createSection(name);
- };
-
const handleSelectGroup = (group: Group) => {
void navigate({ to: "/groups/$groupId", params: { groupId: group.id } });
};
@@ -1119,13 +1006,9 @@ export default function BotRosterSidebar() {
return (
<>
- <RosterSidebarHeader
- onNewBot={handleNewBot}
- onNewGroup={handleNewGroup}
- onNewSection={handleNewSection}
- />
+ <RosterSidebarHeader onNewBot={handleNewBot} onNewGroup={handleNewGroup} />
<SidebarContent
- className="gap-0"
+ className="gap-0 [overflow-anchor:none]"
fixedHeader={
<SidebarGroup className="px-[var(--sidebar-content-inset)] pb-1 pt-1 group-data-[collapsible=icon]:hidden">
<label className="flex h-9 items-center gap-2 rounded-lg bg-sidebar-row-hover px-2.5 ring-ring focus-within:ring-2">
@@ -1202,7 +1085,7 @@ export default function BotRosterSidebar() {
sensors={dndSensors}
collisionDetection={dndCollisionDetection}
modifiers={[
- restrictToVerticalAxis,
+ restrictRosterAxis,
restrictBelowPins,
restrictToFirstScrollableAncestor,
]}
@@ -1216,15 +1099,14 @@ export default function BotRosterSidebar() {
ref={attachListMotionRef}
role="list"
aria-label="Bots and groups"
- className="relative flex flex-col gap-px"
+ className="relative flex flex-wrap justify-center gap-x-1 gap-y-px"
>
{rosterListItems.map((item) => {
if (item.kind === "entry") {
- const dropVerb = dropVerbFor(rosterListItemId(item));
const pinned = pinnedKeys.has(rosterItemKey(item.item));
const zoneOrder = rosterItemsForZone(item.zone, {
pinnedItems: visiblePinnedItems,
- sections: visibleSectionLayouts,
+ sections: [],
unassignedItems: visibleUnassignedItems,
});
const zoneIndex = zoneOrder.findIndex((candidate) =>
@@ -1255,22 +1137,15 @@ export default function BotRosterSidebar() {
isActive={!groupRouteActive && selectedBotId === bot.id}
onSelect={handleSelect}
pinned={pinned}
- sections={sections}
onPin={(nextPinned) =>
useRosterStore
.getState()
.setItemPinned({ kind: "bot", id: bot.id }, nextPinned)
}
- onMove={(sectionId) =>
- useRosterStore
- .getState()
- .moveBotToSection(bot.id, sectionId)
- }
canMoveUp={canMoveUp}
canMoveDown={canMoveDown}
onNudge={onNudge}
sortable={bag}
- dropVerb={dropVerb}
/>
);
})()
@@ -1286,7 +1161,6 @@ export default function BotRosterSidebar() {
isActive={pathname === `/groups/${group.id}`}
onSelect={() => handleSelectGroup(group)}
pinned={pinned}
- sections={sections}
onPin={(nextPinned) =>
useRosterStore
.getState()
@@ -1295,16 +1169,10 @@ export default function BotRosterSidebar() {
nextPinned,
)
}
- onMove={(sectionId) =>
- useRosterStore
- .getState()
- .moveGroupToSection(group.id, sectionId)
- }
canMoveUp={canMoveUp}
canMoveDown={canMoveDown}
onNudge={onNudge}
sortable={bag}
- dropVerb={dropVerb}
/>
);
})()
@@ -1330,7 +1198,7 @@ export default function BotRosterSidebar() {
<RosterDragBoundary
key="pinned-divider"
marker="pinned-divider"
- label={sections[0]?.name ?? "Unassigned"}
+ label={null}
visible={dragging}
isDropTarget={dragTargetZone !== null && dragTargetZone !== "pinned"}
/>
@@ -1341,7 +1209,7 @@ export default function BotRosterSidebar() {
key="unassigned-header"
marker="unassigned-header"
data-testid="roster-unassigned-header"
- className="relative"
+ className="relative w-full flex-none"
>
<div
className={cn(
@@ -1351,7 +1219,7 @@ export default function BotRosterSidebar() {
)}
>
<ChevronDownIcon className="size-3.5" />
- <span>Unassigned</span>
+ <span>Bots</span>
<span className="tabular-nums">
{visibleUnassignedItems.length}
</span>
@@ -1372,7 +1240,7 @@ export default function BotRosterSidebar() {
<RosterSectionPlaceholder
key="unassigned-placeholder"
marker="unassigned-placeholder"
- label="Unassigned"
+ label="Bots"
showHint={
dragging &&
(visibleUnassignedItems.length === 0 ||
@@ -1384,141 +1252,8 @@ export default function BotRosterSidebar() {
isDropTarget={dragTargetZone === "unassigned"}
/>
);
- default: {
- if (typeof item.marker !== "object") return null;
- const marker = item.marker;
- if (marker.kind === "section-header") {
- const section = sections.find(
- (candidate) => candidate.id === marker.sectionId,
- );
- if (!section) return null;
- const layout = visibleSectionLayouts.find(
- (candidate) => candidate.id === section.id,
- );
- const collapsed = layout?.collapsed ?? section.collapsed;
- const count = layout?.items.length ?? 0;
- const zone = { sectionId: section.id };
- const sectionIndex = sections.findIndex(
- (candidate) => candidate.id === section.id,
- );
- return (
- <SortableRosterMarker
- key={rosterMarkerId(item.marker)}
- marker={item.marker}
- draggable={!searching}
- data-testid="roster-section-header"
- className="relative"
- >
- <div
- className="relative flex h-8 items-center rounded-md hover:bg-sidebar-row-hover"
- onContextMenu={(event) => {
- event.preventDefault();
- event.currentTarget
- .querySelector<HTMLButtonElement>("[data-section-actions]")
- ?.click();
- }}
- >
- <button
- type="button"
- aria-expanded={!collapsed}
- onClick={() =>
- useRosterStore.getState().toggleSection(section.id)
- }
- className={cn(
- "flex min-w-0 flex-1 cursor-grab items-center gap-1.5 px-2 text-left text-xs font-medium text-sidebar-muted-foreground active:cursor-grabbing",
- rosterZonesEqual(dragTargetZone ?? "pinned", zone) &&
- "text-primary",
- )}
- >
- {collapsed ? (
- <ChevronRightIcon className="size-3.5" />
- ) : (
- <ChevronDownIcon className="size-3.5" />
- )}
- <span className="truncate">{section.name}</span>
- <span className="tabular-nums">{count}</span>
- </button>
- <Menu>
- <MenuTrigger
- render={
- <button
- type="button"
- data-section-actions
- aria-label={`Actions for ${section.name}`}
- className="absolute right-2 top-1/2 size-px -translate-y-1/2 overflow-hidden opacity-0 outline-none focus-visible:size-7 focus-visible:overflow-visible focus-visible:opacity-100 focus-visible:ring-2 focus-visible:ring-ring"
- />
- }
- />
- <MenuPopup align="end">
- <MenuItem
- disabled={searching || sectionIndex <= 0}
- onClick={() =>
- useRosterStore
- .getState()
- .reorderSections(sectionIndex, sectionIndex - 1)
- }
- >
- <ArrowUpIcon />
- Move up
- </MenuItem>
- <MenuItem
- disabled={searching || sectionIndex >= sections.length - 1}
- onClick={() =>
- useRosterStore
- .getState()
- .reorderSections(sectionIndex, sectionIndex + 1)
- }
- >
- <ArrowDownIcon />
- Move down
- </MenuItem>
- <MenuItem
- variant="destructive"
- onClick={() =>
- useRosterStore.getState().deleteSection(section.id)
- }
- >
- <Trash2Icon />
- Delete section
- </MenuItem>
- </MenuPopup>
- </Menu>
- </div>
- </SortableRosterMarker>
- );
- }
- const zone = { sectionId: marker.sectionId };
- const layout = visibleSectionLayouts.find(
- (candidate) => candidate.id === marker.sectionId,
- );
- const activeEntry = dragState && parseRosterEntryId(dragState.activeId);
- return (
- <RosterSectionPlaceholder
- key={rosterMarkerId(item.marker)}
- marker={item.marker}
- label={layout?.name ?? "Section"}
- showHint={
- dragging &&
- (layout?.items.length === 0 ||
- layout?.collapsed === true ||
- (activeEntry !== null &&
- dragState?.from !== "section" &&
- dragState !== null &&
- rosterZonesEqual(dragState.from, zone) &&
- !rosterZoneHasVisibleEntries(
- rosterListItems,
- zone,
- activeEntry ?? undefined,
- ) &&
- dragTargetZone !== null &&
- !rosterZonesEqual(dragTargetZone, zone)))
- }
- isDropTarget={
- dragTargetZone !== null && rosterZonesEqual(dragTargetZone, zone)
- }
- />
- );
- }
+ default:
+ return null;
}
})}
</ul>
diff --git a/apps/web/src/components/roster/roster.drag.test.ts b/apps/web/src/components/roster/roster.drag.test.ts
index c0ab1a3e8..64bae54e7 100644
--- a/apps/web/src/components/roster/roster.drag.test.ts
+++ b/apps/web/src/components/roster/roster.drag.test.ts
@@ -1,8 +1,16 @@
import { describe, expect, it } from "vite-plus/test";
import { closestCenter, type CollisionDetection } from "@dnd-kit/core";
-import { verticalListSortingStrategy, type SortingStrategy } from "@dnd-kit/sortable";
+import {
+ rectSortingStrategy,
+ verticalListSortingStrategy,
+ type SortingStrategy,
+} from "@dnd-kit/sortable";
-import { createRosterCollisionDetection, createRosterSortingStrategy } from "./roster.drag";
+import {
+ createRosterCollisionDetection,
+ createRosterSortingStrategy,
+ restrictRosterDragAxis,
+} from "./roster.drag";
import {
buildRosterListItems,
rosterEntryId,
@@ -16,6 +24,22 @@ const stationary = { x: 0, y: 0, scaleX: 1, scaleY: 1 };
const akeru: RosterItemRef = { kind: "bot", id: "akeru" };
const mori: RosterItemRef = { kind: "bot", id: "mori" };
+function modifierArgs() {
+ return {
+ transform: { x: 12, y: 24, scaleX: 1, scaleY: 1 },
+ } as Parameters<typeof restrictRosterDragAxis>[0];
+}
+
+describe("roster drag axis", () => {
+ it("allows pinned cards to move across wrapped rows", () => {
+ expect(restrictRosterDragAxis(modifierArgs(), "pinned")).toMatchObject({ x: 12, y: 24 });
+ });
+
+ it("keeps full-width bot rows on the vertical axis", () => {
+ expect(restrictRosterDragAxis(modifierArgs(), "unassigned")).toMatchObject({ x: 0, y: 24 });
+ });
+});
+
function layout(items: readonly RosterListItem[], active: string, over: string, cardHeight = 52) {
let top = 100;
const rects = items.map((item) => {
@@ -87,9 +111,78 @@ describe("roster collision detection", () => {
const detector = createRosterCollisionDetection(() => true);
expect(detector(collisionArgs())[0]?.id).toBe(rosterEntryId(mori));
});
+
+ it("targets a section header while its section body is under the pointer", () => {
+ const items = buildRosterListItems({
+ pinnedItems: [],
+ sections: [
+ { id: "alpha", name: "Alpha", items: [akeru], collapsed: false },
+ { id: "beta", name: "Beta", items: [mori], collapsed: false },
+ ],
+ unassignedItems: [],
+ });
+ const active = rosterMarkerId({ kind: "section-header", sectionId: "alpha" });
+ const over = rosterEntryId(mori);
+ const { rects, activeIndex, overIndex } = layout(items, active, over);
+ const collisionRect = rects[overIndex]!;
+ const args = {
+ active: {
+ id: active,
+ data: { current: {} },
+ rect: { current: { initial: rects[activeIndex]!, translated: collisionRect } },
+ },
+ collisionRect,
+ droppableRects: new Map(items.map((item, index) => [rosterListItemId(item), rects[index]!])),
+ droppableContainers: items.map((item, index) => ({
+ id: rosterListItemId(item),
+ key: rosterListItemId(item),
+ disabled: false,
+ data: { current: {} },
+ node: { current: null },
+ rect: { current: rects[index]! },
+ })),
+ pointerCoordinates: null,
+ } satisfies Parameters<CollisionDetection>[0];
+ const detector = createRosterCollisionDetection(
+ (id) => id === rosterMarkerId({ kind: "section-header", sectionId: "beta" }),
+ { items },
+ );
+
+ expect(closestCenter(args)[0]?.id).toBe(over);
+ expect(detector(args)[0]?.id).toBe(
+ rosterMarkerId({ kind: "section-header", sectionId: "beta" }),
+ );
+ });
});
describe("roster drag projection", () => {
+ it("uses two-dimensional projection when reordering wrapped pinned cards", () => {
+ const cedar: RosterItemRef = { kind: "bot", id: "cedar" };
+ const items = buildRosterListItems({
+ pinnedItems: [akeru, mori, cedar],
+ sections: [],
+ unassignedItems: [],
+ });
+ const args = layout(items, rosterEntryId(akeru), rosterEntryId(mori));
+ const pinnedIndexes = items.flatMap((item, index) =>
+ item.kind === "entry" && item.zone === "pinned" ? [index] : [],
+ );
+ const [first, second, third] = pinnedIndexes;
+ if (first === undefined || second === undefined || third === undefined) {
+ throw new Error("expected three pinned entries");
+ }
+ args.rects[first] = { top: 100, bottom: 172, left: 0, right: 72, width: 72, height: 72 };
+ args.rects[second] = { top: 100, bottom: 172, left: 76, right: 148, width: 72, height: 72 };
+ args.rects[third] = { top: 176, bottom: 248, left: 0, right: 72, width: 72, height: 72 };
+ args.activeNodeRect = args.rects[first];
+
+ const strategy = createRosterSortingStrategy({ items });
+ expect(strategy({ ...args, index: second })).toEqual(
+ rectSortingStrategy({ ...args, index: second }),
+ );
+ expect(strategy({ ...args, index: second })?.x).not.toBe(0);
+ });
+
it("opens Pins label space while dragging an unassigned bot to the header", () => {
const items = buildRosterListItems({
pinnedItems: [],
diff --git a/apps/web/src/components/roster/roster.drag.ts b/apps/web/src/components/roster/roster.drag.ts
index 9b865c90a..6d5a8bfbe 100644
--- a/apps/web/src/components/roster/roster.drag.ts
+++ b/apps/web/src/components/roster/roster.drag.ts
@@ -1,6 +1,8 @@
import { closestCenter, type CollisionDetection, type Modifier } from "@dnd-kit/core";
+import { restrictToVerticalAxis } from "@dnd-kit/modifiers";
import {
defaultAnimateLayoutChanges,
+ rectSortingStrategy,
verticalListSortingStrategy,
type AnimateLayoutChanges,
type SortingStrategy,
@@ -37,12 +39,36 @@ export function restrictBelowRosterLabel(
return transform.y < minimumY ? { ...transform, y: minimumY } : transform;
}
+/** Pinned cards need both axes for their wrapped shelf. Full-width roster rows
+ * stay vertical so their movement matches their one-column layout. */
+export function restrictRosterDragAxis(
+ args: Parameters<Modifier>[0],
+ sourceZone: RosterZone | null,
+) {
+ return sourceZone === "pinned" ? args.transform : restrictToVerticalAxis(args);
+}
+
function markerIsPinnedBoundary(marker: RosterListMarker): boolean {
return marker === "pinned-header" || marker === "pinned-divider";
}
-/** Reject the nearest unsupported target without selecting another section.
- * Recreate this detector when drop eligibility changes. */
+function sectionTargetForItem(items: readonly RosterListItem[], id: string): string | null {
+ const item = items.find((candidate) => rosterListItemId(candidate) === id);
+ if (!item) return null;
+ if (item.kind === "entry") {
+ if (item.zone === "unassigned") return rosterMarkerId("unassigned-header");
+ if (item.zone === "pinned") return null;
+ return rosterMarkerId({ kind: "section-header", sectionId: item.zone.sectionId });
+ }
+ if (item.marker === "unassigned-placeholder") return rosterMarkerId("unassigned-header");
+ if (typeof item.marker === "object" && item.marker.kind === "section-placeholder") {
+ return rosterMarkerId({ kind: "section-header", sectionId: item.marker.sectionId });
+ }
+ return null;
+}
+
+/** Reject unsupported targets. A section drag treats its full visible body as
+ * the section header target. Recreate this detector when eligibility changes. */
export function createRosterCollisionDetection(
isValidTarget: (id: string) => boolean,
options: {
@@ -111,7 +137,13 @@ export function createRosterCollisionDetection(
const id = String(nearest.id);
const valid = validity.get(id) ?? isValidTarget(id);
validity.set(id, valid);
- return valid ? collisions : collisions.filter((collision) => collision.id === args.active.id);
+ if (valid) return collisions;
+ if (items && parseRosterSectionHeaderId(String(args.active.id)) !== null) {
+ const targetId = sectionTargetForItem(items, id);
+ const target = collisions.find((collision) => String(collision.id) === targetId);
+ if (target) return [target, ...collisions.filter((collision) => collision !== target)];
+ }
+ return collisions.filter((collision) => collision.id === args.active.id);
};
}
@@ -343,6 +375,16 @@ export function createRosterSortingStrategy(input: {
}
return (args) => {
+ const active = items[args.activeIndex];
+ const over = items[args.overIndex];
+ if (
+ active?.kind === "entry" &&
+ active.zone === "pinned" &&
+ over?.kind === "entry" &&
+ over.zone === "pinned"
+ ) {
+ return rectSortingStrategy(args);
+ }
if (
previous?.rects !== args.rects ||
previous.activeIndex !== args.activeIndex ||
diff --git a/apps/web/src/components/roster/roster.logic.test.ts b/apps/web/src/components/roster/roster.logic.test.ts
index ca007b74a..60f2d4aa9 100644
--- a/apps/web/src/components/roster/roster.logic.test.ts
+++ b/apps/web/src/components/roster/roster.logic.test.ts
@@ -31,7 +31,6 @@ import {
rosterItemsForZone,
buildRosterListItems,
resolveRosterDropTarget,
- resolveRosterDropVerb,
rosterBotDragId,
rosterEntryId,
rosterGroupDropId,
@@ -585,7 +584,6 @@ describe("roster drag drop planning", () => {
pinnedOrder: [akeru],
}),
).toEqual({ kind: "pin", item: mori, order: [mori, akeru] });
- expect(resolveRosterDropVerb("unassigned", "pinned")).toBe("pin");
});
it("unpins a bot dropped into Unassigned and keeps the named section as a move", () => {
@@ -610,8 +608,6 @@ describe("roster drag drop planning", () => {
order: [akeru, mori],
unpin: true,
});
- expect(resolveRosterDropVerb("pinned", "unassigned")).toBe("unpin");
- expect(resolveRosterDropVerb({ sectionId: "news" }, "unassigned")).toBe("move");
});
it("keeps a collapsed or emptied section droppable after its last item leaves", () => {
@@ -656,7 +652,6 @@ describe("roster drag drop planning", () => {
pinnedOrder: [akeru],
}).kind,
).toBe("none");
- expect(resolveRosterDropVerb("pinned", "pinned")).toBeNull();
});
it("nudges an item one slot without wrapping past the ends", () => {
diff --git a/apps/web/src/components/roster/roster.logic.ts b/apps/web/src/components/roster/roster.logic.ts
index 0aeadebd7..1fd56eb59 100644
--- a/apps/web/src/components/roster/roster.logic.ts
+++ b/apps/web/src/components/roster/roster.logic.ts
@@ -599,18 +599,6 @@ export function resolveRosterDropTarget(
};
}
-export type RosterDropVerb = "pin" | "unpin" | "move";
-
-export function resolveRosterDropVerb(
- from: RosterZone,
- to: RosterZone | null,
-): RosterDropVerb | null {
- if (to === null || rosterZonesEqual(from, to)) return null;
- if (to === "pinned") return "pin";
- if (from === "pinned") return "unpin";
- return "move";
-}
-
export type RosterDropPlan =
| { readonly kind: "none" }
| { readonly kind: "reorder-pinned"; readonly order: readonly RosterItemRef[] }
diff --git a/apps/web/src/components/roster/rosterStore.test.ts b/apps/web/src/components/roster/rosterStore.test.ts
index c4306d3f0..5c336f737 100644
--- a/apps/web/src/components/roster/rosterStore.test.ts
+++ b/apps/web/src/components/roster/rosterStore.test.ts
@@ -1,6 +1,6 @@
import { afterEach, beforeEach, describe, expect, it } from "vite-plus/test";
-import { reorderVisibleRosterBots, useRosterStore } from "./rosterStore";
+import { flattenPersistedSections, reorderVisibleRosterBots, useRosterStore } from "./rosterStore";
import type { Bot, Group } from "./types";
function bot(id: string, archivedAt: string | null = null): Bot {
@@ -45,7 +45,6 @@ beforeEach(() => {
lastMessageByBotId: {},
selectedBotId: null,
chatPathByBotId: {},
- sections: [],
pinnedItems: [],
unassignedItems: [],
environmentId: null,
@@ -59,7 +58,6 @@ afterEach(() => {
lastMessageByBotId: initialState.lastMessageByBotId,
selectedBotId: initialState.selectedBotId,
chatPathByBotId: initialState.chatPathByBotId,
- sections: initialState.sections,
pinnedItems: initialState.pinnedItems,
unassignedItems: initialState.unassignedItems,
environmentId: initialState.environmentId,
@@ -133,51 +131,7 @@ describe("bot order", () => {
});
});
-describe("roster sections and pins", () => {
- it("moves a bot into a section without changing group or bot identity", () => {
- const bots = [bot("one"), bot("two")];
- useRosterStore.setState({
- bots,
- sections: [{ id: "news", name: "News", botIds: [], collapsed: false }],
- });
-
- useRosterStore.getState().moveBotToSection("one", "news");
-
- expect(useRosterStore.getState().sections[0]?.botIds).toEqual(["one"]);
- expect(useRosterStore.getState().bots).toEqual(bots);
- });
-
- it("moves a bot between sections and back to unassigned", () => {
- useRosterStore.setState({
- bots: [bot("one")],
- sections: [
- { id: "first", name: "First", botIds: ["one"], collapsed: false },
- { id: "second", name: "Second", botIds: [], collapsed: false },
- ],
- });
-
- useRosterStore.getState().moveBotToSection("one", "second");
- expect(useRosterStore.getState().sections.map((section) => section.botIds)).toEqual([
- [],
- ["one"],
- ]);
-
- useRosterStore.getState().moveBotToSection("one", null);
- expect(useRosterStore.getState().sections.map((section) => section.botIds)).toEqual([[], []]);
- });
-
- it("reorders bots inside Unassigned", () => {
- useRosterStore.setState({ bots: [bot("one"), bot("two"), bot("three")] });
-
- useRosterStore.getState().moveBotToSection("three", null, 0);
-
- expect(useRosterStore.getState().bots.map((entry) => entry.id)).toEqual([
- "three",
- "one",
- "two",
- ]);
- });
-
+describe("roster pins", () => {
it("pins bots and groups as separate quick-launch items", () => {
useRosterStore.getState().setItemPinned({ kind: "bot", id: "one" }, true);
useRosterStore.getState().setItemPinned({ kind: "group", id: "crew" }, true);
@@ -186,140 +140,35 @@ describe("roster sections and pins", () => {
expect(useRosterStore.getState().pinnedItems).toEqual([{ kind: "group", id: "crew" }]);
});
- it("moves a group between a section and Unassigned", () => {
- useRosterStore.setState({
- groups: [group("crew")],
- sections: [
- {
- id: "launch",
- name: "Launch",
- botIds: [],
- groupIds: [],
- collapsed: false,
- },
- ],
- });
-
- useRosterStore.getState().moveGroupToSection("crew", "launch");
- expect(useRosterStore.getState().sections[0]?.groupIds).toEqual(["crew"]);
-
- useRosterStore.getState().moveGroupToSection("crew", null);
- expect(useRosterStore.getState().sections[0]?.groupIds).toEqual([]);
- });
-
- it("reorders sections and persists collapsed state", () => {
- useRosterStore.setState({
- sections: [
- { id: "first", name: "First", botIds: [], collapsed: false },
- { id: "second", name: "Second", botIds: [], collapsed: false },
- ],
- });
-
- useRosterStore.getState().toggleSection("first");
- useRosterStore.getState().reorderSections(0, 1);
-
- expect(
- useRosterStore.getState().sections.map(({ id, collapsed }) => ({ id, collapsed })),
- ).toEqual([
- { id: "second", collapsed: false },
- { id: "first", collapsed: true },
- ]);
- });
-
- it("deletes a section without deleting its bots", () => {
- const bots = [bot("one"), bot("two")];
- useRosterStore.setState({
- bots,
- sections: [{ id: "old", name: "Old", botIds: ["one"], collapsed: false }],
- });
-
- useRosterStore.getState().deleteSection("old");
-
- expect(useRosterStore.getState().sections).toEqual([]);
- expect(useRosterStore.getState().bots).toEqual(bots);
- });
-
- it("does not erase another environment's layout", () => {
- useRosterStore.setState({
- environmentId: "env-one",
- bots: [bot("one")],
- sections: [{ id: "work", name: "Work", botIds: ["one"], collapsed: false }],
- });
- useRosterStore.getState().toggleSection("work");
-
- useRosterStore.getState().replaceRoster({
- environmentId: "env-two",
- bots: [bot("two")],
- groups: [],
- });
- expect(useRosterStore.getState().sections).toEqual([]);
- useRosterStore.getState().replaceRoster({
- environmentId: "env-one",
- bots: [bot("one")],
- groups: [],
- });
-
- expect(useRosterStore.getState().sections).toEqual([
- {
- id: "work",
- name: "Work",
- botIds: ["one"],
- groupIds: [],
- items: [{ kind: "bot", id: "one" }],
- collapsed: true,
- },
- ]);
- });
-
- it("applies pin, unpin, and mixed-section drops without changing group membership", () => {
+ it("unpins a bot into the main list without changing group membership", () => {
const crew = group("crew");
useRosterStore.setState({
bots: [bot("akeru"), bot("mori")],
groups: [crew],
- sections: [
- {
- id: "news",
- name: "News",
- botIds: ["akeru"],
- groupIds: ["crew"],
- items: [
- { kind: "group", id: "crew" },
- { kind: "bot", id: "akeru" },
- ],
- collapsed: false,
- },
- ],
+ pinnedItems: [{ kind: "bot", id: "mori" }],
+ unassignedItems: [{ kind: "bot", id: "akeru" }],
});
- useRosterStore.getState().applyRosterDrop({
- kind: "pin",
- item: { kind: "bot", id: "mori" },
- order: [{ kind: "bot", id: "mori" }],
- });
- expect(useRosterStore.getState().pinnedItems).toEqual([{ kind: "bot", id: "mori" }]);
- expect(useRosterStore.getState().groups).toEqual([crew]);
-
useRosterStore.getState().applyRosterDrop({
kind: "move",
item: { kind: "bot", id: "mori" },
- zone: { sectionId: "news" },
+ zone: "unassigned",
order: [
- { kind: "group", id: "crew" },
- { kind: "bot", id: "akeru" },
{ kind: "bot", id: "mori" },
+ { kind: "bot", id: "akeru" },
],
unpin: true,
});
+
expect(useRosterStore.getState().pinnedItems).toEqual([]);
- expect(useRosterStore.getState().sections[0]?.items).toEqual([
- { kind: "group", id: "crew" },
- { kind: "bot", id: "akeru" },
- { kind: "bot", id: "mori" },
+ expect(useRosterStore.getState().unassignedItems.map((item) => item.id)).toEqual([
+ "mori",
+ "akeru",
]);
- expect(useRosterStore.getState().groups[0]?.members).toEqual([]);
+ expect(useRosterStore.getState().groups).toEqual([crew]);
});
- it("nudges unassigned bots with Move up without changing group membership", () => {
+ it("nudges bots in the main list without changing group membership", () => {
useRosterStore.setState({
bots: [bot("akeru"), bot("mori"), bot("scout")],
groups: [group("crew")],
@@ -363,40 +212,32 @@ describe("roster sections and pins", () => {
]);
});
- it("nudges pinned and section items without crossing zones", () => {
- useRosterStore.setState({
- bots: [bot("akeru"), bot("mori"), bot("scout")],
- groups: [group("crew")],
- pinnedItems: [
- { kind: "bot", id: "akeru" },
- { kind: "group", id: "crew" },
- ],
+ it("flattens legacy sections into the main list in their saved order", () => {
+ const migrated = flattenPersistedSections({
sections: [
{
- id: "news",
- name: "News",
- botIds: ["mori", "scout"],
- groupIds: [],
+ id: "first",
+ name: "First",
+ botIds: ["mori"],
+ groupIds: ["crew"],
items: [
+ { kind: "group", id: "crew" },
{ kind: "bot", id: "mori" },
- { kind: "bot", id: "scout" },
],
- collapsed: false,
+ collapsed: true,
},
],
+ unassignedItems: [
+ { kind: "bot", id: "mori" },
+ { kind: "bot", id: "akeru" },
+ ],
});
- useRosterStore.getState().nudgeRosterItem({ kind: "group", id: "crew" }, -1);
- expect(useRosterStore.getState().pinnedItems.map((item) => item.id)).toEqual(["crew", "akeru"]);
-
- useRosterStore.getState().nudgeRosterItem({ kind: "bot", id: "scout" }, -1);
- expect(useRosterStore.getState().sections[0]?.items?.map((item) => item.id)).toEqual([
- "scout",
- "mori",
+ expect(migrated?.sections).toEqual([]);
+ expect(migrated?.unassignedItems).toEqual([
+ { kind: "group", id: "crew" },
+ { kind: "bot", id: "mori" },
+ { kind: "bot", id: "akeru" },
]);
- expect(useRosterStore.getState().pinnedItems.map((item) => item.id)).toEqual(["crew", "akeru"]);
-
- useRosterStore.getState().nudgeRosterItem({ kind: "group", id: "crew" }, -1);
- expect(useRosterStore.getState().pinnedItems.map((item) => item.id)).toEqual(["crew", "akeru"]);
});
});
diff --git a/apps/web/src/components/roster/rosterStore.ts b/apps/web/src/components/roster/rosterStore.ts
index 67380dd48..47f2e29e7 100644
--- a/apps/web/src/components/roster/rosterStore.ts
+++ b/apps/web/src/components/roster/rosterStore.ts
@@ -1,12 +1,10 @@
import { create } from "zustand";
-import { randomUUID } from "../../lib/utils";
import {
moveRosterItemInOrder,
rosterItemKey,
rosterItemsEqual,
rosterSectionItems,
- splitRosterSectionItems,
type RosterDropPlan,
type RosterItemRef,
type RosterLastMessage,
@@ -26,12 +24,12 @@ interface PersistedRoster {
selectedBotId?: string;
chatPathByBotId?: Record<string, string>;
botLayout?: Array<{ id: string; pinned: boolean }>;
- sections?: RosterSection[];
+ sections?: LegacyRosterSection[];
pinnedItems?: RosterItemRef[];
unassignedItems?: RosterItemRef[];
}
-export interface RosterSection {
+interface LegacyRosterSection {
id: string;
name: string;
botIds: string[];
@@ -58,47 +56,6 @@ function isRosterItemList(value: unknown): value is RosterItemRef[] {
);
}
-function withSectionItems(section: RosterSection, items: readonly RosterItemRef[]): RosterSection {
- const split = splitRosterSectionItems(items);
- return {
- ...section,
- items: [...items],
- botIds: split.botIds,
- groupIds: split.groupIds,
- };
-}
-
-function removeItemFromSections(
- sections: readonly RosterSection[],
- item: RosterItemRef,
-): RosterSection[] {
- return sections.map((section) =>
- withSectionItems(
- section,
- rosterSectionItems(section).filter((candidate) => !rosterItemsEqual(candidate, item)),
- ),
- );
-}
-
-/** Insert `moved` into `previous` using the visible drop order, keeping
- * hidden (pinned) members in place so pin state is not a membership change. */
-function mergeVisibleOrder(
- previous: readonly RosterItemRef[],
- visibleOrder: readonly RosterItemRef[],
- moved: RosterItemRef,
-): RosterItemRef[] {
- const withoutMoved = previous.filter((item) => !rosterItemsEqual(item, moved));
- const movedIndex = visibleOrder.findIndex((item) => rosterItemsEqual(item, moved));
- const after = movedIndex >= 0 ? visibleOrder[movedIndex + 1] : undefined;
- const insertAt =
- after === undefined
- ? withoutMoved.length
- : withoutMoved.findIndex((item) => rosterItemsEqual(item, after));
- const next = [...withoutMoved];
- next.splice(insertAt < 0 ? next.length : insertAt, 0, moved);
- return next;
-}
-
function readPersistedRoster(environmentId: string | null = null): PersistedRoster | null {
const key = persistedRosterKey(environmentId);
const inMemory = persistedRosterMemory.get(key);
@@ -154,7 +111,7 @@ function readPersistedRoster(environmentId: string | null = null): PersistedRost
? {
sections: (
sections as Array<
- Omit<RosterSection, "groupIds" | "items"> & {
+ Omit<LegacyRosterSection, "groupIds" | "items"> & {
groupIds?: string[];
items?: RosterItemRef[];
}
@@ -165,11 +122,10 @@ function readPersistedRoster(environmentId: string | null = null): PersistedRost
groupIds: section.groupIds ?? [],
items: section.items,
});
- const split = splitRosterSectionItems(items);
return {
...section,
- botIds: split.botIds,
- groupIds: split.groupIds,
+ botIds: items.filter((item) => item.kind === "bot").map((item) => item.id),
+ groupIds: items.filter((item) => item.kind === "group").map((item) => item.id),
items,
};
}),
@@ -194,26 +150,34 @@ function persistRoster(roster: PersistedRoster, environmentId: string | null): v
}
}
+export function flattenPersistedSections(roster: PersistedRoster | null): PersistedRoster | null {
+ if (!roster) return null;
+ const unassignedItems: RosterItemRef[] = [];
+ const seen = new Set<string>();
+ for (const item of [
+ ...(roster.sections ?? []).flatMap((section) => rosterSectionItems(section)),
+ ...(roster.unassignedItems ?? []),
+ ]) {
+ const key = rosterItemKey(item);
+ if (seen.has(key)) continue;
+ seen.add(key);
+ unassignedItems.push(item);
+ }
+ return { ...roster, sections: [], unassignedItems };
+}
+
interface RosterStore {
bots: Bot[];
groups: Group[];
lastMessageByBotId: Record<string, RosterLastMessage>;
selectedBotId: string | null;
chatPathByBotId: Record<string, string>;
- sections: RosterSection[];
pinnedItems: RosterItemRef[];
unassignedItems: RosterItemRef[];
environmentId: string | null;
selectBot: (botId: string) => void;
setBotAvatar: (botId: string, avatar: BotAvatar) => boolean;
commitBotLayout: (bots: Bot[]) => void;
- createSection: (name: string) => void;
- toggleSection: (sectionId: string) => void;
- deleteSection: (sectionId: string) => void;
- moveGroupToSection: (groupId: string, sectionId: string | null, index?: number) => void;
- moveBotToSection: (botId: string, sectionId: string | null, index?: number) => void;
- moveItemToSection: (item: RosterItemRef, sectionId: string | null, index?: number) => void;
- reorderSections: (sourceIndex: number, destinationIndex: number) => void;
nudgeRosterItem: (item: RosterItemRef, delta: -1 | 1) => void;
setItemPinned: (item: RosterItemRef, pinned: boolean) => void;
applyRosterDrop: (plan: RosterDropPlan) => void;
@@ -262,7 +226,6 @@ function saveState(
| "bots"
| "selectedBotId"
| "chatPathByBotId"
- | "sections"
| "pinnedItems"
| "unassignedItems"
| "environmentId"
@@ -273,7 +236,6 @@ function saveState(
...(state.selectedBotId === null ? {} : { selectedBotId: state.selectedBotId }),
chatPathByBotId: state.chatPathByBotId,
botLayout: state.bots.map((bot) => ({ id: bot.id, pinned: bot.pinned })),
- sections: state.sections,
pinnedItems: state.pinnedItems,
unassignedItems: state.unassignedItems,
},
@@ -281,7 +243,7 @@ function saveState(
);
}
-const persisted = readPersistedRoster();
+const persisted = flattenPersistedSections(readPersistedRoster());
export const useRosterStore = create<RosterStore>((set, get) => ({
bots: [],
@@ -289,7 +251,6 @@ export const useRosterStore = create<RosterStore>((set, get) => ({
lastMessageByBotId: {},
selectedBotId: persisted?.selectedBotId ?? null,
chatPathByBotId: persisted?.chatPathByBotId ?? {},
- sections: persisted?.sections ?? [],
pinnedItems: persisted?.pinnedItems ?? [],
unassignedItems: persisted?.unassignedItems ?? [],
environmentId: null,
@@ -335,115 +296,9 @@ export const useRosterStore = create<RosterStore>((set, get) => ({
saveState(get());
},
- createSection: (name) => {
- const trimmed = name.trim();
- if (!trimmed) return;
- set((state) => ({
- sections: [
- ...state.sections,
- {
- id: randomUUID(),
- name: trimmed,
- botIds: [],
- groupIds: [],
- items: [],
- collapsed: false,
- },
- ],
- }));
- saveState(get());
- },
-
- toggleSection: (sectionId) => {
- set((state) => ({
- sections: state.sections.map((section) =>
- section.id === sectionId ? { ...section, collapsed: !section.collapsed } : section,
- ),
- }));
- saveState(get());
- },
-
- deleteSection: (sectionId) => {
- if (!get().sections.some((section) => section.id === sectionId)) return;
- set((state) => ({
- sections: state.sections.filter((section) => section.id !== sectionId),
- }));
- saveState(get());
- },
-
- moveBotToSection: (botId, sectionId, index) => {
- get().moveItemToSection({ kind: "bot", id: botId }, sectionId, index);
- },
-
- moveGroupToSection: (groupId, sectionId, index) => {
- get().moveItemToSection({ kind: "group", id: groupId }, sectionId, index);
- },
-
- moveItemToSection: (item, sectionId, index) => {
- if (
- item.kind === "bot" &&
- !get().bots.some((bot) => bot.id === item.id && bot.archivedAt === null)
- ) {
- return;
- }
- if (item.kind === "group" && !get().groups.some((group) => group.id === item.id)) return;
- if (sectionId !== null && !get().sections.some((section) => section.id === sectionId)) return;
- set((state) => {
- const sections = removeItemFromSections(state.sections, item).map((section) => {
- if (section.id !== sectionId) return section;
- const items = rosterSectionItems(section);
- items.splice(Math.min(Math.max(index ?? items.length, 0), items.length), 0, item);
- return withSectionItems(section, items);
- });
- const assignedKeys = new Set(
- sections.flatMap((section) => rosterSectionItems(section).map(rosterItemKey)),
- );
- const remainingUnassigned = state.unassignedItems.filter(
- (candidate) =>
- !rosterItemsEqual(candidate, item) && !assignedKeys.has(rosterItemKey(candidate)),
- );
- if (sectionId !== null) {
- return { sections, unassignedItems: remainingUnassigned };
- }
- remainingUnassigned.splice(
- Math.min(Math.max(index ?? remainingUnassigned.length, 0), remainingUnassigned.length),
- 0,
- item,
- );
- if (item.kind !== "bot") {
- return { sections, unassignedItems: remainingUnassigned };
- }
- const assignedBotIds = new Set(sections.flatMap((section) => section.botIds));
- const unassignedIds = state.bots
- .filter(
- (bot) => bot.archivedAt === null && !assignedBotIds.has(bot.id) && bot.id !== item.id,
- )
- .map((bot) => bot.id);
- unassignedIds.splice(
- Math.min(Math.max(index ?? unassignedIds.length, 0), unassignedIds.length),
- 0,
- item.id,
- );
- const unassigned = new Set(unassignedIds);
- const botsById = new Map(state.bots.map((bot) => [bot.id, bot] as const));
- let botIndex = 0;
- return {
- sections,
- unassignedItems: remainingUnassigned,
- bots: state.bots.map((bot) =>
- unassigned.has(bot.id) ? (botsById.get(unassignedIds[botIndex++]!) ?? bot) : bot,
- ),
- };
- });
- saveState(get());
- },
-
applyRosterDrop: (plan) => {
if (plan.kind === "none") return;
- if (plan.kind === "reorder-section") {
- get().reorderSections(plan.fromIndex, plan.toIndex);
- return;
- }
+ if (plan.kind === "reorder-section") return;
if (plan.kind === "reorder-pinned") {
set({ pinnedItems: [...plan.order] });
saveState(get());
@@ -454,26 +309,15 @@ export const useRosterStore = create<RosterStore>((set, get) => ({
saveState(get());
return;
}
+ if (plan.zone !== "unassigned") return;
set((state) => {
const pinnedItems = plan.unpin
? state.pinnedItems.filter((candidate) => !rosterItemsEqual(candidate, plan.item))
: state.pinnedItems;
- const sectionId = typeof plan.zone === "object" ? plan.zone.sectionId : null;
- const sections = removeItemFromSections(state.sections, plan.item).map((section) => {
- if (section.id !== sectionId) return section;
- return withSectionItems(
- section,
- mergeVisibleOrder(rosterSectionItems(section), plan.order, plan.item),
- );
- });
- const unassignedItems =
- sectionId === null
- ? [...plan.order]
- : state.unassignedItems.filter((candidate) => !rosterItemsEqual(candidate, plan.item));
- if (plan.item.kind !== "bot" || sectionId !== null) {
- return { pinnedItems, sections, unassignedItems };
+ const unassignedItems = [...plan.order];
+ if (plan.item.kind !== "bot") {
+ return { pinnedItems, unassignedItems };
}
- const assignedBotIds = new Set(sections.flatMap((section) => section.botIds));
const unassignedIds = plan.order
.filter((entry) => entry.kind === "bot")
.map((entry) => entry.id);
@@ -482,36 +326,15 @@ export const useRosterStore = create<RosterStore>((set, get) => ({
let botIndex = 0;
return {
pinnedItems,
- sections,
unassignedItems,
bots: state.bots.map((bot) =>
- unassigned.has(bot.id) && !assignedBotIds.has(bot.id)
- ? (botsById.get(unassignedIds[botIndex++]!) ?? bot)
- : bot,
+ unassigned.has(bot.id) ? (botsById.get(unassignedIds[botIndex++]!) ?? bot) : bot,
),
};
});
saveState(get());
},
- reorderSections: (sourceIndex, destinationIndex) => {
- if (
- sourceIndex === destinationIndex ||
- sourceIndex < 0 ||
- destinationIndex < 0 ||
- sourceIndex >= get().sections.length ||
- destinationIndex >= get().sections.length
- ) {
- return;
- }
- const sections = [...get().sections];
- const [moved] = sections.splice(sourceIndex, 1);
- if (!moved) return;
- sections.splice(destinationIndex, 0, moved);
- set({ sections });
- saveState(get());
- },
-
nudgeRosterItem: (item, delta) => {
const state = get();
const pinned = moveRosterItemInOrder(state.pinnedItems, item, delta);
@@ -520,23 +343,8 @@ export const useRosterStore = create<RosterStore>((set, get) => ({
saveState(get());
return;
}
- for (const section of state.sections) {
- const moved = moveRosterItemInOrder(rosterSectionItems(section), item, delta);
- if (!moved) continue;
- set({
- sections: state.sections.map((candidate) =>
- candidate.id === section.id ? withSectionItems(candidate, moved) : candidate,
- ),
- });
- saveState(get());
- return;
- }
- const assigned = new Set(
- state.sections.flatMap((section) => rosterSectionItems(section).map(rosterItemKey)),
- );
const pinnedKeys = new Set(state.pinnedItems.map(rosterItemKey));
- const remaining = (candidate: RosterItemRef) =>
- !assigned.has(rosterItemKey(candidate)) && !pinnedKeys.has(rosterItemKey(candidate));
+ const remaining = (candidate: RosterItemRef) => !pinnedKeys.has(rosterItemKey(candidate));
const unassigned = state.unassignedItems.filter(remaining);
const seen = new Set(unassigned.map(rosterItemKey));
for (const group of state.groups) {
@@ -593,7 +401,9 @@ export const useRosterStore = create<RosterStore>((set, get) => ({
replaceRoster: (input) => {
const switchingEnvironment = get().environmentId !== input.environmentId;
- const scopedPersisted = switchingEnvironment ? readPersistedRoster(input.environmentId) : null;
+ const scopedPersisted = switchingEnvironment
+ ? flattenPersistedSections(readPersistedRoster(input.environmentId))
+ : null;
const targetPersisted = switchingEnvironment
? (scopedPersisted ?? (get().environmentId === null ? persisted : null))
: null;
@@ -618,9 +428,6 @@ export const useRosterStore = create<RosterStore>((set, get) => ({
)
? targetSelectedBotId
: firstAvailableBotId(bots);
- const targetSections = switchingEnvironment
- ? (targetPersisted?.sections ?? [])
- : get().sections;
const targetPinnedItems = switchingEnvironment
? (targetPersisted?.pinnedItems ?? [])
: get().pinnedItems;
@@ -631,9 +438,6 @@ export const useRosterStore = create<RosterStore>((set, get) => ({
item.kind === "bot"
? bots.some((bot) => bot.id === item.id && bot.archivedAt === null)
: input.groups.some((group) => group.id === item.id);
- const sections = targetSections.map((section) =>
- withSectionItems(section, rosterSectionItems(section).filter(liveItem)),
- );
set({
environmentId: input.environmentId,
bots,
@@ -641,7 +445,6 @@ export const useRosterStore = create<RosterStore>((set, get) => ({
chatPathByBotId: switchingEnvironment
? (targetPersisted?.chatPathByBotId ?? {})
: get().chatPathByBotId,
- sections,
pinnedItems: targetPinnedItems.filter(liveItem),
unassignedItems: targetUnassignedItems.filter(liveItem),
selectedBotId,
diff --git a/apps/web/src/components/sidebar/SidebarChrome.test.ts b/apps/web/src/components/sidebar/SidebarChrome.test.ts
index d615b3218..96552fb46 100644
--- a/apps/web/src/components/sidebar/SidebarChrome.test.ts
+++ b/apps/web/src/components/sidebar/SidebarChrome.test.ts
@@ -234,6 +234,8 @@ describe("sidebar footer", () => {
expect(source).not.toContain("botEnvironment.groups.assignMember");
expect(source).toContain("roster-pinned-header");
+ expect(source).toContain("[overflow-anchor:none]");
+ expect(source).toContain("restrictRosterAxis");
expect(source).not.toContain("KeyboardSensor");
expect(source).toContain("Move up");
expect(source).toContain("Move down");
diff --git a/apps/web/src/components/ui/sidebar.test.tsx b/apps/web/src/components/ui/sidebar.test.tsx
index 5bb0a9ba0..55ca4c635 100644
--- a/apps/web/src/components/ui/sidebar.test.tsx
+++ b/apps/web/src/components/ui/sidebar.test.tsx
@@ -3,6 +3,7 @@ import { describe, expect, it } from "vite-plus/test";
import {
Sidebar,
+ SidebarContent,
SidebarMenuAction,
SidebarMenuButton,
SidebarMenuSubButton,
@@ -67,6 +68,18 @@ describe("sidebar interactive cursors", () => {
expect(html).toContain("motion-reduce:transition-none");
});
+ it("preserves browser scroll anchoring for shared sidebar lists", () => {
+ const html = renderToStaticMarkup(
+ <SidebarProvider>
+ <Sidebar>
+ <SidebarContent>Scout</SidebarContent>
+ </Sidebar>
+ </SidebarProvider>,
+ );
+
+ expect(html).not.toContain("[overflow-anchor:none]");
+ });
+
it("uses shared geometry and icon constraints for menu buttons by default", () => {
const html = renderSidebarButton();
diff --git a/docs/internals/glossary.md b/docs/internals/glossary.md
index 99516bc13..ca321afa0 100644
--- a/docs/internals/glossary.md
+++ b/docs/internals/glossary.md
@@ -43,7 +43,7 @@ A single user-to-assistant work cycle inside a thread. It starts with user input
### Roster organization
-The live sidebar is `BotRosterSidebar`. Pins, named sections, and Unassigned are a client layout over bots and groups. They must not assign or remove group members, and they must not settle chats. Drag planning lives in `roster.logic.ts`; pointer cleanup, insertion-gap projection, and list motion live beside it in `roster.pointer.ts`, `roster.drag.ts`, and `roster.motion.ts`.
+The live sidebar is `BotRosterSidebar`. Pins and the main Bots list are a client layout over bots and groups. They must not assign or remove group members, and they must not settle chats. Drag planning lives in `roster.logic.ts`; pointer cleanup, insertion-gap projection, and list motion live beside it in `roster.pointer.ts`, `roster.drag.ts`, and `roster.motion.ts`.
#### Activity
diff --git a/docs/user/bots.md b/docs/user/bots.md
index a14167a55..68bd5d05f 100644
--- a/docs/user/bots.md
+++ b/docs/user/bots.md
@@ -56,11 +56,13 @@ Changing the provider starts a fresh provider session with the same enabled tool
## Organize the roster
-The sidebar lists pinned bots and groups, then any named sections you create, then everything else under **Unassigned**. Drag a bot or group to reorder it, pin it, or unpin it. Dragging into **Pinned** pins it at that spot. Dragging a pinned item into a section or Unassigned unpins it. Drag a section header to reorder sections.
+The sidebar shows pinned bots and groups as launcher cards at the top, followed by the rest as detailed rows under **Bots**. Drag a bot or group to reorder it, pin it, or unpin it. Dragging into **Pinned** pins it at that spot, and dragging a pinned item back into **Bots** unpins it.
-Pins, sections, and Unassigned are roster layout only. They do not change group membership, and they do not settle chats.
+Pins only change the roster layout. They do not change group membership or settle chats.
-While you drag, the destination label stays readable and takes the accent color. Empty and collapsed sections stay droppable. The lifted row shows **Pin**, **Unpin**, or **Move** when the drop would change its section. Reordering inside one section has no badge. These transitions follow your reduced-motion preference, and a drop does not replay a second animation.
+While you drag, the lifted row stays in the roster and moves vertically between available positions. The destination label stays readable and takes the accent color. These transitions follow your reduced-motion preference, and a drop does not replay a second animation.
+
+Pinning, unpinning, and moving an item keeps the sidebar at your current scroll position instead of following the item to its new place in the roster.
On this device the layout is stored in the browser for the connected environment. Refresh keeps it. Other devices keep their own layout until the environment can store roster order.