pi-crew 0.1.34 → 0.1.35
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/docs/research-source-pi-crew-reference.md +174 -0
- package/package.json +1 -1
- package/src/extension/register.ts +1 -1
- package/src/runtime/child-pi.ts +5 -1
- package/src/ui/dashboard-panes/agents-pane.ts +4 -1
- package/src/ui/live-run-sidebar.ts +5 -4
- package/src/ui/run-dashboard.ts +7 -3
- package/src/ui/spinner.ts +17 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# Research: `source/pi-crew` as New Reference Source
|
|
2
|
+
|
|
3
|
+
Date: 2026-04-29
|
|
4
|
+
Reference source: `D:/my/my_project/source/pi-crew` (`@melihmucuk/pi-crew@1.0.14`, commit `c0631a3`)
|
|
5
|
+
Current target: `D:/my/my_project/pi-crew` (`pi-crew@0.1.34`)
|
|
6
|
+
Research run: `team_20260429091311_8047706b`
|
|
7
|
+
|
|
8
|
+
> Note: the parallel research run produced useful artifacts, but child workers were marked failed because they did not exit within 5s after their final assistant message. The source audit content was still captured in result/shared artifacts.
|
|
9
|
+
|
|
10
|
+
## Executive Summary
|
|
11
|
+
|
|
12
|
+
`source/pi-crew` is a compact, in-process subagent orchestration extension. It is not a team/workflow engine; instead, it focuses on fast non-blocking subagent sessions, owner-routed steering-message delivery, interactive subagents, and context-overflow recovery. It is valuable as a reference for **session-native subagent runtime**, **delivery semantics**, and **minimal interactive worker UX**.
|
|
13
|
+
|
|
14
|
+
Current `pi-crew` is more powerful and durable: child Pi workers, teams/workflows, task graph scheduling, worktrees, mailbox, event logs, dashboard, notifications, and recovery state. The best path is not replacement; it is selective porting of patterns into `pi-crew`'s existing `live-session-runtime` / `SubagentManager` as an optional session-native lane.
|
|
15
|
+
|
|
16
|
+
## Source File Map
|
|
17
|
+
|
|
18
|
+
| Area | Reference files |
|
|
19
|
+
|---|---|
|
|
20
|
+
| Extension entry/session hooks | `source/pi-crew/extension/index.ts` |
|
|
21
|
+
| Runtime singleton | `source/pi-crew/extension/runtime/crew-runtime.ts` |
|
|
22
|
+
| Delivery routing | `source/pi-crew/extension/runtime/delivery-coordinator.ts` |
|
|
23
|
+
| State model/registry | `source/pi-crew/extension/runtime/subagent-state.ts`, `source/pi-crew/extension/runtime/subagent-registry.ts` |
|
|
24
|
+
| Overflow recovery | `source/pi-crew/extension/runtime/overflow-recovery.ts` |
|
|
25
|
+
| Session bootstrap | `source/pi-crew/extension/bootstrap-session.ts` |
|
|
26
|
+
| Agent discovery | `source/pi-crew/extension/agent-discovery.ts` |
|
|
27
|
+
| Tool registration | `source/pi-crew/extension/integration/register-tools.ts`, `source/pi-crew/extension/integration/tools/*.ts` |
|
|
28
|
+
| Message renderers | `source/pi-crew/extension/integration/register-renderers.ts` |
|
|
29
|
+
| Message formatting | `source/pi-crew/extension/subagent-messages.ts` |
|
|
30
|
+
| Status widget | `source/pi-crew/extension/status-widget.ts` |
|
|
31
|
+
| Architecture doc | `source/pi-crew/docs/architecture.md` |
|
|
32
|
+
|
|
33
|
+
## Architecture Observations
|
|
34
|
+
|
|
35
|
+
### Reference `source/pi-crew`
|
|
36
|
+
|
|
37
|
+
- Process-level singleton `CrewRuntime` survives Pi runtime/session replacement and rebinds on `session_start`.
|
|
38
|
+
- Subagents are in-process SDK `AgentSession`s created with `createAgentSession()`.
|
|
39
|
+
- Parent/child linkage uses `SessionManager.newSession({ parentSession })`.
|
|
40
|
+
- Subagent resource loading filters out the pi-crew extension through `extensionsOverride` to prevent recursive `crew_spawn` loops.
|
|
41
|
+
- Results are delivered through Pi-native `sendMessage()` with explicit idle/streaming semantics.
|
|
42
|
+
- Interactive subagents are first-class: `interactive: true` workers enter `waiting`; parent continues with `crew_respond`; cleanup is explicit with `crew_done`.
|
|
43
|
+
- Overflow recovery tracks `agent_end`, `compaction_start/end`, and `auto_retry_start/end` events around `session.prompt()`.
|
|
44
|
+
- State is in-memory only; subagent session files remain for post-hoc `/resume` inspection.
|
|
45
|
+
|
|
46
|
+
### Current `pi-crew`
|
|
47
|
+
|
|
48
|
+
- Primary runtime is child Pi process execution with durable `.crew/state` manifests and artifacts.
|
|
49
|
+
- It has workflow/team abstractions, task graphs, worktree support, event log, mailbox, dashboard panes, render scheduler, notifications, and diagnostic exports.
|
|
50
|
+
- It already has `live-session-runtime.ts`, but the current product surface centers on durable child-process workers rather than interactive in-process subagents.
|
|
51
|
+
|
|
52
|
+
## Extension API Patterns Worth Reusing
|
|
53
|
+
|
|
54
|
+
| Pattern | Reference source | Why it matters for current `pi-crew` |
|
|
55
|
+
|---|---|---|
|
|
56
|
+
| Owner-routed delivery by `sessionManager.getSessionId()` | `delivery-coordinator.ts` | Avoids sending async worker results to the wrong active session after `/resume`, `/new`, `/fork`, or multi-session use. |
|
|
57
|
+
| Idle vs streaming delivery split | `subagent-messages.ts`, `delivery-coordinator.ts` | Prevents messages from getting stuck: idle sessions need `triggerTurn`; streaming sessions need `deliverAs: "steer"`. |
|
|
58
|
+
| Deferred pending flush via `setTimeout(0)` | `delivery-coordinator.ts` | Avoids lost JSONL/custom-message persistence during resume before listeners reconnect. |
|
|
59
|
+
| `extensionsOverride` filter | `bootstrap-session.ts` | Required for any in-process worker lane to prevent recursive subagent spawning. |
|
|
60
|
+
| Fire-and-forget interactive response | `crew-respond.ts`, `crew-runtime.ts` | Lets parent stay responsive while an interactive worker continues in background. |
|
|
61
|
+
| No duplicate done message | `crew-done.ts` | Avoids repeating the last subagent response during cleanup. |
|
|
62
|
+
| Source-specific abort reasons | `crew-abort.ts`, `index.ts` shutdown handlers | Better diagnostics than generic "aborted by user". |
|
|
63
|
+
| Emergency unrestricted abort command | `register-command.ts` | Useful escape hatch distinct from owner-scoped tool actions. |
|
|
64
|
+
| Overflow tracker around SDK prompt | `overflow-recovery.ts` | Better UX for context overflow/compaction/retry in session-native workers. |
|
|
65
|
+
|
|
66
|
+
## Key Differences / Non-Goals
|
|
67
|
+
|
|
68
|
+
| Dimension | Reference `source/pi-crew` | Current `pi-crew` |
|
|
69
|
+
|---|---|---|
|
|
70
|
+
| Runtime | In-process `AgentSession` | Child Pi processes + durable orchestration |
|
|
71
|
+
| State | In-memory map | Durable manifests/event logs/artifacts |
|
|
72
|
+
| Scope | Flat subagent spawn/respond/done | Teams, workflows, task graph, worktrees |
|
|
73
|
+
| Result UX | Pi steering/custom messages | Tool results, mailbox, dashboard, async status |
|
|
74
|
+
| Interactive workers | Native | Not yet first-class |
|
|
75
|
+
| Worktree isolation | None | First-class |
|
|
76
|
+
| Replay/restart | Limited | Strong durable recovery |
|
|
77
|
+
|
|
78
|
+
Do **not** replace the current runtime wholesale. Reference `source/pi-crew` lacks durable state, worktrees, workflow scheduling, artifact indexing, and the Phase 8 operator experience. Its best value is a narrower session-native execution lane and delivery correctness patterns.
|
|
79
|
+
|
|
80
|
+
## Recommendations
|
|
81
|
+
|
|
82
|
+
### P0 — Adopt Delivery Semantics for Async/Live Results
|
|
83
|
+
|
|
84
|
+
Implement or adapt a small owner-routed delivery coordinator in current `pi-crew`:
|
|
85
|
+
|
|
86
|
+
- Key by owner `sessionId`, not session file.
|
|
87
|
+
- Queue pending messages when owner inactive.
|
|
88
|
+
- On `session_start`, flush pending messages on next macrotask.
|
|
89
|
+
- Use idle/streaming split:
|
|
90
|
+
- idle: `sendMessage(payload, { triggerTurn: true })`
|
|
91
|
+
- streaming: `sendMessage(payload, { deliverAs: "steer", triggerTurn: true })`
|
|
92
|
+
- Keep current mailbox/event-log as durable source of truth; use delivery coordinator only for live UX.
|
|
93
|
+
|
|
94
|
+
Likely target files:
|
|
95
|
+
|
|
96
|
+
- `pi-crew/src/extension/register.ts`
|
|
97
|
+
- `pi-crew/src/runtime/subagent-manager.ts`
|
|
98
|
+
- `pi-crew/src/runtime/live-session-runtime.ts`
|
|
99
|
+
- `pi-crew/src/extension/notification-router.ts`
|
|
100
|
+
|
|
101
|
+
### P1 — Add Optional Session-Native Subagent Lane
|
|
102
|
+
|
|
103
|
+
Build an opt-in lane on top of existing `live-session-runtime.ts` rather than changing the default child-process runtime:
|
|
104
|
+
|
|
105
|
+
- `runtime.mode = "child-process" | "live-session" | "auto"` already exists conceptually; tighten semantics.
|
|
106
|
+
- Use `SessionManager.newSession({ parentSession })` and `createAgentSession()` for in-process workers.
|
|
107
|
+
- Filter `pi-crew` out of subagent resource loader extensions.
|
|
108
|
+
- Persist minimal metadata to existing `.crew/state` so dashboards/recovery still work.
|
|
109
|
+
|
|
110
|
+
This can reduce process startup overhead and blank console issues, while preserving child-process isolation as the safe default.
|
|
111
|
+
|
|
112
|
+
### P1 — Introduce Interactive Worker Semantics
|
|
113
|
+
|
|
114
|
+
Add first-class interactive subagents without disrupting teams:
|
|
115
|
+
|
|
116
|
+
- New status: `waiting` for interactive background workers.
|
|
117
|
+
- `crew_agent_respond` / `crew_agent_done` or extend existing `crew_agent_steer` semantics.
|
|
118
|
+
- Fire-and-forget response: parent tool returns immediately; worker response arrives as mailbox/steering message.
|
|
119
|
+
- `done` performs cleanup only; no duplicate response.
|
|
120
|
+
|
|
121
|
+
Likely target files:
|
|
122
|
+
|
|
123
|
+
- `pi-crew/src/runtime/crew-agent-records.ts`
|
|
124
|
+
- `pi-crew/src/runtime/subagent-manager.ts`
|
|
125
|
+
- `pi-crew/src/extension/registration/subagent-tools.ts`
|
|
126
|
+
- `pi-crew/src/state/mailbox.ts`
|
|
127
|
+
- `pi-crew/src/ui/dashboard-panes/agents-pane.ts`
|
|
128
|
+
|
|
129
|
+
### P2 — Port Overflow Recovery Tracker for Live Sessions
|
|
130
|
+
|
|
131
|
+
For session-native workers, wrap `AgentSession.prompt()` with an event tracker similar to `source/pi-crew/extension/runtime/overflow-recovery.ts`:
|
|
132
|
+
|
|
133
|
+
- Track `compaction_start/end` and `auto_retry_start/end`.
|
|
134
|
+
- Report recovered context overflow separately from hard failure.
|
|
135
|
+
- Emit durable event-log records and dashboard health hints.
|
|
136
|
+
|
|
137
|
+
This should not apply to child Pi workers directly; they already have process/transcript supervision.
|
|
138
|
+
|
|
139
|
+
### P2 — Improve Abort Reason Taxonomy
|
|
140
|
+
|
|
141
|
+
Adopt explicit abort source reasons across all worker paths:
|
|
142
|
+
|
|
143
|
+
- tool-triggered abort
|
|
144
|
+
- command-triggered emergency abort
|
|
145
|
+
- session quit cleanup
|
|
146
|
+
- session replacement detach/deactivate
|
|
147
|
+
- watchdog timeout
|
|
148
|
+
- stale heartbeat kill
|
|
149
|
+
|
|
150
|
+
This improves diagnostics, notification routing, and Phase 9 reliability work.
|
|
151
|
+
|
|
152
|
+
## Risks
|
|
153
|
+
|
|
154
|
+
- In-process sessions reduce OS/process isolation; failures or leaks may affect the parent Pi process.
|
|
155
|
+
- `extensionsOverride` is mandatory; missing it risks recursive subagent spawning.
|
|
156
|
+
- Pi SDK internals may shift; keep this lane optional and covered by integration tests.
|
|
157
|
+
- Delivery semantics must not bypass durable mailbox/event log; live messages are convenience, not source of truth.
|
|
158
|
+
- Interactive workers can linger in memory; require TTL/status visibility and explicit cleanup.
|
|
159
|
+
|
|
160
|
+
## Suggested Follow-Up Plan
|
|
161
|
+
|
|
162
|
+
1. Write a focused design doc: `docs/research-session-native-runtime-plan.md`.
|
|
163
|
+
2. Spike delivery coordinator only; no runtime swap.
|
|
164
|
+
3. Add tests for idle/streaming/inactive owner delivery behavior.
|
|
165
|
+
4. Add optional `live-session` worker lane behind config.
|
|
166
|
+
5. Add interactive worker status/actions after live delivery is stable.
|
|
167
|
+
|
|
168
|
+
## Research Artifacts
|
|
169
|
+
|
|
170
|
+
- `D:/my/my_project/.crew/artifacts/team_20260429091311_8047706b/results/01_discover.txt`
|
|
171
|
+
- `D:/my/my_project/.crew/artifacts/team_20260429091311_8047706b/results/02_explore-shard-1.txt`
|
|
172
|
+
- `D:/my/my_project/.crew/artifacts/team_20260429091311_8047706b/results/03_explore-shard-2.txt`
|
|
173
|
+
- `D:/my/my_project/.crew/artifacts/team_20260429091311_8047706b/results/04_explore-shard-3.txt`
|
|
174
|
+
- `D:/my/my_project/.crew/artifacts/team_20260429091311_8047706b/batches/01_discover+02_explore-shard-1+03_explore-shard-2+04_explore-shard-3.md`
|
package/package.json
CHANGED
|
@@ -318,7 +318,7 @@ export function registerPiTeams(pi: ExtensionAPI): void {
|
|
|
318
318
|
}
|
|
319
319
|
};
|
|
320
320
|
renderScheduler = new RenderScheduler(pi.events, renderTick, {
|
|
321
|
-
fallbackMs: loadedConfig.config.ui?.dashboardLiveRefreshMs ??
|
|
321
|
+
fallbackMs: loadedConfig.config.ui?.dashboardLiveRefreshMs ?? 250,
|
|
322
322
|
onInvalidate: () => getRunSnapshotCache(ctx.cwd).invalidate(),
|
|
323
323
|
});
|
|
324
324
|
});
|
package/src/runtime/child-pi.ts
CHANGED
|
@@ -430,7 +430,11 @@ export async function runChildPi(input: ChildPiRunInput): Promise<ChildPiRunResu
|
|
|
430
430
|
clearHardKillTimer(child.pid);
|
|
431
431
|
}
|
|
432
432
|
const timeoutError = responseTimeoutHit && !stderr.trim() ? { error: `Child Pi produced no new output for ${responseTimeoutMs}ms; process was terminated as unresponsive.` } : undefined;
|
|
433
|
-
|
|
433
|
+
// A final assistant event is the child Pi contract for "the worker produced its answer".
|
|
434
|
+
// Some Pi processes can linger during post-final cleanup/stdio shutdown; finalDrain terminates
|
|
435
|
+
// that lingering process so the parent can continue, but it must not turn a completed
|
|
436
|
+
// subagent answer into a failed task. Real pre-final response timeouts still report errors.
|
|
437
|
+
settle({ exitCode: forcedFinalDrain && !timeoutError ? 0 : exitCode, stdout, stderr, ...(timeoutError ? { error: timeoutError.error } : {}) });
|
|
434
438
|
});
|
|
435
439
|
});
|
|
436
440
|
} finally {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { RunDashboardOptions } from "../run-dashboard.ts";
|
|
2
|
+
import { iconForStatus } from "../status-colors.ts";
|
|
2
3
|
import type { RunUiSnapshot } from "../snapshot-types.ts";
|
|
4
|
+
import { spinnerFrame } from "../spinner.ts";
|
|
3
5
|
|
|
4
6
|
function tokens(agent: RunUiSnapshot["agents"][number]): string {
|
|
5
7
|
const total = (agent.usage?.input ?? 0) + (agent.usage?.output ?? agent.progress?.tokens ?? 0) + (agent.usage?.cacheRead ?? 0) + (agent.usage?.cacheWrite ?? 0);
|
|
@@ -19,7 +21,8 @@ export function renderAgentsPane(snapshot: RunUiSnapshot | undefined, options: R
|
|
|
19
21
|
options.showTokens !== false ? tokens(agent) : undefined,
|
|
20
22
|
options.showModel !== false ? (agent.model ? `model=${agent.model}` : undefined) : undefined,
|
|
21
23
|
].filter((part): part is string => Boolean(part));
|
|
22
|
-
|
|
24
|
+
const icon = iconForStatus(agent.status, { runningGlyph: spinnerFrame(agent.taskId) });
|
|
25
|
+
return `${icon} ${agent.taskId} ${agent.role}->${agent.agent} · ${parts.join(" · ")}`;
|
|
23
26
|
}),
|
|
24
27
|
];
|
|
25
28
|
}
|
|
@@ -13,9 +13,9 @@ import type { CrewTheme } from "./theme-adapter.ts";
|
|
|
13
13
|
import { asCrewTheme, subscribeThemeChange } from "./theme-adapter.ts";
|
|
14
14
|
import { Box, Text } from "./layout-primitives.ts";
|
|
15
15
|
import type { RunSnapshotCache, RunUiSnapshot } from "./snapshot-types.ts";
|
|
16
|
+
import { spinnerBucket, spinnerFrame } from "./spinner.ts";
|
|
16
17
|
|
|
17
18
|
const TASK_READ_TTL_MS = 200;
|
|
18
|
-
const SPINNER = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
19
19
|
|
|
20
20
|
function renderLines(lines: string[], width: number): string[] {
|
|
21
21
|
const box = new Box(0, 0);
|
|
@@ -75,10 +75,11 @@ export class LiveRunSidebar {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
private buildSignature(manifestStatus: string, tasks: TeamTaskState[], agents: ReturnType<typeof readCrewAgents>, waitingCount: number, snapshot?: RunUiSnapshot): string {
|
|
78
|
-
|
|
78
|
+
const animation = agents.some((agent) => agent.status === "running") ? `:spin=${spinnerBucket()}` : "";
|
|
79
|
+
if (snapshot) return `${snapshot.signature}:${waitingCount}${animation}`;
|
|
79
80
|
const taskSig = tasks.map((task) => `${task.id}:${task.status}:${task.startedAt ?? ""}:${task.finishedAt ?? ""}:${task.agentProgress?.currentTool ?? ""}:${task.agentProgress?.toolCount ?? 0}:${task.agentProgress?.tokens ?? 0}:${task.usage ? JSON.stringify(task.usage) : ""}`).join("|");
|
|
80
81
|
const agentSig = agents.map((agent) => [agent.id, agent.status, agent.startedAt, agent.completedAt ?? "", agent.progress?.currentTool ?? "", agent.progress?.toolCount ?? 0, agent.progress?.tokens ?? 0, agent.progress?.turns ?? 0, agent.progress?.lastActivityAt ?? "", agent.progress?.recentOutput.at(-1) ?? "", agent.toolUses ?? 0].join(":")).join("|");
|
|
81
|
-
return `${manifestStatus}|${agents.length}|${waitingCount}|${taskSig}|${agentSig}`;
|
|
82
|
+
return `${manifestStatus}|${agents.length}|${waitingCount}|${taskSig}|${agentSig}${animation}`;
|
|
82
83
|
}
|
|
83
84
|
|
|
84
85
|
private colorLine(line: string): string {
|
|
@@ -140,7 +141,7 @@ export class LiveRunSidebar {
|
|
|
140
141
|
line(`Active agents (${active.length})`, w),
|
|
141
142
|
];
|
|
142
143
|
for (const agent of active.slice(0, 8)) {
|
|
143
|
-
const status = iconForStatus(agent.status, { runningGlyph:
|
|
144
|
+
const status = iconForStatus(agent.status, { runningGlyph: spinnerFrame(agent.taskId) });
|
|
144
145
|
const usage = agent.usage ? formatUsage(agent.usage) : agent.progress?.tokens ? `tokens=${agent.progress.tokens}` : "usage=pending";
|
|
145
146
|
lines.push(line(`${status} ${agent.taskId} ${agent.role}->${agent.agent}`, w));
|
|
146
147
|
lines.push(line(` ${agent.routing ? `model ${agent.routing.requested ? `${agent.routing.requested} → ` : ""}${agent.routing.resolved}` : agent.model ? `model ${agent.model}` : "model pending"}`, w));
|
package/src/ui/run-dashboard.ts
CHANGED
|
@@ -19,6 +19,7 @@ import { renderTranscriptPane } from "./dashboard-panes/transcript-pane.ts";
|
|
|
19
19
|
import { renderHealthPane } from "./dashboard-panes/health-pane.ts";
|
|
20
20
|
import { dashboardActionForKey } from "./keybinding-map.ts";
|
|
21
21
|
import type { RunSnapshotCache, RunUiSnapshot } from "./snapshot-types.ts";
|
|
22
|
+
import { spinnerBucket, spinnerFrame } from "./spinner.ts";
|
|
22
23
|
|
|
23
24
|
interface DashboardComponent {
|
|
24
25
|
invalidate(): void;
|
|
@@ -140,7 +141,8 @@ function agentPreviewLine(agent: CrewAgentRecord, task: TeamTaskState | undefine
|
|
|
140
141
|
agent.startedAt ? `age=${formatAge(agent.completedAt ?? agent.startedAt)}` : undefined,
|
|
141
142
|
].filter((part): part is string => Boolean(part));
|
|
142
143
|
const recent = agent.progress?.recentOutput?.at(-1);
|
|
143
|
-
|
|
144
|
+
const icon = iconForStatus(agent.status, { runningGlyph: spinnerFrame(agent.taskId) });
|
|
145
|
+
return `Agent: ${icon} ${agent.taskId} ${agent.role}->${agent.agent}${stats.length ? ` · ${stats.join(" · ")}` : ""}${recent ? ` ⎿ ${recent}` : ""}`;
|
|
144
146
|
}
|
|
145
147
|
|
|
146
148
|
function readAgentPreview(run: TeamRunManifest, maxLines = 5, options: RunDashboardOptions = {}): string[] {
|
|
@@ -189,7 +191,7 @@ function runLabel(run: TeamRunManifest, selected: boolean, snapshotCache?: RunSn
|
|
|
189
191
|
const step = stale ? "orphaned queued run" : running ? `step ${running.taskId}` : queued ? `queued ${queued.taskId}` : `agents ${agents.length}`;
|
|
190
192
|
const status: RunStatus = stale ? "stale" : (run.status as RunStatus);
|
|
191
193
|
const marker = selected ? "›" : " ";
|
|
192
|
-
return `${marker} ${iconForStatus(status)} ${run.runId.slice(-8)} ${status} | ${run.team}/${run.workflow ?? "none"} | ${step} | ${run.goal}`;
|
|
194
|
+
return `${marker} ${iconForStatus(status, { runningGlyph: spinnerFrame(run.runId) })} ${run.runId.slice(-8)} ${status} | ${run.team}/${run.workflow ?? "none"} | ${step} | ${run.goal}`;
|
|
193
195
|
}
|
|
194
196
|
|
|
195
197
|
function groupedRuns(runs: TeamRunManifest[], snapshotCache?: RunSnapshotCache): Array<{ label: string; run?: TeamRunManifest }> {
|
|
@@ -253,15 +255,17 @@ export class RunDashboard implements DashboardComponent {
|
|
|
253
255
|
}
|
|
254
256
|
|
|
255
257
|
private buildSignature(): string {
|
|
258
|
+
let hasRunning = false;
|
|
256
259
|
const statuses = this.runs.map((run) => {
|
|
257
260
|
const snapshot = snapshotFor(run, this.options.snapshotCache);
|
|
258
261
|
const displayRun = snapshot?.manifest ?? run;
|
|
259
262
|
const agents = snapshot?.agents ?? agentsFor(run, this.options.snapshotCache);
|
|
260
263
|
const stale = isLikelyOrphanedActiveRun(displayRun, agents);
|
|
261
264
|
const status: RunStatus = stale ? "stale" : (displayRun.status as RunStatus);
|
|
265
|
+
if (status === "running" || agents.some((agent) => agent.status === "running")) hasRunning = true;
|
|
262
266
|
return snapshot?.signature ?? `${displayRun.runId}:${displayRun.status}:${displayRun.updatedAt}:${status}`;
|
|
263
267
|
}).join("|");
|
|
264
|
-
return `${this.selected}:${this.showFullProgress ? 1 : 0}:${this.activePane}:${statuses}`;
|
|
268
|
+
return `${this.selected}:${this.showFullProgress ? 1 : 0}:${this.activePane}:${statuses}${hasRunning ? `:spin=${spinnerBucket()}` : ""}`;
|
|
265
269
|
}
|
|
266
270
|
|
|
267
271
|
invalidate(): void {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const SUBAGENT_SPINNER_FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"] as const;
|
|
2
|
+
export const SUBAGENT_SPINNER_FRAME_MS = 160;
|
|
3
|
+
|
|
4
|
+
export function spinnerBucket(now = Date.now(), frameMs = SUBAGENT_SPINNER_FRAME_MS): number {
|
|
5
|
+
return Math.floor(now / Math.max(1, frameMs));
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function hashKey(key: string): number {
|
|
9
|
+
let hash = 0;
|
|
10
|
+
for (let index = 0; index < key.length; index += 1) hash = (hash * 31 + key.charCodeAt(index)) >>> 0;
|
|
11
|
+
return hash;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function spinnerFrame(key = "", now = Date.now()): string {
|
|
15
|
+
const offset = key ? hashKey(key) % SUBAGENT_SPINNER_FRAMES.length : 0;
|
|
16
|
+
return SUBAGENT_SPINNER_FRAMES[(spinnerBucket(now) + offset) % SUBAGENT_SPINNER_FRAMES.length] ?? SUBAGENT_SPINNER_FRAMES[0];
|
|
17
|
+
}
|