Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(sidebar): one legible mark and a 13px name on department lines
mantrandev51f478df9640
diff --git a/docs/pr-screenshots/sidebar-department-line/before-after.png b/docs/pr-screenshots/sidebar-department-line/before-after.pngnew file mode 100644index 0000000000..54d38c1d4cBinary files /dev/null and b/docs/pr-screenshots/sidebar-department-line/before-after.png differdiff --git a/src/components/SidebarSectionHeader.test.ts b/src/components/SidebarSectionHeader.test.tsindex 2bfaae93b0..369362733a 100644--- a/src/components/SidebarSectionHeader.test.ts+++ b/src/components/SidebarSectionHeader.test.ts@@ -97,12 +97,12 @@ describe("SidebarSectionHeader as a Simple-mode line", () => {name: "Work", collapsed: false, onToggle: () => {}, reorderable: true, dragging: false, line: true, ...props,}) as ReactElement<Props>;- it("draws a quiet 12px name with no hairline, and a ⋯ team menu button that shows on hover, with no trash or grip", () => {+ it("draws a quiet 13px name with no hairline, and a ⋯ team menu button that shows on hover, with no trash or grip", () => {const onMenu = vi.fn();const element = line({ onMenu, onDelete: () => {} });const html = renderToStaticMarkup(element);expect(html).toContain('data-sidebar-section-line=""');- expect(html).toMatch(/text-\[12px\][^"]*text-ink-secondary/);+ expect(html).toMatch(/text-\[13px\] leading-\[18px\] text-ink-secondary/);expect(html).not.toContain("bg-hairline");expect(html).toContain('aria-label="Actions for Work department" title="Actions for Work department" aria-haspopup="menu" aria-expanded="false"');expect(html).toMatch(/aria-label="Actions for Work department"[^>]*class="[^"]*\bopacity-0\b[^"]*\bgroup-hover\/section:opacity-100\b[^"]*\baria-expanded:opacity-100\b/);@@ -126,7 +126,7 @@ describe("SidebarSectionHeader as a Simple-mode line", () => {});it("keeps the count in the same column whether or not the line has a ⋯ menu", () => {- const slot = /<span aria-hidden="true" class="w-\[22px\] shrink-0"><\/span>/;+ const slot = /<span aria-hidden="true" class="w-6 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);@@ -135,10 +135,10 @@ describe("SidebarSectionHeader as a Simple-mode line", () => {const reserved = top({ count: 1, reserveMenu: true });const withMenu = top({ count: 4, onMenu: () => {} });expect(reserved.map((node) => node.type)).toEqual(["button", "span"]);- expect(reserved[1].props).toMatchObject({ "aria-hidden": "true", className: "w-[22px] shrink-0" });+ expect(reserved[1].props).toMatchObject({ "aria-hidden": "true", className: "w-6 shrink-0" });expect(withMenu.map((node) => node.type)).toEqual(["button", "button"]);expect(withMenu[1].props["aria-label"]).toBe("Actions for Work department");- expect(String(withMenu[1].props.className).split(" ")).toEqual(expect.arrayContaining(["w-[22px]", "shrink-0"]));+ expect(String(withMenu[1].props.className).split(" ")).toEqual(expect.arrayContaining(["size-6", "shrink-0"]));});it("is dragged by the line itself, and only when it can be reordered", () => {@@ -181,4 +181,29 @@ describe("SidebarSectionHeader as a Simple-mode line", () => {expect(html).toContain("1 working");expect(renderToStaticMarkup(line())).not.toContain("lucide-chevron-right");});++ it("marks a collapsed line with one dot, the most urgent of waiting, unread and working, and no number", () => {+ const marks = (attention: { waiting: number; unread: number; working: number }) =>+ renderToStaticMarkup(line({ collapsed: true, attention })).match(/data-section-mark="(\w+)"/g) ?? [];+ expect(marks({ waiting: 1, unread: 2, working: 1 })).toEqual(['data-section-mark="waiting"']);+ expect(marks({ waiting: 0, unread: 2, working: 1 })).toEqual(['data-section-mark="unread"']);+ expect(marks({ waiting: 0, unread: 0, working: 3 })).toEqual(['data-section-mark="working"']);+ expect(marks({ waiting: 0, unread: 0, working: 0 })).toEqual([]);+ const html = renderToStaticMarkup(line({ collapsed: true, attention: { waiting: 0, unread: 12, working: 0 } }));+ expect(html).not.toContain(">12<");+ expect(html).not.toContain("text-[9px]");+ expect(html).toContain('title="12 unread"');+ expect(renderToStaticMarkup(line({ collapsed: false, attention: { waiting: 1, unread: 0, working: 0 } }))).not.toContain("data-section-mark");+ });++ it("draws the working pulse still when motion is reduced", () => {+ const html = renderToStaticMarkup(line({ collapsed: true, attention: { waiting: 0, unread: 0, working: 1 } }));+ expect(html).toMatch(/animate-pulse[^"]*motion-reduce:animate-none/);+ });++ it("lets a routine alert stand alone instead of a second dot", () => {+ const html = renderToStaticMarkup(line({ collapsed: true, alert: true, attention: { waiting: 1, unread: 0, working: 0 } }));+ expect(html).toContain('data-testid="section-alert"');+ expect(html).not.toContain("data-section-mark");+ });});diff --git a/src/components/SidebarSectionHeader.tsx b/src/components/SidebarSectionHeader.tsxindex 12846166d9..cf0f808005 100644--- a/src/components/SidebarSectionHeader.tsx+++ b/src/components/SidebarSectionHeader.tsx@@ -106,13 +106,13 @@ export function SidebarSectionHeader({title={toggleTitle}className="flex min-w-0 flex-1 items-center gap-1.5 rounded text-left focus-visible:outline focus-visible:outline-2 focus-visible:outline-focus">- <span className="min-w-0 flex-1 truncate text-[12px] leading-4 text-ink-secondary">{name}</span>+ <span className="min-w-0 flex-1 truncate text-[13px] leading-[18px] text-ink-secondary">{name}</span>{collapsed && <SectionAttention attention={attention} label={attentionLabel} alert={alert} />}{tail}</button>) : (<div className="flex min-w-0 flex-1 items-center gap-1.5">- <span className="min-w-0 flex-1 truncate text-[12px] leading-4 text-ink-secondary">{name}</span>+ <span className="min-w-0 flex-1 truncate text-[13px] leading-[18px] text-ink-secondary">{name}</span>{attentionLabel && <span className="sr-only">{attentionLabel}</span>}{tail}</div>@@ -125,12 +125,12 @@ export function SidebarSectionHeader({aria-haspopup="menu"aria-expanded={menuOpen}onClick={(event) => onMenu(event.currentTarget)}- className="flex h-[18px] w-[22px] shrink-0 items-center justify-center rounded-[6px] text-ink-tertiary opacity-0 transition-opacity hover:bg-raised hover:text-ink focus-visible:opacity-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-focus group-hover/section:opacity-100 group-focus-within/section:opacity-100 aria-expanded:bg-raised aria-expanded:text-ink aria-expanded:opacity-100 touch:opacity-100"+ className="flex size-6 shrink-0 items-center justify-center rounded-[6px] text-ink-tertiary opacity-0 transition-opacity hover:bg-raised hover:text-ink focus-visible:opacity-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-focus group-hover/section:opacity-100 group-focus-within/section:opacity-100 aria-expanded:bg-raised aria-expanded:text-ink aria-expanded:opacity-100 touch:opacity-100"><MoreHorizontal size={15} aria-hidden="true" /></button>)}- {!onMenu && reserveMenu && !naming && <span aria-hidden="true" className="w-[22px] shrink-0" />}+ {!onMenu && reserveMenu && !naming && <span aria-hidden="true" className="w-6 shrink-0" />}</div>);}@@ -230,31 +230,29 @@ function SectionNameField({ value, label, onCommit, onCancel }: SectionNaming) {);}+type SectionMark = "waiting" | "unread" | "working";++const SECTION_MARK: Record<SectionMark, string> = {+ waiting: "size-2 bg-warning",+ unread: "size-2 bg-accent",+ working: "size-1.5 animate-pulse bg-success motion-reduce:animate-none",+};++function sectionMark(attention: SidebarSectionAttention | undefined): SectionMark | null {+ if (!attention) return null;+ if (attention.waiting > 0) return "waiting";+ if (attention.unread > 0) return "unread";+ if (attention.working > 0) return "working";+ return null;+}+function SectionAttention({ attention, label, alert }: { attention?: SidebarSectionAttention; label: string; alert?: boolean }) {+ const mark = alert ? null : sectionMark(attention);return (<>- {attention && attention.waiting > 0 && (- <span- aria-hidden="true"- className="min-w-4 rounded-full bg-warning/15 px-1 text-center text-[9px] font-semibold leading-4 text-warning"- >- {attention.waiting}- </span>- )}- {attention && attention.unread > 0 && (- <span- aria-hidden="true"- className="min-w-4 rounded-full bg-accent/15 px-1 text-center text-[9px] font-semibold leading-4 text-accent"- >- {attention.unread}- </span>- )}- {attention && attention.working > 0 && (- <span- aria-hidden="true"- className="flex size-4 items-center justify-center"- >- <span className="size-1.5 animate-pulse rounded-full bg-success" />+ {mark && (+ <span aria-hidden="true" title={label} data-section-mark={mark} className="flex size-4 shrink-0 items-center justify-center">+ <span className={cn("rounded-full", SECTION_MARK[mark])} /></span>)}{label && <span className="sr-only">{label}</span>}