Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Merge #7197 into train L1

milind-sonib9dbf9105d3e
diff --cc src/components/SidebarBotDrag.tsx
index 493c9dd11e,1ccda93e49..2e602b228f
--- a/src/components/SidebarBotDrag.tsx
+++ b/src/components/SidebarBotDrag.tsx
@@@ -166,12 -157,12 +166,14 @@@ export function useSidebarBotDrag({ dis
const movable = enabled && mayMove;
const lists = new Map<string, string[]>([["", main.map((bot) => bot.id)]]);
for (const name of departments) if (name !== NEW_DEPARTMENT) lists.set(name, sectioned.filter((bot) => bot.section === name).map((bot) => bot.id));
+ const floating = new Set(floats ? [...main, ...sectioned].filter(floats).map((bot) => bot.id) : []);
+ const drawn = new Map([...lists].map(([name, ids]) => [name, drawnOrder(ids, floating)]));
+ latest.current = { enabled: movable, lists, shown: drawn, floating, bots, taken, withinList };
- const active = movable && dragging !== null && botListOf(lists, dragging) !== undefined ? dragging : null;
+ const listOf = new Map<string, string>();
+ for (const [list, ids] of lists) for (const id of ids) listOf.set(id, list);
- latest.current = { enabled: movable, lists, bots, taken, withinList };
+ const active = movable && dragging !== null && listOf.has(dragging) ? dragging : null;
const shown = active ? drop : null;
- const mainIds = lists.get("")!.filter((id) => id !== active);
+ const mainIds = drawn.get("")!.filter((id) => id !== active);
const listFor = (sectionId: string) => (sectionId === BOTS_SECTION_ID ? "" : userSectionName(sectionId));
// Between rows, or under the last one, the nearest row places the bot; a department's heading takes it in.
const zoneDrop = (event: DragEvent<HTMLElement>, list: string): BotDrop => {