@koinzhang/paseo-plugin-activity 0.6.0 → 0.8.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 +50 -1
- package/README.md +18 -11
- package/client/activity-heatmap.tsx +115 -74
- package/client/agent-creations.tsx +100 -90
- package/client/attention-pill.tsx +17 -6
- package/client/attention-popover.tsx +19 -23
- package/client/design-tokens.test.ts +39 -0
- package/client/design-tokens.ts +180 -0
- package/client/formatted-time.tsx +4 -4
- package/client/global-surface.tsx +243 -268
- package/client/header-button.ts +136 -0
- package/client/hourly-activity-timeline.tsx +153 -103
- package/client/panel-visibility.test.ts +25 -0
- package/client/panel-visibility.ts +45 -0
- package/client/panel.tsx +94 -111
- package/client/pill.tsx +1 -1
- package/client/provider-dropdown.tsx +134 -0
- package/client/provider-filter.test.ts +17 -13
- package/client/provider-filter.ts +5 -7
- package/client/rank-color.ts +3 -3
- package/client/ranking-bars.tsx +294 -0
- package/client/sidebar-item.tsx +15 -0
- package/client/ui.tsx +351 -0
- package/client/usage-popover.tsx +72 -137
- package/client/usage-stats.tsx +29 -11
- 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 +28 -28
- package/client/workspace/agents-section.tsx +42 -57
- package/client/workspace/constants.ts +8 -6
- package/client/workspace/display-menu.tsx +6 -5
- package/client/workspace/filters.test.ts +1 -1
- package/client/workspace/filters.ts +4 -2
- package/client/workspace/panel.tsx +96 -104
- package/client/workspace/rank-section.tsx +40 -65
- package/client/workspace/running-indicator.tsx +1 -1
- package/client/workspace/terminals-section.tsx +24 -12
- package/index.client.tsx +53 -31
- package/index.server.ts +55 -73
- package/package.json +3 -3
- package/paseo-plugin.json +2 -1
- package/server/agents.ts +20 -2
- package/server/background-sync.ts +34 -4
- package/server/handlers-query.test.ts +27 -1
- package/server/handlers.ts +75 -31
- package/server/host-types.ts +6 -6
- 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/server/turn-ingest.test.ts +180 -0
- package/server/turn-ingest.ts +71 -0
- package/shared/activity.test.ts +36 -0
- package/shared/activity.ts +37 -0
- package/shared/classify.test.ts +1 -10
- package/shared/classify.ts +3 -10
- package/shared/format.ts +10 -7
- package/shared/i18n.test.ts +34 -0
- package/shared/i18n.ts +363 -0
- package/shared/insights.test.ts +120 -81
- package/shared/insights.ts +125 -64
- package/shared/usage.test.ts +121 -0
- package/shared/usage.ts +191 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,53 @@ 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.8.0] - 2026-11-05
|
|
9
|
+
|
|
10
|
+
Requires Paseo **>= 0.15.0**.
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Align the plugin SDK with Paseo 0.15 (`@getpaseo/plugin@0.15.1`): the global page is a screen with a sidebar header row (replacing the deprecated `addSurface` / `addSidebarItem`), the agent panel registers through `addAgentPanel` and reads `params.agentId`, UI components import from `@getpaseo/plugin/client/ui`, and lifecycle hooks use `server.addHook` (`agent.create.after`, `agent.archive.after`, `agent.turn.after`).
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- Tool calls are recorded as soon as a turn ends again. Paseo 0.13+ sends an empty `timeline` in the turn-ended hook, so the plugin reads the recent history back with `timeline.refetch`; the background scan still owns full history.
|
|
19
|
+
|
|
20
|
+
## [0.7.0] - 2026-09-27
|
|
21
|
+
|
|
22
|
+
### Added
|
|
23
|
+
|
|
24
|
+
- 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.
|
|
25
|
+
- 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.
|
|
26
|
+
- `usage.by-project` RPC; the agent registry now records `cwd` and `project_root`.
|
|
27
|
+
- `usage.agent-lifetime` now also reports average engaged session time and prompted / multi-turn session counts.
|
|
28
|
+
- 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.
|
|
29
|
+
- 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.
|
|
30
|
+
- Providers and Projects rankings collapse to five rows with a `Show N more` / `Show less` toggle.
|
|
31
|
+
- Global chart motion: ranking bars and Daily Activity bars grow from zero and transition when the metric changes, the Activity Calendar sweeps in by week column, and the Hourly Activity plot grows from its baseline (081).
|
|
32
|
+
|
|
33
|
+
### Changed
|
|
34
|
+
|
|
35
|
+
- Requires Paseo **>= 0.9.0** (was >= 0.9.0-beta.2).
|
|
36
|
+
- 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.
|
|
37
|
+
- Global Activity says **Sessions** wherever it counts agent conversations (KPI, Insights, creations histogram, timeline, heatmap tooltip, empty state). Workspace / Agent Agents lists are unchanged.
|
|
38
|
+
- 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.
|
|
39
|
+
- Global KPI: Sessions, Prompts, Top provider · share, Top model · share. Active days, Peak weekday and Longest streak moved into Insights.
|
|
40
|
+
- User-sent messages are called **Prompts** in every Activity view; the Workspace "Show → Prompt" preview is now "Latest prompt".
|
|
41
|
+
- Most used skills / MCP / models list every item; the column is as tall as the Insights column and scrolls beyond it, resetting to the top when the list kind changes (082).
|
|
42
|
+
- The heatmap no longer shows the Daily / Weekly / Cumulative switch (always daily).
|
|
43
|
+
- Global chart titles name their granularity: Activity Calendar (heatmap), Daily Activity (30-day histogram), Hourly Activity (timeline).
|
|
44
|
+
- Activity insights put Longest streak and Peak weekday above Workspaces.
|
|
45
|
+
|
|
46
|
+
### Fixed
|
|
47
|
+
|
|
48
|
+
- 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.
|
|
49
|
+
- 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.
|
|
50
|
+
- The Global `Provider: All ▾` filter is right-aligned in the content area, and its menu opens right-aligned under the trigger.
|
|
51
|
+
- Oh My Pi (`omp`) is counted as its own provider everywhere instead of being merged into Pi; stored data is unchanged.
|
|
52
|
+
- KPI fit-to-width accounts for the tile divider, so values that just fit no longer ellipsize by a pixel.
|
|
53
|
+
- The Hourly Activity line meets cleanly at each hour with rounded joins instead of sheared border spikes (079).
|
|
54
|
+
|
|
8
55
|
## [0.6.0] - 2026-09-22
|
|
9
56
|
|
|
10
57
|
Requires Paseo **>= 0.9.0-beta.2**.
|
|
@@ -155,7 +202,9 @@ Last release that supports Paseo **0.8.0**. Later versions require Paseo **>= 0.
|
|
|
155
202
|
- Command Center entries: open panels and export a markdown usage report.
|
|
156
203
|
- Plugin renamed from `tool-usage` to `activity`, migrating the old data directory automatically.
|
|
157
204
|
|
|
158
|
-
[Unreleased]: https://github.com/koinzhang/paseo-plugins/compare/activity-v0.
|
|
205
|
+
[Unreleased]: https://github.com/koinzhang/paseo-plugins/compare/activity-v0.8.0...HEAD
|
|
206
|
+
[0.8.0]: https://github.com/koinzhang/paseo-plugins/releases/tag/activity-v0.8.0
|
|
207
|
+
[0.7.0]: https://github.com/koinzhang/paseo-plugins/releases/tag/activity-v0.7.0
|
|
159
208
|
[0.6.0]: https://github.com/koinzhang/paseo-plugins/releases/tag/activity-v0.6.0
|
|
160
209
|
[0.5.0]: https://github.com/koinzhang/paseo-plugins/releases/tag/activity-v0.5.0
|
|
161
210
|
[0.4.0]: https://github.com/koinzhang/paseo-plugins/releases/tag/activity-v0.4.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, rolling 168-hour activity timeline,
|
|
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 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
|
|
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** (or the Activity button in a workspace header; hidden while the panel is open) — 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,21 +37,27 @@ Everything lives on the daemon machine in `~/.paseo/plugin-data/activity/` (SQLi
|
|
|
37
37
|
|
|
38
38
|
## Install
|
|
39
39
|
|
|
40
|
-
Requires Paseo **>= 0.
|
|
40
|
+
Requires Paseo **>= 0.15.0**. Earlier releases keep working on older runtimes: **0.7.0** is the last release that supports Paseo 0.9–0.14, and **0.4.0** the last that supports 0.8.0.
|
|
41
41
|
|
|
42
|
-
From Git (Paseo 0.
|
|
42
|
+
From Git (Paseo 0.15 and later):
|
|
43
43
|
|
|
44
44
|
```bash
|
|
45
|
-
paseo plugin add koinzhang/paseo-plugins
|
|
45
|
+
paseo plugin add github:koinzhang/paseo-plugins:activity
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
-
From npm (Paseo 0.
|
|
48
|
+
From npm (Paseo 0.15 and later; this is the source paseo.cafe hands to Paseo). Pin `0.7.0` on Paseo 0.9–0.14, or `0.4.0` on Paseo 0.8:
|
|
49
49
|
|
|
50
50
|
```bash
|
|
51
51
|
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.7.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,11 +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
6
|
import { useMeasuredWidth } from "./measured-width.ts";
|
|
7
7
|
import { ACTIVITY_MIX_STEPS, mixColor } from "./color-mix.ts";
|
|
8
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";
|
|
9
12
|
|
|
10
13
|
type ThemeColors = {
|
|
11
14
|
accent: string; border: string; foreground: string; foregroundMuted: string;
|
|
@@ -14,13 +17,8 @@ type ThemeColors = {
|
|
|
14
17
|
|
|
15
18
|
type HoveredMonth = { year: number; month: number };
|
|
16
19
|
|
|
17
|
-
// Month-axis labels
|
|
18
|
-
|
|
19
|
-
const LABEL_FONT_SIZE = 12;
|
|
20
|
-
|
|
21
|
-
function plural(count: number, singular: string, pluralForm = `${singular}s`): string {
|
|
22
|
-
return `${count.toLocaleString()} ${count === 1 ? singular : pluralForm}`;
|
|
23
|
-
}
|
|
20
|
+
// Month-axis labels stay at the secondary label size under the section title.
|
|
21
|
+
const LABEL_FONT_SIZE = FONT_SIZE.label;
|
|
24
22
|
|
|
25
23
|
function cellInMonth(dateKey: string, hovered: HoveredMonth | null): boolean {
|
|
26
24
|
if (!hovered) return false;
|
|
@@ -28,16 +26,15 @@ function cellInMonth(dateKey: string, hovered: HoveredMonth | null): boolean {
|
|
|
28
26
|
return year === hovered.year && month === hovered.month + 1;
|
|
29
27
|
}
|
|
30
28
|
|
|
31
|
-
export function ActivityHeatmap({ days, from, colors, compact, mode
|
|
29
|
+
export function ActivityHeatmap({ days, from, colors, compact, mode }: {
|
|
32
30
|
days: readonly ActivityDay[]; from?: string; colors: ThemeColors; compact?: boolean;
|
|
33
|
-
mode: HeatmapMode;
|
|
34
|
-
modeOptions: ReadonlyArray<{ id: HeatmapMode; label: string }>;
|
|
31
|
+
mode: HeatmapMode;
|
|
35
32
|
}) {
|
|
33
|
+
const [metric, setMetric] = useState<ActivityMetric>("sessions");
|
|
36
34
|
const locale = useAppLanguage();
|
|
37
35
|
const [width, widthRef, onWidthLayout] = useMeasuredWidth("global:heatmap");
|
|
38
36
|
const [gridTop, setGridTop] = useState(0);
|
|
39
37
|
const [scrollX, setScrollX] = useState(0);
|
|
40
|
-
const [tooltipSize, setTooltipSize] = useState({ width: 220, height: 28 });
|
|
41
38
|
const [selected, setSelected] = useState<string | null>(null);
|
|
42
39
|
const [hovered, setHovered] = useState<string | null>(null);
|
|
43
40
|
const [hoveredMonth, setHoveredMonth] = useState<HoveredMonth | null>(null);
|
|
@@ -46,7 +43,34 @@ export function ActivityHeatmap({ days, from, colors, compact, mode, onModeChang
|
|
|
46
43
|
setHovered(null);
|
|
47
44
|
setHoveredMonth(null);
|
|
48
45
|
}, [from, mode, days]);
|
|
49
|
-
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: true,
|
|
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
|
+
);
|
|
50
74
|
const gap = compact ? 2 : 3;
|
|
51
75
|
// Fit the full year into the measured width (no min floor — avoid horizontal overflow).
|
|
52
76
|
const cellSize =
|
|
@@ -61,36 +85,36 @@ export function ActivityHeatmap({ days, from, colors, compact, mode, onModeChang
|
|
|
61
85
|
const active = activeIndex >= 0 ? weeks.flat()[activeIndex] : undefined;
|
|
62
86
|
const anchorX = Math.floor(activeIndex / 7) * (cellSize + gap) + cellSize / 2 - scrollX;
|
|
63
87
|
const anchorY = gridTop + (activeIndex % 7) * (cellSize + gap);
|
|
64
|
-
const tooltipLeft = Math.max(0, Math.min(anchorX - tooltipSize.width / 2, width - tooltipSize.width));
|
|
65
|
-
const tooltipTop = Math.max(0, anchorY - tooltipSize.height - 8);
|
|
66
88
|
const dateLabel = active ? (() => {
|
|
67
89
|
const [year, month, day] = active.key.split("-").map(Number);
|
|
68
90
|
return new Date(year!, month! - 1, day!).toLocaleDateString(locale, {
|
|
69
91
|
month: "short", day: "numeric", year: year !== new Date().getFullYear() ? "numeric" : undefined,
|
|
70
92
|
});
|
|
71
93
|
})() : "";
|
|
72
|
-
const
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
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;
|
|
76
107
|
const axisWidth = needsScroll ? gridWidth : width;
|
|
77
|
-
const modeLabel = mode === "weekly" ? "Week containing" : mode === "cumulative" ? "Through" : "";
|
|
78
108
|
const monthFocus = hoveredMonth != null;
|
|
79
109
|
return (
|
|
80
110
|
<View
|
|
81
111
|
ref={widthRef}
|
|
82
|
-
style={{ gap: compact
|
|
112
|
+
style={{ gap: titleGap(compact) }}
|
|
83
113
|
onLayout={onWidthLayout}
|
|
84
114
|
>
|
|
85
115
|
<View style={{ flexDirection: "row", flexWrap: "wrap", alignItems: "center", justifyContent: "space-between", gap: 12 }}>
|
|
86
|
-
<Text style={{ color: colors.foreground
|
|
87
|
-
<
|
|
88
|
-
{modeOptions.map(option => (
|
|
89
|
-
<Pressable key={option.id} accessibilityRole="tab" accessibilityState={{ selected: mode === option.id }} onPress={() => onModeChange(option.id)} style={{ paddingVertical: 6 }}>
|
|
90
|
-
<Text style={{ color: mode === option.id ? colors.foreground : colors.foregroundMuted, fontSize: LABEL_FONT_SIZE }}>{option.label}</Text>
|
|
91
|
-
</Pressable>
|
|
92
|
-
))}
|
|
93
|
-
</View>
|
|
116
|
+
<Text style={{ ...sectionTitle(compact), color: colors.foreground }}>{m.heatmap.title}</Text>
|
|
117
|
+
<MetricStepper value={metric} onChange={setMetric} colors={colors} />
|
|
94
118
|
</View>
|
|
95
119
|
<ScrollView
|
|
96
120
|
horizontal
|
|
@@ -102,44 +126,63 @@ export function ActivityHeatmap({ days, from, colors, compact, mode, onModeChang
|
|
|
102
126
|
>
|
|
103
127
|
<View style={{ width: Math.max(0, axisWidth) }}>
|
|
104
128
|
<View style={{ flexDirection: "row", gap }}>
|
|
105
|
-
{weeks.map((week, i) =>
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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 }) => (
|
|
126
155
|
<Pressable key={cell.key} disabled={hidden} accessibilityRole="button"
|
|
127
|
-
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)}`}
|
|
128
157
|
accessibilityState={{ selected: activeKey === cell.key }}
|
|
129
158
|
onHoverIn={() => setHovered(cell.key)} onHoverOut={() => setHovered(null)}
|
|
130
159
|
onFocus={() => setHovered(cell.key)} onBlur={() => setHovered(null)}
|
|
131
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"
|
|
132
166
|
style={{
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
opacity
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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
|
+
})}
|
|
143
186
|
</View>
|
|
144
187
|
<View style={{ marginTop: 10, flexDirection: "row", justifyContent: "space-between" }}>
|
|
145
188
|
{months.map((item, i) => {
|
|
@@ -149,7 +192,7 @@ export function ActivityHeatmap({ days, from, colors, compact, mode, onModeChang
|
|
|
149
192
|
<Pressable
|
|
150
193
|
key={`${item.year}-${item.month}-${i}`}
|
|
151
194
|
accessibilityRole="button"
|
|
152
|
-
accessibilityLabel={
|
|
195
|
+
accessibilityLabel={m.heatmap.highlightMonth(item.label)}
|
|
153
196
|
onHoverIn={() => setHoveredMonth({ year: item.year, month: item.month })}
|
|
154
197
|
onHoverOut={() => setHoveredMonth(null)}
|
|
155
198
|
onFocus={() => setHoveredMonth({ year: item.year, month: item.month })}
|
|
@@ -172,16 +215,14 @@ export function ActivityHeatmap({ days, from, colors, compact, mode, onModeChang
|
|
|
172
215
|
</View>
|
|
173
216
|
</ScrollView>
|
|
174
217
|
{active && anchorX >= 0 && anchorX <= width ? (
|
|
175
|
-
<
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
</Text>
|
|
184
|
-
</View>
|
|
218
|
+
<ChartTooltip
|
|
219
|
+
anchorX={anchorX}
|
|
220
|
+
anchorY={anchorY}
|
|
221
|
+
containerWidth={width}
|
|
222
|
+
title={periodLabel(dateLabel)}
|
|
223
|
+
rows={tooltipRows}
|
|
224
|
+
colors={colors}
|
|
225
|
+
/>
|
|
185
226
|
) : null}
|
|
186
227
|
</View>
|
|
187
228
|
);
|