@koinzhang/paseo-plugin-activity 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +78 -1
- package/README.md +15 -8
- package/client/activity-heatmap.tsx +126 -93
- package/client/agent-creations.tsx +216 -0
- package/client/attention-pill.tsx +16 -5
- package/client/attention-popover.tsx +19 -23
- package/client/color-mix.test.ts +27 -0
- package/client/color-mix.ts +38 -0
- package/client/design-tokens.test.ts +39 -0
- package/client/design-tokens.ts +168 -0
- package/client/fit-text.test.ts +41 -0
- package/client/fit-text.ts +33 -0
- package/client/formatted-time.tsx +4 -4
- package/client/global-surface.tsx +316 -275
- package/client/header-button.ts +136 -0
- package/client/hourly-activity-timeline.tsx +425 -0
- package/client/measured-width.ts +72 -0
- package/client/panel-visibility.test.ts +25 -0
- package/client/panel-visibility.ts +45 -0
- package/client/panel.tsx +83 -108
- package/client/provider-dropdown.tsx +131 -0
- package/client/provider-filter.test.ts +17 -13
- package/client/provider-filter.ts +5 -7
- package/client/range.test.ts +44 -0
- package/client/range.ts +14 -0
- package/client/rank-color.test.ts +108 -14
- package/client/rank-color.ts +261 -48
- package/client/ranking-bars.tsx +291 -0
- package/client/ui.tsx +339 -0
- package/client/usage-popover.tsx +62 -134
- package/client/usage-stats.tsx +137 -8
- package/client/use-agent-turn-end.ts +2 -1
- package/client/use-app-language.ts +17 -0
- package/client/web.ts +73 -18
- package/client/workspace/agent-row.tsx +18 -25
- package/client/workspace/agents-section.tsx +23 -20
- package/client/workspace/constants.ts +6 -6
- package/client/workspace/display-menu.tsx +5 -4
- package/client/workspace/filters.test.ts +1 -1
- package/client/workspace/filters.ts +4 -2
- package/client/workspace/panel.tsx +176 -104
- package/client/workspace/rank-section.tsx +157 -44
- package/client/workspace/terminals-section.tsx +13 -9
- package/index.client.tsx +40 -20
- package/index.server.ts +63 -31
- package/package.json +2 -2
- package/paseo-plugin.json +2 -1
- package/server/agents.ts +20 -2
- package/server/background-sync.test.ts +43 -0
- package/server/background-sync.ts +43 -4
- package/server/handlers-query.test.ts +252 -1
- package/server/handlers.ts +174 -13
- package/server/ingest.test.ts +8 -0
- package/server/messages.test.ts +96 -1
- package/server/prompt-dedupe.ts +52 -0
- package/server/rpc-cache.test.ts +74 -0
- package/server/rpc-cache.ts +48 -0
- package/server/store.test.ts +122 -0
- package/server/store.ts +313 -19
- package/server/ttl-cache.ts +3 -0
- package/shared/activity.test.ts +159 -6
- package/shared/activity.ts +140 -5
- package/shared/classify.test.ts +1 -0
- package/shared/classify.ts +4 -1
- package/shared/explorer-agent-display.test.ts +61 -0
- package/shared/explorer-agent-display.ts +21 -2
- package/shared/format.test.ts +28 -3
- package/shared/format.ts +25 -2
- package/shared/i18n.test.ts +34 -0
- package/shared/i18n.ts +363 -0
- package/shared/insights.test.ts +162 -80
- package/shared/insights.ts +136 -61
- package/shared/usage.test.ts +330 -0
- package/shared/usage.ts +471 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,81 @@ All notable changes to `@koinzhang/paseo-plugin-activity` are documented in this
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.7.0] - 2026-09-27
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Global Activity **Providers** ranking: one bar per provider, cycling Sessions / Prompts / Skill calls / MCP calls from the section header; a selected provider stays highlighted while the others dim.
|
|
13
|
+
- Global Activity **Projects** ranking under Providers, with the same metric switch and provider filter. Projects resolve from the workspace's project root (recorded while the workspace is listed), the agent `cwd` under a known project, or a sibling in the same Paseo worktree; the rest group under Other.
|
|
14
|
+
- `usage.by-project` RPC; the agent registry now records `cwd` and `project_root`.
|
|
15
|
+
- `usage.agent-lifetime` now also reports average engaged session time and prompted / multi-turn session counts.
|
|
16
|
+
- Heatmap, Last 30 days histogram and Timeline each get a Sessions / Prompts / Skill calls / MCP calls switch (default Sessions); the timeline draws a single series for the chosen metric.
|
|
17
|
+
- Global KPI tiles compare against the previous 7 days: Sessions / Prompts show the change vs prev. 7d, Top provider / Top model show the previous window's leader; the provider filter applies to both windows.
|
|
18
|
+
- Providers and Projects rankings collapse to five rows with a `Show N more` / `Show less` toggle.
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- Requires Paseo **>= 0.9.0** (was >= 0.9.0-beta.2).
|
|
23
|
+
- Activity insights now show Active days, Busiest day, Workspaces, Coding vs chat, Longest streak, Peak weekday (full name), Multi-turn sessions (share of prompted sessions with 2+ prompts) and Avg session duration (engaged time, idle gaps over 30 min skipped). Skill / MCP calls, Prompts per session and Longest session were removed.
|
|
24
|
+
- Global Activity says **Sessions** wherever it counts agent conversations (KPI, Insights, creations histogram, timeline, heatmap tooltip, empty state). Workspace / Agent Agents lists are unchanged.
|
|
25
|
+
- Global filter bar: the range chips are gone (the page is all-time) and provider chips became a `Provider: All ▾` dropdown listing every provider instead of the top 5.
|
|
26
|
+
- Global KPI: Sessions, Prompts, Top provider · share, Top model · share. Active days, Peak weekday and Longest streak moved into Insights.
|
|
27
|
+
- User-sent messages are called **Prompts** in every Activity view; the Workspace "Show → Prompt" preview is now "Latest prompt".
|
|
28
|
+
- Most used models lists every model; skills / MCP stay capped at 8.
|
|
29
|
+
- The heatmap no longer shows the Daily / Weekly / Cumulative switch (always daily).
|
|
30
|
+
- Global chart titles name their granularity: Activity Calendar (heatmap), Daily Activity (30-day histogram), Hourly Activity (timeline).
|
|
31
|
+
- Activity insights put Longest streak and Peak weekday above Workspaces.
|
|
32
|
+
|
|
33
|
+
### Fixed
|
|
34
|
+
|
|
35
|
+
- Rescans no longer overwrite an event's real time with the later replay time: upserts keep the earliest timestamp, an event time can never be later than its first ingest, and existing rows are repaired on startup.
|
|
36
|
+
- Replayed copies of a prompt are dropped: a prompt sent live and later replayed by the provider is stored once, keeping the live row's real time and model.
|
|
37
|
+
- The Global `Provider: All ▾` filter is right-aligned in the content area, and its menu opens right-aligned under the trigger.
|
|
38
|
+
- Oh My Pi (`omp`) is counted as its own provider everywhere instead of being merged into Pi; stored data is unchanged.
|
|
39
|
+
- KPI fit-to-width accounts for the tile divider, so values that just fit no longer ellipsize by a pixel.
|
|
40
|
+
|
|
41
|
+
## [0.6.0] - 2026-09-22
|
|
42
|
+
|
|
43
|
+
Requires Paseo **>= 0.9.0-beta.2**.
|
|
44
|
+
|
|
45
|
+
### Added
|
|
46
|
+
|
|
47
|
+
- Workspace Activity Skills and MCP can switch from call-count rankings to newest-first timelines; each call shows its agent title and time, timeline nodes use accent for active agents and gray for archived agents, active-agent rows open their conversations, and both sections share one host-scoped persisted view choice.
|
|
48
|
+
- `usage.recent-skill-calls` RPC returns recent exact / inferred skill calls for a workspace with agent titles.
|
|
49
|
+
- `usage.recent-mcp-calls` RPC returns recent MCP calls for a workspace with agent titles.
|
|
50
|
+
- Global Activity **Agent creations** histogram: a fixed 30-local-day window of daily bars stacked by provider, with per-provider colours and a hover / focus / click card listing every provider's count for that day plus the date.
|
|
51
|
+
- `usage.agent-creations` RPC: daily creation counts with per-provider slices, read from the agent registry alone (no tool-call or message joins).
|
|
52
|
+
- `usage.agent-lifetime` now includes still-active agents (`createdAt → now`, marked `· active` in the KPI) instead of archived agents only.
|
|
53
|
+
- Directory sync lists archived agents (`includeArchived`) so archive metadata (`archivedAt`) is backfilled for agents archived before or between observations; archived entries are registered but never timeline-scanned.
|
|
54
|
+
|
|
55
|
+
### Changed
|
|
56
|
+
|
|
57
|
+
- Workspace Activity Skills / MCP default to the newest-call timeline; an explicitly saved ranked view is kept.
|
|
58
|
+
- Global KPI reordered to lead with Top / Longest: Agents, Longest agent, Top provider, Top model, Peak weekday, Longest streak; Insights fixed at 8 rows.
|
|
59
|
+
- Agent creations histogram ignores the range chips (always the last 30 local days) and no longer depends on `usage.activity-by-day`.
|
|
60
|
+
- `mcpServerColor` renamed to `entityColor`; the same accent-derived stable colour now covers MCP servers and providers.
|
|
61
|
+
- KPI values and labels shrink to fit their tile instead of wrapping onto a second line (Global / Workspace / Agent share `UsageStats`); line height is fixed so the label baselines stay aligned.
|
|
62
|
+
- Top provider / Top model KPI tiles show the name only (no share), matching the provider-filtered shape; shares stay available from `usage.by-provider`.
|
|
63
|
+
- Agent creations bars round only the top segment's top corners — stacked joints and bar bottoms are square.
|
|
64
|
+
- Agent creations day bars are a single soft provider-colour gradient (tiny middle shares omitted so they cannot notch the bar; remaining colours blend evenly) instead of hard stacked segments; single-provider days stay solid.
|
|
65
|
+
- Global KPI tile 3 and Insights row 3 swapped: `Peak weekday` moved to the KPI (penultimate tile, next to `Longest streak`) and `Workspaces` reads with the volume counts in Insights.
|
|
66
|
+
- Agent creations / MCP rank colours use a soft fixed chart palette (light + dark, inferred from `surface0` luminance) instead of accent-hue hashing; known Paseo providers map to stable slots.
|
|
67
|
+
- Agent creations stacked segments follow window-wide provider rank (largest series at the bottom on every bar), not each day's local count order.
|
|
68
|
+
- Agent creations header no longer shows `N agents · last 30 days` (title is `Agents` only).
|
|
69
|
+
- Chart palette: light / dark colour sets swapped (bright fills on light UI, deep fills on dark UI).
|
|
70
|
+
- Agent creations colours: branded providers keep brand accents; unbranded catalog providers and any future ACP id fall back to the soft chart palette (no theme `accent` for the window leader).
|
|
71
|
+
- Agent creations hover card lists only providers with creations that day (no `: 0` rows); empty days still show the date alone.
|
|
72
|
+
- Agent creations day bars use the same theme-accent intensity steps as the Activity heatmap; provider brand colours remain only on the hover card chips.
|
|
73
|
+
- Activity heatmap rows are weekdays again (row 1 Sunday … row 7 Saturday) and each column is one Sunday-start calendar week, matching GitHub / Codex contribution graphs. The window is still 52 columns × 7 rows ending with the current week; days after today in the last column stay blank.
|
|
74
|
+
- Heatmap `Daily / Weekly / Cumulative` tabs use the month-axis label size (12) instead of their own 13 / 15 scale.
|
|
75
|
+
- Global Activity adds a rolling 168-hour timeline below the Agents histogram: a diverging filled line chart with messages above the time axis and agents below it. The viewport shows 24 hours at a time and starts at the current hour; press and drag the chart to pan through the rest of the week (no scrollbar). Empty hours keep their slot, and hovering or focusing an hour reveals its local range with agents, messages, skill calls, and MCP calls; the window is independent of range chips.
|
|
76
|
+
|
|
77
|
+
### Fixed
|
|
78
|
+
|
|
79
|
+
- Switching back to Activity no longer re-lays out the heatmap or the 168-hour timeline. A hidden page reports width 0 to `onLayout` (and a hidden app window runs no rendering updates at all, so `onLayout` never fires), which collapsed the grid to nothing until the next measurement. Both sections now ignore zero widths, remember the last real width across remounts, and re-measure synchronously from the DOM node on mount, resize, and `visibilitychange`.
|
|
80
|
+
- Global Activity section rhythm: the heatmap month row no longer reserves a fixed 24px band, the 168-hour timeline's inner gap matches the other chart sections, and the insights / rank-list titles share the same 10 / 12 title gap. Sections now read as one evenly spaced stack (container gap 24 / 32 unchanged; list row density untouched).
|
|
81
|
+
- Longest-agent metric was understated: agents archived before the plugin could observe them had no `archived_at`, so the tile only ever saw live-hook archives.
|
|
82
|
+
|
|
8
83
|
## [0.5.0] - 2026-09-20
|
|
9
84
|
|
|
10
85
|
Requires Paseo **>= 0.9.0-beta.2**.
|
|
@@ -113,7 +188,9 @@ Last release that supports Paseo **0.8.0**. Later versions require Paseo **>= 0.
|
|
|
113
188
|
- Command Center entries: open panels and export a markdown usage report.
|
|
114
189
|
- Plugin renamed from `tool-usage` to `activity`, migrating the old data directory automatically.
|
|
115
190
|
|
|
116
|
-
[Unreleased]: https://github.com/koinzhang/paseo-plugins/compare/activity-v0.
|
|
191
|
+
[Unreleased]: https://github.com/koinzhang/paseo-plugins/compare/activity-v0.7.0...HEAD
|
|
192
|
+
[0.7.0]: https://github.com/koinzhang/paseo-plugins/releases/tag/activity-v0.7.0
|
|
193
|
+
[0.6.0]: https://github.com/koinzhang/paseo-plugins/releases/tag/activity-v0.6.0
|
|
117
194
|
[0.5.0]: https://github.com/koinzhang/paseo-plugins/releases/tag/activity-v0.5.0
|
|
118
195
|
[0.4.0]: https://github.com/koinzhang/paseo-plugins/releases/tag/activity-v0.4.0
|
|
119
196
|
[0.3.0]: https://github.com/koinzhang/paseo-plugins/releases/tag/activity-v0.3.0
|
package/README.md
CHANGED
|
@@ -6,8 +6,8 @@ It still answers “how am I using Paseo” (tools, messages, models, habits). W
|
|
|
6
6
|
|
|
7
7
|
| Scope | Role |
|
|
8
8
|
|---|---|
|
|
9
|
-
| **Global** | Cross-workspace habits: heatmap,
|
|
10
|
-
| **Workspace** | Per-workspace agent fleet: ranked list + display prefs + archive; live status (permission / finished / error / running); open Terminals; shell / file /
|
|
9
|
+
| **Global** | Cross-workspace habits: KPI vs the previous 7 days, daily heatmap, rolling 168-hour activity timeline, `Provider: All ▾` filter, per-chart Sessions / Prompts / Skill calls / MCP calls switches, collapsible Providers / Projects rankings, insights, most-used skills / MCP / models |
|
|
10
|
+
| **Workspace** | Per-workspace agent fleet: ranked list + display prefs + archive; live status (permission / finished / error / running); open Terminals; shell / file / prompt KPIs; times via shared `FormattedTime` |
|
|
11
11
|
| **Agent** | Current session: dense tool KPIs, Skills / MCP header toggle, SKILL.md reader, composer Activity pill; **Needs attention** pill jumps to other same-workspace finished/permission/error sessions |
|
|
12
12
|
|
|
13
13
|
Architecture notes: [docs/architecture.md](./docs/architecture.md).
|
|
@@ -20,14 +20,14 @@ Ingests every agent's Paseo timeline into a local SQLite database. Queries read
|
|
|
20
20
|
|---|---|
|
|
21
21
|
| Tools | Skill / MCP / shell / file calls; skills classified into exact / inferred / low confidence tiers |
|
|
22
22
|
| Agents | Every created agent (registry with archive metadata) |
|
|
23
|
-
|
|
|
23
|
+
| Prompts | User-sent messages (called **Prompts** in every Activity view) |
|
|
24
24
|
| Models | Model at send time (weighted by messages; global view) |
|
|
25
25
|
|
|
26
26
|
## Where it shows up
|
|
27
27
|
|
|
28
|
-
- **Sidebar Activity** — global view by provider (heatmap,
|
|
29
|
-
- **Explorer → Activity** — workspace agents as a management list (search / sort / group / status / lifecycle / archive), live attention (permission badge, status colors, running spinner; API-owned directory observation + explicit lifecycle/archive fields + 15s reconciliation), open Terminals (list / preview / close), plus workspace KPIs and
|
|
30
|
-
- **Agent workspace panel** — per-agent tool detail (dense KPI including
|
|
28
|
+
- **Sidebar Activity** — all-time global view by provider (KPI with prev-7d comparison, Activity Calendar heatmap, Daily Activity 30-day histogram, Hourly Activity 168-hour timeline, Providers / Projects rankings, insights, most used)
|
|
29
|
+
- **Explorer → Activity** — workspace agents as a management list (search / sort / group / status / lifecycle / archive), live attention (permission badge, status colors, running spinner; API-owned directory observation + explicit lifecycle/archive fields + 15s reconciliation), open Terminals (list / preview / close), plus workspace KPIs and Skills / MCP ranked or newest-call timeline views (with agent titles and one shared persisted view choice); usage queries get a best-effort refresh hint when agents leave running
|
|
30
|
+
- **Agent workspace panel** — per-agent tool detail (dense KPI including prompts / Skills / MCP toggle / SKILL.md); refreshes on timeline turn terminal events
|
|
31
31
|
- **Composer pills** — Activity: current agent's skill / MCP summary (hidden when empty); **Needs attention**: other same-workspace agents with finished / permission / error (hidden when none; click opens shared list)
|
|
32
32
|
- **Command Center** — Activity · Workspace Activity · Agent Activity
|
|
33
33
|
|
|
@@ -37,7 +37,7 @@ Everything lives on the daemon machine in `~/.paseo/plugin-data/activity/` (SQLi
|
|
|
37
37
|
|
|
38
38
|
## Install
|
|
39
39
|
|
|
40
|
-
Requires Paseo **>= 0.9.0
|
|
40
|
+
Requires Paseo **>= 0.9.0**. **0.4.0** is the last release that supports Paseo 0.8.0.
|
|
41
41
|
|
|
42
42
|
From Git (Paseo 0.8 and later):
|
|
43
43
|
|
|
@@ -52,6 +52,12 @@ paseo plugin install npm:@koinzhang/paseo-plugin-activity
|
|
|
52
52
|
# Paseo 0.8: npm:@koinzhang/paseo-plugin-activity@0.4.0
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
+
From a local checkout (development), run this inside `activity/`. It uses the same plugin ID `activity`, so don't pass `--id`, and it shares the same data directory:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
paseo plugin install "$PWD" # absolute path; `paseo plugin remove activity` first if npm is installed
|
|
59
|
+
```
|
|
60
|
+
|
|
55
61
|
After source changes, reload and check status:
|
|
56
62
|
|
|
57
63
|
```bash
|
|
@@ -65,6 +71,7 @@ paseo plugin ls
|
|
|
65
71
|
- Analytics and the agent registry are local to each daemon: every machine keeps its own database, and there is no cross-host aggregation.
|
|
66
72
|
- Numbers are reconstructed from the Paseo timeline; items that do not report a model or skill cannot be attributed for that dimension.
|
|
67
73
|
- Skill classification is heuristic (exact / inferred / low confidence); check the tier before trusting a count.
|
|
74
|
+
- Project attribution for the Projects ranking comes from the workspace root recorded while it was listed, or the agent `cwd`; sessions with neither group under **Other**.
|
|
68
75
|
- Workspace Activity focuses on agent operations for the current workspace; heatmap / provider / model breakdowns stay on the global sidebar.
|
|
69
76
|
|
|
70
77
|
## Development
|
|
@@ -79,7 +86,7 @@ This plugin is spec-driven: read [specs/README.md](./specs/README.md) before cod
|
|
|
79
86
|
|
|
80
87
|
## Publish
|
|
81
88
|
|
|
82
|
-
Release history: [CHANGELOG.md](./CHANGELOG.md) (current **0.
|
|
89
|
+
Release history: [CHANGELOG.md](./CHANGELOG.md) (current **0.6.0**). npm releases go through a GitHub Release tag `activity-vX.Y.Z` (not push-to-`main` alone). Steps: [CONTRIBUTING.md § Publishing to npm](../CONTRIBUTING.md#publishing-to-npm).
|
|
83
90
|
|
|
84
91
|
## License
|
|
85
92
|
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import { useEffect, useMemo, useState } from "react";
|
|
2
|
-
import { Pressable, ScrollView, Text, View } from "react-native";
|
|
1
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { Animated, Easing, Pressable, ScrollView, Text, View } from "react-native";
|
|
3
3
|
import type { ActivityDay } from "../shared/usage.ts";
|
|
4
|
-
import { activityLevel, buildActivityCalendar, type HeatmapMode } from "../shared/activity.ts";
|
|
4
|
+
import { activityLevel, buildActivityCalendar, metricValue, type ActivityMetric, type HeatmapMode } from "../shared/activity.ts";
|
|
5
5
|
import { useAppLanguage } from "./use-app-language.ts";
|
|
6
|
+
import { useMeasuredWidth } from "./measured-width.ts";
|
|
7
|
+
import { ACTIVITY_MIX_STEPS, mixColor } from "./color-mix.ts";
|
|
6
8
|
export { computeStreaks, type HeatmapMode } from "../shared/activity.ts";
|
|
9
|
+
import { CHART_MOTION, FONT_SIZE, sectionTitle, titleGap } from "./design-tokens.ts";
|
|
10
|
+
import { messagesFor } from "../shared/i18n.ts";
|
|
11
|
+
import { ChartTooltip, MetricStepper } from "./ui.tsx";
|
|
7
12
|
|
|
8
13
|
type ThemeColors = {
|
|
9
14
|
accent: string; border: string; foreground: string; foregroundMuted: string;
|
|
@@ -12,27 +17,8 @@ type ThemeColors = {
|
|
|
12
17
|
|
|
13
18
|
type HoveredMonth = { year: number; month: number };
|
|
14
19
|
|
|
15
|
-
//
|
|
16
|
-
|
|
17
|
-
const parse = (value: string): number[] | null => {
|
|
18
|
-
const hex = value.replace("#", "").trim();
|
|
19
|
-
const expanded = hex.length === 3 || hex.length === 4
|
|
20
|
-
? hex.split("").map((c) => c + c).join("")
|
|
21
|
-
: hex;
|
|
22
|
-
// Use first 6 digits only — ignore trailing alpha on 8-digit hex.
|
|
23
|
-
const rgb = expanded.slice(0, 6);
|
|
24
|
-
if (!/^[0-9a-fA-F]{6}$/.test(rgb)) return null;
|
|
25
|
-
return [0, 2, 4].map((i) => parseInt(rgb.slice(i, i + 2), 16));
|
|
26
|
-
};
|
|
27
|
-
const a = parse(base);
|
|
28
|
-
const b = parse(accent);
|
|
29
|
-
if (!a || !b) return base;
|
|
30
|
-
return `rgb(${a.map((v, i) => Math.round(v + (b[i]! - v) * amount)).join(",")})`;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function plural(count: number, singular: string, pluralForm = `${singular}s`): string {
|
|
34
|
-
return `${count.toLocaleString()} ${count === 1 ? singular : pluralForm}`;
|
|
35
|
-
}
|
|
20
|
+
// Month-axis labels stay at the secondary label size under the section title.
|
|
21
|
+
const LABEL_FONT_SIZE = FONT_SIZE.label;
|
|
36
22
|
|
|
37
23
|
function cellInMonth(dateKey: string, hovered: HoveredMonth | null): boolean {
|
|
38
24
|
if (!hovered) return false;
|
|
@@ -40,16 +26,15 @@ function cellInMonth(dateKey: string, hovered: HoveredMonth | null): boolean {
|
|
|
40
26
|
return year === hovered.year && month === hovered.month + 1;
|
|
41
27
|
}
|
|
42
28
|
|
|
43
|
-
export function ActivityHeatmap({ days, from, colors, compact, mode
|
|
29
|
+
export function ActivityHeatmap({ days, from, colors, compact, mode }: {
|
|
44
30
|
days: readonly ActivityDay[]; from?: string; colors: ThemeColors; compact?: boolean;
|
|
45
|
-
mode: HeatmapMode;
|
|
46
|
-
modeOptions: ReadonlyArray<{ id: HeatmapMode; label: string }>;
|
|
31
|
+
mode: HeatmapMode;
|
|
47
32
|
}) {
|
|
33
|
+
const [metric, setMetric] = useState<ActivityMetric>("sessions");
|
|
48
34
|
const locale = useAppLanguage();
|
|
49
|
-
const [width,
|
|
35
|
+
const [width, widthRef, onWidthLayout] = useMeasuredWidth("global:heatmap");
|
|
50
36
|
const [gridTop, setGridTop] = useState(0);
|
|
51
37
|
const [scrollX, setScrollX] = useState(0);
|
|
52
|
-
const [tooltipSize, setTooltipSize] = useState({ width: 220, height: 28 });
|
|
53
38
|
const [selected, setSelected] = useState<string | null>(null);
|
|
54
39
|
const [hovered, setHovered] = useState<string | null>(null);
|
|
55
40
|
const [hoveredMonth, setHoveredMonth] = useState<HoveredMonth | null>(null);
|
|
@@ -58,7 +43,34 @@ export function ActivityHeatmap({ days, from, colors, compact, mode, onModeChang
|
|
|
58
43
|
setHovered(null);
|
|
59
44
|
setHoveredMonth(null);
|
|
60
45
|
}, [from, mode, days]);
|
|
61
|
-
const
|
|
46
|
+
const reveal = useRef(new Animated.Value(0)).current;
|
|
47
|
+
const revealedRef = useRef(false);
|
|
48
|
+
const measured = width > 0;
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (!measured) return;
|
|
51
|
+
const first = !revealedRef.current;
|
|
52
|
+
reveal.setValue(0);
|
|
53
|
+
const animation = Animated.timing(reveal, {
|
|
54
|
+
toValue: 1,
|
|
55
|
+
duration: first ? CHART_MOTION.reveal : CHART_MOTION.refresh,
|
|
56
|
+
easing: Easing.out(Easing.cubic),
|
|
57
|
+
useNativeDriver: false,
|
|
58
|
+
});
|
|
59
|
+
animation.start(() => {
|
|
60
|
+
revealedRef.current = true;
|
|
61
|
+
});
|
|
62
|
+
return () => animation.stop();
|
|
63
|
+
}, [measured, metric, mode, from, reveal]);
|
|
64
|
+
const { weeks, months } = useMemo(() => buildActivityCalendar(days, mode, from, new Date(), locale), [days, mode, from, locale]);
|
|
65
|
+
// Intensity follows the selected metric only (070), not the four-metric total.
|
|
66
|
+
const max = useMemo(
|
|
67
|
+
() =>
|
|
68
|
+
weeks.flat().reduce(
|
|
69
|
+
(peak, cell) => (cell.future || cell.excluded ? peak : Math.max(peak, metricValue(cell, metric))),
|
|
70
|
+
0,
|
|
71
|
+
),
|
|
72
|
+
[weeks, metric],
|
|
73
|
+
);
|
|
62
74
|
const gap = compact ? 2 : 3;
|
|
63
75
|
// Fit the full year into the measured width (no min floor — avoid horizontal overflow).
|
|
64
76
|
const cellSize =
|
|
@@ -67,38 +79,42 @@ export function ActivityHeatmap({ days, from, colors, compact, mode, onModeChang
|
|
|
67
79
|
: 0;
|
|
68
80
|
const gridWidth = weeks.length > 0 ? weeks.length * (cellSize + gap) - gap : 0;
|
|
69
81
|
const needsScroll = gridWidth > width + 0.5;
|
|
70
|
-
const palette = [colors.surface2, ...
|
|
82
|
+
const palette = [colors.surface2, ...ACTIVITY_MIX_STEPS.map(n => mixColor(colors.surface2, colors.accent, n))];
|
|
71
83
|
const activeKey = hovered ?? selected;
|
|
72
84
|
const activeIndex = weeks.flat().findIndex(cell => cell.key === activeKey);
|
|
73
85
|
const active = activeIndex >= 0 ? weeks.flat()[activeIndex] : undefined;
|
|
74
86
|
const anchorX = Math.floor(activeIndex / 7) * (cellSize + gap) + cellSize / 2 - scrollX;
|
|
75
87
|
const anchorY = gridTop + (activeIndex % 7) * (cellSize + gap);
|
|
76
|
-
const tooltipLeft = Math.max(0, Math.min(anchorX - tooltipSize.width / 2, width - tooltipSize.width));
|
|
77
|
-
const tooltipTop = Math.max(0, anchorY - tooltipSize.height - 8);
|
|
78
88
|
const dateLabel = active ? (() => {
|
|
79
89
|
const [year, month, day] = active.key.split("-").map(Number);
|
|
80
90
|
return new Date(year!, month! - 1, day!).toLocaleDateString(locale, {
|
|
81
91
|
month: "short", day: "numeric", year: year !== new Date().getFullYear() ? "numeric" : undefined,
|
|
82
92
|
});
|
|
83
93
|
})() : "";
|
|
84
|
-
const
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
94
|
+
const m = messagesFor(locale);
|
|
95
|
+
const periodLabel = (date: string) =>
|
|
96
|
+
mode === "weekly" ? m.heatmap.weekContaining(date) : mode === "cumulative" ? m.heatmap.through(date) : date;
|
|
97
|
+
const tooltipRows = active
|
|
98
|
+
? [
|
|
99
|
+
{ label: m.common.sessions, value: active.agents.toLocaleString(locale) },
|
|
100
|
+
{ label: m.common.prompts, value: active.messages.toLocaleString(locale) },
|
|
101
|
+
{ label: m.common.skills, value: active.skills.toLocaleString(locale) },
|
|
102
|
+
{ label: m.common.mcp, value: active.mcp.toLocaleString(locale) },
|
|
103
|
+
]
|
|
104
|
+
: [];
|
|
105
|
+
const floor = revealedRef.current ? CHART_MOTION.refreshFloor : 0;
|
|
106
|
+
const columnStep = weeks.length > 1 ? (1 - CHART_MOTION.columnSpan) / (weeks.length - 1) : 0;
|
|
88
107
|
const axisWidth = needsScroll ? gridWidth : width;
|
|
89
|
-
const modeLabel = mode === "weekly" ? "Week containing" : mode === "cumulative" ? "Through" : "";
|
|
90
108
|
const monthFocus = hoveredMonth != null;
|
|
91
109
|
return (
|
|
92
|
-
<View
|
|
110
|
+
<View
|
|
111
|
+
ref={widthRef}
|
|
112
|
+
style={{ gap: titleGap(compact) }}
|
|
113
|
+
onLayout={onWidthLayout}
|
|
114
|
+
>
|
|
93
115
|
<View style={{ flexDirection: "row", flexWrap: "wrap", alignItems: "center", justifyContent: "space-between", gap: 12 }}>
|
|
94
|
-
<Text style={{ color: colors.foreground
|
|
95
|
-
<
|
|
96
|
-
{modeOptions.map(option => (
|
|
97
|
-
<Pressable key={option.id} accessibilityRole="tab" accessibilityState={{ selected: mode === option.id }} onPress={() => onModeChange(option.id)} style={{ paddingVertical: 6 }}>
|
|
98
|
-
<Text style={{ color: mode === option.id ? colors.foreground : colors.foregroundMuted, fontSize: compact ? 13 : 15 }}>{option.label}</Text>
|
|
99
|
-
</Pressable>
|
|
100
|
-
))}
|
|
101
|
-
</View>
|
|
116
|
+
<Text style={{ ...sectionTitle(compact), color: colors.foreground }}>{m.heatmap.title}</Text>
|
|
117
|
+
<MetricStepper value={metric} onChange={setMetric} colors={colors} />
|
|
102
118
|
</View>
|
|
103
119
|
<ScrollView
|
|
104
120
|
horizontal
|
|
@@ -108,48 +124,67 @@ export function ActivityHeatmap({ days, from, colors, compact, mode, onModeChang
|
|
|
108
124
|
onScroll={event => setScrollX(event.nativeEvent.contentOffset.x)}
|
|
109
125
|
scrollEventThrottle={16}
|
|
110
126
|
>
|
|
111
|
-
<View style={{ width: Math.max(0, axisWidth)
|
|
127
|
+
<View style={{ width: Math.max(0, axisWidth) }}>
|
|
112
128
|
<View style={{ flexDirection: "row", gap }}>
|
|
113
|
-
{weeks.map((week, i) =>
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
129
|
+
{weeks.map((week, i) => {
|
|
130
|
+
const cells = week.map(cell => {
|
|
131
|
+
const hidden = cell.future || cell.excluded;
|
|
132
|
+
const inMonth = cellInMonth(cell.key, hoveredMonth);
|
|
133
|
+
const level = activityLevel(metricValue(cell, metric), max);
|
|
134
|
+
const base = palette[level]!;
|
|
135
|
+
// Focus = leave target month as-is; gently mute others toward surface2
|
|
136
|
+
// (same space as empty cells — preserves activity hue, avoids surface0 parse issues).
|
|
137
|
+
const fill =
|
|
138
|
+
hidden
|
|
139
|
+
? base
|
|
140
|
+
: monthFocus && inMonth
|
|
141
|
+
? mixColor(base, colors.accent, 0.04)
|
|
142
|
+
: base;
|
|
143
|
+
const opacity = hidden
|
|
144
|
+
? 0
|
|
145
|
+
: monthFocus && !inMonth
|
|
146
|
+
? 0.64
|
|
147
|
+
: 1;
|
|
148
|
+
return { cell, hidden, colored: !hidden && level > 0, fill, opacity };
|
|
149
|
+
});
|
|
150
|
+
const cellShape = { width: cellSize, height: cellSize, borderRadius: Math.max(2, cellSize / 4) };
|
|
151
|
+
return (
|
|
152
|
+
<View key={i} style={{ gap }}>
|
|
153
|
+
{/* Static layer: empty cells and every hit target; only colored cells animate. */}
|
|
154
|
+
{cells.map(({ cell, hidden, colored, fill, opacity }) => (
|
|
134
155
|
<Pressable key={cell.key} disabled={hidden} accessibilityRole="button"
|
|
135
|
-
accessibilityLabel={`${
|
|
156
|
+
accessibilityLabel={`${periodLabel(cell.key)}: ${m.units.prompts(cell.messages)}, ${m.units.sessions(cell.agents)}, ${m.units.skills(cell.skills)}, ${m.units.mcp(cell.mcp)}`}
|
|
136
157
|
accessibilityState={{ selected: activeKey === cell.key }}
|
|
137
158
|
onHoverIn={() => setHovered(cell.key)} onHoverOut={() => setHovered(null)}
|
|
138
159
|
onFocus={() => setHovered(cell.key)} onBlur={() => setHovered(null)}
|
|
139
160
|
onPress={() => setSelected(prev => prev === cell.key ? null : cell.key)}
|
|
161
|
+
style={{ ...cellShape, backgroundColor: colored ? "transparent" : fill, opacity }} />
|
|
162
|
+
))}
|
|
163
|
+
{cells.some(item => item.colored) ? (
|
|
164
|
+
<Animated.View
|
|
165
|
+
pointerEvents="none"
|
|
140
166
|
style={{
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
opacity
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
167
|
+
position: "absolute",
|
|
168
|
+
top: 0,
|
|
169
|
+
left: 0,
|
|
170
|
+
gap,
|
|
171
|
+
opacity: reveal.interpolate({
|
|
172
|
+
inputRange: [i * columnStep, i * columnStep + CHART_MOTION.columnSpan],
|
|
173
|
+
outputRange: [floor, 1],
|
|
174
|
+
extrapolate: "clamp",
|
|
175
|
+
}),
|
|
176
|
+
}}
|
|
177
|
+
>
|
|
178
|
+
{cells.map(({ cell, colored, fill, opacity }) => (
|
|
179
|
+
<View key={cell.key} style={{ ...cellShape, backgroundColor: colored ? fill : "transparent", opacity }} />
|
|
180
|
+
))}
|
|
181
|
+
</Animated.View>
|
|
182
|
+
) : null}
|
|
183
|
+
</View>
|
|
184
|
+
);
|
|
185
|
+
})}
|
|
151
186
|
</View>
|
|
152
|
-
<View style={{
|
|
187
|
+
<View style={{ marginTop: 10, flexDirection: "row", justifyContent: "space-between" }}>
|
|
153
188
|
{months.map((item, i) => {
|
|
154
189
|
const activeMonth =
|
|
155
190
|
hoveredMonth?.year === item.year && hoveredMonth.month === item.month;
|
|
@@ -157,7 +192,7 @@ export function ActivityHeatmap({ days, from, colors, compact, mode, onModeChang
|
|
|
157
192
|
<Pressable
|
|
158
193
|
key={`${item.year}-${item.month}-${i}`}
|
|
159
194
|
accessibilityRole="button"
|
|
160
|
-
accessibilityLabel={
|
|
195
|
+
accessibilityLabel={m.heatmap.highlightMonth(item.label)}
|
|
161
196
|
onHoverIn={() => setHoveredMonth({ year: item.year, month: item.month })}
|
|
162
197
|
onHoverOut={() => setHoveredMonth(null)}
|
|
163
198
|
onFocus={() => setHoveredMonth({ year: item.year, month: item.month })}
|
|
@@ -168,7 +203,7 @@ export function ActivityHeatmap({ days, from, colors, compact, mode, onModeChang
|
|
|
168
203
|
numberOfLines={1}
|
|
169
204
|
style={{
|
|
170
205
|
color: activeMonth ? colors.foreground : colors.foregroundMuted,
|
|
171
|
-
fontSize:
|
|
206
|
+
fontSize: LABEL_FONT_SIZE,
|
|
172
207
|
}}
|
|
173
208
|
>
|
|
174
209
|
{item.label}
|
|
@@ -180,16 +215,14 @@ export function ActivityHeatmap({ days, from, colors, compact, mode, onModeChang
|
|
|
180
215
|
</View>
|
|
181
216
|
</ScrollView>
|
|
182
217
|
{active && anchorX >= 0 && anchorX <= width ? (
|
|
183
|
-
<
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
</Text>
|
|
192
|
-
</View>
|
|
218
|
+
<ChartTooltip
|
|
219
|
+
anchorX={anchorX}
|
|
220
|
+
anchorY={anchorY}
|
|
221
|
+
containerWidth={width}
|
|
222
|
+
title={periodLabel(dateLabel)}
|
|
223
|
+
rows={tooltipRows}
|
|
224
|
+
colors={colors}
|
|
225
|
+
/>
|
|
193
226
|
) : null}
|
|
194
227
|
</View>
|
|
195
228
|
);
|