@mrclrchtr/supi-review 7.3.1 → 8.0.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/README.md +4 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/README.md +11 -1
- package/node_modules/@mrclrchtr/supi-agent-runtime/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-agent-runtime/node_modules/@mrclrchtr/supi-core/src/config/config.ts +110 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/node_modules/@mrclrchtr/supi-core/src/config.ts +6 -1
- package/node_modules/@mrclrchtr/supi-agent-runtime/node_modules/@mrclrchtr/supi-core/src/settings/settings-schema.ts +2 -1
- package/node_modules/@mrclrchtr/supi-agent-runtime/package.json +7 -3
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/api.ts +37 -1
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/lifecycle-trace.ts +5 -2
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/run.ts +237 -35
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/session/agent-run-registry-types.ts +95 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/session/agent-run-registry.ts +372 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/session/transcript-format.ts +184 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/session/transcript-store.ts +284 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/types.ts +30 -4
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-command.ts +206 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-overlay-data.ts +100 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-overlay-render.ts +167 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-overlay.ts +398 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-run-list.ts +95 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-run-switcher.ts +29 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-run-viewer-input.ts +69 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-run-viewer-render.ts +246 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-run-viewer.ts +400 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-run-viewport.ts +112 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-steering-input.ts +50 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-transcript-context.ts +56 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-transcript-pane.ts +386 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-transcript-payload.ts +66 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-transcript.ts +380 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/README.md +6 -6
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +22 -4
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-core/src/config/config.ts +110 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-core/src/config.ts +6 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-core/src/settings/settings-schema.ts +2 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/README.md +29 -6
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +22 -4
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/config/config.ts +110 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/config.ts +6 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/settings/settings-schema.ts +2 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/package.json +3 -3
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/api.ts +25 -3
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-host.ts +2 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-refresh.ts +5 -2
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostics.ts +39 -6
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/client/client-document-sync.ts +82 -12
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/client/client-semantic-input-barrier.ts +28 -5
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +606 -30
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/config/capabilities.ts +9 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/config/config.ts +69 -8
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/config/operation-support.ts +196 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/config/server-config.ts +15 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/config/types.ts +9 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-project-info.ts +2 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-symbol.ts +31 -2
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +72 -2
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/provider/lsp-refactor-provider.ts +9 -43
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/provider/refactor-planning.ts +102 -50
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-edit-normalizer.ts +49 -3
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-controller.ts +78 -18
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +46 -2
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/session/workspace-lsp-runtime.ts +14 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/workspace-path-policy.ts +30 -4
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/query-result.ts +22 -4
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/config/config.ts +110 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/config.ts +6 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/settings/settings-schema.ts +2 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/package.json +3 -3
- package/node_modules/@mrclrchtr/supi-code-intelligence/package.json +5 -5
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/analysis/capability/capability-warnings.ts +64 -25
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/analysis/health/server-status.ts +23 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/analysis/health/signals.ts +1 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/analysis/search/ast-scan.ts +42 -8
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/analysis/search/pattern.ts +4 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/config.ts +64 -34
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/extension.ts +29 -10
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/headless.ts +1 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/session/find-types.ts +2 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/session/find-workflow.ts +5 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/session/health-types.ts +3 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/session/health-workflow.ts +10 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/session/session.ts +34 -2
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/substrate/lsp/lifecycle.ts +2 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/substrate/lsp/recovery.ts +3 -3
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/substrate/lsp/settings.ts +191 -108
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/substrate/workspace-provider-host.ts +50 -12
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/code_find/markdown.ts +12 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/code_find/render.ts +20 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/code_find/result.ts +3 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/code_health/markdown.ts +3 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/code_health/result.ts +3 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/result/types.ts +3 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/ui/status-command.ts +54 -6
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/ui/status-overlay.ts +5 -0
- package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-core/src/config/config.ts +110 -0
- package/node_modules/@mrclrchtr/supi-core/src/config.ts +6 -1
- package/node_modules/@mrclrchtr/supi-core/src/settings/settings-schema.ts +2 -1
- package/package.json +4 -4
- package/src/review.ts +5 -2
- package/src/tool/review_run/child-session.ts +29 -7
- package/src/tool/review_run/execute.ts +6 -1
- package/src/tool/review_run/execution.ts +6 -0
- package/src/tool/review_run/register.ts +3 -1
- package/src/tool/review_run/runner.ts +40 -0
- package/src/tool/review_run/spec.ts +2 -0
- package/src/tool/review_run/workflow.ts +7 -1
- package/src/tui/review-command.ts +74 -3
- package/src/types.ts +5 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/config/lsp-settings.ts +0 -22
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import type { Theme } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import {
|
|
3
|
+
type Container,
|
|
4
|
+
Spacer,
|
|
5
|
+
Text,
|
|
6
|
+
truncateToWidth,
|
|
7
|
+
visibleWidth,
|
|
8
|
+
} from "@earendil-works/pi-tui";
|
|
9
|
+
import type { AgentsOverlayData, AgentsProfilePageEntry } from "./agents-overlay-data.ts";
|
|
10
|
+
|
|
11
|
+
const LIST_WINDOW_SIZE = 8;
|
|
12
|
+
|
|
13
|
+
/** Center a legend row using visible terminal columns, with clipping on narrow screens. */
|
|
14
|
+
export function centerLegend(text: string, width: number): string {
|
|
15
|
+
const clipped = truncateToWidth(text, Math.max(0, width - 2));
|
|
16
|
+
const padding = Math.max(0, Math.floor((width - visibleWidth(clipped)) / 2));
|
|
17
|
+
return `${" ".repeat(padding)}${clipped}`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Render effective Agent Profiles with human-only source provenance. */
|
|
21
|
+
export function renderProfilesSection(
|
|
22
|
+
container: Container,
|
|
23
|
+
data: AgentsOverlayData,
|
|
24
|
+
selectedIndex: number,
|
|
25
|
+
theme: Theme,
|
|
26
|
+
): void {
|
|
27
|
+
const profiles = data.profilePages?.profiles ?? [];
|
|
28
|
+
container.addChild(new Text(theme.fg("accent", theme.bold("Effective Agent Profiles")), 1, 0));
|
|
29
|
+
if (profiles.length === 0) {
|
|
30
|
+
container.addChild(new Text(theme.fg("dim", "No effective profiles."), 1, 0));
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
for (const [index, profile] of visibleWindow(profiles, selectedIndex).entries()) {
|
|
34
|
+
const actualIndex = windowStart(profiles.length, selectedIndex) + index;
|
|
35
|
+
const selected = actualIndex === selectedIndex;
|
|
36
|
+
const label = `${selected ? "▶" : " "} ${profile.id} — ${profile.source ?? "unavailable"}`;
|
|
37
|
+
container.addChild(
|
|
38
|
+
new Text(selected ? theme.fg("accent", label) : theme.fg("dim", label), 1, 0),
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
const profile = profiles[selectedIndex];
|
|
42
|
+
if (profile) renderProfileDetails(container, profile, theme);
|
|
43
|
+
const omitted = data.profilePages?.omittedProfileCount ?? 0;
|
|
44
|
+
if (omitted > 0) {
|
|
45
|
+
const noun = omitted === 1 ? "profile" : "profiles";
|
|
46
|
+
container.addChild(
|
|
47
|
+
new Text(
|
|
48
|
+
theme.fg("warning", `${omitted} additional ${noun} omitted by the catalogue limit.`),
|
|
49
|
+
1,
|
|
50
|
+
0,
|
|
51
|
+
),
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Render bounded Profile Diagnostics and their omission disclosure. */
|
|
57
|
+
export function renderDiagnosticsSection(
|
|
58
|
+
container: Container,
|
|
59
|
+
data: AgentsOverlayData,
|
|
60
|
+
selectedIndex: number,
|
|
61
|
+
theme: Theme,
|
|
62
|
+
): void {
|
|
63
|
+
const diagnostics = data.profilePages?.diagnostics ?? [];
|
|
64
|
+
container.addChild(new Text(theme.fg("accent", theme.bold("Profile Diagnostics")), 1, 0));
|
|
65
|
+
if (diagnostics.length === 0) {
|
|
66
|
+
container.addChild(new Text(theme.fg("success", "No Profile Diagnostics."), 1, 0));
|
|
67
|
+
addDiagnosticOmission(container, data.profilePages?.omittedDiagnosticCount ?? 0, theme);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
for (const [index, diagnostic] of visibleWindow(diagnostics, selectedIndex).entries()) {
|
|
71
|
+
const actualIndex = windowStart(diagnostics.length, selectedIndex) + index;
|
|
72
|
+
const selected = actualIndex === selectedIndex;
|
|
73
|
+
const label = `${selected ? "▶" : " "} ${diagnostic.profileId} · ${diagnostic.code}`;
|
|
74
|
+
container.addChild(
|
|
75
|
+
new Text(selected ? theme.fg("accent", label) : theme.fg("dim", label), 1, 0),
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
const diagnostic = diagnostics[selectedIndex];
|
|
79
|
+
if (diagnostic) {
|
|
80
|
+
container.addChild(new Spacer(1));
|
|
81
|
+
container.addChild(new Text(`${diagnostic.source} · ${diagnostic.code}`, 1, 0));
|
|
82
|
+
container.addChild(new Text(diagnostic.message, 1, 0));
|
|
83
|
+
if (diagnostic.directory)
|
|
84
|
+
container.addChild(new Text(theme.fg("dim", diagnostic.directory), 1, 0));
|
|
85
|
+
}
|
|
86
|
+
addDiagnosticOmission(container, data.profilePages?.omittedDiagnosticCount ?? 0, theme);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function renderProfileDetails(
|
|
90
|
+
container: Container,
|
|
91
|
+
profile: AgentsProfilePageEntry,
|
|
92
|
+
theme: Theme,
|
|
93
|
+
): void {
|
|
94
|
+
container.addChild(new Spacer(1));
|
|
95
|
+
container.addChild(
|
|
96
|
+
new Text(
|
|
97
|
+
`Description (${profile.fieldSources?.description ?? "unavailable"}): ${profile.description}`,
|
|
98
|
+
1,
|
|
99
|
+
0,
|
|
100
|
+
),
|
|
101
|
+
);
|
|
102
|
+
if (profile.unavailable) {
|
|
103
|
+
container.addChild(new Text(theme.fg("error", `Unavailable: ${profile.unavailable}`), 1, 0));
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
container.addChild(new Text(`Strongest source: ${profile.source} — ${profile.directory}`, 1, 0));
|
|
107
|
+
container.addChild(
|
|
108
|
+
new Text(
|
|
109
|
+
theme.fg(
|
|
110
|
+
"dim",
|
|
111
|
+
`Model (${profile.fieldSources?.model ?? "session"}): ${profile.model} · Thinking (${profile.fieldSources?.thinking ?? "session"}): ${profile.thinking}`,
|
|
112
|
+
),
|
|
113
|
+
1,
|
|
114
|
+
0,
|
|
115
|
+
),
|
|
116
|
+
);
|
|
117
|
+
container.addChild(
|
|
118
|
+
new Text(
|
|
119
|
+
theme.fg(
|
|
120
|
+
"dim",
|
|
121
|
+
`Timeout (${profile.fieldSources?.timeoutMinutes ?? "default"}): ${profile.timeoutMinutes ?? "none"}`,
|
|
122
|
+
),
|
|
123
|
+
1,
|
|
124
|
+
0,
|
|
125
|
+
),
|
|
126
|
+
);
|
|
127
|
+
container.addChild(
|
|
128
|
+
new Text(
|
|
129
|
+
theme.fg(
|
|
130
|
+
"dim",
|
|
131
|
+
`Tools (${profile.fieldSources?.tools ?? "unavailable"}): ${profile.tools?.join(", ") || "none"}`,
|
|
132
|
+
),
|
|
133
|
+
1,
|
|
134
|
+
0,
|
|
135
|
+
),
|
|
136
|
+
);
|
|
137
|
+
container.addChild(
|
|
138
|
+
new Text(
|
|
139
|
+
theme.fg(
|
|
140
|
+
"dim",
|
|
141
|
+
`Prompt (${profile.fieldSources?.systemPrompt ?? "unavailable"}): ${profile.systemPrompt} · Instructions (${profile.fieldSources?.instructionScopes ?? "unavailable"}): ${profile.instructionScopes?.join(", ") || "none"}`,
|
|
142
|
+
),
|
|
143
|
+
1,
|
|
144
|
+
0,
|
|
145
|
+
),
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function addDiagnosticOmission(container: Container, count: number, theme: Theme): void {
|
|
150
|
+
if (count > 0)
|
|
151
|
+
container.addChild(
|
|
152
|
+
new Text(
|
|
153
|
+
theme.fg("warning", `${count} additional diagnostics omitted by the overlay limit.`),
|
|
154
|
+
1,
|
|
155
|
+
0,
|
|
156
|
+
),
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function visibleWindow<T>(items: readonly T[], selected: number): readonly T[] {
|
|
161
|
+
const start = windowStart(items.length, selected);
|
|
162
|
+
return items.slice(start, start + LIST_WINDOW_SIZE);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function windowStart(length: number, selected: number, size = LIST_WINDOW_SIZE): number {
|
|
166
|
+
return Math.min(Math.max(0, length - size), Math.max(0, selected - Math.floor(size / 2)));
|
|
167
|
+
}
|
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
import { DynamicBorder } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import {
|
|
3
|
+
Container,
|
|
4
|
+
type Focusable,
|
|
5
|
+
Key,
|
|
6
|
+
type KeyId,
|
|
7
|
+
matchesKey,
|
|
8
|
+
type TuiMouseEvent,
|
|
9
|
+
type TuiMouseEventResult,
|
|
10
|
+
truncateToWidth,
|
|
11
|
+
} from "@earendil-works/pi-tui";
|
|
12
|
+
import type {
|
|
13
|
+
AgentOverlayControlResult,
|
|
14
|
+
AgentsDialogDependencies,
|
|
15
|
+
AgentsOverlayData,
|
|
16
|
+
AgentsOverlayRun,
|
|
17
|
+
} from "./agents-overlay-data.ts";
|
|
18
|
+
import {
|
|
19
|
+
AGENTS_OVERLAY_MAX_HEIGHT_PERCENT,
|
|
20
|
+
agentOverlayControlNotice,
|
|
21
|
+
} from "./agents-overlay-data.ts";
|
|
22
|
+
import {
|
|
23
|
+
centerLegend,
|
|
24
|
+
renderDiagnosticsSection,
|
|
25
|
+
renderProfilesSection,
|
|
26
|
+
} from "./agents-overlay-render.ts";
|
|
27
|
+
import { AgentsRunViewer, type AgentsRunViewerAction } from "./agents-run-viewer.ts";
|
|
28
|
+
import { AgentsSteeringInput } from "./agents-steering-input.ts";
|
|
29
|
+
|
|
30
|
+
type AgentsTab = "agents" | "reviews" | "profiles" | "diagnostics";
|
|
31
|
+
|
|
32
|
+
const AGENTS_TITLE = "Agents";
|
|
33
|
+
const CATALOGUE_HINT = "tab/←→ sections · ↑↓ select · esc close";
|
|
34
|
+
|
|
35
|
+
/** TUI-only Agent Run inspector and selected-run controller. */
|
|
36
|
+
export class AgentsDialog implements Focusable {
|
|
37
|
+
#cachedLines: string[] | undefined;
|
|
38
|
+
#cachedWidth: number | undefined;
|
|
39
|
+
#cachedHeight: number | undefined;
|
|
40
|
+
#profileIndex = 0;
|
|
41
|
+
#diagnosticIndex = 0;
|
|
42
|
+
#notice: string | undefined;
|
|
43
|
+
#stopConfirmKey: string | undefined;
|
|
44
|
+
#tabIndex = 0;
|
|
45
|
+
#busy = false;
|
|
46
|
+
#steeringInput: AgentsSteeringInput | undefined;
|
|
47
|
+
#focused = false;
|
|
48
|
+
#unsubscribe: (() => void) | undefined;
|
|
49
|
+
#elapsedInterval: ReturnType<typeof setInterval> | undefined;
|
|
50
|
+
readonly #runViewer: AgentsRunViewer;
|
|
51
|
+
|
|
52
|
+
constructor(
|
|
53
|
+
private data: AgentsOverlayData,
|
|
54
|
+
private readonly dependencies: AgentsDialogDependencies,
|
|
55
|
+
) {
|
|
56
|
+
this.#runViewer = new AgentsRunViewer(
|
|
57
|
+
data,
|
|
58
|
+
dependencies.theme,
|
|
59
|
+
() => this.#changed(),
|
|
60
|
+
dependencies.keybindings,
|
|
61
|
+
);
|
|
62
|
+
this.#runViewer.setSection("agents");
|
|
63
|
+
this.#unsubscribe = dependencies.subscribe?.((next) => this.updateData(next));
|
|
64
|
+
this.#updateElapsedTimer();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Implement Pi's Focusable contract for the embedded steering input. */
|
|
68
|
+
get focused(): boolean {
|
|
69
|
+
return this.#focused;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
set focused(value: boolean) {
|
|
73
|
+
if (this.#focused === value) return;
|
|
74
|
+
this.#focused = value;
|
|
75
|
+
if (this.#steeringInput) this.#steeringInput.focused = value;
|
|
76
|
+
this.#runViewer.focused = value;
|
|
77
|
+
this.#changed();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
render(width: number): string[] {
|
|
81
|
+
const height = Math.max(
|
|
82
|
+
1,
|
|
83
|
+
Math.floor((this.dependencies.tui.terminal.rows * AGENTS_OVERLAY_MAX_HEIGHT_PERCENT) / 100),
|
|
84
|
+
);
|
|
85
|
+
if (this.#cachedLines && this.#cachedWidth === width && this.#cachedHeight === height) {
|
|
86
|
+
return this.#cachedLines;
|
|
87
|
+
}
|
|
88
|
+
this.#cachedLines =
|
|
89
|
+
this.#tab() === "agents" || this.#tab() === "reviews"
|
|
90
|
+
? this.#runViewer.render({
|
|
91
|
+
width,
|
|
92
|
+
height,
|
|
93
|
+
header: AGENTS_TITLE,
|
|
94
|
+
tabs: this.#tabs(),
|
|
95
|
+
notice: this.#notice,
|
|
96
|
+
steeringLines: this.#steeringLines(width),
|
|
97
|
+
steeringActive: this.#steeringInput !== undefined,
|
|
98
|
+
stopConfirmation: this.#stopConfirmKey !== undefined,
|
|
99
|
+
})
|
|
100
|
+
: this.#renderCataloguePage(width, height);
|
|
101
|
+
this.#cachedWidth = width;
|
|
102
|
+
this.#cachedHeight = height;
|
|
103
|
+
return this.#cachedLines;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
handleInput(data: string): void {
|
|
107
|
+
if (this.#handleSteeringInput(data)) return;
|
|
108
|
+
if (this.#stopConfirmKey) {
|
|
109
|
+
this.#handleStopConfirmation(data);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (this.#runViewer.isList && this.#handleTabInput(data, false)) return;
|
|
113
|
+
if (this.#tab() === "agents" || this.#tab() === "reviews") {
|
|
114
|
+
this.#handleRunInput(data);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if (this.#handleCloseInput(data) || this.#handleTabInput(data)) return;
|
|
118
|
+
this.#handleCatalogueInput(data);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** Route fullscreen mouse input to the run and transcript panes. */
|
|
122
|
+
handleMouse(event: TuiMouseEvent): TuiMouseEventResult | undefined {
|
|
123
|
+
if (
|
|
124
|
+
(this.#tab() !== "agents" && this.#tab() !== "reviews") ||
|
|
125
|
+
this.#steeringInput ||
|
|
126
|
+
this.#stopConfirmKey
|
|
127
|
+
)
|
|
128
|
+
return undefined;
|
|
129
|
+
return this.#runViewer.handleMouse(event);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** Replace live registry data while preserving the selected run when possible. */
|
|
133
|
+
updateData(data: AgentsOverlayData): void {
|
|
134
|
+
this.data = data;
|
|
135
|
+
this.#runViewer.updateData(data);
|
|
136
|
+
this.#updateElapsedTimer();
|
|
137
|
+
this.#diagnosticIndex = Math.min(
|
|
138
|
+
this.#diagnosticIndex,
|
|
139
|
+
Math.max(0, (data.profilePages?.diagnostics.length ?? 0) - 1),
|
|
140
|
+
);
|
|
141
|
+
this.#profileIndex = Math.min(
|
|
142
|
+
this.#profileIndex,
|
|
143
|
+
Math.max(0, (data.profilePages?.profiles.length ?? 0) - 1),
|
|
144
|
+
);
|
|
145
|
+
this.#tabIndex = Math.min(this.#tabIndex, this.#tabsList().length - 1);
|
|
146
|
+
this.#changed();
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** Release the live registry subscription when Pi removes the overlay. */
|
|
150
|
+
dispose(): void {
|
|
151
|
+
this.#unsubscribe?.();
|
|
152
|
+
this.#unsubscribe = undefined;
|
|
153
|
+
if (this.#elapsedInterval) clearInterval(this.#elapsedInterval);
|
|
154
|
+
this.#elapsedInterval = undefined;
|
|
155
|
+
this.#runViewer.dispose();
|
|
156
|
+
this.#clearSteering();
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
invalidate(): void {
|
|
160
|
+
this.#cachedLines = undefined;
|
|
161
|
+
this.#steeringInput?.invalidate();
|
|
162
|
+
this.#runViewer.invalidate();
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
#renderCataloguePage(width: number, height: number): string[] {
|
|
166
|
+
const theme = this.dependencies.theme;
|
|
167
|
+
const header =
|
|
168
|
+
height <= 3
|
|
169
|
+
? [this.#line(`${AGENTS_TITLE} ${this.#tabs()}`, width)]
|
|
170
|
+
: [
|
|
171
|
+
this.#line(AGENTS_TITLE, width),
|
|
172
|
+
this.#line(this.#tabs(), width),
|
|
173
|
+
...new DynamicBorder((text: string) => theme.fg("accent", text)).render(width),
|
|
174
|
+
];
|
|
175
|
+
const footer = [CATALOGUE_HINT].map((hint) => centerLegend(theme.fg("dim", hint), width));
|
|
176
|
+
const bodyHeight = Math.max(0, height - header.length - footer.length);
|
|
177
|
+
const body = new Container();
|
|
178
|
+
if (this.#tab() === "profiles") {
|
|
179
|
+
renderProfilesSection(body, this.data, this.#profileIndex, theme);
|
|
180
|
+
} else {
|
|
181
|
+
renderDiagnosticsSection(body, this.data, this.#diagnosticIndex, theme);
|
|
182
|
+
}
|
|
183
|
+
const lines = [...header, ...body.render(width).slice(0, bodyHeight), ...footer].slice(
|
|
184
|
+
0,
|
|
185
|
+
height,
|
|
186
|
+
);
|
|
187
|
+
while (lines.length < height) lines.push("");
|
|
188
|
+
return lines.map((line) => truncateToWidth(line, width));
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
#handleRunViewerAction(action: AgentsRunViewerAction | undefined): boolean {
|
|
192
|
+
if (action === "handled") {
|
|
193
|
+
this.#changed();
|
|
194
|
+
return true;
|
|
195
|
+
}
|
|
196
|
+
if (action === "close") {
|
|
197
|
+
this.dependencies.done();
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
const run = this.#runViewer.selectedRun;
|
|
201
|
+
if (action === "steer" && run) {
|
|
202
|
+
this.#beginSteering(run);
|
|
203
|
+
return true;
|
|
204
|
+
}
|
|
205
|
+
if (action === "stop" && run) {
|
|
206
|
+
this.#stopConfirmKey = run.runKey ?? run.taskId;
|
|
207
|
+
this.#notice = `Stop ${run.taskId}? Press Enter or y to confirm; Esc to cancel.`;
|
|
208
|
+
this.#changed();
|
|
209
|
+
return true;
|
|
210
|
+
}
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
#handleSteeringInput(data: string): boolean {
|
|
215
|
+
if (!this.#steeringInput) return false;
|
|
216
|
+
if (matchesKey(data, Key.ctrl("c"))) this.#cancelSteering();
|
|
217
|
+
else {
|
|
218
|
+
this.#steeringInput.handleInput(data);
|
|
219
|
+
this.#changed();
|
|
220
|
+
}
|
|
221
|
+
return true;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
#handleCloseInput(data: string): boolean {
|
|
225
|
+
const interrupted = this.#matches(data, "app.interrupt", Key.escape);
|
|
226
|
+
const canceled = this.#matches(data, "tui.select.cancel", Key.ctrl("c"));
|
|
227
|
+
if (!interrupted && !canceled) return false;
|
|
228
|
+
this.dependencies.done();
|
|
229
|
+
return true;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
#handleRunInput(data: string): boolean {
|
|
233
|
+
if (this.#tab() !== "agents" && this.#tab() !== "reviews") return false;
|
|
234
|
+
const action = this.#runViewer.handleInput(data, !this.#busy);
|
|
235
|
+
return this.#handleRunViewerAction(action);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
#handleTabInput(data: string, allowArrows = true): boolean {
|
|
239
|
+
if (matchesKey(data, Key.tab) || (allowArrows && matchesKey(data, Key.right))) {
|
|
240
|
+
this.#tabIndex = (this.#tabIndex + 1) % this.#tabsList().length;
|
|
241
|
+
} else if (matchesKey(data, Key.shift("tab")) || (allowArrows && matchesKey(data, Key.left))) {
|
|
242
|
+
this.#tabIndex = (this.#tabIndex + this.#tabsList().length - 1) % this.#tabsList().length;
|
|
243
|
+
} else {
|
|
244
|
+
return false;
|
|
245
|
+
}
|
|
246
|
+
if (this.#runViewer.isList) {
|
|
247
|
+
this.#runViewer.setSection(this.#tab() === "reviews" ? "reviews" : "agents");
|
|
248
|
+
}
|
|
249
|
+
this.#changed();
|
|
250
|
+
return true;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
#handleCatalogueInput(data: string): void {
|
|
254
|
+
if (this.#matches(data, "tui.select.up", Key.up)) {
|
|
255
|
+
this.#moveCatalogueSelection(-1);
|
|
256
|
+
} else if (this.#matches(data, "tui.select.down", Key.down)) {
|
|
257
|
+
this.#moveCatalogueSelection(1);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
#moveCatalogueSelection(delta: number): void {
|
|
262
|
+
const pages = this.data.profilePages;
|
|
263
|
+
const length =
|
|
264
|
+
this.#tab() === "profiles" ? (pages?.profiles.length ?? 0) : (pages?.diagnostics.length ?? 0);
|
|
265
|
+
if (length === 0) return;
|
|
266
|
+
if (this.#tab() === "profiles") {
|
|
267
|
+
this.#profileIndex = clamp(this.#profileIndex + delta, 0, length - 1);
|
|
268
|
+
} else {
|
|
269
|
+
this.#diagnosticIndex = clamp(this.#diagnosticIndex + delta, 0, length - 1);
|
|
270
|
+
}
|
|
271
|
+
this.#changed();
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
#beginSteering(run: AgentsOverlayRun): void {
|
|
275
|
+
const input = new AgentsSteeringInput(run.taskId, this.dependencies.theme, {
|
|
276
|
+
onSubmit: (message) => {
|
|
277
|
+
this.#clearSteering();
|
|
278
|
+
this.#runControl("Sending steering…", () =>
|
|
279
|
+
this.dependencies.onSteer(run.runKey ?? run.taskId, message),
|
|
280
|
+
);
|
|
281
|
+
},
|
|
282
|
+
onEmpty: () => {
|
|
283
|
+
this.#notice = "Enter a steering message or press Esc to cancel.";
|
|
284
|
+
this.#changed();
|
|
285
|
+
},
|
|
286
|
+
onCancel: () => this.#cancelSteering(),
|
|
287
|
+
});
|
|
288
|
+
input.focused = this.#focused;
|
|
289
|
+
this.#steeringInput = input;
|
|
290
|
+
this.#notice = undefined;
|
|
291
|
+
this.#changed();
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
#handleStopConfirmation(data: string): void {
|
|
295
|
+
if (this.#matches(data, "app.interrupt", Key.escape)) {
|
|
296
|
+
this.#stopConfirmKey = undefined;
|
|
297
|
+
this.#notice = "Stop canceled.";
|
|
298
|
+
this.#changed();
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
if (!this.#matches(data, "tui.select.confirm", Key.enter) && data.toLowerCase() !== "y") return;
|
|
302
|
+
const runKey = this.#stopConfirmKey;
|
|
303
|
+
this.#stopConfirmKey = undefined;
|
|
304
|
+
if (runKey) this.#runControl("Stopping selected run…", () => this.dependencies.onStop(runKey));
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
#cancelSteering(): void {
|
|
308
|
+
this.#clearSteering();
|
|
309
|
+
this.#notice = "Control canceled.";
|
|
310
|
+
this.#changed();
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
#clearSteering(): void {
|
|
314
|
+
if (this.#steeringInput) this.#steeringInput.focused = false;
|
|
315
|
+
this.#steeringInput = undefined;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
#steeringLines(width: number): string[] {
|
|
319
|
+
if (!this.#steeringInput) return [];
|
|
320
|
+
return this.#steeringInput
|
|
321
|
+
.render(Math.max(1, width - 2))
|
|
322
|
+
.map((line) => this.#line(line, width));
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
#runControl(message: string, action: () => Promise<AgentOverlayControlResult>): void {
|
|
326
|
+
this.#busy = true;
|
|
327
|
+
this.#notice = message;
|
|
328
|
+
this.#changed();
|
|
329
|
+
void action()
|
|
330
|
+
.then((result) => {
|
|
331
|
+
this.#notice = agentOverlayControlNotice(result);
|
|
332
|
+
})
|
|
333
|
+
.catch(() => {
|
|
334
|
+
this.#notice = "Control failed.";
|
|
335
|
+
})
|
|
336
|
+
.finally(() => {
|
|
337
|
+
this.#busy = false;
|
|
338
|
+
this.#changed();
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
#tabs(): string {
|
|
343
|
+
return this.#tabsList()
|
|
344
|
+
.map((tab, index) => {
|
|
345
|
+
const value = title(tab);
|
|
346
|
+
return index === this.#tabIndex ? `[${value}]` : value;
|
|
347
|
+
})
|
|
348
|
+
.join(this.dependencies.theme.fg("dim", " "));
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
#tabsList(): AgentsTab[] {
|
|
352
|
+
return this.data.profilePages
|
|
353
|
+
? ["agents", "reviews", "profiles", "diagnostics"]
|
|
354
|
+
: ["agents", "reviews"];
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
#tab(): AgentsTab {
|
|
358
|
+
return this.#tabsList()[this.#tabIndex] ?? "agents";
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
#matches(
|
|
362
|
+
data: string,
|
|
363
|
+
action: Parameters<NonNullable<AgentsDialogDependencies["keybindings"]>["matches"]>[1],
|
|
364
|
+
fallback: KeyId,
|
|
365
|
+
): boolean {
|
|
366
|
+
return typeof this.dependencies.keybindings?.matches === "function"
|
|
367
|
+
? this.dependencies.keybindings.matches(data, action)
|
|
368
|
+
: matchesKey(data, fallback);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
#line(text: string, width: number): string {
|
|
372
|
+
return truncateToWidth(` ${text}`, width);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
#updateElapsedTimer(): void {
|
|
376
|
+
if (!this.data.runs.some((run) => run.active)) {
|
|
377
|
+
clearInterval(this.#elapsedInterval);
|
|
378
|
+
this.#elapsedInterval = undefined;
|
|
379
|
+
} else if (!this.#elapsedInterval) {
|
|
380
|
+
this.#elapsedInterval = setInterval(() => this.#runViewer.refreshElapsed(), 1_000);
|
|
381
|
+
this.#elapsedInterval.unref?.();
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
#changed(): void {
|
|
386
|
+
this.#cachedLines = undefined;
|
|
387
|
+
this.#steeringInput?.invalidate();
|
|
388
|
+
this.dependencies.tui.requestRender();
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
function clamp(value: number, minimum: number, maximum: number): number {
|
|
393
|
+
return Math.min(maximum, Math.max(minimum, value));
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
function title(tab: AgentsTab): string {
|
|
397
|
+
return tab[0]?.toUpperCase() + tab.slice(1);
|
|
398
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { SelectItem } from "@earendil-works/pi-tui";
|
|
2
|
+
import type { AgentsOverlayRun } from "./agents-overlay-data.ts";
|
|
3
|
+
|
|
4
|
+
export type RunSection = "agents" | "reviews";
|
|
5
|
+
|
|
6
|
+
export function orderedRuns(
|
|
7
|
+
runs: readonly AgentsOverlayRun[],
|
|
8
|
+
section: RunSection,
|
|
9
|
+
query: string,
|
|
10
|
+
): AgentsOverlayRun[] {
|
|
11
|
+
const normalizedQuery = query.trim().toLowerCase();
|
|
12
|
+
const groups = new Map<string, AgentsOverlayRun[]>();
|
|
13
|
+
for (const run of runs) {
|
|
14
|
+
if (isReviewRun(run) !== (section === "reviews") || !matchesQuery(run, normalizedQuery))
|
|
15
|
+
continue;
|
|
16
|
+
const group = groups.get(run.batchId) ?? [];
|
|
17
|
+
group.push(run);
|
|
18
|
+
groups.set(run.batchId, group);
|
|
19
|
+
}
|
|
20
|
+
return [...groups.values()]
|
|
21
|
+
.sort((left, right) => latestStarted(right) - latestStarted(left))
|
|
22
|
+
.flat();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function runListItem(run: AgentsOverlayRun, now = Date.now()): SelectItem {
|
|
26
|
+
const batchLabel = run.display?.batchLabel ?? run.batchId.slice(0, 8);
|
|
27
|
+
return {
|
|
28
|
+
value: run.key,
|
|
29
|
+
label: `${run.taskId} — ${run.label}`,
|
|
30
|
+
description: `${run.status} · ${formatElapsed(run, now)} · batch ${batchLabel}`,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function runListPreview(run: AgentsOverlayRun): string[] {
|
|
35
|
+
const display = run.result?.display;
|
|
36
|
+
const target = display?.target ?? run.display?.target;
|
|
37
|
+
const findings =
|
|
38
|
+
display?.findingCount === undefined
|
|
39
|
+
? undefined
|
|
40
|
+
: `${display.findingCount} findings${display.blockingFindingCount ? `, ${display.blockingFindingCount} blocking` : ""}`;
|
|
41
|
+
const review = [
|
|
42
|
+
target ? `Target: ${target}` : undefined,
|
|
43
|
+
display?.verdict ? `verdict ${display.verdict}` : undefined,
|
|
44
|
+
findings,
|
|
45
|
+
]
|
|
46
|
+
.filter((value): value is string => value !== undefined)
|
|
47
|
+
.join(" · ");
|
|
48
|
+
const summary = run.active
|
|
49
|
+
? run.recentActivity?.at(-1)
|
|
50
|
+
: run.result?.finalText?.split("\n", 1)[0]?.trim();
|
|
51
|
+
return [
|
|
52
|
+
...(review ? [review] : []),
|
|
53
|
+
...(summary ? [`${run.active ? "Activity" : "Result"}: ${summary}`] : []),
|
|
54
|
+
];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function matchesQuery(run: AgentsOverlayRun, query: string): boolean {
|
|
58
|
+
if (!query) return true;
|
|
59
|
+
return [
|
|
60
|
+
run.taskId,
|
|
61
|
+
run.label,
|
|
62
|
+
run.kind,
|
|
63
|
+
run.batchId,
|
|
64
|
+
run.taskDescription,
|
|
65
|
+
run.display?.target,
|
|
66
|
+
run.result?.display?.target,
|
|
67
|
+
run.result?.display?.verdict,
|
|
68
|
+
run.result?.finalText,
|
|
69
|
+
...(run.recentActivity ?? []),
|
|
70
|
+
]
|
|
71
|
+
.filter((value): value is string => typeof value === "string")
|
|
72
|
+
.join(" ")
|
|
73
|
+
.toLowerCase()
|
|
74
|
+
.includes(query);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function isReviewRun(run: AgentsOverlayRun): boolean {
|
|
78
|
+
return run.kind.toLowerCase().includes("review");
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function latestStarted(group: readonly AgentsOverlayRun[]): number {
|
|
82
|
+
return Math.max(...group.map((run) => run.startedAt));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function formatElapsed(run: AgentsOverlayRun, now = Date.now()): string {
|
|
86
|
+
const end = run.finishedAt ?? now;
|
|
87
|
+
const seconds = Math.max(0, Math.floor((end - run.startedAt) / 1_000));
|
|
88
|
+
if (seconds < 60) return `${seconds}s`;
|
|
89
|
+
const minutes = Math.floor(seconds / 60);
|
|
90
|
+
const remainder = seconds % 60;
|
|
91
|
+
if (minutes < 60) return remainder === 0 ? `${minutes}m` : `${minutes}m ${remainder}s`;
|
|
92
|
+
const hours = Math.floor(minutes / 60);
|
|
93
|
+
const remainingMinutes = minutes % 60;
|
|
94
|
+
return remainingMinutes === 0 ? `${hours}h` : `${hours}h ${remainingMinutes}m`;
|
|
95
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { AgentsOverlayRun } from "./agents-overlay-data.ts";
|
|
2
|
+
|
|
3
|
+
/** Return the next selected run and its index for wrapped or bounded navigation. */
|
|
4
|
+
export function nextRunSelection(
|
|
5
|
+
runs: readonly AgentsOverlayRun[],
|
|
6
|
+
currentIndex: number,
|
|
7
|
+
delta: number,
|
|
8
|
+
wrap: boolean,
|
|
9
|
+
): { readonly index: number; readonly run: AgentsOverlayRun } | undefined {
|
|
10
|
+
if (runs.length === 0) return undefined;
|
|
11
|
+
const startIndex = wrap && currentIndex < 0 ? (delta < 0 ? 0 : runs.length - 1) : currentIndex;
|
|
12
|
+
const index = wrap
|
|
13
|
+
? (((startIndex + delta) % runs.length) + runs.length) % runs.length
|
|
14
|
+
: Math.max(0, Math.min(runs.length - 1, startIndex + delta));
|
|
15
|
+
const run = runs[index];
|
|
16
|
+
return run ? { index, run } : undefined;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Describe where the selected run sits in the filtered result set. */
|
|
20
|
+
export function runSwitcherPosition(
|
|
21
|
+
runs: readonly AgentsOverlayRun[],
|
|
22
|
+
selectedKey: string | undefined,
|
|
23
|
+
): { readonly position?: number; readonly canSwitch: boolean } {
|
|
24
|
+
const index = runs.findIndex((run) => run.key === selectedKey);
|
|
25
|
+
return {
|
|
26
|
+
...(index >= 0 ? { position: index + 1 } : {}),
|
|
27
|
+
canSwitch: runs.length > 1 || (runs.length > 0 && index < 0),
|
|
28
|
+
};
|
|
29
|
+
}
|