Skip to content

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

Rooms: show one room mark in the sidebar instead of members' faces

TuftyBruno976197f96fff
diff --git a/src/components/Sidebar.simple-mode.test.ts b/src/components/Sidebar.simple-mode.test.ts
index ef2202591e..6d16868373 100644
--- a/src/components/Sidebar.simple-mode.test.ts
+++ b/src/components/Sidebar.simple-mode.test.ts
@@ -250,6 +250,18 @@ describe("bot-first sidebar", () => {
expect(renderToStaticMarkup(createElement(BotListItem, rowProps("comfortable", candidate)))).toMatch(/data-bot-actions="atlas"[^>]*class="[^"]*\bpointer-events-auto opacity-100/);
});
+ it.each(densities)("marks a room as one place instead of its members' faces, where a two-bot channel keeps both faces (%s)", (density) => {
+ const pip: Bot = { ...quiet, id: "pip", name: "Pip", color: "blue" };
+ fixture.state = { ...fixture.state, bots: [bot, pip] };
+ const room: Group = { id: "room", threadId: "room-thread", name: "Launch", memberIds: [bot.id, pip.id], messages: [], defaultResponder: { kind: "mentions" }, bulletin: "", unread: false, createdAt: 1 };
+ const roomMarkup = renderToStaticMarkup(createElement(GroupListItem, { group: room, density, onMenu: vi.fn() }));
+ expect(roomMarkup).toContain("data-room-mark");
+ expect(roomMarkup).not.toContain("data-avatar-kind=\"bot\"");
+ const channel = renderToStaticMarkup(createElement(GroupListItem, { group: { ...room, dm: true }, density, onMenu: vi.fn() }));
+ expect(channel).not.toContain("data-room-mark");
+ expect(channel.match(/data-avatar-kind="bot"/g)).toHaveLength(2);
+ });
+
it("marks an unread Simple group chat with the same top-right dot as a bot row, said once for a screen reader", () => {
const group: Group = { id: "room", threadId: "room-thread", name: "Launch", memberIds: [bot.id], messages: [], defaultResponder: { kind: "mentions" }, bulletin: "", unread: true, createdAt: 1 };
const markup = renderToStaticMarkup(createElement(GroupListItem, { group, density: "comfortable", onMenu: vi.fn() }));
@@ -290,11 +302,11 @@ describe("bot-first sidebar", () => {
});
it.each([
- { advanced: false, density: "comfortable", face: 36, spacing: ["gap-2", "rounded-[8px]", "pl-2", "pr-2", "md:h-[54px]"], name: "font-medium", preview: "text-[13px]" },
- { advanced: false, density: "icons", face: 36, spacing: ["h-[54px]", "justify-center"], name: "font-semibold", preview: "text-[11px]" },
- { advanced: true, density: "icons", face: 44, spacing: ["justify-center", "px-1", "py-1.5"], name: "font-semibold", preview: "text-[11px]" },
- { advanced: true, density: "comfortable", face: 32, spacing: ["gap-2", "py-1.5", "pl-6", "pr-9"], name: "font-semibold", preview: "text-[11px]" },
- ] as const)("sizes group chat rows in $density density (advanced $advanced)", ({ advanced, density, face, spacing, name, preview }) => {
+ { advanced: false, density: "comfortable", slot: "size-9", spacing: ["gap-2", "rounded-[8px]", "pl-2", "pr-2", "md:h-[54px]"], name: "font-medium", preview: "text-[13px]" },
+ { advanced: false, density: "icons", slot: "size-9", spacing: ["h-[54px]", "justify-center"], name: "font-semibold", preview: "text-[11px]" },
+ { advanced: true, density: "icons", slot: "size-12", spacing: ["justify-center", "px-1", "py-1.5"], name: "font-semibold", preview: "text-[11px]" },
+ { advanced: true, density: "comfortable", slot: "size-8", spacing: ["gap-2", "py-1.5", "pl-6", "pr-9"], name: "font-semibold", preview: "text-[11px]" },
+ ] as const)("sizes group chat rows in $density density (advanced $advanced)", ({ advanced, density, slot, spacing, name, preview }) => {
fixture.advanced = advanced;
const group: Group = { id: "room", threadId: "room-thread", name: "Launch", memberIds: [bot.id], messages: [], defaultResponder: { kind: "mentions" }, bulletin: "", unread: false, createdAt: 1 };
let tree: ReactNode;
@@ -302,7 +314,7 @@ describe("bot-first sidebar", () => {
const markup = renderToStaticMarkup(createElement(Capture));
const row = findElement(tree, "data-sidebar-group-row", group.id)!;
expect(String(row.props.className).split(" ")).toEqual(expect.arrayContaining([...spacing]));
- expect(markup).toContain(`width="${face}px" height="${face}px"`);
+ expect(markup).toMatch(new RegExp(`data-room-mark="" class="[^"]*\\b${slot}\\b[^"]*"><svg[^>]*width="16" height="16"`));
expect(markup).toMatch(new RegExp(`truncate text-\\[14px\\] text-ink ${name}`));
expect(markup).toContain(`truncate text-ink-secondary ${preview}`);
});
diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx
index f3eb4d0283..43f43c4065 100644
--- a/src/components/Sidebar.tsx
+++ b/src/components/Sidebar.tsx
@@ -24,7 +24,7 @@ import type { LocaleKey } from "@/locales";
import { ConfirmDialog } from "./ConfirmDialog";
import { BulkSelectFilters, ThreadListFooter, deleteThreadsInBulk, useBulkSelect } from "./BulkSelectBar";
-import { StackedMauses } from "./StackedMauses";
+import { RoomMark, StackedMauses } from "./StackedMauses";
import { LocalComputerAutoWarning } from "./LocalComputerAutoWarning";
import { nextRename } from "@/lib/rename";
import { useDesktopCapabilities, windowFramed } from "./DesktopCapabilities";
@@ -194,7 +194,9 @@ export const GroupListItem = memo(function GroupListItem({
title={density === "icons" ? group.name : undefined}
aria-label={density === "icons" ? group.name : undefined}
>
- <StackedMauses members={members} density={railTile ? "comfortable" : density} large={simpleRow || railTile} />
+ {group.dm
+ ? <StackedMauses members={members} density={railTile ? "comfortable" : density} large={simpleRow || railTile} />
+ : <RoomMark density={railTile ? "comfortable" : density} large={simpleRow || railTile} />}
<div className={cn("min-w-0 flex-1", density === "icons" && "hidden")}>
<div className={cn("flex items-baseline justify-between gap-2", simpleRow && "pr-7")}>
<span className={cn("truncate text-[14px] text-ink", simpleRow ? "font-medium leading-5" : "font-semibold")}>{group.name}</span>
diff --git a/src/components/StackedMauses.tsx b/src/components/StackedMauses.tsx
index 41dffcbf0d..64f360b87b 100644
--- a/src/components/StackedMauses.tsx
+++ b/src/components/StackedMauses.tsx
@@ -4,9 +4,19 @@ import type { SidebarDensity } from "@/lib/sidebar-preferences";
import type { Bot } from "@/state/store";
import { BotAvatar } from "./Avatar";
+const slotFor = (density: SidebarDensity, large: boolean) => density === "icons" ? "size-12" : large ? "size-9" : "size-8";
+
+export function RoomMark({ density, large = false }: { density: SidebarDensity; large?: boolean }) {
+ return (
+ <div data-room-mark="" className={cn("flex shrink-0 items-center justify-center", slotFor(density, large))}>
+ <Users aria-hidden="true" size={16} className="text-ink-secondary" />
+ </div>
+ );
+}
+
export function StackedMauses({ members, density, large = false }: { members: Bot[]; density: SidebarDensity; large?: boolean }) {
const iconOnly = density === "icons";
- const slotSize = iconOnly ? "size-12" : large ? "size-9" : "size-8";
+ const slotSize = slotFor(density, large);
const singleSize = iconOnly ? 44 : large ? 36 : 32;
if (members.length <= 1) {
const b = members[0];