@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.
Files changed (62) hide show
  1. package/CHANGELOG.md +35 -1
  2. package/README.md +14 -7
  3. package/client/activity-heatmap.tsx +115 -74
  4. package/client/agent-creations.tsx +97 -88
  5. package/client/attention-pill.tsx +16 -5
  6. package/client/attention-popover.tsx +19 -23
  7. package/client/design-tokens.test.ts +39 -0
  8. package/client/design-tokens.ts +168 -0
  9. package/client/formatted-time.tsx +4 -4
  10. package/client/global-surface.tsx +236 -268
  11. package/client/header-button.ts +136 -0
  12. package/client/hourly-activity-timeline.tsx +136 -103
  13. package/client/panel-visibility.test.ts +25 -0
  14. package/client/panel-visibility.ts +45 -0
  15. package/client/panel.tsx +83 -108
  16. package/client/provider-dropdown.tsx +131 -0
  17. package/client/provider-filter.test.ts +17 -13
  18. package/client/provider-filter.ts +5 -7
  19. package/client/rank-color.ts +3 -3
  20. package/client/ranking-bars.tsx +291 -0
  21. package/client/ui.tsx +339 -0
  22. package/client/usage-popover.tsx +62 -134
  23. package/client/usage-stats.tsx +29 -11
  24. package/client/use-agent-turn-end.ts +2 -1
  25. package/client/use-app-language.ts +17 -0
  26. package/client/web.ts +73 -18
  27. package/client/workspace/agent-row.tsx +18 -25
  28. package/client/workspace/agents-section.tsx +23 -20
  29. package/client/workspace/constants.ts +6 -6
  30. package/client/workspace/display-menu.tsx +5 -4
  31. package/client/workspace/filters.test.ts +1 -1
  32. package/client/workspace/filters.ts +4 -2
  33. package/client/workspace/panel.tsx +89 -103
  34. package/client/workspace/rank-section.tsx +36 -62
  35. package/client/workspace/terminals-section.tsx +13 -9
  36. package/index.client.tsx +40 -20
  37. package/index.server.ts +53 -51
  38. package/package.json +2 -2
  39. package/paseo-plugin.json +2 -1
  40. package/server/agents.ts +20 -2
  41. package/server/background-sync.ts +34 -4
  42. package/server/handlers-query.test.ts +27 -1
  43. package/server/handlers.ts +75 -31
  44. package/server/ingest.test.ts +8 -0
  45. package/server/messages.test.ts +96 -1
  46. package/server/prompt-dedupe.ts +52 -0
  47. package/server/rpc-cache.test.ts +74 -0
  48. package/server/rpc-cache.ts +48 -0
  49. package/server/store.test.ts +122 -0
  50. package/server/store.ts +313 -19
  51. package/server/ttl-cache.ts +3 -0
  52. package/shared/activity.test.ts +36 -0
  53. package/shared/activity.ts +37 -0
  54. package/shared/classify.test.ts +1 -10
  55. package/shared/classify.ts +3 -10
  56. package/shared/format.ts +10 -7
  57. package/shared/i18n.test.ts +34 -0
  58. package/shared/i18n.ts +363 -0
  59. package/shared/insights.test.ts +120 -81
  60. package/shared/insights.ts +124 -63
  61. package/shared/usage.test.ts +121 -0
  62. package/shared/usage.ts +191 -2
@@ -11,6 +11,8 @@ import {
11
11
  } from "react-native";
12
12
  import type { AgentAttentionKind, WorkspaceTheme } from "./constants.ts";
13
13
  import { RunningIndicator } from "./running-indicator.tsx";
14
+ import { CONTROL, ICON_SIZE } from "../design-tokens.ts";
15
+ import { useMessages } from "../use-app-language.ts";
14
16
 
15
17
  export type AgentRowStyles = {
16
18
  agentListRow: ViewStyle;
@@ -60,6 +62,7 @@ export function AgentRow({
60
62
  /** Omit to hide the archive control (attention popover). */
61
63
  onArchiveToggle?: () => void;
62
64
  }): ReactNode {
65
+ const m = useMessages();
63
66
  const [hovered, setHovered] = useState(false);
64
67
  // Web: hover-reveal. Native has no hover — keep the action visible.
65
68
  // mouseenter/leave (not nested Pressable hover) so title/action don't flicker.
@@ -81,17 +84,11 @@ export function AgentRow({
81
84
  ? theme.colors.statusSuccess
82
85
  : theme.colors.foregroundMuted;
83
86
  const stateLabels: string[] = [];
84
- if (!archived && running) stateLabels.push("running");
85
- if (subAgentCount > 0) {
86
- stateLabels.push(subAgentCount === 1 ? "1 subagent" : `${subAgentCount} subagents`);
87
- }
88
- if (permissionCount > 0) {
89
- stateLabels.push(
90
- permissionCount === 1 ? "1 pending permission" : `${permissionCount} pending permissions`,
91
- );
92
- }
93
- if (!archived && attentionKind === "error") stateLabels.push("failed");
94
- if (!archived && attentionKind === "finished") stateLabels.push("turn finished, unread");
87
+ if (!archived && running) stateLabels.push(m.workspace.state.running);
88
+ if (subAgentCount > 0) stateLabels.push(m.workspace.state.subagents(subAgentCount));
89
+ if (permissionCount > 0) stateLabels.push(m.workspace.state.permissions(permissionCount));
90
+ if (!archived && attentionKind === "error") stateLabels.push(m.workspace.state.failed);
91
+ if (!archived && attentionKind === "finished") stateLabels.push(m.workspace.state.finished);
95
92
  const stateSuffix = stateLabels.length > 0 ? `, ${stateLabels.join(", ")}` : "";
96
93
  const showRunning = running && !archived;
97
94
  const showSubAgentCount = !showRunning && subAgentCount > 0;
@@ -102,7 +99,7 @@ export function AgentRow({
102
99
  <View style={styles.agentIconWrap}>
103
100
  <Icon
104
101
  name={archived ? "BotOff" : "Bot"}
105
- size={18}
102
+ size={ICON_SIZE.leading}
106
103
  color={botColor}
107
104
  />
108
105
  {showRunning ? (
@@ -111,9 +108,7 @@ export function AgentRow({
111
108
  </View>
112
109
  ) : showSubAgentCount ? (
113
110
  <View
114
- accessibilityLabel={
115
- subAgentCount === 1 ? "1 subagent" : `${subAgentCount} subagents`
116
- }
111
+ accessibilityLabel={m.workspace.state.subagents(subAgentCount)}
117
112
  style={styles.subAgentBadge}
118
113
  >
119
114
  <Text style={styles.subAgentBadgeText}>{subAgentLabel}</Text>
@@ -132,12 +127,10 @@ export function AgentRow({
132
127
  </View>
133
128
  {permissionCount > 0 ? (
134
129
  <View
135
- accessibilityLabel={
136
- permissionCount === 1 ? "1 pending permission" : `${permissionCount} pending permissions`
137
- }
130
+ accessibilityLabel={m.workspace.state.permissions(permissionCount)}
138
131
  style={styles.permissionBadge}
139
132
  >
140
- <Icon name="ShieldAlert" size={12} color={theme.colors.statusWarning} />
133
+ <Icon name="ShieldAlert" size={ICON_SIZE.badge} color={theme.colors.statusWarning} />
141
134
  {permissionCount > 1 ? (
142
135
  <Text style={styles.permissionBadgeText}>{permissionCount}</Text>
143
136
  ) : null}
@@ -146,24 +139,24 @@ export function AgentRow({
146
139
  {onArchiveToggle ? (
147
140
  <Pressable
148
141
  accessibilityRole="button"
149
- accessibilityLabel={archived ? `Unarchive ${label}` : `Archive ${label}`}
142
+ accessibilityLabel={archived ? m.workspace.unarchive(label) : m.workspace.archive(label)}
150
143
  accessibilityState={{ disabled: actionDisabled }}
151
144
  disabled={actionDisabled || !showAction}
152
- hitSlop={8}
145
+ hitSlop={CONTROL.hitSlop}
153
146
  onPress={onArchiveToggle}
154
147
  pointerEvents={showAction ? "auto" : "none"}
155
148
  style={[styles.titleAction, { opacity: showAction ? 1 : 0 }]}
156
149
  >
157
150
  {busy ? (
158
151
  <ActivityIndicator
159
- size={14}
152
+ size={ICON_SIZE.inline}
160
153
  color={theme.colors.foregroundMuted}
161
- style={{ width: 14, height: 14 }}
154
+ style={{ width: ICON_SIZE.inline, height: ICON_SIZE.inline }}
162
155
  />
163
156
  ) : (
164
157
  <Icon
165
158
  name={archived ? "ArchiveRestore" : "Archive"}
166
- size={14}
159
+ size={ICON_SIZE.inline}
167
160
  color={theme.colors.foregroundMuted}
168
161
  />
169
162
  )}
@@ -176,7 +169,7 @@ export function AgentRow({
176
169
  return (
177
170
  <Pressable
178
171
  accessibilityRole="link"
179
- accessibilityLabel={`Open conversation ${label}${stateSuffix}`}
172
+ accessibilityLabel={`${m.common.openConversation(label)}${stateSuffix}`}
180
173
  onPress={onOpen}
181
174
  style={styles.agentListRow}
182
175
  {...hoverProps}
@@ -26,6 +26,8 @@ import {
26
26
  } from "./constants.ts";
27
27
  import { formatAgentMeta } from "./filters.ts";
28
28
  import type { WorkspaceTheme } from "./constants.ts";
29
+ import { CONTROL, ICON_SIZE } from "../design-tokens.ts";
30
+ import { useMessages } from "../use-app-language.ts";
29
31
 
30
32
  export type AgentsSectionStyles = AgentRowStyles & {
31
33
  agentsSection: ViewStyle;
@@ -160,6 +162,7 @@ export function AgentsSection({
160
162
  /** Bump when workspace changes to collapse search. */
161
163
  resetKey: string;
162
164
  }): ReactNode {
165
+ const m = useMessages();
163
166
  const [agentSearchOpen, setAgentSearchOpen] = useState(false);
164
167
  const [searchSlotWidth, setSearchSlotWidth] = useState(0);
165
168
  const [pageIndex, setPageIndex] = useState(0);
@@ -225,8 +228,8 @@ export function AgentsSection({
225
228
  else active.push(item);
226
229
  }
227
230
  const groups: Array<[string, AgentUsageItem[]]> = [];
228
- if (active.length > 0) groups.push(["Active", active]);
229
- if (archived.length > 0) groups.push(["Archived", archived]);
231
+ if (active.length > 0) groups.push([m.workspace.options.status.active, active]);
232
+ if (archived.length > 0) groups.push([m.workspace.options.status.archived, archived]);
230
233
  return groups;
231
234
  }
232
235
  const map = new Map<string, AgentUsageItem[]>();
@@ -238,7 +241,7 @@ export function AgentsSection({
238
241
  return [...map.entries()].sort((a, b) =>
239
242
  providerLabel(a[0]).localeCompare(providerLabel(b[0])),
240
243
  );
241
- }, [agentGroup, pageItems]);
244
+ }, [agentGroup, pageItems, m]);
242
245
 
243
246
  const subAgentCounts = useMemo(
244
247
  () => countSubAgentsByParent(agentItems, statusFilters),
@@ -270,7 +273,7 @@ export function AgentsSection({
270
273
  <View style={styles.agentsSection}>
271
274
  <View style={styles.agentsHeaderWrap}>
272
275
  <View style={styles.agentsHeaderRow}>
273
- <Text style={styles.sectionTitle}>Agents</Text>
276
+ <Text style={styles.sectionTitle}>{m.common.agents}</Text>
274
277
  <View
275
278
  style={styles.agentsHeaderSearchSlot}
276
279
  onLayout={(event) => {
@@ -295,28 +298,28 @@ export function AgentsSection({
295
298
  },
296
299
  ]}
297
300
  >
298
- <Icon name="Search" size={14} color={theme.colors.foregroundMuted} />
301
+ <Icon name="Search" size={ICON_SIZE.inline} color={theme.colors.foregroundMuted} />
299
302
  <TextInput
300
303
  ref={searchInputRef as never}
301
304
  value={searchQuery}
302
305
  onChangeText={onSearchQueryChange}
303
- placeholder="Search agents"
306
+ placeholder={m.workspace.searchPlaceholder}
304
307
  placeholderTextColor={theme.colors.foregroundMuted}
305
308
  autoCapitalize="none"
306
309
  autoCorrect={false}
307
310
  returnKeyType="search"
308
311
  editable={agentSearchOpen}
309
312
  style={styles.searchInput}
310
- accessibilityLabel="Search agents by title"
313
+ accessibilityLabel={m.workspace.searchLabel}
311
314
  />
312
315
  </Animated.View>
313
316
  </View>
314
317
  <View style={styles.headerActions}>
315
318
  <Pressable
316
319
  accessibilityRole="button"
317
- accessibilityLabel={agentSearchOpen ? "Close agent search" : "Search agents"}
320
+ accessibilityLabel={agentSearchOpen ? m.workspace.closeSearch : m.workspace.openSearch}
318
321
  accessibilityState={{ expanded: agentSearchOpen }}
319
- hitSlop={8}
322
+ hitSlop={CONTROL.hitSlop}
320
323
  onPress={() => {
321
324
  if (agentSearchOpen) closeAgentSearch();
322
325
  else openAgentSearch();
@@ -325,20 +328,20 @@ export function AgentsSection({
325
328
  >
326
329
  <Icon
327
330
  name={agentSearchOpen ? "X" : "Search"}
328
- size={14}
331
+ size={ICON_SIZE.action}
329
332
  color={theme.colors.foregroundMuted}
330
333
  />
331
334
  </Pressable>
332
335
  <View ref={triggerRef} collapsable={false}>
333
336
  <Pressable
334
337
  accessibilityRole="button"
335
- accessibilityLabel="Agent display options"
338
+ accessibilityLabel={m.workspace.displayOptions}
336
339
  accessibilityState={{ expanded: menuOpen }}
337
- hitSlop={8}
340
+ hitSlop={CONTROL.hitSlop}
338
341
  onPress={onToggleMenu}
339
342
  style={styles.titleAction}
340
343
  >
341
- <Icon name="Settings2" size={14} color={theme.colors.foregroundMuted} />
344
+ <Icon name="Settings2" size={ICON_SIZE.action} color={theme.colors.foregroundMuted} />
342
345
  </Pressable>
343
346
  </View>
344
347
  </View>
@@ -357,38 +360,38 @@ export function AgentsSection({
357
360
  : pageItems.map(renderAgentRow)}
358
361
  {visibleAgentItems.length === 0 ? (
359
362
  <Text style={styles.empty}>
360
- {statusFiltersEmpty ? "No filters selected" : "No matching agents"}
363
+ {statusFiltersEmpty ? m.workspace.noFilters : m.workspace.noMatches}
361
364
  </Text>
362
365
  ) : null}
363
366
  {showPager ? (
364
367
  <View style={styles.pagerRow}>
365
368
  <Pressable
366
369
  accessibilityRole="button"
367
- accessibilityLabel="Previous agents page"
370
+ accessibilityLabel={m.workspace.previousPage}
368
371
  accessibilityState={{ disabled: safePage === 0 }}
369
372
  disabled={safePage === 0}
370
- hitSlop={8}
373
+ hitSlop={CONTROL.hitSlop}
371
374
  onPress={() => setPageIndex((p) => Math.max(0, p - 1))}
372
375
  style={[styles.pagerButton, safePage === 0 ? styles.pagerButtonDisabled : null]}
373
376
  >
374
- <Icon name="ChevronLeft" size={14} color={theme.colors.foregroundMuted} />
377
+ <Icon name="ChevronLeft" size={ICON_SIZE.action} color={theme.colors.foregroundMuted} />
375
378
  </Pressable>
376
379
  <Text style={styles.pagerLabel}>
377
380
  {safePage + 1} / {pageCount}
378
381
  </Text>
379
382
  <Pressable
380
383
  accessibilityRole="button"
381
- accessibilityLabel="Next agents page"
384
+ accessibilityLabel={m.workspace.nextPage}
382
385
  accessibilityState={{ disabled: safePage >= pageCount - 1 }}
383
386
  disabled={safePage >= pageCount - 1}
384
- hitSlop={8}
387
+ hitSlop={CONTROL.hitSlop}
385
388
  onPress={() => setPageIndex((p) => Math.min(pageCount - 1, p + 1))}
386
389
  style={[
387
390
  styles.pagerButton,
388
391
  safePage >= pageCount - 1 ? styles.pagerButtonDisabled : null,
389
392
  ]}
390
393
  >
391
- <Icon name="ChevronRight" size={14} color={theme.colors.foregroundMuted} />
394
+ <Icon name="ChevronRight" size={ICON_SIZE.action} color={theme.colors.foregroundMuted} />
392
395
  </Pressable>
393
396
  </View>
394
397
  ) : null}
@@ -85,7 +85,6 @@ export const SEARCH_TITLE_GAP = 8;
85
85
  /** Host MenuFlyout overlap between root surface and submenu (`SUBMENU_OVERLAP`). */
86
86
  export const MENU_SUBMENU_OVERLAP = 5;
87
87
  export const MENU_WIDTH = 232;
88
- export const MENU_OPTION_ICON_SIZE = 14;
89
88
  /** Approx list-row height (padding + title/meta) for stable Skills/MCP section size. */
90
89
  export const RANK_ROW_ESTIMATE = 42;
91
90
  /** Visible agents per page in Explorer; pager hidden when pageCount ≤ 1. */
@@ -131,11 +130,12 @@ export const LIFECYCLE_FILTER_OPTIONS: ReadonlyArray<
131
130
  { id: "closed", label: "Closed", icon: "CircleOff" },
132
131
  ];
133
132
 
134
- export function optionLabel<T extends string>(
135
- options: ReadonlyArray<{ id: T; label: string }>,
136
- id: T,
137
- ): string {
138
- return options.find((option) => option.id === id)?.label ?? id;
133
+ /** Swap option labels for localized copy (066); ids / icons unchanged. */
134
+ export function localizeOptions<T extends string>(
135
+ options: ReadonlyArray<MenuOption & { id: T }>,
136
+ labels: Record<T, string>,
137
+ ): ReadonlyArray<MenuOption & { id: T }> {
138
+ return options.map((option) => ({ ...option, label: labels[option.id] ?? option.label }));
139
139
  }
140
140
 
141
141
  /** 0 = attention-worthy, then running / idle / initializing / closed (unknown). */
@@ -1,7 +1,8 @@
1
1
  import { Icon } from "@getpaseo/plugin/client/react-native";
2
2
  import type { ReactNode } from "react";
3
3
  import { Pressable, Text, View, type TextStyle, type ViewStyle } from "react-native";
4
- import { MENU_OPTION_ICON_SIZE, type MenuOption } from "./constants.ts";
4
+ import { type MenuOption } from "./constants.ts";
5
+ import { ICON_SIZE } from "../design-tokens.ts";
5
6
 
6
7
  export type MenuStyles = {
7
8
  menuPage: ViewStyle;
@@ -57,7 +58,7 @@ export function MenuSubTrigger({
57
58
  {value}
58
59
  </Text>
59
60
  ) : null}
60
- <Icon name="ChevronRight" size={14} color={chevronColor} />
61
+ <Icon name="ChevronRight" size={ICON_SIZE.inline} color={chevronColor} />
61
62
  </View>
62
63
  </Pressable>
63
64
  </View>
@@ -98,14 +99,14 @@ export function MenuOptionList({
98
99
  ]}
99
100
  >
100
101
  <View style={styles.menuLeadingSlot}>
101
- <Icon name={option.icon} size={MENU_OPTION_ICON_SIZE} color={iconColor} />
102
+ <Icon name={option.icon} size={ICON_SIZE.inline} color={iconColor} />
102
103
  </View>
103
104
  <Text style={styles.menuOptionLabel} numberOfLines={1}>
104
105
  {option.label}
105
106
  </Text>
106
107
  {selected ? (
107
108
  <View style={styles.menuTrailing}>
108
- <Icon name="Check" size={16} color={checkColor} />
109
+ <Icon name="Check" size={ICON_SIZE.action} color={checkColor} />
109
110
  </View>
110
111
  ) : null}
111
112
  </Pressable>
@@ -42,7 +42,7 @@ test("formatAgentMeta joins selected fields; prompt last", () => {
42
42
  assert.equal(formatAgentMeta(item, fields(), byId, "en-US"), null);
43
43
  assert.equal(
44
44
  formatAgentMeta(item, fields("messages", "prompt"), byId, "en-US", "ship it"),
45
- "5 messages · ship it",
45
+ "5 prompts · ship it",
46
46
  );
47
47
  assert.equal(
48
48
  formatAgentMeta(item, fields("prompt"), byId, "en-US", null),
@@ -1,5 +1,6 @@
1
1
  import { matchesAgentTitleSearch } from "../../shared/agent-title-search.ts";
2
2
  import { formatActivityTime } from "../../shared/format.ts";
3
+ import { messagesFor } from "../../shared/i18n.ts";
3
4
  import { providerLabel, type AgentUsageItem } from "../../shared/usage.ts";
4
5
  import {
5
6
  type AgentShowField,
@@ -23,9 +24,10 @@ export function formatAgentMeta(
23
24
  promptPreview?: string | null,
24
25
  ): string | null {
25
26
  const parts: string[] = [];
27
+ const { units } = messagesFor(locale);
26
28
  if (showFields.has("provider")) parts.push(providerLabel(item.provider));
27
- if (showFields.has("calls")) parts.push(`${item.callCount} calls`);
28
- if (showFields.has("messages")) parts.push(`${item.messageCount} messages`);
29
+ if (showFields.has("calls")) parts.push(units.calls(item.callCount));
30
+ if (showFields.has("messages")) parts.push(units.prompts(item.messageCount));
29
31
  if (showFields.has("updated")) {
30
32
  const at = agentUpdatedAt(item, byId);
31
33
  if (at) parts.push(formatActivityTime(at, locale));