@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.
Files changed (68) hide show
  1. package/CHANGELOG.md +50 -1
  2. package/README.md +18 -11
  3. package/client/activity-heatmap.tsx +115 -74
  4. package/client/agent-creations.tsx +100 -90
  5. package/client/attention-pill.tsx +17 -6
  6. package/client/attention-popover.tsx +19 -23
  7. package/client/design-tokens.test.ts +39 -0
  8. package/client/design-tokens.ts +180 -0
  9. package/client/formatted-time.tsx +4 -4
  10. package/client/global-surface.tsx +243 -268
  11. package/client/header-button.ts +136 -0
  12. package/client/hourly-activity-timeline.tsx +153 -103
  13. package/client/panel-visibility.test.ts +25 -0
  14. package/client/panel-visibility.ts +45 -0
  15. package/client/panel.tsx +94 -111
  16. package/client/pill.tsx +1 -1
  17. package/client/provider-dropdown.tsx +134 -0
  18. package/client/provider-filter.test.ts +17 -13
  19. package/client/provider-filter.ts +5 -7
  20. package/client/rank-color.ts +3 -3
  21. package/client/ranking-bars.tsx +294 -0
  22. package/client/sidebar-item.tsx +15 -0
  23. package/client/ui.tsx +351 -0
  24. package/client/usage-popover.tsx +72 -137
  25. package/client/usage-stats.tsx +29 -11
  26. package/client/use-agent-turn-end.ts +2 -1
  27. package/client/use-app-language.ts +17 -0
  28. package/client/web.ts +73 -18
  29. package/client/workspace/agent-row.tsx +28 -28
  30. package/client/workspace/agents-section.tsx +42 -57
  31. package/client/workspace/constants.ts +8 -6
  32. package/client/workspace/display-menu.tsx +6 -5
  33. package/client/workspace/filters.test.ts +1 -1
  34. package/client/workspace/filters.ts +4 -2
  35. package/client/workspace/panel.tsx +96 -104
  36. package/client/workspace/rank-section.tsx +40 -65
  37. package/client/workspace/running-indicator.tsx +1 -1
  38. package/client/workspace/terminals-section.tsx +24 -12
  39. package/index.client.tsx +53 -31
  40. package/index.server.ts +55 -73
  41. package/package.json +3 -3
  42. package/paseo-plugin.json +2 -1
  43. package/server/agents.ts +20 -2
  44. package/server/background-sync.ts +34 -4
  45. package/server/handlers-query.test.ts +27 -1
  46. package/server/handlers.ts +75 -31
  47. package/server/host-types.ts +6 -6
  48. package/server/ingest.test.ts +8 -0
  49. package/server/messages.test.ts +96 -1
  50. package/server/prompt-dedupe.ts +52 -0
  51. package/server/rpc-cache.test.ts +74 -0
  52. package/server/rpc-cache.ts +48 -0
  53. package/server/store.test.ts +122 -0
  54. package/server/store.ts +313 -19
  55. package/server/ttl-cache.ts +3 -0
  56. package/server/turn-ingest.test.ts +180 -0
  57. package/server/turn-ingest.ts +71 -0
  58. package/shared/activity.test.ts +36 -0
  59. package/shared/activity.ts +37 -0
  60. package/shared/classify.test.ts +1 -10
  61. package/shared/classify.ts +3 -10
  62. package/shared/format.ts +10 -7
  63. package/shared/i18n.test.ts +34 -0
  64. package/shared/i18n.ts +363 -0
  65. package/shared/insights.test.ts +120 -81
  66. package/shared/insights.ts +125 -64
  67. package/shared/usage.test.ts +121 -0
  68. package/shared/usage.ts +191 -2
@@ -0,0 +1,180 @@
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
+ /** Press feedback (084): compact controls scale down, text-only targets dim. */
125
+ export const PRESS = {
126
+ /** Icon / compact controls (icon buttons, row actions). */
127
+ scale: 0.94,
128
+ /** Opacity for controls that also scale. */
129
+ opacity: 0.7,
130
+ /** Opacity for text-only targets (tabs, links, text buttons). */
131
+ textOpacity: 0.6,
132
+ } as const;
133
+
134
+ export const iconButton: ViewStyle = {
135
+ width: CONTROL.iconButton,
136
+ height: CONTROL.iconButton,
137
+ alignItems: "center",
138
+ justifyContent: "center",
139
+ borderRadius: RADIUS.control,
140
+ flexShrink: 0,
141
+ };
142
+
143
+ /**
144
+ * Global chart motion (081): `grow` for bars reaching a new value, `reveal` /
145
+ * `refresh` for the heatmap's first column sweep and later metric / range
146
+ * switches. `refreshFloor` is the lowest column opacity during a refresh.
147
+ * `disclose` is the ranking Show more / Show less height transition; exits
148
+ * (`discloseClose`) stay faster than enters. `step` / `stepOffset` slide the
149
+ * metric switch label in from the pressed side.
150
+ */
151
+ export const CHART_MOTION = {
152
+ grow: 400,
153
+ disclose: 250,
154
+ discloseClose: 180,
155
+ step: 200,
156
+ stepOffset: 12,
157
+ reveal: 700,
158
+ refresh: 450,
159
+ refreshFloor: 0.3,
160
+ columnSpan: 0.35,
161
+ } as const;
162
+
163
+ /** Composer popover content frame, shared by the Activity and Attention pills. */
164
+ export const POPOVER_WIDTH = { min: 300, max: 380 } as const;
165
+
166
+ export function popoverFrame(compact: boolean): ViewStyle {
167
+ return compact ? {} : { minWidth: POPOVER_WIDTH.min, maxWidth: POPOVER_WIDTH.max };
168
+ }
169
+
170
+ /** Floating chart tooltip container (heatmap, creations histogram). */
171
+ export function tooltipSurface(colors: { surface2: string; border: string }): ViewStyle {
172
+ return {
173
+ paddingHorizontal: 10,
174
+ paddingVertical: 6,
175
+ borderRadius: RADIUS.overlay,
176
+ backgroundColor: colors.surface2,
177
+ borderWidth: 1,
178
+ borderColor: colors.border,
179
+ };
180
+ }
@@ -10,14 +10,14 @@ import { useAppLanguage } from "./use-app-language.ts";
10
10
  export function FormattedTime({
11
11
  iso,
12
12
  style,
13
- prefix,
13
+ format,
14
14
  }: {
15
15
  iso: string | null | undefined;
16
16
  style?: TextStyle;
17
- /** e.g. `"Last "` — concatenated before the stamp */
18
- prefix?: string;
17
+ /** Wraps the stamp in localized copy, e.g. `messages.common.lastUsed`. */
18
+ format?: (stamp: string) => string;
19
19
  }): ReactNode {
20
20
  const locale = useAppLanguage();
21
21
  const stamp = formatActivityTime(iso, locale);
22
- return <Text style={style}>{prefix ? `${prefix}${stamp}` : stamp}</Text>;
22
+ return <Text style={style}>{format ? format(stamp) : stamp}</Text>;
23
23
  }