Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

fix(community): heatmap real tooltip + desktop 3 rows, bigger cells

Gus7ad56f633076
diff --git a/src/web/src/components/community/bots/bot-activity-heatmap.test.ts b/src/web/src/components/community/bots/bot-activity-heatmap.test.ts
index 5f8c29fc9..65d5aa7b6 100644
--- a/src/web/src/components/community/bots/bot-activity-heatmap.test.ts
+++ b/src/web/src/components/community/bots/bot-activity-heatmap.test.ts
@@ -2,6 +2,19 @@ import { describe, it, expect, vi, afterEach } from "vitest"
import React from "react"
import TestRenderer, { act } from "react-test-renderer"
import { utcDayKeyDaysAgo } from "@alook/shared"
+
+// The real Tooltip pulls in floating-ui, which needs `window` — unavailable in
+// this node renderer. Mock it to plain passthroughs: the trigger renders its
+// `render` element (the cell span) and the content renders its text into a
+// `data-tip` span, so we can still count cells and read each cell's tooltip.
+vi.mock("@/components/ui/tooltip", () => ({
+ Tooltip: ({ children }: { children?: React.ReactNode }) =>
+ React.createElement(React.Fragment, {}, children),
+ TooltipTrigger: ({ render }: { render: React.ReactElement }) => render,
+ TooltipContent: ({ children }: { children?: React.ReactNode }) =>
+ React.createElement("span", { "data-tip": children }),
+}))
+
import { BotActivityHeatmap, type BotActivityDay } from "./bot-activity-heatmap"
// The heatmap must place each sparse day at its true calendar slot (a gap of N
@@ -19,13 +32,21 @@ function render(days: BotActivityDay[]) {
return r
}
-// Every leaf cell in DOM order — the grid renders exactly 30, oldest→newest.
+// The cell spans in DOM order — the grid renders exactly 30, oldest→newest.
+// (The mocked TooltipContent renders a `data-tip` span; exclude it here.)
function cells(r: TestRenderer.ReactTestRenderer) {
return r.root.findAll(
- (n) => typeof n.type === "string" && n.type === "span",
+ (n) => typeof n.type === "string" && n.type === "span" && n.props["data-tip"] === undefined,
)
}
+// Each cell's tooltip text, in DOM order — read from the mocked content spans.
+function tips(r: TestRenderer.ReactTestRenderer): string[] {
+ return r.root
+ .findAll((n) => typeof n.type === "string" && n.type === "span" && n.props["data-tip"] !== undefined)
+ .map((n) => String(n.props["data-tip"]))
+}
+
afterEach(() => vi.useRealTimers())
describe("BotActivityHeatmap — calendar-axis fill", () => {
@@ -45,21 +66,25 @@ describe("BotActivityHeatmap — calendar-axis fill", () => {
{ day: older, handledCount: 4, sentCount: 0 },
{ day: newer, handledCount: 1, sentCount: 2 },
])
- const all = cells(r)
+ const all = tips(r)
// Oldest→newest over a 30-day axis (today-29 … today): index = 29 - daysAgo.
- const olderIdx = all.findIndex((c) => c.props.title?.includes("4 handled"))
- const newerIdx = all.findIndex((c) => c.props.title?.includes("1 handled"))
+ const olderIdx = all.findIndex((t) => t.includes("4 handled"))
+ const newerIdx = all.findIndex((t) => t.includes("1 handled"))
expect(olderIdx).toBe(29 - 20)
expect(newerIdx).toBe(29 - 5)
// 15 calendar days apart → 15 index slots apart, not glued together.
expect(newerIdx - olderIdx).toBe(15)
})
- it("gives empty days no tooltip (bucket-0 track cells)", () => {
+ it("labels active days with the split and empty days as 'no activity'", () => {
const r = render([{ day: utcDayKeyDaysAgo(new Date(), 10), handledCount: 2, sentCount: 0 }])
- const withTitle = cells(r).filter((c) => c.props.title)
- // Only the single active day carries a tooltip; the other 29 are empty.
- expect(withTitle.length).toBe(1)
- expect(withTitle[0].props.title).toContain("2 handled · 0 sent")
+ const all = tips(r)
+ // Every slot has a tooltip now (Gus #695 — hover must respond everywhere).
+ expect(all.length).toBe(30)
+ const active = all.filter((t) => t.includes("handled"))
+ expect(active.length).toBe(1)
+ expect(active[0]).toContain("2 handled · 0 sent")
+ // The other 29 read as "no activity", not empty/undefined.
+ expect(all.filter((t) => t.endsWith("no activity")).length).toBe(29)
})
})
diff --git a/src/web/src/components/community/bots/bot-activity-heatmap.tsx b/src/web/src/components/community/bots/bot-activity-heatmap.tsx
index a7e049c15..e947c9858 100644
--- a/src/web/src/components/community/bots/bot-activity-heatmap.tsx
+++ b/src/web/src/components/community/bots/bot-activity-heatmap.tsx
@@ -2,6 +2,11 @@
import { useMemo } from "react"
import { utcDayKeyDaysAgo } from "@alook/shared"
+import {
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
+} from "@/components/ui/tooltip"
// One day's activity for a bot: post-gate messages handled + messages the bot
// sent. Both counts are non-negative integers; a day with no activity is 0/0.
@@ -48,9 +53,17 @@ function bucketFor(total: number, max: number): number {
return 1
}
-function tooltipFor(day: BotActivityDay): string {
- const d = new Date(`${day.day}T00:00:00`)
- const label = Number.isNaN(d.getTime()) ? day.day : DATE_FMT.format(d)
+function dayLabel(dayKey: string): string {
+ const d = new Date(`${dayKey}T00:00:00`)
+ return Number.isNaN(d.getTime()) ? dayKey : DATE_FMT.format(d)
+}
+
+// Tooltip text for a slot. Active days split the two counts; empty days (a gap
+// or a quiet day) still get a tooltip so hovering anywhere reads as responsive
+// (Gus /Gus/working #695 — native `title` gave no feedback on empty cells).
+function tooltipFor(dayKey: string, day: BotActivityDay | undefined): string {
+ const label = dayLabel(dayKey)
+ if (!day || day.handledCount + day.sentCount === 0) return `${label} · no activity`
return `${label} · ${day.handledCount} handled · ${day.sentCount} sent`
}
@@ -100,14 +113,14 @@ export function BotActivityHeatmap({
utcDayKeyDaysAgo(now, WINDOW_DAYS - 1 - i),
)
const max = days.reduce((m, d) => Math.max(m, d.handledCount + d.sentCount), 0)
- // Key by calendar day (stable across renders), not grid index.
+ // Key by calendar day (stable across renders), not grid index. Every slot
+ // gets a tooltip (active or empty) so hover always responds.
return axisKeys.map((key) => {
const d = byDay.get(key)
- if (!d) return { key, bucket: 0, title: undefined as string | undefined }
return {
key,
- bucket: bucketFor(d.handledCount + d.sentCount, max),
- title: tooltipFor(d),
+ bucket: d ? bucketFor(d.handledCount + d.sentCount, max) : 0,
+ title: tooltipFor(key, d),
}
})
}, [days])
@@ -124,10 +137,9 @@ export function BotActivityHeatmap({
// • mobile: FULL-WIDTH horizontal ribbon (Gus #164/#165) — 3 rows × 10
// columns; 10 1fr columns span the card, cells auto-size square to the
// column width so the ribbon always fills the card, left/right flush.
- // • desktop: a thin fixed-size strip in the card's empty right side
- // (#155/#165) — 5 rows → 6 columns, small size-2 cells, w-fit. 5 rows
- // (not 4) so it divides 30 evenly (Alli #692 / Blair #691): 4 rows left a
- // ragged 2-cell last column; 5×6 fills every column, flush bottom-right.
+ // • desktop: a thin strip in the card's empty right side (#155/#165) —
+ // 3 rows → 10 columns (Gus #695: was 5 rows/too small; 3 divides 30 so
+ // it's still flush, and fewer rows lets each cell be larger). size-3 cells.
const isMobile = variant === "mobile"
return (
<div
@@ -137,20 +149,28 @@ export function BotActivityHeatmap({
"grid grid-flow-col gap-[3px]",
isMobile
? "w-full [grid-template-columns:repeat(10,minmax(0,1fr))] [grid-template-rows:repeat(3,auto)]"
- : "w-fit [grid-template-rows:repeat(5,minmax(0,1fr))]",
+ : "w-fit [grid-template-rows:repeat(3,minmax(0,1fr))]",
className ?? "",
].join(" ")}
>
{cells.map((c) => (
- <span
- key={c.key}
- title={c.title}
- className={[
- "rounded-[2px]",
- isMobile ? "aspect-square w-full" : "size-2",
- BUCKET_CLASSES[c.bucket],
- ].join(" ")}
- />
+ // A real Tooltip (not native `title`) so hover is instant, styled, and
+ // fires on every cell including empty days (Gus #695 — `title` was
+ // OS-delayed and absent on empty cells, reading as "no reaction").
+ <Tooltip key={c.key}>
+ <TooltipTrigger
+ render={
+ <span
+ className={[
+ "rounded-[2px]",
+ isMobile ? "aspect-square w-full" : "size-3",
+ BUCKET_CLASSES[c.bucket],
+ ].join(" ")}
+ />
+ }
+ />
+ <TooltipContent>{c.title}</TooltipContent>
+ </Tooltip>
))}
</div>
)
diff --git a/src/web/src/components/community/bots/bot-list-card.test.ts b/src/web/src/components/community/bots/bot-list-card.test.ts
index 95bf41ad6..597f2036e 100644
--- a/src/web/src/components/community/bots/bot-list-card.test.ts
+++ b/src/web/src/components/community/bots/bot-list-card.test.ts
@@ -44,6 +44,14 @@ vi.mock("@/components/ui/dropdown-menu", () => ({
DropdownMenuItem: passthrough("dmi"),
DropdownMenuTrigger: passthrough("dmt"),
}))
+// The heatmap's real Tooltip needs `window` (floating-ui) — mock to passthroughs
+// so the node renderer can mount the card. The model-segment assertions don't
+// touch the heatmap.
+vi.mock("@/components/ui/tooltip", () => ({
+ Tooltip: passthrough("tt"),
+ TooltipTrigger: ({ render }: { render: React.ReactElement }) => render,
+ TooltipContent: passthrough("ttc"),
+}))
vi.mock("@/components/ui/alert-dialog", () => ({
AlertDialog: passthrough("ad"),
AlertDialogAction: passthrough("ada"),