@koinzhang/paseo-plugin-activity 0.1.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 +81 -0
- package/README.md +85 -0
- package/client/activity-heatmap.tsx +72 -14
- package/client/formatted-time.tsx +23 -0
- package/client/global-surface.tsx +24 -25
- package/client/hidden-pill-recheck.test.ts +33 -0
- package/client/hidden-pill-recheck.ts +22 -0
- package/client/panel.tsx +116 -107
- package/client/pill-directory.test.ts +92 -0
- package/client/pill-directory.ts +79 -0
- package/client/pill.tsx +23 -23
- package/client/range.ts +20 -0
- package/client/usage-popover.tsx +75 -84
- package/client/usage-query.tsx +8 -3
- package/client/usage-stats.tsx +7 -5
- package/client/use-agent-turn-end.ts +69 -0
- package/client/workspace/agent-row.tsx +167 -0
- package/client/workspace/agents-section.tsx +330 -0
- package/client/workspace/constants.ts +147 -0
- package/client/workspace/display-menu.tsx +116 -0
- package/client/workspace/filters.ts +30 -0
- package/client/workspace/list-host-agents.test.ts +45 -0
- package/client/workspace/list-host-agents.ts +90 -0
- package/client/workspace/panel.tsx +964 -0
- package/client/workspace/rank-section.tsx +131 -0
- 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/client/workspace-panel.tsx +2 -0
- package/index.client.tsx +20 -13
- package/index.server.ts +13 -0
- package/package.json +9 -3
- package/server/agents.test.ts +36 -1
- package/server/agents.ts +9 -5
- package/server/background-sync.test.ts +14 -3
- package/server/background-sync.ts +16 -5
- package/server/handlers-query.test.ts +82 -3
- package/server/handlers.ts +89 -6
- package/server/messages.test.ts +8 -2
- package/server/skill-path.ts +3 -20
- package/server/store.test.ts +13 -0
- package/server/store.ts +2 -2
- package/shared/activity.test.ts +22 -12
- package/shared/activity.ts +8 -13
- package/shared/agent-page-size.test.ts +11 -0
- package/shared/agent-title-search.test.ts +28 -0
- package/shared/agent-title-search.ts +12 -0
- package/shared/explorer-agent-display.ts +30 -0
- package/shared/format.test.ts +41 -16
- package/shared/format.ts +26 -17
- package/shared/home-path.ts +19 -0
- package/shared/insights.test.ts +38 -18
- package/shared/insights.ts +38 -19
- package/shared/list-agent-pages.test.ts +51 -0
- package/shared/list-agent-pages.ts +31 -0
- package/shared/usage.test.ts +248 -0
- package/shared/usage.ts +336 -11
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { Icon } from "@getpaseo/plugin/client/react-native";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
import { Pressable, Text, View, type TextStyle, type ViewStyle } from "react-native";
|
|
4
|
+
import { formatDisplayName } from "../../shared/format.ts";
|
|
5
|
+
import type { McpByToolItem, SkillByNameItem } from "../../shared/usage.ts";
|
|
6
|
+
import { FormattedTime } from "../formatted-time.tsx";
|
|
7
|
+
import { RANK_ROW_ESTIMATE } from "./constants.ts";
|
|
8
|
+
|
|
9
|
+
type RankKind = "skills" | "mcp";
|
|
10
|
+
|
|
11
|
+
function rankTitle(kind: RankKind): string {
|
|
12
|
+
return kind === "skills" ? "Skills" : "MCP";
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function rankAction(kind: RankKind): { icon: "Sparkles" | "Plug"; accessibilityLabel: string } {
|
|
16
|
+
return kind === "skills"
|
|
17
|
+
? { icon: "Plug", accessibilityLabel: "Show most used MCP" }
|
|
18
|
+
: { icon: "Sparkles", accessibilityLabel: "Show most used skills" };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function CountText({
|
|
22
|
+
value,
|
|
23
|
+
styles,
|
|
24
|
+
}: {
|
|
25
|
+
value: number | string;
|
|
26
|
+
styles: { countText: TextStyle };
|
|
27
|
+
}): ReactNode {
|
|
28
|
+
return <Text style={styles.countText}>{value}</Text>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type RankSectionStyles = {
|
|
32
|
+
sectionHeaderRow: ViewStyle;
|
|
33
|
+
sectionTitle: TextStyle;
|
|
34
|
+
titleAction: ViewStyle;
|
|
35
|
+
panel: ViewStyle;
|
|
36
|
+
listRow: ViewStyle;
|
|
37
|
+
listMain: ViewStyle;
|
|
38
|
+
listTitle: TextStyle;
|
|
39
|
+
listMeta: TextStyle;
|
|
40
|
+
countText: TextStyle;
|
|
41
|
+
empty: TextStyle;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export function RankSection({
|
|
45
|
+
rankKind,
|
|
46
|
+
onToggleKind,
|
|
47
|
+
showToggle = true,
|
|
48
|
+
skillItems,
|
|
49
|
+
mcpItems,
|
|
50
|
+
mutedColor,
|
|
51
|
+
styles,
|
|
52
|
+
}: {
|
|
53
|
+
rankKind: RankKind;
|
|
54
|
+
onToggleKind: () => void;
|
|
55
|
+
showToggle?: boolean;
|
|
56
|
+
skillItems: ReadonlyArray<SkillByNameItem>;
|
|
57
|
+
mcpItems: ReadonlyArray<McpByToolItem>;
|
|
58
|
+
mutedColor: string;
|
|
59
|
+
styles: RankSectionStyles;
|
|
60
|
+
}): ReactNode {
|
|
61
|
+
if (skillItems.length === 0 && mcpItems.length === 0) return null;
|
|
62
|
+
|
|
63
|
+
const items = rankKind === "skills" ? skillItems : mcpItems;
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<View style={{ gap: 12 }}>
|
|
67
|
+
<View style={styles.sectionHeaderRow}>
|
|
68
|
+
<Text style={styles.sectionTitle}>{rankTitle(rankKind)}</Text>
|
|
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}
|
|
80
|
+
</View>
|
|
81
|
+
<View
|
|
82
|
+
style={[
|
|
83
|
+
styles.panel,
|
|
84
|
+
{
|
|
85
|
+
minHeight: Math.max(items.length, 1) * RANK_ROW_ESTIMATE,
|
|
86
|
+
},
|
|
87
|
+
]}
|
|
88
|
+
>
|
|
89
|
+
{rankKind === "skills"
|
|
90
|
+
? skillItems.map((item) => (
|
|
91
|
+
<View key={item.skillName} style={styles.listRow}>
|
|
92
|
+
<Icon name="Sparkles" size={18} color={mutedColor} />
|
|
93
|
+
<View style={styles.listMain}>
|
|
94
|
+
<Text style={styles.listTitle} numberOfLines={1}>
|
|
95
|
+
{formatDisplayName(item.skillName)}
|
|
96
|
+
</Text>
|
|
97
|
+
<FormattedTime
|
|
98
|
+
iso={item.lastUsedAt}
|
|
99
|
+
prefix="Last "
|
|
100
|
+
style={styles.listMeta}
|
|
101
|
+
/>
|
|
102
|
+
</View>
|
|
103
|
+
<CountText value={item.total} styles={styles} />
|
|
104
|
+
</View>
|
|
105
|
+
))
|
|
106
|
+
: mcpItems.map((item) => (
|
|
107
|
+
<View key={`${item.server}.${item.tool}`} style={styles.listRow}>
|
|
108
|
+
<Icon name="Plug" size={18} color={mutedColor} />
|
|
109
|
+
<View style={styles.listMain}>
|
|
110
|
+
<Text style={styles.listTitle} numberOfLines={1}>
|
|
111
|
+
{formatDisplayName(`${item.server}.${item.tool}`)}
|
|
112
|
+
</Text>
|
|
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
|
+
)}
|
|
124
|
+
</View>
|
|
125
|
+
<CountText value={item.count} styles={styles} />
|
|
126
|
+
</View>
|
|
127
|
+
))}
|
|
128
|
+
</View>
|
|
129
|
+
</View>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
@@ -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 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" }) };
|
|
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, undefined);
|
|
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" } }], pageInfo: { hasMore: false, nextCursor: null } };
|
|
41
|
+
},
|
|
42
|
+
} }, "w");
|
|
43
|
+
assert.equal(map.a?.permissionCount, 1);
|
|
44
|
+
assert.equal(map.b, undefined);
|
|
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,19 @@
|
|
|
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) && (update.kind === "remove" || update.agent.workspaceId !== workspaceId)) return;
|
|
13
|
+
// cancelQueries cancels synchronously, even when the SDK ignores AbortSignal.
|
|
14
|
+
// Restore our captured latest cache after cancellation reverts the old fetch.
|
|
15
|
+
void queryClient.cancelQueries({ queryKey, exact: true });
|
|
16
|
+
const next = { ...previous };
|
|
17
|
+
applyAgentStatusUpdate(next, workspaceId, update);
|
|
18
|
+
queryClient.setQueryData(queryKey, next);
|
|
19
|
+
}
|
|
@@ -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,9 +1,8 @@
|
|
|
1
1
|
import type { PluginClientContext } from "@getpaseo/plugin/client";
|
|
2
|
-
import { copyText } from "@getpaseo/plugin/client/react-native";
|
|
3
2
|
import { GlobalUsageSurface } from "./client/global-surface.tsx";
|
|
4
3
|
import { UsagePanel } from "./client/panel.tsx";
|
|
5
4
|
import { contributePills } from "./client/pill.tsx";
|
|
6
|
-
import {
|
|
5
|
+
import { WorkspaceActivityPanel } from "./client/workspace-panel.tsx";
|
|
7
6
|
|
|
8
7
|
const GLOBAL_SURFACE_ID = "activity";
|
|
9
8
|
|
|
@@ -24,9 +23,18 @@ export default function contribute(client: PluginClientContext) {
|
|
|
24
23
|
Component: UsagePanel,
|
|
25
24
|
});
|
|
26
25
|
|
|
26
|
+
client.addWorkspacePanel({
|
|
27
|
+
id: "workspace-activity",
|
|
28
|
+
title: "Activity",
|
|
29
|
+
icon: "Activity",
|
|
30
|
+
context: "workspace",
|
|
31
|
+
locations: ["explorer"],
|
|
32
|
+
Component: WorkspaceActivityPanel,
|
|
33
|
+
});
|
|
34
|
+
|
|
27
35
|
client.addCommandCenterItem({
|
|
28
36
|
id: "open-usage-global",
|
|
29
|
-
title: "
|
|
37
|
+
title: "Activity",
|
|
30
38
|
icon: "Activity",
|
|
31
39
|
keywords: ["activity", "tool", "usage", "provider", "all", "global", "sidebar"],
|
|
32
40
|
context: "global",
|
|
@@ -37,9 +45,9 @@ export default function contribute(client: PluginClientContext) {
|
|
|
37
45
|
|
|
38
46
|
client.addCommandCenterItem({
|
|
39
47
|
id: "open-usage",
|
|
40
|
-
title: "Activity",
|
|
48
|
+
title: "Agent Activity",
|
|
41
49
|
icon: "Activity",
|
|
42
|
-
keywords: ["activity", "tool", "usage", "shell", "skill", "mcp", "stats"],
|
|
50
|
+
keywords: ["activity", "current", "agent", "tool", "usage", "shell", "skill", "mcp", "stats"],
|
|
43
51
|
context: "agent",
|
|
44
52
|
onSelect: ({ openPanel }) => {
|
|
45
53
|
openPanel("usage");
|
|
@@ -47,14 +55,13 @@ export default function contribute(client: PluginClientContext) {
|
|
|
47
55
|
});
|
|
48
56
|
|
|
49
57
|
client.addCommandCenterItem({
|
|
50
|
-
id: "
|
|
51
|
-
title: "
|
|
52
|
-
icon: "
|
|
53
|
-
keywords: ["
|
|
54
|
-
context: "
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
await copyText(result.markdown);
|
|
58
|
+
id: "open-workspace-activity",
|
|
59
|
+
title: "Workspace Activity",
|
|
60
|
+
icon: "Activity",
|
|
61
|
+
keywords: ["activity", "workspace", "explorer", "tool", "usage", "shell", "skill", "mcp", "stats"],
|
|
62
|
+
context: "workspace",
|
|
63
|
+
onSelect({ openPanel }) {
|
|
64
|
+
openPanel("workspace-activity", { location: "explorer" });
|
|
58
65
|
},
|
|
59
66
|
});
|
|
60
67
|
|
package/index.server.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { homedir } from "node:os";
|
|
|
3
3
|
import type { PluginServerContext } from "@getpaseo/plugin/server";
|
|
4
4
|
import {
|
|
5
5
|
createActivityByDayHandler,
|
|
6
|
+
createAgentsHandler,
|
|
6
7
|
createByProviderHandler,
|
|
7
8
|
createExportHandler,
|
|
8
9
|
createListHandler,
|
|
@@ -10,6 +11,7 @@ import {
|
|
|
10
11
|
createReadSkillHandler,
|
|
11
12
|
createSkillsByNameHandler,
|
|
12
13
|
createSummaryHandler,
|
|
14
|
+
createUnarchiveAgentHandler,
|
|
13
15
|
} from "./server/handlers.ts";
|
|
14
16
|
import { agentRowFromHook } from "./server/agents.ts";
|
|
15
17
|
import { ingestTimeline, ingestUserMessages } from "./server/ingest.ts";
|
|
@@ -17,19 +19,24 @@ import { resolveAgentModel } from "./server/resolve-model.ts";
|
|
|
17
19
|
import { createUsageStore } from "./server/store.ts";
|
|
18
20
|
import {
|
|
19
21
|
usageActivityByDayRpc,
|
|
22
|
+
usageAgentsRpc,
|
|
23
|
+
usageAgentUnarchiveRpc,
|
|
20
24
|
usageByProviderRpc,
|
|
21
25
|
usageExportRpc,
|
|
26
|
+
usageHostInfoRpc,
|
|
22
27
|
usageListRpc,
|
|
23
28
|
usageMcpByToolRpc,
|
|
24
29
|
usageReadSkillRpc,
|
|
25
30
|
usageSkillsByNameRpc,
|
|
26
31
|
usageSummaryRpc,
|
|
27
32
|
} from "./shared/usage.ts";
|
|
33
|
+
import { explorerAgentDisplaySettings } from "./shared/explorer-agent-display.ts";
|
|
28
34
|
|
|
29
35
|
export default function contribute(server: PluginServerContext) {
|
|
30
36
|
const store = createUsageStore();
|
|
31
37
|
const background = createBackgroundSync(store);
|
|
32
38
|
console.log(`[activity] store ready (driver=${store.driver})`);
|
|
39
|
+
server.registerSettings(explorerAgentDisplaySettings);
|
|
33
40
|
|
|
34
41
|
server.handle(usageSummaryRpc, (input, context) => {
|
|
35
42
|
void background.request(context.paseo);
|
|
@@ -51,11 +58,17 @@ export default function contribute(server: PluginServerContext) {
|
|
|
51
58
|
void background.request(context.paseo);
|
|
52
59
|
return createByProviderHandler(store)(input);
|
|
53
60
|
});
|
|
61
|
+
server.handle(usageAgentsRpc, (input, context) => {
|
|
62
|
+
void background.request(context.paseo);
|
|
63
|
+
return createAgentsHandler(store)(input);
|
|
64
|
+
});
|
|
65
|
+
server.handle(usageAgentUnarchiveRpc, createUnarchiveAgentHandler(store));
|
|
54
66
|
server.handle(usageActivityByDayRpc, (input, context) => {
|
|
55
67
|
void background.request(context.paseo);
|
|
56
68
|
return createActivityByDayHandler(store)(input);
|
|
57
69
|
});
|
|
58
70
|
server.handle(usageExportRpc, createExportHandler(store));
|
|
71
|
+
server.handle(usageHostInfoRpc, () => ({ homeDir: homedir() }));
|
|
59
72
|
server.handle(usageReadSkillRpc, createReadSkillHandler());
|
|
60
73
|
|
|
61
74
|
const removeCreated = server.on("agent.created", (event, context) => {
|
package/package.json
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koinzhang/paseo-plugin-activity",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Local usage analytics for Paseo:
|
|
3
|
+
"version": "0.3.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
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/koinzhang/paseo-plugins.git",
|
|
10
|
+
"directory": "activity"
|
|
11
|
+
},
|
|
7
12
|
"files": [
|
|
8
13
|
"paseo-plugin.json",
|
|
14
|
+
"CHANGELOG.md",
|
|
9
15
|
"index.client.ts",
|
|
10
16
|
"index.client.tsx",
|
|
11
17
|
"index.server.ts",
|
|
@@ -16,7 +22,7 @@
|
|
|
16
22
|
],
|
|
17
23
|
"scripts": {
|
|
18
24
|
"typecheck": "tsc --noEmit",
|
|
19
|
-
"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 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/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/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"
|
|
20
26
|
},
|
|
21
27
|
"devDependencies": {
|
|
22
28
|
"@getpaseo/plugin": "0.8.0",
|
package/server/agents.test.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import { describe, it } from "node:test";
|
|
3
|
-
import { agentsFromToolCalls, agentRowFromHook } from "./agents.ts";
|
|
3
|
+
import { agentsFromToolCalls, agentRowFromHook, agentRowFromSnapshot } from "./agents.ts";
|
|
4
4
|
import type { ToolCallRow } from "./store.ts";
|
|
5
5
|
|
|
6
6
|
function row(over: Partial<ToolCallRow> = {}): ToolCallRow {
|
|
@@ -65,3 +65,38 @@ describe("agentRowFromHook", () => {
|
|
|
65
65
|
assert.equal(row.createdAt, "2026-09-18T00:00:00.000Z");
|
|
66
66
|
});
|
|
67
67
|
});
|
|
68
|
+
|
|
69
|
+
describe("agentRowFromSnapshot", () => {
|
|
70
|
+
it("passes through archivedAt", () => {
|
|
71
|
+
const active = agentRowFromSnapshot({
|
|
72
|
+
id: "a1",
|
|
73
|
+
provider: "claude",
|
|
74
|
+
createdAt: "2026-09-18T00:00:00.000Z",
|
|
75
|
+
archivedAt: null,
|
|
76
|
+
});
|
|
77
|
+
assert.equal(active.archivedAt, null);
|
|
78
|
+
const archived = agentRowFromSnapshot({
|
|
79
|
+
id: "a2",
|
|
80
|
+
provider: "claude",
|
|
81
|
+
createdAt: "2026-09-18T00:00:00.000Z",
|
|
82
|
+
archivedAt: "2026-09-19T00:00:00.000Z",
|
|
83
|
+
});
|
|
84
|
+
assert.equal(archived.archivedAt, "2026-09-19T00:00:00.000Z");
|
|
85
|
+
});
|
|
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
|
+
});
|