@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.
Files changed (55) hide show
  1. package/CHANGELOG.md +50 -1
  2. package/README.md +26 -11
  3. package/client/attention-agents.test.ts +94 -0
  4. package/client/attention-agents.ts +67 -0
  5. package/client/attention-pill.tsx +254 -0
  6. package/client/attention-popover.tsx +161 -0
  7. package/client/attention-status-store.ts +47 -0
  8. package/client/formatted-time.tsx +23 -0
  9. package/client/global-surface.tsx +3 -1
  10. package/client/hidden-pill-recheck.test.ts +33 -0
  11. package/client/hidden-pill-recheck.ts +22 -0
  12. package/client/latest-user-message.test.ts +34 -0
  13. package/client/latest-user-message.ts +96 -0
  14. package/client/open-agent.ts +32 -0
  15. package/client/panel.tsx +117 -107
  16. package/client/pill-directory.test.ts +92 -0
  17. package/client/pill-directory.ts +79 -0
  18. package/client/pill.tsx +23 -23
  19. package/client/usage-popover.tsx +75 -84
  20. package/client/usage-query.tsx +8 -3
  21. package/client/usage-stats.tsx +2 -2
  22. package/client/use-agent-turn-end.ts +72 -0
  23. package/client/use-latest-user-message.ts +15 -0
  24. package/client/use-workspace-agent-statuses.ts +47 -0
  25. package/client/workspace/agent-live-status-sync.tsx +103 -0
  26. package/client/workspace/agent-row.tsx +105 -28
  27. package/client/workspace/agents-section.tsx +92 -17
  28. package/client/workspace/constants.test.ts +66 -0
  29. package/client/workspace/constants.ts +66 -4
  30. package/client/workspace/filters.test.ts +59 -0
  31. package/client/workspace/filters.ts +11 -2
  32. package/client/workspace/list-host-agents.test.ts +103 -0
  33. package/client/workspace/list-host-agents.ts +113 -23
  34. package/client/workspace/panel.tsx +192 -12
  35. package/client/workspace/rank-section.tsx +36 -26
  36. package/client/workspace/running-indicator.tsx +54 -0
  37. package/client/workspace/status-cache.test.ts +62 -0
  38. package/client/workspace/status-cache.ts +23 -0
  39. package/client/workspace/terminal-preview.test.ts +17 -0
  40. package/client/workspace/terminal-preview.ts +10 -0
  41. package/client/workspace/terminals-section.tsx +155 -0
  42. package/index.client.tsx +7 -1
  43. package/index.server.ts +2 -0
  44. package/package.json +3 -3
  45. package/server/agents.test.ts +16 -0
  46. package/server/agents.ts +7 -4
  47. package/server/handlers-query.test.ts +24 -3
  48. package/server/handlers.ts +17 -5
  49. package/server/skill-path.ts +3 -20
  50. package/shared/explorer-agent-display.ts +1 -1
  51. package/shared/format.test.ts +35 -31
  52. package/shared/format.ts +21 -36
  53. package/shared/home-path.ts +19 -0
  54. package/shared/usage.test.ts +8 -2
  55. package/shared/usage.ts +16 -0
@@ -0,0 +1,103 @@
1
+ import assert from "node:assert/strict";
2
+ import { test } from "node:test";
3
+ import { attentionKind } from "./constants.ts";
4
+ import { agentStatusInfo, applyAgentStatusUpdate, loadWorkspaceAgentStatuses } from "./list-host-agents.ts";
5
+
6
+ test("workspace status uses daemon placement project ID on every page and rejects other workspaces", async () => {
7
+ let pages = 0;
8
+ const map = await loadWorkspaceAgentStatuses({ agents: { list: async (options) => {
9
+ assert.deepEqual(options.filter, { includeArchived: true, projectKeys: ["prj_c187d0857b6da810"] });
10
+ pages++;
11
+ return {
12
+ entries: [{ agent: { id: `a${pages}`, workspaceId: pages === 1 ? "other" : "w", pendingPermissions: [{}] } },
13
+ { agent: { id: "unknown" } }],
14
+ pageInfo: { hasMore: pages === 1, nextCursor: pages === 1 ? "next" : null },
15
+ };
16
+ } } }, "w", "prj_c187d0857b6da810");
17
+ assert.equal(pages, 2);
18
+ assert.deepEqual(Object.keys(map), ["a2"]);
19
+ assert.equal(map.a2?.permissionCount, 1);
20
+ });
21
+
22
+ // Reproduce daemon 0.8's structural filter, including the two different keys.
23
+ test("pending questions survive a poll when catalog key differs from placement key", async () => {
24
+ const workspace = { id: "w", projectId: "prj_project" };
25
+ const project = { projectId: workspace.projectId, projectKey: "remote:github.com/org/repo" };
26
+ const entry = {
27
+ agent: { id: "waiting", workspaceId: workspace.id, status: "running",
28
+ requiresAttention: false, attentionReason: null, pendingPermissions: [{ tool: "question" }] },
29
+ project: { projectKey: project.projectId },
30
+ };
31
+ const paseo = { agents: { list: async (options: { filter?: { projectKeys?: string[] } }) => ({
32
+ entries: !options.filter?.projectKeys || options.filter.projectKeys.includes(entry.project.projectKey) ? [entry] : [],
33
+ pageInfo: { hasMore: false, nextCursor: null },
34
+ }) } };
35
+ const incorrect = await loadWorkspaceAgentStatuses(paseo, workspace.id, project.projectKey);
36
+ assert.deepEqual(incorrect, {});
37
+ for (let poll = 0; poll < 2; poll++) {
38
+ const statuses = await loadWorkspaceAgentStatuses(paseo, workspace.id, workspace.projectId);
39
+ assert.equal(statuses.waiting?.permissionCount, 1);
40
+ assert.equal(statuses.waiting?.rank, 0);
41
+ assert.equal(attentionKind(statuses.waiting), "permission");
42
+ }
43
+ const fallback = await loadWorkspaceAgentStatuses(paseo, workspace.id);
44
+ assert.equal(fallback.waiting?.permissionCount, 1);
45
+ });
46
+
47
+ test("agentStatusInfo maps parentAgentId and preserves it on partial pushes", () => {
48
+ const first = agentStatusInfo({ id: "child", workspaceId: "w", parentAgentId: "parent" });
49
+ assert.equal(first.parentAgentId, "parent");
50
+ const partial = agentStatusInfo(
51
+ { id: "child", workspaceId: "w", status: "running", pendingPermissions: [{}] },
52
+ first,
53
+ );
54
+ assert.equal(partial.parentAgentId, "parent");
55
+ assert.equal(partial.status, "running");
56
+ assert.equal(partial.permissionCount, 1);
57
+ const cleared = agentStatusInfo(
58
+ { id: "child", workspaceId: "w", parentAgentId: null },
59
+ partial,
60
+ );
61
+ assert.equal(cleared.parentAgentId, null);
62
+ });
63
+
64
+ test("agentStatusInfo falls back to paseo.parent-agent-id label when field is null", () => {
65
+ const fromLabel = agentStatusInfo({
66
+ id: "child",
67
+ workspaceId: "w",
68
+ parentAgentId: null,
69
+ labels: { "paseo.parent-agent-id": "e59c28e7-91f6-4571-b182-56c9b93116c6" },
70
+ });
71
+ assert.equal(fromLabel.parentAgentId, "e59c28e7-91f6-4571-b182-56c9b93116c6");
72
+ const prefersField = agentStatusInfo({
73
+ id: "child",
74
+ workspaceId: "w",
75
+ parentAgentId: "root",
76
+ labels: { "paseo.parent-agent-id": "other" },
77
+ });
78
+ assert.equal(prefersField.parentAgentId, "root");
79
+ });
80
+
81
+ test("applyAgentStatusUpdate marks remove as closed and merges upserts without workspaceId", () => {
82
+ const map = {
83
+ a: agentStatusInfo({ id: "a", workspaceId: "w", status: "idle" }),
84
+ b: agentStatusInfo({ id: "b", workspaceId: "w", status: "running", pendingPermissions: [{}] }),
85
+ };
86
+ applyAgentStatusUpdate(map, "w", { kind: "remove", agentId: "a" });
87
+ assert.equal(map.a.status, "closed");
88
+ assert.equal(map.a.permissionCount, 0);
89
+ applyAgentStatusUpdate(map, "w", {
90
+ kind: "upsert",
91
+ agent: { id: "b", status: "closed" },
92
+ });
93
+ assert.equal(map.b.status, "closed");
94
+ assert.equal(map.b.permissionCount, 1);
95
+ applyAgentStatusUpdate(map, "w", {
96
+ kind: "upsert",
97
+ agent: { id: "c", status: "idle" },
98
+ });
99
+ assert.equal(
100
+ (map as Record<string, ReturnType<typeof agentStatusInfo>>).c,
101
+ undefined,
102
+ );
103
+ });
@@ -5,7 +5,7 @@ import {
5
5
  type AgentStatusInfo,
6
6
  } from "./constants.ts";
7
7
 
8
- type HostAgentEntry = {
8
+ export type HostAgentEntry = {
9
9
  agent: {
10
10
  id: string;
11
11
  workspaceId?: string;
@@ -13,13 +13,31 @@ type HostAgentEntry = {
13
13
  updatedAt?: string;
14
14
  requiresAttention?: boolean;
15
15
  attentionReason?: string | null;
16
+ pendingPermissions?: ReadonlyArray<unknown>;
17
+ parentAgentId?: string | null;
18
+ labels?: Readonly<Record<string, string>>;
16
19
  };
17
20
  };
18
21
 
22
+ export type HostAgentUpdate =
23
+ | { kind: "remove"; agentId: string }
24
+ | { kind: "upsert"; agent: HostAgentEntry["agent"] };
25
+
26
+ /** Prefer first-class parentAgentId; fall back to legacy label (agent-crew / older snapshots). */
27
+ export const PARENT_AGENT_ID_LABEL = "paseo.parent-agent-id";
28
+
29
+ export function resolveParentAgentId(agent: HostAgentEntry["agent"]): string | null {
30
+ const firstClass = agent.parentAgentId;
31
+ if (typeof firstClass === "string" && firstClass.trim()) return firstClass.trim();
32
+ const legacy = agent.labels?.[PARENT_AGENT_ID_LABEL];
33
+ return typeof legacy === "string" && legacy.trim() ? legacy.trim() : null;
34
+ }
35
+
19
36
  type HostAgentsApi = {
20
37
  agents: {
38
+ subscribe?: (handler: (update: HostAgentUpdate) => void) => () => void;
21
39
  list: (options: {
22
- filter?: { includeArchived?: boolean };
40
+ filter?: { includeArchived?: boolean; projectKeys?: string[] };
23
41
  page?: { limit: number; cursor?: string };
24
42
  }) => Promise<{
25
43
  entries: ReadonlyArray<HostAgentEntry>;
@@ -28,30 +46,102 @@ type HostAgentsApi = {
28
46
  };
29
47
  };
30
48
 
31
- /** Fetch all host agents (paged) and build workspace-scoped status enrichment. */
49
+ /**
50
+ * Fetch project agents then enforce workspace scope. In daemon 0.8,
51
+ * ProjectPlacement.projectKey is projectId; the project catalog's repository
52
+ * key is a different identifier and produces an empty agent directory.
53
+ */
32
54
  export async function loadWorkspaceAgentStatuses(
33
55
  paseo: HostAgentsApi,
34
56
  workspaceId: string,
57
+ projectId?: string | null,
35
58
  ): Promise<Record<string, AgentStatusInfo>> {
36
- const entries = await listAllAgentPages(
37
- async (cursor) => {
38
- const result = await paseo.agents.list({
39
- filter: { includeArchived: true },
40
- page: { limit: HOST_AGENT_PAGE_LIMIT, ...(cursor ? { cursor } : {}) },
41
- });
42
- return { entries: result.entries, pageInfo: result.pageInfo };
43
- },
44
- );
45
-
46
- const map: Record<string, AgentStatusInfo> = {};
47
- for (const entry of entries) {
48
- const agent = entry.agent;
49
- if (agent.workspaceId && agent.workspaceId !== workspaceId) continue;
50
- map[agent.id] = {
51
- rank: attentionRank(agent),
52
- updatedAt: agent.updatedAt ?? null,
53
- status: agent.status ?? null,
54
- };
59
+ const pending: HostAgentUpdate[] = [];
60
+ const unsubscribe = paseo.agents.subscribe?.((update) => pending.push(update));
61
+ try {
62
+ const entries = await listAllAgentPages(
63
+ async (cursor) => {
64
+ const result = await paseo.agents.list({
65
+ filter: { includeArchived: true, ...(projectId ? { projectKeys: [projectId] } : {}) },
66
+ page: { limit: HOST_AGENT_PAGE_LIMIT, ...(cursor ? { cursor } : {}) },
67
+ });
68
+ return { entries: result.entries, pageInfo: result.pageInfo };
69
+ },
70
+ );
71
+
72
+ const map: Record<string, AgentStatusInfo> = {};
73
+ for (const entry of entries) {
74
+ const agent = entry.agent;
75
+ if (agent.workspaceId !== workspaceId) continue;
76
+ map[agent.id] = agentStatusInfo(agent);
77
+ }
78
+ for (const update of pending) applyAgentStatusUpdate(map, workspaceId, update);
79
+ return map;
80
+ } finally {
81
+ unsubscribe?.();
82
+ }
83
+ }
84
+
85
+ export function applyAgentStatusUpdate(
86
+ map: Record<string, AgentStatusInfo>, workspaceId: string, update: HostAgentUpdate,
87
+ ): void {
88
+ const id = update.kind === "remove" ? update.agentId : update.agent.id;
89
+ if (update.kind === "remove") {
90
+ // Keep the row as Closed so Lifecycle filters work until the next list poll.
91
+ const previous = map[id];
92
+ if (!previous) return;
93
+ map[id] = agentStatusInfo(
94
+ { id, workspaceId, status: "closed", updatedAt: previous.updatedAt ?? undefined },
95
+ previous,
96
+ );
97
+ return;
98
+ }
99
+ const agentWorkspaceId = update.agent.workspaceId;
100
+ if (agentWorkspaceId != null && agentWorkspaceId !== workspaceId) {
101
+ delete map[id];
102
+ return;
55
103
  }
56
- return map;
104
+ // Missing workspaceId: still merge when we already track the agent (043).
105
+ if (agentWorkspaceId == null && !(id in map)) return;
106
+ map[id] = agentStatusInfo(update.agent, map[id]);
107
+ }
108
+
109
+ /** Map host agent → status; preserve prior attention fields when the push omits them. */
110
+ export function agentStatusInfo(
111
+ agent: HostAgentEntry["agent"],
112
+ previous?: AgentStatusInfo,
113
+ ): AgentStatusInfo {
114
+ const permissionCount =
115
+ agent.pendingPermissions !== undefined
116
+ ? agent.pendingPermissions.length
117
+ : (previous?.permissionCount ?? 0);
118
+ const requiresAttention =
119
+ agent.requiresAttention !== undefined
120
+ ? agent.requiresAttention === true
121
+ : (previous?.requiresAttention ?? false);
122
+ const attentionReason =
123
+ agent.attentionReason !== undefined
124
+ ? agent.attentionReason
125
+ : (previous?.attentionReason ?? null);
126
+ const parentSpecified =
127
+ agent.parentAgentId !== undefined ||
128
+ (agent.labels != null && PARENT_AGENT_ID_LABEL in agent.labels);
129
+ const parentAgentId = parentSpecified
130
+ ? resolveParentAgentId(agent)
131
+ : (previous?.parentAgentId ?? null);
132
+ return {
133
+ rank: attentionRank({
134
+ status: agent.status,
135
+ requiresAttention,
136
+ attentionReason,
137
+ pendingPermissions: agent.pendingPermissions ??
138
+ (permissionCount > 0 ? Array.from({ length: permissionCount }) : undefined),
139
+ }),
140
+ updatedAt: agent.updatedAt ?? previous?.updatedAt ?? null,
141
+ status: agent.status ?? previous?.status ?? null,
142
+ permissionCount,
143
+ requiresAttention,
144
+ attentionReason,
145
+ parentAgentId,
146
+ };
57
147
  }
@@ -6,7 +6,9 @@ import {
6
6
  } from "@getpaseo/plugin/client";
7
7
  import { useToast } from "@getpaseo/plugin/client/react-native";
8
8
  import { useQuery, useQueryClient } from "@tanstack/react-query";
9
- import { useMemo, useRef, useState } from "react";
9
+ import { useEffect, useMemo, useRef, useState } from "react";
10
+ import { useRegisterOpenAgent } from "../open-agent.ts";
11
+ import { useWorkspaceAgentStatuses } from "../use-workspace-agent-statuses.ts";
10
12
  import {
11
13
  ActivityIndicator,
12
14
  Dimensions,
@@ -26,13 +28,16 @@ import {
26
28
  type AgentUsageItem,
27
29
  usageAgentUnarchiveRpc,
28
30
  usageAgentsRpc,
31
+ usageHostInfoRpc,
29
32
  usageMcpByToolRpc,
30
33
  usageSkillsByNameRpc,
31
34
  usageSummaryRpc,
32
35
  } from "../../shared/usage.ts";
33
36
  import { useAppLanguage } from "../use-app-language.ts";
37
+ import { useWorkspaceActivityRefresh } from "../use-agent-turn-end.ts";
34
38
  import { UsageStats } from "../usage-stats.tsx";
35
39
  import { AgentsSection } from "./agents-section.tsx";
40
+ import { WorkspaceAgentLiveStatusSync } from "./agent-live-status-sync.tsx";
36
41
  import {
37
42
  AGENT_HEADER_HEIGHT,
38
43
  GROUP_OPTIONS,
@@ -42,6 +47,7 @@ import {
42
47
  SHOW_FIELD_OPTIONS,
43
48
  SORT_OPTIONS,
44
49
  STATUS_FILTER_OPTIONS,
50
+ TERMINAL_REFETCH_MS,
45
51
  agentUpdatedAt,
46
52
  matchesAgentFilters,
47
53
  optionLabel,
@@ -55,11 +61,13 @@ import {
55
61
  } from "./constants.ts";
56
62
  import { MenuOptionList, MenuSubTrigger } from "./display-menu.tsx";
57
63
  import { matchesAgentTitle } from "./filters.ts";
58
- import { loadWorkspaceAgentStatuses } from "./list-host-agents.ts";
59
64
  import { RankSection } from "./rank-section.tsx";
65
+ import { TerminalsSection, type TerminalListItem } from "./terminals-section.tsx";
60
66
 
61
67
  type RankKind = "skills" | "mcp";
62
68
 
69
+ const MONO = Platform.select({ ios: "Menlo", default: "monospace" });
70
+
63
71
  /** Workspace-scoped Activity for the Explorer (024 / 031). */
64
72
  export function WorkspaceActivityPanel({
65
73
  theme,
@@ -92,11 +100,13 @@ export function WorkspaceActivityPanel({
92
100
  const [agentSearchQuery, setAgentSearchQuery] = useState("");
93
101
  const [rankKind, setRankKind] = useState<RankKind>("skills");
94
102
  const [busyAgentId, setBusyAgentId] = useState<string | null>(null);
103
+ const [busyTerminalId, setBusyTerminalId] = useState<string | null>(null);
95
104
  const padding = layout.compact ? 16 : 24;
96
105
  const locale = useAppLanguage();
97
106
  const toast = useToast();
98
107
  const queryClient = useQueryClient();
99
108
  const openAgent = navigation?.openAgent;
109
+ useRegisterOpenAgent(openAgent);
100
110
  const rootRef = useRef<View>(null);
101
111
  const triggerRef = useRef<View>(null);
102
112
 
@@ -110,8 +120,10 @@ export function WorkspaceActivityPanel({
110
120
  const unarchiveAgentRpc = useRpc(usageAgentUnarchiveRpc);
111
121
  const skillsRpc = useRpc(usageSkillsByNameRpc);
112
122
  const mcpRpc = useRpc(usageMcpByToolRpc);
123
+ const hostInfoRpc = useRpc(usageHostInfoRpc);
113
124
 
114
125
  const agentsQueryKey = ["activity", "workspace-agents", workspaceId] as const;
126
+ const terminalsQueryKey = ["activity", "workspace-terminals", workspaceId] as const;
115
127
 
116
128
  const summary = useQuery({
117
129
  refetchInterval: 15_000,
@@ -142,14 +154,40 @@ export function WorkspaceActivityPanel({
142
154
  });
143
155
 
144
156
  const paseo = usePaseo();
145
- const statuses = useQuery({
146
- refetchInterval: 15_000,
157
+ const terminals = useQuery({
158
+ refetchInterval: TERMINAL_REFETCH_MS,
159
+ retry: false,
160
+ queryKey: terminalsQueryKey,
161
+ queryFn: () => paseo.terminals.list({ workspaceId }),
162
+ });
163
+
164
+ const hostInfo = useQuery({
165
+ staleTime: Infinity,
147
166
  retry: false,
148
- queryKey: ["activity", "workspace-agent-status", workspaceId],
149
- queryFn: () => loadWorkspaceAgentStatuses(paseo, workspaceId),
167
+ queryKey: ["activity", "host-info"],
168
+ queryFn: () => hostInfoRpc({}),
169
+ });
170
+
171
+ const statuses = useWorkspaceAgentStatuses(workspaceId);
172
+
173
+ useWorkspaceActivityRefresh(workspaceId, () => {
174
+ void queryClient.invalidateQueries({
175
+ queryKey: ["activity", "workspace-summary", workspaceId],
176
+ });
177
+ void queryClient.invalidateQueries({ queryKey: agentsQueryKey });
178
+ void queryClient.invalidateQueries({
179
+ queryKey: ["activity", "workspace-skills", workspaceId],
180
+ });
181
+ void queryClient.invalidateQueries({
182
+ queryKey: ["activity", "workspace-mcp", workspaceId],
183
+ });
150
184
  });
151
185
 
152
186
  const agentItems = agents.data?.items ?? [];
187
+ const liveStatusAgentIds = useMemo(
188
+ () => agentItems.map((item) => item.agentId),
189
+ [agentItems],
190
+ );
153
191
  const visibleAgentItems = useMemo(() => {
154
192
  const byId = statuses.data;
155
193
  const filtered = agentItems
@@ -195,7 +233,10 @@ export function WorkspaceActivityPanel({
195
233
  () => (skills.data?.items ?? []).filter((item) => item.total > 0),
196
234
  [skills.data],
197
235
  );
198
- const allMcp = mcp.data?.items ?? [];
236
+ const allMcp = useMemo(
237
+ () => (mcp.data?.items ?? []).filter((item) => item.count > 0),
238
+ [mcp.data],
239
+ );
199
240
  const skillItems = useMemo(() => allSkills.slice(0, ACTIVITY_LIST_LIMIT), [allSkills]);
200
241
  const mcpItems = useMemo(() => allMcp.slice(0, ACTIVITY_LIST_LIMIT), [allMcp]);
201
242
 
@@ -213,9 +254,18 @@ export function WorkspaceActivityPanel({
213
254
  },
214
255
  ];
215
256
 
257
+ const terminalItems = terminals.data?.entries ?? [];
216
258
  const showAgents = agentItems.length > 0;
217
259
  const showRank = skillItems.length > 0 || mcpItems.length > 0;
218
- const showContent = showAgents || showRank;
260
+ const showRankToggle = skillItems.length > 0 && mcpItems.length > 0;
261
+ const showTerminals = terminalItems.length > 0;
262
+ const showContent = showAgents || showRank || showTerminals;
263
+
264
+ useEffect(() => {
265
+ if (skillItems.length === 0 && mcpItems.length === 0) return;
266
+ if (rankKind === "skills" && skillItems.length === 0) setRankKind("mcp");
267
+ else if (rankKind === "mcp" && mcpItems.length === 0) setRankKind("skills");
268
+ }, [skillItems.length, mcpItems.length, rankKind]);
219
269
 
220
270
  const styles = useMemo(
221
271
  () => ({
@@ -304,21 +354,21 @@ export function WorkspaceActivityPanel({
304
354
  },
305
355
  sectionTitle: {
306
356
  color: theme.colors.foreground,
307
- fontSize: layout.compact ? 18 : 20,
357
+ fontSize: 16,
308
358
  fontWeight: "600" as const,
309
359
  flexShrink: 0,
310
360
  letterSpacing: -0.3,
311
361
  lineHeight: AGENT_HEADER_HEIGHT,
312
362
  },
313
363
  panel: {
314
- gap: 4,
364
+ gap: 2,
315
365
  overflow: "hidden" as const,
316
366
  },
317
367
  listRow: {
318
368
  flexDirection: "row" as const,
319
369
  alignItems: "center" as const,
320
370
  gap: 12,
321
- paddingVertical: 12,
371
+ paddingVertical: 6,
322
372
  },
323
373
  agentListRow: {
324
374
  flexDirection: "row" as const,
@@ -326,6 +376,44 @@ export function WorkspaceActivityPanel({
326
376
  gap: 10,
327
377
  paddingVertical: 6,
328
378
  },
379
+ agentIconWrap: {
380
+ width: 18,
381
+ height: 18,
382
+ alignItems: "center" as const,
383
+ justifyContent: "center" as const,
384
+ },
385
+ runningBadge: {
386
+ position: "absolute" as const,
387
+ right: -4,
388
+ bottom: -4,
389
+ width: 13,
390
+ height: 13,
391
+ borderRadius: 6.5,
392
+ alignItems: "center" as const,
393
+ justifyContent: "center" as const,
394
+ backgroundColor: theme.colors.surface0,
395
+ },
396
+ subAgentBadge: {
397
+ position: "absolute" as const,
398
+ right: -5,
399
+ bottom: -5,
400
+ minWidth: 14,
401
+ height: 14,
402
+ paddingHorizontal: 3,
403
+ borderRadius: 7,
404
+ alignItems: "center" as const,
405
+ justifyContent: "center" as const,
406
+ backgroundColor: theme.colors.surface0,
407
+ borderWidth: 1,
408
+ borderColor: theme.colors.border,
409
+ },
410
+ subAgentBadgeText: {
411
+ color: theme.colors.foregroundMuted,
412
+ fontSize: 9,
413
+ fontWeight: "700" as const,
414
+ fontVariant: ["tabular-nums" as const],
415
+ lineHeight: 11,
416
+ },
329
417
  listMain: {
330
418
  flex: 1,
331
419
  minWidth: 0,
@@ -345,6 +433,45 @@ export function WorkspaceActivityPanel({
345
433
  color: theme.colors.foregroundMuted,
346
434
  fontSize: 12,
347
435
  },
436
+ permissionBadge: {
437
+ flexDirection: "row" as const,
438
+ alignItems: "center" as const,
439
+ gap: 3,
440
+ height: 18,
441
+ paddingHorizontal: 5,
442
+ borderRadius: 9,
443
+ borderWidth: 1,
444
+ borderColor: theme.colors.border,
445
+ backgroundColor: theme.colors.surface1,
446
+ flexShrink: 0,
447
+ },
448
+ permissionBadgeText: {
449
+ color: theme.colors.statusWarning,
450
+ fontSize: 11,
451
+ fontWeight: "600" as const,
452
+ fontVariant: ["tabular-nums" as const],
453
+ },
454
+ terminalRow: {
455
+ flexDirection: "row" as const,
456
+ alignItems: "center" as const,
457
+ gap: 10,
458
+ paddingVertical: 6,
459
+ },
460
+ terminalPreview: {
461
+ marginLeft: 28,
462
+ marginBottom: 4,
463
+ paddingVertical: 8,
464
+ paddingHorizontal: 10,
465
+ borderRadius: 6,
466
+ backgroundColor: theme.colors.surface1,
467
+ gap: 2,
468
+ },
469
+ terminalLine: {
470
+ color: theme.colors.foregroundMuted,
471
+ fontFamily: MONO,
472
+ fontSize: 11,
473
+ lineHeight: 15,
474
+ },
348
475
  countText: {
349
476
  color: theme.colors.foregroundMuted,
350
477
  fontSize: 13,
@@ -653,6 +780,38 @@ export function WorkspaceActivityPanel({
653
780
  }
654
781
  }
655
782
 
783
+ function patchTerminalRemoved(terminalId: string) {
784
+ queryClient.setQueryData<{ entries: TerminalListItem[]; requestId: string }>(
785
+ terminalsQueryKey,
786
+ (prev) =>
787
+ prev
788
+ ? { ...prev, entries: prev.entries.filter((entry) => entry.id !== terminalId) }
789
+ : prev,
790
+ );
791
+ }
792
+
793
+ async function closeTerminal(item: TerminalListItem) {
794
+ if (busyTerminalId != null) return;
795
+ setBusyTerminalId(item.id);
796
+ const previous = queryClient.getQueryData<{
797
+ entries: TerminalListItem[];
798
+ requestId: string;
799
+ }>(terminalsQueryKey);
800
+ patchTerminalRemoved(item.id);
801
+ try {
802
+ await paseo.terminals.ref(item.id).kill();
803
+ queryClient.removeQueries({
804
+ queryKey: ["activity", "terminal-capture", workspaceId, item.id],
805
+ });
806
+ await queryClient.invalidateQueries({ queryKey: terminalsQueryKey });
807
+ } catch (err) {
808
+ if (previous) queryClient.setQueryData(terminalsQueryKey, previous);
809
+ toast.error(err instanceof Error ? err.message : String(err));
810
+ } finally {
811
+ setBusyTerminalId(null);
812
+ }
813
+ }
814
+
656
815
  return (
657
816
  <View ref={rootRef} collapsable={false} style={styles.shell}>
658
817
  <View style={styles.screen}>
@@ -679,14 +838,21 @@ export function WorkspaceActivityPanel({
679
838
  ) : null}
680
839
 
681
840
  {showAgents ? (
682
- <AgentsSection
841
+ <>
842
+ <WorkspaceAgentLiveStatusSync
843
+ agentIds={liveStatusAgentIds}
844
+ workspaceId={workspaceId}
845
+ />
846
+ <AgentsSection
683
847
  theme={theme}
684
848
  styles={styles}
685
849
  locale={locale}
686
850
  agentGroup={agentGroup}
687
851
  agentShowFields={agentShowFields}
688
852
  statuses={statuses.data}
853
+ agentItems={agentItems}
689
854
  visibleAgentItems={visibleAgentItems}
855
+ statusFilters={agentStatusFilters}
690
856
  statusFiltersEmpty={
691
857
  agentStatusFilters.size === 0 || agentLifecycleFilters.size === 0
692
858
  }
@@ -704,6 +870,19 @@ export function WorkspaceActivityPanel({
704
870
  onUnarchive={(item) => void unarchiveAgent(item)}
705
871
  resetKey={workspaceId}
706
872
  />
873
+ </>
874
+ ) : null}
875
+
876
+ {showTerminals ? (
877
+ <TerminalsSection
878
+ workspaceId={workspaceId}
879
+ terminalItems={terminalItems}
880
+ busyTerminalId={busyTerminalId}
881
+ homeDir={hostInfo.data?.homeDir}
882
+ mutedColor={theme.colors.foregroundMuted}
883
+ styles={styles}
884
+ onClose={(item) => void closeTerminal(item)}
885
+ />
707
886
  ) : null}
708
887
 
709
888
  {showRank ? (
@@ -712,6 +891,7 @@ export function WorkspaceActivityPanel({
712
891
  onToggleKind={() =>
713
892
  setRankKind((prev) => (prev === "skills" ? "mcp" : "skills"))
714
893
  }
894
+ showToggle={showRankToggle}
715
895
  skillItems={skillItems}
716
896
  mcpItems={mcpItems}
717
897
  mutedColor={theme.colors.foregroundMuted}