Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

fix(community): heatmap absolute color scale + full-width mobile row + hide-first on narrow

Gusd444457b4d66
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 65d5aa7b6..03896d39d 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
@@ -76,6 +76,30 @@ describe("BotActivityHeatmap — calendar-axis fill", () => {
expect(newerIdx - olderIdx).toBe(15)
})
+ it("colors by ABSOLUTE per-day count (busier bots read darker), not relative to own max", () => {
+ // Gus #706/#708: cross-bot comparability. A quiet bot (1/day) must NOT reach
+ // the darkest bucket just because it's that bot's own peak. Bucket class is
+ // on the trigger cell; find each active day's cell by DOM index and read its
+ // bucket class. Thresholds: 1-2→b1, 3-5→b2, 6-10→b3, 11+→b4.
+ const now = new Date()
+ const r = render([
+ { day: utcDayKeyDaysAgo(now, 3), handledCount: 1, sentCount: 0 }, // 1 → b1
+ { day: utcDayKeyDaysAgo(now, 2), handledCount: 3, sentCount: 2 }, // 5 → b2
+ { day: utcDayKeyDaysAgo(now, 1), handledCount: 6, sentCount: 0 }, // 6 → b3
+ { day: utcDayKeyDaysAgo(now, 0), handledCount: 40, sentCount: 5 }, // 45 → b4
+ ])
+ // Split into tokens so "bg-status-online" (b4) doesn't match the /opacity
+ // variants (b1–b3) as a substring.
+ const tokens = cells(r).map((c) => String(c.props.className).split(/\s+/))
+ const idx = (n: number) => 29 - n // oldest→newest slot for n days ago
+ expect(tokens[idx(3)]).toContain("bg-status-online/30") // 1 msg — palest
+ expect(tokens[idx(2)]).toContain("bg-status-online/55") // 5 msgs
+ expect(tokens[idx(1)]).toContain("bg-status-online/80") // 6 msgs
+ expect(tokens[idx(0)]).toContain("bg-status-online") // 45 msgs — darkest, no /opacity
+ // the low-count day must NOT reach the darkest, even though it's this bot's min
+ expect(tokens[idx(3)]).not.toContain("bg-status-online")
+ })
+
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 all = tips(r)
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 e947c9858..5f921431f 100644
--- a/src/web/src/components/community/bots/bot-activity-heatmap.tsx
+++ b/src/web/src/components/community/bots/bot-activity-heatmap.tsx
@@ -41,16 +41,18 @@ const BUCKET_CLASSES = [
const DATE_FMT = new Intl.DateTimeFormat(undefined, { month: "short", day: "numeric" })
-function bucketFor(total: number, max: number): number {
- if (total <= 0 || max <= 0) return 0
- // Map (0, max] onto buckets 1..4 by quartile of the observed max, so a quiet
- // month still shows contrast instead of collapsing to a single step (Alli
- // #628 adopted this relative scale over absolute thresholds).
- const ratio = total / max
- if (ratio > 0.75) return 4
- if (ratio > 0.5) return 3
- if (ratio > 0.25) return 2
- return 1
+// ABSOLUTE per-day thresholds (Gus /Gus/working #706/#708): the point of the
+// heatmap is to see WHICH AGENTS are busier, not which day — so a day's tint is
+// its raw message count, comparable across bots (a 1-msg day is always pale, a
+// 50-msg day always darkest). A relative-to-own-max scale (the old #628 version)
+// defeated this: every bot's peak went darkest, so all bots looked equally busy
+// and sparse data collapsed to a single peak cell.
+function bucketFor(total: number): number {
+ if (total <= 0) return 0
+ if (total <= 2) return 1 // 1–2
+ if (total <= 5) return 2 // 3–5
+ if (total <= 10) return 3 // 6–10
+ return 4 // 11+
}
function dayLabel(dayKey: string): string {
@@ -112,14 +114,13 @@ export function BotActivityHeatmap({
const axisKeys = Array.from({ length: WINDOW_DAYS }, (_, i) =>
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. Every slot
// gets a tooltip (active or empty) so hover always responds.
return axisKeys.map((key) => {
const d = byDay.get(key)
return {
key,
- bucket: d ? bucketFor(d.handledCount + d.sentCount, max) : 0,
+ bucket: d ? bucketFor(d.handledCount + d.sentCount) : 0,
title: tooltipFor(key, d),
}
})
@@ -134,12 +135,14 @@ export function BotActivityHeatmap({
// down each column like a GitHub graph. Always exactly 30 cells into a row
// count that divides 30 → complete columns, flush bottom edge (#159). Uniform
// x/y gap both variants (Gus /Gus/uiux #155). Two layouts:
- // • 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.
+ // • mobile: FULL-WIDTH horizontal ribbon — 2 rows × 15 columns (Gus #699:
+ // was 3 rows; 2 divides 30, a slimmer ribbon). 15 1fr columns span the
+ // card, cells auto-size square to the column width, left/right flush. The
+ // card places this as its own full-width row (not inside the meta column),
+ // so it truly spans the whole card.
// • 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.
+ // 3 rows → 10 columns (Gus #695), size-3 cells. Only shown on wide
+ // screens (the card hides it before it can squeeze the meta text, #699).
const isMobile = variant === "mobile"
return (
<div
@@ -148,7 +151,7 @@ export function BotActivityHeatmap({
className={[
"grid grid-flow-col gap-[3px]",
isMobile
- ? "w-full [grid-template-columns:repeat(10,minmax(0,1fr))] [grid-template-rows:repeat(3,auto)]"
+ ? "w-full [grid-template-columns:repeat(15,minmax(0,1fr))] [grid-template-rows:repeat(2,auto)]"
: "w-fit [grid-template-rows:repeat(3,minmax(0,1fr))]",
className ?? "",
].join(" ")}
diff --git a/src/web/src/components/community/bots/bot-list.tsx b/src/web/src/components/community/bots/bot-list.tsx
index 8795c7bb7..95fae119b 100644
--- a/src/web/src/components/community/bots/bot-list.tsx
+++ b/src/web/src/components/community/bots/bot-list.tsx
@@ -297,22 +297,15 @@ export function BotList({ onBack }: { onBack?: () => void } = {}) {
</>
)}
</span>
- {/* Mobile heatmap: full-width ribbon below the meta
- line (Gus /Gus/uiux #164). Desktop places its
- own instance on the card's right (below).
- Visibility is on the wrapper, not the grid
- element, to avoid a display-class conflict. */}
- <div className="mt-1.5 sm:hidden">
- <BotActivityHeatmap days={bot.dailyActivity} variant="mobile" />
- </div>
</div>
</div>
{/* Desktop heatmap: thin strip in the card's empty
right side, pushed toward the kebab (Gus
/Gus/uiux #155). ml-auto eats the gap so it hugs
- the right rather than centering in a justify-between
- row. */}
- <div className="ml-auto hidden self-center sm:block">
+ the right. Only shown on wide screens (xl) — as the
+ window narrows we hide the heatmap first rather than
+ let it squeeze/truncate the name+meta (Gus #699). */}
+ <div className="ml-auto hidden self-center xl:block">
<BotActivityHeatmap days={bot.dailyActivity} variant="desktop" />
</div>
<DropdownMenu>
@@ -361,6 +354,15 @@ export function BotList({ onBack }: { onBack?: () => void } = {}) {
</DropdownMenuContent>
</DropdownMenu>
</div>
+ {/* Mobile heatmap: its OWN full-width row under the top
+ row (Gus #699) — a sibling of the avatar+meta+kebab
+ row, not nested in the meta column, so it spans the
+ whole card (left padding to right padding), not just
+ the text column. Shown below xl; on xl+ the desktop
+ strip in the top row takes over. */}
+ <div className="xl:hidden">
+ <BotActivityHeatmap days={bot.dailyActivity} variant="mobile" />
+ </div>
</Card>
)
})}