@koinzhang/paseo-plugin-activity 0.6.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 +35 -1
- package/README.md +14 -7
- package/client/activity-heatmap.tsx +115 -74
- package/client/agent-creations.tsx +97 -88
- package/client/attention-pill.tsx +16 -5
- package/client/attention-popover.tsx +19 -23
- package/client/design-tokens.test.ts +39 -0
- package/client/design-tokens.ts +168 -0
- package/client/formatted-time.tsx +4 -4
- package/client/global-surface.tsx +236 -268
- package/client/header-button.ts +136 -0
- package/client/hourly-activity-timeline.tsx +136 -103
- 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/rank-color.ts +3 -3
- 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 +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 +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 +89 -103
- package/client/workspace/rank-section.tsx +36 -62
- package/client/workspace/terminals-section.tsx +13 -9
- package/index.client.tsx +40 -20
- package/index.server.ts +53 -51
- package/package.json +2 -2
- 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/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 +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 +124 -63
- package/shared/usage.test.ts +121 -0
- package/shared/usage.ts +191 -2
|
@@ -1,16 +1,23 @@
|
|
|
1
|
-
import { useEffect, useMemo, useState } from "react";
|
|
2
|
-
import { Pressable, Text, View } from "react-native";
|
|
1
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { Animated, Easing, Pressable, Text, View } from "react-native";
|
|
3
3
|
import {
|
|
4
4
|
buildAgentCreationBuckets,
|
|
5
|
+
buildDailyMetricBuckets,
|
|
5
6
|
rankCreationProviders,
|
|
6
7
|
stackCreationProviders,
|
|
7
8
|
type CreationBucket,
|
|
9
|
+
type ActivityMetric,
|
|
8
10
|
type CreationProviderSlice,
|
|
9
11
|
} from "../shared/activity.ts";
|
|
10
|
-
import type { AgentCreationDay } from "../shared/usage.ts";
|
|
12
|
+
import type { ActivityDay, AgentCreationDay } from "../shared/usage.ts";
|
|
11
13
|
import { creationBarColor } from "./color-mix.ts";
|
|
12
14
|
import { chartColorScheme, creationProviderColors } from "./rank-color.ts";
|
|
13
15
|
import { fixedWindowFrom } from "./range.ts";
|
|
16
|
+
import { CHART_MOTION, RADIUS, TEXT, sectionTitle, titleGap } from "./design-tokens.ts";
|
|
17
|
+
import { messagesFor } from "../shared/i18n.ts";
|
|
18
|
+
import { ChartTooltip, InlineEmpty, MetricStepper } from "./ui.tsx";
|
|
19
|
+
|
|
20
|
+
const EMPTY_BAR_HEIGHT = 2;
|
|
14
21
|
|
|
15
22
|
type ThemeColors = {
|
|
16
23
|
accent: string;
|
|
@@ -31,39 +38,40 @@ function dayLabel(key: string, locale: string): string {
|
|
|
31
38
|
return bucketDate(key).toLocaleDateString(locale, { month: "short", day: "numeric" });
|
|
32
39
|
}
|
|
33
40
|
|
|
34
|
-
function agentCountText(count: number): string {
|
|
35
|
-
return `${count} ${count === 1 ? "agent" : "agents"}`;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
41
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* (nonzero that day only, 056)
|
|
42
|
+
* Daily bars over a fixed window (051 / 057): the last `windowDays` days
|
|
43
|
+
* ending today. Each day is one accent-intensity bar (057). The header switch
|
|
44
|
+
* (070) picks the metric; Sessions hovers show a provider breakdown card
|
|
45
|
+
* (nonzero that day only, 056), other metrics come from `activityDays` and
|
|
46
|
+
* show the day total only.
|
|
43
47
|
*/
|
|
44
|
-
export function AgentCreations({ days, windowDays, colors, compact, locale }: {
|
|
48
|
+
export function AgentCreations({ days, activityDays, windowDays, colors, compact, locale }: {
|
|
45
49
|
days: readonly AgentCreationDay[];
|
|
50
|
+
activityDays: readonly ActivityDay[];
|
|
46
51
|
windowDays: number;
|
|
47
52
|
colors: ThemeColors;
|
|
48
53
|
compact?: boolean;
|
|
49
54
|
locale: string;
|
|
50
55
|
}) {
|
|
56
|
+
const [metric, setMetric] = useState<ActivityMetric>("sessions");
|
|
51
57
|
const from = fixedWindowFrom(windowDays);
|
|
52
58
|
const buckets = useMemo(
|
|
53
|
-
() =>
|
|
54
|
-
|
|
59
|
+
() =>
|
|
60
|
+
metric === "sessions"
|
|
61
|
+
? buildAgentCreationBuckets(days, { from })
|
|
62
|
+
: buildDailyMetricBuckets(activityDays, metric, { from }),
|
|
63
|
+
[days, activityDays, metric, from],
|
|
55
64
|
);
|
|
56
65
|
const providers = useMemo(() => rankCreationProviders(buckets), [buckets]);
|
|
57
66
|
const [hovered, setHovered] = useState<string | null>(null);
|
|
58
67
|
const [selected, setSelected] = useState<string | null>(null);
|
|
59
68
|
const [width, setWidth] = useState(0);
|
|
60
|
-
const [tooltipSize, setTooltipSize] = useState({ width: 150, height: 0 });
|
|
61
69
|
useEffect(() => {
|
|
62
70
|
setHovered(null);
|
|
63
71
|
setSelected(null);
|
|
64
72
|
// Only the window start invalidates the selection: refetching the same
|
|
65
73
|
// window must not close a tooltip the pointer is resting on (051).
|
|
66
|
-
}, [from]);
|
|
74
|
+
}, [from, metric]);
|
|
67
75
|
|
|
68
76
|
const activeKey = hovered ?? selected;
|
|
69
77
|
const total = buckets.reduce((sum, bucket) => sum + bucket.count, 0);
|
|
@@ -74,7 +82,6 @@ export function AgentCreations({ days, windowDays, colors, compact, locale }: {
|
|
|
74
82
|
const gap = compact ? 2 : 3;
|
|
75
83
|
const slot = buckets.length > 0 ? (width + gap) / buckets.length : 0;
|
|
76
84
|
const anchorX = activeIndex >= 0 ? activeIndex * slot + (slot - gap) / 2 : 0;
|
|
77
|
-
const tooltipLeft = Math.max(0, Math.min(anchorX - tooltipSize.width / 2, width - tooltipSize.width));
|
|
78
85
|
const scheme = chartColorScheme(colors.surface0);
|
|
79
86
|
const colorByProvider = creationProviderColors(
|
|
80
87
|
providers.map((item) => item.provider),
|
|
@@ -84,17 +91,27 @@ export function AgentCreations({ days, windowDays, colors, compact, locale }: {
|
|
|
84
91
|
? stackCreationProviders(providers, active.providers)
|
|
85
92
|
: [];
|
|
86
93
|
const first = buckets[0];
|
|
94
|
+
const m = messagesFor(locale);
|
|
95
|
+
const unit = (count: number) =>
|
|
96
|
+
metric === "sessions"
|
|
97
|
+
? m.units.sessions(count)
|
|
98
|
+
: metric === "prompts"
|
|
99
|
+
? m.units.prompts(count)
|
|
100
|
+
: metric === "skills"
|
|
101
|
+
? m.units.skills(count)
|
|
102
|
+
: m.units.mcp(count);
|
|
87
103
|
|
|
88
104
|
return (
|
|
89
|
-
<View style={{ gap: compact
|
|
90
|
-
<
|
|
91
|
-
|
|
92
|
-
|
|
105
|
+
<View style={{ gap: titleGap(compact) }}>
|
|
106
|
+
<View style={{ flexDirection: "row", alignItems: "center", justifyContent: "space-between", gap: 12 }}>
|
|
107
|
+
<Text style={{ ...sectionTitle(compact), color: colors.foreground }}>
|
|
108
|
+
{m.creations.title}
|
|
109
|
+
</Text>
|
|
110
|
+
<MetricStepper value={metric} onChange={setMetric} colors={colors} />
|
|
111
|
+
</View>
|
|
93
112
|
|
|
94
113
|
{total === 0 ? (
|
|
95
|
-
<
|
|
96
|
-
No agents created in the last {windowDays} days
|
|
97
|
-
</Text>
|
|
114
|
+
<InlineEmpty text={m.creations.empty(windowDays)} color={colors.foregroundMuted} />
|
|
98
115
|
) : (
|
|
99
116
|
<View style={{ gap: 6 }}>
|
|
100
117
|
<View style={{ position: "relative" }} onLayout={(event) => setWidth(event.nativeEvent.layout.width)}>
|
|
@@ -103,7 +120,7 @@ export function AgentCreations({ days, windowDays, colors, compact, locale }: {
|
|
|
103
120
|
<Pressable
|
|
104
121
|
key={bucket.key}
|
|
105
122
|
accessibilityRole="button"
|
|
106
|
-
accessibilityLabel={`${dayLabel(bucket.key, locale)}: ${
|
|
123
|
+
accessibilityLabel={`${dayLabel(bucket.key, locale)}: ${unit(bucket.count)}${providerBreakdown(bucket, providers)}`}
|
|
107
124
|
accessibilityState={{ selected: activeKey === bucket.key }}
|
|
108
125
|
onHoverIn={() => setHovered(bucket.key)}
|
|
109
126
|
onHoverOut={() => setHovered(null)}
|
|
@@ -117,78 +134,43 @@ export function AgentCreations({ days, windowDays, colors, compact, locale }: {
|
|
|
117
134
|
justifyContent: "flex-end",
|
|
118
135
|
}}
|
|
119
136
|
>
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
borderTopRightRadius: 3,
|
|
134
|
-
}}
|
|
135
|
-
/>
|
|
136
|
-
)}
|
|
137
|
+
<DayBar
|
|
138
|
+
height={
|
|
139
|
+
bucket.count > 0 && max > 0
|
|
140
|
+
? Math.max(EMPTY_BAR_HEIGHT, Math.round((bucket.count / max) * chartHeight))
|
|
141
|
+
: EMPTY_BAR_HEIGHT
|
|
142
|
+
}
|
|
143
|
+
color={
|
|
144
|
+
bucket.count === 0
|
|
145
|
+
? colors.surface2
|
|
146
|
+
: creationBarColor(bucket.count, max, colors.surface2, colors.accent)
|
|
147
|
+
}
|
|
148
|
+
rounded={bucket.count > 0}
|
|
149
|
+
/>
|
|
137
150
|
</Pressable>
|
|
138
151
|
))}
|
|
139
152
|
</View>
|
|
140
153
|
{active && width > 0 ? (
|
|
141
|
-
<
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
paddingHorizontal: 12,
|
|
155
|
-
paddingVertical: 8,
|
|
156
|
-
borderRadius: 10,
|
|
157
|
-
backgroundColor: colors.surface2,
|
|
158
|
-
borderWidth: 1,
|
|
159
|
-
borderColor: colors.border,
|
|
160
|
-
gap: 4,
|
|
161
|
-
}}
|
|
162
|
-
>
|
|
163
|
-
{tooltipProviders.map((item) => (
|
|
164
|
-
<View key={item.provider} style={{ flexDirection: "row", alignItems: "center", gap: 8 }}>
|
|
165
|
-
<View
|
|
166
|
-
style={{
|
|
167
|
-
width: 10,
|
|
168
|
-
height: 10,
|
|
169
|
-
borderRadius: 3,
|
|
170
|
-
backgroundColor: colorByProvider.get(item.provider) ?? colors.accent,
|
|
171
|
-
}}
|
|
172
|
-
/>
|
|
173
|
-
<Text style={{ color: colors.foreground, fontSize: 13 }}>
|
|
174
|
-
{item.label}: {item.count}
|
|
175
|
-
</Text>
|
|
176
|
-
</View>
|
|
177
|
-
))}
|
|
178
|
-
<Text
|
|
179
|
-
accessibilityLiveRegion="polite"
|
|
180
|
-
style={{ color: colors.foregroundMuted, fontSize: 12, marginTop: 2 }}
|
|
181
|
-
>
|
|
182
|
-
{dayLabel(active.key, locale)}
|
|
183
|
-
</Text>
|
|
184
|
-
</View>
|
|
154
|
+
<ChartTooltip
|
|
155
|
+
anchorX={anchorX}
|
|
156
|
+
anchorY={0}
|
|
157
|
+
containerWidth={width}
|
|
158
|
+
clampTop={false}
|
|
159
|
+
title={`${dayLabel(active.key, locale)} · ${unit(active.count)}`}
|
|
160
|
+
rows={tooltipProviders.map((item) => ({
|
|
161
|
+
label: item.label,
|
|
162
|
+
value: item.count.toLocaleString(locale),
|
|
163
|
+
color: colorByProvider.get(item.provider) ?? colors.accent,
|
|
164
|
+
}))}
|
|
165
|
+
colors={colors}
|
|
166
|
+
/>
|
|
185
167
|
) : null}
|
|
186
168
|
</View>
|
|
187
169
|
<View style={{ flexDirection: "row", justifyContent: "space-between" }}>
|
|
188
|
-
<Text style={{ color: colors.foregroundMuted
|
|
170
|
+
<Text style={{ ...TEXT.meta, color: colors.foregroundMuted }}>
|
|
189
171
|
{first ? dayLabel(first.key, locale) : ""}
|
|
190
172
|
</Text>
|
|
191
|
-
<Text style={{ color: colors.foregroundMuted
|
|
173
|
+
<Text style={{ ...TEXT.meta, color: colors.foregroundMuted }}>{m.common.today}</Text>
|
|
192
174
|
</View>
|
|
193
175
|
</View>
|
|
194
176
|
)}
|
|
@@ -196,6 +178,33 @@ export function AgentCreations({ days, windowDays, colors, compact, locale }: {
|
|
|
196
178
|
);
|
|
197
179
|
}
|
|
198
180
|
|
|
181
|
+
/** Day column that grows from 0 on mount and animates between heights on change. */
|
|
182
|
+
function DayBar({ height, color, rounded }: { height: number; color: string; rounded: boolean }) {
|
|
183
|
+
const progress = useRef(new Animated.Value(0)).current;
|
|
184
|
+
|
|
185
|
+
useEffect(() => {
|
|
186
|
+
const animation = Animated.timing(progress, {
|
|
187
|
+
toValue: height,
|
|
188
|
+
duration: CHART_MOTION.grow,
|
|
189
|
+
easing: Easing.out(Easing.cubic),
|
|
190
|
+
useNativeDriver: false,
|
|
191
|
+
});
|
|
192
|
+
animation.start();
|
|
193
|
+
return () => animation.stop();
|
|
194
|
+
}, [height, progress]);
|
|
195
|
+
|
|
196
|
+
return (
|
|
197
|
+
<Animated.View
|
|
198
|
+
style={{
|
|
199
|
+
height: progress,
|
|
200
|
+
backgroundColor: color,
|
|
201
|
+
borderTopLeftRadius: rounded ? RADIUS.swatch : 0,
|
|
202
|
+
borderTopRightRadius: rounded ? RADIUS.swatch : 0,
|
|
203
|
+
}}
|
|
204
|
+
/>
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
|
|
199
208
|
function providerBreakdown(
|
|
200
209
|
bucket: CreationBucket,
|
|
201
210
|
ranked: readonly CreationProviderSlice[],
|
|
@@ -12,6 +12,8 @@ import {
|
|
|
12
12
|
type AttentionAgentItem,
|
|
13
13
|
} from "./attention-agents.ts";
|
|
14
14
|
import { AttentionPopover } from "./attention-popover.tsx";
|
|
15
|
+
import { messagesFor } from "../shared/i18n.ts";
|
|
16
|
+
import { currentAppLanguage, watchAppLanguage } from "./use-app-language.ts";
|
|
15
17
|
import {
|
|
16
18
|
clearAttentionStatuses,
|
|
17
19
|
getAttentionStatuses,
|
|
@@ -22,7 +24,7 @@ import { watchAgentDirectory } from "./agent-directory.ts";
|
|
|
22
24
|
import { agentStatusInfo } from "./workspace/list-host-agents.ts";
|
|
23
25
|
import type { AgentStatusInfo } from "./workspace/constants.ts";
|
|
24
26
|
|
|
25
|
-
const
|
|
27
|
+
const attentionTitle = () => messagesFor(currentAppLanguage()).attention.title;
|
|
26
28
|
const PILL_ID = "attention";
|
|
27
29
|
|
|
28
30
|
type PillEntry = {
|
|
@@ -56,7 +58,7 @@ export function contributeAttentionPills(client: PluginClientContext): () => voi
|
|
|
56
58
|
entry.signature = signature;
|
|
57
59
|
|
|
58
60
|
if (items.length === 0) {
|
|
59
|
-
pill.update({ visible: false, label:
|
|
61
|
+
pill.update({ visible: false, label: attentionTitle(), disabled: false });
|
|
60
62
|
return;
|
|
61
63
|
}
|
|
62
64
|
|
|
@@ -64,7 +66,7 @@ export function contributeAttentionPills(client: PluginClientContext): () => voi
|
|
|
64
66
|
pill.update({
|
|
65
67
|
visible: true,
|
|
66
68
|
label: String(items.length),
|
|
67
|
-
title:
|
|
69
|
+
title: attentionTitle(),
|
|
68
70
|
disabled: false,
|
|
69
71
|
behavior: {
|
|
70
72
|
kind: "popover",
|
|
@@ -115,8 +117,8 @@ export function contributeAttentionPills(client: PluginClientContext): () => voi
|
|
|
115
117
|
workspaceId,
|
|
116
118
|
agentId,
|
|
117
119
|
button: {
|
|
118
|
-
title:
|
|
119
|
-
label:
|
|
120
|
+
title: attentionTitle(),
|
|
121
|
+
label: attentionTitle(),
|
|
120
122
|
visible: false,
|
|
121
123
|
icon: createPillIcon(agentId),
|
|
122
124
|
behavior: {
|
|
@@ -154,7 +156,16 @@ export function contributeAttentionPills(client: PluginClientContext): () => voi
|
|
|
154
156
|
for (const [workspaceId, statuses] of workspaces) applyWorkspace(workspaceId, statuses);
|
|
155
157
|
});
|
|
156
158
|
|
|
159
|
+
const stopLanguage = watchAppLanguage(() => {
|
|
160
|
+
for (const [agentId, entry] of pills) {
|
|
161
|
+
entry.signature = "";
|
|
162
|
+
const cached = getAttentionStatuses(entry.workspaceId);
|
|
163
|
+
if (cached) applyPill(agentId, entry, cached);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
|
|
157
167
|
return () => {
|
|
168
|
+
stopLanguage();
|
|
158
169
|
stopDirectory();
|
|
159
170
|
pills.forEach((entry) => entry.registration?.remove());
|
|
160
171
|
pills.clear();
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
useAgent,
|
|
4
4
|
} from "@getpaseo/plugin/client";
|
|
5
5
|
import { useEffect, useMemo, type ReactNode } from "react";
|
|
6
|
-
import {
|
|
6
|
+
import { View, type TextStyle, type ViewStyle } from "react-native";
|
|
7
7
|
import {
|
|
8
8
|
filterAttentionAgents,
|
|
9
9
|
type AttentionAgentItem,
|
|
@@ -12,6 +12,9 @@ import { openAttentionAgent } from "./open-agent.ts";
|
|
|
12
12
|
import { useLatestUserMessagePreview } from "./use-latest-user-message.ts";
|
|
13
13
|
import { useAttentionStatuses } from "./attention-status-store.ts";
|
|
14
14
|
import { AgentRow, type AgentRowStyles } from "./workspace/agent-row.tsx";
|
|
15
|
+
import { CONTROL, ICON_SIZE, ROW_PADDING, TEXT, pillRadius, popoverFrame } from "./design-tokens.ts";
|
|
16
|
+
import { useMessages } from "./use-app-language.ts";
|
|
17
|
+
import { InlineEmpty } from "./ui.tsx";
|
|
15
18
|
|
|
16
19
|
function AttentionRow({
|
|
17
20
|
item,
|
|
@@ -56,12 +59,9 @@ function AttentionRow({
|
|
|
56
59
|
|
|
57
60
|
/** Popover body: other agents in this workspace that need attention. */
|
|
58
61
|
export function AttentionPopover(props: PluginButtonContentProps) {
|
|
62
|
+
const m = useMessages();
|
|
59
63
|
if (props.context !== "agent") {
|
|
60
|
-
return
|
|
61
|
-
<Text style={{ color: props.theme.colors.foregroundMuted }}>
|
|
62
|
-
Attention is only available for an agent
|
|
63
|
-
</Text>
|
|
64
|
-
);
|
|
64
|
+
return <InlineEmpty text={m.attention.agentOnly} color={props.theme.colors.foregroundMuted} />;
|
|
65
65
|
}
|
|
66
66
|
return <AttentionPopoverAgent {...props} context="agent" />;
|
|
67
67
|
}
|
|
@@ -69,7 +69,8 @@ export function AttentionPopover(props: PluginButtonContentProps) {
|
|
|
69
69
|
function AttentionPopoverAgent(
|
|
70
70
|
props: PluginButtonContentProps & { context: "agent" },
|
|
71
71
|
) {
|
|
72
|
-
const { theme, workspaceId, agentId, close } = props;
|
|
72
|
+
const { theme, layout, workspaceId, agentId, close } = props;
|
|
73
|
+
const m = useMessages();
|
|
73
74
|
const statuses = useAttentionStatuses(workspaceId);
|
|
74
75
|
const items = useMemo(
|
|
75
76
|
() => filterAttentionAgents(statuses, agentId),
|
|
@@ -81,18 +82,17 @@ function AttentionPopoverAgent(
|
|
|
81
82
|
flexDirection: "row",
|
|
82
83
|
alignItems: "center",
|
|
83
84
|
gap: 10,
|
|
84
|
-
paddingVertical:
|
|
85
|
+
paddingVertical: ROW_PADDING.dense,
|
|
85
86
|
};
|
|
86
87
|
const title: TextStyle = {
|
|
88
|
+
...TEXT.rowTitle,
|
|
87
89
|
color: theme.colors.foreground,
|
|
88
|
-
fontSize: 14,
|
|
89
|
-
fontWeight: "500",
|
|
90
90
|
};
|
|
91
91
|
return {
|
|
92
92
|
agentListRow: row,
|
|
93
93
|
agentIconWrap: {
|
|
94
|
-
width:
|
|
95
|
-
height:
|
|
94
|
+
width: ICON_SIZE.leading,
|
|
95
|
+
height: ICON_SIZE.leading,
|
|
96
96
|
alignItems: "center",
|
|
97
97
|
justifyContent: "center",
|
|
98
98
|
} satisfies ViewStyle,
|
|
@@ -103,47 +103,43 @@ function AttentionPopoverAgent(
|
|
|
103
103
|
listLink: title,
|
|
104
104
|
listTitle: title,
|
|
105
105
|
listMeta: {
|
|
106
|
+
...TEXT.meta,
|
|
106
107
|
color: theme.colors.foregroundMuted,
|
|
107
|
-
fontSize: 12,
|
|
108
108
|
} satisfies TextStyle,
|
|
109
109
|
titleAction: { width: 0, height: 0 } satisfies ViewStyle,
|
|
110
110
|
permissionBadge: {
|
|
111
111
|
flexDirection: "row",
|
|
112
112
|
alignItems: "center",
|
|
113
113
|
gap: 3,
|
|
114
|
-
height:
|
|
114
|
+
height: CONTROL.pillBadgeHeight,
|
|
115
115
|
paddingHorizontal: 5,
|
|
116
|
-
borderRadius:
|
|
116
|
+
borderRadius: pillRadius(CONTROL.pillBadgeHeight),
|
|
117
117
|
borderWidth: 1,
|
|
118
118
|
borderColor: theme.colors.border,
|
|
119
119
|
backgroundColor: theme.colors.surface1,
|
|
120
120
|
flexShrink: 0,
|
|
121
121
|
} satisfies ViewStyle,
|
|
122
122
|
permissionBadgeText: {
|
|
123
|
+
...TEXT.pillBadge,
|
|
123
124
|
color: theme.colors.statusWarning,
|
|
124
|
-
fontSize: 11,
|
|
125
|
-
fontWeight: "600",
|
|
126
|
-
fontVariant: ["tabular-nums"],
|
|
127
125
|
} satisfies TextStyle,
|
|
128
126
|
} satisfies AgentRowStyles;
|
|
129
127
|
}, [theme]);
|
|
130
128
|
|
|
131
129
|
if (!statuses) {
|
|
132
130
|
return (
|
|
133
|
-
<
|
|
131
|
+
<InlineEmpty text={m.common.loading} color={theme.colors.foregroundMuted} />
|
|
134
132
|
);
|
|
135
133
|
}
|
|
136
134
|
|
|
137
135
|
if (items.length === 0) {
|
|
138
136
|
return (
|
|
139
|
-
<
|
|
140
|
-
No other agents need attention
|
|
141
|
-
</Text>
|
|
137
|
+
<InlineEmpty text={m.attention.empty} color={theme.colors.foregroundMuted} />
|
|
142
138
|
);
|
|
143
139
|
}
|
|
144
140
|
|
|
145
141
|
return (
|
|
146
|
-
<View style={{ gap: 2,
|
|
142
|
+
<View style={{ gap: 2, ...popoverFrame(layout.compact) }}>
|
|
147
143
|
{items.map((item) => (
|
|
148
144
|
<AttentionRow
|
|
149
145
|
key={item.agentId}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { readdirSync, readFileSync } from "node:fs";
|
|
3
|
+
import { join, relative } from "node:path";
|
|
4
|
+
import { test } from "node:test";
|
|
5
|
+
|
|
6
|
+
const CLIENT_DIR = new URL(".", import.meta.url).pathname;
|
|
7
|
+
|
|
8
|
+
const RULES: ReadonlyArray<{ name: string; pattern: RegExp }> = [
|
|
9
|
+
{ name: "fontSize literal", pattern: /fontSize:\s*[0-9]/ },
|
|
10
|
+
{ name: "fontWeight literal", pattern: /fontWeight:\s*["'][0-9a-z]+["']/ },
|
|
11
|
+
{ name: "border radius literal", pattern: /[bB]order\w*Radius:\s*[0-9]/ },
|
|
12
|
+
{ name: "Icon size literal", pattern: /<Icon\b[^>]*\bsize=\{[0-9]/ },
|
|
13
|
+
{ name: "multi-line Icon size literal", pattern: /^\s*size=\{[0-9]+\}\s*$/ },
|
|
14
|
+
{ name: "hitSlop literal", pattern: /hitSlop=\{[0-9]/ },
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
function tsxFiles(dir: string): string[] {
|
|
18
|
+
return readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {
|
|
19
|
+
const path = join(dir, entry.name);
|
|
20
|
+
if (entry.isDirectory()) return tsxFiles(path);
|
|
21
|
+
return entry.name.endsWith(".tsx") ? [path] : [];
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
test("client UI uses design tokens instead of raw type / radius / icon literals (065)", () => {
|
|
26
|
+
const violations: string[] = [];
|
|
27
|
+
for (const file of tsxFiles(CLIENT_DIR)) {
|
|
28
|
+
readFileSync(file, "utf8")
|
|
29
|
+
.split("\n")
|
|
30
|
+
.forEach((line, index) => {
|
|
31
|
+
for (const rule of RULES) {
|
|
32
|
+
if (rule.pattern.test(line)) {
|
|
33
|
+
violations.push(`${relative(CLIENT_DIR, file)}:${index + 1} ${rule.name}: ${line.trim()}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
assert.deepEqual(violations, [], "use client/design-tokens.ts (see docs/design-system.md)");
|
|
39
|
+
});
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { Platform, type TextStyle, type ViewStyle } from "react-native";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Activity design tokens (065). The host only supplies `theme.colors` and
|
|
5
|
+
* `layout.compact`; type scale, spacing, radii and sizes live here so the
|
|
6
|
+
* Global / Workspace / Agent scopes and the composer popovers share one
|
|
7
|
+
* visual language. Rules and rationale: `docs/design-system.md`.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export const MONO = Platform.select({ ios: "Menlo", default: "monospace" });
|
|
11
|
+
|
|
12
|
+
export const FONT_SIZE = {
|
|
13
|
+
/** Icon corner counters. */
|
|
14
|
+
badge: 9,
|
|
15
|
+
/** Pill badges, dense chart ticks, terminal output. */
|
|
16
|
+
caption: 11,
|
|
17
|
+
/** Row meta, axis labels, legends, tooltips, in-chart tabs. */
|
|
18
|
+
label: 12,
|
|
19
|
+
/** Inline empty / error / loading, row counts, search input, code body. */
|
|
20
|
+
small: 13,
|
|
21
|
+
/** Row titles, insights / rank rows, filter tabs, menu items. */
|
|
22
|
+
body: 14,
|
|
23
|
+
/** Section title (regular); compact uses `body`. */
|
|
24
|
+
title: 15,
|
|
25
|
+
/** KPI value (FitText base, shrinks to fit). */
|
|
26
|
+
metric: 18,
|
|
27
|
+
/** Full-page empty state title. */
|
|
28
|
+
display: 19,
|
|
29
|
+
} as const;
|
|
30
|
+
|
|
31
|
+
export const FONT_WEIGHT = {
|
|
32
|
+
regular: "normal",
|
|
33
|
+
medium: "500",
|
|
34
|
+
semibold: "600",
|
|
35
|
+
bold: "700",
|
|
36
|
+
} as const satisfies Record<string, TextStyle["fontWeight"]>;
|
|
37
|
+
|
|
38
|
+
const TABULAR: TextStyle["fontVariant"] = ["tabular-nums"];
|
|
39
|
+
|
|
40
|
+
/** Text roles without color; components add `color` from `theme.colors`. */
|
|
41
|
+
export const TEXT = {
|
|
42
|
+
display: { fontSize: FONT_SIZE.display, fontWeight: FONT_WEIGHT.medium },
|
|
43
|
+
rowTitle: { fontSize: FONT_SIZE.body, fontWeight: FONT_WEIGHT.medium },
|
|
44
|
+
body: { fontSize: FONT_SIZE.body },
|
|
45
|
+
small: { fontSize: FONT_SIZE.small },
|
|
46
|
+
meta: { fontSize: FONT_SIZE.label },
|
|
47
|
+
caption: { fontSize: FONT_SIZE.caption },
|
|
48
|
+
count: { fontSize: FONT_SIZE.small, fontVariant: TABULAR },
|
|
49
|
+
tabularMeta: { fontSize: FONT_SIZE.label, fontVariant: TABULAR },
|
|
50
|
+
pillBadge: { fontSize: FONT_SIZE.caption, fontWeight: FONT_WEIGHT.semibold, fontVariant: TABULAR },
|
|
51
|
+
iconBadge: { fontSize: FONT_SIZE.badge, fontWeight: FONT_WEIGHT.bold, fontVariant: TABULAR, lineHeight: 11 },
|
|
52
|
+
back: { fontSize: FONT_SIZE.small, fontWeight: FONT_WEIGHT.medium },
|
|
53
|
+
code: { fontSize: FONT_SIZE.small, lineHeight: 22, fontFamily: MONO },
|
|
54
|
+
terminal: { fontSize: FONT_SIZE.caption, lineHeight: 15, fontFamily: MONO },
|
|
55
|
+
tooltip: { fontSize: FONT_SIZE.label, lineHeight: 16 },
|
|
56
|
+
menu: { fontSize: FONT_SIZE.body, lineHeight: 18, fontWeight: FONT_WEIGHT.regular },
|
|
57
|
+
} as const satisfies Record<string, TextStyle>;
|
|
58
|
+
|
|
59
|
+
/** One section-title style for every scope and popover. */
|
|
60
|
+
export function sectionTitle(compact = false): TextStyle {
|
|
61
|
+
return {
|
|
62
|
+
fontSize: compact ? FONT_SIZE.body : FONT_SIZE.title,
|
|
63
|
+
fontWeight: FONT_WEIGHT.semibold,
|
|
64
|
+
letterSpacing: -0.3,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export type PageKind = "surface" | "panel";
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Page container rhythm. `surface` = Global sidebar page (charts, wide);
|
|
72
|
+
* `panel` = Workspace / Agent workspace panels.
|
|
73
|
+
*/
|
|
74
|
+
export function pageLayout(kind: PageKind, compact: boolean): { padding: number; gap: number } {
|
|
75
|
+
return {
|
|
76
|
+
padding: compact ? 16 : 24,
|
|
77
|
+
gap: kind === "surface" ? (compact ? 24 : 32) : compact ? 20 : 28,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Section title → first content row. */
|
|
82
|
+
export function titleGap(compact = false): number {
|
|
83
|
+
return compact ? 10 : 12;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** List row vertical padding: `dense` for operational lists and popovers. */
|
|
87
|
+
export const ROW_PADDING = { dense: 6, regular: 9 } as const;
|
|
88
|
+
|
|
89
|
+
export const RADIUS = {
|
|
90
|
+
/** Chart bars, legend swatches. */
|
|
91
|
+
swatch: 3,
|
|
92
|
+
/** Icon buttons, menu rows, terminal preview. */
|
|
93
|
+
control: 6,
|
|
94
|
+
/** Menus, tooltips. */
|
|
95
|
+
overlay: 8,
|
|
96
|
+
/** Code body. */
|
|
97
|
+
block: 12,
|
|
98
|
+
/** KPI card. */
|
|
99
|
+
card: 20,
|
|
100
|
+
} as const;
|
|
101
|
+
|
|
102
|
+
/** Fully rounded ends for a box of the given height (badges, search field, dots). */
|
|
103
|
+
export function pillRadius(height: number): number {
|
|
104
|
+
return height / 2;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export const ICON_SIZE = {
|
|
108
|
+
/** Inside a pill badge. */
|
|
109
|
+
badge: 12,
|
|
110
|
+
/** Inline glyphs: search field, menu chevron, row close. */
|
|
111
|
+
inline: 14,
|
|
112
|
+
/** Header / back / toggle icon buttons. */
|
|
113
|
+
action: 16,
|
|
114
|
+
/** Leading icon of a list row. */
|
|
115
|
+
leading: 18,
|
|
116
|
+
} as const;
|
|
117
|
+
|
|
118
|
+
export const CONTROL = {
|
|
119
|
+
iconButton: 24,
|
|
120
|
+
hitSlop: 8,
|
|
121
|
+
pillBadgeHeight: 18,
|
|
122
|
+
} as const;
|
|
123
|
+
|
|
124
|
+
export const iconButton: ViewStyle = {
|
|
125
|
+
width: CONTROL.iconButton,
|
|
126
|
+
height: CONTROL.iconButton,
|
|
127
|
+
alignItems: "center",
|
|
128
|
+
justifyContent: "center",
|
|
129
|
+
borderRadius: RADIUS.control,
|
|
130
|
+
flexShrink: 0,
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Global chart motion (081): `grow` for bars reaching a new value, `reveal` /
|
|
135
|
+
* `refresh` for the heatmap's first column sweep and later metric / range
|
|
136
|
+
* switches. `refreshFloor` is the lowest column opacity during a refresh.
|
|
137
|
+
* `disclose` is the ranking Show more / Show less height transition.
|
|
138
|
+
* `step` / `stepOffset` slide the metric switch label in from the pressed side.
|
|
139
|
+
*/
|
|
140
|
+
export const CHART_MOTION = {
|
|
141
|
+
grow: 400,
|
|
142
|
+
disclose: 250,
|
|
143
|
+
step: 200,
|
|
144
|
+
stepOffset: 12,
|
|
145
|
+
reveal: 700,
|
|
146
|
+
refresh: 450,
|
|
147
|
+
refreshFloor: 0.3,
|
|
148
|
+
columnSpan: 0.35,
|
|
149
|
+
} as const;
|
|
150
|
+
|
|
151
|
+
/** Composer popover content frame, shared by the Activity and Attention pills. */
|
|
152
|
+
export const POPOVER_WIDTH = { min: 300, max: 380 } as const;
|
|
153
|
+
|
|
154
|
+
export function popoverFrame(compact: boolean): ViewStyle {
|
|
155
|
+
return compact ? {} : { minWidth: POPOVER_WIDTH.min, maxWidth: POPOVER_WIDTH.max };
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** Floating chart tooltip container (heatmap, creations histogram). */
|
|
159
|
+
export function tooltipSurface(colors: { surface2: string; border: string }): ViewStyle {
|
|
160
|
+
return {
|
|
161
|
+
paddingHorizontal: 10,
|
|
162
|
+
paddingVertical: 6,
|
|
163
|
+
borderRadius: RADIUS.overlay,
|
|
164
|
+
backgroundColor: colors.surface2,
|
|
165
|
+
borderWidth: 1,
|
|
166
|
+
borderColor: colors.border,
|
|
167
|
+
};
|
|
168
|
+
}
|