@h-rig/cli 0.0.6-alpha.82 → 0.0.6-alpha.84
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/dist/bin/build-rig-binaries.js +40 -8
- package/dist/bin/rig.js +23402 -14577
- package/dist/src/app/board.js +217 -41
- package/dist/src/app-opentui/adapters/command.d.ts +2 -0
- package/dist/src/app-opentui/adapters/command.js +329 -0
- package/dist/src/app-opentui/adapters/common.js +2 -2
- package/dist/src/app-opentui/adapters/doctor.d.ts +0 -2
- package/dist/src/app-opentui/adapters/doctor.js +64 -39
- package/dist/src/app-opentui/adapters/family.d.ts +62 -0
- package/dist/src/app-opentui/adapters/family.js +14305 -0
- package/dist/src/app-opentui/adapters/fleet.d.ts +0 -2
- package/dist/src/app-opentui/adapters/fleet.js +90 -60
- package/dist/src/app-opentui/adapters/inbox.d.ts +12 -2
- package/dist/src/app-opentui/adapters/inbox.js +137 -78
- package/dist/src/app-opentui/adapters/init.d.ts +0 -2
- package/dist/src/app-opentui/adapters/init.js +85 -47
- package/dist/src/app-opentui/adapters/inspect.d.ts +52 -0
- package/dist/src/app-opentui/adapters/inspect.js +1024 -0
- package/dist/src/app-opentui/adapters/pi-attach.d.ts +15 -6
- package/dist/src/app-opentui/adapters/pi-attach.js +442 -125
- package/dist/src/app-opentui/adapters/pi.d.ts +23 -0
- package/dist/src/app-opentui/adapters/pi.js +363 -0
- package/dist/src/app-opentui/adapters/plugin.d.ts +84 -0
- package/dist/src/app-opentui/adapters/plugin.js +544 -0
- package/dist/src/app-opentui/adapters/repo.d.ts +37 -0
- package/dist/src/app-opentui/adapters/repo.js +186 -0
- package/dist/src/app-opentui/adapters/run-detail.d.ts +9 -2
- package/dist/src/app-opentui/adapters/run-detail.js +180 -63
- package/dist/src/app-opentui/adapters/server.d.ts +10 -2
- package/dist/src/app-opentui/adapters/server.js +191 -45
- package/dist/src/app-opentui/adapters/tasks.d.ts +11 -2
- package/dist/src/app-opentui/adapters/tasks.js +1123 -143
- package/dist/src/app-opentui/adapters/workspace.d.ts +49 -0
- package/dist/src/app-opentui/adapters/workspace.js +333 -0
- package/dist/src/app-opentui/autocomplete.d.ts +20 -0
- package/dist/src/app-opentui/autocomplete.js +576 -0
- package/dist/src/app-opentui/bootstrap.d.ts +1 -6
- package/dist/src/app-opentui/bootstrap.js +25252 -16474
- package/dist/src/app-opentui/command-palette.d.ts +3 -0
- package/dist/src/app-opentui/command-palette.js +1010 -0
- package/dist/src/app-opentui/command-pty-host.d.ts +62 -0
- package/dist/src/app-opentui/command-pty-host.js +248 -0
- package/dist/src/app-opentui/drone.js +8 -6
- package/dist/src/app-opentui/events.js +1 -1
- package/dist/src/app-opentui/fleet-stats.d.ts +32 -0
- package/dist/src/app-opentui/fleet-stats.js +114 -0
- package/dist/src/app-opentui/focus-manager.d.ts +14 -0
- package/dist/src/app-opentui/focus-manager.js +24 -0
- package/dist/src/app-opentui/index.js +5431 -2797
- package/dist/src/app-opentui/intent.js +179 -50
- package/dist/src/app-opentui/keymap.d.ts +21 -0
- package/dist/src/app-opentui/keymap.js +1748 -0
- package/dist/src/app-opentui/launch-routing.d.ts +16 -0
- package/dist/src/app-opentui/launch-routing.js +55 -0
- package/dist/src/app-opentui/layout.d.ts +7 -0
- package/dist/src/app-opentui/layout.js +13 -6
- package/dist/src/app-opentui/list-search.d.ts +24 -0
- package/dist/src/app-opentui/list-search.js +88 -1
- package/dist/src/app-opentui/pi-host-child.js +99 -17
- package/dist/src/app-opentui/pi-pty-host.d.ts +14 -0
- package/dist/src/app-opentui/pi-pty-host.js +30 -14
- package/dist/src/app-opentui/react/App.d.ts +9 -0
- package/dist/src/app-opentui/react/App.js +5144 -0
- package/dist/src/app-opentui/react/Backdrop.d.ts +5 -0
- package/dist/src/app-opentui/react/Backdrop.js +1834 -0
- package/dist/src/app-opentui/react/ChromeHost.d.ts +5 -0
- package/dist/src/app-opentui/react/ChromeHost.js +2942 -0
- package/dist/src/app-opentui/react/SceneFrameView.d.ts +7 -0
- package/dist/src/app-opentui/react/SceneFrameView.js +529 -0
- package/dist/src/app-opentui/react/context.d.ts +17 -0
- package/dist/src/app-opentui/react/context.js +37 -0
- package/dist/src/app-opentui/react/launch.d.ts +2 -0
- package/dist/src/app-opentui/react/launch.js +5743 -0
- package/dist/src/app-opentui/react/nav.d.ts +18 -0
- package/dist/src/app-opentui/react/nav.js +54 -0
- package/dist/src/app-opentui/react/scroll.d.ts +12 -0
- package/dist/src/app-opentui/react/scroll.js +21 -0
- package/dist/src/app-opentui/react/syntax.d.ts +2 -0
- package/dist/src/app-opentui/react/syntax.js +64 -0
- package/dist/src/app-opentui/registry.js +20428 -4828
- package/dist/src/app-opentui/render/ascii-fleet.d.ts +15 -0
- package/dist/src/app-opentui/render/ascii-fleet.js +82 -0
- package/dist/src/app-opentui/render/constants.d.ts +31 -0
- package/dist/src/app-opentui/render/constants.js +66 -0
- package/dist/src/app-opentui/render/graphics.d.ts +2 -1
- package/dist/src/app-opentui/render/graphics.js +228 -46
- package/dist/src/app-opentui/render/image-visual-layer-worker.js +469 -930
- package/dist/src/app-opentui/render/image-visual-layer.d.ts +25 -10
- package/dist/src/app-opentui/render/image-visual-layer.js +448 -329
- package/dist/src/app-opentui/render/native-host.d.ts +37 -0
- package/dist/src/app-opentui/render/native-host.js +179 -0
- package/dist/src/app-opentui/render/panel-layout.d.ts +38 -0
- package/dist/src/app-opentui/render/panel-layout.js +48 -0
- package/dist/src/app-opentui/render/panels.d.ts +2 -0
- package/dist/src/app-opentui/render/panels.js +78 -38
- package/dist/src/app-opentui/render/preloader.d.ts +10 -0
- package/dist/src/app-opentui/render/preloader.js +165 -0
- package/dist/src/app-opentui/render/scene.d.ts +53 -1
- package/dist/src/app-opentui/render/scene.js +195 -6
- package/dist/src/app-opentui/render/text.d.ts +7 -1
- package/dist/src/app-opentui/render/text.js +15 -8
- package/dist/src/app-opentui/render/type-bar.d.ts +2 -1
- package/dist/src/app-opentui/render/type-bar.js +113 -39
- package/dist/src/app-opentui/runtime-resources.d.ts +16 -0
- package/dist/src/app-opentui/runtime-resources.js +62 -0
- package/dist/src/app-opentui/runtime.d.ts +44 -1
- package/dist/src/app-opentui/runtime.js +5415 -2738
- package/dist/src/app-opentui/scenes/command.d.ts +3 -0
- package/dist/src/app-opentui/scenes/command.js +117 -0
- package/dist/src/app-opentui/scenes/doctor.d.ts +2 -1
- package/dist/src/app-opentui/scenes/doctor.js +221 -17
- package/dist/src/app-opentui/scenes/error.js +60 -20
- package/dist/src/app-opentui/scenes/family-domains/agent.d.ts +2 -0
- package/dist/src/app-opentui/scenes/family-domains/agent.js +348 -0
- package/dist/src/app-opentui/scenes/family-domains/browser.d.ts +2 -0
- package/dist/src/app-opentui/scenes/family-domains/browser.js +195 -0
- package/dist/src/app-opentui/scenes/family-domains/dist.d.ts +2 -0
- package/dist/src/app-opentui/scenes/family-domains/dist.js +243 -0
- package/dist/src/app-opentui/scenes/family-domains/git.d.ts +2 -0
- package/dist/src/app-opentui/scenes/family-domains/git.js +195 -0
- package/dist/src/app-opentui/scenes/family-domains/github.d.ts +2 -0
- package/dist/src/app-opentui/scenes/family-domains/github.js +274 -0
- package/dist/src/app-opentui/scenes/family-domains/harness.d.ts +2 -0
- package/dist/src/app-opentui/scenes/family-domains/harness.js +152 -0
- package/dist/src/app-opentui/scenes/family-domains/index.d.ts +4 -0
- package/dist/src/app-opentui/scenes/family-domains/index.js +1679 -0
- package/dist/src/app-opentui/scenes/family-domains/kit.d.ts +76 -0
- package/dist/src/app-opentui/scenes/family-domains/kit.js +305 -0
- package/dist/src/app-opentui/scenes/family-domains/profile.d.ts +2 -0
- package/dist/src/app-opentui/scenes/family-domains/profile.js +212 -0
- package/dist/src/app-opentui/scenes/family-domains/queue.d.ts +2 -0
- package/dist/src/app-opentui/scenes/family-domains/queue.js +146 -0
- package/dist/src/app-opentui/scenes/family-domains/remote.d.ts +2 -0
- package/dist/src/app-opentui/scenes/family-domains/remote.js +518 -0
- package/dist/src/app-opentui/scenes/family-domains/review.d.ts +2 -0
- package/dist/src/app-opentui/scenes/family-domains/review.js +280 -0
- package/dist/src/app-opentui/scenes/family-domains/setup.d.ts +2 -0
- package/dist/src/app-opentui/scenes/family-domains/setup.js +267 -0
- package/dist/src/app-opentui/scenes/family-domains/stats.d.ts +2 -0
- package/dist/src/app-opentui/scenes/family-domains/stats.js +370 -0
- package/dist/src/app-opentui/scenes/family.d.ts +3 -0
- package/dist/src/app-opentui/scenes/family.js +2144 -0
- package/dist/src/app-opentui/scenes/fleet.js +552 -43
- package/dist/src/app-opentui/scenes/handoff.js +342 -35
- package/dist/src/app-opentui/scenes/help.js +640 -56
- package/dist/src/app-opentui/scenes/inbox.d.ts +2 -1
- package/dist/src/app-opentui/scenes/inbox.js +329 -21
- package/dist/src/app-opentui/scenes/init.d.ts +2 -1
- package/dist/src/app-opentui/scenes/init.js +120 -34
- package/dist/src/app-opentui/scenes/inspect.d.ts +3 -0
- package/dist/src/app-opentui/scenes/inspect.js +793 -0
- package/dist/src/app-opentui/scenes/main.d.ts +2 -1
- package/dist/src/app-opentui/scenes/main.js +264 -29
- package/dist/src/app-opentui/scenes/pi.d.ts +3 -0
- package/dist/src/app-opentui/scenes/pi.js +508 -0
- package/dist/src/app-opentui/scenes/plugin.d.ts +3 -0
- package/dist/src/app-opentui/scenes/plugin.js +486 -0
- package/dist/src/app-opentui/scenes/repo.d.ts +3 -0
- package/dist/src/app-opentui/scenes/repo.js +424 -0
- package/dist/src/app-opentui/scenes/run-detail.d.ts +2 -1
- package/dist/src/app-opentui/scenes/run-detail.js +362 -35
- package/dist/src/app-opentui/scenes/server.d.ts +2 -1
- package/dist/src/app-opentui/scenes/server.js +243 -26
- package/dist/src/app-opentui/scenes/tasks.js +518 -41
- package/dist/src/app-opentui/scenes/workspace.d.ts +3 -0
- package/dist/src/app-opentui/scenes/workspace.js +426 -0
- package/dist/src/app-opentui/selectable.d.ts +19 -0
- package/dist/src/app-opentui/selectable.js +79 -0
- package/dist/src/app-opentui/state.js +129 -36
- package/dist/src/app-opentui/surface-catalog.d.ts +20 -0
- package/dist/src/app-opentui/surface-catalog.js +540 -0
- package/dist/src/app-opentui/terminal-capabilities.d.ts +7 -0
- package/dist/src/app-opentui/terminal-capabilities.js +15 -0
- package/dist/src/app-opentui/theme.d.ts +28 -6
- package/dist/src/app-opentui/theme.js +61 -8
- package/dist/src/app-opentui/types.d.ts +130 -5
- package/dist/src/commands/_authority-runs.d.ts +1 -1
- package/dist/src/commands/_authority-runs.js +2 -12
- package/dist/src/commands/_doctor-checks.js +62 -13
- package/dist/src/commands/_help-catalog.js +95 -15
- package/dist/src/commands/_operator-view.js +97 -15
- package/dist/src/commands/_pi-frontend.d.ts +2 -0
- package/dist/src/commands/_pi-frontend.js +97 -13
- package/dist/src/commands/_preflight.js +64 -14
- package/dist/src/commands/_server-client.js +82 -18
- package/dist/src/commands/_server-events.d.ts +26 -0
- package/dist/src/commands/_server-events.js +310 -0
- package/dist/src/commands/_snapshot-upload.js +62 -13
- package/dist/src/commands/agent.js +2 -12
- package/dist/src/commands/connect.js +7 -1
- package/dist/src/commands/doctor.js +62 -13
- package/dist/src/commands/github.js +144 -23
- package/dist/src/commands/inbox.js +62 -13
- package/dist/src/commands/init.js +82 -18
- package/dist/src/commands/inspect.js +62 -13
- package/dist/src/commands/run.js +100 -15
- package/dist/src/commands/server.js +71 -26
- package/dist/src/commands/setup.js +62 -13
- package/dist/src/commands/stats.js +157 -28
- package/dist/src/commands/task-run-driver.js +64 -25
- package/dist/src/commands/task.js +196 -43
- package/dist/src/commands.js +419 -123
- package/dist/src/index.js +426 -130
- package/package.json +11 -10
- package/dist/src/app-opentui/render/image-visual-layer-native-canvas.d.ts +0 -2
- package/dist/src/app-opentui/render/image-visual-layer-native-canvas.js +0 -1484
|
@@ -11,15 +11,17 @@ var RIG_UI = {
|
|
|
11
11
|
bg: "#070809",
|
|
12
12
|
bg2: "#0b0c0e",
|
|
13
13
|
panel: "#101115",
|
|
14
|
-
panel2: "#
|
|
15
|
-
glass: "#
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
panel2: "#14161b",
|
|
15
|
+
glass: "#1e2230",
|
|
16
|
+
border: "#2a2e3a",
|
|
17
|
+
ink: "#f4f5f8",
|
|
18
|
+
ink2: "#c7c9d3",
|
|
19
|
+
ink3: "#9aa0ae",
|
|
20
|
+
ink4: "#787b86",
|
|
20
21
|
lime: "#ccff4d",
|
|
21
22
|
limeDim: "#a9d63f",
|
|
22
23
|
cyan: "#56d8ff",
|
|
24
|
+
cyanDim: "#3f9fbd",
|
|
23
25
|
red: "#ff5d5d",
|
|
24
26
|
yellow: "#ffd24d",
|
|
25
27
|
magenta: "#ff79b0"
|
|
@@ -38,11 +40,11 @@ var styles = {
|
|
|
38
40
|
};
|
|
39
41
|
function statusColor(status) {
|
|
40
42
|
switch (status) {
|
|
41
|
-
case "running":
|
|
42
43
|
case "success":
|
|
43
44
|
case "completed":
|
|
44
45
|
case "merged":
|
|
45
46
|
return RIG_UI.lime;
|
|
47
|
+
case "running":
|
|
46
48
|
case "preparing":
|
|
47
49
|
case "created":
|
|
48
50
|
case "validating":
|
|
@@ -62,15 +64,225 @@ function statusColor(status) {
|
|
|
62
64
|
return RIG_UI.ink3;
|
|
63
65
|
}
|
|
64
66
|
}
|
|
67
|
+
function statusGlyph(status) {
|
|
68
|
+
switch (status) {
|
|
69
|
+
case "success":
|
|
70
|
+
case "completed":
|
|
71
|
+
case "merged":
|
|
72
|
+
return "\u2713";
|
|
73
|
+
case "running":
|
|
74
|
+
return "\u25CF";
|
|
75
|
+
case "preparing":
|
|
76
|
+
case "created":
|
|
77
|
+
case "validating":
|
|
78
|
+
case "reviewing":
|
|
79
|
+
case "closing-out":
|
|
80
|
+
case "stopping":
|
|
81
|
+
case "loading":
|
|
82
|
+
case "action":
|
|
83
|
+
return "\u25D0";
|
|
84
|
+
case "needs-attention":
|
|
85
|
+
case "needs_attention":
|
|
86
|
+
return "\u26A0";
|
|
87
|
+
case "failed":
|
|
88
|
+
case "error":
|
|
89
|
+
return "\u2717";
|
|
90
|
+
default:
|
|
91
|
+
return "\xB7";
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function noColorActive() {
|
|
95
|
+
const noColor = process.env.NO_COLOR;
|
|
96
|
+
if (noColor !== undefined && noColor !== "") {
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
return process.env.RIG_NO_COLOR !== undefined;
|
|
100
|
+
}
|
|
101
|
+
function statusLabel(status) {
|
|
102
|
+
return {
|
|
103
|
+
glyph: statusGlyph(status),
|
|
104
|
+
color: noColorActive() ? RIG_UI.ink : statusColor(status)
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// packages/cli/src/app-opentui/drone.ts
|
|
109
|
+
import { RGBA, StyledText, TextAttributes as TextAttributes2 } from "@opentui/core";
|
|
110
|
+
var MINI_DRONE = [
|
|
111
|
+
"(!!!) (!!!)",
|
|
112
|
+
" \\%==%/ ",
|
|
113
|
+
" %%?%% ",
|
|
114
|
+
" /%==%\\ ",
|
|
115
|
+
"(!!!) (!!!)"
|
|
116
|
+
];
|
|
117
|
+
var LEAD_MARK = [
|
|
118
|
+
" .-=-. ",
|
|
119
|
+
"=%%?%%=",
|
|
120
|
+
" '-=-' "
|
|
121
|
+
];
|
|
122
|
+
var BLADE_FRAMES = ["---", "\\\\\\", "|||", "///"];
|
|
123
|
+
var EYE_FRAMES = ["o", "@", "\u2022", "."];
|
|
124
|
+
var COLOR = {
|
|
125
|
+
body: RGBA.fromHex(RIG_UI.lime),
|
|
126
|
+
mini: RGBA.fromHex(RIG_UI.limeDim),
|
|
127
|
+
rotor: RGBA.fromHex(RIG_UI.cyan),
|
|
128
|
+
path: RGBA.fromHex(RIG_UI.cyan),
|
|
129
|
+
eye: RGBA.fromHex(RIG_UI.ink),
|
|
130
|
+
dim: RGBA.fromHex(RIG_UI.ink4),
|
|
131
|
+
ink: RGBA.fromHex(RIG_UI.ink2)
|
|
132
|
+
};
|
|
133
|
+
function bladeForTick(tick, phase = 0) {
|
|
134
|
+
return BLADE_FRAMES[(Math.floor(tick / 3) + phase) % BLADE_FRAMES.length];
|
|
135
|
+
}
|
|
136
|
+
function eyeForTick(tick, phase = 0) {
|
|
137
|
+
const pulse = Math.sin(tick * 0.09 + phase);
|
|
138
|
+
return pulse > 0.55 ? EYE_FRAMES[1] : pulse > 0.1 ? EYE_FRAMES[0] : pulse > -0.45 ? EYE_FRAMES[2] : EYE_FRAMES[3];
|
|
139
|
+
}
|
|
140
|
+
function chunk(text, fg, bold = false, dim = false) {
|
|
141
|
+
let attributes = TextAttributes2.NONE;
|
|
142
|
+
if (bold)
|
|
143
|
+
attributes |= TextAttributes2.BOLD;
|
|
144
|
+
if (dim)
|
|
145
|
+
attributes |= TextAttributes2.DIM;
|
|
146
|
+
return { __isChunk: true, text, fg, ...attributes !== TextAttributes2.NONE ? { attributes } : {} };
|
|
147
|
+
}
|
|
148
|
+
function styledLine(text, colorFor) {
|
|
149
|
+
const chunks = [];
|
|
150
|
+
let run = "";
|
|
151
|
+
let runColor = null;
|
|
152
|
+
const flush = () => {
|
|
153
|
+
if (!run || !runColor)
|
|
154
|
+
return;
|
|
155
|
+
chunks.push(chunk(run, COLOR[runColor], runColor === "body" || runColor === "eye", runColor === "dim"));
|
|
156
|
+
run = "";
|
|
157
|
+
};
|
|
158
|
+
for (const char of text) {
|
|
159
|
+
const next = colorFor(char);
|
|
160
|
+
if (next !== runColor) {
|
|
161
|
+
flush();
|
|
162
|
+
runColor = next;
|
|
163
|
+
}
|
|
164
|
+
run += char;
|
|
165
|
+
}
|
|
166
|
+
flush();
|
|
167
|
+
return new StyledText(chunks.length > 0 ? chunks : [chunk("", COLOR.ink)]);
|
|
168
|
+
}
|
|
169
|
+
function droneColor(char) {
|
|
170
|
+
if (char === "?" || char === "o" || char === "@" || char === "\u2022")
|
|
171
|
+
return "eye";
|
|
172
|
+
if (char === "%" || char === "=")
|
|
173
|
+
return "mini";
|
|
174
|
+
if (char === "$")
|
|
175
|
+
return "body";
|
|
176
|
+
if (char === "(" || char === ")" || char === "/" || char === "\\" || char === "|" || char === "-")
|
|
177
|
+
return "rotor";
|
|
178
|
+
if (char === "\xB7" || char === "\u2022" || char === "'" || char === ".")
|
|
179
|
+
return "path";
|
|
180
|
+
if (char.trim() === "")
|
|
181
|
+
return "dim";
|
|
182
|
+
return "ink";
|
|
183
|
+
}
|
|
184
|
+
function motionColor(char) {
|
|
185
|
+
if (char === "\u25CF" || char === "\u25C6" || char === "\u25C9")
|
|
186
|
+
return "body";
|
|
187
|
+
if (char === "\u2022" || char === "\xB7" || char === "\u2500" || char === "\u2502" || char === "\u2571" || char === "\u2572" || char === "\u256D" || char === "\u256E" || char === "\u2570" || char === "\u256F")
|
|
188
|
+
return "path";
|
|
189
|
+
if (char === "\u258C" || char === "\u2590" || char === "\u2581" || char === "\u2594")
|
|
190
|
+
return "mini";
|
|
191
|
+
return droneColor(char);
|
|
192
|
+
}
|
|
193
|
+
function materializeDrone(lines, tick, phase = 0) {
|
|
194
|
+
const blade = bladeForTick(tick, phase);
|
|
195
|
+
const eye = eyeForTick(tick, phase);
|
|
196
|
+
return lines.map((line) => line.replaceAll("!!!", blade).replaceAll("?", eye));
|
|
197
|
+
}
|
|
198
|
+
function miniDroneLines(tick, align = "left", phase = 0) {
|
|
199
|
+
return materializeDrone(MINI_DRONE, tick, phase).map((text) => ({
|
|
200
|
+
text,
|
|
201
|
+
styledText: styledLine(text, droneColor),
|
|
202
|
+
fg: RIG_UI.limeDim,
|
|
203
|
+
align
|
|
204
|
+
}));
|
|
205
|
+
}
|
|
206
|
+
function brandFleetLines(tick, align = "center") {
|
|
207
|
+
const left = materializeDrone(MINI_DRONE, tick, 0);
|
|
208
|
+
const right = materializeDrone(MINI_DRONE, tick, 2);
|
|
209
|
+
const lead = materializeDrone(LEAD_MARK, tick, 1);
|
|
210
|
+
const packet = ["\xB7", "\u2022", "\u25CF", "\u2022"][Math.floor(tick / 2) % 4];
|
|
211
|
+
const bridge = [
|
|
212
|
+
` ${left[0]} ${lead[0]} ${right[0]}`,
|
|
213
|
+
` ${left[1]} \xB7\u2500\u2500${packet}\u2500\u2500\xB7 ${lead[1]} \xB7\u2500\u2500${packet}\u2500\u2500\xB7 ${right[1]}`,
|
|
214
|
+
` ${left[2]} \xB7' '${lead[2]}' '\xB7 ${right[2]}`,
|
|
215
|
+
` ${left[3]} \u2572 signal bus \u2571 ${right[3]}`,
|
|
216
|
+
` ${left[4]} \xB7\u2500\u2500\u2500${packet}\u2500\u2500\u2500\u2500\u2500\u2500${packet}\u2500\u2500\u2500\xB7 ${right[4]}`
|
|
217
|
+
];
|
|
218
|
+
return bridge.map((text) => ({
|
|
219
|
+
text,
|
|
220
|
+
styledText: styledLine(text, motionColor),
|
|
221
|
+
fg: RIG_UI.limeDim,
|
|
222
|
+
align
|
|
223
|
+
}));
|
|
224
|
+
}
|
|
225
|
+
function actionDrone(tick, phase = 0) {
|
|
226
|
+
const blade = bladeForTick(tick, phase);
|
|
227
|
+
const eye = eyeForTick(tick, phase);
|
|
228
|
+
return `(${blade})\u2572${eye}\u2571(${blade})`;
|
|
229
|
+
}
|
|
230
|
+
function actionDroneLine(tick, text, fg = RIG_UI.ink2) {
|
|
231
|
+
const prefix = actionDrone(tick);
|
|
232
|
+
const content = `${prefix} ${text}`;
|
|
233
|
+
return { text: content, styledText: styledLine(content, motionColor), fg, align: "center" };
|
|
234
|
+
}
|
|
65
235
|
|
|
66
236
|
// packages/cli/src/app-opentui/render/scene.ts
|
|
67
237
|
function line(text, options = {}) {
|
|
68
238
|
return { text, ...options };
|
|
69
239
|
}
|
|
240
|
+
function blank() {
|
|
241
|
+
return { text: "" };
|
|
242
|
+
}
|
|
243
|
+
function deckRow(input) {
|
|
244
|
+
const prefix = input.active ? "\u25B8" : " ";
|
|
245
|
+
const label = input.label.toUpperCase().padEnd(10);
|
|
246
|
+
return line(`${prefix} ${label} ${input.detail}`, {
|
|
247
|
+
fg: input.active ? RIG_UI.lime : RIG_UI.ink2,
|
|
248
|
+
bold: input.active,
|
|
249
|
+
selectableIndex: input.index,
|
|
250
|
+
activateOnClick: input.activateOnClick
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
function loadingRows(label, tick = 0, compact = false) {
|
|
254
|
+
const mascot = compact ? miniDroneLines(tick, "center") : brandFleetLines(tick, "center");
|
|
255
|
+
return [
|
|
256
|
+
blank(),
|
|
257
|
+
...mascot,
|
|
258
|
+
blank(),
|
|
259
|
+
{ ...actionDroneLine(tick, `loading ${label}\u2026`, RIG_UI.cyan), align: "center" }
|
|
260
|
+
];
|
|
261
|
+
}
|
|
262
|
+
function errorBanner(message, hint) {
|
|
263
|
+
return [
|
|
264
|
+
line(`\u2717 failed to load \u2014 ${message}`, { fg: RIG_UI.red, bold: true }),
|
|
265
|
+
...hint ? [line(` ${hint}`, { fg: RIG_UI.ink3 })] : [],
|
|
266
|
+
line(" select refresh/retry below", { fg: RIG_UI.ink4 }),
|
|
267
|
+
line("", { fg: RIG_UI.ink3 })
|
|
268
|
+
];
|
|
269
|
+
}
|
|
270
|
+
function lastRefreshError(state) {
|
|
271
|
+
const value = state.data.lastRefreshError;
|
|
272
|
+
return typeof value === "string" && value.trim() ? value : undefined;
|
|
273
|
+
}
|
|
70
274
|
function makeSceneFrame(input) {
|
|
71
275
|
return input;
|
|
72
276
|
}
|
|
73
277
|
|
|
278
|
+
// packages/cli/src/app-opentui/selectable.ts
|
|
279
|
+
function selectableDeckRow(deck, item) {
|
|
280
|
+
return { ...deckRow({ ...deck, activateOnClick: true }), selectable: item };
|
|
281
|
+
}
|
|
282
|
+
function withSelectable(line2, item) {
|
|
283
|
+
return { ...line2, selectable: item, activateOnClick: true };
|
|
284
|
+
}
|
|
285
|
+
|
|
74
286
|
// packages/cli/src/app-opentui/list-search.ts
|
|
75
287
|
function isListSearchScene(scene) {
|
|
76
288
|
return scene === "fleet" || scene === "tasks";
|
|
@@ -103,15 +315,199 @@ function filterRunsForSearch(runs, query) {
|
|
|
103
315
|
function searchSummary(kind, query, visible, total) {
|
|
104
316
|
return query.trim() ? `search ${JSON.stringify(query)} \xB7 ${visible}/${total} ${kind}` : `${total} ${kind}`;
|
|
105
317
|
}
|
|
318
|
+
function runSortSpec(value) {
|
|
319
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
320
|
+
return null;
|
|
321
|
+
const record = value;
|
|
322
|
+
const key = record.key;
|
|
323
|
+
const dir = record.dir;
|
|
324
|
+
if ((key === "status" || key === "runId" || key === "title" || key === "age") && (dir === "asc" || dir === "desc")) {
|
|
325
|
+
return { key, dir };
|
|
326
|
+
}
|
|
327
|
+
return null;
|
|
328
|
+
}
|
|
329
|
+
function cycleRunSort(current, key) {
|
|
330
|
+
if (!current || current.key !== key)
|
|
331
|
+
return { key, dir: "asc" };
|
|
332
|
+
if (current.dir === "asc")
|
|
333
|
+
return { key, dir: "desc" };
|
|
334
|
+
return null;
|
|
335
|
+
}
|
|
336
|
+
function ageValue(updatedAt) {
|
|
337
|
+
const parsed = Date.parse(updatedAt ?? "");
|
|
338
|
+
return Number.isFinite(parsed) ? parsed : 0;
|
|
339
|
+
}
|
|
340
|
+
function applyDir(rows, compare, dir) {
|
|
341
|
+
const sorted = [...rows].sort(compare);
|
|
342
|
+
return dir === "desc" ? sorted.reverse() : sorted;
|
|
343
|
+
}
|
|
344
|
+
function sortRuns(runs, spec) {
|
|
345
|
+
if (!spec)
|
|
346
|
+
return [...runs];
|
|
347
|
+
const { key, dir } = spec;
|
|
348
|
+
if (key === "age") {
|
|
349
|
+
const byNewest = applyDir(runs, (a, b) => ageValue(b.updatedAt) - ageValue(a.updatedAt) || a.runId.localeCompare(b.runId), "asc");
|
|
350
|
+
return dir === "asc" ? byNewest : [...byNewest].reverse();
|
|
351
|
+
}
|
|
352
|
+
const compare = (a, b) => {
|
|
353
|
+
if (key === "status")
|
|
354
|
+
return a.status.localeCompare(b.status) || a.runId.localeCompare(b.runId);
|
|
355
|
+
if (key === "title")
|
|
356
|
+
return a.title.localeCompare(b.title, undefined, { sensitivity: "base" }) || a.runId.localeCompare(b.runId);
|
|
357
|
+
return a.runId.localeCompare(b.runId, undefined, { numeric: true });
|
|
358
|
+
};
|
|
359
|
+
return applyDir(runs, compare, dir);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
// packages/cli/src/app-opentui/fleet-stats.ts
|
|
363
|
+
var ACTIVE_STATUSES = new Set([
|
|
364
|
+
"running",
|
|
365
|
+
"preparing",
|
|
366
|
+
"created",
|
|
367
|
+
"validating",
|
|
368
|
+
"reviewing",
|
|
369
|
+
"closing-out",
|
|
370
|
+
"stopping",
|
|
371
|
+
"loading"
|
|
372
|
+
]);
|
|
373
|
+
var SPARK_CHARS = ["\u2581", "\u2582", "\u2583", "\u2584", "\u2585", "\u2586", "\u2587", "\u2588"];
|
|
374
|
+
function normalizeStatus(status) {
|
|
375
|
+
return status.replace(/_/g, "-").toLowerCase();
|
|
376
|
+
}
|
|
377
|
+
function computeFleetStats(runs) {
|
|
378
|
+
const byStatus = new Map;
|
|
379
|
+
let active = 0;
|
|
380
|
+
let succeeded = 0;
|
|
381
|
+
let failed = 0;
|
|
382
|
+
for (const run of runs) {
|
|
383
|
+
const status = normalizeStatus(run.status ?? "");
|
|
384
|
+
byStatus.set(status, (byStatus.get(status) ?? 0) + 1);
|
|
385
|
+
if (ACTIVE_STATUSES.has(status))
|
|
386
|
+
active += 1;
|
|
387
|
+
else if (status === "success" || status === "completed" || status === "merged")
|
|
388
|
+
succeeded += 1;
|
|
389
|
+
else if (status === "failed" || status === "error")
|
|
390
|
+
failed += 1;
|
|
391
|
+
}
|
|
392
|
+
const total = runs.length;
|
|
393
|
+
const load = total === 0 ? 0 : active / total;
|
|
394
|
+
const sparkline = buildSparklineSeries(active, succeeded, failed);
|
|
395
|
+
return { total, active, succeeded, failed, byStatus, load, sparkline };
|
|
396
|
+
}
|
|
397
|
+
function buildSparklineSeries(active, succeeded, failed) {
|
|
398
|
+
const peak = Math.max(1, active, succeeded, failed);
|
|
399
|
+
const base = [succeeded, Math.round(succeeded * 0.6 + failed * 0.4), failed, Math.round((active + failed) / 2), active];
|
|
400
|
+
return base.map((value) => Math.max(0, Math.min(peak, value)) / peak);
|
|
401
|
+
}
|
|
402
|
+
function sparklineString(values, width) {
|
|
403
|
+
if (values.length === 0)
|
|
404
|
+
return "";
|
|
405
|
+
const series = width && width > 0 && values.length > width ? values.slice(values.length - width) : values;
|
|
406
|
+
return series.map((value) => {
|
|
407
|
+
const clamped = Math.max(0, Math.min(1, value));
|
|
408
|
+
const index = Math.min(SPARK_CHARS.length - 1, Math.round(clamped * (SPARK_CHARS.length - 1)));
|
|
409
|
+
return SPARK_CHARS[index];
|
|
410
|
+
}).join("");
|
|
411
|
+
}
|
|
412
|
+
function statusSegments(stats, width) {
|
|
413
|
+
if (width <= 0 || stats.total === 0)
|
|
414
|
+
return { active: "", done: "", failed: "", other: "" };
|
|
415
|
+
const other = Math.max(0, stats.total - stats.active - stats.succeeded - stats.failed);
|
|
416
|
+
const raw = [
|
|
417
|
+
{ key: "active", value: stats.active },
|
|
418
|
+
{ key: "done", value: stats.succeeded },
|
|
419
|
+
{ key: "failed", value: stats.failed },
|
|
420
|
+
{ key: "other", value: other }
|
|
421
|
+
];
|
|
422
|
+
const exact = raw.map((entry) => ({ key: entry.key, exact: entry.value / stats.total * width }));
|
|
423
|
+
const floored = exact.map((entry) => ({ key: entry.key, n: Math.floor(entry.exact), frac: entry.exact - Math.floor(entry.exact) }));
|
|
424
|
+
let remaining = width - floored.reduce((sum, entry) => sum + entry.n, 0);
|
|
425
|
+
for (const entry of [...floored].sort((a, b) => b.frac - a.frac)) {
|
|
426
|
+
if (remaining <= 0)
|
|
427
|
+
break;
|
|
428
|
+
entry.n += 1;
|
|
429
|
+
remaining -= 1;
|
|
430
|
+
}
|
|
431
|
+
const widths = new Map(floored.map((entry) => [entry.key, entry.n]));
|
|
432
|
+
return {
|
|
433
|
+
active: "\u2588".repeat(widths.get("active") ?? 0),
|
|
434
|
+
done: "\u2588".repeat(widths.get("done") ?? 0),
|
|
435
|
+
failed: "\u2588".repeat(widths.get("failed") ?? 0),
|
|
436
|
+
other: "\u2592".repeat(widths.get("other") ?? 0)
|
|
437
|
+
};
|
|
438
|
+
}
|
|
106
439
|
|
|
107
440
|
// packages/cli/src/app-opentui/scenes/fleet.ts
|
|
108
|
-
|
|
441
|
+
var FLEET_RECOVERY_ITEMS = [
|
|
442
|
+
{ id: "tasks", label: "tasks", intent: { scene: "tasks", argv: ["tasks"], action: { kind: "refresh", label: "Open tasks" } }, message: "open tasks and dispatch work" },
|
|
443
|
+
{ id: "repair", label: "repair", intent: { scene: "command", argv: ["init", "--repair"], action: { kind: "command-run", label: "Repair project link" } }, message: "repair project/server/auth link" },
|
|
444
|
+
{ id: "server", label: "server", intent: { scene: "server", argv: ["server", "status"], action: { kind: "refresh", label: "Open server controls" } }, message: "server controls" },
|
|
445
|
+
{ id: "doctor", label: "doctor", intent: { scene: "doctor", argv: ["doctor"], action: { kind: "doctor-run", label: "Run doctor" } }, message: "diagnose project" }
|
|
446
|
+
];
|
|
447
|
+
var COL = {
|
|
448
|
+
glyph: 1,
|
|
449
|
+
runId: 8,
|
|
450
|
+
status: 13,
|
|
451
|
+
age: 6,
|
|
452
|
+
model: 10
|
|
453
|
+
};
|
|
454
|
+
var GUTTER = " ";
|
|
455
|
+
var RUN_COLUMNS = [
|
|
456
|
+
{ key: "status", label: "status", hint: "by run state" },
|
|
457
|
+
{ key: "runId", label: "run-id", hint: "by run id" },
|
|
458
|
+
{ key: "title", label: "task/title", hint: "by task title" },
|
|
459
|
+
{ key: "age", label: "age", hint: "by recency" }
|
|
460
|
+
];
|
|
461
|
+
function runSelectableItem(run) {
|
|
462
|
+
const runId = run.runId?.trim();
|
|
463
|
+
if (!runId)
|
|
464
|
+
return null;
|
|
465
|
+
const title = (run.title || run.taskId || "run").trim() || "run";
|
|
466
|
+
return {
|
|
467
|
+
id: runId,
|
|
468
|
+
label: title,
|
|
469
|
+
data: { selectedRunId: runId },
|
|
470
|
+
intent: { scene: "run-detail", argv: ["run", "status", runId], action: { kind: "refresh", payload: { runId }, label: `Open run ${runId.slice(0, 8)}` } },
|
|
471
|
+
message: `open run ${runId.slice(0, 8)} detail`
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
function fleetSlice(state) {
|
|
109
475
|
const fleet = state.data.fleet;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
476
|
+
return fleet && typeof fleet === "object" && !Array.isArray(fleet) ? fleet : null;
|
|
477
|
+
}
|
|
478
|
+
function asRuns(state) {
|
|
479
|
+
const runs = fleetSlice(state)?.runs;
|
|
113
480
|
return Array.isArray(runs) ? runs : [];
|
|
114
481
|
}
|
|
482
|
+
function optimisticStatuses(state) {
|
|
483
|
+
const map = new Map;
|
|
484
|
+
for (const key of ["optimisticRun", "dispatchingRun"]) {
|
|
485
|
+
const value = state.data[key];
|
|
486
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
487
|
+
continue;
|
|
488
|
+
const record = value;
|
|
489
|
+
if (typeof record.runId === "string" && typeof record.status === "string")
|
|
490
|
+
map.set(record.runId, record.status);
|
|
491
|
+
}
|
|
492
|
+
return map;
|
|
493
|
+
}
|
|
494
|
+
function updatedAgoLabel(state) {
|
|
495
|
+
const refreshedAt = fleetSlice(state)?.refreshedAt;
|
|
496
|
+
if (typeof refreshedAt !== "string")
|
|
497
|
+
return;
|
|
498
|
+
const parsed = Date.parse(refreshedAt);
|
|
499
|
+
if (!Number.isFinite(parsed))
|
|
500
|
+
return;
|
|
501
|
+
const seconds = Math.max(0, Math.round((Date.now() - parsed) / 1000));
|
|
502
|
+
if (seconds < 1)
|
|
503
|
+
return "updated just now";
|
|
504
|
+
if (seconds < 60)
|
|
505
|
+
return `updated ${seconds}s ago`;
|
|
506
|
+
const minutes = Math.round(seconds / 60);
|
|
507
|
+
if (minutes < 60)
|
|
508
|
+
return `updated ${minutes}m ago`;
|
|
509
|
+
return `updated ${Math.round(minutes / 60)}h ago`;
|
|
510
|
+
}
|
|
115
511
|
function panelWidth(layout) {
|
|
116
512
|
return layout?.centerWidth ?? 100;
|
|
117
513
|
}
|
|
@@ -123,63 +519,172 @@ function clip(value, width) {
|
|
|
123
519
|
return "";
|
|
124
520
|
return value.length <= width ? value : `${value.slice(0, Math.max(0, width - 1))}\u2026`;
|
|
125
521
|
}
|
|
126
|
-
function
|
|
127
|
-
|
|
128
|
-
|
|
522
|
+
function cell(value, width) {
|
|
523
|
+
return clip(value, width).padEnd(width);
|
|
524
|
+
}
|
|
525
|
+
function relativeAge(updatedAt) {
|
|
526
|
+
const parsed = Date.parse(updatedAt ?? "");
|
|
527
|
+
if (!Number.isFinite(parsed))
|
|
528
|
+
return "\u2014";
|
|
529
|
+
const deltaMs = Date.now() - parsed;
|
|
530
|
+
if (deltaMs < 0)
|
|
531
|
+
return "now";
|
|
532
|
+
const seconds = Math.floor(deltaMs / 1000);
|
|
533
|
+
if (seconds < 60)
|
|
534
|
+
return `${seconds}s`;
|
|
535
|
+
const minutes = Math.floor(seconds / 60);
|
|
536
|
+
if (minutes < 60)
|
|
537
|
+
return `${minutes}m`;
|
|
538
|
+
const hours = Math.floor(minutes / 60);
|
|
539
|
+
if (hours < 24)
|
|
540
|
+
return `${hours}h`;
|
|
541
|
+
const days = Math.floor(hours / 24);
|
|
542
|
+
if (days < 99)
|
|
543
|
+
return `${days}d`;
|
|
544
|
+
return "99d+";
|
|
545
|
+
}
|
|
546
|
+
function modelLabel(run) {
|
|
547
|
+
const raw = run.raw;
|
|
548
|
+
for (const key of ["model", "runtimeAdapter", "adapter", "runtimeMode"]) {
|
|
549
|
+
const value = raw[key];
|
|
550
|
+
if (typeof value === "string" && value.trim())
|
|
551
|
+
return value.trim();
|
|
552
|
+
}
|
|
553
|
+
return "\u2014";
|
|
554
|
+
}
|
|
555
|
+
function sortArrow(spec, key) {
|
|
556
|
+
if (!spec || spec.key !== key)
|
|
557
|
+
return "";
|
|
558
|
+
return spec.dir === "asc" ? "\u25B2" : "\u25BC";
|
|
559
|
+
}
|
|
560
|
+
function headerRow(titleWidth, spec) {
|
|
561
|
+
const text = [
|
|
562
|
+
" ",
|
|
563
|
+
cell(`run-id${sortArrow(spec, "runId")}`, COL.runId),
|
|
564
|
+
cell(`status${sortArrow(spec, "status")}`, COL.status),
|
|
565
|
+
cell(`task / title${sortArrow(spec, "title")}`, titleWidth),
|
|
566
|
+
cell(`age${sortArrow(spec, "age")}`, COL.age),
|
|
567
|
+
"model"
|
|
568
|
+
].join(GUTTER);
|
|
569
|
+
return line(text, { fg: RIG_UI.ink, bold: true, bg: RIG_UI.glass });
|
|
570
|
+
}
|
|
571
|
+
function sortToggleRow(column, current) {
|
|
572
|
+
const arrow = sortArrow(current, column.key);
|
|
573
|
+
const active = current?.key === column.key;
|
|
574
|
+
const next = cycleRunSort(current, column.key);
|
|
575
|
+
const marker = active ? "\u25B8" : " ";
|
|
576
|
+
const label = `${column.label}${arrow ? ` ${arrow}` : ""}`.padEnd(14);
|
|
577
|
+
const row = line(`${marker} ${label} ${column.hint}`, {
|
|
578
|
+
fg: active ? RIG_UI.lime : RIG_UI.ink2,
|
|
579
|
+
bold: active
|
|
580
|
+
});
|
|
581
|
+
return withSelectable(row, {
|
|
582
|
+
id: `fleet-sort-${column.key}`,
|
|
583
|
+
label: `sort by ${column.label}`,
|
|
584
|
+
data: { fleetSort: next },
|
|
585
|
+
message: `sort runs ${next ? `${column.label} ${next.dir}` : "default"}`
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
function sortStrip(spec) {
|
|
589
|
+
return [
|
|
590
|
+
line("SORT", { fg: RIG_UI.ink3, bold: true }),
|
|
591
|
+
...RUN_COLUMNS.map((column) => sortToggleRow(column, spec)),
|
|
592
|
+
line("", { fg: RIG_UI.ink3 })
|
|
593
|
+
];
|
|
594
|
+
}
|
|
595
|
+
function runRow(width, run, active, optimistic) {
|
|
596
|
+
const effectiveStatus = optimistic ?? run.status;
|
|
597
|
+
const { glyph } = statusLabel(effectiveStatus);
|
|
129
598
|
const marker = active ? "\u258C" : " ";
|
|
130
|
-
const
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
599
|
+
const status = effectiveStatus.replace(/[_-]/g, " ");
|
|
600
|
+
const fixed = `${marker} ${glyph}${GUTTER}${cell(run.runId.slice(0, COL.runId), COL.runId)}${GUTTER}${cell(status, COL.status)}${GUTTER}`;
|
|
601
|
+
const tail = `${GUTTER}${cell(relativeAge(run.updatedAt), COL.age)}${GUTTER}${cell(modelLabel(run), COL.model)}`;
|
|
602
|
+
const titleWidth = Math.max(8, width - fixed.length - tail.length);
|
|
603
|
+
const row = line(`${fixed}${cell(run.title, titleWidth)}${tail}`, {
|
|
604
|
+
fg: active ? RIG_UI.ink : RIG_UI.ink2,
|
|
134
605
|
bold: active,
|
|
135
|
-
|
|
606
|
+
...active ? { bg: RIG_UI.glass } : {}
|
|
136
607
|
});
|
|
608
|
+
const item = runSelectableItem(run);
|
|
609
|
+
return item ? withSelectable(row, item) : row;
|
|
610
|
+
}
|
|
611
|
+
var RECOVERY_DECKS = [
|
|
612
|
+
{ label: "tasks", detail: "open tasks and dispatch work" },
|
|
613
|
+
{ label: "repair", detail: "repair project/server/auth link" },
|
|
614
|
+
{ label: "server", detail: "open server controls" },
|
|
615
|
+
{ label: "doctor", detail: "diagnose project" }
|
|
616
|
+
];
|
|
617
|
+
function recoveryRows(selected, reason) {
|
|
618
|
+
return [
|
|
619
|
+
...reason ? [line(reason, { fg: RIG_UI.yellow }), line("", { fg: RIG_UI.ink3 })] : [],
|
|
620
|
+
line("ACTIONS", { fg: RIG_UI.ink3, bold: true }),
|
|
621
|
+
...RECOVERY_DECKS.map((deck, index) => selectableDeckRow({ ...deck, index, active: selected === index }, FLEET_RECOVERY_ITEMS[index]))
|
|
622
|
+
];
|
|
137
623
|
}
|
|
138
|
-
function emptyRows(query, total) {
|
|
624
|
+
function emptyRows(query, total, selected) {
|
|
625
|
+
if (!query.trim() && total === 0)
|
|
626
|
+
return recoveryRows(selected, "No runs yet.");
|
|
139
627
|
if (query.trim() && total > 0) {
|
|
140
628
|
return [
|
|
141
|
-
|
|
142
|
-
line(`search ${JSON.stringify(query)} returned 0/${total}`, { fg: RIG_UI.ink3 }),
|
|
143
|
-
line("escape clears search", { fg: RIG_UI.ink4 })
|
|
629
|
+
...recoveryRows(selected, `No matching runs for ${JSON.stringify(query)} (${total} total).`)
|
|
144
630
|
];
|
|
145
631
|
}
|
|
146
|
-
return
|
|
147
|
-
line("No runs yet.", { fg: RIG_UI.ink2, bold: true }),
|
|
148
|
-
line("Open Tasks and dispatch work; live and completed runs appear here.", { fg: RIG_UI.ink3 }),
|
|
149
|
-
line("tab switches screens", { fg: RIG_UI.ink4 })
|
|
150
|
-
];
|
|
632
|
+
return recoveryRows(selected, "No runs are visible with this filter.");
|
|
151
633
|
}
|
|
152
|
-
function degradedRows(state) {
|
|
634
|
+
function degradedRows(state, selected) {
|
|
153
635
|
if (!state.error)
|
|
154
636
|
return [];
|
|
155
|
-
return
|
|
156
|
-
line(`status: ${state.error.message}`, { fg: RIG_UI.red, bold: true }),
|
|
157
|
-
...state.error.hint ? [line(state.error.hint, { fg: RIG_UI.yellow })] : [],
|
|
158
|
-
line("", { fg: RIG_UI.ink3 })
|
|
159
|
-
];
|
|
637
|
+
return recoveryRows(selected, state.error.message);
|
|
160
638
|
}
|
|
161
639
|
function renderFleetScene(state, layout) {
|
|
162
640
|
const width = panelWidth(layout);
|
|
163
641
|
const allRuns = asRuns(state);
|
|
164
642
|
const query = listSearchQuery(state);
|
|
165
|
-
const
|
|
643
|
+
const spec = runSortSpec(state.data.fleetSort);
|
|
644
|
+
const runs = sortRuns(filterRunsForSearch(allRuns, query), spec);
|
|
166
645
|
const selectedRun = typeof state.data.selectedRunId === "string" && runs.some((run) => run.runId === state.data.selectedRunId) ? state.data.selectedRunId : runs[0]?.runId;
|
|
167
646
|
const selectedIndex = Math.max(0, runs.findIndex((run) => run.runId === selectedRun));
|
|
647
|
+
const recoveryIndex = Math.max(0, Math.min(3, state.selection.index));
|
|
648
|
+
const optimistic = optimisticStatuses(state);
|
|
649
|
+
const updatedAgo = updatedAgoLabel(state);
|
|
168
650
|
const panelTop = 0;
|
|
169
651
|
const contentWidth = Math.max(12, width - (layout?.compact ? 8 : 10));
|
|
652
|
+
const stats = computeFleetStats(allRuns);
|
|
653
|
+
const barWidth = Math.max(8, Math.min(48, contentWidth - 8));
|
|
654
|
+
const segments = statusSegments(stats, barWidth);
|
|
655
|
+
const distributionBar = t`${styles.cyan(segments.active)}${styles.lime(segments.done)}${styles.red(segments.failed)}${styles.ink4(segments.other)}`;
|
|
656
|
+
const telemetry = allRuns.length > 0 ? [
|
|
657
|
+
line(`load ${sparklineString(stats.sparkline)} ${Math.round(stats.load * 100)}% \u25CF${stats.active} active \u2713${stats.succeeded} done \u2717${stats.failed} failed ${stats.total} total`, { fg: RIG_UI.cyan }),
|
|
658
|
+
{ text: segments.active + segments.done + segments.failed + segments.other, styledText: distributionBar, fg: RIG_UI.ink2 },
|
|
659
|
+
line("", { fg: RIG_UI.ink3 })
|
|
660
|
+
] : [];
|
|
661
|
+
const G = GUTTER.length;
|
|
662
|
+
const railWidth = 1 + 1 + COL.glyph;
|
|
663
|
+
const titleWidth = Math.max(8, contentWidth - (railWidth + G + COL.runId + G + COL.status + G + G + COL.age + G + COL.model));
|
|
664
|
+
const loading = state.status === "loading" && allRuns.length === 0;
|
|
665
|
+
const refreshError = lastRefreshError(state);
|
|
666
|
+
const banner = refreshError && !state.error ? errorBanner(refreshError) : [];
|
|
170
667
|
const panelLines = [
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
...
|
|
174
|
-
|
|
175
|
-
|
|
668
|
+
...banner,
|
|
669
|
+
...telemetry,
|
|
670
|
+
...runs.length > 0 ? [
|
|
671
|
+
...degradedRows(state, recoveryIndex),
|
|
672
|
+
...query.trim() ? [line(searchSummary("runs", query, runs.length, allRuns.length), { fg: RIG_UI.ink4 }), line("", { fg: RIG_UI.ink3 })] : [],
|
|
673
|
+
...sortStrip(spec),
|
|
674
|
+
headerRow(titleWidth, spec),
|
|
675
|
+
line("", { fg: RIG_UI.ink3 }),
|
|
676
|
+
...runs.map((run, index) => runRow(contentWidth, run, index === selectedIndex, optimistic.get(run.runId)))
|
|
677
|
+
] : state.error ? degradedRows(state, recoveryIndex) : loading ? loadingRows("runs", state.tick) : [
|
|
678
|
+
...query.trim() ? [line(searchSummary("runs", query, runs.length, allRuns.length), { fg: RIG_UI.ink4 }), line("", { fg: RIG_UI.ink3 })] : [],
|
|
679
|
+
...emptyRows(query, allRuns.length, recoveryIndex)
|
|
680
|
+
]
|
|
176
681
|
];
|
|
177
682
|
return makeSceneFrame({
|
|
178
683
|
scene: "fleet",
|
|
179
684
|
title: "Runs",
|
|
180
685
|
lines: [
|
|
181
686
|
line("", { fg: RIG_UI.ink4 }),
|
|
182
|
-
line(query.trim() ? `
|
|
687
|
+
line(`${query.trim() ? ` runs --search ${JSON.stringify(query)}` : " runs"}${updatedAgo ? ` \xB7 ${updatedAgo}` : ""}`, { fg: RIG_UI.ink3 })
|
|
183
688
|
],
|
|
184
689
|
panels: [{
|
|
185
690
|
id: "runs-list",
|
|
@@ -192,12 +697,16 @@ function renderFleetScene(state, layout) {
|
|
|
192
697
|
opacity: 1,
|
|
193
698
|
border: false,
|
|
194
699
|
chrome: "ad-terminal",
|
|
195
|
-
headerText: query.trim() ? `
|
|
700
|
+
headerText: query.trim() ? `runs --search ${JSON.stringify(query)}` : "runs",
|
|
196
701
|
headerHeight: 3,
|
|
197
702
|
paddingX: layout?.compact ? 2 : 3,
|
|
198
703
|
paddingY: 1
|
|
199
704
|
}],
|
|
200
|
-
footer: {
|
|
705
|
+
footer: {
|
|
706
|
+
run: selectedRun ? selectedRun.slice(0, 8) : "no runs",
|
|
707
|
+
message: searchSummary("runs", query, runs.length, allRuns.length),
|
|
708
|
+
...updatedAgo ? { updated: updatedAgo } : {}
|
|
709
|
+
},
|
|
201
710
|
typeBarPlaceholder: "search runs\u2026",
|
|
202
711
|
live: true
|
|
203
712
|
});
|