@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
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Icon } from "@getpaseo/plugin/client/react-native";
|
|
2
2
|
import type { ReactNode } from "react";
|
|
3
3
|
import { Pressable, Text, View, type TextStyle, type ViewStyle } from "react-native";
|
|
4
|
-
import { formatDisplayName
|
|
4
|
+
import { formatDisplayName } from "../../shared/format.ts";
|
|
5
5
|
import type { McpByToolItem, SkillByNameItem } from "../../shared/usage.ts";
|
|
6
|
+
import { FormattedTime } from "../formatted-time.tsx";
|
|
6
7
|
import { RANK_ROW_ESTIMATE } from "./constants.ts";
|
|
7
8
|
|
|
8
9
|
type RankKind = "skills" | "mcp";
|
|
@@ -43,6 +44,7 @@ export type RankSectionStyles = {
|
|
|
43
44
|
export function RankSection({
|
|
44
45
|
rankKind,
|
|
45
46
|
onToggleKind,
|
|
47
|
+
showToggle = true,
|
|
46
48
|
skillItems,
|
|
47
49
|
mcpItems,
|
|
48
50
|
mutedColor,
|
|
@@ -50,30 +52,37 @@ export function RankSection({
|
|
|
50
52
|
}: {
|
|
51
53
|
rankKind: RankKind;
|
|
52
54
|
onToggleKind: () => void;
|
|
55
|
+
showToggle?: boolean;
|
|
53
56
|
skillItems: ReadonlyArray<SkillByNameItem>;
|
|
54
57
|
mcpItems: ReadonlyArray<McpByToolItem>;
|
|
55
58
|
mutedColor: string;
|
|
56
59
|
styles: RankSectionStyles;
|
|
57
60
|
}): ReactNode {
|
|
61
|
+
if (skillItems.length === 0 && mcpItems.length === 0) return null;
|
|
62
|
+
|
|
63
|
+
const items = rankKind === "skills" ? skillItems : mcpItems;
|
|
64
|
+
|
|
58
65
|
return (
|
|
59
66
|
<View style={{ gap: 12 }}>
|
|
60
67
|
<View style={styles.sectionHeaderRow}>
|
|
61
68
|
<Text style={styles.sectionTitle}>{rankTitle(rankKind)}</Text>
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
{showToggle ? (
|
|
70
|
+
<Pressable
|
|
71
|
+
accessibilityRole="button"
|
|
72
|
+
accessibilityLabel={rankAction(rankKind).accessibilityLabel}
|
|
73
|
+
hitSlop={8}
|
|
74
|
+
onPress={onToggleKind}
|
|
75
|
+
style={styles.titleAction}
|
|
76
|
+
>
|
|
77
|
+
<Icon name={rankAction(rankKind).icon} size={16} color={mutedColor} />
|
|
78
|
+
</Pressable>
|
|
79
|
+
) : null}
|
|
71
80
|
</View>
|
|
72
81
|
<View
|
|
73
82
|
style={[
|
|
74
83
|
styles.panel,
|
|
75
84
|
{
|
|
76
|
-
minHeight: Math.max(
|
|
85
|
+
minHeight: Math.max(items.length, 1) * RANK_ROW_ESTIMATE,
|
|
77
86
|
},
|
|
78
87
|
]}
|
|
79
88
|
>
|
|
@@ -85,9 +94,11 @@ export function RankSection({
|
|
|
85
94
|
<Text style={styles.listTitle} numberOfLines={1}>
|
|
86
95
|
{formatDisplayName(item.skillName)}
|
|
87
96
|
</Text>
|
|
88
|
-
<
|
|
89
|
-
|
|
90
|
-
|
|
97
|
+
<FormattedTime
|
|
98
|
+
iso={item.lastUsedAt}
|
|
99
|
+
prefix="Last "
|
|
100
|
+
style={styles.listMeta}
|
|
101
|
+
/>
|
|
91
102
|
</View>
|
|
92
103
|
<CountText value={item.total} styles={styles} />
|
|
93
104
|
</View>
|
|
@@ -99,22 +110,21 @@ export function RankSection({
|
|
|
99
110
|
<Text style={styles.listTitle} numberOfLines={1}>
|
|
100
111
|
{formatDisplayName(`${item.server}.${item.tool}`)}
|
|
101
112
|
</Text>
|
|
102
|
-
|
|
103
|
-
{item.failures >
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
113
|
+
{item.failures > 0 ? (
|
|
114
|
+
<Text style={styles.listMeta}>{item.failures} failed</Text>
|
|
115
|
+
) : item.lastUsedAt ? (
|
|
116
|
+
<FormattedTime
|
|
117
|
+
iso={item.lastUsedAt}
|
|
118
|
+
prefix="Last "
|
|
119
|
+
style={styles.listMeta}
|
|
120
|
+
/>
|
|
121
|
+
) : (
|
|
122
|
+
<Text style={styles.listMeta}>—</Text>
|
|
123
|
+
)}
|
|
109
124
|
</View>
|
|
110
125
|
<CountText value={item.count} styles={styles} />
|
|
111
126
|
</View>
|
|
112
127
|
))}
|
|
113
|
-
{(rankKind === "skills" ? skillItems.length : mcpItems.length) === 0 ? (
|
|
114
|
-
<Text style={styles.empty}>
|
|
115
|
-
{rankKind === "skills" ? "No skills yet" : "No MCP yet"}
|
|
116
|
-
</Text>
|
|
117
|
-
) : null}
|
|
118
128
|
</View>
|
|
119
129
|
</View>
|
|
120
130
|
);
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { useEffect, useRef, type ReactNode } from "react";
|
|
2
|
+
import { Animated, Easing, type ViewStyle } from "react-native";
|
|
3
|
+
import type { WorkspaceTheme } from "./constants.ts";
|
|
4
|
+
|
|
5
|
+
const SPIN_SIZE = 10;
|
|
6
|
+
const SPIN_DURATION_MS = 800;
|
|
7
|
+
|
|
8
|
+
/** Host-style running ring: border-colored track with an accent arc, rotating. */
|
|
9
|
+
export function RunningIndicator({
|
|
10
|
+
theme,
|
|
11
|
+
style,
|
|
12
|
+
}: {
|
|
13
|
+
theme: WorkspaceTheme;
|
|
14
|
+
style?: ViewStyle;
|
|
15
|
+
}): ReactNode {
|
|
16
|
+
const spin = useRef(new Animated.Value(0)).current;
|
|
17
|
+
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
const animation = Animated.loop(
|
|
20
|
+
Animated.timing(spin, {
|
|
21
|
+
toValue: 1,
|
|
22
|
+
duration: SPIN_DURATION_MS,
|
|
23
|
+
easing: Easing.linear,
|
|
24
|
+
useNativeDriver: false,
|
|
25
|
+
}),
|
|
26
|
+
);
|
|
27
|
+
animation.start();
|
|
28
|
+
return () => animation.stop();
|
|
29
|
+
}, [spin]);
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<Animated.View
|
|
33
|
+
style={[
|
|
34
|
+
{
|
|
35
|
+
width: SPIN_SIZE,
|
|
36
|
+
height: SPIN_SIZE,
|
|
37
|
+
borderRadius: SPIN_SIZE / 2,
|
|
38
|
+
borderWidth: 2,
|
|
39
|
+
borderColor: theme.colors.border,
|
|
40
|
+
borderTopColor: theme.colors.accent,
|
|
41
|
+
transform: [
|
|
42
|
+
{
|
|
43
|
+
rotate: spin.interpolate({
|
|
44
|
+
inputRange: [0, 1],
|
|
45
|
+
outputRange: ["0deg", "360deg"],
|
|
46
|
+
}),
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
style,
|
|
51
|
+
]}
|
|
52
|
+
/>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { test } from "node:test";
|
|
3
|
+
import { QueryClient } from "@tanstack/react-query";
|
|
4
|
+
import { updateWorkspaceStatusCache } from "./status-cache.ts";
|
|
5
|
+
import { agentStatusInfo, loadWorkspaceAgentStatuses, type HostAgentUpdate } from "./list-host-agents.ts";
|
|
6
|
+
import { agentUpdatedAt } from "./constants.ts";
|
|
7
|
+
import type { AgentUsageItem } from "../../shared/usage.ts";
|
|
8
|
+
|
|
9
|
+
test("late poll cannot erase live permission or closed-on-remove; cancellation preserves earlier pushes", async () => {
|
|
10
|
+
const client = new QueryClient();
|
|
11
|
+
const key = ["activity", "workspace-agent-status", "w"];
|
|
12
|
+
const stale = { a: agentStatusInfo({ id: "a", workspaceId: "w" }), b: agentStatusInfo({ id: "b", workspaceId: "w", status: "idle" }) };
|
|
13
|
+
client.setQueryData(key, stale);
|
|
14
|
+
let finish!: (value: typeof stale) => void;
|
|
15
|
+
const pending = client.fetchQuery({ queryKey: key, queryFn: () => new Promise<typeof stale>(resolve => { finish = resolve; }) });
|
|
16
|
+
updateWorkspaceStatusCache(client, key, "w", { kind: "upsert", agent: { id: "a", workspaceId: "w", pendingPermissions: [{}] } });
|
|
17
|
+
updateWorkspaceStatusCache(client, key, "w", { kind: "remove", agentId: "b" });
|
|
18
|
+
finish(stale);
|
|
19
|
+
await pending;
|
|
20
|
+
await Promise.resolve();
|
|
21
|
+
const current = client.getQueryData<typeof stale>(key)!;
|
|
22
|
+
assert.equal(current.a.permissionCount, 1);
|
|
23
|
+
assert.equal(current.b?.status, "closed");
|
|
24
|
+
assert.equal(client.getQueryState(key)?.status, "success");
|
|
25
|
+
assert.equal(client.getQueryState(key)?.fetchStatus, "idle");
|
|
26
|
+
client.clear();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test("first paginated load replays upserts and removes and releases its listener", async () => {
|
|
30
|
+
let listener!: (update: HostAgentUpdate) => void;
|
|
31
|
+
let unsubscribed = false;
|
|
32
|
+
let pages = 0;
|
|
33
|
+
const map = await loadWorkspaceAgentStatuses({ agents: {
|
|
34
|
+
subscribe: (handler) => { listener = handler; return () => { unsubscribed = true; }; },
|
|
35
|
+
list: async () => {
|
|
36
|
+
pages++;
|
|
37
|
+
if (pages === 1) return { entries: [{ agent: { id: "a", workspaceId: "w" } }], pageInfo: { hasMore: true, nextCursor: "next" } };
|
|
38
|
+
listener({ kind: "upsert", agent: { id: "a", workspaceId: "w", pendingPermissions: [{}] } });
|
|
39
|
+
listener({ kind: "remove", agentId: "b" });
|
|
40
|
+
return { entries: [{ agent: { id: "b", workspaceId: "w", status: "idle" } }], pageInfo: { hasMore: false, nextCursor: null } };
|
|
41
|
+
},
|
|
42
|
+
} }, "w");
|
|
43
|
+
assert.equal(map.a?.permissionCount, 1);
|
|
44
|
+
assert.equal(map.b?.status, "closed");
|
|
45
|
+
assert.equal(unsubscribed, true);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test("failed load releases its listener", async () => {
|
|
49
|
+
let unsubscribed = false;
|
|
50
|
+
await assert.rejects(loadWorkspaceAgentStatuses({ agents: {
|
|
51
|
+
subscribe: () => () => { unsubscribed = true; },
|
|
52
|
+
list: async () => { throw new Error("offline"); },
|
|
53
|
+
} }, "w"), /offline/);
|
|
54
|
+
assert.equal(unsubscribed, true);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test("live updatedAt takes precedence over old database sync timestamps", () => {
|
|
58
|
+
const item = { agentId: "a", updatedAt: "2026-09-19T12:00:00Z", lastActivityAt: "2026-01-01T00:00:00Z" } as AgentUsageItem;
|
|
59
|
+
const live = { a: agentStatusInfo({ id: "a", updatedAt: "2026-01-02T00:00:00Z" }) };
|
|
60
|
+
assert.equal(agentUpdatedAt(item, live), "2026-01-02T00:00:00Z");
|
|
61
|
+
assert.equal(agentUpdatedAt(item, undefined), item.updatedAt);
|
|
62
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { QueryClient, QueryKey } from "@tanstack/react-query";
|
|
2
|
+
import type { AgentStatusInfo } from "./constants.ts";
|
|
3
|
+
import { applyAgentStatusUpdate, type HostAgentUpdate } from "./list-host-agents.ts";
|
|
4
|
+
|
|
5
|
+
/** Cancel stale reads before publishing live state; the loader buffers first-load events. */
|
|
6
|
+
export function updateWorkspaceStatusCache(
|
|
7
|
+
queryClient: QueryClient, queryKey: QueryKey, workspaceId: string, update: HostAgentUpdate,
|
|
8
|
+
): void {
|
|
9
|
+
const previous = queryClient.getQueryData<Record<string, AgentStatusInfo>>(queryKey);
|
|
10
|
+
if (!previous) return;
|
|
11
|
+
const id = update.kind === "remove" ? update.agentId : update.agent.id;
|
|
12
|
+
if (!(id in previous)) {
|
|
13
|
+
if (update.kind === "remove") return;
|
|
14
|
+
if (update.agent.workspaceId != null && update.agent.workspaceId !== workspaceId) return;
|
|
15
|
+
if (update.agent.workspaceId == null) return;
|
|
16
|
+
}
|
|
17
|
+
// cancelQueries cancels synchronously, even when the SDK ignores AbortSignal.
|
|
18
|
+
// Restore our captured latest cache after cancellation reverts the old fetch.
|
|
19
|
+
void queryClient.cancelQueries({ queryKey, exact: true });
|
|
20
|
+
const next = { ...previous };
|
|
21
|
+
applyAgentStatusUpdate(next, workspaceId, update);
|
|
22
|
+
queryClient.setQueryData(queryKey, next);
|
|
23
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { test } from "node:test";
|
|
3
|
+
import { terminalPreviewLines } from "./terminal-preview.ts";
|
|
4
|
+
|
|
5
|
+
test("terminalPreviewLines trims trailing blank lines", () => {
|
|
6
|
+
assert.deepEqual(terminalPreviewLines(["a", "b", "", " "], 10), ["a", "b"]);
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
test("terminalPreviewLines keeps the last max lines", () => {
|
|
10
|
+
assert.deepEqual(terminalPreviewLines(["1", "2", "3", "4"], 2), ["3", "4"]);
|
|
11
|
+
assert.deepEqual(terminalPreviewLines(["1", "2", "3"], 0), []);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test("terminalPreviewLines handles empty and blank-only output", () => {
|
|
15
|
+
assert.deepEqual(terminalPreviewLines([], 5), []);
|
|
16
|
+
assert.deepEqual(terminalPreviewLines(["", " "], 5), []);
|
|
17
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Capture output ends with blank rows for a fresh shell; keep the last N meaningful lines. */
|
|
2
|
+
export function terminalPreviewLines(
|
|
3
|
+
lines: ReadonlyArray<string>,
|
|
4
|
+
max: number,
|
|
5
|
+
): string[] {
|
|
6
|
+
let end = lines.length;
|
|
7
|
+
while (end > 0 && (lines[end - 1] ?? "").trim() === "") end -= 1;
|
|
8
|
+
const start = Math.max(0, end - max);
|
|
9
|
+
return lines.slice(start, end);
|
|
10
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { usePaseo } from "@getpaseo/plugin/client";
|
|
2
|
+
import { Icon } from "@getpaseo/plugin/client/react-native";
|
|
3
|
+
import { useQuery } from "@tanstack/react-query";
|
|
4
|
+
import { useEffect, useState, type ReactNode } from "react";
|
|
5
|
+
import {
|
|
6
|
+
ActivityIndicator,
|
|
7
|
+
Platform,
|
|
8
|
+
Pressable,
|
|
9
|
+
Text,
|
|
10
|
+
View,
|
|
11
|
+
type TextStyle,
|
|
12
|
+
type ViewStyle,
|
|
13
|
+
} from "react-native";
|
|
14
|
+
import { collapseHomePath } from "../../shared/home-path.ts";
|
|
15
|
+
import { TERMINAL_PREVIEW_LINES, TERMINAL_REFETCH_MS } from "./constants.ts";
|
|
16
|
+
import { terminalPreviewLines } from "./terminal-preview.ts";
|
|
17
|
+
|
|
18
|
+
export type TerminalListItem = {
|
|
19
|
+
id: string;
|
|
20
|
+
workspaceId: string;
|
|
21
|
+
cwd: string;
|
|
22
|
+
name: string;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type TerminalsSectionStyles = {
|
|
26
|
+
sectionHeaderRow: ViewStyle;
|
|
27
|
+
sectionTitle: TextStyle;
|
|
28
|
+
panel: ViewStyle;
|
|
29
|
+
terminalRow: ViewStyle;
|
|
30
|
+
listMain: ViewStyle;
|
|
31
|
+
listTitle: TextStyle;
|
|
32
|
+
listMeta: TextStyle;
|
|
33
|
+
titleAction: ViewStyle;
|
|
34
|
+
terminalPreview: ViewStyle;
|
|
35
|
+
terminalLine: TextStyle;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export function TerminalsSection({
|
|
39
|
+
workspaceId,
|
|
40
|
+
terminalItems,
|
|
41
|
+
busyTerminalId,
|
|
42
|
+
homeDir,
|
|
43
|
+
mutedColor,
|
|
44
|
+
styles,
|
|
45
|
+
onClose,
|
|
46
|
+
}: {
|
|
47
|
+
workspaceId: string;
|
|
48
|
+
terminalItems: ReadonlyArray<TerminalListItem>;
|
|
49
|
+
busyTerminalId: string | null;
|
|
50
|
+
homeDir?: string;
|
|
51
|
+
mutedColor: string;
|
|
52
|
+
styles: TerminalsSectionStyles;
|
|
53
|
+
onClose: (item: TerminalListItem) => void;
|
|
54
|
+
}): ReactNode {
|
|
55
|
+
const paseo = usePaseo();
|
|
56
|
+
const [expandedId, setExpandedId] = useState<string | null>(null);
|
|
57
|
+
const [hoveredId, setHoveredId] = useState<string | null>(null);
|
|
58
|
+
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
if (expandedId != null && !terminalItems.some((item) => item.id === expandedId)) {
|
|
61
|
+
setExpandedId(null);
|
|
62
|
+
}
|
|
63
|
+
}, [expandedId, terminalItems]);
|
|
64
|
+
|
|
65
|
+
const capture = useQuery({
|
|
66
|
+
enabled: expandedId != null,
|
|
67
|
+
refetchInterval: TERMINAL_REFETCH_MS,
|
|
68
|
+
retry: false,
|
|
69
|
+
queryKey: ["activity", "terminal-capture", workspaceId, expandedId],
|
|
70
|
+
queryFn: async () => {
|
|
71
|
+
const result = await paseo.terminals
|
|
72
|
+
.ref(expandedId as string)
|
|
73
|
+
.capture({ stripAnsi: true });
|
|
74
|
+
return terminalPreviewLines(result.lines, TERMINAL_PREVIEW_LINES);
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<View style={{ gap: 12 }}>
|
|
80
|
+
<View style={styles.sectionHeaderRow}>
|
|
81
|
+
<Text style={styles.sectionTitle}>Terminals</Text>
|
|
82
|
+
</View>
|
|
83
|
+
<View style={styles.panel}>
|
|
84
|
+
{terminalItems.map((item) => {
|
|
85
|
+
const expanded = item.id === expandedId;
|
|
86
|
+
const busy = busyTerminalId === item.id;
|
|
87
|
+
// Web: hover-reveal. Native has no hover — keep the action visible.
|
|
88
|
+
const showClose = Platform.OS !== "web" || hoveredId === item.id || busy;
|
|
89
|
+
const lines = expanded ? (capture.data ?? []) : [];
|
|
90
|
+
return (
|
|
91
|
+
<View key={item.id}>
|
|
92
|
+
<Pressable
|
|
93
|
+
accessibilityRole="button"
|
|
94
|
+
accessibilityLabel={
|
|
95
|
+
expanded ? `Hide output of ${item.name}` : `Show output of ${item.name}`
|
|
96
|
+
}
|
|
97
|
+
accessibilityState={{ expanded }}
|
|
98
|
+
onPress={() => setExpandedId(expanded ? null : item.id)}
|
|
99
|
+
style={styles.terminalRow}
|
|
100
|
+
{...(Platform.OS === "web"
|
|
101
|
+
? ({
|
|
102
|
+
onMouseEnter: () => setHoveredId(item.id),
|
|
103
|
+
onMouseLeave: () =>
|
|
104
|
+
setHoveredId((prev) => (prev === item.id ? null : prev)),
|
|
105
|
+
} as object)
|
|
106
|
+
: null)}
|
|
107
|
+
>
|
|
108
|
+
<Icon name="Terminal" size={18} color={mutedColor} />
|
|
109
|
+
<View style={styles.listMain}>
|
|
110
|
+
<Text style={styles.listTitle} numberOfLines={1}>
|
|
111
|
+
{item.name}
|
|
112
|
+
</Text>
|
|
113
|
+
<Text style={styles.listMeta} numberOfLines={1}>
|
|
114
|
+
{collapseHomePath(item.cwd, homeDir ?? "")}
|
|
115
|
+
</Text>
|
|
116
|
+
</View>
|
|
117
|
+
<Pressable
|
|
118
|
+
accessibilityRole="button"
|
|
119
|
+
accessibilityLabel={`Close ${item.name}`}
|
|
120
|
+
accessibilityState={{ disabled: busyTerminalId != null }}
|
|
121
|
+
disabled={busyTerminalId != null || !showClose}
|
|
122
|
+
hitSlop={8}
|
|
123
|
+
onPress={() => onClose(item)}
|
|
124
|
+
pointerEvents={showClose ? "auto" : "none"}
|
|
125
|
+
style={[styles.titleAction, { opacity: showClose ? 1 : 0 }]}
|
|
126
|
+
>
|
|
127
|
+
{busy ? (
|
|
128
|
+
<ActivityIndicator size="small" color={mutedColor} />
|
|
129
|
+
) : (
|
|
130
|
+
<Icon name="X" size={14} color={mutedColor} />
|
|
131
|
+
)}
|
|
132
|
+
</Pressable>
|
|
133
|
+
</Pressable>
|
|
134
|
+
{expanded ? (
|
|
135
|
+
<View style={styles.terminalPreview}>
|
|
136
|
+
{capture.isPending ? (
|
|
137
|
+
<Text style={styles.listMeta}>Loading…</Text>
|
|
138
|
+
) : lines.length === 0 ? (
|
|
139
|
+
<Text style={styles.listMeta}>No output</Text>
|
|
140
|
+
) : (
|
|
141
|
+
lines.map((line, index) => (
|
|
142
|
+
<Text key={index} style={styles.terminalLine} numberOfLines={1}>
|
|
143
|
+
{line.length > 0 ? line : " "}
|
|
144
|
+
</Text>
|
|
145
|
+
))
|
|
146
|
+
)}
|
|
147
|
+
</View>
|
|
148
|
+
) : null}
|
|
149
|
+
</View>
|
|
150
|
+
);
|
|
151
|
+
})}
|
|
152
|
+
</View>
|
|
153
|
+
</View>
|
|
154
|
+
);
|
|
155
|
+
}
|
package/index.client.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { PluginClientContext } from "@getpaseo/plugin/client";
|
|
2
2
|
import { GlobalUsageSurface } from "./client/global-surface.tsx";
|
|
3
3
|
import { UsagePanel } from "./client/panel.tsx";
|
|
4
|
+
import { contributeAttentionPills } from "./client/attention-pill.tsx";
|
|
4
5
|
import { contributePills } from "./client/pill.tsx";
|
|
5
6
|
import { WorkspaceActivityPanel } from "./client/workspace-panel.tsx";
|
|
6
7
|
|
|
@@ -65,5 +66,10 @@ export default function contribute(client: PluginClientContext) {
|
|
|
65
66
|
},
|
|
66
67
|
});
|
|
67
68
|
|
|
68
|
-
|
|
69
|
+
const stopUsagePills = contributePills(client);
|
|
70
|
+
const stopAttentionPills = contributeAttentionPills(client);
|
|
71
|
+
return () => {
|
|
72
|
+
stopUsagePills();
|
|
73
|
+
stopAttentionPills();
|
|
74
|
+
};
|
|
69
75
|
}
|
package/index.server.ts
CHANGED
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
usageAgentUnarchiveRpc,
|
|
24
24
|
usageByProviderRpc,
|
|
25
25
|
usageExportRpc,
|
|
26
|
+
usageHostInfoRpc,
|
|
26
27
|
usageListRpc,
|
|
27
28
|
usageMcpByToolRpc,
|
|
28
29
|
usageReadSkillRpc,
|
|
@@ -67,6 +68,7 @@ export default function contribute(server: PluginServerContext) {
|
|
|
67
68
|
return createActivityByDayHandler(store)(input);
|
|
68
69
|
});
|
|
69
70
|
server.handle(usageExportRpc, createExportHandler(store));
|
|
71
|
+
server.handle(usageHostInfoRpc, () => ({ homeDir: homedir() }));
|
|
70
72
|
server.handle(usageReadSkillRpc, createReadSkillHandler());
|
|
71
73
|
|
|
72
74
|
const removeCreated = server.on("agent.created", (event, context) => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koinzhang/paseo-plugin-activity",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Local usage analytics for Paseo:
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "Local usage analytics and workspace agent ops for Paseo: tools, agents, messages, models, Explorer fleet list, and terminals.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"repository": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
],
|
|
23
23
|
"scripts": {
|
|
24
24
|
"typecheck": "tsc --noEmit",
|
|
25
|
-
"test": "node --experimental-strip-types --test server/background-sync.test.ts server/handlers-query.test.ts client/pill-data-cache.test.ts client/rank-color.test.ts client/provider-filter.test.ts shared/activity.test.ts shared/insights.test.ts shared/classify.test.ts shared/usage.test.ts shared/format.test.ts shared/agent-title-search.test.ts shared/list-agent-pages.test.ts shared/agent-page-size.test.ts server/store.test.ts server/ingest.test.ts server/skill-path.test.ts server/mcp-servers.test.ts server/agents.test.ts server/migrate-data.test.ts server/messages.test.ts server/resolve-model.test.ts"
|
|
25
|
+
"test": "node --experimental-strip-types --test server/background-sync.test.ts server/handlers-query.test.ts client/attention-agents.test.ts client/latest-user-message.test.ts client/pill-data-cache.test.ts client/pill-directory.test.ts client/hidden-pill-recheck.test.ts client/workspace/list-host-agents.test.ts client/workspace/status-cache.test.ts client/workspace/constants.test.ts client/workspace/filters.test.ts client/rank-color.test.ts client/provider-filter.test.ts client/workspace/terminal-preview.test.ts shared/activity.test.ts shared/insights.test.ts shared/classify.test.ts shared/usage.test.ts shared/format.test.ts shared/agent-title-search.test.ts shared/list-agent-pages.test.ts shared/agent-page-size.test.ts server/store.test.ts server/ingest.test.ts server/skill-path.test.ts server/mcp-servers.test.ts server/agents.test.ts server/migrate-data.test.ts server/messages.test.ts server/resolve-model.test.ts"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@getpaseo/plugin": "0.8.0",
|
package/server/agents.test.ts
CHANGED
|
@@ -84,3 +84,19 @@ describe("agentRowFromSnapshot", () => {
|
|
|
84
84
|
assert.equal(archived.archivedAt, "2026-09-19T00:00:00.000Z");
|
|
85
85
|
});
|
|
86
86
|
});
|
|
87
|
+
|
|
88
|
+
describe("agent activity timestamps", () => {
|
|
89
|
+
it("preserves snapshot time and uses creation time only when absent", () => {
|
|
90
|
+
const agent = { id: "a", provider: "codex", createdAt: "2026-01-01T00:00:00Z", updatedAt: "2026-01-02T00:00:00Z" };
|
|
91
|
+
assert.equal(agentRowFromSnapshot(agent).updatedAt, agent.updatedAt);
|
|
92
|
+
assert.equal(agentRowFromSnapshot({ ...agent, updatedAt: undefined }).updatedAt, agent.createdAt);
|
|
93
|
+
});
|
|
94
|
+
it("derives last activity from tool history regardless of input order", () => {
|
|
95
|
+
const calls = [row({ ts: "2026-01-03T00:00:00Z" }), row({ ts: "2026-01-01T00:00:00Z" }), row({ ts: "2026-01-04T00:00:00Z" })];
|
|
96
|
+
for (const ordered of [calls, calls.slice().reverse()]) {
|
|
97
|
+
const agent = agentsFromToolCalls(ordered)[0]!;
|
|
98
|
+
assert.equal(agent.createdAt, "2026-01-01T00:00:00Z");
|
|
99
|
+
assert.equal(agent.updatedAt, "2026-01-04T00:00:00Z");
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
});
|
package/server/agents.ts
CHANGED
|
@@ -29,9 +29,10 @@ export function agentRowFromSnapshot(agent: {
|
|
|
29
29
|
provider: string;
|
|
30
30
|
title?: string | null;
|
|
31
31
|
createdAt: string;
|
|
32
|
+
updatedAt?: string;
|
|
32
33
|
archivedAt?: string | null;
|
|
33
34
|
}): AgentRow {
|
|
34
|
-
const updatedAt =
|
|
35
|
+
const updatedAt = agent.updatedAt ?? agent.createdAt;
|
|
35
36
|
return {
|
|
36
37
|
agentId: agent.id,
|
|
37
38
|
workspaceId: agent.workspaceId ?? null,
|
|
@@ -48,7 +49,7 @@ export function agentRowFromSnapshot(agent: {
|
|
|
48
49
|
export function agentsFromToolCalls(rows: readonly ToolCallRow[]): AgentRow[] {
|
|
49
50
|
const earliest = new Map<
|
|
50
51
|
string,
|
|
51
|
-
{ provider: string; workspaceId: string | null; createdAt: string }
|
|
52
|
+
{ provider: string; workspaceId: string | null; createdAt: string; updatedAt: string }
|
|
52
53
|
>();
|
|
53
54
|
for (const row of rows) {
|
|
54
55
|
const t = row.ts ?? row.ingestedAt;
|
|
@@ -58,10 +59,12 @@ export function agentsFromToolCalls(rows: readonly ToolCallRow[]): AgentRow[] {
|
|
|
58
59
|
provider: row.provider,
|
|
59
60
|
workspaceId: row.workspaceId,
|
|
60
61
|
createdAt: t,
|
|
62
|
+
updatedAt: prev && prev.updatedAt > t ? prev.updatedAt : t,
|
|
61
63
|
});
|
|
64
|
+
} else if (t > prev.updatedAt) {
|
|
65
|
+
prev.updatedAt = t;
|
|
62
66
|
}
|
|
63
67
|
}
|
|
64
|
-
const updatedAt = nowIso();
|
|
65
68
|
return [...earliest.entries()].map(([agentId, info]) => ({
|
|
66
69
|
agentId,
|
|
67
70
|
workspaceId: info.workspaceId,
|
|
@@ -70,7 +73,7 @@ export function agentsFromToolCalls(rows: readonly ToolCallRow[]): AgentRow[] {
|
|
|
70
73
|
title: null,
|
|
71
74
|
createdAt: info.createdAt,
|
|
72
75
|
archivedAt: null,
|
|
73
|
-
updatedAt,
|
|
76
|
+
updatedAt: info.updatedAt,
|
|
74
77
|
}));
|
|
75
78
|
}
|
|
76
79
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
|
-
import { mkdtempSync, rmSync } from "node:fs";
|
|
2
|
+
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
import { test } from "node:test";
|
|
@@ -123,7 +123,7 @@ test("usage.agents filters by workspace and merges the registry", async () => {
|
|
|
123
123
|
}
|
|
124
124
|
});
|
|
125
125
|
|
|
126
|
-
test("skills-by-name
|
|
126
|
+
test("skills-by-name refreshes an empty handle and resolves project skills", async () => {
|
|
127
127
|
const dir = mkdtempSync(join(tmpdir(), "fast-skills-"));
|
|
128
128
|
const store = createUsageStore({ dir, driver: "sqlite" });
|
|
129
129
|
let refreshed = 0;
|
|
@@ -133,15 +133,36 @@ test("skills-by-name never awaits agent.refresh", async () => {
|
|
|
133
133
|
current: () => null,
|
|
134
134
|
refresh: async () => {
|
|
135
135
|
refreshed += 1;
|
|
136
|
+
return { agent: { id: "a1", provider: "codex", cwd: dir } };
|
|
136
137
|
},
|
|
137
138
|
}),
|
|
138
139
|
},
|
|
139
140
|
} as unknown as PaseoApi;
|
|
141
|
+
try {
|
|
142
|
+
mkdirSync(join(dir, ".claude/skills/demo"), { recursive: true });
|
|
143
|
+
writeFileSync(join(dir, ".claude/skills/demo/SKILL.md"), "# Demo");
|
|
144
|
+
store.upsertMany([row()]);
|
|
145
|
+
const result = await createSkillsByNameHandler(store)({ agentId: "a1" }, { paseo });
|
|
146
|
+
assert.equal(result.items[0]?.skillName, "demo");
|
|
147
|
+
assert.equal(refreshed, 1);
|
|
148
|
+
assert.equal(result.items[0]?.skillPath, join(dir, ".claude/skills/demo/SKILL.md"));
|
|
149
|
+
} finally {
|
|
150
|
+
store.close();
|
|
151
|
+
rmSync(dir, { recursive: true, force: true });
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
test("skills-by-name keeps counts when agent metadata is unavailable", async () => {
|
|
156
|
+
const dir = mkdtempSync(join(tmpdir(), "missing-agent-"));
|
|
157
|
+
const store = createUsageStore({ dir, driver: "sqlite" });
|
|
158
|
+
const paseo = { agents: { ref: () => ({
|
|
159
|
+
current: () => null,
|
|
160
|
+
refresh: async () => null,
|
|
161
|
+
}) } } as unknown as PaseoApi;
|
|
140
162
|
try {
|
|
141
163
|
store.upsertMany([row()]);
|
|
142
164
|
const result = await createSkillsByNameHandler(store)({ agentId: "a1" }, { paseo });
|
|
143
165
|
assert.equal(result.items[0]?.skillName, "demo");
|
|
144
|
-
assert.equal(refreshed, 0);
|
|
145
166
|
} finally {
|
|
146
167
|
store.close();
|
|
147
168
|
rmSync(dir, { recursive: true, force: true });
|
package/server/handlers.ts
CHANGED
|
@@ -151,14 +151,21 @@ export function createListHandler(store: UsageStore) {
|
|
|
151
151
|
};
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
function skillRootsForQuery(
|
|
154
|
+
async function skillRootsForQuery(
|
|
155
155
|
paseo: PaseoApi,
|
|
156
156
|
agentId: string | undefined,
|
|
157
157
|
homeDir: string,
|
|
158
|
-
): string[] {
|
|
158
|
+
): Promise<string[]> {
|
|
159
159
|
if (!agentId) return buildHomeSkillRoots(homeDir);
|
|
160
160
|
const handle = paseo.agents.ref(agentId);
|
|
161
|
-
|
|
161
|
+
let snapshot = handle.current();
|
|
162
|
+
if (!snapshot) {
|
|
163
|
+
try {
|
|
164
|
+
snapshot = (await handle.refresh())?.agent ?? handle.current();
|
|
165
|
+
} catch (error) {
|
|
166
|
+
console.error("[activity] could not resolve agent skill roots", error);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
162
169
|
if (snapshot?.cwd) {
|
|
163
170
|
return buildSkillRoots(agentFromSnapshot(snapshot), homeDir);
|
|
164
171
|
}
|
|
@@ -178,7 +185,7 @@ export function createSkillsByNameHandler(store: UsageStore) {
|
|
|
178
185
|
from: input.from,
|
|
179
186
|
to: input.to,
|
|
180
187
|
});
|
|
181
|
-
const roots = skillRootsForQuery(context.paseo, input.agentId, homeDir);
|
|
188
|
+
const roots = await skillRootsForQuery(context.paseo, input.agentId, homeDir);
|
|
182
189
|
const items = finalizeSkillPaths(aggregateSkillsByName(rows), roots, homeDir);
|
|
183
190
|
return { items };
|
|
184
191
|
};
|
|
@@ -248,7 +255,12 @@ export function createAgentsHandler(store: UsageStore) {
|
|
|
248
255
|
};
|
|
249
256
|
}
|
|
250
257
|
|
|
251
|
-
/**
|
|
258
|
+
/**
|
|
259
|
+
* 0.8 SDK has no reload API (handle.refresh is a read). Run CLI on this daemon's
|
|
260
|
+
* machine, inheriting PATH and PASEO_HOME / PASEO_HOST / PASEO_LISTEN. CLI also
|
|
261
|
+
* resolves its pid/config socket. Requires that environment to target this daemon;
|
|
262
|
+
* do not substitute the client UI's remote host or hard-code a default port.
|
|
263
|
+
*/
|
|
252
264
|
export function createUnarchiveAgentHandler(store: UsageStore) {
|
|
253
265
|
return async (
|
|
254
266
|
input: RpcInput<typeof usageAgentUnarchiveRpc>,
|