@koinzhang/paseo-plugin-activity 0.2.0 → 0.4.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 +50 -1
- package/README.md +26 -11
- package/client/attention-agents.test.ts +94 -0
- package/client/attention-agents.ts +67 -0
- package/client/attention-pill.tsx +254 -0
- package/client/attention-popover.tsx +161 -0
- package/client/attention-status-store.ts +47 -0
- package/client/formatted-time.tsx +23 -0
- package/client/global-surface.tsx +3 -1
- package/client/hidden-pill-recheck.test.ts +33 -0
- package/client/hidden-pill-recheck.ts +22 -0
- package/client/latest-user-message.test.ts +34 -0
- package/client/latest-user-message.ts +96 -0
- package/client/open-agent.ts +32 -0
- package/client/panel.tsx +117 -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 +72 -0
- package/client/use-latest-user-message.ts +15 -0
- package/client/use-workspace-agent-statuses.ts +47 -0
- package/client/workspace/agent-live-status-sync.tsx +103 -0
- package/client/workspace/agent-row.tsx +105 -28
- package/client/workspace/agents-section.tsx +92 -17
- package/client/workspace/constants.test.ts +66 -0
- package/client/workspace/constants.ts +66 -4
- package/client/workspace/filters.test.ts +59 -0
- package/client/workspace/filters.ts +11 -2
- package/client/workspace/list-host-agents.test.ts +103 -0
- package/client/workspace/list-host-agents.ts +113 -23
- package/client/workspace/panel.tsx +192 -12
- 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 +23 -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.client.tsx +7 -1
- 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/explorer-agent-display.ts +1 -1
- package/shared/format.test.ts +35 -31
- package/shared/format.ts +21 -36
- package/shared/home-path.ts +19 -0
- package/shared/usage.test.ts +8 -2
- package/shared/usage.ts +16 -0
package/server/skill-path.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { existsSync, readdirSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
+
import { collapseHomePath } from "../shared/home-path.ts";
|
|
3
4
|
import { createKeyedTtlCache } from "./ttl-cache.ts";
|
|
4
5
|
|
|
6
|
+
export { collapseHomePath };
|
|
7
|
+
|
|
5
8
|
/** Expand a leading `~` / `~/…` to an absolute path under `homeDir`. */
|
|
6
9
|
export function expandHomePath(path: string, homeDir: string): string {
|
|
7
10
|
const trimmed = path.trim();
|
|
@@ -10,26 +13,6 @@ export function expandHomePath(path: string, homeDir: string): string {
|
|
|
10
13
|
return trimmed;
|
|
11
14
|
}
|
|
12
15
|
|
|
13
|
-
/** Collapse `homeDir` prefix to `~` so RPC/UI never expose `/Users/…`. */
|
|
14
|
-
export function collapseHomePath(path: string, homeDir: string): string {
|
|
15
|
-
const trimmed = path.trim();
|
|
16
|
-
if (!trimmed || !homeDir) return trimmed;
|
|
17
|
-
if (trimmed === homeDir) return "~";
|
|
18
|
-
const prefix = homeDir.endsWith("/") ? homeDir : `${homeDir}/`;
|
|
19
|
-
if (trimmed.startsWith(prefix)) {
|
|
20
|
-
return `~/${trimmed.slice(prefix.length)}`;
|
|
21
|
-
}
|
|
22
|
-
// Case-insensitive match (macOS default FS); preserve the remainder as-is.
|
|
23
|
-
const lower = trimmed.toLowerCase();
|
|
24
|
-
const homeLower = homeDir.toLowerCase();
|
|
25
|
-
if (lower === homeLower) return "~";
|
|
26
|
-
const prefixLower = homeLower.endsWith("/") ? homeLower : `${homeLower}/`;
|
|
27
|
-
if (lower.startsWith(prefixLower)) {
|
|
28
|
-
return `~/${trimmed.slice(prefixLower.length)}`;
|
|
29
|
-
}
|
|
30
|
-
return trimmed;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
16
|
const rootListingCache = createKeyedTtlCache<string[]>(30_000);
|
|
34
17
|
|
|
35
18
|
function listRootEntries(root: string): string[] {
|
|
@@ -9,7 +9,7 @@ export const explorerAgentDisplaySettings = defineSettings({
|
|
|
9
9
|
schema: z.object({
|
|
10
10
|
sort: z.enum(["created", "updated", "name", "messages", "status"]).default("updated"),
|
|
11
11
|
group: z.enum(["none", "provider", "status"]).default("none"),
|
|
12
|
-
show: z.array(z.enum(["provider", "calls", "messages", "updated"])).default([]),
|
|
12
|
+
show: z.array(z.enum(["provider", "calls", "messages", "updated", "prompt"])).default([]),
|
|
13
13
|
status: z.array(z.enum(["active", "archived"])).default(["active"]),
|
|
14
14
|
lifecycle: z
|
|
15
15
|
.array(z.enum(["idle", "running", "error", "closed"]))
|
package/shared/format.test.ts
CHANGED
|
@@ -1,52 +1,56 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import { describe, it } from "node:test";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
formatActivityTime,
|
|
5
|
+
formatDisplayName,
|
|
6
|
+
formatLocalDateTime,
|
|
7
|
+
formatUpdatedAt,
|
|
8
|
+
} from "./format.ts";
|
|
4
9
|
|
|
5
10
|
const NOW = new Date(2026, 8, 18, 15, 30);
|
|
6
11
|
|
|
7
|
-
describe("
|
|
8
|
-
it("shows only
|
|
9
|
-
|
|
10
|
-
assert.
|
|
12
|
+
describe("formatActivityTime", () => {
|
|
13
|
+
it("shows only the time for the same local day", () => {
|
|
14
|
+
const text = formatActivityTime(new Date(2026, 8, 18, 9, 5).toISOString(), "en", NOW);
|
|
15
|
+
assert.match(text, /09:05|9:05/);
|
|
16
|
+
assert.doesNotMatch(text, /Sep/);
|
|
17
|
+
assert.doesNotMatch(text, /\bAM\b|\bPM\b/i);
|
|
11
18
|
});
|
|
12
19
|
|
|
13
|
-
it("adds
|
|
14
|
-
|
|
15
|
-
assert.equal(formatDayTime(new Date(2026, 0, 3, 0, 7).toISOString(), NOW), "01-03 00:07");
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it("adds the year for a different year", () => {
|
|
19
|
-
assert.equal(
|
|
20
|
-
formatDayTime(new Date(2025, 11, 31, 23, 59).toISOString(), NOW),
|
|
21
|
-
"2025-12-31 23:59",
|
|
22
|
-
);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it("returns the placeholder for empty and keeps invalid input", () => {
|
|
26
|
-
assert.equal(formatDayTime(null, NOW), "—");
|
|
27
|
-
assert.equal(formatDayTime(undefined, NOW), "—");
|
|
28
|
-
assert.equal(formatDayTime("not-a-date", NOW), "not-a-date");
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
describe("formatUpdatedAt", () => {
|
|
33
|
-
it("uses locale month/day + time for the same year", () => {
|
|
34
|
-
const text = formatUpdatedAt(new Date(2026, 8, 17, 14, 2).toISOString(), "en", NOW);
|
|
20
|
+
it("adds month/day for another day in the same year", () => {
|
|
21
|
+
const text = formatActivityTime(new Date(2026, 8, 17, 14, 2).toISOString(), "en", NOW);
|
|
35
22
|
assert.match(text, /Sep/);
|
|
36
23
|
assert.match(text, /17/);
|
|
24
|
+
assert.match(text, /14:02/);
|
|
37
25
|
assert.doesNotMatch(text, /2026/);
|
|
26
|
+
assert.doesNotMatch(text, /\bAM\b|\bPM\b/i);
|
|
38
27
|
});
|
|
39
28
|
|
|
40
29
|
it("includes the year when the date is not this year", () => {
|
|
41
|
-
const text =
|
|
30
|
+
const text = formatActivityTime(new Date(2025, 11, 31, 23, 59).toISOString(), "en", NOW);
|
|
42
31
|
assert.match(text, /2025/);
|
|
43
32
|
assert.match(text, /Dec/);
|
|
33
|
+
assert.match(text, /23:59/);
|
|
34
|
+
assert.doesNotMatch(text, /\bAM\b|\bPM\b/i);
|
|
44
35
|
});
|
|
45
36
|
|
|
46
37
|
it("returns the placeholder for empty and keeps invalid input", () => {
|
|
47
|
-
assert.equal(
|
|
48
|
-
assert.equal(
|
|
49
|
-
assert.equal(
|
|
38
|
+
assert.equal(formatActivityTime(null, "en", NOW), "—");
|
|
39
|
+
assert.equal(formatActivityTime(undefined, "en", NOW), "—");
|
|
40
|
+
assert.equal(formatActivityTime("not-a-date", "en", NOW), "not-a-date");
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("keeps formatUpdatedAt as an alias", () => {
|
|
44
|
+
assert.equal(formatUpdatedAt, formatActivityTime);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
describe("formatLocalDateTime", () => {
|
|
49
|
+
it("defaults to English locale style", () => {
|
|
50
|
+
const text = formatLocalDateTime(new Date(2026, 8, 17, 14, 2).toISOString());
|
|
51
|
+
assert.match(text, /Sep/);
|
|
52
|
+
assert.match(text, /17/);
|
|
53
|
+
assert.match(text, /2026/);
|
|
50
54
|
});
|
|
51
55
|
});
|
|
52
56
|
|
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.test.ts
CHANGED
|
@@ -870,6 +870,7 @@ describe("aggregateAgents (024)", () => {
|
|
|
870
870
|
createdAt: "2026-09-18T00:00:00.000Z",
|
|
871
871
|
},
|
|
872
872
|
{ agentId: "a3", provider: "codex", title: "Idle", createdAt: "2026-09-19T00:00:00.000Z", updatedAt: "2026-09-19T02:00:00.000Z", archivedAt: "2026-09-19T01:00:00.000Z" },
|
|
873
|
+
{ agentId: "a4", provider: "codex", title: "Child", createdAt: "2026-09-19T03:00:00.000Z", parentAgentId: "a1" },
|
|
873
874
|
],
|
|
874
875
|
[
|
|
875
876
|
{ agentId: "a1", provider: "claude/opus", ts: "2026-09-18T05:00:00.000Z" },
|
|
@@ -880,7 +881,7 @@ describe("aggregateAgents (024)", () => {
|
|
|
880
881
|
|
|
881
882
|
assert.deepEqual(
|
|
882
883
|
items.map((item) => item.agentId),
|
|
883
|
-
["a1", "a2", "a3"],
|
|
884
|
+
["a1", "a2", "a4", "a3"],
|
|
884
885
|
);
|
|
885
886
|
|
|
886
887
|
const a1 = items[0]!;
|
|
@@ -896,6 +897,7 @@ describe("aggregateAgents (024)", () => {
|
|
|
896
897
|
assert.equal(a1.messageCount, 2);
|
|
897
898
|
assert.equal(a1.archivedAt, null);
|
|
898
899
|
assert.equal(a1.updatedAt, null);
|
|
900
|
+
assert.equal(a1.parentAgentId, null);
|
|
899
901
|
assert.equal(a1.lastActivityAt, "2026-09-18T06:00:00.000Z");
|
|
900
902
|
|
|
901
903
|
const a2 = items[1]!;
|
|
@@ -904,7 +906,11 @@ describe("aggregateAgents (024)", () => {
|
|
|
904
906
|
assert.equal(a2.messageCount, 1);
|
|
905
907
|
assert.equal(a2.lastActivityAt, "2026-09-18T00:00:00.000Z");
|
|
906
908
|
|
|
907
|
-
const
|
|
909
|
+
const a4 = items[2]!;
|
|
910
|
+
assert.equal(a4.parentAgentId, "a1");
|
|
911
|
+
assert.equal(a4.title, "Child");
|
|
912
|
+
|
|
913
|
+
const a3 = items[3]!;
|
|
908
914
|
assert.equal(a3.callCount, 0);
|
|
909
915
|
assert.equal(a3.messageCount, 0);
|
|
910
916
|
assert.equal(a3.title, "Idle");
|
package/shared/usage.ts
CHANGED
|
@@ -227,6 +227,8 @@ export const AgentUsageItemSchema = z.object({
|
|
|
227
227
|
updatedAt: z.string().nullable(),
|
|
228
228
|
/** Registry archive time; null for active agents (025). */
|
|
229
229
|
archivedAt: z.string().nullable(),
|
|
230
|
+
/** Registry parent session; null for top-level agents (041). */
|
|
231
|
+
parentAgentId: z.string().nullable(),
|
|
230
232
|
/** Latest tool call / message time in the window. */
|
|
231
233
|
lastActivityAt: z.string().nullable(),
|
|
232
234
|
});
|
|
@@ -256,6 +258,15 @@ export const usageAgentUnarchiveRpc = defineRpc({
|
|
|
256
258
|
}),
|
|
257
259
|
});
|
|
258
260
|
|
|
261
|
+
/** Host paths for display-only formatting (e.g. collapsing `homeDir` to `~`). */
|
|
262
|
+
export const usageHostInfoRpc = defineRpc({
|
|
263
|
+
name: "usage.host-info",
|
|
264
|
+
input: z.object({}),
|
|
265
|
+
output: z.object({
|
|
266
|
+
homeDir: z.string(),
|
|
267
|
+
}),
|
|
268
|
+
});
|
|
269
|
+
|
|
259
270
|
const PROVIDER_LABELS: Record<string, string> = {
|
|
260
271
|
claude: "Claude",
|
|
261
272
|
opencode: "OpenCode",
|
|
@@ -657,6 +668,7 @@ export function aggregateAgents(
|
|
|
657
668
|
createdAt?: string | null;
|
|
658
669
|
updatedAt?: string | null;
|
|
659
670
|
archivedAt?: string | null;
|
|
671
|
+
parentAgentId?: string | null;
|
|
660
672
|
}> = [],
|
|
661
673
|
messages: ReadonlyArray<{
|
|
662
674
|
agentId?: string;
|
|
@@ -685,6 +697,7 @@ export function aggregateAgents(
|
|
|
685
697
|
createdAt: null,
|
|
686
698
|
updatedAt: null,
|
|
687
699
|
archivedAt: null,
|
|
700
|
+
parentAgentId: null,
|
|
688
701
|
lastActivityAt: null,
|
|
689
702
|
};
|
|
690
703
|
map.set(agentId, acc);
|
|
@@ -717,6 +730,9 @@ export function aggregateAgents(
|
|
|
717
730
|
acc.createdAt = agent.createdAt ?? acc.createdAt;
|
|
718
731
|
acc.updatedAt = agent.updatedAt ?? acc.updatedAt;
|
|
719
732
|
acc.archivedAt = agent.archivedAt ?? acc.archivedAt;
|
|
733
|
+
if (agent.parentAgentId !== undefined) {
|
|
734
|
+
acc.parentAgentId = agent.parentAgentId?.trim() || null;
|
|
735
|
+
}
|
|
720
736
|
}
|
|
721
737
|
|
|
722
738
|
for (const message of messages) {
|