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