Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

feat(community): heatmap domain-scale bands + sent-weighted color

Gusb6b6acfe182d
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 92fda887d..8fe21ed03 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
@@ -80,26 +80,37 @@ describe("BotActivityHeatmap — calendar-axis fill", () => {
// 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 (Alli #712): 1-3=b1, 4-9=b2, 10-24=b3, 25+=b4.
+ // bucket class. Thresholds (Gus #714): 1-50=b1, 51-100=b2, 101-500=b3, 500+=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: 12, sentCount: 0 }, // 12 → b3
- { day: utcDayKeyDaysAgo(now, 0), handledCount: 40, sentCount: 5 }, // 45 → b4
+ { day: utcDayKeyDaysAgo(now, 3), handledCount: 1, sentCount: 0 }, // 1 → b1
+ { day: utcDayKeyDaysAgo(now, 2), handledCount: 60, sentCount: 0 }, // 60 → b2
+ { day: utcDayKeyDaysAgo(now, 1), handledCount: 200, sentCount: 0 }, // 200 → b3
+ { day: utcDayKeyDaysAgo(now, 0), handledCount: 600, sentCount: 5 }, // 605 → 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") // 12 msgs
- expect(tokens[idx(0)]).toContain("bg-status-online") // 45 msgs — darkest, no /opacity
+ expect(tokens[idx(2)]).toContain("bg-status-online/55") // 60 msgs
+ expect(tokens[idx(1)]).toContain("bg-status-online/80") // 200 msgs
+ expect(tokens[idx(0)]).toContain("bg-status-online") // 605 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("weights sent x2 for color only — tooltip still shows raw counts (Gus #716/Blair #717)", () => {
+ const now = new Date()
+ // 30 handled + 20 sent: raw sum 50 (→ b1), but weighted 30+20*2=70 (→ b2).
+ // Color must use the weighted score; tooltip must show the raw numbers.
+ const r = render([{ day: utcDayKeyDaysAgo(now, 0), handledCount: 30, sentCount: 20 }])
+ const cell = cells(r)[29] // today = last slot
+ expect(String(cell.props.className).split(/\s+/)).toContain("bg-status-online/55") // b2, weighted
+ const tip = tips(r).find((t) => t.includes("handled"))
+ expect(tip).toContain("30 handled · 20 sent") // raw, NOT the weighted 70
+ })
+
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 9132ac978..b36104388 100644
--- a/src/web/src/components/community/bots/bot-activity-heatmap.tsx
+++ b/src/web/src/components/community/bots/bot-activity-heatmap.tsx
@@ -41,18 +41,19 @@ const BUCKET_CLASSES = [
const DATE_FMT = new Intl.DateTimeFormat(undefined, { month: "short", day: "numeric" })
-// 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 <= 3) return 1 // 1–3
- if (total <= 9) return 2 // 4–9
- if (total <= 24) return 3 // 10–24
- return 4 // 25+
+// ABSOLUTE thresholds (Gus /Gus/working #708/#714): the heatmap is for seeing
+// WHICH AGENTS are busier, not which day — so tint maps a day's weighted score
+// to a fixed band, comparable across bots (a relative-to-own-max scale, the old
+// #628 version, made every bot's peak darkest so all looked equally busy). Bands
+// are sized for the steady-state ~100 msgs/day an agent handles (Gus #714), not
+// today's dev-period cross-wake noise. `score` is the weighted value below, NOT
+// the raw message count.
+function bucketFor(score: number): number {
+ if (score <= 0) return 0
+ if (score <= 50) return 1 // 1–50
+ if (score <= 100) return 2 // 51–100
+ if (score <= 500) return 3 // 101–500
+ return 4 // 500+
}
function dayLabel(dayKey: string): string {
@@ -120,7 +121,11 @@ export function BotActivityHeatmap({
const d = byDay.get(key)
return {
key,
- bucket: d ? bucketFor(d.handledCount + d.sentCount) : 0,
+ // Coloring weight (Gus #716): sent counts double — sending a message is
+ // impact/real work, vs just being woken to handle one. This weight feeds
+ // ONLY the color bucket; the tooltip and the stored counts stay raw
+ // (Blair #717 — never let the weight leak into what we display or store).
+ bucket: d ? bucketFor(d.handledCount + d.sentCount * 2) : 0,
title: tooltipFor(key, d),
}
})