@koinzhang/paseo-plugin-activity 0.2.0 → 0.3.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 (38) hide show
  1. package/CHANGELOG.md +26 -1
  2. package/README.md +23 -9
  3. package/client/formatted-time.tsx +23 -0
  4. package/client/hidden-pill-recheck.test.ts +33 -0
  5. package/client/hidden-pill-recheck.ts +22 -0
  6. package/client/panel.tsx +115 -107
  7. package/client/pill-directory.test.ts +92 -0
  8. package/client/pill-directory.ts +79 -0
  9. package/client/pill.tsx +23 -23
  10. package/client/usage-popover.tsx +75 -84
  11. package/client/usage-query.tsx +8 -3
  12. package/client/usage-stats.tsx +2 -2
  13. package/client/use-agent-turn-end.ts +69 -0
  14. package/client/workspace/agent-row.tsx +57 -7
  15. package/client/workspace/agents-section.tsx +7 -0
  16. package/client/workspace/constants.ts +29 -3
  17. package/client/workspace/filters.ts +2 -2
  18. package/client/workspace/list-host-agents.test.ts +45 -0
  19. package/client/workspace/list-host-agents.ts +55 -22
  20. package/client/workspace/panel.tsx +172 -8
  21. package/client/workspace/rank-section.tsx +36 -26
  22. package/client/workspace/running-indicator.tsx +54 -0
  23. package/client/workspace/status-cache.test.ts +62 -0
  24. package/client/workspace/status-cache.ts +19 -0
  25. package/client/workspace/terminal-preview.test.ts +17 -0
  26. package/client/workspace/terminal-preview.ts +10 -0
  27. package/client/workspace/terminals-section.tsx +155 -0
  28. package/index.server.ts +2 -0
  29. package/package.json +3 -3
  30. package/server/agents.test.ts +16 -0
  31. package/server/agents.ts +7 -4
  32. package/server/handlers-query.test.ts +24 -3
  33. package/server/handlers.ts +17 -5
  34. package/server/skill-path.ts +3 -20
  35. package/shared/format.test.ts +35 -31
  36. package/shared/format.ts +21 -36
  37. package/shared/home-path.ts +19 -0
  38. package/shared/usage.ts +9 -0
package/shared/format.ts CHANGED
@@ -1,18 +1,17 @@
1
1
  /** Format stored ISO timestamps for UI / export in the local timezone + locale. */
2
- export function formatLocalDateTime(iso: string | null | undefined): string {
2
+ export function formatLocalDateTime(
3
+ iso: string | null | undefined,
4
+ locale = "en",
5
+ ): string {
3
6
  if (!iso) return "—";
4
7
  const date = new Date(iso);
5
8
  if (Number.isNaN(date.getTime())) return iso;
6
- return date.toLocaleString(undefined, {
9
+ return date.toLocaleString(locale, {
7
10
  dateStyle: "medium",
8
11
  timeStyle: "short",
9
12
  });
10
13
  }
11
14
 
12
- function pad2(value: number): string {
13
- return String(value).padStart(2, "0");
14
- }
15
-
16
15
  /** Display-name prettifier: `-` / `_` → spaces, then Title Case each word. */
17
16
  export function formatDisplayName(value: string): string {
18
17
  const cleaned = value.replace(/[-_]+/g, " ").replace(/\s+/g, " ").trim();
@@ -21,49 +20,35 @@ export function formatDisplayName(value: string): string {
21
20
  }
22
21
 
23
22
  /**
24
- * Compact 24-hour timestamp for list rows:
25
- * today → `HH:mm`; same year → `MM-DD HH:mm`; otherwise → `YYYY-MM-DD HH:mm`.
23
+ * Activity UI timestamp: app locale + local timezone.
24
+ * Today → time only; same year → month/day + time; otherwise year + month/day + time.
26
25
  */
27
- export function formatDayTime(
26
+ export function formatActivityTime(
28
27
  iso: string | null | undefined,
28
+ locale = "en",
29
29
  now: Date = new Date(),
30
30
  ): string {
31
31
  if (!iso) return "—";
32
32
  const date = new Date(iso);
33
33
  if (Number.isNaN(date.getTime())) return iso;
34
- const time = `${pad2(date.getHours())}:${pad2(date.getMinutes())}`;
35
- if (
34
+ const sameDay =
36
35
  date.getFullYear() === now.getFullYear() &&
37
36
  date.getMonth() === now.getMonth() &&
38
- date.getDate() === now.getDate()
39
- ) {
40
- return time;
41
- }
42
- const monthDay = `${pad2(date.getMonth() + 1)}-${pad2(date.getDate())}`;
43
- if (date.getFullYear() === now.getFullYear()) return `${monthDay} ${time}`;
44
- return `${date.getFullYear()}-${monthDay} ${time}`;
45
- }
46
-
47
- /**
48
- * Agent list "Updated" stamp: app locale + local timezone.
49
- * Same calendar year → month/day + time; otherwise also includes the year.
50
- */
51
- export function formatUpdatedAt(
52
- iso: string | null | undefined,
53
- locale = "en",
54
- now: Date = new Date(),
55
- ): string {
56
- if (!iso) return "—";
57
- const date = new Date(iso);
58
- if (Number.isNaN(date.getTime())) return iso;
37
+ date.getDate() === now.getDate();
59
38
  const options: Intl.DateTimeFormatOptions = {
60
- month: "short",
61
- day: "numeric",
62
39
  hour: "numeric",
63
40
  minute: "2-digit",
41
+ hour12: false,
64
42
  };
65
- if (date.getFullYear() !== now.getFullYear()) {
66
- options.year = "numeric";
43
+ if (!sameDay) {
44
+ options.month = "short";
45
+ options.day = "numeric";
46
+ if (date.getFullYear() !== now.getFullYear()) {
47
+ options.year = "numeric";
48
+ }
67
49
  }
68
50
  return date.toLocaleString(locale, options);
69
51
  }
52
+
53
+ /** @deprecated Prefer `formatActivityTime`. */
54
+ export const formatUpdatedAt = formatActivityTime;
@@ -0,0 +1,19 @@
1
+ /** Collapse `homeDir` prefix to `~` so RPC/UI never expose `/Users/…`. */
2
+ export function collapseHomePath(path: string, homeDir: string): string {
3
+ const trimmed = path.trim();
4
+ if (!trimmed || !homeDir) return trimmed;
5
+ if (trimmed === homeDir) return "~";
6
+ const prefix = homeDir.endsWith("/") ? homeDir : `${homeDir}/`;
7
+ if (trimmed.startsWith(prefix)) {
8
+ return `~/${trimmed.slice(prefix.length)}`;
9
+ }
10
+ // Case-insensitive match (macOS default FS); preserve the remainder as-is.
11
+ const lower = trimmed.toLowerCase();
12
+ const homeLower = homeDir.toLowerCase();
13
+ if (lower === homeLower) return "~";
14
+ const prefixLower = homeLower.endsWith("/") ? homeLower : `${homeLower}/`;
15
+ if (lower.startsWith(prefixLower)) {
16
+ return `~/${trimmed.slice(prefixLower.length)}`;
17
+ }
18
+ return trimmed;
19
+ }
package/shared/usage.ts CHANGED
@@ -256,6 +256,15 @@ export const usageAgentUnarchiveRpc = defineRpc({
256
256
  }),
257
257
  });
258
258
 
259
+ /** Host paths for display-only formatting (e.g. collapsing `homeDir` to `~`). */
260
+ export const usageHostInfoRpc = defineRpc({
261
+ name: "usage.host-info",
262
+ input: z.object({}),
263
+ output: z.object({
264
+ homeDir: z.string(),
265
+ }),
266
+ });
267
+
259
268
  const PROVIDER_LABELS: Record<string, string> = {
260
269
  claude: "Claude",
261
270
  opencode: "OpenCode",