@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
package/client/usage-popover.tsx
CHANGED
|
@@ -4,24 +4,33 @@ import {
|
|
|
4
4
|
} from "@getpaseo/plugin/client";
|
|
5
5
|
import { Icon } from "@getpaseo/plugin/client/react-native";
|
|
6
6
|
import { useQuery } from "@tanstack/react-query";
|
|
7
|
-
import { useEffect, useMemo, useState
|
|
8
|
-
import {
|
|
9
|
-
ActivityIndicator,
|
|
10
|
-
Platform,
|
|
11
|
-
Pressable,
|
|
12
|
-
Text,
|
|
13
|
-
View,
|
|
14
|
-
type TextStyle,
|
|
15
|
-
type ViewStyle,
|
|
16
|
-
} from "react-native";
|
|
7
|
+
import { useEffect, useMemo, useState } from "react";
|
|
8
|
+
import { Pressable, Text, View } from "react-native";
|
|
17
9
|
import {
|
|
18
10
|
usageReadSkillRpc,
|
|
19
11
|
} from "../shared/usage.ts";
|
|
20
12
|
import { formatDisplayName } from "../shared/format.ts";
|
|
21
13
|
import { FormattedTime } from "./formatted-time.tsx";
|
|
22
14
|
import { useUsagePillData } from "./usage-query.tsx";
|
|
15
|
+
import { useMessages } from "./use-app-language.ts";
|
|
16
|
+
import {
|
|
17
|
+
CountText,
|
|
18
|
+
ErrorState,
|
|
19
|
+
IconButton,
|
|
20
|
+
InlineEmpty,
|
|
21
|
+
LoadingState,
|
|
22
|
+
SectionHeader,
|
|
23
|
+
} from "./ui.tsx";
|
|
24
|
+
import {
|
|
25
|
+
ICON_SIZE,
|
|
26
|
+
RADIUS,
|
|
27
|
+
ROW_PADDING,
|
|
28
|
+
TEXT,
|
|
29
|
+
popoverFrame,
|
|
30
|
+
sectionTitle,
|
|
31
|
+
titleGap,
|
|
32
|
+
} from "./design-tokens.ts";
|
|
23
33
|
|
|
24
|
-
const MONO = Platform.select({ ios: "Menlo", default: "monospace" });
|
|
25
34
|
|
|
26
35
|
export type SkillDetail = { skillName: string; path: string };
|
|
27
36
|
|
|
@@ -30,31 +39,14 @@ export type UsagePopoverProps = PluginButtonContentProps & {
|
|
|
30
39
|
openSkillInPanel?: (skill: SkillDetail) => void;
|
|
31
40
|
};
|
|
32
41
|
|
|
33
|
-
function CountBadge({
|
|
34
|
-
value,
|
|
35
|
-
styles,
|
|
36
|
-
}: {
|
|
37
|
-
value: number | string;
|
|
38
|
-
styles: { countBadge: ViewStyle; countText: TextStyle };
|
|
39
|
-
}): ReactNode {
|
|
40
|
-
return (
|
|
41
|
-
<View style={styles.countBadge}>
|
|
42
|
-
<Text style={styles.countText}>{value}</Text>
|
|
43
|
-
</View>
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
42
|
/**
|
|
48
43
|
* Composer-pill popover body. Host owns anchoring / sheet chrome / outer scroll;
|
|
49
44
|
* render content only.
|
|
50
45
|
*/
|
|
51
46
|
export function UsagePopover(props: UsagePopoverProps) {
|
|
47
|
+
const m = useMessages();
|
|
52
48
|
if (props.context !== "agent") {
|
|
53
|
-
return
|
|
54
|
-
<Text style={{ color: props.theme.colors.foregroundMuted }}>
|
|
55
|
-
Activity is only available for an agent
|
|
56
|
-
</Text>
|
|
57
|
-
);
|
|
49
|
+
return <InlineEmpty text={m.common.agentOnly} color={props.theme.colors.foregroundMuted} />;
|
|
58
50
|
}
|
|
59
51
|
return <UsagePopoverAgent {...props} context="agent" />;
|
|
60
52
|
}
|
|
@@ -66,6 +58,7 @@ function UsagePopoverAgent(
|
|
|
66
58
|
const [tab, setTab] = useState<"skills" | "mcp" | null>(null);
|
|
67
59
|
const [skillDetail, setSkillDetail] = useState<SkillDetail | null>(null);
|
|
68
60
|
const compact = layout.compact;
|
|
61
|
+
const m = useMessages();
|
|
69
62
|
|
|
70
63
|
const usage = useUsagePillData(agentId);
|
|
71
64
|
const readSkillRpc = useRpc(usageReadSkillRpc);
|
|
@@ -108,38 +101,17 @@ function UsagePopoverAgent(
|
|
|
108
101
|
const styles = useMemo(
|
|
109
102
|
() => ({
|
|
110
103
|
root: {
|
|
111
|
-
gap:
|
|
112
|
-
|
|
113
|
-
maxWidth: compact ? undefined : 380,
|
|
114
|
-
},
|
|
115
|
-
sectionHeaderRow: {
|
|
116
|
-
flexDirection: "row" as const,
|
|
117
|
-
alignItems: "center" as const,
|
|
118
|
-
justifyContent: "space-between" as const,
|
|
119
|
-
gap: 8,
|
|
120
|
-
},
|
|
121
|
-
sectionTitle: {
|
|
122
|
-
color: theme.colors.foreground,
|
|
123
|
-
fontSize: 14,
|
|
124
|
-
fontWeight: "600" as const,
|
|
125
|
-
flexShrink: 1,
|
|
126
|
-
},
|
|
127
|
-
titleAction: {
|
|
128
|
-
width: 24,
|
|
129
|
-
height: 24,
|
|
130
|
-
alignItems: "center" as const,
|
|
131
|
-
justifyContent: "center" as const,
|
|
132
|
-
borderRadius: 6,
|
|
133
|
-
flexShrink: 0,
|
|
104
|
+
gap: titleGap(true),
|
|
105
|
+
...popoverFrame(compact),
|
|
134
106
|
},
|
|
135
107
|
list: {
|
|
136
|
-
gap:
|
|
108
|
+
gap: 2,
|
|
137
109
|
},
|
|
138
110
|
row: {
|
|
139
111
|
flexDirection: "row" as const,
|
|
140
112
|
alignItems: "center" as const,
|
|
141
113
|
gap: 10,
|
|
142
|
-
paddingVertical:
|
|
114
|
+
paddingVertical: ROW_PADDING.dense,
|
|
143
115
|
borderTopWidth: 0,
|
|
144
116
|
borderTopColor: theme.colors.border,
|
|
145
117
|
},
|
|
@@ -150,30 +122,15 @@ function UsagePopoverAgent(
|
|
|
150
122
|
rowMain: {
|
|
151
123
|
flex: 1,
|
|
152
124
|
minWidth: 0,
|
|
153
|
-
gap:
|
|
125
|
+
gap: 3,
|
|
154
126
|
},
|
|
155
127
|
rowTitle: {
|
|
128
|
+
...TEXT.rowTitle,
|
|
156
129
|
color: theme.colors.foreground,
|
|
157
|
-
fontSize: 13,
|
|
158
|
-
fontWeight: "500" as const,
|
|
159
130
|
},
|
|
160
131
|
rowMeta: {
|
|
132
|
+
...TEXT.meta,
|
|
161
133
|
color: theme.colors.foregroundMuted,
|
|
162
|
-
fontSize: 11,
|
|
163
|
-
},
|
|
164
|
-
countBadge: {
|
|
165
|
-
minWidth: 22,
|
|
166
|
-
alignItems: "flex-end" as const,
|
|
167
|
-
},
|
|
168
|
-
countText: {
|
|
169
|
-
color: theme.colors.foregroundMuted,
|
|
170
|
-
fontSize: 12,
|
|
171
|
-
fontVariant: ["tabular-nums" as const],
|
|
172
|
-
},
|
|
173
|
-
empty: {
|
|
174
|
-
color: theme.colors.foregroundMuted,
|
|
175
|
-
fontSize: 13,
|
|
176
|
-
paddingVertical: 4,
|
|
177
134
|
},
|
|
178
135
|
detailHeader: {
|
|
179
136
|
flexDirection: "row" as const,
|
|
@@ -187,32 +144,20 @@ function UsagePopoverAgent(
|
|
|
187
144
|
gap: 4,
|
|
188
145
|
},
|
|
189
146
|
back: {
|
|
147
|
+
...TEXT.back,
|
|
190
148
|
color: theme.colors.foregroundMuted,
|
|
191
|
-
fontSize: 12,
|
|
192
|
-
fontWeight: "500" as const,
|
|
193
|
-
},
|
|
194
|
-
panelButton: {
|
|
195
|
-
width: 24,
|
|
196
|
-
height: 24,
|
|
197
|
-
alignItems: "center" as const,
|
|
198
|
-
justifyContent: "center" as const,
|
|
199
|
-
borderRadius: 6,
|
|
200
|
-
flexShrink: 0,
|
|
201
149
|
},
|
|
202
150
|
title: {
|
|
151
|
+
...sectionTitle(true),
|
|
203
152
|
color: theme.colors.foreground,
|
|
204
|
-
fontSize: 14,
|
|
205
|
-
fontWeight: "600" as const,
|
|
206
153
|
flexShrink: 1,
|
|
207
154
|
},
|
|
208
155
|
body: {
|
|
156
|
+
...TEXT.code,
|
|
209
157
|
color: theme.colors.foreground,
|
|
210
|
-
fontSize: 13,
|
|
211
|
-
fontFamily: MONO,
|
|
212
|
-
lineHeight: 22,
|
|
213
158
|
backgroundColor: theme.colors.surface1,
|
|
214
159
|
padding: 16,
|
|
215
|
-
borderRadius:
|
|
160
|
+
borderRadius: RADIUS.block,
|
|
216
161
|
},
|
|
217
162
|
}),
|
|
218
163
|
[theme, compact],
|
|
@@ -223,8 +168,8 @@ function UsagePopoverAgent(
|
|
|
223
168
|
const showToggle = skillItems.length > 0 && mcpItems.length > 0;
|
|
224
169
|
const toggleAction =
|
|
225
170
|
tab === "skills"
|
|
226
|
-
? { icon: "Plug" as const, accessibilityLabel:
|
|
227
|
-
: { icon: "Sparkles" as const, accessibilityLabel:
|
|
171
|
+
? { icon: "Plug" as const, accessibilityLabel: m.common.showMcp, next: "mcp" as const }
|
|
172
|
+
: { icon: "Sparkles" as const, accessibilityLabel: m.common.showSkills, next: "skills" as const };
|
|
228
173
|
|
|
229
174
|
if (skillDetail) {
|
|
230
175
|
return (
|
|
@@ -235,30 +180,25 @@ function UsagePopoverAgent(
|
|
|
235
180
|
onPress={() => setSkillDetail(null)}
|
|
236
181
|
style={styles.backRow}
|
|
237
182
|
>
|
|
238
|
-
<Icon name="ChevronLeft" size={
|
|
239
|
-
<Text style={styles.back}>
|
|
183
|
+
<Icon name="ChevronLeft" size={ICON_SIZE.action} color={theme.colors.foregroundMuted} />
|
|
184
|
+
<Text style={styles.back}>{m.common.skills}</Text>
|
|
240
185
|
</Pressable>
|
|
241
186
|
{openSkillInPanel ? (
|
|
242
|
-
<
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
style={styles.panelButton}
|
|
187
|
+
<IconButton
|
|
188
|
+
icon="ArrowUpRight"
|
|
189
|
+
label={m.common.openSkillInPanel}
|
|
190
|
+
color={theme.colors.foregroundMuted}
|
|
247
191
|
onPress={() => {
|
|
248
192
|
openSkillInPanel(skillDetail);
|
|
249
193
|
close();
|
|
250
194
|
}}
|
|
251
|
-
|
|
252
|
-
<Icon name="ArrowUpRight" size={16} color={theme.colors.foregroundMuted} />
|
|
253
|
-
</Pressable>
|
|
195
|
+
/>
|
|
254
196
|
) : null}
|
|
255
197
|
</View>
|
|
256
198
|
<Text style={styles.title}>{formatDisplayName(skillDetail.skillName)}</Text>
|
|
257
|
-
{skillFile.isLoading ? <
|
|
199
|
+
{skillFile.isLoading ? <LoadingState color={theme.colors.accent} /> : null}
|
|
258
200
|
{skillFile.error ? (
|
|
259
|
-
<
|
|
260
|
-
{skillFile.error instanceof Error ? skillFile.error.message : String(skillFile.error)}
|
|
261
|
-
</Text>
|
|
201
|
+
<ErrorState error={skillFile.error} onRetry={() => void skillFile.refetch()} colors={theme.colors} />
|
|
262
202
|
) : null}
|
|
263
203
|
{skillFile.data ? (
|
|
264
204
|
<Text style={styles.body} selectable>
|
|
@@ -272,35 +212,23 @@ function UsagePopoverAgent(
|
|
|
272
212
|
return (
|
|
273
213
|
<View style={styles.root}>
|
|
274
214
|
{tab && (skillItems.length > 0 || mcpItems.length > 0) ? (
|
|
275
|
-
<
|
|
276
|
-
<Text style={styles.sectionTitle}>{tab === "skills" ? "Skills" : "MCP"}</Text>
|
|
215
|
+
<SectionHeader title={tab === "skills" ? m.common.skills : m.common.mcp} colors={theme.colors} compact>
|
|
277
216
|
{showToggle ? (
|
|
278
|
-
<
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
hitSlop={8}
|
|
217
|
+
<IconButton
|
|
218
|
+
icon={toggleAction.icon}
|
|
219
|
+
label={toggleAction.accessibilityLabel}
|
|
282
220
|
onPress={() => setTab(toggleAction.next)}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
<Icon
|
|
286
|
-
name={toggleAction.icon}
|
|
287
|
-
size={16}
|
|
288
|
-
color={theme.colors.foregroundMuted}
|
|
289
|
-
/>
|
|
290
|
-
</Pressable>
|
|
221
|
+
color={theme.colors.foregroundMuted}
|
|
222
|
+
/>
|
|
291
223
|
) : null}
|
|
292
|
-
</
|
|
224
|
+
</SectionHeader>
|
|
293
225
|
) : null}
|
|
294
226
|
|
|
295
|
-
{loading ? <
|
|
296
|
-
{error ? (
|
|
297
|
-
<Text style={{ color: theme.colors.statusDanger }}>
|
|
298
|
-
{error instanceof Error ? error.message : String(error)}
|
|
299
|
-
</Text>
|
|
300
|
-
) : null}
|
|
227
|
+
{loading ? <LoadingState color={theme.colors.accent} /> : null}
|
|
228
|
+
{error ? <ErrorState error={error} onRetry={() => void usage.refetch()} colors={theme.colors} /> : null}
|
|
301
229
|
|
|
302
230
|
{!loading && !error && skillItems.length === 0 && mcpItems.length === 0 ? (
|
|
303
|
-
<
|
|
231
|
+
<InlineEmpty text={m.common.noSkillOrMcp} color={theme.colors.foregroundMuted} />
|
|
304
232
|
) : null}
|
|
305
233
|
|
|
306
234
|
{tab === "skills" && skillItems.length > 0 ? (
|
|
@@ -310,7 +238,7 @@ function UsagePopoverAgent(
|
|
|
310
238
|
const rowStyle = [styles.row, index === 0 ? styles.rowFirst : null];
|
|
311
239
|
const content = (
|
|
312
240
|
<>
|
|
313
|
-
<Icon name="Sparkles" size={
|
|
241
|
+
<Icon name="Sparkles" size={ICON_SIZE.leading} color={theme.colors.foregroundMuted} />
|
|
314
242
|
<View style={styles.rowMain}>
|
|
315
243
|
<Text style={styles.rowTitle} numberOfLines={1}>
|
|
316
244
|
{name}
|
|
@@ -319,7 +247,7 @@ function UsagePopoverAgent(
|
|
|
319
247
|
<FormattedTime iso={item.lastUsedAt} style={styles.rowMeta} />
|
|
320
248
|
) : null}
|
|
321
249
|
</View>
|
|
322
|
-
<
|
|
250
|
+
<CountText value={item.total} color={theme.colors.foregroundMuted} />
|
|
323
251
|
</>
|
|
324
252
|
);
|
|
325
253
|
if (item.skillPath) {
|
|
@@ -327,7 +255,7 @@ function UsagePopoverAgent(
|
|
|
327
255
|
<Pressable
|
|
328
256
|
key={item.skillName}
|
|
329
257
|
accessibilityRole="link"
|
|
330
|
-
accessibilityLabel={
|
|
258
|
+
accessibilityLabel={m.common.openSkillFile(name)}
|
|
331
259
|
onPress={() =>
|
|
332
260
|
setSkillDetail({ skillName: item.skillName, path: item.skillPath! })
|
|
333
261
|
}
|
|
@@ -353,18 +281,18 @@ function UsagePopoverAgent(
|
|
|
353
281
|
key={`${item.server}.${item.tool}`}
|
|
354
282
|
style={[styles.row, index === 0 ? styles.rowFirst : null]}
|
|
355
283
|
>
|
|
356
|
-
<Icon name="Plug" size={
|
|
357
|
-
|
|
284
|
+
<Icon name="Plug" size={ICON_SIZE.leading} color={theme.colors.foregroundMuted} />
|
|
285
|
+
<View style={styles.rowMain}>
|
|
358
286
|
<Text style={styles.rowTitle} numberOfLines={1}>
|
|
359
287
|
{formatDisplayName(`${item.server}.${item.tool}`)}
|
|
360
288
|
</Text>
|
|
361
289
|
{item.failures > 0 ? (
|
|
362
|
-
<Text style={styles.rowMeta}>{item.failures}
|
|
290
|
+
<Text style={styles.rowMeta}>{m.common.failed(item.failures)}</Text>
|
|
363
291
|
) : item.lastUsedAt ? (
|
|
364
292
|
<FormattedTime iso={item.lastUsedAt} style={styles.rowMeta} />
|
|
365
293
|
) : null}
|
|
366
294
|
</View>
|
|
367
|
-
<
|
|
295
|
+
<CountText value={item.count} color={theme.colors.foregroundMuted} />
|
|
368
296
|
</View>
|
|
369
297
|
))}
|
|
370
298
|
</View>
|
package/client/usage-stats.tsx
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { useState } from "react";
|
|
2
2
|
import { Text, View, type TextStyle } from "react-native";
|
|
3
3
|
import { fitFontSize } from "./fit-text.ts";
|
|
4
|
+
import { FONT_SIZE, FONT_WEIGHT, RADIUS } from "./design-tokens.ts";
|
|
5
|
+
import type { KpiRow } from "../shared/insights.ts";
|
|
4
6
|
|
|
5
7
|
/** Hidden measuring box wide enough to never clamp the text (051). */
|
|
6
8
|
const MEASURE_WIDTH = 1000;
|
|
@@ -20,7 +22,7 @@ function FitText({ text, available, base, min, lineHeight, color, weight, tabula
|
|
|
20
22
|
min?: number;
|
|
21
23
|
lineHeight: number;
|
|
22
24
|
color: string;
|
|
23
|
-
weight?:
|
|
25
|
+
weight?: typeof FONT_WEIGHT.medium;
|
|
24
26
|
tabular?: boolean;
|
|
25
27
|
}) {
|
|
26
28
|
// The hidden copy renders at `fontSize` and reports its width; the fit is
|
|
@@ -61,20 +63,24 @@ function FitText({ text, available, base, min, lineHeight, color, weight, tabula
|
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
function StatTile({ item, colors, dense, compact, bordered }: {
|
|
64
|
-
item:
|
|
65
|
-
colors: { border: string; foreground: string; foregroundMuted: string };
|
|
66
|
+
item: KpiRow;
|
|
67
|
+
colors: { border: string; foreground: string; foregroundMuted: string; statusSuccess: string; statusDanger: string };
|
|
66
68
|
dense: boolean;
|
|
67
69
|
compact: boolean;
|
|
68
70
|
bordered: boolean;
|
|
69
71
|
}) {
|
|
70
72
|
const [width, setWidth] = useState(0);
|
|
71
73
|
const padding = dense ? 8 : 12;
|
|
72
|
-
const available = Math.max(0, width - padding * 2);
|
|
74
|
+
const available = Math.max(0, width - padding * 2 - (bordered ? 1 : 0));
|
|
75
|
+
const comparisonColor = item.comparison?.direction === "up"
|
|
76
|
+
? colors.statusSuccess
|
|
77
|
+
: item.comparison?.direction === "down"
|
|
78
|
+
? colors.statusDanger
|
|
79
|
+
: colors.foregroundMuted;
|
|
73
80
|
return (
|
|
74
81
|
<View
|
|
75
82
|
onLayout={(event) => setWidth(event.nativeEvent.layout.width)}
|
|
76
83
|
style={{
|
|
77
|
-
position: "relative",
|
|
78
84
|
flexGrow: 1,
|
|
79
85
|
flexBasis: dense ? 84 : compact ? 100 : 120,
|
|
80
86
|
minWidth: 0,
|
|
@@ -89,33 +95,45 @@ function StatTile({ item, colors, dense, compact, bordered }: {
|
|
|
89
95
|
<FitText
|
|
90
96
|
text={item.value}
|
|
91
97
|
available={available}
|
|
92
|
-
base={
|
|
98
|
+
base={FONT_SIZE.metric}
|
|
99
|
+
min={FONT_SIZE.caption}
|
|
93
100
|
lineHeight={22}
|
|
94
101
|
color={colors.foreground}
|
|
95
|
-
weight=
|
|
102
|
+
weight={FONT_WEIGHT.medium}
|
|
96
103
|
tabular
|
|
97
104
|
/>
|
|
98
105
|
<FitText
|
|
99
106
|
text={item.label}
|
|
100
107
|
available={available}
|
|
101
|
-
base={
|
|
108
|
+
base={FONT_SIZE.label}
|
|
102
109
|
min={10}
|
|
103
110
|
lineHeight={16}
|
|
104
111
|
color={colors.foregroundMuted}
|
|
105
112
|
/>
|
|
113
|
+
{item.comparison ? (
|
|
114
|
+
<FitText
|
|
115
|
+
text={item.comparison.text}
|
|
116
|
+
available={available}
|
|
117
|
+
base={FONT_SIZE.label}
|
|
118
|
+
min={10}
|
|
119
|
+
lineHeight={16}
|
|
120
|
+
color={comparisonColor}
|
|
121
|
+
tabular
|
|
122
|
+
/>
|
|
123
|
+
) : null}
|
|
106
124
|
</View>
|
|
107
125
|
);
|
|
108
126
|
}
|
|
109
127
|
|
|
110
128
|
export function UsageStats({ items, colors, compact, dense }: {
|
|
111
|
-
items: ReadonlyArray<
|
|
112
|
-
colors: { border: string; foreground: string; foregroundMuted: string };
|
|
129
|
+
items: ReadonlyArray<KpiRow>;
|
|
130
|
+
colors: { border: string; foreground: string; foregroundMuted: string; statusSuccess: string; statusDanger: string };
|
|
113
131
|
compact: boolean;
|
|
114
132
|
/** Smaller numbers / labels / padding (025). */
|
|
115
133
|
dense?: boolean;
|
|
116
134
|
}) {
|
|
117
135
|
return (
|
|
118
|
-
<View style={{ flexDirection: "row", flexWrap: "wrap", borderWidth: 1, borderColor: colors.border, borderRadius:
|
|
136
|
+
<View style={{ flexDirection: "row", flexWrap: "wrap", borderWidth: 1, borderColor: colors.border, borderRadius: RADIUS.card, paddingVertical: dense ? 6 : compact ? 8 : 12, rowGap: dense ? 10 : 16 }}>
|
|
119
137
|
{items.map((item, index) => (
|
|
120
138
|
<StatTile
|
|
121
139
|
key={item.label}
|
|
@@ -56,7 +56,8 @@ function useActivityRefresh(scope: AgentTurnEndScope, onTurnEnd: () => void): vo
|
|
|
56
56
|
: watchAgentDirectory(paseo.agents, (_snapshot, update) => {
|
|
57
57
|
// Workspace-wide hint only. The 15s query poll owns completeness.
|
|
58
58
|
// The surface owns its API observation, independently of the entry.
|
|
59
|
-
|
|
59
|
+
// Snapshot-only publishes (mount, periodic re-read) are not activity.
|
|
60
|
+
if (!update) return;
|
|
60
61
|
if (update.kind === "remove") {
|
|
61
62
|
schedule();
|
|
62
63
|
return;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { useSyncExternalStore } from "react";
|
|
2
2
|
import { Platform } from "react-native";
|
|
3
|
+
import { messagesFor, type Messages } from "../shared/i18n.ts";
|
|
3
4
|
import { readAppLanguage, subscribeAppLanguage } from "./web.ts";
|
|
4
5
|
|
|
5
6
|
const defaultLanguage = () => "en";
|
|
6
7
|
const noSubscription = () => () => {};
|
|
7
8
|
|
|
9
|
+
/** Paseo app language (Settings → Language, `system` → OS preference); `en` off web. */
|
|
8
10
|
export function useAppLanguage(): string {
|
|
9
11
|
return useSyncExternalStore(
|
|
10
12
|
Platform.OS === "web" ? subscribeAppLanguage : noSubscription,
|
|
@@ -12,3 +14,18 @@ export function useAppLanguage(): string {
|
|
|
12
14
|
defaultLanguage,
|
|
13
15
|
);
|
|
14
16
|
}
|
|
17
|
+
|
|
18
|
+
/** UI copy for the current app language (066). */
|
|
19
|
+
export function useMessages(): Messages {
|
|
20
|
+
return messagesFor(useAppLanguage());
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Non-React read for registrations (Command Center titles, pill titles). */
|
|
24
|
+
export function currentAppLanguage(): string {
|
|
25
|
+
return Platform.OS === "web" ? readAppLanguage() : "en";
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Non-React subscription; no-op off web. */
|
|
29
|
+
export function watchAppLanguage(onChange: () => void): () => void {
|
|
30
|
+
return Platform.OS === "web" ? subscribeAppLanguage(onChange) : () => {};
|
|
31
|
+
}
|
package/client/web.ts
CHANGED
|
@@ -1,28 +1,83 @@
|
|
|
1
|
-
// Browser-only bridge: the SDK
|
|
2
|
-
//
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
// Browser-only bridge: the SDK does not expose the app language, and the host
|
|
2
|
+
// leaves `<html lang="en">` static. The Paseo `language` setting lives in the
|
|
3
|
+
// app settings blob in localStorage; keep DOM / storage access here and call it
|
|
4
|
+
// only on the web platform.
|
|
5
|
+
import { resolveAppLanguage, type AppLanguage } from "../shared/i18n.ts";
|
|
6
|
+
|
|
7
|
+
const APP_SETTINGS_KEY = "@paseo:app-settings";
|
|
8
|
+
/** Same-window writes do not fire `storage`; poll the (small) settings string. */
|
|
9
|
+
const POLL_MS = 1_500;
|
|
10
|
+
|
|
11
|
+
type BrowserEventTarget = {
|
|
12
|
+
addEventListener(type: string, listener: () => void): void;
|
|
13
|
+
removeEventListener(type: string, listener: () => void): void;
|
|
7
14
|
};
|
|
8
|
-
const browser = globalThis as unknown as {
|
|
9
|
-
|
|
10
|
-
|
|
15
|
+
const browser = globalThis as unknown as BrowserEventTarget & {
|
|
16
|
+
localStorage?: { getItem(key: string): string | null };
|
|
17
|
+
navigator?: { languages?: readonly string[]; language?: string };
|
|
18
|
+
document?: BrowserEventTarget;
|
|
11
19
|
};
|
|
12
20
|
|
|
13
|
-
|
|
14
|
-
const language = browser.document?.documentElement.lang.trim() || "en";
|
|
21
|
+
function readLanguageSetting(): string | null {
|
|
15
22
|
try {
|
|
16
|
-
|
|
23
|
+
const raw = browser.localStorage?.getItem(APP_SETTINGS_KEY);
|
|
24
|
+
if (!raw) return null;
|
|
25
|
+
const parsed = JSON.parse(raw) as { language?: unknown };
|
|
26
|
+
return typeof parsed.language === "string" ? parsed.language : null;
|
|
17
27
|
} catch {
|
|
18
|
-
return
|
|
28
|
+
return null;
|
|
19
29
|
}
|
|
20
30
|
}
|
|
21
31
|
|
|
32
|
+
function systemLanguages(): readonly string[] {
|
|
33
|
+
const nav = browser.navigator;
|
|
34
|
+
if (!nav) return [];
|
|
35
|
+
if (nav.languages && nav.languages.length > 0) return nav.languages;
|
|
36
|
+
return nav.language ? [nav.language] : [];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
let current: AppLanguage = "en";
|
|
40
|
+
let initialized = false;
|
|
41
|
+
const listeners = new Set<() => void>();
|
|
42
|
+
let stopWatching: (() => void) | null = null;
|
|
43
|
+
|
|
44
|
+
function refresh(): void {
|
|
45
|
+
const next = resolveAppLanguage(readLanguageSetting(), systemLanguages());
|
|
46
|
+
if (next === current) return;
|
|
47
|
+
current = next;
|
|
48
|
+
for (const listener of [...listeners]) listener();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function readAppLanguage(): AppLanguage {
|
|
52
|
+
if (!initialized) {
|
|
53
|
+
initialized = true;
|
|
54
|
+
current = resolveAppLanguage(readLanguageSetting(), systemLanguages());
|
|
55
|
+
}
|
|
56
|
+
return current;
|
|
57
|
+
}
|
|
58
|
+
|
|
22
59
|
export function subscribeAppLanguage(onChange: () => void): () => void {
|
|
23
|
-
|
|
24
|
-
if (!
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
60
|
+
listeners.add(onChange);
|
|
61
|
+
if (!stopWatching) {
|
|
62
|
+
readAppLanguage();
|
|
63
|
+
const timer = setInterval(refresh, POLL_MS);
|
|
64
|
+
browser.addEventListener?.("storage", refresh);
|
|
65
|
+
browser.addEventListener?.("focus", refresh);
|
|
66
|
+
browser.addEventListener?.("languagechange", refresh);
|
|
67
|
+
browser.document?.addEventListener?.("visibilitychange", refresh);
|
|
68
|
+
stopWatching = () => {
|
|
69
|
+
clearInterval(timer);
|
|
70
|
+
browser.removeEventListener?.("storage", refresh);
|
|
71
|
+
browser.removeEventListener?.("focus", refresh);
|
|
72
|
+
browser.removeEventListener?.("languagechange", refresh);
|
|
73
|
+
browser.document?.removeEventListener?.("visibilitychange", refresh);
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
return () => {
|
|
77
|
+
listeners.delete(onChange);
|
|
78
|
+
if (listeners.size === 0 && stopWatching) {
|
|
79
|
+
stopWatching();
|
|
80
|
+
stopWatching = null;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
28
83
|
}
|