@higherdev/cli 0.4.0 → 0.5.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 +14 -5
- package/dist/api.js +31 -22
- package/dist/config.js +62 -8
- package/dist/index.js +15 -1
- package/dist/out/format.js +96 -0
- package/dist/out/theme.js +73 -0
- package/dist/tui/App.js +418 -0
- package/dist/tui/Banner.js +301 -0
- package/dist/tui/Bubble.js +12 -0
- package/dist/tui/Dashboard.js +206 -0
- package/dist/tui/Decision.js +48 -0
- package/dist/tui/Help.js +30 -0
- package/dist/tui/Panels.js +195 -0
- package/dist/tui/Settings.js +45 -0
- package/dist/tui/Splash.js +15 -0
- package/dist/tui/TextInput.js +137 -0
- package/dist/tui/alert.js +19 -0
- package/dist/tui/bounded.js +37 -0
- package/dist/tui/capability.js +4 -0
- package/dist/tui/data.js +165 -0
- package/dist/tui/height.js +58 -0
- package/dist/tui/launch.js +20 -0
- package/dist/tui/layout.js +54 -0
- package/dist/tui/parse.js +48 -0
- package/dist/tui/settings-model.js +76 -0
- package/dist/tui/stream.js +122 -0
- package/dist/tui/theme.js +52 -0
- package/dist/tui/workspace-load.js +18 -0
- package/package.json +6 -1
package/dist/tui/App.js
ADDED
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { Box, Static, Text, useApp, useInput, useStdout } from "ink";
|
|
4
|
+
import { Banner } from "./Banner.js";
|
|
5
|
+
import { Bubble } from "./Bubble.js";
|
|
6
|
+
import { Cockpit, StreamPanel, boardTicketIds, nextCursor } from "./Dashboard.js";
|
|
7
|
+
import { DecisionPanel, decisionRows } from "./Decision.js";
|
|
8
|
+
import { COMMANDS, Help } from "./Help.js";
|
|
9
|
+
import { AgentsPanel, BoardPanel, FeedPanel, InboxPanel, TicketPanel } from "./Panels.js";
|
|
10
|
+
import { SettingsPanel } from "./Settings.js";
|
|
11
|
+
import { Splash } from "./Splash.js";
|
|
12
|
+
import TextInput from "./TextInput.js";
|
|
13
|
+
import { alertOnce } from "./alert.js";
|
|
14
|
+
import { bubbleRows } from "./height.js";
|
|
15
|
+
import { planLayout, splitPanels } from "./layout.js";
|
|
16
|
+
import { parseLine } from "./parse.js";
|
|
17
|
+
import { configuredSlugs, decisionOptions, loadLiveEvents, loadTicketDetail, pollSnapshot, postOrchestrator, resolveDecision, switchWorkspace, updateAgent, updateProviderCap, } from "./data.js";
|
|
18
|
+
import { editFor, editableKeys, nextValue, seedFor, settingsRows } from "./settings-model.js";
|
|
19
|
+
import { appendLines, runLabels, toStreamLines } from "./stream.js";
|
|
20
|
+
import { UI } from "./theme.js";
|
|
21
|
+
import { WorkspaceLoads } from "./workspace-load.js";
|
|
22
|
+
let messageSeq = 0;
|
|
23
|
+
const nextId = () => `m${messageSeq++}`;
|
|
24
|
+
export function App({ initial }) {
|
|
25
|
+
const { exit } = useApp();
|
|
26
|
+
const { stdout } = useStdout();
|
|
27
|
+
const columns = stdout?.columns && stdout.columns > 0 ? stdout.columns : 80;
|
|
28
|
+
const rows = stdout?.rows && stdout.rows > 0 ? stdout.rows : 24;
|
|
29
|
+
const width = Math.max(48, Math.min(columns - 1, 120));
|
|
30
|
+
const [config, setConfig] = useState(initial.config);
|
|
31
|
+
const [workspace, setWorkspace] = useState(initial.workspace);
|
|
32
|
+
const [board, setBoard] = useState(initial.board);
|
|
33
|
+
const [feed, setFeed] = useState(initial.feed);
|
|
34
|
+
const [mode, setMode] = useState("browse");
|
|
35
|
+
const [view, setView] = useState("home");
|
|
36
|
+
const [live, setLive] = useState("connecting");
|
|
37
|
+
const [messages, setMessages] = useState([]);
|
|
38
|
+
const [draft, setDraft] = useState("");
|
|
39
|
+
const [busy, setBusy] = useState(false);
|
|
40
|
+
const [notice, setNotice] = useState(null);
|
|
41
|
+
const [ticketKey, setTicketKey] = useState(null);
|
|
42
|
+
const [ready, setReady] = useState(false);
|
|
43
|
+
const [stream, setStream] = useState([]);
|
|
44
|
+
const [cursor, setCursor] = useState(null);
|
|
45
|
+
const [started, setStarted] = useState(false);
|
|
46
|
+
const [field, setField] = useState(null);
|
|
47
|
+
const [editing, setEditing] = useState(null);
|
|
48
|
+
const selectedRef = useRef(null);
|
|
49
|
+
const fieldRef = useRef(null);
|
|
50
|
+
const editingRef = useRef(null);
|
|
51
|
+
const history = useRef([]);
|
|
52
|
+
const historyAt = useRef(-1);
|
|
53
|
+
const refreshRef = useRef(null);
|
|
54
|
+
const loads = useRef(new WorkspaceLoads(initial.workspace.id));
|
|
55
|
+
editingRef.current = editing;
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (messages.length > 0 || view !== "home")
|
|
58
|
+
setStarted(true);
|
|
59
|
+
}, [messages.length, view]);
|
|
60
|
+
const applySnapshot = useCallback((snapshot) => {
|
|
61
|
+
const token = loads.current.start(snapshot.workspace.id);
|
|
62
|
+
if (!loads.current.isCurrent(token))
|
|
63
|
+
return;
|
|
64
|
+
setWorkspace(snapshot.workspace);
|
|
65
|
+
setBoard(snapshot.board);
|
|
66
|
+
setFeed(snapshot.feed);
|
|
67
|
+
}, []);
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
setLive("connecting");
|
|
70
|
+
const polling = pollSnapshot(config, applySnapshot, setLive, (error) => setNotice(error instanceof Error ? error.message : String(error)));
|
|
71
|
+
refreshRef.current = polling.refresh;
|
|
72
|
+
return polling.close;
|
|
73
|
+
}, [config, applySnapshot]);
|
|
74
|
+
const labels = useMemo(() => runLabels(board), [board]);
|
|
75
|
+
const liveRunIds = [...labels.keys()].sort().join(",");
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (!liveRunIds) {
|
|
78
|
+
setStream([]);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const token = loads.current.start(workspace.id);
|
|
82
|
+
void loadLiveEvents(config, board)
|
|
83
|
+
.then((events) => {
|
|
84
|
+
if (!loads.current.isCurrent(token))
|
|
85
|
+
return;
|
|
86
|
+
setStream((prior) => appendLines(prior, toStreamLines(events, labels)));
|
|
87
|
+
})
|
|
88
|
+
.catch(() => { });
|
|
89
|
+
}, [liveRunIds, board, config, labels, workspace.id]);
|
|
90
|
+
const say = useCallback((speaker, body, steps) => {
|
|
91
|
+
setMessages((prior) => [...prior, { id: nextId(), speaker, body, steps, done: true }]);
|
|
92
|
+
}, []);
|
|
93
|
+
const order = useMemo(() => boardTicketIds(board), [board]);
|
|
94
|
+
const settings = useMemo(() => settingsRows(workspace, board.agents), [workspace, board.agents]);
|
|
95
|
+
const settingsOrder = useMemo(() => editableKeys(settings), [settings]);
|
|
96
|
+
const browsing = mode === "browse" && draft.length === 0 && cursor !== null;
|
|
97
|
+
const configuring = view === "settings" && !editing;
|
|
98
|
+
const moveCursor = useCallback((delta) => {
|
|
99
|
+
if (!order.length)
|
|
100
|
+
return false;
|
|
101
|
+
const next = nextCursor(order, selectedRef.current, delta);
|
|
102
|
+
if (!next)
|
|
103
|
+
return false;
|
|
104
|
+
selectedRef.current = next;
|
|
105
|
+
setCursor(next);
|
|
106
|
+
return true;
|
|
107
|
+
}, [order]);
|
|
108
|
+
const moveField = useCallback((delta) => {
|
|
109
|
+
const next = nextCursor(settingsOrder, fieldRef.current, delta);
|
|
110
|
+
if (!next)
|
|
111
|
+
return false;
|
|
112
|
+
fieldRef.current = next;
|
|
113
|
+
setField(next);
|
|
114
|
+
return true;
|
|
115
|
+
}, [settingsOrder]);
|
|
116
|
+
const refresh = useCallback(async () => {
|
|
117
|
+
await refreshRef.current?.();
|
|
118
|
+
}, []);
|
|
119
|
+
const applyEdit = useCallback(async (key, raw) => {
|
|
120
|
+
const row = settings.find((entry) => entry.key === key);
|
|
121
|
+
if (!row)
|
|
122
|
+
return;
|
|
123
|
+
const edit = editFor(row, raw);
|
|
124
|
+
if (!edit.ok) {
|
|
125
|
+
setNotice(edit.error);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
setBusy(true);
|
|
129
|
+
try {
|
|
130
|
+
if (edit.value.target === "cap") {
|
|
131
|
+
await updateProviderCap(config, edit.value.provider, edit.value.cap);
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
await updateAgent(config, edit.value.id, edit.value.fields);
|
|
135
|
+
}
|
|
136
|
+
setNotice(null);
|
|
137
|
+
await refresh();
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
setNotice(error instanceof Error ? error.message : String(error));
|
|
141
|
+
}
|
|
142
|
+
finally {
|
|
143
|
+
setBusy(false);
|
|
144
|
+
}
|
|
145
|
+
}, [settings, config, refresh]);
|
|
146
|
+
const changeWorkspace = useCallback(async (slug) => {
|
|
147
|
+
if (!configuredSlugs().includes(slug)) {
|
|
148
|
+
setNotice(`No configured workspace ${slug}. You can reach: ${configuredSlugs().join(", ")}.`);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
setBusy(true);
|
|
152
|
+
try {
|
|
153
|
+
const snapshot = await switchWorkspace(slug);
|
|
154
|
+
loads.current.switchTo(snapshot.workspace.id);
|
|
155
|
+
setConfig(snapshot.config);
|
|
156
|
+
setWorkspace(snapshot.workspace);
|
|
157
|
+
setBoard(snapshot.board);
|
|
158
|
+
setFeed(snapshot.feed);
|
|
159
|
+
setStream([]);
|
|
160
|
+
setCursor(null);
|
|
161
|
+
selectedRef.current = null;
|
|
162
|
+
setView("home");
|
|
163
|
+
setTicketKey(null);
|
|
164
|
+
setNotice(null);
|
|
165
|
+
say("system", `Now on ${snapshot.workspace.slug} (${snapshot.workspace.repo}).`);
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
setNotice(error instanceof Error ? error.message : String(error));
|
|
169
|
+
}
|
|
170
|
+
finally {
|
|
171
|
+
setBusy(false);
|
|
172
|
+
}
|
|
173
|
+
}, [say]);
|
|
174
|
+
const askOrchestrator = useCallback(async (text) => {
|
|
175
|
+
setBusy(true);
|
|
176
|
+
const id = nextId();
|
|
177
|
+
setMessages((prior) => [...prior, { id, speaker: "orchestrator", body: "", pending: true }]);
|
|
178
|
+
const since = new Date().toISOString();
|
|
179
|
+
try {
|
|
180
|
+
await postOrchestrator(text, config);
|
|
181
|
+
setMessages((prior) => prior.map((message) => message.id === id
|
|
182
|
+
? { ...message, steps: ["· queued, it answers on the next tick"] }
|
|
183
|
+
: message));
|
|
184
|
+
const { waitForReply } = await import("./data.js");
|
|
185
|
+
const reply = await waitForReply(config, since, 180_000);
|
|
186
|
+
setMessages((prior) => prior.map((message) => message.id === id
|
|
187
|
+
? { ...message, body: reply ?? "No reply yet. It will land in /inbox.", pending: false, steps: [] }
|
|
188
|
+
: message));
|
|
189
|
+
}
|
|
190
|
+
catch (error) {
|
|
191
|
+
const body = error instanceof Error ? error.message : String(error);
|
|
192
|
+
setMessages((prior) => prior.map((message) => message.id === id ? { ...message, body, pending: false } : message));
|
|
193
|
+
}
|
|
194
|
+
finally {
|
|
195
|
+
setMessages((prior) => prior.map((message) => message.id === id ? { ...message, done: true } : message));
|
|
196
|
+
setBusy(false);
|
|
197
|
+
}
|
|
198
|
+
}, [config]);
|
|
199
|
+
const run = useCallback(async (raw) => {
|
|
200
|
+
const text = raw.trim();
|
|
201
|
+
if (view === "settings") {
|
|
202
|
+
const open = editingRef.current;
|
|
203
|
+
if (open) {
|
|
204
|
+
setEditing(null);
|
|
205
|
+
setDraft("");
|
|
206
|
+
await applyEdit(open.key, raw);
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
if (!text) {
|
|
210
|
+
const key = fieldRef.current;
|
|
211
|
+
const row = settings.find((entry) => entry.key === key);
|
|
212
|
+
if (!row || !key)
|
|
213
|
+
return;
|
|
214
|
+
const flipped = nextValue(row);
|
|
215
|
+
if (flipped !== null)
|
|
216
|
+
return applyEdit(key, flipped);
|
|
217
|
+
const seed = seedFor(row);
|
|
218
|
+
setEditing({ key, draft: seed });
|
|
219
|
+
setDraft(seed);
|
|
220
|
+
setNotice(row.hint ?? null);
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
if (!text) {
|
|
225
|
+
const selected = board.tickets.find((ticket) => ticket.id === selectedRef.current);
|
|
226
|
+
if (browsing && selected) {
|
|
227
|
+
setTicketKey(selected.key);
|
|
228
|
+
setView("ticket");
|
|
229
|
+
}
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
history.current.push(text);
|
|
233
|
+
historyAt.current = -1;
|
|
234
|
+
setDraft("");
|
|
235
|
+
setNotice(null);
|
|
236
|
+
const action = parseLine(text);
|
|
237
|
+
if (action.kind === "say") {
|
|
238
|
+
say("you", text);
|
|
239
|
+
if (mode === "orchestrator")
|
|
240
|
+
await askOrchestrator(text);
|
|
241
|
+
else
|
|
242
|
+
setNotice("Use /orchestrator before sending a message.");
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
switch (action.kind) {
|
|
246
|
+
case "mode":
|
|
247
|
+
setMode("orchestrator");
|
|
248
|
+
setCursor(null);
|
|
249
|
+
selectedRef.current = null;
|
|
250
|
+
say("system", "Talking to the orchestrator. It moves work already in flight.");
|
|
251
|
+
return;
|
|
252
|
+
case "view":
|
|
253
|
+
setView(action.view);
|
|
254
|
+
if (action.view === "board" && order.length) {
|
|
255
|
+
const next = selectedRef.current && order.includes(selectedRef.current) ? selectedRef.current : order[0];
|
|
256
|
+
selectedRef.current = next;
|
|
257
|
+
setCursor(next);
|
|
258
|
+
setMode("browse");
|
|
259
|
+
}
|
|
260
|
+
if (action.view === "settings") {
|
|
261
|
+
const first = settingsOrder[0] ?? null;
|
|
262
|
+
fieldRef.current = first;
|
|
263
|
+
setField(first);
|
|
264
|
+
setEditing(null);
|
|
265
|
+
}
|
|
266
|
+
return;
|
|
267
|
+
case "workspace":
|
|
268
|
+
if (!action.slug)
|
|
269
|
+
say("system", `Workspaces: ${configuredSlugs().join(", ")}.`);
|
|
270
|
+
else
|
|
271
|
+
await changeWorkspace(action.slug);
|
|
272
|
+
return;
|
|
273
|
+
case "ticket":
|
|
274
|
+
setTicketKey(action.key);
|
|
275
|
+
setView("ticket");
|
|
276
|
+
setBusy(true);
|
|
277
|
+
try {
|
|
278
|
+
const { ticket: detail } = await loadTicketDetail(config, action.key);
|
|
279
|
+
setBoard((prior) => ({
|
|
280
|
+
...prior,
|
|
281
|
+
tickets: prior.tickets.map((ticket) => ticket.id === detail.id ? { ...ticket, ...detail } : ticket),
|
|
282
|
+
}));
|
|
283
|
+
}
|
|
284
|
+
catch (error) {
|
|
285
|
+
setNotice(error instanceof Error ? error.message : String(error));
|
|
286
|
+
}
|
|
287
|
+
finally {
|
|
288
|
+
setBusy(false);
|
|
289
|
+
}
|
|
290
|
+
return;
|
|
291
|
+
case "decide": {
|
|
292
|
+
const decision = board.decisions[0];
|
|
293
|
+
if (!decision) {
|
|
294
|
+
setNotice("Nothing is waiting on a decision.");
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
if (action.dismiss) {
|
|
298
|
+
setNotice("Skipping decisions is not available through the HDX API. Answer it instead.");
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
const options = decisionOptions(decision);
|
|
302
|
+
const option = /^\d+$/.test(action.answer) ? options[Number(action.answer) - 1] : undefined;
|
|
303
|
+
const answer = option ?? action.answer;
|
|
304
|
+
if (!answer) {
|
|
305
|
+
setNotice("Answer it with /decide 1 or /decide <your answer>.");
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
setBusy(true);
|
|
309
|
+
try {
|
|
310
|
+
await resolveDecision(config, decision.id, answer);
|
|
311
|
+
say("system", `Answered: ${answer}`);
|
|
312
|
+
await refresh();
|
|
313
|
+
}
|
|
314
|
+
catch (error) {
|
|
315
|
+
setNotice(error instanceof Error ? error.message : String(error));
|
|
316
|
+
}
|
|
317
|
+
finally {
|
|
318
|
+
setBusy(false);
|
|
319
|
+
}
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
case "help":
|
|
323
|
+
setMessages((prior) => [...prior, { id: nextId(), speaker: "system", body: "", panel: "help", done: true }]);
|
|
324
|
+
return;
|
|
325
|
+
case "refresh":
|
|
326
|
+
await refresh();
|
|
327
|
+
return;
|
|
328
|
+
case "exit":
|
|
329
|
+
exit();
|
|
330
|
+
return;
|
|
331
|
+
case "unknown":
|
|
332
|
+
setNotice(`No command /${action.command}. Try /help.`);
|
|
333
|
+
return;
|
|
334
|
+
default:
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
}, [view, settings, applyEdit, board, browsing, mode, say, askOrchestrator, order, settingsOrder, changeWorkspace, config, refresh, exit]);
|
|
338
|
+
useInput((input, key) => {
|
|
339
|
+
if (key.ctrl && input === "c")
|
|
340
|
+
exit();
|
|
341
|
+
});
|
|
342
|
+
const decisions = board.decisions;
|
|
343
|
+
const waiting = decisions.length;
|
|
344
|
+
const announced = useRef(0);
|
|
345
|
+
useEffect(() => {
|
|
346
|
+
if (waiting > announced.current)
|
|
347
|
+
alertOnce();
|
|
348
|
+
announced.current = waiting;
|
|
349
|
+
}, [waiting]);
|
|
350
|
+
const ticket = ticketKey ? board.tickets.find((row) => row.key === ticketKey) : null;
|
|
351
|
+
const settled = messages.filter((message) => message.done);
|
|
352
|
+
const inFlight = messages.filter((message) => !message.done);
|
|
353
|
+
const splash = !started;
|
|
354
|
+
const scrollback = splash ? [] : [
|
|
355
|
+
{ key: "banner" },
|
|
356
|
+
{ key: "help", message: { id: "help", speaker: "system", body: "", panel: "help" } },
|
|
357
|
+
...settled.map((message) => ({ key: message.id, message })),
|
|
358
|
+
];
|
|
359
|
+
const plan = planLayout({
|
|
360
|
+
rows, columns, width, splash, ready, decision: decisionRows(decisions),
|
|
361
|
+
inFlight: inFlight.reduce((total, message) => total + bubbleRows(message, width), 0),
|
|
362
|
+
notice: Boolean(notice), home: view === "home",
|
|
363
|
+
});
|
|
364
|
+
const agentsView = splitPanels(plan.panels);
|
|
365
|
+
const running = board.runs.filter((run) => run.status === "running").length;
|
|
366
|
+
const selected = cursor ? board.tickets.find((row) => row.id === cursor) : null;
|
|
367
|
+
return (_jsxs(_Fragment, { children: [_jsx(Static, { items: scrollback, children: (item) => {
|
|
368
|
+
if (!item.message)
|
|
369
|
+
return _jsx(Banner, { animate: false }, item.key);
|
|
370
|
+
if (item.message.panel === "help")
|
|
371
|
+
return _jsx(Help, { width: width }, item.key);
|
|
372
|
+
return _jsx(Bubble, { message: item.message, width: width }, item.key);
|
|
373
|
+
} }), splash ? (_jsx(Splash, { columns: columns, rows: rows, width: width, ready: ready, helpFull: plan.helpFull, animate: plan.fits, onDone: () => setReady(true) })) : null, _jsxs(Box, { flexDirection: "column", width: width, children: [view === "board" && plan.panels > 0 ? _jsx(BoardPanel, { board: board, width: width, rows: plan.panels, cursor: cursor }) : null, view === "agents" && plan.panels > 0 ? (_jsxs(Box, { flexDirection: "column", children: [_jsx(AgentsPanel, { board: board, width: width, rows: agentsView.top }), agentsView.bottom > 0 ? _jsxs(_Fragment, { children: [_jsx(Box, { height: 1 }), _jsx(StreamPanel, { lines: stream, width: width, rows: agentsView.bottom, live: running > 0 })] }) : null] })) : null, view === "feed" && plan.panels > 0 ? _jsx(FeedPanel, { entries: feed, width: width, rows: plan.panels }) : null, view === "settings" && plan.panels > 0 ? _jsx(SettingsPanel, { entries: settings, width: width, rows: plan.panels, title: "Settings", cursor: field, editing: editing }) : null, view === "inbox" && plan.panels > 0 ? _jsx(InboxPanel, { board: board, width: width, rows: plan.panels }) : null, view === "ticket" && plan.panels > 0 ? ticket
|
|
374
|
+
? _jsx(TicketPanel, { ticket: ticket, width: width, rows: plan.panels })
|
|
375
|
+
: _jsxs(Text, { color: UI.warn, children: ["No ticket ", ticketKey, " here."] }) : null, view === "home" && plan.cockpit > 0 ? (_jsxs(Box, { flexDirection: "column", children: [_jsx(Cockpit, { board: board, width: width, rows: plan.cockpit, cursor: cursor }), _jsx(Box, { height: 1 }), _jsx(StreamPanel, { lines: stream, width: width, rows: plan.stream, live: running > 0 })] })) : null, inFlight.map((message) => _jsx(Bubble, { message: message, width: width }, message.id)), _jsx(DecisionPanel, { decisions: decisions, board: board, width: width, rows: plan.decision }), notice ? _jsx(Box, { marginBottom: 1, children: _jsx(Text, { color: UI.warn, children: notice }) }) : null, _jsxs(Box, { marginTop: 1, children: [_jsx(Text, { color: UI.text, bold: true, children: workspace.slug }), _jsxs(Text, { color: UI.dim, children: [" ", workspace.repo, " "] }), _jsx(Text, { color: live === "live" ? UI.accent : UI.dim, children: "\u25CF " }), _jsxs(Text, { color: UI.dim, children: [live === "live" ? "5s poll" : live, " "] }), _jsx(Text, { color: UI.dim, children: running ? `${running} running ` : "" }), board.decisions.length ? _jsxs(Text, { color: UI.warn, children: [board.decisions.length, " decisions "] }) : null, workspace.paused ? _jsx(Text, { color: UI.warn, children: "paused " }) : null, _jsxs(Text, { color: UI.dim, wrap: "truncate", children: ["\u00B7 ", mode, cursor && selected ? ` ${selected.key} ↑↓ move · enter opens · esc leaves` : ""] })] }), _jsx(Box, { children: _jsx(TextInput, { value: draft, onChange: (next) => {
|
|
376
|
+
setDraft(next);
|
|
377
|
+
if (editingRef.current)
|
|
378
|
+
setEditing({ key: editingRef.current.key, draft: next });
|
|
379
|
+
}, onSubmit: (value) => void run(value), isActive: !busy, placeholder: busy ? "working…" : "message, or /help", prompt: _jsx(Text, { color: mode === "browse" ? UI.dim : UI.cream, children: mode === "orchestrator" ? "orchestrator> " : "> " }), color: UI.text, onCancel: () => {
|
|
380
|
+
if (editing) {
|
|
381
|
+
setEditing(null);
|
|
382
|
+
setDraft("");
|
|
383
|
+
setNotice(null);
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
if (view !== "home") {
|
|
387
|
+
setView("home");
|
|
388
|
+
setTicketKey(null);
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
setCursor(null);
|
|
392
|
+
selectedRef.current = null;
|
|
393
|
+
}, onUp: () => {
|
|
394
|
+
if (configuring && moveField(-1))
|
|
395
|
+
return;
|
|
396
|
+
if (browsing && moveCursor(-1))
|
|
397
|
+
return;
|
|
398
|
+
if (!history.current.length)
|
|
399
|
+
return;
|
|
400
|
+
historyAt.current = historyAt.current < 0 ? history.current.length - 1 : Math.max(0, historyAt.current - 1);
|
|
401
|
+
setDraft(history.current[historyAt.current] ?? "");
|
|
402
|
+
}, onDown: () => {
|
|
403
|
+
if (configuring && moveField(1))
|
|
404
|
+
return;
|
|
405
|
+
if (browsing && moveCursor(1))
|
|
406
|
+
return;
|
|
407
|
+
if (historyAt.current < 0)
|
|
408
|
+
return;
|
|
409
|
+
historyAt.current += 1;
|
|
410
|
+
if (historyAt.current >= history.current.length) {
|
|
411
|
+
historyAt.current = -1;
|
|
412
|
+
setDraft("");
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
setDraft(history.current[historyAt.current] ?? "");
|
|
416
|
+
} }) })] })] }));
|
|
417
|
+
}
|
|
418
|
+
export { COMMANDS };
|