@koinzhang/paseo-plugin-activity 0.5.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 (74) hide show
  1. package/CHANGELOG.md +78 -1
  2. package/README.md +15 -8
  3. package/client/activity-heatmap.tsx +126 -93
  4. package/client/agent-creations.tsx +216 -0
  5. package/client/attention-pill.tsx +16 -5
  6. package/client/attention-popover.tsx +19 -23
  7. package/client/color-mix.test.ts +27 -0
  8. package/client/color-mix.ts +38 -0
  9. package/client/design-tokens.test.ts +39 -0
  10. package/client/design-tokens.ts +168 -0
  11. package/client/fit-text.test.ts +41 -0
  12. package/client/fit-text.ts +33 -0
  13. package/client/formatted-time.tsx +4 -4
  14. package/client/global-surface.tsx +316 -275
  15. package/client/header-button.ts +136 -0
  16. package/client/hourly-activity-timeline.tsx +425 -0
  17. package/client/measured-width.ts +72 -0
  18. package/client/panel-visibility.test.ts +25 -0
  19. package/client/panel-visibility.ts +45 -0
  20. package/client/panel.tsx +83 -108
  21. package/client/provider-dropdown.tsx +131 -0
  22. package/client/provider-filter.test.ts +17 -13
  23. package/client/provider-filter.ts +5 -7
  24. package/client/range.test.ts +44 -0
  25. package/client/range.ts +14 -0
  26. package/client/rank-color.test.ts +108 -14
  27. package/client/rank-color.ts +261 -48
  28. package/client/ranking-bars.tsx +291 -0
  29. package/client/ui.tsx +339 -0
  30. package/client/usage-popover.tsx +62 -134
  31. package/client/usage-stats.tsx +137 -8
  32. package/client/use-agent-turn-end.ts +2 -1
  33. package/client/use-app-language.ts +17 -0
  34. package/client/web.ts +73 -18
  35. package/client/workspace/agent-row.tsx +18 -25
  36. package/client/workspace/agents-section.tsx +23 -20
  37. package/client/workspace/constants.ts +6 -6
  38. package/client/workspace/display-menu.tsx +5 -4
  39. package/client/workspace/filters.test.ts +1 -1
  40. package/client/workspace/filters.ts +4 -2
  41. package/client/workspace/panel.tsx +176 -104
  42. package/client/workspace/rank-section.tsx +157 -44
  43. package/client/workspace/terminals-section.tsx +13 -9
  44. package/index.client.tsx +40 -20
  45. package/index.server.ts +63 -31
  46. package/package.json +2 -2
  47. package/paseo-plugin.json +2 -1
  48. package/server/agents.ts +20 -2
  49. package/server/background-sync.test.ts +43 -0
  50. package/server/background-sync.ts +43 -4
  51. package/server/handlers-query.test.ts +252 -1
  52. package/server/handlers.ts +174 -13
  53. package/server/ingest.test.ts +8 -0
  54. package/server/messages.test.ts +96 -1
  55. package/server/prompt-dedupe.ts +52 -0
  56. package/server/rpc-cache.test.ts +74 -0
  57. package/server/rpc-cache.ts +48 -0
  58. package/server/store.test.ts +122 -0
  59. package/server/store.ts +313 -19
  60. package/server/ttl-cache.ts +3 -0
  61. package/shared/activity.test.ts +159 -6
  62. package/shared/activity.ts +140 -5
  63. package/shared/classify.test.ts +1 -0
  64. package/shared/classify.ts +4 -1
  65. package/shared/explorer-agent-display.test.ts +61 -0
  66. package/shared/explorer-agent-display.ts +21 -2
  67. package/shared/format.test.ts +28 -3
  68. package/shared/format.ts +25 -2
  69. package/shared/i18n.test.ts +34 -0
  70. package/shared/i18n.ts +363 -0
  71. package/shared/insights.test.ts +162 -80
  72. package/shared/insights.ts +136 -61
  73. package/shared/usage.test.ts +330 -0
  74. package/shared/usage.ts +471 -0
@@ -232,3 +232,125 @@ test("sqlite: epoch replace deletes canonical user messages", () => {
232
232
  assert.equal(store.selectUserMessages({ agentId: "agent-1" })[0]?.messageId, "real-id");
233
233
  store.close();
234
234
  });
235
+
236
+ for (const driver of ["sqlite", "jsonl"] as const) {
237
+ test(`${driver}: selectRecent / countRows page newest-first with scopes (064)`, () => {
238
+ const store = createUsageStore({ dir: tempDir(), driver });
239
+ store.upsertMany([
240
+ row({ callId: "a", ts: "2026-09-18T01:00:00.000Z", category: "skill", skillName: "alpha", confidence: "exact" }),
241
+ row({ callId: "b", ts: "2026-09-18T03:00:00.000Z", category: "skill", skillName: "low", confidence: "low" }),
242
+ row({ callId: "c", ts: "2026-09-18T02:00:00.000Z", category: "skill", skillName: " ", confidence: "exact" }),
243
+ row({ callId: "d", ts: null, ingestedAt: "2026-09-18T04:00:00.000Z", category: "skill", skillName: "beta", confidence: "inferred" }),
244
+ row({ callId: "e", ts: "2026-09-18T05:00:00.000Z", workspaceId: "ws-2", category: "skill", skillName: "other", confidence: "exact" }),
245
+ row({ callId: "f", ts: "2026-09-18T02:00:00.000Z", category: "mcp", mcpServer: "paseo", mcpTool: "list" }),
246
+ row({ callId: "g", ts: "2026-09-18T06:00:00.000Z", category: "mcp", mcpServer: "paseo", mcpTool: null }),
247
+ ]);
248
+ const skill = { workspaceId: "ws-1", category: "skill" as const };
249
+ assert.deepEqual(
250
+ store.selectRecent(skill, { limit: 10, scope: "skill-named" }).map((r) => r.callId),
251
+ ["d", "a"],
252
+ );
253
+ assert.deepEqual(
254
+ store.selectRecent({ workspaceId: "ws-1", category: "mcp" }, { limit: 10, scope: "mcp-named" })
255
+ .map((r) => r.callId),
256
+ ["f"],
257
+ );
258
+ assert.deepEqual(
259
+ store.selectRecent({ workspaceId: "ws-1" }, { limit: 2, offset: 1 }).map((r) => r.callId),
260
+ ["d", "b"],
261
+ );
262
+ assert.equal(store.countRows({ workspaceId: "ws-1" }), 6);
263
+ assert.equal(store.countRows(skill), 4);
264
+ store.close();
265
+ });
266
+
267
+ test(`${driver}: generation, activity spans and terminal call ids (064)`, () => {
268
+ const store = createUsageStore({ dir: tempDir(), driver });
269
+ const g0 = store.generation();
270
+ store.upsertMany([
271
+ row({ callId: "x", ts: "2026-09-18T05:00:00.000Z", status: "completed", provider: "codex", workspaceId: "late" }),
272
+ row({ callId: "y", ts: "2026-09-18T01:00:00.000Z", status: "running", provider: "claude", workspaceId: "early" }),
273
+ row({ agentId: "agent-2", callId: "z", ts: "2026-09-18T02:00:00.000Z", status: "failed" }),
274
+ ]);
275
+ assert.ok(store.generation() > g0);
276
+ const g1 = store.generation();
277
+ store.select();
278
+ assert.equal(store.generation(), g1, "reads do not bump generation");
279
+ const spans = store.agentActivitySpans().sort((a, b) => a.agentId.localeCompare(b.agentId));
280
+ assert.deepEqual(spans[0], {
281
+ agentId: "agent-1",
282
+ provider: "claude",
283
+ workspaceId: "early",
284
+ firstAt: "2026-09-18T01:00:00.000Z",
285
+ lastAt: "2026-09-18T05:00:00.000Z",
286
+ });
287
+ assert.equal(spans.length, 2);
288
+ assert.deepEqual([...store.terminalCallIds("agent-1")], ["x"]);
289
+ assert.deepEqual([...store.terminalCallIds("agent-2")], ["z"]);
290
+ store.close();
291
+ });
292
+
293
+ test(`${driver}: rescans keep the earliest event time, never after first ingest (074)`, () => {
294
+ const store = createUsageStore({ dir: tempDir(), driver });
295
+ const ts = (callId: string) => store.getRow("agent-1", callId)?.ts ?? null;
296
+ store.upsertMany([
297
+ row({ callId: "known", ts: "2026-09-18T10:00:00.000Z" }),
298
+ row({ callId: "live", ts: null }),
299
+ row({ callId: "live-real", ts: null }),
300
+ ]);
301
+ store.upsertMany([
302
+ row({ callId: "known", ts: "2026-09-20T08:00:00.000Z", ingestedAt: "2026-09-20T08:00:01.000Z" }),
303
+ row({ callId: "live", ts: "2026-09-20T08:00:00.000Z", ingestedAt: "2026-09-20T08:00:01.000Z" }),
304
+ row({ callId: "live-real", ts: "2026-09-18T11:30:00.000Z" }),
305
+ ]);
306
+ assert.equal(ts("known"), "2026-09-18T10:00:00.000Z");
307
+ assert.equal(ts("live"), null);
308
+ assert.equal(ts("live-real"), "2026-09-18T11:30:00.000Z");
309
+ store.upsertMany([row({ callId: "known", ts: "2026-09-18T09:00:00.000Z" }), row({ callId: "known", ts: null })]);
310
+ assert.equal(ts("known"), "2026-09-18T09:00:00.000Z");
311
+
312
+ const message = {
313
+ agentId: "agent-1",
314
+ messageId: "m1",
315
+ workspaceId: "ws",
316
+ provider: "cursor",
317
+ model: null,
318
+ turnId: null,
319
+ seq: 1,
320
+ ts: null,
321
+ ingestedAt: "2026-09-18T12:00:00.000Z",
322
+ };
323
+ store.upsertUserMessages([message]);
324
+ store.upsertUserMessages([{ ...message, ts: "2026-09-20T08:00:00.000Z", ingestedAt: "2026-09-20T08:00:01.000Z" }]);
325
+ assert.equal(store.selectUserMessages({ agentId: "agent-1" })[0]?.ts, null);
326
+ store.upsertUserMessages([{ ...message, ts: "2026-09-18T11:00:00.000Z" }]);
327
+ assert.equal(store.selectUserMessages({ agentId: "agent-1" })[0]?.ts, "2026-09-18T11:00:00.000Z");
328
+ store.close();
329
+ });
330
+
331
+ test(`${driver}: reopening clears event times later than first ingest (074)`, () => {
332
+ const dir = tempDir();
333
+ const store = createUsageStore({ dir, driver });
334
+ store.upsertMany([
335
+ row({ callId: "stamped", ts: "2026-09-20T08:00:00.000Z" }),
336
+ row({ callId: "fine", ts: "2026-09-18T11:00:00.000Z" }),
337
+ ]);
338
+ store.upsertUserMessages([{
339
+ agentId: "agent-1",
340
+ messageId: "m1",
341
+ workspaceId: "ws",
342
+ provider: "cursor",
343
+ model: null,
344
+ turnId: null,
345
+ seq: 1,
346
+ ts: "2026-09-20T08:00:00.000Z",
347
+ ingestedAt: "2026-09-18T12:00:00.000Z",
348
+ }]);
349
+ store.close();
350
+ const reopened = createUsageStore({ dir, driver });
351
+ assert.equal(reopened.getRow("agent-1", "stamped")?.ts, null);
352
+ assert.equal(reopened.getRow("agent-1", "fine")?.ts, "2026-09-18T11:00:00.000Z");
353
+ assert.equal(reopened.selectUserMessages({ agentId: "agent-1" })[0]?.ts, null);
354
+ reopened.close();
355
+ });
356
+ }