Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Sidebar: drop the row count beside each department name
luishron123da5bd0d2f7da
diff --git a/src/components/Sidebar.simple-layout.test.ts b/src/components/Sidebar.simple-layout.test.tsindex cb20af90cf..990e7eae21 100644--- a/src/components/Sidebar.simple-layout.test.ts+++ b/src/components/Sidebar.simple-layout.test.ts@@ -109,12 +109,12 @@ afterEach(() => {});describe("Simple-mode sidebar layout", () => {- it("lists the bots with no heading, then gives group chats and a person's own departments a quiet heading with a count", () => {+ it("lists the bots with no heading, then gives group chats and a person's own departments a quiet heading with no count", () => {const { tree } = render();expect(sectionOrder(tree)).toEqual([BOTS_SECTION_ID, CHANNELS_SECTION_ID, userSectionId("Work")]);expect(listedBots(tree)).toEqual(["atlas", "bea", "dodo"]);const lines = headers(tree);- expect(lines.map((header) => [header.props.name, header.props.line, header.props.count])).toEqual([["Group chats", true, 1], ["Work", true, 1]]);+ expect(lines.map((header) => [header.props.name, header.props.line, "count" in header.props])).toEqual([["Group chats", true, false], ["Work", true, false]]);expect(lines[0]!.props.onMenu).toBeUndefined();expect(lines[1]!.props.onDelete).toBeUndefined();expect(lines[1]!.props.onMenu).toBeTypeOf("function");diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsxindex 0136d8d057..9740b1d450 100644--- a/src/components/Sidebar.tsx+++ b/src/components/Sidebar.tsx@@ -1435,7 +1435,6 @@ export const Sidebar = memo(function Sidebar({ open, onClose, collapseToIcons =<SidebarSectionHeadername={sectionLabel(id)}line={simple} reserveMenu={simple && !remoteClient}- count={simple ? sectionChiefItems.length + sectionBotItems.length + sectionGroupItems.length : undefined}onMenu={simple && !remoteClient && sectionName ? (button) => {const rect = button.getBoundingClientRect();openTeamMenu(sectionName, rect.right - 256, rect.bottom + 4, button);diff --git a/src/components/SidebarSectionHeader.naming.dom.test.ts b/src/components/SidebarSectionHeader.naming.dom.test.tsindex d588d9b304..77db708344 100644--- a/src/components/SidebarSectionHeader.naming.dom.test.ts+++ b/src/components/SidebarSectionHeader.naming.dom.test.ts@@ -21,7 +21,7 @@ afterEach(() => {function mount(line: boolean, extra: Partial<Parameters<typeof SidebarSectionHeader>[0]> = {}) {const naming = { value: "New department", label: "New department name", onCommit: vi.fn(), onCancel: vi.fn() };flushSync(() => root.render(createElement(SidebarSectionHeader, {- name: "Work", collapsed: false, reorderable: true, dragging: false, line, count: 2, onToggle: () => {}, onMenu: () => {}, naming, ...extra,+ name: "Work", collapsed: false, reorderable: true, dragging: false, line, onToggle: () => {}, onMenu: () => {}, naming, ...extra,})));return { naming, field: container.querySelector<HTMLInputElement>("[data-section-name-field]")! };}diff --git a/src/components/SidebarSectionHeader.test.ts b/src/components/SidebarSectionHeader.test.tsindex 2bfaae93b0..d6df848d70 100644--- a/src/components/SidebarSectionHeader.test.ts+++ b/src/components/SidebarSectionHeader.test.ts@@ -109,7 +109,7 @@ describe("SidebarSectionHeader as a Simple-mode line", () => {expect(html).not.toContain("Delete Work department");expect(html).not.toContain("lucide-grip-vertical");expect(html).not.toContain("lucide-trash");- expect(html).toMatch(/lucide-chevron-down absolute text-ink-secondary opacity-0 transition-opacity group-hover\/section:opacity-100 group-focus-within\/section:opacity-100 touch:opacity-100/);+ expect(html).toMatch(/lucide-chevron-down shrink-0 text-ink-secondary opacity-0 transition-opacity group-hover\/section:opacity-100 group-focus-within\/section:opacity-100 touch:opacity-100/);expect(html.indexOf(">Work</span>")).toBeLessThan(html.indexOf("Actions for Work department"));const button = { id: "dots" };const dots = nodes(element.props.children).find((node) => node.props["aria-label"] === "Actions for Work department")!;@@ -119,21 +119,21 @@ describe("SidebarSectionHeader as a Simple-mode line", () => {expect(renderToStaticMarkup(line())).not.toContain("Actions for Work department");});- it("shows how many rows the section holds at rest, crossfading to the chevron on hover or focus", () => {- const html = renderToStaticMarkup(line({ count: 3 }));- expect(html).toMatch(/class="h-\[30px\]|group\/section flex h-\[30px\] items-center gap-1\.5 rounded-\[6px\] px-2 pb-1\.5 pt-2 hover:bg-raised\/50/);- expect(html).toMatch(/<span class="text-\[12px\] tabular-nums leading-4 text-ink-secondary transition-opacity group-hover\/section:opacity-0 group-focus-within\/section:opacity-0 touch:opacity-0">3<\/span>/);+ it("shows no row count, only the chevron on hover or focus", () => {+ const html = renderToStaticMarkup(line());+ expect(html).not.toContain("tabular-nums");+ expect(html.replace(/<svg.*?<\/svg>/g, "")).not.toMatch(/>\d+</);});- it("keeps the count in the same column whether or not the line has a ⋯ menu", () => {+ it("keeps the chevron in the same column whether or not the line has a ⋯ menu", () => {const slot = /<span aria-hidden="true" class="w-\[22px\] shrink-0"><\/span>/;- expect(renderToStaticMarkup(line({ count: 1, reserveMenu: true }))).toMatch(slot);- expect(renderToStaticMarkup(line({ count: 4, reserveMenu: true, onMenu: () => {} }))).not.toMatch(slot);- expect(renderToStaticMarkup(line({ count: 1 }))).not.toMatch(slot);+ expect(renderToStaticMarkup(line({ reserveMenu: true }))).toMatch(slot);+ expect(renderToStaticMarkup(line({ reserveMenu: true, onMenu: () => {} }))).not.toMatch(slot);+ expect(renderToStaticMarkup(line())).not.toMatch(slot);expect(renderToStaticMarkup(line({ reserveMenu: true, naming: { value: "", label: "Name", onCommit: () => {}, onCancel: () => {} } }))).not.toMatch(slot);const top = (props: Parameters<typeof line>[0]) => Children.toArray(line(props).props.children).filter(isValidElement) as ReactElement<Props>[];- const reserved = top({ count: 1, reserveMenu: true });- const withMenu = top({ count: 4, onMenu: () => {} });+ const reserved = top({ reserveMenu: true });+ const withMenu = top({ onMenu: () => {} });expect(reserved.map((node) => node.type)).toEqual(["button", "span"]);expect(reserved[1].props).toMatchObject({ "aria-hidden": "true", className: "w-[22px] shrink-0" });expect(withMenu.map((node) => node.type)).toEqual(["button", "button"]);diff --git a/src/components/SidebarSectionHeader.tsx b/src/components/SidebarSectionHeader.tsxindex 12846166d9..5622f7140d 100644--- a/src/components/SidebarSectionHeader.tsx+++ b/src/components/SidebarSectionHeader.tsx@@ -26,7 +26,6 @@ export function SidebarSectionHeader({onMenu,reserveMenu = false,menuOpen = false,- count,naming,dropInto = false,}: {@@ -44,11 +43,9 @@ export function SidebarSectionHeader({onContextMenu?: (event: MouseEvent<HTMLDivElement>) => void;line?: boolean;onMenu?: (button: HTMLButtonElement) => void;- /** Keep the ⋯ button's space when this line has none, so counts line up with lines that do (Simple). */+ /** Keep the ⋯ button's space when this line has none, so chevrons line up with lines that do (Simple). */reserveMenu?: boolean;menuOpen?: boolean;- /** How many rows the section holds, shown at rest where the chevron shows on hover (Simple). */- count?: number;/** A name field in place of the name, for a department being made or renamed. */naming?: SectionNaming;/** A dragged bot would go into this department. */@@ -78,11 +75,8 @@ export function SidebarSectionHeader({const dropMark = dropInto ? "bg-accent/10 outline outline-2 -outline-offset-2 outline-accent/70" : undefined;if (line) {- const tail = (- <span aria-hidden="true" className="relative flex size-4 shrink-0 items-center justify-center">- {count !== undefined && <span className={cn("text-[12px] tabular-nums leading-4 text-ink-secondary transition-opacity", onToggle && "group-hover/section:opacity-0 group-focus-within/section:opacity-0 touch:opacity-0")}>{count}</span>}- {onToggle && <Chevron size={14} className="absolute text-ink-secondary opacity-0 transition-opacity group-hover/section:opacity-100 group-focus-within/section:opacity-100 touch:opacity-100" />}- </span>+ const tail = onToggle && (+ <Chevron size={14} aria-hidden="true" className="shrink-0 text-ink-secondary opacity-0 transition-opacity group-hover/section:opacity-100 group-focus-within/section:opacity-100 touch:opacity-100" />);return (<div