@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.
- package/CHANGELOG.md +26 -1
- package/README.md +23 -9
- package/client/formatted-time.tsx +23 -0
- package/client/hidden-pill-recheck.test.ts +33 -0
- package/client/hidden-pill-recheck.ts +22 -0
- package/client/panel.tsx +115 -107
- package/client/pill-directory.test.ts +92 -0
- package/client/pill-directory.ts +79 -0
- package/client/pill.tsx +23 -23
- package/client/usage-popover.tsx +75 -84
- package/client/usage-query.tsx +8 -3
- package/client/usage-stats.tsx +2 -2
- package/client/use-agent-turn-end.ts +69 -0
- package/client/workspace/agent-row.tsx +57 -7
- package/client/workspace/agents-section.tsx +7 -0
- package/client/workspace/constants.ts +29 -3
- package/client/workspace/filters.ts +2 -2
- package/client/workspace/list-host-agents.test.ts +45 -0
- package/client/workspace/list-host-agents.ts +55 -22
- package/client/workspace/panel.tsx +172 -8
- package/client/workspace/rank-section.tsx +36 -26
- package/client/workspace/running-indicator.tsx +54 -0
- package/client/workspace/status-cache.test.ts +62 -0
- package/client/workspace/status-cache.ts +19 -0
- package/client/workspace/terminal-preview.test.ts +17 -0
- package/client/workspace/terminal-preview.ts +10 -0
- package/client/workspace/terminals-section.tsx +155 -0
- package/index.server.ts +2 -0
- package/package.json +3 -3
- package/server/agents.test.ts +16 -0
- package/server/agents.ts +7 -4
- package/server/handlers-query.test.ts +24 -3
- package/server/handlers.ts +17 -5
- package/server/skill-path.ts +3 -20
- package/shared/format.test.ts +35 -31
- package/shared/format.ts +21 -36
- package/shared/home-path.ts +19 -0
- 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(
|
|
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(
|
|
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
|
-
*
|
|
25
|
-
*
|
|
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
|
|
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
|
|
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 (
|
|
66
|
-
options.
|
|
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",
|