@matthesketh/fleet 1.1.0 → 1.6.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 +183 -251
- package/dist/adapters/detector/index.d.ts +8 -0
- package/dist/adapters/detector/index.js +54 -0
- package/dist/adapters/notifier/index.d.ts +2 -0
- package/dist/adapters/notifier/index.js +2 -0
- package/dist/adapters/notifier/stdout.d.ts +2 -0
- package/dist/adapters/notifier/stdout.js +8 -0
- package/dist/adapters/notifier/webhook.d.ts +9 -0
- package/dist/adapters/notifier/webhook.js +38 -0
- package/dist/adapters/runner/claude-cli.d.ts +7 -0
- package/dist/adapters/runner/claude-cli.js +231 -0
- package/dist/adapters/runner/mcp-call.d.ts +8 -0
- package/dist/adapters/runner/mcp-call.js +82 -0
- package/dist/adapters/runner/shell.d.ts +2 -0
- package/dist/adapters/runner/shell.js +103 -0
- package/dist/adapters/scheduler/systemd-timer.d.ts +17 -0
- package/dist/adapters/scheduler/systemd-timer.js +149 -0
- package/dist/adapters/signals/ci-status.d.ts +2 -0
- package/dist/adapters/signals/ci-status.js +79 -0
- package/dist/adapters/signals/container-up.d.ts +5 -0
- package/dist/adapters/signals/container-up.js +54 -0
- package/dist/adapters/signals/git-clean.d.ts +2 -0
- package/dist/adapters/signals/git-clean.js +55 -0
- package/dist/adapters/signals/index.d.ts +6 -0
- package/dist/adapters/signals/index.js +7 -0
- package/dist/adapters/types.d.ts +52 -0
- package/dist/adapters/types.js +1 -0
- package/dist/cli.js +43 -2
- package/dist/commands/add.js +0 -6
- package/dist/commands/boot-start.d.ts +1 -0
- package/dist/commands/boot-start.js +51 -0
- package/dist/commands/deploy.js +13 -0
- package/dist/commands/deps.js +5 -0
- package/dist/commands/egress.d.ts +1 -0
- package/dist/commands/egress.js +106 -0
- package/dist/commands/freeze.d.ts +4 -0
- package/dist/commands/freeze.js +64 -0
- package/dist/commands/logs.d.ts +1 -1
- package/dist/commands/logs.js +237 -8
- package/dist/commands/patch-systemd.d.ts +1 -0
- package/dist/commands/patch-systemd.js +126 -0
- package/dist/commands/rollback.d.ts +1 -0
- package/dist/commands/rollback.js +58 -0
- package/dist/commands/routine-run.d.ts +1 -0
- package/dist/commands/routine-run.js +122 -0
- package/dist/commands/routines.d.ts +1 -0
- package/dist/commands/routines.js +25 -0
- package/dist/commands/secrets.js +449 -16
- package/dist/commands/status.js +7 -3
- package/dist/commands/watchdog.d.ts +1 -1
- package/dist/commands/watchdog.js +16 -40
- package/dist/core/boot-refresh.d.ts +57 -0
- package/dist/core/boot-refresh.js +116 -0
- package/dist/core/deps/actors/pr-creator.js +11 -9
- package/dist/core/deps/collectors/docker-running.js +2 -2
- package/dist/core/deps/collectors/github-pr.js +5 -2
- package/dist/core/deps/collectors/npm.js +10 -5
- package/dist/core/deps/collectors/vulnerability.js +10 -6
- package/dist/core/deps/reporters/motd.js +1 -1
- package/dist/core/deps/reporters/telegram.js +2 -29
- package/dist/core/docker.js +45 -15
- package/dist/core/egress.d.ts +41 -0
- package/dist/core/egress.js +161 -0
- package/dist/core/exec.d.ts +7 -1
- package/dist/core/exec.js +25 -17
- package/dist/core/git.d.ts +1 -0
- package/dist/core/git.js +36 -23
- package/dist/core/github.js +27 -8
- package/dist/core/health.d.ts +3 -0
- package/dist/core/health.js +15 -3
- package/dist/core/logs-multi.d.ts +73 -0
- package/dist/core/logs-multi.js +163 -0
- package/dist/core/logs-policy.d.ts +55 -0
- package/dist/core/logs-policy.js +148 -0
- package/dist/core/nginx.js +8 -4
- package/dist/core/notify.d.ts +15 -0
- package/dist/core/notify.js +55 -0
- package/dist/core/registry.d.ts +25 -0
- package/dist/core/registry.js +57 -10
- package/dist/core/routines/cost-queries.d.ts +24 -0
- package/dist/core/routines/cost-queries.js +65 -0
- package/dist/core/routines/db.d.ts +9 -0
- package/dist/core/routines/db.js +126 -0
- package/dist/core/routines/defaults.d.ts +2 -0
- package/dist/core/routines/defaults.js +72 -0
- package/dist/core/routines/engine.d.ts +59 -0
- package/dist/core/routines/engine.js +175 -0
- package/dist/core/routines/incidents.d.ts +13 -0
- package/dist/core/routines/incidents.js +35 -0
- package/dist/core/routines/schema.d.ts +418 -0
- package/dist/core/routines/schema.js +113 -0
- package/dist/core/routines/signals-collector.d.ts +35 -0
- package/dist/core/routines/signals-collector.js +114 -0
- package/dist/core/routines/store.d.ts +316 -0
- package/dist/core/routines/store.js +99 -0
- package/dist/core/routines/test-utils.d.ts +2 -0
- package/dist/core/routines/test-utils.js +13 -0
- package/dist/core/secrets-audit.d.ts +21 -0
- package/dist/core/secrets-audit.js +60 -0
- package/dist/core/secrets-metadata.d.ts +39 -0
- package/dist/core/secrets-metadata.js +82 -0
- package/dist/core/secrets-motd.d.ts +20 -0
- package/dist/core/secrets-motd.js +72 -0
- package/dist/core/secrets-ops.d.ts +3 -1
- package/dist/core/secrets-ops.js +78 -13
- package/dist/core/secrets-providers.d.ts +50 -0
- package/dist/core/secrets-providers.js +291 -0
- package/dist/core/secrets-rotation.d.ts +52 -0
- package/dist/core/secrets-rotation.js +165 -0
- package/dist/core/secrets-snapshots.d.ts +26 -0
- package/dist/core/secrets-snapshots.js +95 -0
- package/dist/core/secrets-validate.js +2 -1
- package/dist/core/secrets.d.ts +12 -1
- package/dist/core/secrets.js +35 -24
- package/dist/core/self-update.d.ts +41 -0
- package/dist/core/self-update.js +73 -0
- package/dist/core/systemd.js +29 -12
- package/dist/core/telegram.d.ts +6 -0
- package/dist/core/telegram.js +32 -0
- package/dist/core/validate.d.ts +7 -0
- package/dist/core/validate.js +42 -0
- package/dist/index.js +0 -4
- package/dist/mcp/deps-tools.js +9 -1
- package/dist/mcp/git-tools.js +4 -4
- package/dist/mcp/server.js +193 -8
- package/dist/templates/systemd.js +3 -3
- package/dist/templates/unseal.js +5 -1
- package/dist/tui/components/Confirm.js +3 -4
- package/dist/tui/components/Header.js +37 -8
- package/dist/tui/components/KeyHint.js +14 -5
- package/dist/tui/exec-bridge.js +26 -12
- package/dist/tui/hooks/use-fleet-data.js +5 -2
- package/dist/tui/hooks/use-health.js +5 -2
- package/dist/tui/hooks/use-terminal-size.d.ts +1 -0
- package/dist/tui/hooks/use-terminal-size.js +1 -0
- package/dist/tui/router.js +133 -8
- package/dist/tui/routines/RoutinesApp.d.ts +8 -0
- package/dist/tui/routines/RoutinesApp.js +277 -0
- package/dist/tui/routines/components/AlertsPanel.d.ts +7 -0
- package/dist/tui/routines/components/AlertsPanel.js +22 -0
- package/dist/tui/routines/components/AlertsPanel.test.d.ts +1 -0
- package/dist/tui/routines/components/AlertsPanel.test.js +52 -0
- package/dist/tui/routines/components/CommandPalette.d.ts +12 -0
- package/dist/tui/routines/components/CommandPalette.js +21 -0
- package/dist/tui/routines/components/LiveRunPanel.d.ts +12 -0
- package/dist/tui/routines/components/LiveRunPanel.js +107 -0
- package/dist/tui/routines/components/RoutineForm.d.ts +8 -0
- package/dist/tui/routines/components/RoutineForm.js +254 -0
- package/dist/tui/routines/components/SignalsGrid.d.ts +13 -0
- package/dist/tui/routines/components/SignalsGrid.js +34 -0
- package/dist/tui/routines/components/SignalsGrid.test.d.ts +1 -0
- package/dist/tui/routines/components/SignalsGrid.test.js +43 -0
- package/dist/tui/routines/format.d.ts +7 -0
- package/dist/tui/routines/format.js +51 -0
- package/dist/tui/routines/hooks/use-git-fleet.d.ts +33 -0
- package/dist/tui/routines/hooks/use-git-fleet.js +82 -0
- package/dist/tui/routines/hooks/use-logs-stream.d.ts +13 -0
- package/dist/tui/routines/hooks/use-logs-stream.js +64 -0
- package/dist/tui/routines/hooks/use-ops-fleet.d.ts +20 -0
- package/dist/tui/routines/hooks/use-ops-fleet.js +70 -0
- package/dist/tui/routines/hooks/use-repo-detail.d.ts +31 -0
- package/dist/tui/routines/hooks/use-repo-detail.js +104 -0
- package/dist/tui/routines/hooks/use-security.d.ts +33 -0
- package/dist/tui/routines/hooks/use-security.js +110 -0
- package/dist/tui/routines/hooks/use-signals.d.ts +9 -0
- package/dist/tui/routines/hooks/use-signals.js +60 -0
- package/dist/tui/routines/runtime.d.ts +20 -0
- package/dist/tui/routines/runtime.js +40 -0
- package/dist/tui/routines/tabs/CostTab.d.ts +7 -0
- package/dist/tui/routines/tabs/CostTab.js +24 -0
- package/dist/tui/routines/tabs/DashboardTab.d.ts +15 -0
- package/dist/tui/routines/tabs/DashboardTab.js +10 -0
- package/dist/tui/routines/tabs/GitTab.d.ts +6 -0
- package/dist/tui/routines/tabs/GitTab.js +39 -0
- package/dist/tui/routines/tabs/LogsTab.d.ts +6 -0
- package/dist/tui/routines/tabs/LogsTab.js +58 -0
- package/dist/tui/routines/tabs/OpsTab.d.ts +6 -0
- package/dist/tui/routines/tabs/OpsTab.js +34 -0
- package/dist/tui/routines/tabs/RepoDetailView.d.ts +6 -0
- package/dist/tui/routines/tabs/RepoDetailView.js +12 -0
- package/dist/tui/routines/tabs/RoutinesTab.d.ts +10 -0
- package/dist/tui/routines/tabs/RoutinesTab.js +58 -0
- package/dist/tui/routines/tabs/ScaffoldTab.d.ts +2 -0
- package/dist/tui/routines/tabs/ScaffoldTab.js +127 -0
- package/dist/tui/routines/tabs/SecurityTab.d.ts +6 -0
- package/dist/tui/routines/tabs/SecurityTab.js +31 -0
- package/dist/tui/routines/tabs/SettingsTab.d.ts +6 -0
- package/dist/tui/routines/tabs/SettingsTab.js +61 -0
- package/dist/tui/routines/tabs/TimelineTab.d.ts +7 -0
- package/dist/tui/routines/tabs/TimelineTab.js +26 -0
- package/dist/tui/state.js +16 -1
- package/dist/tui/tests/flicker.test.d.ts +1 -0
- package/dist/tui/tests/flicker.test.js +105 -0
- package/dist/tui/tests/keyboard-integration.test.d.ts +1 -0
- package/dist/tui/tests/keyboard-integration.test.js +120 -0
- package/dist/tui/tests/test-app.d.ts +4 -0
- package/dist/tui/tests/test-app.js +79 -0
- package/dist/tui/types.d.ts +14 -1
- package/dist/tui/views/AppDetail.js +40 -26
- package/dist/tui/views/Dashboard.js +34 -9
- package/dist/tui/views/HealthView.js +42 -12
- package/dist/tui/views/LogsView.js +38 -10
- package/dist/tui/views/MultiLogsView.d.ts +2 -0
- package/dist/tui/views/MultiLogsView.js +165 -0
- package/dist/tui/views/SecretEdit.js +18 -7
- package/dist/tui/views/SecretsView.js +55 -39
- package/dist/ui/prompt.d.ts +52 -0
- package/dist/ui/prompt.js +169 -0
- package/package.json +33 -5
- package/dist/commands/motd.d.ts +0 -1
- package/dist/commands/motd.js +0 -10
- package/dist/templates/motd.d.ts +0 -1
- package/dist/templates/motd.js +0 -7
- package/dist/tui/components/AppList.d.ts +0 -12
- package/dist/tui/components/AppList.js +0 -32
- package/dist/tui/hooks/use-keyboard.d.ts +0 -1
- package/dist/tui/hooks/use-keyboard.js +0 -44
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { useState, useEffect, useCallback, useRef } from 'react';
|
|
2
|
+
import { useStableState } from '@matthesketh/ink-stable-state';
|
|
2
3
|
import { runFleetJson } from '../exec-bridge.js';
|
|
3
4
|
import { useInterval } from './use-interval.js';
|
|
4
5
|
export function useHealth(autoRefreshMs = 15_000) {
|
|
5
|
-
|
|
6
|
+
// useStableState short-circuits setState when the new payload is structurally
|
|
7
|
+
// equal to the previous one — no flicker on identical poll cycles.
|
|
8
|
+
const [results, setResults] = useStableState([]);
|
|
6
9
|
const [loading, setLoading] = useState(true);
|
|
7
10
|
const [error, setError] = useState(null);
|
|
8
11
|
const initialised = useRef(false);
|
|
@@ -20,7 +23,7 @@ export function useHealth(autoRefreshMs = 15_000) {
|
|
|
20
23
|
}
|
|
21
24
|
setLoading(false);
|
|
22
25
|
});
|
|
23
|
-
}, []);
|
|
26
|
+
}, [setResults]);
|
|
24
27
|
useEffect(() => {
|
|
25
28
|
refresh();
|
|
26
29
|
}, [refresh]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useTerminalSize, useAvailableHeight } from '@matthesketh/ink-viewport';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useTerminalSize, useAvailableHeight } from '@matthesketh/ink-viewport';
|
package/dist/tui/router.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import React, { useReducer, useState, useEffect } from 'react';
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import React, { useReducer, useState, useEffect, useCallback, useRef } from 'react';
|
|
3
3
|
import { Box, Text } from 'ink';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { InputDispatcher } from '@matthesketh/ink-input-dispatcher';
|
|
5
|
+
import { Viewport } from '@matthesketh/ink-viewport';
|
|
6
|
+
import { ToastProvider } from '@matthesketh/ink-toast';
|
|
7
|
+
import { ToastContainer } from '@matthesketh/ink-toast';
|
|
8
|
+
import { checkForUpdate, applyUpdate } from '../core/self-update.js';
|
|
9
|
+
import { KeyBindingHelp } from '@matthesketh/ink-keybinding-help';
|
|
10
|
+
import { reducer, initialState, AppStateContext, AppDispatchContext, nextTopView } from './state.js';
|
|
6
11
|
import { Header } from './components/Header.js';
|
|
7
12
|
import { KeyHint } from './components/KeyHint.js';
|
|
8
13
|
import { Confirm } from './components/Confirm.js';
|
|
@@ -13,6 +18,35 @@ import { SecretEdit } from './views/SecretEdit.js';
|
|
|
13
18
|
import { HealthView } from './views/HealthView.js';
|
|
14
19
|
import { LogsView } from './views/LogsView.js';
|
|
15
20
|
import { isSealed, isInitialized } from '../core/secrets.js';
|
|
21
|
+
const HELP_GROUPS = [
|
|
22
|
+
{
|
|
23
|
+
title: 'Navigation',
|
|
24
|
+
bindings: [
|
|
25
|
+
{ key: 'j/k', description: 'move up/down' },
|
|
26
|
+
{ key: 'Enter', description: 'select / confirm' },
|
|
27
|
+
{ key: 'Tab', description: 'switch view' },
|
|
28
|
+
{ key: 'Esc', description: 'go back' },
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
title: 'Actions',
|
|
33
|
+
bindings: [
|
|
34
|
+
{ key: 'x', description: 'toggle redaction' },
|
|
35
|
+
{ key: 'f', description: 'follow logs' },
|
|
36
|
+
{ key: 'q', description: 'quit' },
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
title: 'Secrets',
|
|
41
|
+
bindings: [
|
|
42
|
+
{ key: 'u', description: 'unseal vault' },
|
|
43
|
+
{ key: 'l', description: 'seal vault' },
|
|
44
|
+
{ key: 'a', description: 'add secret' },
|
|
45
|
+
{ key: 'd', description: 'delete secret' },
|
|
46
|
+
{ key: 'r', description: 'reveal / hide' },
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
];
|
|
16
50
|
function ViewRouter() {
|
|
17
51
|
const state = React.useContext(AppStateContext);
|
|
18
52
|
switch (state.currentView) {
|
|
@@ -32,13 +66,44 @@ function ViewRouter() {
|
|
|
32
66
|
return _jsx(Dashboard, {});
|
|
33
67
|
}
|
|
34
68
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
69
|
+
const CHROME_ROWS = 6;
|
|
70
|
+
function UpdateBanner({ info, inProgress }) {
|
|
71
|
+
if (!info?.available && !inProgress)
|
|
72
|
+
return null;
|
|
73
|
+
if (inProgress) {
|
|
74
|
+
return (_jsx(Box, { paddingX: 1, children: _jsx(Box, { borderStyle: "round", borderColor: "yellow", paddingX: 1, children: _jsx(Text, { color: "yellow", children: "Updating fleet\u2026 (git pull + npm run build)" }) }) }));
|
|
75
|
+
}
|
|
76
|
+
const ahead = info.behind;
|
|
77
|
+
const subject = info.latestSubject ? ` — ${info.latestSubject}` : '';
|
|
78
|
+
return (_jsx(Box, { paddingX: 1, children: _jsxs(Box, { borderStyle: "round", borderColor: "cyan", paddingX: 1, children: [_jsxs(Text, { color: "cyan", children: ["\u2191 Update available: ", ahead, " commit", ahead === 1 ? '' : 's', " ahead", subject, ". Press "] }), _jsx(Text, { color: "cyan", bold: true, children: "U" }), _jsx(Text, { color: "cyan", children: " to install." })] }) }));
|
|
38
79
|
}
|
|
39
80
|
export function App() {
|
|
40
81
|
const [state, dispatch] = useReducer(reducer, initialState);
|
|
41
82
|
const [vaultSealed, setVaultSealed] = useState(true);
|
|
83
|
+
const [showHelp, setShowHelp] = useState(false);
|
|
84
|
+
const [updateInfo, setUpdateInfo] = useState(null);
|
|
85
|
+
const [updateInProgress, setUpdateInProgress] = useState(false);
|
|
86
|
+
const confirmRef = useRef(state.confirmAction);
|
|
87
|
+
const updateInfoRef = useRef(null);
|
|
88
|
+
const updateInProgressRef = useRef(false);
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
confirmRef.current = state.confirmAction;
|
|
91
|
+
}, [state.confirmAction]);
|
|
92
|
+
useEffect(() => { updateInfoRef.current = updateInfo; }, [updateInfo]);
|
|
93
|
+
useEffect(() => { updateInProgressRef.current = updateInProgress; }, [updateInProgress]);
|
|
94
|
+
// One-shot update check on mount + a recheck every 30 minutes for long sessions.
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
let cancelled = false;
|
|
97
|
+
const run = () => {
|
|
98
|
+
checkForUpdate().then(info => {
|
|
99
|
+
if (!cancelled)
|
|
100
|
+
setUpdateInfo(info);
|
|
101
|
+
}).catch(() => { });
|
|
102
|
+
};
|
|
103
|
+
run();
|
|
104
|
+
const interval = setInterval(run, 30 * 60 * 1000);
|
|
105
|
+
return () => { cancelled = true; clearInterval(interval); };
|
|
106
|
+
}, []);
|
|
42
107
|
useEffect(() => {
|
|
43
108
|
try {
|
|
44
109
|
if (isInitialized()) {
|
|
@@ -61,5 +126,65 @@ export function App() {
|
|
|
61
126
|
}, 5000);
|
|
62
127
|
return () => clearInterval(interval);
|
|
63
128
|
}, []);
|
|
64
|
-
|
|
129
|
+
const globalHandler = useCallback((input, key) => {
|
|
130
|
+
if (showHelp) {
|
|
131
|
+
setShowHelp(false);
|
|
132
|
+
return true;
|
|
133
|
+
}
|
|
134
|
+
if (confirmRef.current) {
|
|
135
|
+
if (input === 'y' || input === 'Y') {
|
|
136
|
+
confirmRef.current.onConfirm();
|
|
137
|
+
dispatch({ type: 'CANCEL_CONFIRM' });
|
|
138
|
+
}
|
|
139
|
+
else if (input === 'n' || input === 'N' || key.escape) {
|
|
140
|
+
dispatch({ type: 'CANCEL_CONFIRM' });
|
|
141
|
+
}
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
if (input === '?' && state.currentView !== 'secret-edit') {
|
|
145
|
+
setShowHelp(true);
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
if (input === 'q' && state.currentView !== 'secret-edit') {
|
|
149
|
+
process.exit(0);
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
if (input === 'x' && state.currentView !== 'secret-edit') {
|
|
153
|
+
dispatch({ type: 'TOGGLE_REDACT' });
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
// U → apply pending update. Only fires when one is actually available.
|
|
157
|
+
if ((input === 'U' || input === 'u') && state.currentView !== 'secret-edit') {
|
|
158
|
+
const info = updateInfoRef.current;
|
|
159
|
+
if (info?.available && !updateInProgressRef.current) {
|
|
160
|
+
setUpdateInProgress(true);
|
|
161
|
+
applyUpdate().then(result => {
|
|
162
|
+
setUpdateInProgress(false);
|
|
163
|
+
if (result.ok) {
|
|
164
|
+
setUpdateInfo({ available: false, behind: 0, latestSubject: '', branch: info.branch });
|
|
165
|
+
}
|
|
166
|
+
// Result reported via UpdateBanner below.
|
|
167
|
+
App.__lastUpdateOutput = result.output;
|
|
168
|
+
}).catch(err => {
|
|
169
|
+
setUpdateInProgress(false);
|
|
170
|
+
App.__lastUpdateOutput = err instanceof Error ? err.message : String(err);
|
|
171
|
+
});
|
|
172
|
+
return true;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (key.tab) {
|
|
176
|
+
const topViews = ['dashboard', 'health', 'secrets', 'logs-multi'];
|
|
177
|
+
const base = topViews.includes(state.currentView)
|
|
178
|
+
? state.currentView
|
|
179
|
+
: state.previousView ?? 'dashboard';
|
|
180
|
+
dispatch({ type: 'NAVIGATE', view: nextTopView(base) });
|
|
181
|
+
return true;
|
|
182
|
+
}
|
|
183
|
+
if (key.escape && state.previousView) {
|
|
184
|
+
dispatch({ type: 'GO_BACK' });
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
return false;
|
|
188
|
+
}, [state.currentView, state.previousView, showHelp]);
|
|
189
|
+
return (_jsx(AppStateContext.Provider, { value: state, children: _jsx(AppDispatchContext.Provider, { value: dispatch, children: _jsx(ToastProvider, { children: _jsx(InputDispatcher, { globalHandler: globalHandler, children: _jsxs(Viewport, { chrome: CHROME_ROWS, children: [_jsx(Header, { vaultSealed: vaultSealed }), _jsx(UpdateBanner, { info: updateInfo, inProgress: updateInProgress }), _jsx(Box, { flexGrow: 1, flexDirection: "column", children: showHelp ? (_jsx(KeyBindingHelp, { groups: HELP_GROUPS, title: "Fleet TUI \u2014 Keyboard Shortcuts" })) : (_jsxs(_Fragment, { children: [_jsx(ViewRouter, {}), _jsx(Confirm, {}), state.error && (_jsx(Box, { paddingX: 1, children: _jsx(Box, { borderStyle: "round", borderColor: "red", paddingX: 1, children: _jsx(Text, { color: "red", children: state.error }) }) }))] })) }), _jsx(ToastContainer, {}), _jsx(KeyHint, {})] }) }) }) }) }));
|
|
65
190
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Registry } from '../../core/registry.js';
|
|
3
|
+
import type { RoutinesRuntime } from './runtime.js';
|
|
4
|
+
export interface RoutinesAppProps {
|
|
5
|
+
runtime: RoutinesRuntime;
|
|
6
|
+
registry: Registry;
|
|
7
|
+
}
|
|
8
|
+
export declare function RoutinesApp({ runtime, registry }: RoutinesAppProps): React.JSX.Element;
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo, useState } from 'react';
|
|
3
|
+
import { Box, Text } from 'ink';
|
|
4
|
+
import { Tabs } from '@matthesketh/ink-tabs';
|
|
5
|
+
import { useRegisterHandler } from '@matthesketh/ink-input-dispatcher';
|
|
6
|
+
import { CostTab } from './tabs/CostTab.js';
|
|
7
|
+
import { DashboardTab } from './tabs/DashboardTab.js';
|
|
8
|
+
import { GitTab } from './tabs/GitTab.js';
|
|
9
|
+
import { LogsTab } from './tabs/LogsTab.js';
|
|
10
|
+
import { OpsTab } from './tabs/OpsTab.js';
|
|
11
|
+
import { RepoDetailView } from './tabs/RepoDetailView.js';
|
|
12
|
+
import { RoutinesTab } from './tabs/RoutinesTab.js';
|
|
13
|
+
import { ScaffoldTab } from './tabs/ScaffoldTab.js';
|
|
14
|
+
import { SecurityTab } from './tabs/SecurityTab.js';
|
|
15
|
+
import { SettingsTab } from './tabs/SettingsTab.js';
|
|
16
|
+
import { TimelineTab } from './tabs/TimelineTab.js';
|
|
17
|
+
import { RoutineForm } from './components/RoutineForm.js';
|
|
18
|
+
import { CommandPalette } from './components/CommandPalette.js';
|
|
19
|
+
import { LiveRunPanel } from './components/LiveRunPanel.js';
|
|
20
|
+
import { useSignals } from './hooks/use-signals.js';
|
|
21
|
+
function targetsForRegistry(apps) {
|
|
22
|
+
return apps.map(a => ({
|
|
23
|
+
repoName: a.name,
|
|
24
|
+
repoPath: typeof a.composePath === 'string' && a.composePath ? a.composePath : '',
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
export function RoutinesApp({ runtime, registry }) {
|
|
28
|
+
const [activeTab, setActiveTab] = useState('dashboard');
|
|
29
|
+
const [dashboardIndex, setDashboardIndex] = useState(0);
|
|
30
|
+
const [routinesIndex, setRoutinesIndex] = useState(0);
|
|
31
|
+
const [routinesDetail, setRoutinesDetail] = useState(false);
|
|
32
|
+
const [focusedRepo, setFocusedRepo] = useState(null);
|
|
33
|
+
const [modal, setModal] = useState(null);
|
|
34
|
+
const [routinesVersion, setRoutinesVersion] = useState(0);
|
|
35
|
+
const targets = useMemo(() => targetsForRegistry(registry.apps), [registry]);
|
|
36
|
+
const { snapshot, loading, lastRefreshed, refresh } = useSignals(runtime.collector, targets, 30_000);
|
|
37
|
+
const routines = useMemo(() => {
|
|
38
|
+
void routinesVersion;
|
|
39
|
+
runtime.store.reload();
|
|
40
|
+
return runtime.store.list();
|
|
41
|
+
}, [runtime.store, routinesVersion]);
|
|
42
|
+
const dashboardRows = useMemo(() => targets.map(t => ({ repo: t.repoName, signals: snapshot.get(t.repoName) ?? [] })), [targets, snapshot]);
|
|
43
|
+
const bump = () => setRoutinesVersion(v => v + 1);
|
|
44
|
+
const handleFormSubmit = async (routine) => {
|
|
45
|
+
await runtime.engine.register(routine);
|
|
46
|
+
setModal(null);
|
|
47
|
+
bump();
|
|
48
|
+
};
|
|
49
|
+
const handleDelete = async (id) => {
|
|
50
|
+
await runtime.engine.unregister(id);
|
|
51
|
+
setModal(null);
|
|
52
|
+
setRoutinesIndex(i => Math.max(0, Math.min(i, routines.length - 2)));
|
|
53
|
+
bump();
|
|
54
|
+
};
|
|
55
|
+
const paletteActions = useMemo(() => {
|
|
56
|
+
const items = [
|
|
57
|
+
{ id: 'nav:dashboard', group: 'nav', label: 'go to Dashboard' },
|
|
58
|
+
{ id: 'nav:routines', group: 'nav', label: 'go to Routines' },
|
|
59
|
+
{ id: 'action:refresh', group: 'action', label: 'refresh signals now' },
|
|
60
|
+
{ id: 'action:new', group: 'action', label: 'new routine…' },
|
|
61
|
+
];
|
|
62
|
+
for (const r of routines) {
|
|
63
|
+
items.push({ id: `routine:run:${r.id}`, group: 'routine', label: `run "${r.id}" now` });
|
|
64
|
+
items.push({ id: `routine:edit:${r.id}`, group: 'routine', label: `edit "${r.id}"` });
|
|
65
|
+
items.push({
|
|
66
|
+
id: `routine:toggle:${r.id}`,
|
|
67
|
+
group: 'routine',
|
|
68
|
+
label: r.enabled ? `disable "${r.id}"` : `enable "${r.id}"`,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
for (const app of registry.apps) {
|
|
72
|
+
items.push({ id: `repo:${app.name}`, group: 'repo', label: `focus repo "${app.name}"` });
|
|
73
|
+
}
|
|
74
|
+
return items;
|
|
75
|
+
}, [routines, registry]);
|
|
76
|
+
const handlePalette = async (action) => {
|
|
77
|
+
setModal(null);
|
|
78
|
+
if (action.id === 'nav:dashboard') {
|
|
79
|
+
setActiveTab('dashboard');
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (action.id === 'nav:routines') {
|
|
83
|
+
setActiveTab('routines');
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (action.id === 'action:refresh') {
|
|
87
|
+
await refresh(true);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (action.id === 'action:new') {
|
|
91
|
+
setModal({ kind: 'form' });
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (action.id.startsWith('routine:run:')) {
|
|
95
|
+
const id = action.id.slice('routine:run:'.length);
|
|
96
|
+
setActiveTab('routines');
|
|
97
|
+
setModal({ kind: 'live-run', routineId: id });
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (action.id.startsWith('routine:edit:')) {
|
|
101
|
+
const id = action.id.slice('routine:edit:'.length);
|
|
102
|
+
const r = runtime.store.get(id);
|
|
103
|
+
if (r)
|
|
104
|
+
setModal({ kind: 'form', initial: r });
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (action.id.startsWith('routine:toggle:')) {
|
|
108
|
+
const id = action.id.slice('routine:toggle:'.length);
|
|
109
|
+
const r = runtime.store.get(id);
|
|
110
|
+
if (r)
|
|
111
|
+
await runtime.engine.register({ ...r, enabled: !r.enabled });
|
|
112
|
+
bump();
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (action.id.startsWith('repo:')) {
|
|
116
|
+
const repo = action.id.slice('repo:'.length);
|
|
117
|
+
setFocusedRepo(repo);
|
|
118
|
+
setActiveTab('repo-detail');
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
useRegisterHandler((input, key) => {
|
|
122
|
+
if (modal?.kind === 'palette')
|
|
123
|
+
return false;
|
|
124
|
+
if (modal)
|
|
125
|
+
return false;
|
|
126
|
+
if (input === 'p' || (key.ctrl && input === 'k')) {
|
|
127
|
+
setModal({ kind: 'palette' });
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
if (input === '1') {
|
|
131
|
+
setActiveTab('dashboard');
|
|
132
|
+
return true;
|
|
133
|
+
}
|
|
134
|
+
if (input === '2') {
|
|
135
|
+
setActiveTab('routines');
|
|
136
|
+
setRoutinesDetail(false);
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
if (input === '3') {
|
|
140
|
+
setActiveTab('git');
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
if (input === '4') {
|
|
144
|
+
setActiveTab('ops');
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
if (input === '5') {
|
|
148
|
+
setActiveTab('security');
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
if (input === '6') {
|
|
152
|
+
setActiveTab('logs');
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
if (input === '7') {
|
|
156
|
+
setActiveTab('cost');
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
if (input === '8') {
|
|
160
|
+
setActiveTab('timeline');
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
if (input === '9') {
|
|
164
|
+
setActiveTab('scaffold');
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
if (input === '0') {
|
|
168
|
+
setActiveTab('settings');
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
if (activeTab === 'repo-detail') {
|
|
172
|
+
if (key.escape) {
|
|
173
|
+
setActiveTab('dashboard');
|
|
174
|
+
setFocusedRepo(null);
|
|
175
|
+
return true;
|
|
176
|
+
}
|
|
177
|
+
if (input === 'a') {
|
|
178
|
+
const nightly = runtime.store.get('nightly-audit');
|
|
179
|
+
if (nightly)
|
|
180
|
+
setModal({ kind: 'live-run', routineId: nightly.id });
|
|
181
|
+
return true;
|
|
182
|
+
}
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
if (activeTab === 'dashboard') {
|
|
186
|
+
if (input === 'j' || key.downArrow) {
|
|
187
|
+
setDashboardIndex(i => Math.min(i + 1, Math.max(dashboardRows.length - 1, 0)));
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
190
|
+
if (input === 'k' || key.upArrow) {
|
|
191
|
+
setDashboardIndex(i => Math.max(i - 1, 0));
|
|
192
|
+
return true;
|
|
193
|
+
}
|
|
194
|
+
if (input === 'r') {
|
|
195
|
+
void refresh(true);
|
|
196
|
+
return true;
|
|
197
|
+
}
|
|
198
|
+
if (key.return && dashboardRows[dashboardIndex]) {
|
|
199
|
+
setFocusedRepo(dashboardRows[dashboardIndex].repo);
|
|
200
|
+
setActiveTab('repo-detail');
|
|
201
|
+
return true;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (activeTab === 'routines') {
|
|
205
|
+
if (input === 'j' || key.downArrow) {
|
|
206
|
+
setRoutinesIndex(i => Math.min(i + 1, Math.max(routines.length - 1, 0)));
|
|
207
|
+
return true;
|
|
208
|
+
}
|
|
209
|
+
if (input === 'k' || key.upArrow) {
|
|
210
|
+
setRoutinesIndex(i => Math.max(i - 1, 0));
|
|
211
|
+
return true;
|
|
212
|
+
}
|
|
213
|
+
if (key.return) {
|
|
214
|
+
setRoutinesDetail(o => !o);
|
|
215
|
+
return true;
|
|
216
|
+
}
|
|
217
|
+
if (key.escape) {
|
|
218
|
+
setRoutinesDetail(false);
|
|
219
|
+
return true;
|
|
220
|
+
}
|
|
221
|
+
const selected = routines[routinesIndex];
|
|
222
|
+
if (input === 'n') {
|
|
223
|
+
setModal({ kind: 'form' });
|
|
224
|
+
return true;
|
|
225
|
+
}
|
|
226
|
+
if (input === 'e' && selected) {
|
|
227
|
+
setModal({ kind: 'form', initial: selected });
|
|
228
|
+
return true;
|
|
229
|
+
}
|
|
230
|
+
if (input === 'd' && selected) {
|
|
231
|
+
setModal({ kind: 'delete', id: selected.id });
|
|
232
|
+
return true;
|
|
233
|
+
}
|
|
234
|
+
if (input === 't' && selected) {
|
|
235
|
+
void runtime.engine.register({ ...selected, enabled: !selected.enabled }).then(bump);
|
|
236
|
+
return true;
|
|
237
|
+
}
|
|
238
|
+
if (input === 'r' && selected) {
|
|
239
|
+
setModal({ kind: 'live-run', routineId: selected.id });
|
|
240
|
+
return true;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return false;
|
|
244
|
+
});
|
|
245
|
+
return (_jsxs(Box, { flexDirection: "column", paddingX: 1, children: [_jsx(Tabs, { tabs: [
|
|
246
|
+
{ id: 'dashboard', label: '1 Dashboard', badge: dashboardRows.length },
|
|
247
|
+
{ id: 'routines', label: '2 Routines', badge: routines.length },
|
|
248
|
+
{ id: 'git', label: '3 Git' },
|
|
249
|
+
{ id: 'ops', label: '4 Ops' },
|
|
250
|
+
{ id: 'security', label: '5 Security' },
|
|
251
|
+
{ id: 'logs', label: '6 Logs' },
|
|
252
|
+
{ id: 'cost', label: '7 Cost' },
|
|
253
|
+
{ id: 'timeline', label: '8 Timeline' },
|
|
254
|
+
{ id: 'scaffold', label: '9 Scaffold' },
|
|
255
|
+
{ id: 'settings', label: '0 Settings' },
|
|
256
|
+
...(activeTab === 'repo-detail' ? [{ id: 'repo-detail', label: `◆ ${focusedRepo ?? ''}` }] : []),
|
|
257
|
+
], activeId: activeTab, accentColor: "cyan" }), activeTab === 'dashboard' && (_jsx(DashboardTab, { rows: dashboardRows, selectedIndex: dashboardIndex, loading: loading, lastRefreshed: lastRefreshed, signalsByRepo: snapshot, seededNotice: runtime.seeded })), activeTab === 'routines' && (_jsx(RoutinesTab, { engine: runtime.engine, routines: routines, selectedIndex: routinesIndex, detailOpen: routinesDetail })), activeTab === 'git' && _jsx(GitTab, { apps: registry.apps }), activeTab === 'ops' && _jsx(OpsTab, { apps: registry.apps }), activeTab === 'security' && _jsx(SecurityTab, { apps: registry.apps }), activeTab === 'logs' && _jsx(LogsTab, { apps: registry.apps }), activeTab === 'cost' && _jsx(CostTab, { engine: runtime.engine }), activeTab === 'timeline' && _jsx(TimelineTab, { engine: runtime.engine }), activeTab === 'scaffold' && _jsx(ScaffoldTab, {}), activeTab === 'settings' && _jsx(SettingsTab, { runtime: runtime }), activeTab === 'repo-detail' && focusedRepo && (() => {
|
|
258
|
+
const app = registry.apps.find(a => a.name === focusedRepo);
|
|
259
|
+
return app
|
|
260
|
+
? _jsx(RepoDetailView, { app: app })
|
|
261
|
+
: _jsxs(Text, { color: "red", children: ["repo not found: ", focusedRepo] });
|
|
262
|
+
})(), _jsx(Box, { marginTop: 1, children: _jsx(Text, { color: "gray", children: "1-8 tabs \u00B7 9 scaffold \u00B7 0 settings \u00B7 p palette \u00B7 j/k \u00B7 enter drill \u00B7 n/e/d/t routines \u00B7 r run \u00B7 Esc back \u00B7 q quit" }) }), modal?.kind === 'form' && (_jsx(RoutineForm, { initial: modal.initial, onSubmit: (r) => { void handleFormSubmit(r); }, onCancel: () => setModal(null) })), modal?.kind === 'delete' && (_jsx(ConfirmDelete, { id: modal.id, onConfirm: () => { void handleDelete(modal.id); }, onCancel: () => setModal(null) })), modal?.kind === 'palette' && (_jsx(CommandPalette, { actions: paletteActions, onSelect: (action) => { void handlePalette(action); }, onCancel: () => setModal(null) })), modal?.kind === 'live-run' && (_jsx(LiveRunPanel, { engine: runtime.engine, routineId: modal.routineId, onClose: () => { setModal(null); bump(); } }))] }));
|
|
263
|
+
}
|
|
264
|
+
function ConfirmDelete({ id, onConfirm, onCancel }) {
|
|
265
|
+
useRegisterHandler((input, key) => {
|
|
266
|
+
if (input === 'y' || input === 'Y') {
|
|
267
|
+
onConfirm();
|
|
268
|
+
return true;
|
|
269
|
+
}
|
|
270
|
+
if (input === 'n' || input === 'N' || key.escape) {
|
|
271
|
+
onCancel();
|
|
272
|
+
return true;
|
|
273
|
+
}
|
|
274
|
+
return false;
|
|
275
|
+
});
|
|
276
|
+
return (_jsx(Box, { borderStyle: "round", borderColor: "red", paddingX: 1, marginTop: 1, children: _jsxs(Text, { children: ["Delete routine ", _jsx(Text, { bold: true, color: "cyan", children: id }), "? ", _jsx(Text, { color: "green", children: "y" }), " confirm ", _jsx(Text, { color: "red", children: "n" }), " cancel"] }) }));
|
|
277
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Signal } from '../../../core/routines/schema.js';
|
|
3
|
+
export interface AlertsPanelProps {
|
|
4
|
+
signals: Map<string, Signal[]>;
|
|
5
|
+
maxRows?: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function AlertsPanel({ signals, maxRows }: AlertsPanelProps): React.JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Text } from 'ink';
|
|
3
|
+
import { signalStateColor, truncate } from '../format.js';
|
|
4
|
+
export function AlertsPanel({ signals, maxRows = 8 }) {
|
|
5
|
+
const alerts = [];
|
|
6
|
+
for (const [repo, list] of signals) {
|
|
7
|
+
for (const sig of list) {
|
|
8
|
+
if (sig.state === 'error' || sig.state === 'warn') {
|
|
9
|
+
alerts.push({ repo, signal: sig });
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
alerts.sort((a, b) => {
|
|
14
|
+
const order = (s) => (s.state === 'error' ? 0 : 1);
|
|
15
|
+
const diff = order(a.signal) - order(b.signal);
|
|
16
|
+
if (diff !== 0)
|
|
17
|
+
return diff;
|
|
18
|
+
return a.repo.localeCompare(b.repo);
|
|
19
|
+
});
|
|
20
|
+
const rows = alerts.slice(0, maxRows);
|
|
21
|
+
return (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: "gray", paddingX: 1, children: [_jsxs(Text, { bold: true, children: ["Alerts (", alerts.length, ")"] }), rows.length === 0 && _jsx(Text, { color: "green", children: " all clear" }), rows.map((a, i) => (_jsxs(Box, { children: [_jsx(Text, { color: signalStateColor[a.signal.state], children: "\u25CF " }), _jsx(Box, { width: 20, children: _jsx(Text, { children: truncate(a.repo, 18) }) }), _jsx(Box, { width: 14, children: _jsx(Text, { color: "gray", children: a.signal.kind }) }), _jsx(Text, { children: truncate(a.signal.detail || String(a.signal.value ?? ''), 50) })] }, `${a.repo}-${a.signal.kind}-${i}`))), alerts.length > maxRows && (_jsxs(Text, { color: "gray", children: [" +", alerts.length - maxRows, " more\u2026"] }))] }));
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { render } from 'ink-testing-library';
|
|
3
|
+
import { describe, it, expect } from 'vitest';
|
|
4
|
+
import { AlertsPanel } from './AlertsPanel.js';
|
|
5
|
+
const mk = (repo, kind, state, detail) => ({
|
|
6
|
+
repo, kind, state, value: null, detail,
|
|
7
|
+
collectedAt: new Date().toISOString(), ttlMs: 10_000,
|
|
8
|
+
});
|
|
9
|
+
describe('AlertsPanel', () => {
|
|
10
|
+
it('shows "all clear" when no warn/error signals present', () => {
|
|
11
|
+
const map = new Map([
|
|
12
|
+
['a', [mk('a', 'git-clean', 'ok', '')]],
|
|
13
|
+
]);
|
|
14
|
+
const { lastFrame } = render(_jsx(AlertsPanel, { signals: map }));
|
|
15
|
+
expect(lastFrame()).toContain('all clear');
|
|
16
|
+
});
|
|
17
|
+
it('lists error signals with their detail', () => {
|
|
18
|
+
const map = new Map([
|
|
19
|
+
['my-app', [mk('my-app', 'container-up', 'error', 'all containers down')]],
|
|
20
|
+
]);
|
|
21
|
+
const { lastFrame } = render(_jsx(AlertsPanel, { signals: map }));
|
|
22
|
+
const frame = lastFrame();
|
|
23
|
+
expect(frame).toContain('my-app');
|
|
24
|
+
expect(frame).toContain('container-up');
|
|
25
|
+
expect(frame).toContain('all containers down');
|
|
26
|
+
});
|
|
27
|
+
it('orders errors before warns', () => {
|
|
28
|
+
const map = new Map([
|
|
29
|
+
['warn-repo', [mk('warn-repo', 'git-clean', 'warn', '3 changes')]],
|
|
30
|
+
['err-repo', [mk('err-repo', 'ci-status', 'error', 'build failed')]],
|
|
31
|
+
]);
|
|
32
|
+
const { lastFrame } = render(_jsx(AlertsPanel, { signals: map }));
|
|
33
|
+
const frame = lastFrame();
|
|
34
|
+
const errIdx = frame.indexOf('err-repo');
|
|
35
|
+
const warnIdx = frame.indexOf('warn-repo');
|
|
36
|
+
expect(errIdx).toBeGreaterThan(-1);
|
|
37
|
+
expect(warnIdx).toBeGreaterThan(-1);
|
|
38
|
+
expect(errIdx).toBeLessThan(warnIdx);
|
|
39
|
+
});
|
|
40
|
+
it('truncates the alert count header', () => {
|
|
41
|
+
const signals = [];
|
|
42
|
+
for (let i = 0; i < 20; i++)
|
|
43
|
+
signals.push(mk(`r${i}`, 'git-clean', 'error', `issue ${i}`));
|
|
44
|
+
const map = new Map();
|
|
45
|
+
for (const s of signals)
|
|
46
|
+
map.set(s.repo, [s]);
|
|
47
|
+
const { lastFrame } = render(_jsx(AlertsPanel, { signals: map, maxRows: 5 }));
|
|
48
|
+
const frame = lastFrame();
|
|
49
|
+
expect(frame).toContain('Alerts (20)');
|
|
50
|
+
expect(frame).toContain('+15 more');
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface PaletteAction {
|
|
3
|
+
id: string;
|
|
4
|
+
label: string;
|
|
5
|
+
group: 'nav' | 'routine' | 'repo' | 'action';
|
|
6
|
+
}
|
|
7
|
+
export interface CommandPaletteProps {
|
|
8
|
+
actions: PaletteAction[];
|
|
9
|
+
onSelect(action: PaletteAction): void;
|
|
10
|
+
onCancel(): void;
|
|
11
|
+
}
|
|
12
|
+
export declare function CommandPalette({ actions, onSelect, onCancel }: CommandPaletteProps): React.JSX.Element;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Text } from 'ink';
|
|
3
|
+
import { FuzzySelect } from '@matthesketh/ink-fuzzy-select';
|
|
4
|
+
const GROUP_COLOR = {
|
|
5
|
+
nav: 'cyan',
|
|
6
|
+
routine: 'magenta',
|
|
7
|
+
repo: 'yellow',
|
|
8
|
+
action: 'green',
|
|
9
|
+
};
|
|
10
|
+
export function CommandPalette({ actions, onSelect, onCancel }) {
|
|
11
|
+
const items = actions.map(a => ({ label: a.label, value: a.id }));
|
|
12
|
+
return (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: "cyan", paddingX: 1, children: [_jsx(Text, { bold: true, color: "cyan", children: "\u2318 command palette" }), _jsx(FuzzySelect, { items: items, onSelect: (item) => {
|
|
13
|
+
const found = actions.find(a => a.id === item.value);
|
|
14
|
+
if (found)
|
|
15
|
+
onSelect(found);
|
|
16
|
+
}, onCancel: onCancel, placeholder: "type to search commands\u2026", maxVisible: 10, renderItem: (item, selected) => {
|
|
17
|
+
const full = actions.find(a => a.id === item.value);
|
|
18
|
+
const color = full ? GROUP_COLOR[full.group] : 'gray';
|
|
19
|
+
return (_jsxs(Box, { children: [_jsx(Box, { width: 2, children: _jsx(Text, { color: selected ? 'cyan' : undefined, children: selected ? '▶' : ' ' }) }), _jsx(Box, { width: 10, children: _jsxs(Text, { color: color, children: ["[", full?.group ?? '?', "]"] }) }), _jsx(Text, { color: selected ? 'cyan' : undefined, children: item.label })] }));
|
|
20
|
+
} }), _jsx(Text, { color: "gray", children: "Enter select \u00B7 Esc cancel" })] }));
|
|
21
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { RoutineEngine } from '../../../core/routines/engine.js';
|
|
3
|
+
export interface LiveRunPanelProps {
|
|
4
|
+
engine: RoutineEngine;
|
|
5
|
+
routineId: string;
|
|
6
|
+
target?: {
|
|
7
|
+
repo: string | null;
|
|
8
|
+
repoPath: string | null;
|
|
9
|
+
};
|
|
10
|
+
onClose(): void;
|
|
11
|
+
}
|
|
12
|
+
export declare function LiveRunPanel({ engine, routineId, target, onClose }: LiveRunPanelProps): React.JSX.Element;
|