maestro-flow 0.1.2 → 0.1.4
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/dashboard/tui/dist/index.js +3974 -0
- package/package.json +7 -2
|
@@ -0,0 +1,3974 @@
|
|
|
1
|
+
// src/index.tsx
|
|
2
|
+
import { render } from "ink";
|
|
3
|
+
|
|
4
|
+
// src/App.tsx
|
|
5
|
+
import { useState as useState13 } from "react";
|
|
6
|
+
import { Box as Box34, useInput as useInput13 } from "ink";
|
|
7
|
+
|
|
8
|
+
// src/providers/ApiProvider.tsx
|
|
9
|
+
import React, {
|
|
10
|
+
createContext,
|
|
11
|
+
useContext,
|
|
12
|
+
useState,
|
|
13
|
+
useEffect,
|
|
14
|
+
useCallback,
|
|
15
|
+
useRef
|
|
16
|
+
} from "react";
|
|
17
|
+
import { jsx } from "react/jsx-runtime";
|
|
18
|
+
var ApiContext = createContext({
|
|
19
|
+
baseUrl: "http://localhost:3000"
|
|
20
|
+
});
|
|
21
|
+
function useApi(endpoint, options) {
|
|
22
|
+
const { baseUrl } = useContext(ApiContext);
|
|
23
|
+
const [data, setData] = useState(null);
|
|
24
|
+
const [loading, setLoading] = useState(!options?.skip);
|
|
25
|
+
const [error, setError] = useState(null);
|
|
26
|
+
const requestId = useRef(0);
|
|
27
|
+
const fetchData = useCallback(() => {
|
|
28
|
+
if (options?.skip) return;
|
|
29
|
+
const id = ++requestId.current;
|
|
30
|
+
setLoading(true);
|
|
31
|
+
fetch(`${baseUrl}${endpoint}`, {
|
|
32
|
+
headers: { "Content-Type": "application/json" }
|
|
33
|
+
}).then((res) => {
|
|
34
|
+
if (!res.ok) {
|
|
35
|
+
throw new Error(`API error: ${res.status} ${res.statusText}`);
|
|
36
|
+
}
|
|
37
|
+
return res.json();
|
|
38
|
+
}).then((result) => {
|
|
39
|
+
if (id === requestId.current) {
|
|
40
|
+
setData(result);
|
|
41
|
+
setError(null);
|
|
42
|
+
setLoading(false);
|
|
43
|
+
}
|
|
44
|
+
}).catch((err) => {
|
|
45
|
+
if (id === requestId.current) {
|
|
46
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
47
|
+
setLoading(false);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}, [baseUrl, endpoint, options?.skip]);
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
fetchData();
|
|
53
|
+
}, [fetchData]);
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
const interval = options?.pollInterval;
|
|
56
|
+
if (!interval || interval <= 0 || options?.skip) return;
|
|
57
|
+
const timer = setInterval(fetchData, interval);
|
|
58
|
+
return () => clearInterval(timer);
|
|
59
|
+
}, [fetchData, options?.pollInterval, options?.skip]);
|
|
60
|
+
return { data, loading, error, refetch: fetchData };
|
|
61
|
+
}
|
|
62
|
+
function useBaseUrl() {
|
|
63
|
+
return useContext(ApiContext).baseUrl;
|
|
64
|
+
}
|
|
65
|
+
function ApiProvider({
|
|
66
|
+
baseUrl = "http://localhost:3000",
|
|
67
|
+
children
|
|
68
|
+
}) {
|
|
69
|
+
const value = React.useMemo(() => ({ baseUrl }), [baseUrl]);
|
|
70
|
+
return /* @__PURE__ */ jsx(ApiContext.Provider, { value, children });
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// src/providers/WsProvider.tsx
|
|
74
|
+
import React2, {
|
|
75
|
+
createContext as createContext2,
|
|
76
|
+
useContext as useContext2,
|
|
77
|
+
useState as useState2,
|
|
78
|
+
useEffect as useEffect2,
|
|
79
|
+
useRef as useRef2,
|
|
80
|
+
useCallback as useCallback2
|
|
81
|
+
} from "react";
|
|
82
|
+
import WebSocket from "ws";
|
|
83
|
+
|
|
84
|
+
// ../src/shared/constants.ts
|
|
85
|
+
var API_ENDPOINTS = {
|
|
86
|
+
HEALTH: "/api/health",
|
|
87
|
+
BOARD: "/api/board",
|
|
88
|
+
PROJECT: "/api/project",
|
|
89
|
+
PHASES: "/api/phases",
|
|
90
|
+
PHASE: "/api/phases/:n",
|
|
91
|
+
PHASE_TASKS: "/api/phases/:n/tasks",
|
|
92
|
+
ARTIFACTS: "/api/artifacts",
|
|
93
|
+
SCRATCH: "/api/scratch",
|
|
94
|
+
SETTINGS: "/api/settings",
|
|
95
|
+
SETTINGS_GENERAL: "/api/settings/general",
|
|
96
|
+
SETTINGS_AGENTS: "/api/settings/agents",
|
|
97
|
+
SETTINGS_CLI_TOOLS: "/api/settings/cli-tools",
|
|
98
|
+
SETTINGS_SPECS: "/api/settings/specs"
|
|
99
|
+
};
|
|
100
|
+
var AGENT_API_ENDPOINTS = {
|
|
101
|
+
SPAWN: "/api/agent/spawn",
|
|
102
|
+
STOP: "/api/agent/stop",
|
|
103
|
+
MESSAGE: "/api/agent/message",
|
|
104
|
+
APPROVE: "/api/agent/approve",
|
|
105
|
+
LIST: "/api/agent/list",
|
|
106
|
+
ENTRIES: "/api/agent/entries"
|
|
107
|
+
};
|
|
108
|
+
var ISSUE_API_ENDPOINTS = {
|
|
109
|
+
ISSUES: "/api/issues",
|
|
110
|
+
ISSUE: "/api/issues/:id"
|
|
111
|
+
};
|
|
112
|
+
var EXECUTION_API_ENDPOINTS = {
|
|
113
|
+
DISPATCH: "/api/execution/dispatch",
|
|
114
|
+
BATCH: "/api/execution/batch",
|
|
115
|
+
CANCEL: "/api/execution/cancel",
|
|
116
|
+
STATUS: "/api/execution/status",
|
|
117
|
+
SUPERVISOR: "/api/execution/supervisor"
|
|
118
|
+
};
|
|
119
|
+
var WS_ENDPOINT = "/ws";
|
|
120
|
+
|
|
121
|
+
// src/providers/WsProvider.tsx
|
|
122
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
123
|
+
var WsContext = createContext2({
|
|
124
|
+
connected: false,
|
|
125
|
+
send: () => {
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
function useWs() {
|
|
129
|
+
return useContext2(WsContext);
|
|
130
|
+
}
|
|
131
|
+
var addListener = () => {
|
|
132
|
+
};
|
|
133
|
+
var removeListener = () => {
|
|
134
|
+
};
|
|
135
|
+
function useWsEvent(eventType) {
|
|
136
|
+
const [data, setData] = useState2(null);
|
|
137
|
+
useEffect2(() => {
|
|
138
|
+
const handler = (message) => {
|
|
139
|
+
if (message.type === eventType) {
|
|
140
|
+
setData(message.data);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
addListener(handler);
|
|
144
|
+
return () => removeListener(handler);
|
|
145
|
+
}, [eventType]);
|
|
146
|
+
return data;
|
|
147
|
+
}
|
|
148
|
+
var INITIAL_RECONNECT_MS = 1e3;
|
|
149
|
+
var MAX_RECONNECT_MS = 3e4;
|
|
150
|
+
var RECONNECT_BACKOFF = 2;
|
|
151
|
+
function WsProvider({
|
|
152
|
+
url,
|
|
153
|
+
children
|
|
154
|
+
}) {
|
|
155
|
+
const [connected, setConnected] = useState2(false);
|
|
156
|
+
const wsRef = useRef2(null);
|
|
157
|
+
const listenersRef = useRef2(/* @__PURE__ */ new Set());
|
|
158
|
+
const reconnectDelayRef = useRef2(INITIAL_RECONNECT_MS);
|
|
159
|
+
const reconnectTimerRef = useRef2(null);
|
|
160
|
+
const unmountedRef = useRef2(false);
|
|
161
|
+
const wsUrl = url ?? `ws://localhost:3000${WS_ENDPOINT}`;
|
|
162
|
+
useEffect2(() => {
|
|
163
|
+
addListener = (fn) => listenersRef.current.add(fn);
|
|
164
|
+
removeListener = (fn) => listenersRef.current.delete(fn);
|
|
165
|
+
return () => {
|
|
166
|
+
addListener = () => {
|
|
167
|
+
};
|
|
168
|
+
removeListener = () => {
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
}, []);
|
|
172
|
+
const connect = useCallback2(() => {
|
|
173
|
+
if (unmountedRef.current) return;
|
|
174
|
+
const ws = new WebSocket(wsUrl);
|
|
175
|
+
wsRef.current = ws;
|
|
176
|
+
ws.on("open", () => {
|
|
177
|
+
if (unmountedRef.current) {
|
|
178
|
+
ws.close();
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
setConnected(true);
|
|
182
|
+
reconnectDelayRef.current = INITIAL_RECONNECT_MS;
|
|
183
|
+
});
|
|
184
|
+
ws.on("message", (raw) => {
|
|
185
|
+
try {
|
|
186
|
+
const message = JSON.parse(String(raw));
|
|
187
|
+
for (const listener of listenersRef.current) {
|
|
188
|
+
listener(message);
|
|
189
|
+
}
|
|
190
|
+
} catch {
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
ws.on("close", () => {
|
|
194
|
+
setConnected(false);
|
|
195
|
+
if (!unmountedRef.current) {
|
|
196
|
+
scheduleReconnect();
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
ws.on("error", () => {
|
|
200
|
+
});
|
|
201
|
+
}, [wsUrl]);
|
|
202
|
+
const scheduleReconnect = useCallback2(() => {
|
|
203
|
+
if (unmountedRef.current) return;
|
|
204
|
+
if (reconnectTimerRef.current) return;
|
|
205
|
+
const delay = reconnectDelayRef.current;
|
|
206
|
+
reconnectDelayRef.current = Math.min(delay * RECONNECT_BACKOFF, MAX_RECONNECT_MS);
|
|
207
|
+
reconnectTimerRef.current = setTimeout(() => {
|
|
208
|
+
reconnectTimerRef.current = null;
|
|
209
|
+
connect();
|
|
210
|
+
}, delay);
|
|
211
|
+
}, [connect]);
|
|
212
|
+
useEffect2(() => {
|
|
213
|
+
unmountedRef.current = false;
|
|
214
|
+
connect();
|
|
215
|
+
return () => {
|
|
216
|
+
unmountedRef.current = true;
|
|
217
|
+
if (reconnectTimerRef.current) {
|
|
218
|
+
clearTimeout(reconnectTimerRef.current);
|
|
219
|
+
reconnectTimerRef.current = null;
|
|
220
|
+
}
|
|
221
|
+
if (wsRef.current) {
|
|
222
|
+
wsRef.current.close();
|
|
223
|
+
wsRef.current = null;
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
}, [connect]);
|
|
227
|
+
const send = useCallback2((message) => {
|
|
228
|
+
if (wsRef.current && wsRef.current.readyState === WebSocket.OPEN) {
|
|
229
|
+
wsRef.current.send(JSON.stringify(message));
|
|
230
|
+
}
|
|
231
|
+
}, []);
|
|
232
|
+
const value = React2.useMemo(
|
|
233
|
+
() => ({ connected, send }),
|
|
234
|
+
[connected, send]
|
|
235
|
+
);
|
|
236
|
+
return /* @__PURE__ */ jsx2(WsContext.Provider, { value, children });
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// src/layout/HeaderBar.tsx
|
|
240
|
+
import { Box, Text } from "ink";
|
|
241
|
+
|
|
242
|
+
// src/router/types.ts
|
|
243
|
+
var routes = [
|
|
244
|
+
{ key: "1", id: "issue", label: "Issues" },
|
|
245
|
+
{ key: "2", id: "workflow", label: "Workflow" },
|
|
246
|
+
{ key: "3", id: "artifact", label: "Artifacts" },
|
|
247
|
+
{ key: "4", id: "team", label: "Team" },
|
|
248
|
+
{ key: "5", id: "requirement", label: "Requirements" },
|
|
249
|
+
{ key: "6", id: "execution", label: "Execution" },
|
|
250
|
+
{ key: "7", id: "chat", label: "Chat" }
|
|
251
|
+
];
|
|
252
|
+
|
|
253
|
+
// src/layout/HeaderBar.tsx
|
|
254
|
+
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
255
|
+
function HeaderBar({ activeView }) {
|
|
256
|
+
return /* @__PURE__ */ jsxs(Box, { borderStyle: "single", borderBottom: true, borderLeft: false, borderRight: false, borderTop: false, paddingX: 1, children: [
|
|
257
|
+
/* @__PURE__ */ jsx3(Text, { bold: true, color: "green", children: "Maestro TUI" }),
|
|
258
|
+
/* @__PURE__ */ jsx3(Text, { children: " | " }),
|
|
259
|
+
routes.map((route) => /* @__PURE__ */ jsx3(Box, { marginRight: 1, children: /* @__PURE__ */ jsxs(
|
|
260
|
+
Text,
|
|
261
|
+
{
|
|
262
|
+
bold: route.id === activeView,
|
|
263
|
+
color: route.id === activeView ? "cyan" : void 0,
|
|
264
|
+
dimColor: route.id !== activeView,
|
|
265
|
+
children: [
|
|
266
|
+
"[",
|
|
267
|
+
route.key,
|
|
268
|
+
"] ",
|
|
269
|
+
route.label
|
|
270
|
+
]
|
|
271
|
+
}
|
|
272
|
+
) }, route.id))
|
|
273
|
+
] });
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// src/layout/StatusBar.tsx
|
|
277
|
+
import { Box as Box2, Text as Text2 } from "ink";
|
|
278
|
+
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
279
|
+
function StatusBar({ connected, workspace }) {
|
|
280
|
+
return /* @__PURE__ */ jsxs2(Box2, { borderStyle: "single", borderTop: true, borderLeft: false, borderRight: false, borderBottom: false, paddingX: 1, justifyContent: "space-between", children: [
|
|
281
|
+
/* @__PURE__ */ jsxs2(Box2, { children: [
|
|
282
|
+
/* @__PURE__ */ jsx4(Text2, { color: connected ? "green" : "red", children: connected ? "[*] Connected" : "[ ] Disconnected" }),
|
|
283
|
+
/* @__PURE__ */ jsxs2(Text2, { dimColor: true, children: [
|
|
284
|
+
" | ",
|
|
285
|
+
workspace
|
|
286
|
+
] })
|
|
287
|
+
] }),
|
|
288
|
+
/* @__PURE__ */ jsx4(Text2, { dimColor: true, children: "1-7: Switch views | q: Quit" })
|
|
289
|
+
] });
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// src/router/Router.tsx
|
|
293
|
+
import { Box as Box33, Text as Text34 } from "ink";
|
|
294
|
+
|
|
295
|
+
// src/views/IssueView.tsx
|
|
296
|
+
import { useState as useState4, useCallback as useCallback4, useMemo as useMemo2 } from "react";
|
|
297
|
+
import { Box as Box9, Text as Text10, useInput as useInput4 } from "ink";
|
|
298
|
+
import { TextInput, Select } from "@inkjs/ui";
|
|
299
|
+
|
|
300
|
+
// src/components/ScrollableList.tsx
|
|
301
|
+
import { useState as useState3, useCallback as useCallback3, useEffect as useEffect3, useRef as useRef3 } from "react";
|
|
302
|
+
import { Box as Box3, Text as Text3, useInput, useStdout } from "ink";
|
|
303
|
+
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
304
|
+
function useScrollableList(itemCount, viewportHeight) {
|
|
305
|
+
const [selectedIndex, setSelectedIndex] = useState3(0);
|
|
306
|
+
const [scrollOffset, setScrollOffset] = useState3(0);
|
|
307
|
+
useEffect3(() => {
|
|
308
|
+
if (itemCount === 0) {
|
|
309
|
+
setSelectedIndex(0);
|
|
310
|
+
setScrollOffset(0);
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
if (selectedIndex >= itemCount) {
|
|
314
|
+
setSelectedIndex(itemCount - 1);
|
|
315
|
+
}
|
|
316
|
+
}, [itemCount, selectedIndex]);
|
|
317
|
+
const moveUp = useCallback3(() => {
|
|
318
|
+
setSelectedIndex((prev) => {
|
|
319
|
+
const next = Math.max(0, prev - 1);
|
|
320
|
+
setScrollOffset((off) => next < off ? next : off);
|
|
321
|
+
return next;
|
|
322
|
+
});
|
|
323
|
+
}, []);
|
|
324
|
+
const moveDown = useCallback3(() => {
|
|
325
|
+
setSelectedIndex((prev) => {
|
|
326
|
+
const next = Math.min(itemCount - 1, prev + 1);
|
|
327
|
+
setScrollOffset((off) => next >= off + viewportHeight ? next - viewportHeight + 1 : off);
|
|
328
|
+
return next;
|
|
329
|
+
});
|
|
330
|
+
}, [itemCount, viewportHeight]);
|
|
331
|
+
return { selectedIndex, scrollOffset, moveUp, moveDown, setSelectedIndex, setScrollOffset };
|
|
332
|
+
}
|
|
333
|
+
function ScrollableList({
|
|
334
|
+
items,
|
|
335
|
+
renderItem,
|
|
336
|
+
onSelect,
|
|
337
|
+
onHighlight,
|
|
338
|
+
isFocused = true,
|
|
339
|
+
viewportHeight: fixedHeight,
|
|
340
|
+
reservedRows = 6,
|
|
341
|
+
getItemKey
|
|
342
|
+
}) {
|
|
343
|
+
const { stdout } = useStdout();
|
|
344
|
+
const termRows = stdout?.rows ?? 24;
|
|
345
|
+
const viewportHeight = fixedHeight ?? Math.max(1, termRows - reservedRows);
|
|
346
|
+
const { selectedIndex, scrollOffset, moveUp, moveDown, setSelectedIndex, setScrollOffset } = useScrollableList(
|
|
347
|
+
items.length,
|
|
348
|
+
viewportHeight
|
|
349
|
+
);
|
|
350
|
+
const prevKeyRef = useRef3(null);
|
|
351
|
+
useEffect3(() => {
|
|
352
|
+
if (getItemKey && items.length > 0 && items[selectedIndex]) {
|
|
353
|
+
prevKeyRef.current = getItemKey(items[selectedIndex]);
|
|
354
|
+
}
|
|
355
|
+
}, [selectedIndex, items, getItemKey]);
|
|
356
|
+
const prevItemsLenRef = useRef3(items.length);
|
|
357
|
+
useEffect3(() => {
|
|
358
|
+
if (!getItemKey || items.length === 0 || prevItemsLenRef.current === items.length) {
|
|
359
|
+
prevItemsLenRef.current = items.length;
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
prevItemsLenRef.current = items.length;
|
|
363
|
+
const key = prevKeyRef.current;
|
|
364
|
+
if (!key) return;
|
|
365
|
+
const newIdx = items.findIndex((item) => getItemKey(item) === key);
|
|
366
|
+
if (newIdx >= 0) {
|
|
367
|
+
setSelectedIndex(newIdx);
|
|
368
|
+
setScrollOffset((off) => {
|
|
369
|
+
if (newIdx < off) return newIdx;
|
|
370
|
+
if (newIdx >= off + viewportHeight) return newIdx - viewportHeight + 1;
|
|
371
|
+
return off;
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
}, [items, getItemKey, viewportHeight, setSelectedIndex, setScrollOffset]);
|
|
375
|
+
useInput(
|
|
376
|
+
(input, key) => {
|
|
377
|
+
if (key.upArrow) {
|
|
378
|
+
moveUp();
|
|
379
|
+
} else if (key.downArrow) {
|
|
380
|
+
moveDown();
|
|
381
|
+
} else if (key.return && items.length > 0) {
|
|
382
|
+
onSelect?.(items[selectedIndex], selectedIndex);
|
|
383
|
+
}
|
|
384
|
+
},
|
|
385
|
+
{ isActive: isFocused }
|
|
386
|
+
);
|
|
387
|
+
useEffect3(() => {
|
|
388
|
+
if (items.length > 0 && onHighlight) {
|
|
389
|
+
onHighlight(items[selectedIndex], selectedIndex);
|
|
390
|
+
}
|
|
391
|
+
}, [selectedIndex, items, onHighlight]);
|
|
392
|
+
if (items.length === 0) {
|
|
393
|
+
return /* @__PURE__ */ jsx5(Box3, { children: /* @__PURE__ */ jsx5(Text3, { dimColor: true, children: "(empty)" }) });
|
|
394
|
+
}
|
|
395
|
+
const visibleItems = items.slice(scrollOffset, scrollOffset + viewportHeight);
|
|
396
|
+
const hasAbove = scrollOffset > 0;
|
|
397
|
+
const hasBelow = scrollOffset + viewportHeight < items.length;
|
|
398
|
+
return /* @__PURE__ */ jsxs3(Box3, { flexDirection: "column", children: [
|
|
399
|
+
hasAbove && /* @__PURE__ */ jsxs3(Text3, { dimColor: true, children: [
|
|
400
|
+
" [",
|
|
401
|
+
scrollOffset,
|
|
402
|
+
" more above]"
|
|
403
|
+
] }),
|
|
404
|
+
visibleItems.map((item, i) => {
|
|
405
|
+
const realIndex = scrollOffset + i;
|
|
406
|
+
const isSelected = realIndex === selectedIndex;
|
|
407
|
+
const itemKey = getItemKey ? getItemKey(item) : String(realIndex);
|
|
408
|
+
return /* @__PURE__ */ jsxs3(Box3, { children: [
|
|
409
|
+
/* @__PURE__ */ jsxs3(Text3, { color: isSelected && isFocused ? "cyan" : void 0, children: [
|
|
410
|
+
isSelected ? ">" : " ",
|
|
411
|
+
" "
|
|
412
|
+
] }),
|
|
413
|
+
renderItem(item, realIndex, isSelected)
|
|
414
|
+
] }, itemKey);
|
|
415
|
+
}),
|
|
416
|
+
hasBelow && /* @__PURE__ */ jsxs3(Text3, { dimColor: true, children: [
|
|
417
|
+
" [",
|
|
418
|
+
items.length - scrollOffset - viewportHeight,
|
|
419
|
+
" more below]"
|
|
420
|
+
] })
|
|
421
|
+
] });
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
// src/components/SplitPane.tsx
|
|
425
|
+
import { Box as Box4, Text as Text4 } from "ink";
|
|
426
|
+
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
427
|
+
function SplitPane({
|
|
428
|
+
left,
|
|
429
|
+
right,
|
|
430
|
+
ratio = 40,
|
|
431
|
+
borderChar = "|"
|
|
432
|
+
}) {
|
|
433
|
+
const leftWidth = `${ratio}%`;
|
|
434
|
+
const rightWidth = `${100 - ratio}%`;
|
|
435
|
+
return /* @__PURE__ */ jsxs4(Box4, { flexDirection: "row", width: "100%", height: "100%", children: [
|
|
436
|
+
/* @__PURE__ */ jsx6(Box4, { flexDirection: "column", width: leftWidth, children: left }),
|
|
437
|
+
/* @__PURE__ */ jsx6(Box4, { flexDirection: "column", flexShrink: 0, children: /* @__PURE__ */ jsx6(Text4, { dimColor: true, children: borderChar }) }),
|
|
438
|
+
/* @__PURE__ */ jsx6(Box4, { flexDirection: "column", width: rightWidth, children: right })
|
|
439
|
+
] });
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
// src/components/DataTable.tsx
|
|
443
|
+
import { Box as Box5, Text as Text5 } from "ink";
|
|
444
|
+
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
445
|
+
function DataTable({ columns, data, selectedIndex }) {
|
|
446
|
+
return /* @__PURE__ */ jsxs5(Box5, { flexDirection: "column", children: [
|
|
447
|
+
/* @__PURE__ */ jsx7(Box5, { children: columns.map((col) => /* @__PURE__ */ jsx7(Box5, { width: col.width, flexShrink: 0, children: /* @__PURE__ */ jsx7(Text5, { bold: true, underline: true, wrap: "truncate", children: col.label }) }, col.key)) }),
|
|
448
|
+
data.map((row, rowIndex) => {
|
|
449
|
+
const isSelected = rowIndex === selectedIndex;
|
|
450
|
+
return /* @__PURE__ */ jsx7(Box5, { children: columns.map((col) => /* @__PURE__ */ jsx7(Box5, { width: col.width, flexShrink: 0, children: col.render ? col.render(row[col.key], row) : /* @__PURE__ */ jsx7(
|
|
451
|
+
Text5,
|
|
452
|
+
{
|
|
453
|
+
color: isSelected ? "cyan" : void 0,
|
|
454
|
+
wrap: "truncate",
|
|
455
|
+
children: String(row[col.key] ?? "")
|
|
456
|
+
}
|
|
457
|
+
) }, col.key)) }, rowIndex);
|
|
458
|
+
}),
|
|
459
|
+
data.length === 0 && /* @__PURE__ */ jsx7(Box5, { children: /* @__PURE__ */ jsx7(Text5, { dimColor: true, children: "(no data)" }) })
|
|
460
|
+
] });
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
// src/components/StatusDot.tsx
|
|
464
|
+
import { Text as Text6 } from "ink";
|
|
465
|
+
import { jsxs as jsxs6 } from "react/jsx-runtime";
|
|
466
|
+
var DEFAULT_STATUS_COLORS = {
|
|
467
|
+
pending: "gray",
|
|
468
|
+
exploring: "blue",
|
|
469
|
+
planning: "magenta",
|
|
470
|
+
executing: "yellow",
|
|
471
|
+
verifying: "yellowBright",
|
|
472
|
+
testing: "blue",
|
|
473
|
+
completed: "green",
|
|
474
|
+
blocked: "red",
|
|
475
|
+
// Issue statuses
|
|
476
|
+
open: "gray",
|
|
477
|
+
registered: "yellow",
|
|
478
|
+
analyzing: "blue",
|
|
479
|
+
planned: "magenta",
|
|
480
|
+
in_progress: "yellow",
|
|
481
|
+
resolved: "green",
|
|
482
|
+
closed: "gray",
|
|
483
|
+
deferred: "gray",
|
|
484
|
+
// Task statuses
|
|
485
|
+
failed: "red"
|
|
486
|
+
};
|
|
487
|
+
function StatusDot({ status, colorMap, showLabel = false }) {
|
|
488
|
+
const map = colorMap ?? DEFAULT_STATUS_COLORS;
|
|
489
|
+
const color = map[status] ?? "white";
|
|
490
|
+
return /* @__PURE__ */ jsxs6(Text6, { color, children: [
|
|
491
|
+
"*",
|
|
492
|
+
showLabel ? ` ${status}` : ""
|
|
493
|
+
] });
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
// src/components/FilterBar.tsx
|
|
497
|
+
import { Box as Box6, Text as Text7, useInput as useInput2 } from "ink";
|
|
498
|
+
import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
499
|
+
function FilterBar({
|
|
500
|
+
options,
|
|
501
|
+
activeIndex,
|
|
502
|
+
onSelect,
|
|
503
|
+
isFocused = true
|
|
504
|
+
}) {
|
|
505
|
+
useInput2(
|
|
506
|
+
(_input, key) => {
|
|
507
|
+
if (key.tab && options.length > 0) {
|
|
508
|
+
const next = (activeIndex + 1) % options.length;
|
|
509
|
+
onSelect(next);
|
|
510
|
+
}
|
|
511
|
+
},
|
|
512
|
+
{ isActive: isFocused }
|
|
513
|
+
);
|
|
514
|
+
if (options.length === 0) {
|
|
515
|
+
return null;
|
|
516
|
+
}
|
|
517
|
+
return /* @__PURE__ */ jsx8(Box6, { flexDirection: "row", gap: 1, children: options.map((option, i) => {
|
|
518
|
+
const isActive = i === activeIndex;
|
|
519
|
+
return /* @__PURE__ */ jsx8(Box6, { children: /* @__PURE__ */ jsxs7(
|
|
520
|
+
Text7,
|
|
521
|
+
{
|
|
522
|
+
bold: isActive,
|
|
523
|
+
color: isActive ? "cyan" : void 0,
|
|
524
|
+
dimColor: !isActive,
|
|
525
|
+
children: [
|
|
526
|
+
isActive ? "[" : " ",
|
|
527
|
+
option,
|
|
528
|
+
isActive ? "]" : " "
|
|
529
|
+
]
|
|
530
|
+
}
|
|
531
|
+
) }, i);
|
|
532
|
+
}) });
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
// src/components/ConfirmDialog.tsx
|
|
536
|
+
import { Box as Box7, Text as Text8, useInput as useInput3 } from "ink";
|
|
537
|
+
import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
538
|
+
function ConfirmDialog({ message, onConfirm, onCancel }) {
|
|
539
|
+
useInput3((_input, key) => {
|
|
540
|
+
if (key.return) onConfirm();
|
|
541
|
+
if (key.escape) onCancel();
|
|
542
|
+
});
|
|
543
|
+
return /* @__PURE__ */ jsxs8(Box7, { flexDirection: "column", padding: 1, children: [
|
|
544
|
+
/* @__PURE__ */ jsx9(Text8, { bold: true, color: "yellow", children: message }),
|
|
545
|
+
/* @__PURE__ */ jsx9(Box7, { marginTop: 1, children: /* @__PURE__ */ jsx9(Text8, { dimColor: true, children: "Enter: confirm | Esc: cancel" }) })
|
|
546
|
+
] });
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
// src/components/Markdown.tsx
|
|
550
|
+
import React4, { useMemo, useRef as useRef4 } from "react";
|
|
551
|
+
import { Box as Box8, Text as Text9 } from "ink";
|
|
552
|
+
import { marked } from "marked";
|
|
553
|
+
import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
554
|
+
var markedConfigured = false;
|
|
555
|
+
function configureMarked() {
|
|
556
|
+
if (markedConfigured) return;
|
|
557
|
+
marked.setOptions({ gfm: true, breaks: true });
|
|
558
|
+
markedConfigured = true;
|
|
559
|
+
}
|
|
560
|
+
configureMarked();
|
|
561
|
+
var TOKEN_CACHE_MAX = 500;
|
|
562
|
+
var tokenCache = /* @__PURE__ */ new Map();
|
|
563
|
+
var MD_SYNTAX_RE = /[#*`|[>\-_~]|\n\n|^\d+\. |\n\d+\. /;
|
|
564
|
+
function hasMarkdownSyntax(s) {
|
|
565
|
+
return MD_SYNTAX_RE.test(s.length > 500 ? s.slice(0, 500) : s);
|
|
566
|
+
}
|
|
567
|
+
function cachedLexer(content) {
|
|
568
|
+
if (!hasMarkdownSyntax(content)) {
|
|
569
|
+
return [{
|
|
570
|
+
type: "paragraph",
|
|
571
|
+
raw: content,
|
|
572
|
+
text: content,
|
|
573
|
+
tokens: [{ type: "text", raw: content, text: content }]
|
|
574
|
+
}];
|
|
575
|
+
}
|
|
576
|
+
const key = content;
|
|
577
|
+
const hit = tokenCache.get(key);
|
|
578
|
+
if (hit) {
|
|
579
|
+
tokenCache.delete(key);
|
|
580
|
+
tokenCache.set(key, hit);
|
|
581
|
+
return hit;
|
|
582
|
+
}
|
|
583
|
+
const tokens = marked.lexer(content);
|
|
584
|
+
if (tokenCache.size >= TOKEN_CACHE_MAX) {
|
|
585
|
+
const first = tokenCache.keys().next().value;
|
|
586
|
+
if (first !== void 0) tokenCache.delete(first);
|
|
587
|
+
}
|
|
588
|
+
tokenCache.set(key, tokens);
|
|
589
|
+
return tokens;
|
|
590
|
+
}
|
|
591
|
+
function renderInlineTokens(tokens) {
|
|
592
|
+
if (!tokens) return [];
|
|
593
|
+
return tokens.map((token, i) => {
|
|
594
|
+
switch (token.type) {
|
|
595
|
+
case "strong":
|
|
596
|
+
return /* @__PURE__ */ jsx10(Text9, { bold: true, children: token.text }, i);
|
|
597
|
+
case "em":
|
|
598
|
+
return /* @__PURE__ */ jsx10(Text9, { italic: true, children: token.text }, i);
|
|
599
|
+
case "codespan":
|
|
600
|
+
return /* @__PURE__ */ jsxs9(Text9, { color: "yellow", children: [
|
|
601
|
+
"`",
|
|
602
|
+
token.text,
|
|
603
|
+
"`"
|
|
604
|
+
] }, i);
|
|
605
|
+
case "link":
|
|
606
|
+
return /* @__PURE__ */ jsx10(Text9, { color: "blue", underline: true, children: token.text }, i);
|
|
607
|
+
case "text": {
|
|
608
|
+
const t = token;
|
|
609
|
+
if (t.tokens && t.tokens.length > 0) {
|
|
610
|
+
return /* @__PURE__ */ jsx10(React4.Fragment, { children: renderInlineTokens(t.tokens) }, i);
|
|
611
|
+
}
|
|
612
|
+
return /* @__PURE__ */ jsx10(Text9, { children: t.text }, i);
|
|
613
|
+
}
|
|
614
|
+
case "br":
|
|
615
|
+
return /* @__PURE__ */ jsx10(Text9, { children: "\n" }, i);
|
|
616
|
+
default:
|
|
617
|
+
return /* @__PURE__ */ jsx10(Text9, { children: token.raw }, i);
|
|
618
|
+
}
|
|
619
|
+
});
|
|
620
|
+
}
|
|
621
|
+
function Markdown({ children }) {
|
|
622
|
+
const elements = useMemo(() => {
|
|
623
|
+
const tokens = cachedLexer(children);
|
|
624
|
+
return tokens.map((token, i) => renderBlockToken(token, i));
|
|
625
|
+
}, [children]);
|
|
626
|
+
return /* @__PURE__ */ jsx10(Box8, { flexDirection: "column", children: elements });
|
|
627
|
+
}
|
|
628
|
+
function renderBlockToken(token, key) {
|
|
629
|
+
switch (token.type) {
|
|
630
|
+
case "heading": {
|
|
631
|
+
const h = token;
|
|
632
|
+
const isTopLevel = h.depth <= 2;
|
|
633
|
+
return /* @__PURE__ */ jsx10(Text9, { bold: true, color: isTopLevel ? "cyan" : void 0, children: h.text }, key);
|
|
634
|
+
}
|
|
635
|
+
case "paragraph": {
|
|
636
|
+
const p = token;
|
|
637
|
+
return /* @__PURE__ */ jsx10(Text9, { children: renderInlineTokens(p.tokens) }, key);
|
|
638
|
+
}
|
|
639
|
+
case "code": {
|
|
640
|
+
const c = token;
|
|
641
|
+
return /* @__PURE__ */ jsx10(Box8, { borderStyle: "single", paddingX: 1, children: /* @__PURE__ */ jsx10(Text9, { children: c.text }) }, key);
|
|
642
|
+
}
|
|
643
|
+
case "list": {
|
|
644
|
+
const l = token;
|
|
645
|
+
return /* @__PURE__ */ jsx10(Box8, { flexDirection: "column", children: l.items.map((item, j) => /* @__PURE__ */ jsxs9(Text9, { children: [
|
|
646
|
+
" ",
|
|
647
|
+
l.ordered ? `${j + 1}.` : "\u2022",
|
|
648
|
+
" ",
|
|
649
|
+
item.text
|
|
650
|
+
] }, j)) }, key);
|
|
651
|
+
}
|
|
652
|
+
case "blockquote": {
|
|
653
|
+
const bq = token;
|
|
654
|
+
return /* @__PURE__ */ jsxs9(Text9, { dimColor: true, children: [
|
|
655
|
+
"\u2502",
|
|
656
|
+
" ",
|
|
657
|
+
bq.text
|
|
658
|
+
] }, key);
|
|
659
|
+
}
|
|
660
|
+
case "hr":
|
|
661
|
+
return /* @__PURE__ */ jsx10(Text9, { dimColor: true, children: "\u2500".repeat(40) }, key);
|
|
662
|
+
case "space":
|
|
663
|
+
return null;
|
|
664
|
+
default:
|
|
665
|
+
return /* @__PURE__ */ jsx10(Text9, { children: token.raw }, key);
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
function StreamingMarkdown({ children }) {
|
|
669
|
+
const stablePrefixRef = useRef4("");
|
|
670
|
+
if (!children.startsWith(stablePrefixRef.current)) {
|
|
671
|
+
stablePrefixRef.current = "";
|
|
672
|
+
}
|
|
673
|
+
const boundary = stablePrefixRef.current.length;
|
|
674
|
+
const tokens = marked.lexer(children.substring(boundary));
|
|
675
|
+
let lastContentIdx = tokens.length - 1;
|
|
676
|
+
while (lastContentIdx >= 0 && tokens[lastContentIdx].type === "space") {
|
|
677
|
+
lastContentIdx--;
|
|
678
|
+
}
|
|
679
|
+
let advance = 0;
|
|
680
|
+
for (let i = 0; i < lastContentIdx; i++) {
|
|
681
|
+
advance += tokens[i].raw.length;
|
|
682
|
+
}
|
|
683
|
+
if (advance > 0) {
|
|
684
|
+
stablePrefixRef.current = children.substring(0, boundary + advance);
|
|
685
|
+
}
|
|
686
|
+
const stablePrefix = stablePrefixRef.current;
|
|
687
|
+
const unstableSuffix = children.substring(stablePrefix.length);
|
|
688
|
+
return /* @__PURE__ */ jsxs9(Box8, { flexDirection: "column", children: [
|
|
689
|
+
stablePrefix && /* @__PURE__ */ jsx10(Markdown, { children: stablePrefix }),
|
|
690
|
+
unstableSuffix && /* @__PURE__ */ jsx10(Markdown, { children: unstableSuffix })
|
|
691
|
+
] });
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
// src/views/IssueView.tsx
|
|
695
|
+
import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
696
|
+
var STATUS_FILTERS = [
|
|
697
|
+
"All",
|
|
698
|
+
"open",
|
|
699
|
+
"registered",
|
|
700
|
+
"in_progress",
|
|
701
|
+
"resolved",
|
|
702
|
+
"closed",
|
|
703
|
+
"deferred"
|
|
704
|
+
];
|
|
705
|
+
var TYPE_FILTERS = ["All", "bug", "feature", "improvement", "task"];
|
|
706
|
+
var PRIORITY_FILTERS = ["All", "low", "medium", "high", "urgent"];
|
|
707
|
+
var PRIORITY_COLORS = {
|
|
708
|
+
urgent: "red",
|
|
709
|
+
high: "yellow",
|
|
710
|
+
medium: "cyan",
|
|
711
|
+
low: "gray"
|
|
712
|
+
};
|
|
713
|
+
var CREATE_STEPS = ["title", "description", "type", "priority"];
|
|
714
|
+
var TYPE_OPTIONS = [
|
|
715
|
+
{ label: "Bug", value: "bug" },
|
|
716
|
+
{ label: "Feature", value: "feature" },
|
|
717
|
+
{ label: "Improvement", value: "improvement" },
|
|
718
|
+
{ label: "Task", value: "task" }
|
|
719
|
+
];
|
|
720
|
+
var PRIORITY_OPTIONS = [
|
|
721
|
+
{ label: "Low", value: "low" },
|
|
722
|
+
{ label: "Medium", value: "medium" },
|
|
723
|
+
{ label: "High", value: "high" },
|
|
724
|
+
{ label: "Urgent", value: "urgent" }
|
|
725
|
+
];
|
|
726
|
+
var STATUS_OPTIONS = [
|
|
727
|
+
{ label: "Open", value: "open" },
|
|
728
|
+
{ label: "Registered", value: "registered" },
|
|
729
|
+
{ label: "In Progress", value: "in_progress" },
|
|
730
|
+
{ label: "Resolved", value: "resolved" },
|
|
731
|
+
{ label: "Closed", value: "closed" },
|
|
732
|
+
{ label: "Deferred", value: "deferred" }
|
|
733
|
+
];
|
|
734
|
+
function IssueView() {
|
|
735
|
+
const [mode, setMode] = useState4("list");
|
|
736
|
+
const [statusFilterIndex, setStatusFilterIndex] = useState4(0);
|
|
737
|
+
const [typeFilterIndex, setTypeFilterIndex] = useState4(0);
|
|
738
|
+
const [priorityFilterIndex, setPriorityFilterIndex] = useState4(0);
|
|
739
|
+
const [activeFilterRow, setActiveFilterRow] = useState4(0);
|
|
740
|
+
const [selectedIssue, setSelectedIssue] = useState4(null);
|
|
741
|
+
const [searchQuery, setSearchQuery] = useState4("");
|
|
742
|
+
const [formStep, setFormStep] = useState4("title");
|
|
743
|
+
const [formTitle, setFormTitle] = useState4("");
|
|
744
|
+
const [formDesc, setFormDesc] = useState4("");
|
|
745
|
+
const [formType, setFormType] = useState4("bug");
|
|
746
|
+
const [formError, setFormError] = useState4("");
|
|
747
|
+
const baseUrl = useBaseUrl();
|
|
748
|
+
const { data: issues, loading, error, refetch } = useApi(
|
|
749
|
+
ISSUE_API_ENDPOINTS.ISSUES,
|
|
750
|
+
{ pollInterval: 5e3 }
|
|
751
|
+
);
|
|
752
|
+
const filteredIssues = useMemo2(() => {
|
|
753
|
+
if (!issues) return [];
|
|
754
|
+
let result = issues;
|
|
755
|
+
const statusFilter = STATUS_FILTERS[statusFilterIndex];
|
|
756
|
+
if (statusFilter !== "All") result = result.filter((i) => i.status === statusFilter);
|
|
757
|
+
const typeFilter = TYPE_FILTERS[typeFilterIndex];
|
|
758
|
+
if (typeFilter !== "All") result = result.filter((i) => i.type === typeFilter);
|
|
759
|
+
const prioFilter = PRIORITY_FILTERS[priorityFilterIndex];
|
|
760
|
+
if (prioFilter !== "All") result = result.filter((i) => i.priority === prioFilter);
|
|
761
|
+
if (searchQuery) {
|
|
762
|
+
const q = searchQuery.toLowerCase();
|
|
763
|
+
result = result.filter((i) => i.title.toLowerCase().includes(q));
|
|
764
|
+
}
|
|
765
|
+
return result;
|
|
766
|
+
}, [issues, statusFilterIndex, typeFilterIndex, priorityFilterIndex, searchQuery]);
|
|
767
|
+
const handleSelectIssue = useCallback4((issue) => {
|
|
768
|
+
setSelectedIssue(issue);
|
|
769
|
+
setMode("detail");
|
|
770
|
+
}, []);
|
|
771
|
+
const resetForm = useCallback4(() => {
|
|
772
|
+
setFormStep("title");
|
|
773
|
+
setFormTitle("");
|
|
774
|
+
setFormDesc("");
|
|
775
|
+
setFormType("bug");
|
|
776
|
+
setFormError("");
|
|
777
|
+
}, []);
|
|
778
|
+
const startEdit = useCallback4(() => {
|
|
779
|
+
if (!selectedIssue) return;
|
|
780
|
+
setFormTitle(selectedIssue.title);
|
|
781
|
+
setFormDesc(selectedIssue.description);
|
|
782
|
+
setFormType(selectedIssue.type);
|
|
783
|
+
setFormStep("title");
|
|
784
|
+
setFormError("");
|
|
785
|
+
setMode("edit");
|
|
786
|
+
}, [selectedIssue]);
|
|
787
|
+
const submitCreate = useCallback4(async (priority) => {
|
|
788
|
+
const body = {
|
|
789
|
+
title: formTitle,
|
|
790
|
+
description: formDesc,
|
|
791
|
+
type: formType,
|
|
792
|
+
priority
|
|
793
|
+
};
|
|
794
|
+
try {
|
|
795
|
+
await fetch(`${baseUrl}${ISSUE_API_ENDPOINTS.ISSUES}`, {
|
|
796
|
+
method: "POST",
|
|
797
|
+
headers: { "Content-Type": "application/json" },
|
|
798
|
+
body: JSON.stringify(body)
|
|
799
|
+
});
|
|
800
|
+
resetForm();
|
|
801
|
+
setMode("list");
|
|
802
|
+
refetch();
|
|
803
|
+
} catch (err) {
|
|
804
|
+
setFormError(err instanceof Error ? err.message : "Failed to create issue");
|
|
805
|
+
}
|
|
806
|
+
}, [baseUrl, formTitle, formDesc, formType, resetForm, refetch]);
|
|
807
|
+
const submitEdit = useCallback4(async (priority) => {
|
|
808
|
+
if (!selectedIssue) return;
|
|
809
|
+
try {
|
|
810
|
+
await fetch(`${baseUrl}${ISSUE_API_ENDPOINTS.ISSUES}/${selectedIssue.id}`, {
|
|
811
|
+
method: "PATCH",
|
|
812
|
+
headers: { "Content-Type": "application/json" },
|
|
813
|
+
body: JSON.stringify({ title: formTitle, description: formDesc, type: formType, priority })
|
|
814
|
+
});
|
|
815
|
+
resetForm();
|
|
816
|
+
setMode("list");
|
|
817
|
+
setSelectedIssue(null);
|
|
818
|
+
refetch();
|
|
819
|
+
} catch (err) {
|
|
820
|
+
setFormError(err instanceof Error ? err.message : "Failed to update issue");
|
|
821
|
+
}
|
|
822
|
+
}, [baseUrl, selectedIssue, formTitle, formDesc, formType, resetForm, refetch]);
|
|
823
|
+
const updateStatus = useCallback4(async (status) => {
|
|
824
|
+
if (!selectedIssue) return;
|
|
825
|
+
try {
|
|
826
|
+
await fetch(`${baseUrl}${ISSUE_API_ENDPOINTS.ISSUES}/${selectedIssue.id}`, {
|
|
827
|
+
method: "PATCH",
|
|
828
|
+
headers: { "Content-Type": "application/json" },
|
|
829
|
+
body: JSON.stringify({ status })
|
|
830
|
+
});
|
|
831
|
+
setMode("detail");
|
|
832
|
+
refetch();
|
|
833
|
+
} catch {
|
|
834
|
+
}
|
|
835
|
+
}, [baseUrl, selectedIssue, refetch]);
|
|
836
|
+
const performDelete = useCallback4(async () => {
|
|
837
|
+
if (!selectedIssue) return;
|
|
838
|
+
try {
|
|
839
|
+
await fetch(`${baseUrl}${ISSUE_API_ENDPOINTS.ISSUES}/${selectedIssue.id}`, {
|
|
840
|
+
method: "DELETE"
|
|
841
|
+
});
|
|
842
|
+
setMode("list");
|
|
843
|
+
setSelectedIssue(null);
|
|
844
|
+
refetch();
|
|
845
|
+
} catch {
|
|
846
|
+
}
|
|
847
|
+
}, [baseUrl, selectedIssue, refetch]);
|
|
848
|
+
useInput4(
|
|
849
|
+
(input, key) => {
|
|
850
|
+
if (key.escape) {
|
|
851
|
+
if (mode === "search") {
|
|
852
|
+
setSearchQuery("");
|
|
853
|
+
setMode("list");
|
|
854
|
+
return;
|
|
855
|
+
}
|
|
856
|
+
if (mode === "detail" || mode === "status-select") {
|
|
857
|
+
setMode("list");
|
|
858
|
+
setSelectedIssue(null);
|
|
859
|
+
return;
|
|
860
|
+
}
|
|
861
|
+
if (mode === "create" || mode === "edit") {
|
|
862
|
+
resetForm();
|
|
863
|
+
setMode(selectedIssue ? "detail" : "list");
|
|
864
|
+
return;
|
|
865
|
+
}
|
|
866
|
+
if (mode === "delete-confirm") {
|
|
867
|
+
setMode("detail");
|
|
868
|
+
return;
|
|
869
|
+
}
|
|
870
|
+
return;
|
|
871
|
+
}
|
|
872
|
+
if (mode === "list") {
|
|
873
|
+
if (input === "c" && !key.ctrl) {
|
|
874
|
+
resetForm();
|
|
875
|
+
setMode("create");
|
|
876
|
+
return;
|
|
877
|
+
}
|
|
878
|
+
if (input === "/") {
|
|
879
|
+
setSearchQuery("");
|
|
880
|
+
setMode("search");
|
|
881
|
+
return;
|
|
882
|
+
}
|
|
883
|
+
if (input === "f") {
|
|
884
|
+
setActiveFilterRow((prev) => (prev + 1) % 3);
|
|
885
|
+
return;
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
if (mode === "detail" && selectedIssue) {
|
|
889
|
+
if (input === "s") {
|
|
890
|
+
setMode("status-select");
|
|
891
|
+
return;
|
|
892
|
+
}
|
|
893
|
+
if (input === "e") {
|
|
894
|
+
startEdit();
|
|
895
|
+
return;
|
|
896
|
+
}
|
|
897
|
+
if (input === "d") {
|
|
898
|
+
setMode("delete-confirm");
|
|
899
|
+
return;
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
},
|
|
903
|
+
{ isActive: mode !== "search" && mode !== "create" && mode !== "edit" && mode !== "status-select" }
|
|
904
|
+
);
|
|
905
|
+
if (mode === "search") {
|
|
906
|
+
return /* @__PURE__ */ jsxs10(Box9, { flexDirection: "column", flexGrow: 1, children: [
|
|
907
|
+
/* @__PURE__ */ jsxs10(Box9, { marginBottom: 1, children: [
|
|
908
|
+
/* @__PURE__ */ jsx11(Text10, { bold: true, color: "cyan", children: "Search Issues" }),
|
|
909
|
+
/* @__PURE__ */ jsx11(Text10, { dimColor: true, children: " Esc=clear" })
|
|
910
|
+
] }),
|
|
911
|
+
/* @__PURE__ */ jsx11(
|
|
912
|
+
TextInput,
|
|
913
|
+
{
|
|
914
|
+
placeholder: "Search by title...",
|
|
915
|
+
defaultValue: searchQuery,
|
|
916
|
+
onChange: setSearchQuery,
|
|
917
|
+
onSubmit: () => setMode("list")
|
|
918
|
+
}
|
|
919
|
+
)
|
|
920
|
+
] });
|
|
921
|
+
}
|
|
922
|
+
if (mode === "status-select" && selectedIssue) {
|
|
923
|
+
return /* @__PURE__ */ jsxs10(Box9, { flexDirection: "column", padding: 1, children: [
|
|
924
|
+
/* @__PURE__ */ jsxs10(Text10, { bold: true, color: "cyan", children: [
|
|
925
|
+
"Change Status: ",
|
|
926
|
+
selectedIssue.title
|
|
927
|
+
] }),
|
|
928
|
+
/* @__PURE__ */ jsx11(Box9, { marginTop: 1, children: /* @__PURE__ */ jsx11(
|
|
929
|
+
Select,
|
|
930
|
+
{
|
|
931
|
+
options: STATUS_OPTIONS,
|
|
932
|
+
defaultValue: selectedIssue.status,
|
|
933
|
+
onChange: (value) => updateStatus(value)
|
|
934
|
+
}
|
|
935
|
+
) })
|
|
936
|
+
] });
|
|
937
|
+
}
|
|
938
|
+
if (mode === "delete-confirm" && selectedIssue) {
|
|
939
|
+
return /* @__PURE__ */ jsx11(
|
|
940
|
+
ConfirmDialog,
|
|
941
|
+
{
|
|
942
|
+
message: `Delete "${selectedIssue.title}"?`,
|
|
943
|
+
onConfirm: performDelete,
|
|
944
|
+
onCancel: () => setMode("detail")
|
|
945
|
+
}
|
|
946
|
+
);
|
|
947
|
+
}
|
|
948
|
+
if (mode === "detail" && selectedIssue) {
|
|
949
|
+
return /* @__PURE__ */ jsxs10(Box9, { flexDirection: "column", flexGrow: 1, children: [
|
|
950
|
+
/* @__PURE__ */ jsxs10(Box9, { marginBottom: 1, children: [
|
|
951
|
+
/* @__PURE__ */ jsxs10(Text10, { bold: true, color: "cyan", children: [
|
|
952
|
+
"Issue: ",
|
|
953
|
+
selectedIssue.id
|
|
954
|
+
] }),
|
|
955
|
+
/* @__PURE__ */ jsx11(Text10, { dimColor: true, children: " Esc=back [s]tatus [e]dit [d]elete" })
|
|
956
|
+
] }),
|
|
957
|
+
/* @__PURE__ */ jsx11(
|
|
958
|
+
SplitPane,
|
|
959
|
+
{
|
|
960
|
+
ratio: 45,
|
|
961
|
+
left: /* @__PURE__ */ jsxs10(Box9, { flexDirection: "column", paddingRight: 1, children: [
|
|
962
|
+
/* @__PURE__ */ jsx11(Text10, { bold: true, children: selectedIssue.title }),
|
|
963
|
+
/* @__PURE__ */ jsxs10(Box9, { marginTop: 1, flexDirection: "column", children: [
|
|
964
|
+
/* @__PURE__ */ jsxs10(Box9, { gap: 1, children: [
|
|
965
|
+
/* @__PURE__ */ jsx11(Text10, { dimColor: true, children: "Type:" }),
|
|
966
|
+
/* @__PURE__ */ jsx11(Text10, { children: selectedIssue.type })
|
|
967
|
+
] }),
|
|
968
|
+
/* @__PURE__ */ jsxs10(Box9, { gap: 1, children: [
|
|
969
|
+
/* @__PURE__ */ jsx11(Text10, { dimColor: true, children: "Priority:" }),
|
|
970
|
+
/* @__PURE__ */ jsx11(Text10, { color: PRIORITY_COLORS[selectedIssue.priority], children: selectedIssue.priority })
|
|
971
|
+
] }),
|
|
972
|
+
/* @__PURE__ */ jsxs10(Box9, { gap: 1, children: [
|
|
973
|
+
/* @__PURE__ */ jsx11(Text10, { dimColor: true, children: "Status:" }),
|
|
974
|
+
/* @__PURE__ */ jsx11(StatusDot, { status: selectedIssue.status, showLabel: true })
|
|
975
|
+
] }),
|
|
976
|
+
/* @__PURE__ */ jsxs10(Box9, { gap: 1, children: [
|
|
977
|
+
/* @__PURE__ */ jsx11(Text10, { dimColor: true, children: "Created:" }),
|
|
978
|
+
/* @__PURE__ */ jsx11(Text10, { children: selectedIssue.created_at?.slice(0, 10) ?? "-" })
|
|
979
|
+
] }),
|
|
980
|
+
/* @__PURE__ */ jsxs10(Box9, { gap: 1, children: [
|
|
981
|
+
/* @__PURE__ */ jsx11(Text10, { dimColor: true, children: "Updated:" }),
|
|
982
|
+
/* @__PURE__ */ jsx11(Text10, { children: selectedIssue.updated_at?.slice(0, 10) ?? "-" })
|
|
983
|
+
] }),
|
|
984
|
+
selectedIssue.executor && /* @__PURE__ */ jsxs10(Box9, { gap: 1, children: [
|
|
985
|
+
/* @__PURE__ */ jsx11(Text10, { dimColor: true, children: "Executor:" }),
|
|
986
|
+
/* @__PURE__ */ jsx11(Text10, { children: selectedIssue.executor })
|
|
987
|
+
] })
|
|
988
|
+
] }),
|
|
989
|
+
/* @__PURE__ */ jsxs10(Box9, { marginTop: 1, flexDirection: "column", children: [
|
|
990
|
+
/* @__PURE__ */ jsx11(Text10, { dimColor: true, children: "Description:" }),
|
|
991
|
+
/* @__PURE__ */ jsx11(Text10, { children: selectedIssue.description })
|
|
992
|
+
] })
|
|
993
|
+
] }),
|
|
994
|
+
right: /* @__PURE__ */ jsxs10(Box9, { flexDirection: "column", paddingLeft: 1, children: [
|
|
995
|
+
selectedIssue.analysis ? /* @__PURE__ */ jsxs10(Box9, { flexDirection: "column", children: [
|
|
996
|
+
/* @__PURE__ */ jsx11(Text10, { bold: true, color: "magenta", children: "Analysis" }),
|
|
997
|
+
/* @__PURE__ */ jsxs10(Box9, { gap: 1, children: [
|
|
998
|
+
/* @__PURE__ */ jsx11(Text10, { dimColor: true, children: "Root cause:" }),
|
|
999
|
+
/* @__PURE__ */ jsx11(Text10, { children: selectedIssue.analysis.root_cause })
|
|
1000
|
+
] }),
|
|
1001
|
+
/* @__PURE__ */ jsxs10(Box9, { gap: 1, children: [
|
|
1002
|
+
/* @__PURE__ */ jsx11(Text10, { dimColor: true, children: "Impact:" }),
|
|
1003
|
+
/* @__PURE__ */ jsx11(Text10, { children: selectedIssue.analysis.impact })
|
|
1004
|
+
] }),
|
|
1005
|
+
/* @__PURE__ */ jsxs10(Box9, { gap: 1, children: [
|
|
1006
|
+
/* @__PURE__ */ jsx11(Text10, { dimColor: true, children: "Confidence:" }),
|
|
1007
|
+
/* @__PURE__ */ jsxs10(Text10, { children: [
|
|
1008
|
+
(selectedIssue.analysis.confidence * 100).toFixed(0),
|
|
1009
|
+
"%"
|
|
1010
|
+
] })
|
|
1011
|
+
] }),
|
|
1012
|
+
/* @__PURE__ */ jsxs10(Box9, { gap: 1, children: [
|
|
1013
|
+
/* @__PURE__ */ jsx11(Text10, { dimColor: true, children: "Approach:" }),
|
|
1014
|
+
/* @__PURE__ */ jsx11(Text10, { children: selectedIssue.analysis.suggested_approach })
|
|
1015
|
+
] }),
|
|
1016
|
+
selectedIssue.analysis.related_files.length > 0 && /* @__PURE__ */ jsxs10(Box9, { flexDirection: "column", marginTop: 1, children: [
|
|
1017
|
+
/* @__PURE__ */ jsx11(Text10, { dimColor: true, children: "Related files:" }),
|
|
1018
|
+
selectedIssue.analysis.related_files.map((f, i) => /* @__PURE__ */ jsxs10(Text10, { children: [
|
|
1019
|
+
" ",
|
|
1020
|
+
f
|
|
1021
|
+
] }, i))
|
|
1022
|
+
] })
|
|
1023
|
+
] }) : /* @__PURE__ */ jsx11(Text10, { dimColor: true, children: "No analysis available" }),
|
|
1024
|
+
selectedIssue.solution ? /* @__PURE__ */ jsxs10(Box9, { flexDirection: "column", marginTop: 1, children: [
|
|
1025
|
+
/* @__PURE__ */ jsx11(Text10, { bold: true, color: "green", children: "Solution" }),
|
|
1026
|
+
selectedIssue.solution.steps.map((s, i) => /* @__PURE__ */ jsxs10(Box9, { gap: 1, children: [
|
|
1027
|
+
/* @__PURE__ */ jsxs10(Text10, { dimColor: true, children: [
|
|
1028
|
+
i + 1,
|
|
1029
|
+
"."
|
|
1030
|
+
] }),
|
|
1031
|
+
/* @__PURE__ */ jsx11(Text10, { children: s.description }),
|
|
1032
|
+
s.target && /* @__PURE__ */ jsxs10(Text10, { dimColor: true, children: [
|
|
1033
|
+
"(",
|
|
1034
|
+
s.target,
|
|
1035
|
+
")"
|
|
1036
|
+
] })
|
|
1037
|
+
] }, i)),
|
|
1038
|
+
selectedIssue.solution.context && /* @__PURE__ */ jsx11(Box9, { marginTop: 1, children: /* @__PURE__ */ jsxs10(Text10, { dimColor: true, children: [
|
|
1039
|
+
"Context: ",
|
|
1040
|
+
selectedIssue.solution.context
|
|
1041
|
+
] }) })
|
|
1042
|
+
] }) : /* @__PURE__ */ jsx11(Box9, { marginTop: 1, children: /* @__PURE__ */ jsx11(Text10, { dimColor: true, children: "No solution planned" }) })
|
|
1043
|
+
] })
|
|
1044
|
+
}
|
|
1045
|
+
)
|
|
1046
|
+
] });
|
|
1047
|
+
}
|
|
1048
|
+
if (mode === "create" || mode === "edit") {
|
|
1049
|
+
const isEdit = mode === "edit";
|
|
1050
|
+
const stepIndex = CREATE_STEPS.indexOf(formStep);
|
|
1051
|
+
return /* @__PURE__ */ jsxs10(Box9, { flexDirection: "column", flexGrow: 1, children: [
|
|
1052
|
+
/* @__PURE__ */ jsxs10(Box9, { marginBottom: 1, children: [
|
|
1053
|
+
/* @__PURE__ */ jsx11(Text10, { bold: true, color: "cyan", children: isEdit ? "Edit Issue" : "Create Issue" }),
|
|
1054
|
+
/* @__PURE__ */ jsxs10(Text10, { dimColor: true, children: [
|
|
1055
|
+
" (Step ",
|
|
1056
|
+
stepIndex + 1,
|
|
1057
|
+
"/",
|
|
1058
|
+
CREATE_STEPS.length,
|
|
1059
|
+
") Esc=cancel"
|
|
1060
|
+
] })
|
|
1061
|
+
] }),
|
|
1062
|
+
/* @__PURE__ */ jsx11(Box9, { gap: 1, marginBottom: 1, children: CREATE_STEPS.map((s, i) => /* @__PURE__ */ jsxs10(Text10, { bold: s === formStep, color: i < stepIndex ? "green" : s === formStep ? "cyan" : "gray", children: [
|
|
1063
|
+
i < stepIndex ? "[x]" : s === formStep ? "[>]" : "[ ]",
|
|
1064
|
+
" ",
|
|
1065
|
+
s
|
|
1066
|
+
] }, s)) }),
|
|
1067
|
+
formStep === "title" && /* @__PURE__ */ jsxs10(Box9, { flexDirection: "column", children: [
|
|
1068
|
+
/* @__PURE__ */ jsx11(Text10, { children: "Title:" }),
|
|
1069
|
+
/* @__PURE__ */ jsx11(TextInput, { placeholder: "Enter issue title...", defaultValue: formTitle, onChange: setFormTitle, onSubmit: () => setFormStep("description") })
|
|
1070
|
+
] }),
|
|
1071
|
+
formStep === "description" && /* @__PURE__ */ jsxs10(Box9, { flexDirection: "column", children: [
|
|
1072
|
+
/* @__PURE__ */ jsx11(Text10, { children: "Description:" }),
|
|
1073
|
+
/* @__PURE__ */ jsx11(TextInput, { placeholder: "Enter issue description...", defaultValue: formDesc, onChange: setFormDesc, onSubmit: () => setFormStep("type") })
|
|
1074
|
+
] }),
|
|
1075
|
+
formStep === "type" && /* @__PURE__ */ jsxs10(Box9, { flexDirection: "column", children: [
|
|
1076
|
+
/* @__PURE__ */ jsx11(Text10, { children: "Type:" }),
|
|
1077
|
+
/* @__PURE__ */ jsx11(Select, { options: TYPE_OPTIONS, defaultValue: formType, onChange: (value) => {
|
|
1078
|
+
setFormType(value);
|
|
1079
|
+
setFormStep("priority");
|
|
1080
|
+
} })
|
|
1081
|
+
] }),
|
|
1082
|
+
formStep === "priority" && /* @__PURE__ */ jsxs10(Box9, { flexDirection: "column", children: [
|
|
1083
|
+
/* @__PURE__ */ jsx11(Text10, { children: "Priority:" }),
|
|
1084
|
+
/* @__PURE__ */ jsx11(Select, { options: PRIORITY_OPTIONS, defaultValue: "medium", onChange: (value) => {
|
|
1085
|
+
isEdit ? submitEdit(value) : submitCreate(value);
|
|
1086
|
+
} })
|
|
1087
|
+
] }),
|
|
1088
|
+
formError && /* @__PURE__ */ jsx11(Box9, { marginTop: 1, children: /* @__PURE__ */ jsxs10(Text10, { color: "red", children: [
|
|
1089
|
+
"Error: ",
|
|
1090
|
+
formError
|
|
1091
|
+
] }) }),
|
|
1092
|
+
stepIndex > 0 && /* @__PURE__ */ jsxs10(Box9, { flexDirection: "column", marginTop: 1, borderStyle: "single", paddingX: 1, children: [
|
|
1093
|
+
/* @__PURE__ */ jsx11(Text10, { dimColor: true, bold: true, children: "Filled:" }),
|
|
1094
|
+
formTitle && /* @__PURE__ */ jsxs10(Text10, { dimColor: true, children: [
|
|
1095
|
+
" Title: ",
|
|
1096
|
+
formTitle
|
|
1097
|
+
] }),
|
|
1098
|
+
formDesc && /* @__PURE__ */ jsxs10(Text10, { dimColor: true, children: [
|
|
1099
|
+
" Description: ",
|
|
1100
|
+
formDesc.slice(0, 60),
|
|
1101
|
+
formDesc.length > 60 ? "..." : ""
|
|
1102
|
+
] }),
|
|
1103
|
+
stepIndex > 2 && /* @__PURE__ */ jsxs10(Text10, { dimColor: true, children: [
|
|
1104
|
+
" Type: ",
|
|
1105
|
+
formType
|
|
1106
|
+
] })
|
|
1107
|
+
] })
|
|
1108
|
+
] });
|
|
1109
|
+
}
|
|
1110
|
+
return /* @__PURE__ */ jsx11(
|
|
1111
|
+
ListMode,
|
|
1112
|
+
{
|
|
1113
|
+
issues: filteredIssues,
|
|
1114
|
+
loading,
|
|
1115
|
+
error,
|
|
1116
|
+
statusFilterIndex,
|
|
1117
|
+
typeFilterIndex,
|
|
1118
|
+
priorityFilterIndex,
|
|
1119
|
+
activeFilterRow,
|
|
1120
|
+
onStatusFilterChange: setStatusFilterIndex,
|
|
1121
|
+
onTypeFilterChange: setTypeFilterIndex,
|
|
1122
|
+
onPriorityFilterChange: setPriorityFilterIndex,
|
|
1123
|
+
onSelect: handleSelectIssue,
|
|
1124
|
+
searchQuery
|
|
1125
|
+
}
|
|
1126
|
+
);
|
|
1127
|
+
}
|
|
1128
|
+
function ListMode({
|
|
1129
|
+
issues,
|
|
1130
|
+
loading,
|
|
1131
|
+
error,
|
|
1132
|
+
statusFilterIndex,
|
|
1133
|
+
typeFilterIndex,
|
|
1134
|
+
priorityFilterIndex,
|
|
1135
|
+
activeFilterRow,
|
|
1136
|
+
onStatusFilterChange,
|
|
1137
|
+
onTypeFilterChange,
|
|
1138
|
+
onPriorityFilterChange,
|
|
1139
|
+
onSelect,
|
|
1140
|
+
searchQuery
|
|
1141
|
+
}) {
|
|
1142
|
+
const renderItem = useCallback4(
|
|
1143
|
+
(issue, _index, isSelected) => /* @__PURE__ */ jsxs10(Box9, { gap: 1, children: [
|
|
1144
|
+
/* @__PURE__ */ jsx11(Text10, { color: isSelected ? "cyan" : "gray", dimColor: !isSelected, children: issue.id.slice(0, 8) }),
|
|
1145
|
+
/* @__PURE__ */ jsx11(StatusDot, { status: issue.status, showLabel: false }),
|
|
1146
|
+
/* @__PURE__ */ jsx11(Text10, { color: isSelected ? "cyan" : void 0, wrap: "truncate", children: issue.title }),
|
|
1147
|
+
/* @__PURE__ */ jsxs10(Text10, { color: PRIORITY_COLORS[issue.priority], children: [
|
|
1148
|
+
"[",
|
|
1149
|
+
issue.priority,
|
|
1150
|
+
"]"
|
|
1151
|
+
] })
|
|
1152
|
+
] }),
|
|
1153
|
+
[]
|
|
1154
|
+
);
|
|
1155
|
+
if (error) {
|
|
1156
|
+
return /* @__PURE__ */ jsxs10(Box9, { flexDirection: "column", padding: 1, children: [
|
|
1157
|
+
/* @__PURE__ */ jsx11(Text10, { bold: true, color: "cyan", children: "Issues" }),
|
|
1158
|
+
/* @__PURE__ */ jsxs10(Text10, { color: "red", children: [
|
|
1159
|
+
"Error: ",
|
|
1160
|
+
error.message
|
|
1161
|
+
] })
|
|
1162
|
+
] });
|
|
1163
|
+
}
|
|
1164
|
+
return /* @__PURE__ */ jsxs10(Box9, { flexDirection: "column", flexGrow: 1, children: [
|
|
1165
|
+
/* @__PURE__ */ jsxs10(Box9, { marginBottom: 1, gap: 2, children: [
|
|
1166
|
+
/* @__PURE__ */ jsx11(Text10, { bold: true, color: "cyan", children: "Issues" }),
|
|
1167
|
+
loading && !issues.length && /* @__PURE__ */ jsx11(Text10, { dimColor: true, children: "Loading..." }),
|
|
1168
|
+
/* @__PURE__ */ jsxs10(Text10, { dimColor: true, children: [
|
|
1169
|
+
"(",
|
|
1170
|
+
issues.length,
|
|
1171
|
+
" shown) [c]reate [/]search [f]ilter-row [Tab]cycle"
|
|
1172
|
+
] })
|
|
1173
|
+
] }),
|
|
1174
|
+
searchQuery && /* @__PURE__ */ jsxs10(Box9, { marginBottom: 1, children: [
|
|
1175
|
+
/* @__PURE__ */ jsx11(Text10, { dimColor: true, children: "Search: " }),
|
|
1176
|
+
/* @__PURE__ */ jsx11(Text10, { color: "yellow", children: searchQuery })
|
|
1177
|
+
] }),
|
|
1178
|
+
/* @__PURE__ */ jsxs10(Box9, { flexDirection: "column", gap: 0, children: [
|
|
1179
|
+
/* @__PURE__ */ jsxs10(Box9, { gap: 1, children: [
|
|
1180
|
+
/* @__PURE__ */ jsx11(Text10, { dimColor: true, bold: activeFilterRow === 0, color: activeFilterRow === 0 ? "cyan" : void 0, children: "Status:" }),
|
|
1181
|
+
/* @__PURE__ */ jsx11(FilterBar, { options: STATUS_FILTERS, activeIndex: statusFilterIndex, onSelect: onStatusFilterChange, isFocused: activeFilterRow === 0 })
|
|
1182
|
+
] }),
|
|
1183
|
+
/* @__PURE__ */ jsxs10(Box9, { gap: 1, children: [
|
|
1184
|
+
/* @__PURE__ */ jsx11(Text10, { dimColor: true, bold: activeFilterRow === 1, color: activeFilterRow === 1 ? "cyan" : void 0, children: "Type:" }),
|
|
1185
|
+
/* @__PURE__ */ jsx11(FilterBar, { options: TYPE_FILTERS, activeIndex: typeFilterIndex, onSelect: onTypeFilterChange, isFocused: activeFilterRow === 1 })
|
|
1186
|
+
] }),
|
|
1187
|
+
/* @__PURE__ */ jsxs10(Box9, { gap: 1, children: [
|
|
1188
|
+
/* @__PURE__ */ jsx11(Text10, { dimColor: true, bold: activeFilterRow === 2, color: activeFilterRow === 2 ? "cyan" : void 0, children: "Priority:" }),
|
|
1189
|
+
/* @__PURE__ */ jsx11(FilterBar, { options: PRIORITY_FILTERS, activeIndex: priorityFilterIndex, onSelect: onPriorityFilterChange, isFocused: activeFilterRow === 2 })
|
|
1190
|
+
] })
|
|
1191
|
+
] }),
|
|
1192
|
+
/* @__PURE__ */ jsx11(Box9, { marginTop: 1, flexGrow: 1, flexDirection: "column", children: /* @__PURE__ */ jsx11(
|
|
1193
|
+
ScrollableList,
|
|
1194
|
+
{
|
|
1195
|
+
items: issues,
|
|
1196
|
+
renderItem,
|
|
1197
|
+
onSelect
|
|
1198
|
+
}
|
|
1199
|
+
) })
|
|
1200
|
+
] });
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
// src/views/WorkflowView.tsx
|
|
1204
|
+
import { useState as useState5, useCallback as useCallback5, useMemo as useMemo3 } from "react";
|
|
1205
|
+
import { Box as Box10, Text as Text11, useInput as useInput5 } from "ink";
|
|
1206
|
+
import { TextInput as TextInput2 } from "@inkjs/ui";
|
|
1207
|
+
import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1208
|
+
var TASK_COLUMNS = [
|
|
1209
|
+
{ key: "id", label: "ID", width: 12 },
|
|
1210
|
+
{ key: "title", label: "Title", width: 40 },
|
|
1211
|
+
{
|
|
1212
|
+
key: "meta",
|
|
1213
|
+
label: "Status",
|
|
1214
|
+
width: 14,
|
|
1215
|
+
render: (_value, row) => /* @__PURE__ */ jsx12(StatusDot, { status: row.meta.status, showLabel: true })
|
|
1216
|
+
},
|
|
1217
|
+
{ key: "action", label: "Action", width: 16 }
|
|
1218
|
+
];
|
|
1219
|
+
function WorkflowView() {
|
|
1220
|
+
const [mode, setMode] = useState5("phases");
|
|
1221
|
+
const [selectedPhase, setSelectedPhase] = useState5(null);
|
|
1222
|
+
const [selectedTaskIdx, setSelectedTaskIdx] = useState5(0);
|
|
1223
|
+
const [commandInput, setCommandInput] = useState5("");
|
|
1224
|
+
const { send } = useWs();
|
|
1225
|
+
const { data: phases, loading, error } = useApi(
|
|
1226
|
+
API_ENDPOINTS.PHASES,
|
|
1227
|
+
{ pollInterval: 5e3 }
|
|
1228
|
+
);
|
|
1229
|
+
const phaseNum = selectedPhase?.phase;
|
|
1230
|
+
const tasksEndpoint = phaseNum != null ? API_ENDPOINTS.PHASE_TASKS.replace(":n", String(phaseNum)) : "/___noop___";
|
|
1231
|
+
const { data: tasks, loading: tasksLoading } = useApi(
|
|
1232
|
+
tasksEndpoint,
|
|
1233
|
+
{ skip: phaseNum == null, pollInterval: 5e3 }
|
|
1234
|
+
);
|
|
1235
|
+
const coordinateStatus = useWsEvent("coordinate:status");
|
|
1236
|
+
const handleSelectPhase = useCallback5((phase) => {
|
|
1237
|
+
setSelectedPhase(phase);
|
|
1238
|
+
setSelectedTaskIdx(0);
|
|
1239
|
+
setMode("tasks");
|
|
1240
|
+
}, []);
|
|
1241
|
+
const handleSendCommand = useCallback5((value) => {
|
|
1242
|
+
const trimmed = value.trim();
|
|
1243
|
+
if (!trimmed) return;
|
|
1244
|
+
send({ action: "coordinate:start", intent: trimmed });
|
|
1245
|
+
setCommandInput("");
|
|
1246
|
+
}, [send]);
|
|
1247
|
+
const selectedTask = useMemo3(() => {
|
|
1248
|
+
if (!tasks || selectedTaskIdx >= tasks.length) return null;
|
|
1249
|
+
return tasks[selectedTaskIdx] ?? null;
|
|
1250
|
+
}, [tasks, selectedTaskIdx]);
|
|
1251
|
+
useInput5(
|
|
1252
|
+
(input, key) => {
|
|
1253
|
+
if (key.escape) {
|
|
1254
|
+
if (mode === "coordinate") {
|
|
1255
|
+
setMode("tasks");
|
|
1256
|
+
return;
|
|
1257
|
+
}
|
|
1258
|
+
if (mode === "taskDetail") {
|
|
1259
|
+
setMode("tasks");
|
|
1260
|
+
return;
|
|
1261
|
+
}
|
|
1262
|
+
if (mode === "phaseDetail") {
|
|
1263
|
+
setMode("tasks");
|
|
1264
|
+
return;
|
|
1265
|
+
}
|
|
1266
|
+
if (mode === "tasks") {
|
|
1267
|
+
setMode("phases");
|
|
1268
|
+
setSelectedPhase(null);
|
|
1269
|
+
return;
|
|
1270
|
+
}
|
|
1271
|
+
return;
|
|
1272
|
+
}
|
|
1273
|
+
if (mode === "tasks") {
|
|
1274
|
+
if (input === "x" && !key.ctrl) {
|
|
1275
|
+
setMode("coordinate");
|
|
1276
|
+
return;
|
|
1277
|
+
}
|
|
1278
|
+
if (input === "p") {
|
|
1279
|
+
setMode("phaseDetail");
|
|
1280
|
+
return;
|
|
1281
|
+
}
|
|
1282
|
+
if (key.return && selectedTask) {
|
|
1283
|
+
setMode("taskDetail");
|
|
1284
|
+
return;
|
|
1285
|
+
}
|
|
1286
|
+
if (key.upArrow && selectedTaskIdx > 0) {
|
|
1287
|
+
setSelectedTaskIdx(selectedTaskIdx - 1);
|
|
1288
|
+
return;
|
|
1289
|
+
}
|
|
1290
|
+
if (key.downArrow && tasks && selectedTaskIdx < tasks.length - 1) {
|
|
1291
|
+
setSelectedTaskIdx(selectedTaskIdx + 1);
|
|
1292
|
+
return;
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
},
|
|
1296
|
+
{ isActive: true }
|
|
1297
|
+
);
|
|
1298
|
+
if (mode === "taskDetail" && selectedTask) {
|
|
1299
|
+
return /* @__PURE__ */ jsxs11(Box10, { flexDirection: "column", flexGrow: 1, children: [
|
|
1300
|
+
/* @__PURE__ */ jsxs11(Box10, { marginBottom: 1, children: [
|
|
1301
|
+
/* @__PURE__ */ jsxs11(Text11, { bold: true, color: "cyan", children: [
|
|
1302
|
+
"Task: ",
|
|
1303
|
+
selectedTask.id
|
|
1304
|
+
] }),
|
|
1305
|
+
/* @__PURE__ */ jsx12(Text11, { dimColor: true, children: " Esc=back" })
|
|
1306
|
+
] }),
|
|
1307
|
+
/* @__PURE__ */ jsx12(
|
|
1308
|
+
SplitPane,
|
|
1309
|
+
{
|
|
1310
|
+
ratio: 50,
|
|
1311
|
+
left: /* @__PURE__ */ jsxs11(Box10, { flexDirection: "column", paddingRight: 1, children: [
|
|
1312
|
+
/* @__PURE__ */ jsx12(Text11, { bold: true, children: selectedTask.title }),
|
|
1313
|
+
/* @__PURE__ */ jsxs11(Box10, { marginTop: 1, flexDirection: "column", children: [
|
|
1314
|
+
/* @__PURE__ */ jsxs11(Box10, { gap: 1, children: [
|
|
1315
|
+
/* @__PURE__ */ jsx12(Text11, { dimColor: true, children: "ID:" }),
|
|
1316
|
+
/* @__PURE__ */ jsx12(Text11, { children: selectedTask.id })
|
|
1317
|
+
] }),
|
|
1318
|
+
/* @__PURE__ */ jsxs11(Box10, { gap: 1, children: [
|
|
1319
|
+
/* @__PURE__ */ jsx12(Text11, { dimColor: true, children: "Action:" }),
|
|
1320
|
+
/* @__PURE__ */ jsx12(Text11, { children: selectedTask.action })
|
|
1321
|
+
] }),
|
|
1322
|
+
/* @__PURE__ */ jsxs11(Box10, { gap: 1, children: [
|
|
1323
|
+
/* @__PURE__ */ jsx12(Text11, { dimColor: true, children: "Status:" }),
|
|
1324
|
+
/* @__PURE__ */ jsx12(StatusDot, { status: selectedTask.meta.status, showLabel: true })
|
|
1325
|
+
] })
|
|
1326
|
+
] })
|
|
1327
|
+
] }),
|
|
1328
|
+
right: /* @__PURE__ */ jsxs11(Box10, { flexDirection: "column", paddingLeft: 1, children: [
|
|
1329
|
+
selectedTask.description && /* @__PURE__ */ jsxs11(Box10, { flexDirection: "column", children: [
|
|
1330
|
+
/* @__PURE__ */ jsx12(Text11, { bold: true, dimColor: true, children: "Description" }),
|
|
1331
|
+
/* @__PURE__ */ jsx12(Text11, { children: selectedTask.description })
|
|
1332
|
+
] }),
|
|
1333
|
+
selectedTask.files && selectedTask.files.length > 0 && /* @__PURE__ */ jsxs11(Box10, { flexDirection: "column", marginTop: 1, children: [
|
|
1334
|
+
/* @__PURE__ */ jsx12(Text11, { bold: true, dimColor: true, children: "Files" }),
|
|
1335
|
+
selectedTask.files.map((f, i) => /* @__PURE__ */ jsxs11(Box10, { gap: 1, children: [
|
|
1336
|
+
/* @__PURE__ */ jsxs11(Text11, { color: f.action === "create" ? "green" : f.action === "modify" ? "yellow" : "red", children: [
|
|
1337
|
+
"[",
|
|
1338
|
+
f.action,
|
|
1339
|
+
"]"
|
|
1340
|
+
] }),
|
|
1341
|
+
/* @__PURE__ */ jsx12(Text11, { children: f.path }),
|
|
1342
|
+
f.target && /* @__PURE__ */ jsxs11(Text11, { dimColor: true, children: [
|
|
1343
|
+
"(",
|
|
1344
|
+
f.target,
|
|
1345
|
+
")"
|
|
1346
|
+
] })
|
|
1347
|
+
] }, i))
|
|
1348
|
+
] }),
|
|
1349
|
+
selectedTask.convergence?.criteria && selectedTask.convergence.criteria.length > 0 && /* @__PURE__ */ jsxs11(Box10, { flexDirection: "column", marginTop: 1, children: [
|
|
1350
|
+
/* @__PURE__ */ jsx12(Text11, { bold: true, dimColor: true, children: "Convergence Criteria" }),
|
|
1351
|
+
selectedTask.convergence.criteria.map((c, i) => /* @__PURE__ */ jsxs11(Text11, { dimColor: true, children: [
|
|
1352
|
+
" - ",
|
|
1353
|
+
c
|
|
1354
|
+
] }, i))
|
|
1355
|
+
] })
|
|
1356
|
+
] })
|
|
1357
|
+
}
|
|
1358
|
+
)
|
|
1359
|
+
] });
|
|
1360
|
+
}
|
|
1361
|
+
if (mode === "phaseDetail" && selectedPhase) {
|
|
1362
|
+
return /* @__PURE__ */ jsxs11(Box10, { flexDirection: "column", flexGrow: 1, children: [
|
|
1363
|
+
/* @__PURE__ */ jsxs11(Box10, { marginBottom: 1, children: [
|
|
1364
|
+
/* @__PURE__ */ jsxs11(Text11, { bold: true, color: "cyan", children: [
|
|
1365
|
+
"Phase ",
|
|
1366
|
+
selectedPhase.phase,
|
|
1367
|
+
": ",
|
|
1368
|
+
selectedPhase.title
|
|
1369
|
+
] }),
|
|
1370
|
+
/* @__PURE__ */ jsx12(Text11, { dimColor: true, children: " Esc=back" })
|
|
1371
|
+
] }),
|
|
1372
|
+
/* @__PURE__ */ jsxs11(Box10, { flexDirection: "column", children: [
|
|
1373
|
+
/* @__PURE__ */ jsxs11(Box10, { gap: 1, children: [
|
|
1374
|
+
/* @__PURE__ */ jsx12(Text11, { dimColor: true, children: "Status:" }),
|
|
1375
|
+
/* @__PURE__ */ jsx12(StatusDot, { status: selectedPhase.status, showLabel: true })
|
|
1376
|
+
] }),
|
|
1377
|
+
/* @__PURE__ */ jsxs11(Box10, { gap: 1, children: [
|
|
1378
|
+
/* @__PURE__ */ jsx12(Text11, { dimColor: true, children: "Progress:" }),
|
|
1379
|
+
/* @__PURE__ */ jsxs11(Text11, { children: [
|
|
1380
|
+
selectedPhase.execution.tasks_completed,
|
|
1381
|
+
"/",
|
|
1382
|
+
selectedPhase.execution.tasks_total,
|
|
1383
|
+
" tasks"
|
|
1384
|
+
] })
|
|
1385
|
+
] }),
|
|
1386
|
+
selectedPhase.goal && /* @__PURE__ */ jsxs11(Box10, { flexDirection: "column", marginTop: 1, children: [
|
|
1387
|
+
/* @__PURE__ */ jsx12(Text11, { bold: true, dimColor: true, children: "Goal" }),
|
|
1388
|
+
/* @__PURE__ */ jsx12(Text11, { children: selectedPhase.goal })
|
|
1389
|
+
] }),
|
|
1390
|
+
selectedPhase.success_criteria && selectedPhase.success_criteria.length > 0 && /* @__PURE__ */ jsxs11(Box10, { flexDirection: "column", marginTop: 1, children: [
|
|
1391
|
+
/* @__PURE__ */ jsx12(Text11, { bold: true, dimColor: true, children: "Success Criteria" }),
|
|
1392
|
+
selectedPhase.success_criteria.map((c, i) => /* @__PURE__ */ jsxs11(Text11, { children: [
|
|
1393
|
+
" - ",
|
|
1394
|
+
c
|
|
1395
|
+
] }, i))
|
|
1396
|
+
] }),
|
|
1397
|
+
selectedPhase.requirements && selectedPhase.requirements.length > 0 && /* @__PURE__ */ jsxs11(Box10, { flexDirection: "column", marginTop: 1, children: [
|
|
1398
|
+
/* @__PURE__ */ jsx12(Text11, { bold: true, dimColor: true, children: "Requirements" }),
|
|
1399
|
+
selectedPhase.requirements.map((r, i) => /* @__PURE__ */ jsxs11(Text11, { children: [
|
|
1400
|
+
" - ",
|
|
1401
|
+
r
|
|
1402
|
+
] }, i))
|
|
1403
|
+
] })
|
|
1404
|
+
] })
|
|
1405
|
+
] });
|
|
1406
|
+
}
|
|
1407
|
+
if (mode === "coordinate") {
|
|
1408
|
+
return /* @__PURE__ */ jsxs11(Box10, { flexDirection: "column", flexGrow: 1, children: [
|
|
1409
|
+
/* @__PURE__ */ jsxs11(Box10, { marginBottom: 1, children: [
|
|
1410
|
+
/* @__PURE__ */ jsx12(Text11, { bold: true, color: "cyan", children: "Coordinate" }),
|
|
1411
|
+
selectedPhase && /* @__PURE__ */ jsxs11(Text11, { dimColor: true, children: [
|
|
1412
|
+
" (",
|
|
1413
|
+
selectedPhase.title,
|
|
1414
|
+
")"
|
|
1415
|
+
] }),
|
|
1416
|
+
/* @__PURE__ */ jsx12(Text11, { dimColor: true, children: " | Esc=back" })
|
|
1417
|
+
] }),
|
|
1418
|
+
/* @__PURE__ */ jsxs11(Box10, { flexDirection: "column", marginBottom: 1, borderStyle: "single", paddingX: 1, paddingY: 0, children: [
|
|
1419
|
+
/* @__PURE__ */ jsx12(Text11, { dimColor: true, bold: true, children: "Status" }),
|
|
1420
|
+
coordinateStatus ? /* @__PURE__ */ jsxs11(Box10, { flexDirection: "column", children: [
|
|
1421
|
+
/* @__PURE__ */ jsxs11(Box10, { gap: 1, children: [
|
|
1422
|
+
/* @__PURE__ */ jsx12(Text11, { dimColor: true, children: "State:" }),
|
|
1423
|
+
/* @__PURE__ */ jsx12(Text11, { color: coordinateStatus.status === "running" ? "yellow" : coordinateStatus.status === "completed" ? "green" : "gray", children: coordinateStatus.status })
|
|
1424
|
+
] }),
|
|
1425
|
+
coordinateStatus.message && /* @__PURE__ */ jsxs11(Box10, { gap: 1, children: [
|
|
1426
|
+
/* @__PURE__ */ jsx12(Text11, { dimColor: true, children: "Message:" }),
|
|
1427
|
+
/* @__PURE__ */ jsx12(Text11, { children: coordinateStatus.message })
|
|
1428
|
+
] }),
|
|
1429
|
+
coordinateStatus.sessionId && /* @__PURE__ */ jsxs11(Box10, { gap: 1, children: [
|
|
1430
|
+
/* @__PURE__ */ jsx12(Text11, { dimColor: true, children: "Session:" }),
|
|
1431
|
+
/* @__PURE__ */ jsx12(Text11, { children: coordinateStatus.sessionId })
|
|
1432
|
+
] })
|
|
1433
|
+
] }) : /* @__PURE__ */ jsx12(Text11, { dimColor: true, children: "No active coordinate session" })
|
|
1434
|
+
] }),
|
|
1435
|
+
/* @__PURE__ */ jsxs11(Box10, { flexDirection: "column", children: [
|
|
1436
|
+
/* @__PURE__ */ jsx12(Text11, { children: "Command:" }),
|
|
1437
|
+
/* @__PURE__ */ jsx12(TextInput2, { placeholder: "Enter coordinate command...", onSubmit: handleSendCommand })
|
|
1438
|
+
] })
|
|
1439
|
+
] });
|
|
1440
|
+
}
|
|
1441
|
+
if (mode === "tasks" && selectedPhase) {
|
|
1442
|
+
return /* @__PURE__ */ jsxs11(Box10, { flexDirection: "column", flexGrow: 1, children: [
|
|
1443
|
+
/* @__PURE__ */ jsxs11(Box10, { marginBottom: 1, gap: 2, children: [
|
|
1444
|
+
/* @__PURE__ */ jsxs11(Text11, { bold: true, color: "cyan", children: [
|
|
1445
|
+
"Phase ",
|
|
1446
|
+
selectedPhase.phase,
|
|
1447
|
+
": ",
|
|
1448
|
+
selectedPhase.title
|
|
1449
|
+
] }),
|
|
1450
|
+
/* @__PURE__ */ jsx12(StatusDot, { status: selectedPhase.status, showLabel: true })
|
|
1451
|
+
] }),
|
|
1452
|
+
/* @__PURE__ */ jsx12(Box10, { marginBottom: 1, children: /* @__PURE__ */ jsx12(Text11, { dimColor: true, children: "Esc=back [x]coordinate [p]hase detail Enter=task detail" }) }),
|
|
1453
|
+
tasksLoading && !tasks?.length ? /* @__PURE__ */ jsx12(Text11, { dimColor: true, children: "Loading tasks..." }) : /* @__PURE__ */ jsx12(
|
|
1454
|
+
DataTable,
|
|
1455
|
+
{
|
|
1456
|
+
columns: TASK_COLUMNS,
|
|
1457
|
+
data: tasks ?? [],
|
|
1458
|
+
selectedIndex: selectedTaskIdx
|
|
1459
|
+
}
|
|
1460
|
+
)
|
|
1461
|
+
] });
|
|
1462
|
+
}
|
|
1463
|
+
return /* @__PURE__ */ jsx12(
|
|
1464
|
+
PhasesMode,
|
|
1465
|
+
{
|
|
1466
|
+
phases: phases ?? [],
|
|
1467
|
+
loading,
|
|
1468
|
+
error,
|
|
1469
|
+
onSelect: handleSelectPhase
|
|
1470
|
+
}
|
|
1471
|
+
);
|
|
1472
|
+
}
|
|
1473
|
+
function PhasesMode({ phases, loading, error, onSelect }) {
|
|
1474
|
+
const renderItem = useCallback5(
|
|
1475
|
+
(phase, _index, isSelected) => /* @__PURE__ */ jsxs11(Box10, { gap: 1, children: [
|
|
1476
|
+
/* @__PURE__ */ jsxs11(Text11, { color: isSelected ? "cyan" : "gray", dimColor: !isSelected, children: [
|
|
1477
|
+
"P",
|
|
1478
|
+
phase.phase
|
|
1479
|
+
] }),
|
|
1480
|
+
/* @__PURE__ */ jsx12(StatusDot, { status: phase.status, showLabel: false }),
|
|
1481
|
+
/* @__PURE__ */ jsx12(Text11, { color: isSelected ? "cyan" : void 0, wrap: "truncate", children: phase.title }),
|
|
1482
|
+
/* @__PURE__ */ jsxs11(Text11, { dimColor: true, children: [
|
|
1483
|
+
"[",
|
|
1484
|
+
phase.execution.tasks_completed,
|
|
1485
|
+
"/",
|
|
1486
|
+
phase.execution.tasks_total,
|
|
1487
|
+
"]"
|
|
1488
|
+
] })
|
|
1489
|
+
] }),
|
|
1490
|
+
[]
|
|
1491
|
+
);
|
|
1492
|
+
if (error) {
|
|
1493
|
+
return /* @__PURE__ */ jsxs11(Box10, { flexDirection: "column", padding: 1, children: [
|
|
1494
|
+
/* @__PURE__ */ jsx12(Text11, { bold: true, color: "cyan", children: "Workflow Phases" }),
|
|
1495
|
+
/* @__PURE__ */ jsxs11(Text11, { color: "red", children: [
|
|
1496
|
+
"Error: ",
|
|
1497
|
+
error.message
|
|
1498
|
+
] })
|
|
1499
|
+
] });
|
|
1500
|
+
}
|
|
1501
|
+
return /* @__PURE__ */ jsxs11(Box10, { flexDirection: "column", flexGrow: 1, children: [
|
|
1502
|
+
/* @__PURE__ */ jsxs11(Box10, { marginBottom: 1, gap: 2, children: [
|
|
1503
|
+
/* @__PURE__ */ jsx12(Text11, { bold: true, color: "cyan", children: "Workflow Phases" }),
|
|
1504
|
+
loading && !phases.length && /* @__PURE__ */ jsx12(Text11, { dimColor: true, children: "Loading..." }),
|
|
1505
|
+
/* @__PURE__ */ jsxs11(Text11, { dimColor: true, children: [
|
|
1506
|
+
"(",
|
|
1507
|
+
phases.length,
|
|
1508
|
+
" phases) Enter=view tasks"
|
|
1509
|
+
] })
|
|
1510
|
+
] }),
|
|
1511
|
+
/* @__PURE__ */ jsx12(
|
|
1512
|
+
ScrollableList,
|
|
1513
|
+
{
|
|
1514
|
+
items: phases,
|
|
1515
|
+
renderItem,
|
|
1516
|
+
onSelect
|
|
1517
|
+
}
|
|
1518
|
+
)
|
|
1519
|
+
] });
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1522
|
+
// src/views/ArtifactView.tsx
|
|
1523
|
+
import { useState as useState6, useCallback as useCallback6, useEffect as useEffect4, useRef as useRef5 } from "react";
|
|
1524
|
+
import { Box as Box11, Text as Text12, useInput as useInput6 } from "ink";
|
|
1525
|
+
import { TextInput as TextInput3 } from "@inkjs/ui";
|
|
1526
|
+
import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1527
|
+
function flattenTree(nodes, expandedDirs, depth = 0) {
|
|
1528
|
+
const result = [];
|
|
1529
|
+
for (const node of nodes) {
|
|
1530
|
+
const isDir = node.type === "directory";
|
|
1531
|
+
const hasChildren = isDir && Array.isArray(node.children) && node.children.length > 0;
|
|
1532
|
+
result.push({ name: node.name, path: node.path, depth, isDir, hasChildren });
|
|
1533
|
+
if (isDir && hasChildren && expandedDirs.has(node.path)) {
|
|
1534
|
+
result.push(...flattenTree(node.children, expandedDirs, depth + 1));
|
|
1535
|
+
}
|
|
1536
|
+
}
|
|
1537
|
+
return result;
|
|
1538
|
+
}
|
|
1539
|
+
function getFileType(path) {
|
|
1540
|
+
const ext = path.split(".").pop()?.toLowerCase() ?? "";
|
|
1541
|
+
if (ext === "json") return "json";
|
|
1542
|
+
if (ext === "md" || ext === "markdown") return "markdown";
|
|
1543
|
+
return "text";
|
|
1544
|
+
}
|
|
1545
|
+
function JsonContent({ text }) {
|
|
1546
|
+
const lines = text.split("\n");
|
|
1547
|
+
return /* @__PURE__ */ jsx13(Box11, { flexDirection: "column", children: lines.map((line, i) => {
|
|
1548
|
+
const keyMatch = line.match(/^(\s*)"([^"]+)"(\s*:\s*)/);
|
|
1549
|
+
if (keyMatch) {
|
|
1550
|
+
const [, indent, key, sep] = keyMatch;
|
|
1551
|
+
const rest = line.slice(keyMatch[0].length);
|
|
1552
|
+
return /* @__PURE__ */ jsxs12(Text12, { children: [
|
|
1553
|
+
indent,
|
|
1554
|
+
/* @__PURE__ */ jsxs12(Text12, { color: "cyan", children: [
|
|
1555
|
+
'"',
|
|
1556
|
+
key,
|
|
1557
|
+
'"'
|
|
1558
|
+
] }),
|
|
1559
|
+
sep,
|
|
1560
|
+
/* @__PURE__ */ jsx13(Text12, { color: "green", children: rest })
|
|
1561
|
+
] }, i);
|
|
1562
|
+
}
|
|
1563
|
+
return /* @__PURE__ */ jsx13(Text12, { dimColor: true, children: line }, i);
|
|
1564
|
+
}) });
|
|
1565
|
+
}
|
|
1566
|
+
function MarkdownContent({ text }) {
|
|
1567
|
+
const lines = text.split("\n");
|
|
1568
|
+
return /* @__PURE__ */ jsx13(Box11, { flexDirection: "column", children: lines.map((line, i) => {
|
|
1569
|
+
if (line.startsWith("#")) {
|
|
1570
|
+
return /* @__PURE__ */ jsx13(Text12, { bold: true, color: "cyan", children: line }, i);
|
|
1571
|
+
}
|
|
1572
|
+
if (line.includes("**")) {
|
|
1573
|
+
return /* @__PURE__ */ jsx13(Text12, { bold: true, children: line.replace(/\*\*/g, "") }, i);
|
|
1574
|
+
}
|
|
1575
|
+
if (line.match(/^\s*[-*]\s/)) {
|
|
1576
|
+
return /* @__PURE__ */ jsx13(Text12, { color: "white", children: line }, i);
|
|
1577
|
+
}
|
|
1578
|
+
return /* @__PURE__ */ jsx13(Text12, { children: line }, i);
|
|
1579
|
+
}) });
|
|
1580
|
+
}
|
|
1581
|
+
function PlainContent({ text }) {
|
|
1582
|
+
return /* @__PURE__ */ jsx13(Text12, { children: text });
|
|
1583
|
+
}
|
|
1584
|
+
function ContentPreview({ content, fileType }) {
|
|
1585
|
+
switch (fileType) {
|
|
1586
|
+
case "json":
|
|
1587
|
+
return /* @__PURE__ */ jsx13(JsonContent, { text: content });
|
|
1588
|
+
case "markdown":
|
|
1589
|
+
return /* @__PURE__ */ jsx13(MarkdownContent, { text: content });
|
|
1590
|
+
default:
|
|
1591
|
+
return /* @__PURE__ */ jsx13(PlainContent, { text: content });
|
|
1592
|
+
}
|
|
1593
|
+
}
|
|
1594
|
+
function ArtifactView() {
|
|
1595
|
+
const { data, loading, error } = useApi("/api/artifacts?tree=true");
|
|
1596
|
+
const [expandedDirs, setExpandedDirs] = useState6(/* @__PURE__ */ new Set());
|
|
1597
|
+
const [selectedFile, setSelectedFile] = useState6(null);
|
|
1598
|
+
const [searchMode, setSearchMode] = useState6(false);
|
|
1599
|
+
const [searchQuery, setSearchQuery] = useState6("");
|
|
1600
|
+
const baseUrl = useBaseUrl();
|
|
1601
|
+
const [fileContent, setFileContent] = useState6(null);
|
|
1602
|
+
const [fileLoading, setFileLoading] = useState6(false);
|
|
1603
|
+
const fetchIdRef = useRef5(0);
|
|
1604
|
+
useEffect4(() => {
|
|
1605
|
+
if (!selectedFile) {
|
|
1606
|
+
setFileContent(null);
|
|
1607
|
+
return;
|
|
1608
|
+
}
|
|
1609
|
+
const id = ++fetchIdRef.current;
|
|
1610
|
+
setFileLoading(true);
|
|
1611
|
+
fetch(`${baseUrl}/api/artifacts/${encodeURIComponent(selectedFile.path)}`).then((r) => r.ok ? r.text() : Promise.reject(new Error(`${r.status}`))).then((text) => {
|
|
1612
|
+
if (id === fetchIdRef.current) {
|
|
1613
|
+
setFileContent(text);
|
|
1614
|
+
setFileLoading(false);
|
|
1615
|
+
}
|
|
1616
|
+
}).catch(() => {
|
|
1617
|
+
if (id === fetchIdRef.current) {
|
|
1618
|
+
setFileContent(null);
|
|
1619
|
+
setFileLoading(false);
|
|
1620
|
+
}
|
|
1621
|
+
});
|
|
1622
|
+
}, [baseUrl, selectedFile]);
|
|
1623
|
+
useInput6((input, key) => {
|
|
1624
|
+
if (!searchMode && input === "/") {
|
|
1625
|
+
setSearchQuery("");
|
|
1626
|
+
setSearchMode(true);
|
|
1627
|
+
return;
|
|
1628
|
+
}
|
|
1629
|
+
if (searchMode && key.escape) {
|
|
1630
|
+
setSearchQuery("");
|
|
1631
|
+
setSearchMode(false);
|
|
1632
|
+
return;
|
|
1633
|
+
}
|
|
1634
|
+
}, { isActive: !searchMode });
|
|
1635
|
+
const allItems = flattenTree(data ?? [], expandedDirs);
|
|
1636
|
+
const items = searchQuery ? allItems.filter((item) => item.name.toLowerCase().includes(searchQuery.toLowerCase())) : allItems;
|
|
1637
|
+
const handleSelect = useCallback6(
|
|
1638
|
+
(item) => {
|
|
1639
|
+
if (item.isDir) {
|
|
1640
|
+
setExpandedDirs((prev) => {
|
|
1641
|
+
const next = new Set(prev);
|
|
1642
|
+
if (next.has(item.path)) {
|
|
1643
|
+
next.delete(item.path);
|
|
1644
|
+
} else {
|
|
1645
|
+
next.add(item.path);
|
|
1646
|
+
}
|
|
1647
|
+
return next;
|
|
1648
|
+
});
|
|
1649
|
+
} else {
|
|
1650
|
+
setSelectedFile({ path: item.path, content: "" });
|
|
1651
|
+
}
|
|
1652
|
+
},
|
|
1653
|
+
[]
|
|
1654
|
+
);
|
|
1655
|
+
const renderItem = useCallback6(
|
|
1656
|
+
(item, _index, isSelected) => {
|
|
1657
|
+
const indent = " ".repeat(item.depth);
|
|
1658
|
+
const icon = item.isDir ? expandedDirs.has(item.path) ? "v " : "> " : " ";
|
|
1659
|
+
return /* @__PURE__ */ jsxs12(Text12, { color: isSelected ? "cyan" : void 0, children: [
|
|
1660
|
+
indent,
|
|
1661
|
+
icon,
|
|
1662
|
+
item.name
|
|
1663
|
+
] });
|
|
1664
|
+
},
|
|
1665
|
+
[expandedDirs]
|
|
1666
|
+
);
|
|
1667
|
+
if (loading && !data) {
|
|
1668
|
+
return /* @__PURE__ */ jsx13(Box11, { children: /* @__PURE__ */ jsx13(Text12, { dimColor: true, children: "Loading artifacts..." }) });
|
|
1669
|
+
}
|
|
1670
|
+
if (error) {
|
|
1671
|
+
return /* @__PURE__ */ jsx13(Box11, { children: /* @__PURE__ */ jsxs12(Text12, { color: "red", children: [
|
|
1672
|
+
"Error: ",
|
|
1673
|
+
error.message
|
|
1674
|
+
] }) });
|
|
1675
|
+
}
|
|
1676
|
+
if (!data || data.length === 0) {
|
|
1677
|
+
return /* @__PURE__ */ jsxs12(Box11, { flexDirection: "column", padding: 1, children: [
|
|
1678
|
+
/* @__PURE__ */ jsx13(Text12, { bold: true, color: "cyan", children: "Artifacts" }),
|
|
1679
|
+
/* @__PURE__ */ jsx13(Text12, { dimColor: true, children: "No artifacts found." })
|
|
1680
|
+
] });
|
|
1681
|
+
}
|
|
1682
|
+
let rightContent;
|
|
1683
|
+
if (selectedFile && fileContent) {
|
|
1684
|
+
const fileType = getFileType(selectedFile.path);
|
|
1685
|
+
rightContent = /* @__PURE__ */ jsxs12(Box11, { flexDirection: "column", paddingLeft: 1, children: [
|
|
1686
|
+
/* @__PURE__ */ jsx13(Text12, { bold: true, dimColor: true, children: selectedFile.path }),
|
|
1687
|
+
/* @__PURE__ */ jsx13(Box11, { marginTop: 1, flexDirection: "column", children: /* @__PURE__ */ jsx13(ContentPreview, { content: fileContent, fileType }) })
|
|
1688
|
+
] });
|
|
1689
|
+
} else if (selectedFile && fileLoading) {
|
|
1690
|
+
rightContent = /* @__PURE__ */ jsx13(Box11, { paddingLeft: 1, children: /* @__PURE__ */ jsx13(Text12, { dimColor: true, children: "Loading file..." }) });
|
|
1691
|
+
} else {
|
|
1692
|
+
rightContent = /* @__PURE__ */ jsx13(Box11, { paddingLeft: 1, children: /* @__PURE__ */ jsx13(Text12, { dimColor: true, children: "Select a file to preview" }) });
|
|
1693
|
+
}
|
|
1694
|
+
if (searchMode) {
|
|
1695
|
+
return /* @__PURE__ */ jsxs12(Box11, { flexDirection: "column", flexGrow: 1, children: [
|
|
1696
|
+
/* @__PURE__ */ jsxs12(Box11, { marginBottom: 1, children: [
|
|
1697
|
+
/* @__PURE__ */ jsx13(Text12, { bold: true, color: "cyan", children: "Search Artifacts" }),
|
|
1698
|
+
/* @__PURE__ */ jsx13(Text12, { dimColor: true, children: " Esc=clear" })
|
|
1699
|
+
] }),
|
|
1700
|
+
/* @__PURE__ */ jsx13(
|
|
1701
|
+
TextInput3,
|
|
1702
|
+
{
|
|
1703
|
+
placeholder: "Search by filename...",
|
|
1704
|
+
defaultValue: searchQuery,
|
|
1705
|
+
onChange: setSearchQuery,
|
|
1706
|
+
onSubmit: () => setSearchMode(false)
|
|
1707
|
+
}
|
|
1708
|
+
)
|
|
1709
|
+
] });
|
|
1710
|
+
}
|
|
1711
|
+
return /* @__PURE__ */ jsxs12(Box11, { flexDirection: "column", flexGrow: 1, children: [
|
|
1712
|
+
/* @__PURE__ */ jsxs12(Box11, { marginBottom: 1, children: [
|
|
1713
|
+
/* @__PURE__ */ jsx13(Text12, { bold: true, color: "cyan", children: "Artifacts" }),
|
|
1714
|
+
/* @__PURE__ */ jsxs12(Text12, { dimColor: true, children: [
|
|
1715
|
+
" (",
|
|
1716
|
+
items.length,
|
|
1717
|
+
" items) [/]search"
|
|
1718
|
+
] })
|
|
1719
|
+
] }),
|
|
1720
|
+
searchQuery && /* @__PURE__ */ jsxs12(Box11, { marginBottom: 1, children: [
|
|
1721
|
+
/* @__PURE__ */ jsx13(Text12, { dimColor: true, children: "Filter: " }),
|
|
1722
|
+
/* @__PURE__ */ jsx13(Text12, { color: "yellow", children: searchQuery })
|
|
1723
|
+
] }),
|
|
1724
|
+
/* @__PURE__ */ jsx13(
|
|
1725
|
+
SplitPane,
|
|
1726
|
+
{
|
|
1727
|
+
ratio: 35,
|
|
1728
|
+
left: /* @__PURE__ */ jsx13(
|
|
1729
|
+
ScrollableList,
|
|
1730
|
+
{
|
|
1731
|
+
items,
|
|
1732
|
+
renderItem,
|
|
1733
|
+
onSelect: handleSelect,
|
|
1734
|
+
getItemKey: (item) => item.path
|
|
1735
|
+
}
|
|
1736
|
+
),
|
|
1737
|
+
right: rightContent
|
|
1738
|
+
}
|
|
1739
|
+
)
|
|
1740
|
+
] });
|
|
1741
|
+
}
|
|
1742
|
+
|
|
1743
|
+
// src/views/TeamView.tsx
|
|
1744
|
+
import { useState as useState7, useCallback as useCallback7 } from "react";
|
|
1745
|
+
import { Box as Box12, Text as Text13, useInput as useInput7 } from "ink";
|
|
1746
|
+
import { jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1747
|
+
var SKILL_PREFIX_MAP = {
|
|
1748
|
+
"TC-": "Coordinate",
|
|
1749
|
+
"TLV4-": "Lifecycle",
|
|
1750
|
+
"QA-": "QA",
|
|
1751
|
+
"RV-": "Review",
|
|
1752
|
+
"TST-": "Testing",
|
|
1753
|
+
"TFD-": "Frontend Debug",
|
|
1754
|
+
"TPO-": "Perf Opt",
|
|
1755
|
+
"TTD-": "Tech Debt",
|
|
1756
|
+
"TPX-": "Plan & Execute",
|
|
1757
|
+
"TBS-": "Brainstorm",
|
|
1758
|
+
"TRD-": "Roadmap Dev",
|
|
1759
|
+
"TIS-": "Issue",
|
|
1760
|
+
"TID-": "Iter Dev",
|
|
1761
|
+
"TUA-": "Ultra Analyze",
|
|
1762
|
+
"TUX-": "UX Improve",
|
|
1763
|
+
"TUI-": "UI Design",
|
|
1764
|
+
"TAO-": "Arch Opt"
|
|
1765
|
+
};
|
|
1766
|
+
function inferSkill(sessionId) {
|
|
1767
|
+
for (const [prefix, label] of Object.entries(SKILL_PREFIX_MAP)) {
|
|
1768
|
+
if (sessionId.startsWith(prefix)) return label;
|
|
1769
|
+
}
|
|
1770
|
+
return "Team";
|
|
1771
|
+
}
|
|
1772
|
+
var STATUS_COLORS = {
|
|
1773
|
+
active: "yellow",
|
|
1774
|
+
completed: "green",
|
|
1775
|
+
failed: "red",
|
|
1776
|
+
archived: "gray",
|
|
1777
|
+
done: "green",
|
|
1778
|
+
in_progress: "yellow",
|
|
1779
|
+
pending: "gray",
|
|
1780
|
+
skipped: "gray",
|
|
1781
|
+
injected: "magenta"
|
|
1782
|
+
};
|
|
1783
|
+
var DETAIL_TABS = ["Pipeline", "Roles", "Messages", "Files"];
|
|
1784
|
+
function ProgressBar({ completed, total }) {
|
|
1785
|
+
const width = 12;
|
|
1786
|
+
const pct = total > 0 ? completed / total : 0;
|
|
1787
|
+
const filled = Math.round(pct * width);
|
|
1788
|
+
const empty = width - filled;
|
|
1789
|
+
return /* @__PURE__ */ jsxs13(Text13, { children: [
|
|
1790
|
+
/* @__PURE__ */ jsx14(Text13, { color: "green", children: "#".repeat(filled) }),
|
|
1791
|
+
/* @__PURE__ */ jsx14(Text13, { dimColor: true, children: "-".repeat(empty) }),
|
|
1792
|
+
/* @__PURE__ */ jsxs13(Text13, { dimColor: true, children: [
|
|
1793
|
+
" ",
|
|
1794
|
+
completed,
|
|
1795
|
+
"/",
|
|
1796
|
+
total
|
|
1797
|
+
] })
|
|
1798
|
+
] });
|
|
1799
|
+
}
|
|
1800
|
+
function PipelineTab({ detail }) {
|
|
1801
|
+
const nodes = detail.pipeline?.waves ? detail.pipeline.waves.flatMap((w) => w.nodes) : detail.pipelineStages ?? [];
|
|
1802
|
+
if (nodes.length === 0) {
|
|
1803
|
+
return /* @__PURE__ */ jsx14(Text13, { dimColor: true, children: "No pipeline nodes." });
|
|
1804
|
+
}
|
|
1805
|
+
return /* @__PURE__ */ jsx14(Box12, { flexDirection: "column", children: nodes.map((node) => /* @__PURE__ */ jsxs13(Box12, { gap: 1, children: [
|
|
1806
|
+
/* @__PURE__ */ jsx14(StatusDot, { status: node.status, colorMap: STATUS_COLORS }),
|
|
1807
|
+
/* @__PURE__ */ jsx14(Text13, { children: node.name }),
|
|
1808
|
+
/* @__PURE__ */ jsxs13(Text13, { dimColor: true, children: [
|
|
1809
|
+
"(",
|
|
1810
|
+
node.status,
|
|
1811
|
+
")"
|
|
1812
|
+
] }),
|
|
1813
|
+
node.wave != null && /* @__PURE__ */ jsxs13(Text13, { dimColor: true, children: [
|
|
1814
|
+
"wave:",
|
|
1815
|
+
node.wave
|
|
1816
|
+
] })
|
|
1817
|
+
] }, node.id)) });
|
|
1818
|
+
}
|
|
1819
|
+
function RolesTab({ detail }) {
|
|
1820
|
+
const roles = detail.roleDetails ?? [];
|
|
1821
|
+
if (roles.length === 0) {
|
|
1822
|
+
return /* @__PURE__ */ jsx14(Text13, { dimColor: true, children: "No role details." });
|
|
1823
|
+
}
|
|
1824
|
+
return /* @__PURE__ */ jsxs13(Box12, { flexDirection: "column", children: [
|
|
1825
|
+
/* @__PURE__ */ jsxs13(Box12, { gap: 2, children: [
|
|
1826
|
+
/* @__PURE__ */ jsx14(Box12, { width: 16, children: /* @__PURE__ */ jsx14(Text13, { bold: true, children: "Role" }) }),
|
|
1827
|
+
/* @__PURE__ */ jsx14(Box12, { width: 8, children: /* @__PURE__ */ jsx14(Text13, { bold: true, children: "Status" }) }),
|
|
1828
|
+
/* @__PURE__ */ jsx14(Box12, { width: 6, children: /* @__PURE__ */ jsx14(Text13, { bold: true, children: "Tasks" }) }),
|
|
1829
|
+
/* @__PURE__ */ jsx14(Box12, { width: 6, children: /* @__PURE__ */ jsx14(Text13, { bold: true, children: "Loop" }) })
|
|
1830
|
+
] }),
|
|
1831
|
+
roles.map((role) => /* @__PURE__ */ jsxs13(Box12, { gap: 2, children: [
|
|
1832
|
+
/* @__PURE__ */ jsx14(Box12, { width: 16, children: /* @__PURE__ */ jsx14(Text13, { children: role.name }) }),
|
|
1833
|
+
/* @__PURE__ */ jsx14(Box12, { width: 8, children: /* @__PURE__ */ jsx14(StatusDot, { status: role.status, colorMap: STATUS_COLORS, showLabel: true }) }),
|
|
1834
|
+
/* @__PURE__ */ jsx14(Box12, { width: 6, children: /* @__PURE__ */ jsx14(Text13, { children: role.taskCount }) }),
|
|
1835
|
+
/* @__PURE__ */ jsx14(Box12, { width: 6, children: /* @__PURE__ */ jsx14(Text13, { dimColor: true, children: role.innerLoop ? "yes" : "no" }) })
|
|
1836
|
+
] }, role.prefix))
|
|
1837
|
+
] });
|
|
1838
|
+
}
|
|
1839
|
+
function MessagesTab({ detail }) {
|
|
1840
|
+
const messages = detail.messages ?? [];
|
|
1841
|
+
if (messages.length === 0) {
|
|
1842
|
+
return /* @__PURE__ */ jsx14(Text13, { dimColor: true, children: "No messages." });
|
|
1843
|
+
}
|
|
1844
|
+
return /* @__PURE__ */ jsx14(Box12, { flexDirection: "column", children: messages.map((msg) => /* @__PURE__ */ jsxs13(Box12, { gap: 1, children: [
|
|
1845
|
+
/* @__PURE__ */ jsx14(Text13, { dimColor: true, children: msg.ts.slice(11, 19) }),
|
|
1846
|
+
/* @__PURE__ */ jsx14(Text13, { color: "cyan", children: msg.from }),
|
|
1847
|
+
/* @__PURE__ */ jsxs13(Text13, { dimColor: true, children: [
|
|
1848
|
+
"-",
|
|
1849
|
+
">"
|
|
1850
|
+
] }),
|
|
1851
|
+
/* @__PURE__ */ jsx14(Text13, { color: "yellow", children: msg.to }),
|
|
1852
|
+
/* @__PURE__ */ jsxs13(Text13, { children: [
|
|
1853
|
+
" ",
|
|
1854
|
+
msg.summary
|
|
1855
|
+
] })
|
|
1856
|
+
] }, msg.id)) });
|
|
1857
|
+
}
|
|
1858
|
+
function FilesTab({ detail }) {
|
|
1859
|
+
const files = detail.files ?? [];
|
|
1860
|
+
if (files.length === 0) {
|
|
1861
|
+
return /* @__PURE__ */ jsx14(Text13, { dimColor: true, children: "No files." });
|
|
1862
|
+
}
|
|
1863
|
+
return /* @__PURE__ */ jsx14(Box12, { flexDirection: "column", children: files.map((file) => /* @__PURE__ */ jsxs13(Box12, { gap: 1, children: [
|
|
1864
|
+
/* @__PURE__ */ jsxs13(Text13, { dimColor: true, children: [
|
|
1865
|
+
"[",
|
|
1866
|
+
file.category,
|
|
1867
|
+
"]"
|
|
1868
|
+
] }),
|
|
1869
|
+
/* @__PURE__ */ jsx14(Text13, { color: file.isNew ? "green" : void 0, children: file.name }),
|
|
1870
|
+
file.status && /* @__PURE__ */ jsxs13(Text13, { dimColor: true, children: [
|
|
1871
|
+
"(",
|
|
1872
|
+
file.status,
|
|
1873
|
+
")"
|
|
1874
|
+
] })
|
|
1875
|
+
] }, file.id)) });
|
|
1876
|
+
}
|
|
1877
|
+
function TeamView() {
|
|
1878
|
+
const [mode, setMode] = useState7("list");
|
|
1879
|
+
const [selectedSessionId, setSelectedSessionId] = useState7(null);
|
|
1880
|
+
const [activeTab, setActiveTab] = useState7(0);
|
|
1881
|
+
const { data: sessions, loading, error } = useApi(
|
|
1882
|
+
"/api/teams/sessions"
|
|
1883
|
+
);
|
|
1884
|
+
const { data: detail } = useApi(
|
|
1885
|
+
`/api/teams/sessions/${selectedSessionId}`,
|
|
1886
|
+
{ skip: !selectedSessionId || mode !== "detail" }
|
|
1887
|
+
);
|
|
1888
|
+
useInput7(
|
|
1889
|
+
(_input, key) => {
|
|
1890
|
+
if (key.escape && mode === "detail") {
|
|
1891
|
+
setMode("list");
|
|
1892
|
+
setSelectedSessionId(null);
|
|
1893
|
+
}
|
|
1894
|
+
},
|
|
1895
|
+
{ isActive: mode === "detail" }
|
|
1896
|
+
);
|
|
1897
|
+
const handleSelectSession = useCallback7(
|
|
1898
|
+
(session) => {
|
|
1899
|
+
setSelectedSessionId(session.sessionId);
|
|
1900
|
+
setActiveTab(0);
|
|
1901
|
+
setMode("detail");
|
|
1902
|
+
},
|
|
1903
|
+
[]
|
|
1904
|
+
);
|
|
1905
|
+
const renderSessionItem = useCallback7(
|
|
1906
|
+
(session, _index, isSelected) => {
|
|
1907
|
+
const skill2 = inferSkill(session.sessionId);
|
|
1908
|
+
return /* @__PURE__ */ jsxs13(Box12, { gap: 1, children: [
|
|
1909
|
+
/* @__PURE__ */ jsx14(StatusDot, { status: session.status, colorMap: STATUS_COLORS }),
|
|
1910
|
+
/* @__PURE__ */ jsx14(Text13, { bold: isSelected, color: isSelected ? "cyan" : void 0, children: session.title || session.sessionId }),
|
|
1911
|
+
/* @__PURE__ */ jsxs13(Text13, { dimColor: true, children: [
|
|
1912
|
+
"[",
|
|
1913
|
+
skill2,
|
|
1914
|
+
"]"
|
|
1915
|
+
] }),
|
|
1916
|
+
/* @__PURE__ */ jsx14(
|
|
1917
|
+
ProgressBar,
|
|
1918
|
+
{
|
|
1919
|
+
completed: session.taskProgress.completed,
|
|
1920
|
+
total: session.taskProgress.total
|
|
1921
|
+
}
|
|
1922
|
+
),
|
|
1923
|
+
/* @__PURE__ */ jsx14(Text13, { dimColor: true, children: session.duration })
|
|
1924
|
+
] });
|
|
1925
|
+
},
|
|
1926
|
+
[]
|
|
1927
|
+
);
|
|
1928
|
+
if (loading && !sessions) {
|
|
1929
|
+
return /* @__PURE__ */ jsx14(Box12, { children: /* @__PURE__ */ jsx14(Text13, { dimColor: true, children: "Loading team sessions..." }) });
|
|
1930
|
+
}
|
|
1931
|
+
if (error) {
|
|
1932
|
+
return /* @__PURE__ */ jsx14(Box12, { children: /* @__PURE__ */ jsxs13(Text13, { color: "red", children: [
|
|
1933
|
+
"Error: ",
|
|
1934
|
+
error.message
|
|
1935
|
+
] }) });
|
|
1936
|
+
}
|
|
1937
|
+
if (mode === "list") {
|
|
1938
|
+
if (!sessions || sessions.length === 0) {
|
|
1939
|
+
return /* @__PURE__ */ jsxs13(Box12, { flexDirection: "column", padding: 1, children: [
|
|
1940
|
+
/* @__PURE__ */ jsx14(Text13, { bold: true, color: "cyan", children: "Team Sessions" }),
|
|
1941
|
+
/* @__PURE__ */ jsx14(Text13, { dimColor: true, children: "No team sessions found." })
|
|
1942
|
+
] });
|
|
1943
|
+
}
|
|
1944
|
+
return /* @__PURE__ */ jsxs13(Box12, { flexDirection: "column", flexGrow: 1, children: [
|
|
1945
|
+
/* @__PURE__ */ jsxs13(Box12, { marginBottom: 1, children: [
|
|
1946
|
+
/* @__PURE__ */ jsx14(Text13, { bold: true, color: "cyan", children: "Team Sessions" }),
|
|
1947
|
+
/* @__PURE__ */ jsxs13(Text13, { dimColor: true, children: [
|
|
1948
|
+
" (",
|
|
1949
|
+
sessions.length,
|
|
1950
|
+
")"
|
|
1951
|
+
] })
|
|
1952
|
+
] }),
|
|
1953
|
+
/* @__PURE__ */ jsx14(
|
|
1954
|
+
ScrollableList,
|
|
1955
|
+
{
|
|
1956
|
+
items: sessions,
|
|
1957
|
+
renderItem: renderSessionItem,
|
|
1958
|
+
onSelect: handleSelectSession
|
|
1959
|
+
}
|
|
1960
|
+
)
|
|
1961
|
+
] });
|
|
1962
|
+
}
|
|
1963
|
+
if (!detail) {
|
|
1964
|
+
return /* @__PURE__ */ jsx14(Box12, { children: /* @__PURE__ */ jsx14(Text13, { dimColor: true, children: "Loading session detail..." }) });
|
|
1965
|
+
}
|
|
1966
|
+
const skill = inferSkill(detail.sessionId);
|
|
1967
|
+
let tabContent;
|
|
1968
|
+
switch (activeTab) {
|
|
1969
|
+
case 0:
|
|
1970
|
+
tabContent = /* @__PURE__ */ jsx14(PipelineTab, { detail });
|
|
1971
|
+
break;
|
|
1972
|
+
case 1:
|
|
1973
|
+
tabContent = /* @__PURE__ */ jsx14(RolesTab, { detail });
|
|
1974
|
+
break;
|
|
1975
|
+
case 2:
|
|
1976
|
+
tabContent = /* @__PURE__ */ jsx14(MessagesTab, { detail });
|
|
1977
|
+
break;
|
|
1978
|
+
case 3:
|
|
1979
|
+
tabContent = /* @__PURE__ */ jsx14(FilesTab, { detail });
|
|
1980
|
+
break;
|
|
1981
|
+
default:
|
|
1982
|
+
tabContent = /* @__PURE__ */ jsx14(PipelineTab, { detail });
|
|
1983
|
+
}
|
|
1984
|
+
return /* @__PURE__ */ jsxs13(Box12, { flexDirection: "column", flexGrow: 1, children: [
|
|
1985
|
+
/* @__PURE__ */ jsxs13(Box12, { gap: 1, marginBottom: 1, children: [
|
|
1986
|
+
/* @__PURE__ */ jsx14(StatusDot, { status: detail.status, colorMap: STATUS_COLORS }),
|
|
1987
|
+
/* @__PURE__ */ jsx14(Text13, { bold: true, color: "cyan", children: detail.title || detail.sessionId }),
|
|
1988
|
+
/* @__PURE__ */ jsxs13(Text13, { dimColor: true, children: [
|
|
1989
|
+
"[",
|
|
1990
|
+
skill,
|
|
1991
|
+
"]"
|
|
1992
|
+
] }),
|
|
1993
|
+
/* @__PURE__ */ jsx14(Text13, { dimColor: true, children: "| Esc=back" })
|
|
1994
|
+
] }),
|
|
1995
|
+
/* @__PURE__ */ jsxs13(Box12, { gap: 2, marginBottom: 1, children: [
|
|
1996
|
+
/* @__PURE__ */ jsx14(
|
|
1997
|
+
ProgressBar,
|
|
1998
|
+
{
|
|
1999
|
+
completed: detail.taskProgress.completed,
|
|
2000
|
+
total: detail.taskProgress.total
|
|
2001
|
+
}
|
|
2002
|
+
),
|
|
2003
|
+
/* @__PURE__ */ jsxs13(Text13, { dimColor: true, children: [
|
|
2004
|
+
"Roles: ",
|
|
2005
|
+
detail.roles.length
|
|
2006
|
+
] }),
|
|
2007
|
+
/* @__PURE__ */ jsxs13(Text13, { dimColor: true, children: [
|
|
2008
|
+
"Messages: ",
|
|
2009
|
+
detail.messageCount
|
|
2010
|
+
] }),
|
|
2011
|
+
/* @__PURE__ */ jsx14(Text13, { dimColor: true, children: detail.duration })
|
|
2012
|
+
] }),
|
|
2013
|
+
/* @__PURE__ */ jsx14(Box12, { marginBottom: 1, children: /* @__PURE__ */ jsx14(
|
|
2014
|
+
FilterBar,
|
|
2015
|
+
{
|
|
2016
|
+
options: [...DETAIL_TABS],
|
|
2017
|
+
activeIndex: activeTab,
|
|
2018
|
+
onSelect: setActiveTab
|
|
2019
|
+
}
|
|
2020
|
+
) }),
|
|
2021
|
+
/* @__PURE__ */ jsx14(Box12, { flexDirection: "column", flexGrow: 1, children: tabContent })
|
|
2022
|
+
] });
|
|
2023
|
+
}
|
|
2024
|
+
|
|
2025
|
+
// src/views/RequirementView.tsx
|
|
2026
|
+
import { useState as useState9, useCallback as useCallback9, useEffect as useEffect6 } from "react";
|
|
2027
|
+
import { Box as Box14, Text as Text15, useInput as useInput9 } from "ink";
|
|
2028
|
+
import { TextInput as TextInput4, Select as Select2 } from "@inkjs/ui";
|
|
2029
|
+
|
|
2030
|
+
// src/views/requirement/RequirementBoard.tsx
|
|
2031
|
+
import { useState as useState8, useEffect as useEffect5 } from "react";
|
|
2032
|
+
import { Box as Box13, Text as Text14, useInput as useInput8 } from "ink";
|
|
2033
|
+
import { jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
2034
|
+
var COLUMNS = [
|
|
2035
|
+
{ key: "title", label: "Title", width: 30 },
|
|
2036
|
+
{
|
|
2037
|
+
key: "status",
|
|
2038
|
+
label: "Status",
|
|
2039
|
+
width: 14,
|
|
2040
|
+
render: (value) => /* @__PURE__ */ jsx15(StatusDot, { status: String(value), showLabel: true })
|
|
2041
|
+
},
|
|
2042
|
+
{
|
|
2043
|
+
key: "executor",
|
|
2044
|
+
label: "Executor",
|
|
2045
|
+
width: 16,
|
|
2046
|
+
render: (value) => /* @__PURE__ */ jsx15(Text14, { dimColor: true, children: value ? String(value) : "-" })
|
|
2047
|
+
}
|
|
2048
|
+
];
|
|
2049
|
+
function RequirementBoard({ items: initialItems, onBack }) {
|
|
2050
|
+
const [boardItems, setBoardItems] = useState8(initialItems);
|
|
2051
|
+
const [selectedRow, setSelectedRow] = useState8(0);
|
|
2052
|
+
const execStarted = useWsEvent("execution:started");
|
|
2053
|
+
const execCompleted = useWsEvent("execution:completed");
|
|
2054
|
+
useEffect5(() => {
|
|
2055
|
+
if (execStarted) {
|
|
2056
|
+
setBoardItems(
|
|
2057
|
+
(prev) => prev.map(
|
|
2058
|
+
(item) => item.issueId === execStarted.issueId ? { ...item, status: "in_progress", executor: execStarted.executor } : item
|
|
2059
|
+
)
|
|
2060
|
+
);
|
|
2061
|
+
}
|
|
2062
|
+
}, [execStarted]);
|
|
2063
|
+
useEffect5(() => {
|
|
2064
|
+
if (execCompleted) {
|
|
2065
|
+
setBoardItems(
|
|
2066
|
+
(prev) => prev.map(
|
|
2067
|
+
(item) => item.issueId === execCompleted.issueId ? { ...item, status: "completed" } : item
|
|
2068
|
+
)
|
|
2069
|
+
);
|
|
2070
|
+
}
|
|
2071
|
+
}, [execCompleted]);
|
|
2072
|
+
useInput8((_input, key) => {
|
|
2073
|
+
if (key.escape) {
|
|
2074
|
+
onBack();
|
|
2075
|
+
return;
|
|
2076
|
+
}
|
|
2077
|
+
if (key.upArrow) setSelectedRow((prev) => Math.max(0, prev - 1));
|
|
2078
|
+
if (key.downArrow) setSelectedRow((prev) => Math.min(boardItems.length - 1, prev + 1));
|
|
2079
|
+
});
|
|
2080
|
+
return /* @__PURE__ */ jsxs14(Box13, { flexDirection: "column", flexGrow: 1, children: [
|
|
2081
|
+
/* @__PURE__ */ jsxs14(Box13, { marginBottom: 1, children: [
|
|
2082
|
+
/* @__PURE__ */ jsx15(Text14, { bold: true, color: "cyan", children: "Requirement Board" }),
|
|
2083
|
+
/* @__PURE__ */ jsxs14(Text14, { dimColor: true, children: [
|
|
2084
|
+
" (",
|
|
2085
|
+
boardItems.length,
|
|
2086
|
+
" items) Esc=back"
|
|
2087
|
+
] })
|
|
2088
|
+
] }),
|
|
2089
|
+
/* @__PURE__ */ jsx15(
|
|
2090
|
+
DataTable,
|
|
2091
|
+
{
|
|
2092
|
+
columns: COLUMNS,
|
|
2093
|
+
data: boardItems,
|
|
2094
|
+
selectedIndex: selectedRow
|
|
2095
|
+
}
|
|
2096
|
+
)
|
|
2097
|
+
] });
|
|
2098
|
+
}
|
|
2099
|
+
|
|
2100
|
+
// src/views/RequirementView.tsx
|
|
2101
|
+
import { jsx as jsx16, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
2102
|
+
var DEPTH_OPTIONS = ["high-level", "standard", "atomic"];
|
|
2103
|
+
var METHOD_OPTIONS = ["sdk", "cli"];
|
|
2104
|
+
var CHECKLIST_COLUMNS = [
|
|
2105
|
+
{ key: "title", label: "Title", width: 30 },
|
|
2106
|
+
{ key: "type", label: "Type", width: 14 },
|
|
2107
|
+
{ key: "priority", label: "Priority", width: 10 },
|
|
2108
|
+
{ key: "estimated_effort", label: "Effort", width: 10 },
|
|
2109
|
+
{
|
|
2110
|
+
key: "dependencies",
|
|
2111
|
+
label: "Deps",
|
|
2112
|
+
width: 16,
|
|
2113
|
+
render: (value) => /* @__PURE__ */ jsx16(Text15, { dimColor: true, children: value.length > 0 ? value.join(", ") : "-" })
|
|
2114
|
+
}
|
|
2115
|
+
];
|
|
2116
|
+
function ProgressBar2({ progress, width = 30 }) {
|
|
2117
|
+
const filled = Math.round(progress / 100 * width);
|
|
2118
|
+
const empty = width - filled;
|
|
2119
|
+
return /* @__PURE__ */ jsxs15(Box14, { children: [
|
|
2120
|
+
/* @__PURE__ */ jsx16(Text15, { color: "green", children: "#".repeat(filled) }),
|
|
2121
|
+
/* @__PURE__ */ jsx16(Text15, { dimColor: true, children: "-".repeat(empty) }),
|
|
2122
|
+
/* @__PURE__ */ jsxs15(Text15, { children: [
|
|
2123
|
+
" ",
|
|
2124
|
+
progress,
|
|
2125
|
+
"%"
|
|
2126
|
+
] })
|
|
2127
|
+
] });
|
|
2128
|
+
}
|
|
2129
|
+
function RequirementView() {
|
|
2130
|
+
const [mode, setMode] = useState9("history");
|
|
2131
|
+
const [inputText, setInputText] = useState9("");
|
|
2132
|
+
const [depthIndex, setDepthIndex] = useState9(1);
|
|
2133
|
+
const [methodIndex, setMethodIndex] = useState9(0);
|
|
2134
|
+
const [currentRequirementId, setCurrentRequirementId] = useState9(null);
|
|
2135
|
+
const [resultItems, setResultItems] = useState9([]);
|
|
2136
|
+
const [resultTitle, setResultTitle] = useState9("");
|
|
2137
|
+
const [commitMode, setCommitMode] = useState9("issues");
|
|
2138
|
+
const [commitResult, setCommitResult] = useState9(null);
|
|
2139
|
+
const [selectedRow, setSelectedRow] = useState9(0);
|
|
2140
|
+
const [refineText, setRefineText] = useState9("");
|
|
2141
|
+
const [continueFromId, setContinueFromId] = useState9(null);
|
|
2142
|
+
const [editStep, setEditStep] = useState9("title");
|
|
2143
|
+
const [editTitle, setEditTitle] = useState9("");
|
|
2144
|
+
const [editType, setEditType] = useState9("");
|
|
2145
|
+
const [editPriority, setEditPriority] = useState9("");
|
|
2146
|
+
const { send } = useWs();
|
|
2147
|
+
const { data: history, loading: historyLoading, refetch: refetchHistory } = useApi(
|
|
2148
|
+
"/api/requirements",
|
|
2149
|
+
{ skip: mode !== "history" }
|
|
2150
|
+
);
|
|
2151
|
+
const progressData = useWsEvent("requirement:progress");
|
|
2152
|
+
const expandedData = useWsEvent("requirement:expanded");
|
|
2153
|
+
const committedData = useWsEvent("requirement:committed");
|
|
2154
|
+
useEffect6(() => {
|
|
2155
|
+
if (mode === "expanding" && expandedData?.requirement) {
|
|
2156
|
+
const req = expandedData.requirement;
|
|
2157
|
+
if (!currentRequirementId || req.id === currentRequirementId) {
|
|
2158
|
+
setCurrentRequirementId(req.id);
|
|
2159
|
+
setResultItems(req.items);
|
|
2160
|
+
setResultTitle(req.title);
|
|
2161
|
+
setSelectedRow(0);
|
|
2162
|
+
setMode("result");
|
|
2163
|
+
}
|
|
2164
|
+
}
|
|
2165
|
+
}, [expandedData, mode, currentRequirementId]);
|
|
2166
|
+
useEffect6(() => {
|
|
2167
|
+
if (mode === "commit" && committedData) {
|
|
2168
|
+
if (currentRequirementId && committedData.requirementId === currentRequirementId) {
|
|
2169
|
+
if (committedData.mode === "issues" && committedData.issueIds) {
|
|
2170
|
+
setCommitResult(`Created ${committedData.issueIds.length} issue(s): ${committedData.issueIds.join(", ")}`);
|
|
2171
|
+
} else if (committedData.mode === "coordinate" && committedData.coordinateSessionId) {
|
|
2172
|
+
setCommitResult(`Coordinate session started: ${committedData.coordinateSessionId}`);
|
|
2173
|
+
} else {
|
|
2174
|
+
setCommitResult("Committed successfully.");
|
|
2175
|
+
}
|
|
2176
|
+
}
|
|
2177
|
+
}
|
|
2178
|
+
}, [committedData, mode, currentRequirementId]);
|
|
2179
|
+
useEffect6(() => {
|
|
2180
|
+
if (expandedData?.requirement && !currentRequirementId) {
|
|
2181
|
+
setCurrentRequirementId(expandedData.requirement.id);
|
|
2182
|
+
}
|
|
2183
|
+
}, [expandedData, currentRequirementId]);
|
|
2184
|
+
useInput9((input, key) => {
|
|
2185
|
+
if (key.escape) {
|
|
2186
|
+
if (mode === "input") {
|
|
2187
|
+
setMode("history");
|
|
2188
|
+
setInputText("");
|
|
2189
|
+
setContinueFromId(null);
|
|
2190
|
+
refetchHistory();
|
|
2191
|
+
return;
|
|
2192
|
+
}
|
|
2193
|
+
if (mode === "result" || mode === "commit") {
|
|
2194
|
+
setMode("history");
|
|
2195
|
+
setInputText("");
|
|
2196
|
+
setCommitResult(null);
|
|
2197
|
+
setContinueFromId(null);
|
|
2198
|
+
refetchHistory();
|
|
2199
|
+
return;
|
|
2200
|
+
}
|
|
2201
|
+
if (mode === "refine" || mode === "edit-item") {
|
|
2202
|
+
setMode("result");
|
|
2203
|
+
return;
|
|
2204
|
+
}
|
|
2205
|
+
if (mode === "board") {
|
|
2206
|
+
setMode("result");
|
|
2207
|
+
return;
|
|
2208
|
+
}
|
|
2209
|
+
}
|
|
2210
|
+
if (mode === "history") {
|
|
2211
|
+
if (input === "n") {
|
|
2212
|
+
setContinueFromId(null);
|
|
2213
|
+
setMode("input");
|
|
2214
|
+
setInputText("");
|
|
2215
|
+
setDepthIndex(1);
|
|
2216
|
+
setMethodIndex(0);
|
|
2217
|
+
return;
|
|
2218
|
+
}
|
|
2219
|
+
}
|
|
2220
|
+
if (mode === "input") {
|
|
2221
|
+
if (key.tab) {
|
|
2222
|
+
if (depthIndex === DEPTH_OPTIONS.length - 1) {
|
|
2223
|
+
setDepthIndex(0);
|
|
2224
|
+
setMethodIndex((prev) => (prev + 1) % METHOD_OPTIONS.length);
|
|
2225
|
+
} else {
|
|
2226
|
+
setDepthIndex((prev) => prev + 1);
|
|
2227
|
+
}
|
|
2228
|
+
return;
|
|
2229
|
+
}
|
|
2230
|
+
}
|
|
2231
|
+
if (mode === "result") {
|
|
2232
|
+
if (key.upArrow) {
|
|
2233
|
+
setSelectedRow((prev) => Math.max(0, prev - 1));
|
|
2234
|
+
return;
|
|
2235
|
+
}
|
|
2236
|
+
if (key.downArrow) {
|
|
2237
|
+
setSelectedRow((prev) => Math.min(resultItems.length - 1, prev + 1));
|
|
2238
|
+
return;
|
|
2239
|
+
}
|
|
2240
|
+
if (input === "c") {
|
|
2241
|
+
setCommitMode("issues");
|
|
2242
|
+
setCommitResult(null);
|
|
2243
|
+
setMode("commit");
|
|
2244
|
+
return;
|
|
2245
|
+
}
|
|
2246
|
+
if (input === "r") {
|
|
2247
|
+
setRefineText("");
|
|
2248
|
+
setMode("refine");
|
|
2249
|
+
return;
|
|
2250
|
+
}
|
|
2251
|
+
if (input === "e" && resultItems[selectedRow]) {
|
|
2252
|
+
const item = resultItems[selectedRow];
|
|
2253
|
+
setEditTitle(item.title);
|
|
2254
|
+
setEditType(item.type ?? "");
|
|
2255
|
+
setEditPriority(item.priority ?? "");
|
|
2256
|
+
setEditStep("title");
|
|
2257
|
+
setMode("edit-item");
|
|
2258
|
+
return;
|
|
2259
|
+
}
|
|
2260
|
+
if (input === "b") {
|
|
2261
|
+
setMode("board");
|
|
2262
|
+
return;
|
|
2263
|
+
}
|
|
2264
|
+
if (input === "n") {
|
|
2265
|
+
setContinueFromId(currentRequirementId);
|
|
2266
|
+
setMode("input");
|
|
2267
|
+
setInputText("");
|
|
2268
|
+
setDepthIndex(1);
|
|
2269
|
+
setMethodIndex(0);
|
|
2270
|
+
return;
|
|
2271
|
+
}
|
|
2272
|
+
}
|
|
2273
|
+
if (mode === "commit" && !commitResult) {
|
|
2274
|
+
if (key.tab) {
|
|
2275
|
+
setCommitMode((prev) => prev === "issues" ? "coordinate" : "issues");
|
|
2276
|
+
return;
|
|
2277
|
+
}
|
|
2278
|
+
if (key.return && currentRequirementId) {
|
|
2279
|
+
send({
|
|
2280
|
+
action: "requirement:commit",
|
|
2281
|
+
requirementId: currentRequirementId,
|
|
2282
|
+
mode: commitMode
|
|
2283
|
+
});
|
|
2284
|
+
return;
|
|
2285
|
+
}
|
|
2286
|
+
}
|
|
2287
|
+
});
|
|
2288
|
+
const renderHistoryItem = useCallback9(
|
|
2289
|
+
(item, _index, isSelected) => /* @__PURE__ */ jsxs15(Box14, { children: [
|
|
2290
|
+
/* @__PURE__ */ jsxs15(Text15, { color: isSelected ? "cyan" : statusColor(item.status), children: [
|
|
2291
|
+
"[",
|
|
2292
|
+
item.status,
|
|
2293
|
+
"]"
|
|
2294
|
+
] }),
|
|
2295
|
+
/* @__PURE__ */ jsxs15(Text15, { color: isSelected ? "cyan" : void 0, children: [
|
|
2296
|
+
" ",
|
|
2297
|
+
item.title || item.userInput
|
|
2298
|
+
] }),
|
|
2299
|
+
/* @__PURE__ */ jsxs15(Text15, { dimColor: true, children: [
|
|
2300
|
+
" (",
|
|
2301
|
+
item.items.length,
|
|
2302
|
+
" items, ",
|
|
2303
|
+
item.depth,
|
|
2304
|
+
")"
|
|
2305
|
+
] })
|
|
2306
|
+
] }),
|
|
2307
|
+
[]
|
|
2308
|
+
);
|
|
2309
|
+
const handleSelectHistory = useCallback9(
|
|
2310
|
+
(item) => {
|
|
2311
|
+
setCurrentRequirementId(item.id);
|
|
2312
|
+
setResultItems(item.items);
|
|
2313
|
+
setResultTitle(item.title);
|
|
2314
|
+
setSelectedRow(0);
|
|
2315
|
+
setMode("result");
|
|
2316
|
+
},
|
|
2317
|
+
[]
|
|
2318
|
+
);
|
|
2319
|
+
if (mode === "history") {
|
|
2320
|
+
if (historyLoading && !history) {
|
|
2321
|
+
return /* @__PURE__ */ jsxs15(Box14, { flexDirection: "column", padding: 1, children: [
|
|
2322
|
+
/* @__PURE__ */ jsx16(Text15, { bold: true, color: "cyan", children: "Requirements" }),
|
|
2323
|
+
/* @__PURE__ */ jsx16(Text15, { dimColor: true, children: "Loading history..." })
|
|
2324
|
+
] });
|
|
2325
|
+
}
|
|
2326
|
+
const items = history ?? [];
|
|
2327
|
+
return /* @__PURE__ */ jsxs15(Box14, { flexDirection: "column", flexGrow: 1, children: [
|
|
2328
|
+
/* @__PURE__ */ jsxs15(Box14, { marginBottom: 1, children: [
|
|
2329
|
+
/* @__PURE__ */ jsx16(Text15, { bold: true, color: "cyan", children: "Requirements" }),
|
|
2330
|
+
/* @__PURE__ */ jsxs15(Text15, { dimColor: true, children: [
|
|
2331
|
+
" (",
|
|
2332
|
+
items.length,
|
|
2333
|
+
" expansions) | "
|
|
2334
|
+
] }),
|
|
2335
|
+
/* @__PURE__ */ jsx16(Text15, { dimColor: true, children: "n: new | q: quit" })
|
|
2336
|
+
] }),
|
|
2337
|
+
/* @__PURE__ */ jsx16(
|
|
2338
|
+
ScrollableList,
|
|
2339
|
+
{
|
|
2340
|
+
items,
|
|
2341
|
+
renderItem: renderHistoryItem,
|
|
2342
|
+
onSelect: handleSelectHistory
|
|
2343
|
+
}
|
|
2344
|
+
)
|
|
2345
|
+
] });
|
|
2346
|
+
}
|
|
2347
|
+
if (mode === "input") {
|
|
2348
|
+
return /* @__PURE__ */ jsxs15(Box14, { flexDirection: "column", padding: 1, children: [
|
|
2349
|
+
/* @__PURE__ */ jsx16(Text15, { bold: true, color: "cyan", children: continueFromId ? "Continue Planning" : "New Requirement" }),
|
|
2350
|
+
continueFromId && /* @__PURE__ */ jsxs15(Box14, { marginTop: 1, children: [
|
|
2351
|
+
/* @__PURE__ */ jsx16(Text15, { color: "magenta", children: "Continue from: " }),
|
|
2352
|
+
/* @__PURE__ */ jsx16(Text15, { dimColor: true, children: resultTitle || continueFromId })
|
|
2353
|
+
] }),
|
|
2354
|
+
/* @__PURE__ */ jsxs15(Box14, { marginTop: 1, children: [
|
|
2355
|
+
/* @__PURE__ */ jsx16(Text15, { children: "Text: " }),
|
|
2356
|
+
/* @__PURE__ */ jsx16(
|
|
2357
|
+
TextInput4,
|
|
2358
|
+
{
|
|
2359
|
+
placeholder: continueFromId ? "Describe additional requirements..." : "Enter requirement text...",
|
|
2360
|
+
defaultValue: inputText,
|
|
2361
|
+
onChange: setInputText,
|
|
2362
|
+
onSubmit: (value) => {
|
|
2363
|
+
if (value.trim().length > 0) {
|
|
2364
|
+
send({
|
|
2365
|
+
action: "requirement:expand",
|
|
2366
|
+
text: value.trim(),
|
|
2367
|
+
depth: DEPTH_OPTIONS[depthIndex],
|
|
2368
|
+
method: METHOD_OPTIONS[methodIndex],
|
|
2369
|
+
...continueFromId ? { previousRequirementId: continueFromId } : {}
|
|
2370
|
+
});
|
|
2371
|
+
setCurrentRequirementId(null);
|
|
2372
|
+
setContinueFromId(null);
|
|
2373
|
+
setMode("expanding");
|
|
2374
|
+
}
|
|
2375
|
+
}
|
|
2376
|
+
}
|
|
2377
|
+
)
|
|
2378
|
+
] }),
|
|
2379
|
+
/* @__PURE__ */ jsxs15(Box14, { marginTop: 1, children: [
|
|
2380
|
+
/* @__PURE__ */ jsx16(Text15, { children: "Depth: " }),
|
|
2381
|
+
DEPTH_OPTIONS.map((d, i) => /* @__PURE__ */ jsxs15(Text15, { color: i === depthIndex ? "cyan" : "gray", children: [
|
|
2382
|
+
i === depthIndex ? `[${d}]` : ` ${d} `,
|
|
2383
|
+
" "
|
|
2384
|
+
] }, d)),
|
|
2385
|
+
/* @__PURE__ */ jsx16(Text15, { children: " Method: " }),
|
|
2386
|
+
METHOD_OPTIONS.map((m, i) => /* @__PURE__ */ jsxs15(Text15, { color: i === methodIndex ? "green" : "gray", children: [
|
|
2387
|
+
i === methodIndex ? `[${m.toUpperCase()}]` : ` ${m.toUpperCase()} `,
|
|
2388
|
+
" "
|
|
2389
|
+
] }, m))
|
|
2390
|
+
] }),
|
|
2391
|
+
/* @__PURE__ */ jsx16(Box14, { marginTop: 1, children: /* @__PURE__ */ jsx16(Text15, { dimColor: true, children: "Tab: cycle depth/method | Enter: expand | Esc: cancel" }) })
|
|
2392
|
+
] });
|
|
2393
|
+
}
|
|
2394
|
+
if (mode === "expanding") {
|
|
2395
|
+
const progress = progressData?.progress ?? 0;
|
|
2396
|
+
const stage = progressData?.stage ?? "preparing";
|
|
2397
|
+
const message = progressData?.message ?? "Starting expansion...";
|
|
2398
|
+
return /* @__PURE__ */ jsxs15(Box14, { flexDirection: "column", padding: 1, children: [
|
|
2399
|
+
/* @__PURE__ */ jsx16(Text15, { bold: true, color: "cyan", children: "Expanding Requirement..." }),
|
|
2400
|
+
/* @__PURE__ */ jsxs15(Box14, { marginTop: 1, children: [
|
|
2401
|
+
/* @__PURE__ */ jsx16(Text15, { children: "Stage: " }),
|
|
2402
|
+
/* @__PURE__ */ jsx16(Text15, { color: "yellow", children: stage })
|
|
2403
|
+
] }),
|
|
2404
|
+
/* @__PURE__ */ jsx16(Box14, { marginTop: 1, children: /* @__PURE__ */ jsx16(ProgressBar2, { progress, width: 40 }) }),
|
|
2405
|
+
/* @__PURE__ */ jsx16(Box14, { marginTop: 1, children: /* @__PURE__ */ jsx16(Text15, { dimColor: true, children: message }) })
|
|
2406
|
+
] });
|
|
2407
|
+
}
|
|
2408
|
+
if (mode === "result") {
|
|
2409
|
+
return /* @__PURE__ */ jsxs15(Box14, { flexDirection: "column", flexGrow: 1, children: [
|
|
2410
|
+
/* @__PURE__ */ jsxs15(Box14, { marginBottom: 1, children: [
|
|
2411
|
+
/* @__PURE__ */ jsx16(Text15, { bold: true, color: "cyan", children: resultTitle || "Expansion Result" }),
|
|
2412
|
+
/* @__PURE__ */ jsxs15(Text15, { dimColor: true, children: [
|
|
2413
|
+
" (",
|
|
2414
|
+
resultItems.length,
|
|
2415
|
+
" items)"
|
|
2416
|
+
] })
|
|
2417
|
+
] }),
|
|
2418
|
+
/* @__PURE__ */ jsx16(
|
|
2419
|
+
DataTable,
|
|
2420
|
+
{
|
|
2421
|
+
columns: CHECKLIST_COLUMNS,
|
|
2422
|
+
data: resultItems,
|
|
2423
|
+
selectedIndex: selectedRow
|
|
2424
|
+
}
|
|
2425
|
+
),
|
|
2426
|
+
/* @__PURE__ */ jsx16(Box14, { marginTop: 1, children: /* @__PURE__ */ jsx16(Text15, { dimColor: true, children: "Up/Down: navigate | e: edit | r: refine | n: continue | c: commit | b: board | Esc: back" }) })
|
|
2427
|
+
] });
|
|
2428
|
+
}
|
|
2429
|
+
if (mode === "edit-item") {
|
|
2430
|
+
const EDIT_TYPE_OPTIONS = [
|
|
2431
|
+
{ label: "Bug", value: "bug" },
|
|
2432
|
+
{ label: "Feature", value: "feature" },
|
|
2433
|
+
{ label: "Improvement", value: "improvement" },
|
|
2434
|
+
{ label: "Task", value: "task" }
|
|
2435
|
+
];
|
|
2436
|
+
const EDIT_PRIORITY_OPTIONS = [
|
|
2437
|
+
{ label: "Low", value: "low" },
|
|
2438
|
+
{ label: "Medium", value: "medium" },
|
|
2439
|
+
{ label: "High", value: "high" },
|
|
2440
|
+
{ label: "Urgent", value: "urgent" }
|
|
2441
|
+
];
|
|
2442
|
+
return /* @__PURE__ */ jsxs15(Box14, { flexDirection: "column", padding: 1, children: [
|
|
2443
|
+
/* @__PURE__ */ jsxs15(Text15, { bold: true, color: "cyan", children: [
|
|
2444
|
+
"Edit Item #",
|
|
2445
|
+
selectedRow + 1
|
|
2446
|
+
] }),
|
|
2447
|
+
editStep === "title" && /* @__PURE__ */ jsxs15(Box14, { flexDirection: "column", marginTop: 1, children: [
|
|
2448
|
+
/* @__PURE__ */ jsx16(Text15, { children: "Title:" }),
|
|
2449
|
+
/* @__PURE__ */ jsx16(
|
|
2450
|
+
TextInput4,
|
|
2451
|
+
{
|
|
2452
|
+
placeholder: "Edit title...",
|
|
2453
|
+
defaultValue: editTitle,
|
|
2454
|
+
onChange: setEditTitle,
|
|
2455
|
+
onSubmit: () => setEditStep("type")
|
|
2456
|
+
}
|
|
2457
|
+
)
|
|
2458
|
+
] }),
|
|
2459
|
+
editStep === "type" && /* @__PURE__ */ jsxs15(Box14, { flexDirection: "column", marginTop: 1, children: [
|
|
2460
|
+
/* @__PURE__ */ jsx16(Text15, { children: "Type:" }),
|
|
2461
|
+
/* @__PURE__ */ jsx16(
|
|
2462
|
+
Select2,
|
|
2463
|
+
{
|
|
2464
|
+
options: EDIT_TYPE_OPTIONS,
|
|
2465
|
+
defaultValue: editType || "task",
|
|
2466
|
+
onChange: (value) => {
|
|
2467
|
+
setEditType(value);
|
|
2468
|
+
setEditStep("priority");
|
|
2469
|
+
}
|
|
2470
|
+
}
|
|
2471
|
+
)
|
|
2472
|
+
] }),
|
|
2473
|
+
editStep === "priority" && /* @__PURE__ */ jsxs15(Box14, { flexDirection: "column", marginTop: 1, children: [
|
|
2474
|
+
/* @__PURE__ */ jsx16(Text15, { children: "Priority:" }),
|
|
2475
|
+
/* @__PURE__ */ jsx16(
|
|
2476
|
+
Select2,
|
|
2477
|
+
{
|
|
2478
|
+
options: EDIT_PRIORITY_OPTIONS,
|
|
2479
|
+
defaultValue: editPriority || "medium",
|
|
2480
|
+
onChange: (value) => {
|
|
2481
|
+
setEditPriority(value);
|
|
2482
|
+
setResultItems(
|
|
2483
|
+
(prev) => prev.map(
|
|
2484
|
+
(item, i) => i === selectedRow ? { ...item, title: editTitle, type: editType, priority: value } : item
|
|
2485
|
+
)
|
|
2486
|
+
);
|
|
2487
|
+
setMode("result");
|
|
2488
|
+
}
|
|
2489
|
+
}
|
|
2490
|
+
)
|
|
2491
|
+
] }),
|
|
2492
|
+
/* @__PURE__ */ jsx16(Box14, { marginTop: 1, children: /* @__PURE__ */ jsx16(Text15, { dimColor: true, children: "Esc=cancel" }) })
|
|
2493
|
+
] });
|
|
2494
|
+
}
|
|
2495
|
+
if (mode === "board") {
|
|
2496
|
+
const boardItems = resultItems.map((item) => ({
|
|
2497
|
+
title: item.title,
|
|
2498
|
+
status: "open",
|
|
2499
|
+
executor: void 0,
|
|
2500
|
+
issueId: void 0
|
|
2501
|
+
}));
|
|
2502
|
+
return /* @__PURE__ */ jsx16(
|
|
2503
|
+
RequirementBoard,
|
|
2504
|
+
{
|
|
2505
|
+
items: boardItems,
|
|
2506
|
+
onBack: () => setMode("result")
|
|
2507
|
+
}
|
|
2508
|
+
);
|
|
2509
|
+
}
|
|
2510
|
+
if (mode === "refine") {
|
|
2511
|
+
return /* @__PURE__ */ jsxs15(Box14, { flexDirection: "column", padding: 1, children: [
|
|
2512
|
+
/* @__PURE__ */ jsx16(Text15, { bold: true, color: "magenta", children: "Refine Requirement" }),
|
|
2513
|
+
/* @__PURE__ */ jsxs15(Box14, { marginTop: 1, children: [
|
|
2514
|
+
/* @__PURE__ */ jsx16(Text15, { dimColor: true, children: "Current: " }),
|
|
2515
|
+
/* @__PURE__ */ jsx16(Text15, { children: resultTitle }),
|
|
2516
|
+
/* @__PURE__ */ jsxs15(Text15, { dimColor: true, children: [
|
|
2517
|
+
" (",
|
|
2518
|
+
resultItems.length,
|
|
2519
|
+
" items)"
|
|
2520
|
+
] })
|
|
2521
|
+
] }),
|
|
2522
|
+
/* @__PURE__ */ jsxs15(Box14, { marginTop: 1, children: [
|
|
2523
|
+
/* @__PURE__ */ jsx16(Text15, { children: "Feedback: " }),
|
|
2524
|
+
/* @__PURE__ */ jsx16(
|
|
2525
|
+
TextInput4,
|
|
2526
|
+
{
|
|
2527
|
+
placeholder: "Provide feedback to refine this expansion...",
|
|
2528
|
+
defaultValue: refineText,
|
|
2529
|
+
onChange: setRefineText,
|
|
2530
|
+
onSubmit: (value) => {
|
|
2531
|
+
if (value.trim().length > 0 && currentRequirementId) {
|
|
2532
|
+
send({
|
|
2533
|
+
action: "requirement:refine",
|
|
2534
|
+
requirementId: currentRequirementId,
|
|
2535
|
+
feedback: value.trim()
|
|
2536
|
+
});
|
|
2537
|
+
setRefineText("");
|
|
2538
|
+
setMode("expanding");
|
|
2539
|
+
}
|
|
2540
|
+
}
|
|
2541
|
+
}
|
|
2542
|
+
)
|
|
2543
|
+
] }),
|
|
2544
|
+
/* @__PURE__ */ jsx16(Box14, { marginTop: 1, children: /* @__PURE__ */ jsx16(Text15, { dimColor: true, children: "Enter: send feedback | Esc: back to result" }) })
|
|
2545
|
+
] });
|
|
2546
|
+
}
|
|
2547
|
+
if (mode === "commit") {
|
|
2548
|
+
if (commitResult) {
|
|
2549
|
+
return /* @__PURE__ */ jsxs15(Box14, { flexDirection: "column", padding: 1, children: [
|
|
2550
|
+
/* @__PURE__ */ jsx16(Text15, { bold: true, color: "green", children: "Commit Complete" }),
|
|
2551
|
+
/* @__PURE__ */ jsx16(Box14, { marginTop: 1, children: /* @__PURE__ */ jsx16(Text15, { children: commitResult }) }),
|
|
2552
|
+
/* @__PURE__ */ jsx16(Box14, { marginTop: 1, children: /* @__PURE__ */ jsx16(Text15, { dimColor: true, children: "Esc: back to history" }) })
|
|
2553
|
+
] });
|
|
2554
|
+
}
|
|
2555
|
+
return /* @__PURE__ */ jsxs15(Box14, { flexDirection: "column", padding: 1, children: [
|
|
2556
|
+
/* @__PURE__ */ jsx16(Text15, { bold: true, color: "cyan", children: "Commit Requirement" }),
|
|
2557
|
+
/* @__PURE__ */ jsxs15(Box14, { marginTop: 1, children: [
|
|
2558
|
+
/* @__PURE__ */ jsx16(Text15, { children: "Mode: " }),
|
|
2559
|
+
/* @__PURE__ */ jsx16(Text15, { color: commitMode === "issues" ? "cyan" : "gray", children: commitMode === "issues" ? "[issues]" : " issues " }),
|
|
2560
|
+
/* @__PURE__ */ jsx16(Text15, { children: " " }),
|
|
2561
|
+
/* @__PURE__ */ jsx16(Text15, { color: commitMode === "coordinate" ? "cyan" : "gray", children: commitMode === "coordinate" ? "[coordinate]" : " coordinate " })
|
|
2562
|
+
] }),
|
|
2563
|
+
/* @__PURE__ */ jsx16(Box14, { marginTop: 1, children: /* @__PURE__ */ jsx16(Text15, { dimColor: true, children: commitMode === "issues" ? "Creates individual issues from checklist items" : "Starts a coordinate session to execute items" }) }),
|
|
2564
|
+
/* @__PURE__ */ jsx16(Box14, { marginTop: 1, children: /* @__PURE__ */ jsx16(Text15, { dimColor: true, children: "Tab: toggle mode | Enter: confirm | Esc: cancel" }) })
|
|
2565
|
+
] });
|
|
2566
|
+
}
|
|
2567
|
+
return null;
|
|
2568
|
+
}
|
|
2569
|
+
function statusColor(status) {
|
|
2570
|
+
switch (status) {
|
|
2571
|
+
case "done":
|
|
2572
|
+
return "green";
|
|
2573
|
+
case "expanding":
|
|
2574
|
+
return "yellow";
|
|
2575
|
+
case "reviewing":
|
|
2576
|
+
return "blue";
|
|
2577
|
+
case "failed":
|
|
2578
|
+
return "red";
|
|
2579
|
+
case "committing":
|
|
2580
|
+
return "magenta";
|
|
2581
|
+
default:
|
|
2582
|
+
return "gray";
|
|
2583
|
+
}
|
|
2584
|
+
}
|
|
2585
|
+
|
|
2586
|
+
// src/views/ExecutionView.tsx
|
|
2587
|
+
import { useState as useState11, useEffect as useEffect7, useRef as useRef6, useCallback as useCallback12 } from "react";
|
|
2588
|
+
import { Box as Box20, Text as Text21, useInput as useInput11 } from "ink";
|
|
2589
|
+
|
|
2590
|
+
// src/views/execution/CommanderTab.tsx
|
|
2591
|
+
import { Box as Box15, Text as Text16 } from "ink";
|
|
2592
|
+
import { jsx as jsx17, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
2593
|
+
function CommanderTab() {
|
|
2594
|
+
const status = useWsEvent("commander:status");
|
|
2595
|
+
const decision = useWsEvent("commander:decision");
|
|
2596
|
+
const { data: config } = useApi("/api/commander/config");
|
|
2597
|
+
return /* @__PURE__ */ jsxs16(Box15, { flexDirection: "column", children: [
|
|
2598
|
+
/* @__PURE__ */ jsx17(Text16, { bold: true, dimColor: true, children: "Commander" }),
|
|
2599
|
+
/* @__PURE__ */ jsxs16(Box15, { flexDirection: "column", marginTop: 1, children: [
|
|
2600
|
+
/* @__PURE__ */ jsxs16(Box15, { gap: 2, children: [
|
|
2601
|
+
/* @__PURE__ */ jsxs16(Box15, { children: [
|
|
2602
|
+
/* @__PURE__ */ jsx17(Text16, { dimColor: true, children: "State: " }),
|
|
2603
|
+
/* @__PURE__ */ jsx17(Text16, { color: status?.state === "running" ? "green" : status?.state === "paused" ? "yellow" : "gray", children: status?.state ?? "unknown" })
|
|
2604
|
+
] }),
|
|
2605
|
+
/* @__PURE__ */ jsxs16(Box15, { children: [
|
|
2606
|
+
/* @__PURE__ */ jsx17(Text16, { dimColor: true, children: "Workers: " }),
|
|
2607
|
+
/* @__PURE__ */ jsx17(Text16, { children: status?.activeWorkers ?? 0 })
|
|
2608
|
+
] }),
|
|
2609
|
+
/* @__PURE__ */ jsxs16(Box15, { children: [
|
|
2610
|
+
/* @__PURE__ */ jsx17(Text16, { dimColor: true, children: "Ticks: " }),
|
|
2611
|
+
/* @__PURE__ */ jsx17(Text16, { children: status?.totalTicks ?? 0 })
|
|
2612
|
+
] })
|
|
2613
|
+
] }),
|
|
2614
|
+
status?.lastError && /* @__PURE__ */ jsxs16(Text16, { color: "red", children: [
|
|
2615
|
+
"Error: ",
|
|
2616
|
+
status.lastError
|
|
2617
|
+
] })
|
|
2618
|
+
] }),
|
|
2619
|
+
decision && /* @__PURE__ */ jsxs16(Box15, { flexDirection: "column", marginTop: 1, children: [
|
|
2620
|
+
/* @__PURE__ */ jsx17(Text16, { bold: true, dimColor: true, children: "Last Decision" }),
|
|
2621
|
+
/* @__PURE__ */ jsxs16(Box15, { gap: 1, children: [
|
|
2622
|
+
/* @__PURE__ */ jsx17(Text16, { color: "cyan", children: decision.action }),
|
|
2623
|
+
decision.issueId && /* @__PURE__ */ jsxs16(Text16, { dimColor: true, children: [
|
|
2624
|
+
"issue: ",
|
|
2625
|
+
decision.issueId
|
|
2626
|
+
] })
|
|
2627
|
+
] }),
|
|
2628
|
+
decision.reason && /* @__PURE__ */ jsx17(Text16, { dimColor: true, children: decision.reason })
|
|
2629
|
+
] }),
|
|
2630
|
+
config && /* @__PURE__ */ jsxs16(Box15, { flexDirection: "column", marginTop: 1, children: [
|
|
2631
|
+
/* @__PURE__ */ jsx17(Text16, { bold: true, dimColor: true, children: "Config" }),
|
|
2632
|
+
/* @__PURE__ */ jsxs16(Box15, { gap: 1, children: [
|
|
2633
|
+
/* @__PURE__ */ jsx17(Text16, { dimColor: true, children: "Profile:" }),
|
|
2634
|
+
/* @__PURE__ */ jsx17(Text16, { children: config.profile })
|
|
2635
|
+
] }),
|
|
2636
|
+
/* @__PURE__ */ jsxs16(Box15, { gap: 1, children: [
|
|
2637
|
+
/* @__PURE__ */ jsx17(Text16, { dimColor: true, children: "Model:" }),
|
|
2638
|
+
/* @__PURE__ */ jsx17(Text16, { children: config.decisionModel })
|
|
2639
|
+
] }),
|
|
2640
|
+
/* @__PURE__ */ jsxs16(Box15, { gap: 1, children: [
|
|
2641
|
+
/* @__PURE__ */ jsx17(Text16, { dimColor: true, children: "Max workers:" }),
|
|
2642
|
+
/* @__PURE__ */ jsx17(Text16, { children: config.maxConcurrentWorkers })
|
|
2643
|
+
] }),
|
|
2644
|
+
/* @__PURE__ */ jsxs16(Box15, { gap: 1, children: [
|
|
2645
|
+
/* @__PURE__ */ jsx17(Text16, { dimColor: true, children: "Auto-approve:" }),
|
|
2646
|
+
/* @__PURE__ */ jsx17(Text16, { children: config.autoApproveThreshold })
|
|
2647
|
+
] }),
|
|
2648
|
+
/* @__PURE__ */ jsxs16(Box15, { gap: 1, children: [
|
|
2649
|
+
/* @__PURE__ */ jsx17(Text16, { dimColor: true, children: "Poll interval:" }),
|
|
2650
|
+
/* @__PURE__ */ jsxs16(Text16, { children: [
|
|
2651
|
+
config.pollIntervalMs,
|
|
2652
|
+
"ms"
|
|
2653
|
+
] })
|
|
2654
|
+
] })
|
|
2655
|
+
] })
|
|
2656
|
+
] });
|
|
2657
|
+
}
|
|
2658
|
+
|
|
2659
|
+
// src/views/execution/CoordinatorTab.tsx
|
|
2660
|
+
import React11, { useState as useState10, useCallback as useCallback10 } from "react";
|
|
2661
|
+
import { Box as Box16, Text as Text17, useInput as useInput10 } from "ink";
|
|
2662
|
+
import { TextInput as TextInput5 } from "@inkjs/ui";
|
|
2663
|
+
import { Fragment, jsx as jsx18, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
2664
|
+
function CoordinatorTab() {
|
|
2665
|
+
const [subMode, setSubMode] = useState10("list");
|
|
2666
|
+
const [intentText, setIntentText] = useState10("");
|
|
2667
|
+
const [clarifyText, setClarifyText] = useState10("");
|
|
2668
|
+
const [steps, setSteps] = useState10([]);
|
|
2669
|
+
const { send } = useWs();
|
|
2670
|
+
const status = useWsEvent("coordinate:status");
|
|
2671
|
+
const stepEvt = useWsEvent("coordinate:step");
|
|
2672
|
+
const clarification = useWsEvent("coordinate:clarification_needed");
|
|
2673
|
+
React11.useEffect(() => {
|
|
2674
|
+
if (stepEvt) {
|
|
2675
|
+
setSteps((prev) => {
|
|
2676
|
+
const exists = prev.find((s) => s.step === stepEvt.step && s.sessionId === stepEvt.sessionId);
|
|
2677
|
+
if (exists) return prev.map((s) => s.step === stepEvt.step && s.sessionId === stepEvt.sessionId ? stepEvt : s);
|
|
2678
|
+
return [...prev, stepEvt];
|
|
2679
|
+
});
|
|
2680
|
+
}
|
|
2681
|
+
}, [stepEvt]);
|
|
2682
|
+
useInput10((input, key) => {
|
|
2683
|
+
if (key.escape) {
|
|
2684
|
+
if (subMode === "input" || subMode === "clarify") {
|
|
2685
|
+
setSubMode("list");
|
|
2686
|
+
return;
|
|
2687
|
+
}
|
|
2688
|
+
}
|
|
2689
|
+
if (subMode === "list") {
|
|
2690
|
+
if (input === "n") {
|
|
2691
|
+
setIntentText("");
|
|
2692
|
+
setSubMode("input");
|
|
2693
|
+
return;
|
|
2694
|
+
}
|
|
2695
|
+
if (input === "x" && status?.sessionId) {
|
|
2696
|
+
send({ action: "coordinate:stop" });
|
|
2697
|
+
return;
|
|
2698
|
+
}
|
|
2699
|
+
}
|
|
2700
|
+
}, { isActive: subMode === "list" });
|
|
2701
|
+
const handleSubmitIntent = useCallback10((value) => {
|
|
2702
|
+
const trimmed = value.trim();
|
|
2703
|
+
if (!trimmed) return;
|
|
2704
|
+
send({ action: "coordinate:start", intent: trimmed });
|
|
2705
|
+
setIntentText("");
|
|
2706
|
+
setSteps([]);
|
|
2707
|
+
setSubMode("list");
|
|
2708
|
+
}, [send]);
|
|
2709
|
+
const handleSubmitClarify = useCallback10((value) => {
|
|
2710
|
+
const trimmed = value.trim();
|
|
2711
|
+
if (!trimmed || !status?.sessionId) return;
|
|
2712
|
+
send({ action: "coordinate:clarify", sessionId: status.sessionId, response: trimmed });
|
|
2713
|
+
setClarifyText("");
|
|
2714
|
+
setSubMode("list");
|
|
2715
|
+
}, [send, status?.sessionId]);
|
|
2716
|
+
React11.useEffect(() => {
|
|
2717
|
+
if (clarification) setSubMode("clarify");
|
|
2718
|
+
}, [clarification]);
|
|
2719
|
+
const renderStep = useCallback10(
|
|
2720
|
+
(step, _index, isSelected) => /* @__PURE__ */ jsxs17(Box16, { gap: 1, children: [
|
|
2721
|
+
/* @__PURE__ */ jsx18(StatusDot, { status: step.status, showLabel: false }),
|
|
2722
|
+
/* @__PURE__ */ jsx18(Text17, { color: isSelected ? "cyan" : void 0, children: step.step }),
|
|
2723
|
+
/* @__PURE__ */ jsxs17(Text17, { dimColor: true, children: [
|
|
2724
|
+
"(",
|
|
2725
|
+
step.status,
|
|
2726
|
+
")"
|
|
2727
|
+
] }),
|
|
2728
|
+
step.detail && /* @__PURE__ */ jsx18(Text17, { dimColor: true, children: step.detail.slice(0, 40) })
|
|
2729
|
+
] }),
|
|
2730
|
+
[]
|
|
2731
|
+
);
|
|
2732
|
+
if (subMode === "input") {
|
|
2733
|
+
return /* @__PURE__ */ jsxs17(Box16, { flexDirection: "column", children: [
|
|
2734
|
+
/* @__PURE__ */ jsx18(Text17, { bold: true, dimColor: true, children: "New Coordinate Session" }),
|
|
2735
|
+
/* @__PURE__ */ jsxs17(Box16, { marginTop: 1, children: [
|
|
2736
|
+
/* @__PURE__ */ jsx18(Text17, { children: "Intent: " }),
|
|
2737
|
+
/* @__PURE__ */ jsx18(
|
|
2738
|
+
TextInput5,
|
|
2739
|
+
{
|
|
2740
|
+
placeholder: "Describe the coordination intent...",
|
|
2741
|
+
defaultValue: intentText,
|
|
2742
|
+
onChange: setIntentText,
|
|
2743
|
+
onSubmit: handleSubmitIntent
|
|
2744
|
+
}
|
|
2745
|
+
)
|
|
2746
|
+
] }),
|
|
2747
|
+
/* @__PURE__ */ jsx18(Text17, { dimColor: true, children: "Enter=start | Esc=cancel" })
|
|
2748
|
+
] });
|
|
2749
|
+
}
|
|
2750
|
+
if (subMode === "clarify" && clarification) {
|
|
2751
|
+
return /* @__PURE__ */ jsxs17(Box16, { flexDirection: "column", children: [
|
|
2752
|
+
/* @__PURE__ */ jsx18(Text17, { bold: true, color: "yellow", children: "Clarification Needed" }),
|
|
2753
|
+
/* @__PURE__ */ jsx18(Text17, { children: clarification.question }),
|
|
2754
|
+
/* @__PURE__ */ jsxs17(Box16, { marginTop: 1, children: [
|
|
2755
|
+
/* @__PURE__ */ jsx18(Text17, { children: "Response: " }),
|
|
2756
|
+
/* @__PURE__ */ jsx18(
|
|
2757
|
+
TextInput5,
|
|
2758
|
+
{
|
|
2759
|
+
placeholder: "Answer...",
|
|
2760
|
+
defaultValue: clarifyText,
|
|
2761
|
+
onChange: setClarifyText,
|
|
2762
|
+
onSubmit: handleSubmitClarify
|
|
2763
|
+
}
|
|
2764
|
+
)
|
|
2765
|
+
] }),
|
|
2766
|
+
/* @__PURE__ */ jsx18(Text17, { dimColor: true, children: "Enter=send | Esc=cancel" })
|
|
2767
|
+
] });
|
|
2768
|
+
}
|
|
2769
|
+
return /* @__PURE__ */ jsxs17(Box16, { flexDirection: "column", children: [
|
|
2770
|
+
/* @__PURE__ */ jsxs17(Box16, { gap: 2, children: [
|
|
2771
|
+
/* @__PURE__ */ jsx18(Text17, { bold: true, dimColor: true, children: "Coordinator" }),
|
|
2772
|
+
status && /* @__PURE__ */ jsxs17(Fragment, { children: [
|
|
2773
|
+
/* @__PURE__ */ jsx18(StatusDot, { status: status.status, showLabel: true }),
|
|
2774
|
+
status.sessionId && /* @__PURE__ */ jsxs17(Text17, { dimColor: true, children: [
|
|
2775
|
+
"(",
|
|
2776
|
+
status.sessionId,
|
|
2777
|
+
")"
|
|
2778
|
+
] })
|
|
2779
|
+
] })
|
|
2780
|
+
] }),
|
|
2781
|
+
status?.message && /* @__PURE__ */ jsx18(Box16, { marginTop: 1, children: /* @__PURE__ */ jsx18(Text17, { dimColor: true, children: status.message }) }),
|
|
2782
|
+
/* @__PURE__ */ jsx18(Box16, { marginTop: 1, flexDirection: "column", flexGrow: 1, children: steps.length === 0 ? /* @__PURE__ */ jsx18(Text17, { dimColor: true, children: "No coordinate steps yet." }) : /* @__PURE__ */ jsx18(
|
|
2783
|
+
ScrollableList,
|
|
2784
|
+
{
|
|
2785
|
+
items: steps,
|
|
2786
|
+
renderItem: renderStep,
|
|
2787
|
+
isFocused: true
|
|
2788
|
+
}
|
|
2789
|
+
) }),
|
|
2790
|
+
/* @__PURE__ */ jsx18(Box16, { marginTop: 1, children: /* @__PURE__ */ jsx18(Text17, { dimColor: true, children: "n=new session x=stop" }) })
|
|
2791
|
+
] });
|
|
2792
|
+
}
|
|
2793
|
+
|
|
2794
|
+
// src/views/execution/ScheduleTab.tsx
|
|
2795
|
+
import { Box as Box17, Text as Text18 } from "ink";
|
|
2796
|
+
import { jsx as jsx19, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
2797
|
+
var COLUMNS2 = [
|
|
2798
|
+
{ key: "name", label: "Name", width: 20 },
|
|
2799
|
+
{ key: "cron", label: "Cron", width: 16 },
|
|
2800
|
+
{ key: "type", label: "Type", width: 12 },
|
|
2801
|
+
{
|
|
2802
|
+
key: "enabled",
|
|
2803
|
+
label: "Enabled",
|
|
2804
|
+
width: 10,
|
|
2805
|
+
render: (value) => /* @__PURE__ */ jsx19(Text18, { color: value ? "green" : "gray", children: value ? "yes" : "no" })
|
|
2806
|
+
},
|
|
2807
|
+
{
|
|
2808
|
+
key: "lastRun",
|
|
2809
|
+
label: "Last Run",
|
|
2810
|
+
width: 20,
|
|
2811
|
+
render: (value) => /* @__PURE__ */ jsx19(Text18, { dimColor: true, children: value ? String(value).slice(0, 19) : "-" })
|
|
2812
|
+
}
|
|
2813
|
+
];
|
|
2814
|
+
function ScheduleTab() {
|
|
2815
|
+
const { data, loading } = useApi(
|
|
2816
|
+
"/api/supervisor/schedules",
|
|
2817
|
+
{ pollInterval: 1e4 }
|
|
2818
|
+
);
|
|
2819
|
+
return /* @__PURE__ */ jsxs18(Box17, { flexDirection: "column", children: [
|
|
2820
|
+
/* @__PURE__ */ jsx19(Text18, { bold: true, dimColor: true, children: "Schedules" }),
|
|
2821
|
+
loading && !data ? /* @__PURE__ */ jsx19(Text18, { dimColor: true, children: "Loading schedules..." }) : /* @__PURE__ */ jsx19(DataTable, { columns: COLUMNS2, data: data ?? [] })
|
|
2822
|
+
] });
|
|
2823
|
+
}
|
|
2824
|
+
|
|
2825
|
+
// src/views/execution/LearningTab.tsx
|
|
2826
|
+
import { Box as Box18, Text as Text19 } from "ink";
|
|
2827
|
+
import { jsx as jsx20, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
2828
|
+
function LearningTab() {
|
|
2829
|
+
const { data, loading } = useApi(
|
|
2830
|
+
"/api/supervisor/learning/stats",
|
|
2831
|
+
{ pollInterval: 15e3 }
|
|
2832
|
+
);
|
|
2833
|
+
if (loading && !data) {
|
|
2834
|
+
return /* @__PURE__ */ jsx20(Text19, { dimColor: true, children: "Loading learning stats..." });
|
|
2835
|
+
}
|
|
2836
|
+
if (!data) {
|
|
2837
|
+
return /* @__PURE__ */ jsx20(Text19, { dimColor: true, children: "No learning data available." });
|
|
2838
|
+
}
|
|
2839
|
+
return /* @__PURE__ */ jsxs19(Box18, { flexDirection: "column", children: [
|
|
2840
|
+
/* @__PURE__ */ jsx20(Text19, { bold: true, dimColor: true, children: "Learning" }),
|
|
2841
|
+
/* @__PURE__ */ jsxs19(Box18, { gap: 2, marginTop: 1, children: [
|
|
2842
|
+
/* @__PURE__ */ jsxs19(Box18, { children: [
|
|
2843
|
+
/* @__PURE__ */ jsx20(Text19, { dimColor: true, children: "Total commands: " }),
|
|
2844
|
+
/* @__PURE__ */ jsx20(Text19, { children: data.totalCommands })
|
|
2845
|
+
] }),
|
|
2846
|
+
/* @__PURE__ */ jsxs19(Box18, { children: [
|
|
2847
|
+
/* @__PURE__ */ jsx20(Text19, { dimColor: true, children: "Unique patterns: " }),
|
|
2848
|
+
/* @__PURE__ */ jsx20(Text19, { children: data.uniquePatterns })
|
|
2849
|
+
] })
|
|
2850
|
+
] }),
|
|
2851
|
+
data.topPatterns.length > 0 && /* @__PURE__ */ jsxs19(Box18, { flexDirection: "column", marginTop: 1, children: [
|
|
2852
|
+
/* @__PURE__ */ jsx20(Text19, { bold: true, dimColor: true, children: "Top Patterns" }),
|
|
2853
|
+
data.topPatterns.slice(0, 10).map((p, i) => /* @__PURE__ */ jsxs19(Box18, { gap: 1, children: [
|
|
2854
|
+
/* @__PURE__ */ jsxs19(Text19, { dimColor: true, children: [
|
|
2855
|
+
(i + 1).toString().padStart(2),
|
|
2856
|
+
"."
|
|
2857
|
+
] }),
|
|
2858
|
+
/* @__PURE__ */ jsx20(Text19, { children: p.pattern }),
|
|
2859
|
+
/* @__PURE__ */ jsxs19(Text19, { dimColor: true, children: [
|
|
2860
|
+
"(",
|
|
2861
|
+
p.count,
|
|
2862
|
+
")"
|
|
2863
|
+
] })
|
|
2864
|
+
] }, i))
|
|
2865
|
+
] })
|
|
2866
|
+
] });
|
|
2867
|
+
}
|
|
2868
|
+
|
|
2869
|
+
// src/views/execution/ExtensionsTab.tsx
|
|
2870
|
+
import { useCallback as useCallback11 } from "react";
|
|
2871
|
+
import { Box as Box19, Text as Text20 } from "ink";
|
|
2872
|
+
import { jsx as jsx21, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
2873
|
+
function ExtensionsTab() {
|
|
2874
|
+
const { data, loading } = useApi(
|
|
2875
|
+
"/api/supervisor/extensions",
|
|
2876
|
+
{ pollInterval: 15e3 }
|
|
2877
|
+
);
|
|
2878
|
+
const renderItem = useCallback11(
|
|
2879
|
+
(ext, _index, isSelected) => /* @__PURE__ */ jsxs20(Box19, { gap: 1, children: [
|
|
2880
|
+
/* @__PURE__ */ jsxs20(Text20, { color: ext.status === "loaded" ? "green" : ext.status === "error" ? "red" : "gray", children: [
|
|
2881
|
+
"[",
|
|
2882
|
+
ext.status,
|
|
2883
|
+
"]"
|
|
2884
|
+
] }),
|
|
2885
|
+
/* @__PURE__ */ jsx21(Text20, { color: isSelected ? "cyan" : void 0, bold: isSelected, children: ext.name }),
|
|
2886
|
+
/* @__PURE__ */ jsxs20(Text20, { dimColor: true, children: [
|
|
2887
|
+
"v",
|
|
2888
|
+
ext.version
|
|
2889
|
+
] })
|
|
2890
|
+
] }),
|
|
2891
|
+
[]
|
|
2892
|
+
);
|
|
2893
|
+
if (loading && !data) {
|
|
2894
|
+
return /* @__PURE__ */ jsx21(Text20, { dimColor: true, children: "Loading extensions..." });
|
|
2895
|
+
}
|
|
2896
|
+
const items = data ?? [];
|
|
2897
|
+
return /* @__PURE__ */ jsxs20(Box19, { flexDirection: "column", children: [
|
|
2898
|
+
/* @__PURE__ */ jsx21(Text20, { bold: true, dimColor: true, children: "Extensions" }),
|
|
2899
|
+
items.length === 0 ? /* @__PURE__ */ jsx21(Text20, { dimColor: true, children: "No extensions loaded." }) : /* @__PURE__ */ jsx21(ScrollableList, { items, renderItem })
|
|
2900
|
+
] });
|
|
2901
|
+
}
|
|
2902
|
+
|
|
2903
|
+
// src/views/ExecutionView.tsx
|
|
2904
|
+
import { Fragment as Fragment2, jsx as jsx22, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
2905
|
+
var TABS = ["Monitor", "Commander", "Coordinator", "Schedule", "Learning", "Extensions"];
|
|
2906
|
+
function ElapsedTime({ startedAt }) {
|
|
2907
|
+
const [elapsed, setElapsed] = useState11("");
|
|
2908
|
+
const startRef = useRef6(new Date(startedAt).getTime());
|
|
2909
|
+
useEffect7(() => {
|
|
2910
|
+
startRef.current = new Date(startedAt).getTime();
|
|
2911
|
+
function update() {
|
|
2912
|
+
const diff = Math.floor((Date.now() - startRef.current) / 1e3);
|
|
2913
|
+
const mins = Math.floor(diff / 60);
|
|
2914
|
+
const secs = diff % 60;
|
|
2915
|
+
setElapsed(`${mins}m ${secs.toString().padStart(2, "0")}s`);
|
|
2916
|
+
}
|
|
2917
|
+
update();
|
|
2918
|
+
const timer = setInterval(update, 1e3);
|
|
2919
|
+
return () => clearInterval(timer);
|
|
2920
|
+
}, [startedAt]);
|
|
2921
|
+
return /* @__PURE__ */ jsx22(Text21, { color: "yellow", children: elapsed });
|
|
2922
|
+
}
|
|
2923
|
+
function ExecutionView() {
|
|
2924
|
+
const [activeTab, setActiveTab] = useState11(0);
|
|
2925
|
+
const [monitorMode, setMonitorMode] = useState11("monitor");
|
|
2926
|
+
const [dispatchConfirm, setDispatchConfirm] = useState11(null);
|
|
2927
|
+
const [dispatchResult, setDispatchResult] = useState11(null);
|
|
2928
|
+
const [batchSelected, setBatchSelected] = useState11(/* @__PURE__ */ new Set());
|
|
2929
|
+
const [batchConfirm, setBatchConfirm] = useState11(false);
|
|
2930
|
+
const [highlightedIssue, setHighlightedIssue] = useState11(null);
|
|
2931
|
+
const baseUrl = useBaseUrl();
|
|
2932
|
+
const { send } = useWs();
|
|
2933
|
+
const schedulerData = useWsEvent("execution:scheduler_status");
|
|
2934
|
+
const { data: restStatus } = useApi(
|
|
2935
|
+
EXECUTION_API_ENDPOINTS.STATUS,
|
|
2936
|
+
{ pollInterval: 5e3 }
|
|
2937
|
+
);
|
|
2938
|
+
const status = schedulerData ?? restStatus;
|
|
2939
|
+
const { data: allIssues, loading: issuesLoading, refetch: refetchIssues } = useApi(
|
|
2940
|
+
ISSUE_API_ENDPOINTS.ISSUES,
|
|
2941
|
+
{ skip: activeTab !== 0 || monitorMode !== "dispatch" }
|
|
2942
|
+
);
|
|
2943
|
+
const runningIds = new Set(status?.running.map((s) => s.issueId) ?? []);
|
|
2944
|
+
const queuedIds = new Set(status?.queued ?? []);
|
|
2945
|
+
const dispatchableIssues = (allIssues ?? []).filter(
|
|
2946
|
+
(issue) => (issue.status === "open" || issue.status === "registered") && !runningIds.has(issue.id) && !queuedIds.has(issue.id)
|
|
2947
|
+
);
|
|
2948
|
+
useInput11((input, key) => {
|
|
2949
|
+
if (key.escape) {
|
|
2950
|
+
if (batchConfirm) {
|
|
2951
|
+
setBatchConfirm(false);
|
|
2952
|
+
return;
|
|
2953
|
+
}
|
|
2954
|
+
if (dispatchConfirm) {
|
|
2955
|
+
setDispatchConfirm(null);
|
|
2956
|
+
setDispatchResult(null);
|
|
2957
|
+
return;
|
|
2958
|
+
}
|
|
2959
|
+
if (monitorMode === "dispatch") {
|
|
2960
|
+
setMonitorMode("monitor");
|
|
2961
|
+
setDispatchResult(null);
|
|
2962
|
+
setBatchSelected(/* @__PURE__ */ new Set());
|
|
2963
|
+
return;
|
|
2964
|
+
}
|
|
2965
|
+
}
|
|
2966
|
+
if (activeTab === 0 && monitorMode === "monitor") {
|
|
2967
|
+
if (input === "d") {
|
|
2968
|
+
setMonitorMode("dispatch");
|
|
2969
|
+
setDispatchResult(null);
|
|
2970
|
+
refetchIssues();
|
|
2971
|
+
return;
|
|
2972
|
+
}
|
|
2973
|
+
if (input === "t") {
|
|
2974
|
+
const enabled = !status?.enabled;
|
|
2975
|
+
fetch(`${baseUrl}${EXECUTION_API_ENDPOINTS.SUPERVISOR}`, {
|
|
2976
|
+
method: "PUT",
|
|
2977
|
+
headers: { "Content-Type": "application/json" },
|
|
2978
|
+
body: JSON.stringify({ enabled })
|
|
2979
|
+
}).catch(() => {
|
|
2980
|
+
});
|
|
2981
|
+
return;
|
|
2982
|
+
}
|
|
2983
|
+
}
|
|
2984
|
+
if (activeTab === 0 && monitorMode === "dispatch" && !dispatchConfirm && !batchConfirm) {
|
|
2985
|
+
if (input === " " && highlightedIssue) {
|
|
2986
|
+
toggleBatch(highlightedIssue);
|
|
2987
|
+
return;
|
|
2988
|
+
}
|
|
2989
|
+
if (input === "b" && batchSelected.size > 0) {
|
|
2990
|
+
setBatchConfirm(true);
|
|
2991
|
+
return;
|
|
2992
|
+
}
|
|
2993
|
+
}
|
|
2994
|
+
if (dispatchConfirm && !dispatchResult && key.return) {
|
|
2995
|
+
performDispatch(dispatchConfirm);
|
|
2996
|
+
return;
|
|
2997
|
+
}
|
|
2998
|
+
});
|
|
2999
|
+
const performDispatch = useCallback12(async (issue) => {
|
|
3000
|
+
try {
|
|
3001
|
+
const res = await fetch(`${baseUrl}${EXECUTION_API_ENDPOINTS.DISPATCH}`, {
|
|
3002
|
+
method: "POST",
|
|
3003
|
+
headers: { "Content-Type": "application/json" },
|
|
3004
|
+
body: JSON.stringify({ issueId: issue.id })
|
|
3005
|
+
});
|
|
3006
|
+
if (!res.ok) {
|
|
3007
|
+
setDispatchResult(`Error: ${res.status} ${res.statusText}`);
|
|
3008
|
+
} else {
|
|
3009
|
+
setDispatchResult(`Dispatched: ${issue.id} - ${issue.title}`);
|
|
3010
|
+
}
|
|
3011
|
+
} catch (err) {
|
|
3012
|
+
setDispatchResult(`Error: ${err instanceof Error ? err.message : String(err)}`);
|
|
3013
|
+
}
|
|
3014
|
+
}, [baseUrl]);
|
|
3015
|
+
const performBatchDispatch = useCallback12(async () => {
|
|
3016
|
+
try {
|
|
3017
|
+
const res = await fetch(`${baseUrl}${EXECUTION_API_ENDPOINTS.BATCH}`, {
|
|
3018
|
+
method: "POST",
|
|
3019
|
+
headers: { "Content-Type": "application/json" },
|
|
3020
|
+
body: JSON.stringify({ issueIds: Array.from(batchSelected) })
|
|
3021
|
+
});
|
|
3022
|
+
if (!res.ok) {
|
|
3023
|
+
setDispatchResult(`Batch error: ${res.status}`);
|
|
3024
|
+
} else {
|
|
3025
|
+
setDispatchResult(`Batch dispatched: ${batchSelected.size} issues`);
|
|
3026
|
+
}
|
|
3027
|
+
setBatchSelected(/* @__PURE__ */ new Set());
|
|
3028
|
+
setBatchConfirm(false);
|
|
3029
|
+
} catch (err) {
|
|
3030
|
+
setDispatchResult(`Error: ${err instanceof Error ? err.message : String(err)}`);
|
|
3031
|
+
}
|
|
3032
|
+
}, [baseUrl, batchSelected]);
|
|
3033
|
+
const handleSelectIssue = useCallback12((issue) => {
|
|
3034
|
+
setDispatchConfirm(issue);
|
|
3035
|
+
setDispatchResult(null);
|
|
3036
|
+
}, []);
|
|
3037
|
+
const toggleBatch = useCallback12((issue) => {
|
|
3038
|
+
setBatchSelected((prev) => {
|
|
3039
|
+
const next = new Set(prev);
|
|
3040
|
+
if (next.has(issue.id)) next.delete(issue.id);
|
|
3041
|
+
else next.add(issue.id);
|
|
3042
|
+
return next;
|
|
3043
|
+
});
|
|
3044
|
+
}, []);
|
|
3045
|
+
const renderDispatchItem = useCallback12(
|
|
3046
|
+
(issue, _index, isSelected) => /* @__PURE__ */ jsxs21(Box20, { children: [
|
|
3047
|
+
/* @__PURE__ */ jsx22(Text21, { color: batchSelected.has(issue.id) ? "green" : "gray", children: batchSelected.has(issue.id) ? "[x]" : "[ ]" }),
|
|
3048
|
+
/* @__PURE__ */ jsx22(StatusDot, { status: issue.status }),
|
|
3049
|
+
/* @__PURE__ */ jsxs21(Text21, { color: isSelected ? "cyan" : void 0, children: [
|
|
3050
|
+
" ",
|
|
3051
|
+
issue.id
|
|
3052
|
+
] }),
|
|
3053
|
+
/* @__PURE__ */ jsxs21(Text21, { color: isSelected ? "cyan" : "white", children: [
|
|
3054
|
+
" ",
|
|
3055
|
+
issue.title
|
|
3056
|
+
] }),
|
|
3057
|
+
/* @__PURE__ */ jsxs21(Text21, { dimColor: true, children: [
|
|
3058
|
+
" [",
|
|
3059
|
+
issue.type,
|
|
3060
|
+
"/",
|
|
3061
|
+
issue.priority,
|
|
3062
|
+
"]"
|
|
3063
|
+
] })
|
|
3064
|
+
] }),
|
|
3065
|
+
[batchSelected]
|
|
3066
|
+
);
|
|
3067
|
+
let tabContent;
|
|
3068
|
+
if (activeTab === 0) {
|
|
3069
|
+
if (monitorMode === "dispatch") {
|
|
3070
|
+
if (batchConfirm) {
|
|
3071
|
+
tabContent = /* @__PURE__ */ jsx22(
|
|
3072
|
+
ConfirmDialog,
|
|
3073
|
+
{
|
|
3074
|
+
message: `Dispatch ${batchSelected.size} issues in batch?`,
|
|
3075
|
+
onConfirm: performBatchDispatch,
|
|
3076
|
+
onCancel: () => setBatchConfirm(false)
|
|
3077
|
+
}
|
|
3078
|
+
);
|
|
3079
|
+
} else if (dispatchConfirm) {
|
|
3080
|
+
if (dispatchResult) {
|
|
3081
|
+
tabContent = /* @__PURE__ */ jsxs21(Box20, { flexDirection: "column", padding: 1, children: [
|
|
3082
|
+
/* @__PURE__ */ jsx22(Text21, { bold: true, color: dispatchResult.startsWith("Error") ? "red" : "green", children: dispatchResult }),
|
|
3083
|
+
/* @__PURE__ */ jsx22(Box20, { marginTop: 1, children: /* @__PURE__ */ jsx22(Text21, { dimColor: true, children: "Esc: back to list" }) })
|
|
3084
|
+
] });
|
|
3085
|
+
} else {
|
|
3086
|
+
tabContent = /* @__PURE__ */ jsxs21(Box20, { flexDirection: "column", padding: 1, children: [
|
|
3087
|
+
/* @__PURE__ */ jsx22(Text21, { bold: true, color: "cyan", children: "Confirm Dispatch" }),
|
|
3088
|
+
/* @__PURE__ */ jsxs21(Box20, { marginTop: 1, flexDirection: "column", children: [
|
|
3089
|
+
/* @__PURE__ */ jsxs21(Text21, { children: [
|
|
3090
|
+
"Issue: ",
|
|
3091
|
+
/* @__PURE__ */ jsx22(Text21, { bold: true, children: dispatchConfirm.id })
|
|
3092
|
+
] }),
|
|
3093
|
+
/* @__PURE__ */ jsxs21(Text21, { children: [
|
|
3094
|
+
"Title: ",
|
|
3095
|
+
dispatchConfirm.title
|
|
3096
|
+
] }),
|
|
3097
|
+
/* @__PURE__ */ jsxs21(Text21, { children: [
|
|
3098
|
+
"Type: ",
|
|
3099
|
+
dispatchConfirm.type,
|
|
3100
|
+
" | Priority: ",
|
|
3101
|
+
dispatchConfirm.priority
|
|
3102
|
+
] })
|
|
3103
|
+
] }),
|
|
3104
|
+
/* @__PURE__ */ jsx22(Box20, { marginTop: 1, children: /* @__PURE__ */ jsx22(Text21, { dimColor: true, children: "Enter=confirm Esc=cancel" }) })
|
|
3105
|
+
] });
|
|
3106
|
+
}
|
|
3107
|
+
} else {
|
|
3108
|
+
tabContent = /* @__PURE__ */ jsxs21(Box20, { flexDirection: "column", flexGrow: 1, children: [
|
|
3109
|
+
/* @__PURE__ */ jsxs21(Box20, { marginBottom: 1, children: [
|
|
3110
|
+
/* @__PURE__ */ jsx22(Text21, { bold: true, color: "cyan", children: "Dispatch Issue" }),
|
|
3111
|
+
/* @__PURE__ */ jsxs21(Text21, { dimColor: true, children: [
|
|
3112
|
+
" (",
|
|
3113
|
+
dispatchableIssues.length,
|
|
3114
|
+
") Esc=back Space=toggle [b]atch"
|
|
3115
|
+
] })
|
|
3116
|
+
] }),
|
|
3117
|
+
issuesLoading && !allIssues ? /* @__PURE__ */ jsx22(Text21, { dimColor: true, children: "Loading issues..." }) : dispatchableIssues.length === 0 ? /* @__PURE__ */ jsx22(Text21, { dimColor: true, children: "No dispatchable issues found." }) : /* @__PURE__ */ jsx22(
|
|
3118
|
+
ScrollableList,
|
|
3119
|
+
{
|
|
3120
|
+
items: dispatchableIssues,
|
|
3121
|
+
renderItem: renderDispatchItem,
|
|
3122
|
+
onSelect: handleSelectIssue,
|
|
3123
|
+
onHighlight: (item) => setHighlightedIssue(item)
|
|
3124
|
+
}
|
|
3125
|
+
),
|
|
3126
|
+
batchSelected.size > 0 && /* @__PURE__ */ jsx22(Box20, { marginTop: 1, children: /* @__PURE__ */ jsxs21(Text21, { color: "green", children: [
|
|
3127
|
+
batchSelected.size,
|
|
3128
|
+
" selected for batch"
|
|
3129
|
+
] }) })
|
|
3130
|
+
] });
|
|
3131
|
+
}
|
|
3132
|
+
} else {
|
|
3133
|
+
const running = status?.running ?? [];
|
|
3134
|
+
const queueLength = status?.queued?.length ?? 0;
|
|
3135
|
+
const stats = status?.stats;
|
|
3136
|
+
tabContent = /* @__PURE__ */ jsxs21(Box20, { flexDirection: "column", flexGrow: 1, children: [
|
|
3137
|
+
/* @__PURE__ */ jsxs21(Box20, { marginBottom: 1, gap: 2, children: [
|
|
3138
|
+
/* @__PURE__ */ jsxs21(Box20, { children: [
|
|
3139
|
+
/* @__PURE__ */ jsx22(Text21, { dimColor: true, children: "Slots: " }),
|
|
3140
|
+
/* @__PURE__ */ jsx22(Text21, { color: "green", children: running.length })
|
|
3141
|
+
] }),
|
|
3142
|
+
/* @__PURE__ */ jsxs21(Box20, { children: [
|
|
3143
|
+
/* @__PURE__ */ jsx22(Text21, { dimColor: true, children: "Queued: " }),
|
|
3144
|
+
/* @__PURE__ */ jsx22(Text21, { color: "yellow", children: queueLength })
|
|
3145
|
+
] }),
|
|
3146
|
+
stats && /* @__PURE__ */ jsxs21(Fragment2, { children: [
|
|
3147
|
+
/* @__PURE__ */ jsxs21(Box20, { children: [
|
|
3148
|
+
/* @__PURE__ */ jsx22(Text21, { dimColor: true, children: "Completed: " }),
|
|
3149
|
+
/* @__PURE__ */ jsx22(Text21, { color: "green", children: stats.totalCompleted })
|
|
3150
|
+
] }),
|
|
3151
|
+
/* @__PURE__ */ jsxs21(Box20, { children: [
|
|
3152
|
+
/* @__PURE__ */ jsx22(Text21, { dimColor: true, children: "Failed: " }),
|
|
3153
|
+
/* @__PURE__ */ jsx22(Text21, { color: "red", children: stats.totalFailed })
|
|
3154
|
+
] }),
|
|
3155
|
+
/* @__PURE__ */ jsxs21(Box20, { children: [
|
|
3156
|
+
/* @__PURE__ */ jsx22(Text21, { dimColor: true, children: "Total: " }),
|
|
3157
|
+
/* @__PURE__ */ jsx22(Text21, { children: stats.totalDispatched })
|
|
3158
|
+
] })
|
|
3159
|
+
] })
|
|
3160
|
+
] }),
|
|
3161
|
+
running.length === 0 ? /* @__PURE__ */ jsx22(Text21, { dimColor: true, children: "No active execution slots." }) : /* @__PURE__ */ jsxs21(Box20, { flexDirection: "column", children: [
|
|
3162
|
+
/* @__PURE__ */ jsxs21(Box20, { children: [
|
|
3163
|
+
/* @__PURE__ */ jsx22(Box20, { width: 14, flexShrink: 0, children: /* @__PURE__ */ jsx22(Text21, { bold: true, underline: true, children: "Executor" }) }),
|
|
3164
|
+
/* @__PURE__ */ jsx22(Box20, { width: 12, flexShrink: 0, children: /* @__PURE__ */ jsx22(Text21, { bold: true, underline: true, children: "Issue" }) }),
|
|
3165
|
+
/* @__PURE__ */ jsx22(Box20, { width: 10, flexShrink: 0, children: /* @__PURE__ */ jsx22(Text21, { bold: true, underline: true, children: "Elapsed" }) }),
|
|
3166
|
+
/* @__PURE__ */ jsx22(Box20, { flexShrink: 0, children: /* @__PURE__ */ jsx22(Text21, { bold: true, underline: true, children: "Process" }) })
|
|
3167
|
+
] }),
|
|
3168
|
+
running.map((slot) => /* @__PURE__ */ jsxs21(Box20, { children: [
|
|
3169
|
+
/* @__PURE__ */ jsxs21(Box20, { width: 14, flexShrink: 0, children: [
|
|
3170
|
+
/* @__PURE__ */ jsx22(StatusDot, { status: "in_progress" }),
|
|
3171
|
+
/* @__PURE__ */ jsxs21(Text21, { children: [
|
|
3172
|
+
" ",
|
|
3173
|
+
slot.executor
|
|
3174
|
+
] })
|
|
3175
|
+
] }),
|
|
3176
|
+
/* @__PURE__ */ jsx22(Box20, { width: 12, flexShrink: 0, children: /* @__PURE__ */ jsx22(Text21, { children: slot.issueId }) }),
|
|
3177
|
+
/* @__PURE__ */ jsx22(Box20, { width: 10, flexShrink: 0, children: /* @__PURE__ */ jsx22(ElapsedTime, { startedAt: slot.startedAt }) }),
|
|
3178
|
+
/* @__PURE__ */ jsx22(Box20, { flexShrink: 0, children: /* @__PURE__ */ jsx22(Text21, { dimColor: true, children: slot.processId.slice(0, 8) }) })
|
|
3179
|
+
] }, slot.processId))
|
|
3180
|
+
] }),
|
|
3181
|
+
/* @__PURE__ */ jsx22(Box20, { marginTop: 1, children: /* @__PURE__ */ jsxs21(Text21, { dimColor: true, children: [
|
|
3182
|
+
"Scheduler: ",
|
|
3183
|
+
status?.enabled ? "enabled" : "disabled",
|
|
3184
|
+
status?.isCommanderActive ? " | Commander: active" : "",
|
|
3185
|
+
status?.lastTickAt ? ` | Last tick: ${new Date(status.lastTickAt).toLocaleTimeString()}` : ""
|
|
3186
|
+
] }) }),
|
|
3187
|
+
/* @__PURE__ */ jsx22(Box20, { marginTop: 1, children: /* @__PURE__ */ jsx22(Text21, { dimColor: true, children: "d=dispatch t=toggle supervisor" }) })
|
|
3188
|
+
] });
|
|
3189
|
+
}
|
|
3190
|
+
} else if (activeTab === 1) {
|
|
3191
|
+
tabContent = /* @__PURE__ */ jsx22(CommanderTab, {});
|
|
3192
|
+
} else if (activeTab === 2) {
|
|
3193
|
+
tabContent = /* @__PURE__ */ jsx22(CoordinatorTab, {});
|
|
3194
|
+
} else if (activeTab === 3) {
|
|
3195
|
+
tabContent = /* @__PURE__ */ jsx22(ScheduleTab, {});
|
|
3196
|
+
} else if (activeTab === 4) {
|
|
3197
|
+
tabContent = /* @__PURE__ */ jsx22(LearningTab, {});
|
|
3198
|
+
} else {
|
|
3199
|
+
tabContent = /* @__PURE__ */ jsx22(ExtensionsTab, {});
|
|
3200
|
+
}
|
|
3201
|
+
return /* @__PURE__ */ jsxs21(Box20, { flexDirection: "column", flexGrow: 1, children: [
|
|
3202
|
+
/* @__PURE__ */ jsx22(Box20, { marginBottom: 1, children: /* @__PURE__ */ jsx22(Text21, { bold: true, color: "cyan", children: "Execution" }) }),
|
|
3203
|
+
/* @__PURE__ */ jsx22(Box20, { marginBottom: 1, children: /* @__PURE__ */ jsx22(
|
|
3204
|
+
FilterBar,
|
|
3205
|
+
{
|
|
3206
|
+
options: [...TABS],
|
|
3207
|
+
activeIndex: activeTab,
|
|
3208
|
+
onSelect: setActiveTab
|
|
3209
|
+
}
|
|
3210
|
+
) }),
|
|
3211
|
+
/* @__PURE__ */ jsx22(Box20, { flexDirection: "column", flexGrow: 1, children: tabContent })
|
|
3212
|
+
] });
|
|
3213
|
+
}
|
|
3214
|
+
|
|
3215
|
+
// src/views/ChatView.tsx
|
|
3216
|
+
import { useState as useState12, useCallback as useCallback16, useMemo as useMemo4 } from "react";
|
|
3217
|
+
import { Box as Box32, Text as Text33, useInput as useInput12 } from "ink";
|
|
3218
|
+
import { TextInput as TextInput6, Select as Select3 } from "@inkjs/ui";
|
|
3219
|
+
|
|
3220
|
+
// src/hooks/useAgentState.ts
|
|
3221
|
+
import { useReducer, useEffect as useEffect8, useCallback as useCallback13 } from "react";
|
|
3222
|
+
var initialState = {
|
|
3223
|
+
processes: {},
|
|
3224
|
+
entries: {},
|
|
3225
|
+
pendingApprovals: {},
|
|
3226
|
+
activeProcessId: null,
|
|
3227
|
+
thoughts: {},
|
|
3228
|
+
streaming: {}
|
|
3229
|
+
};
|
|
3230
|
+
function reducer(state, action) {
|
|
3231
|
+
switch (action.type) {
|
|
3232
|
+
case "PROCESS_SPAWNED": {
|
|
3233
|
+
const p = action.process;
|
|
3234
|
+
return {
|
|
3235
|
+
...state,
|
|
3236
|
+
processes: { ...state.processes, [p.id]: p },
|
|
3237
|
+
entries: { ...state.entries, [p.id]: state.entries[p.id] ?? [] },
|
|
3238
|
+
activeProcessId: state.activeProcessId ?? p.id
|
|
3239
|
+
};
|
|
3240
|
+
}
|
|
3241
|
+
case "PROCESS_STOPPED": {
|
|
3242
|
+
const procs = { ...state.processes };
|
|
3243
|
+
if (procs[action.processId]) {
|
|
3244
|
+
procs[action.processId] = { ...procs[action.processId], status: "stopped" };
|
|
3245
|
+
}
|
|
3246
|
+
const approvals = { ...state.pendingApprovals };
|
|
3247
|
+
for (const [k, v] of Object.entries(approvals)) {
|
|
3248
|
+
if (v.processId === action.processId) delete approvals[k];
|
|
3249
|
+
}
|
|
3250
|
+
return { ...state, processes: procs, pendingApprovals: approvals };
|
|
3251
|
+
}
|
|
3252
|
+
case "STATUS_CHANGED": {
|
|
3253
|
+
const { processId, status } = action.payload;
|
|
3254
|
+
const procs = { ...state.processes };
|
|
3255
|
+
if (procs[processId]) {
|
|
3256
|
+
procs[processId] = { ...procs[processId], status };
|
|
3257
|
+
}
|
|
3258
|
+
return { ...state, processes: procs };
|
|
3259
|
+
}
|
|
3260
|
+
case "ENTRY_RECEIVED": {
|
|
3261
|
+
const entry = action.entry;
|
|
3262
|
+
const pid = entry.processId;
|
|
3263
|
+
const existing = state.entries[pid] ?? [];
|
|
3264
|
+
if (entry.type === "assistant_message" && entry.partial) {
|
|
3265
|
+
const lastIdx = existing.length - 1;
|
|
3266
|
+
const last = existing[lastIdx];
|
|
3267
|
+
if (last && last.type === "assistant_message" && last.partial) {
|
|
3268
|
+
const updated = [...existing];
|
|
3269
|
+
updated[lastIdx] = entry;
|
|
3270
|
+
return { ...state, entries: { ...state.entries, [pid]: updated } };
|
|
3271
|
+
}
|
|
3272
|
+
}
|
|
3273
|
+
if (entry.type === "assistant_message" && !entry.partial) {
|
|
3274
|
+
const lastIdx = existing.length - 1;
|
|
3275
|
+
const last = existing[lastIdx];
|
|
3276
|
+
if (last && last.type === "assistant_message" && last.partial) {
|
|
3277
|
+
const updated = [...existing];
|
|
3278
|
+
updated[lastIdx] = entry;
|
|
3279
|
+
return { ...state, entries: { ...state.entries, [pid]: updated } };
|
|
3280
|
+
}
|
|
3281
|
+
}
|
|
3282
|
+
return { ...state, entries: { ...state.entries, [pid]: [...existing, entry] } };
|
|
3283
|
+
}
|
|
3284
|
+
case "APPROVAL_RECEIVED":
|
|
3285
|
+
return {
|
|
3286
|
+
...state,
|
|
3287
|
+
pendingApprovals: { ...state.pendingApprovals, [action.approval.id]: action.approval }
|
|
3288
|
+
};
|
|
3289
|
+
case "APPROVAL_RESOLVED": {
|
|
3290
|
+
const approvals = { ...state.pendingApprovals };
|
|
3291
|
+
delete approvals[action.requestId];
|
|
3292
|
+
return { ...state, pendingApprovals: approvals };
|
|
3293
|
+
}
|
|
3294
|
+
case "THOUGHT_RECEIVED":
|
|
3295
|
+
return {
|
|
3296
|
+
...state,
|
|
3297
|
+
thoughts: { ...state.thoughts, [action.payload.processId]: action.payload.thought }
|
|
3298
|
+
};
|
|
3299
|
+
case "STREAMING_CHANGED":
|
|
3300
|
+
return {
|
|
3301
|
+
...state,
|
|
3302
|
+
streaming: { ...state.streaming, [action.payload.processId]: action.payload.streaming }
|
|
3303
|
+
};
|
|
3304
|
+
case "SET_ACTIVE":
|
|
3305
|
+
return { ...state, activeProcessId: action.processId };
|
|
3306
|
+
case "SET_PROCESSES": {
|
|
3307
|
+
const procs = {};
|
|
3308
|
+
for (const p of action.processes) {
|
|
3309
|
+
procs[p.id] = p;
|
|
3310
|
+
}
|
|
3311
|
+
return {
|
|
3312
|
+
...state,
|
|
3313
|
+
processes: procs,
|
|
3314
|
+
activeProcessId: state.activeProcessId ?? action.processes[0]?.id ?? null
|
|
3315
|
+
};
|
|
3316
|
+
}
|
|
3317
|
+
default:
|
|
3318
|
+
return state;
|
|
3319
|
+
}
|
|
3320
|
+
}
|
|
3321
|
+
function useAgentState() {
|
|
3322
|
+
const [state, dispatch] = useReducer(reducer, initialState);
|
|
3323
|
+
const { data: processList } = useApi(AGENT_API_ENDPOINTS.LIST, { pollInterval: 1e4 });
|
|
3324
|
+
useEffect8(() => {
|
|
3325
|
+
if (processList) {
|
|
3326
|
+
dispatch({ type: "SET_PROCESSES", processes: processList });
|
|
3327
|
+
}
|
|
3328
|
+
}, [processList]);
|
|
3329
|
+
const spawned = useWsEvent("agent:spawned");
|
|
3330
|
+
const entry = useWsEvent("agent:entry");
|
|
3331
|
+
const approval = useWsEvent("agent:approval");
|
|
3332
|
+
const statusChange = useWsEvent("agent:status");
|
|
3333
|
+
const stopped = useWsEvent("agent:stopped");
|
|
3334
|
+
const thought = useWsEvent("agent:thought");
|
|
3335
|
+
const streamingEvt = useWsEvent("agent:streaming");
|
|
3336
|
+
useEffect8(() => {
|
|
3337
|
+
if (spawned) dispatch({ type: "PROCESS_SPAWNED", process: spawned });
|
|
3338
|
+
}, [spawned]);
|
|
3339
|
+
useEffect8(() => {
|
|
3340
|
+
if (entry) dispatch({ type: "ENTRY_RECEIVED", entry });
|
|
3341
|
+
}, [entry]);
|
|
3342
|
+
useEffect8(() => {
|
|
3343
|
+
if (approval) dispatch({ type: "APPROVAL_RECEIVED", approval });
|
|
3344
|
+
}, [approval]);
|
|
3345
|
+
useEffect8(() => {
|
|
3346
|
+
if (statusChange) dispatch({ type: "STATUS_CHANGED", payload: statusChange });
|
|
3347
|
+
}, [statusChange]);
|
|
3348
|
+
useEffect8(() => {
|
|
3349
|
+
if (stopped) dispatch({ type: "PROCESS_STOPPED", processId: stopped.processId });
|
|
3350
|
+
}, [stopped]);
|
|
3351
|
+
useEffect8(() => {
|
|
3352
|
+
if (thought) dispatch({ type: "THOUGHT_RECEIVED", payload: thought });
|
|
3353
|
+
}, [thought]);
|
|
3354
|
+
useEffect8(() => {
|
|
3355
|
+
if (streamingEvt) dispatch({ type: "STREAMING_CHANGED", payload: streamingEvt });
|
|
3356
|
+
}, [streamingEvt]);
|
|
3357
|
+
const setActive = useCallback13((processId) => {
|
|
3358
|
+
dispatch({ type: "SET_ACTIVE", processId });
|
|
3359
|
+
}, []);
|
|
3360
|
+
const resolveApproval = useCallback13((requestId) => {
|
|
3361
|
+
dispatch({ type: "APPROVAL_RESOLVED", requestId });
|
|
3362
|
+
}, []);
|
|
3363
|
+
return { ...state, setActive, resolveApproval };
|
|
3364
|
+
}
|
|
3365
|
+
|
|
3366
|
+
// src/views/chat/MessageList.tsx
|
|
3367
|
+
import { useCallback as useCallback14 } from "react";
|
|
3368
|
+
|
|
3369
|
+
// src/views/chat/entryRenderers/index.ts
|
|
3370
|
+
import React14 from "react";
|
|
3371
|
+
import { Text as Text31 } from "ink";
|
|
3372
|
+
|
|
3373
|
+
// src/views/chat/entryRenderers/UserMessageRow.tsx
|
|
3374
|
+
import { Box as Box21, Text as Text22 } from "ink";
|
|
3375
|
+
import { jsx as jsx23, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
3376
|
+
function UserMessageRow({ entry }) {
|
|
3377
|
+
return /* @__PURE__ */ jsxs22(Box21, { children: [
|
|
3378
|
+
/* @__PURE__ */ jsx23(Text22, { color: "cyan", bold: true, children: "You: " }),
|
|
3379
|
+
/* @__PURE__ */ jsx23(Text22, { children: entry.content })
|
|
3380
|
+
] });
|
|
3381
|
+
}
|
|
3382
|
+
|
|
3383
|
+
// src/views/chat/entryRenderers/AssistantMessageRow.tsx
|
|
3384
|
+
import { Box as Box22 } from "ink";
|
|
3385
|
+
import { jsx as jsx24 } from "react/jsx-runtime";
|
|
3386
|
+
function AssistantMessageRow({ entry }) {
|
|
3387
|
+
if (entry.partial) {
|
|
3388
|
+
return /* @__PURE__ */ jsx24(Box22, { children: /* @__PURE__ */ jsx24(StreamingMarkdown, { children: entry.content }) });
|
|
3389
|
+
}
|
|
3390
|
+
return /* @__PURE__ */ jsx24(Box22, { children: /* @__PURE__ */ jsx24(Markdown, { children: entry.content }) });
|
|
3391
|
+
}
|
|
3392
|
+
|
|
3393
|
+
// src/views/chat/entryRenderers/ThinkingRow.tsx
|
|
3394
|
+
import { Box as Box23, Text as Text23 } from "ink";
|
|
3395
|
+
import { jsx as jsx25, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
3396
|
+
function ThinkingRow({ entry }) {
|
|
3397
|
+
return /* @__PURE__ */ jsx25(Box23, { children: /* @__PURE__ */ jsxs23(Text23, { dimColor: true, italic: true, children: [
|
|
3398
|
+
" [thinking] ",
|
|
3399
|
+
entry.content.slice(0, 120),
|
|
3400
|
+
entry.content.length > 120 ? "..." : ""
|
|
3401
|
+
] }) });
|
|
3402
|
+
}
|
|
3403
|
+
|
|
3404
|
+
// src/views/chat/entryRenderers/ToolUseRow.tsx
|
|
3405
|
+
import { Box as Box24, Text as Text24 } from "ink";
|
|
3406
|
+
import { jsx as jsx26, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
3407
|
+
function ToolUseRow({ entry }) {
|
|
3408
|
+
return /* @__PURE__ */ jsxs24(Box24, { gap: 1, children: [
|
|
3409
|
+
/* @__PURE__ */ jsx26(Text24, { color: "magenta", children: "[tool]" }),
|
|
3410
|
+
/* @__PURE__ */ jsx26(Text24, { children: entry.name }),
|
|
3411
|
+
/* @__PURE__ */ jsxs24(Text24, { dimColor: true, children: [
|
|
3412
|
+
"(",
|
|
3413
|
+
entry.status,
|
|
3414
|
+
")"
|
|
3415
|
+
] })
|
|
3416
|
+
] });
|
|
3417
|
+
}
|
|
3418
|
+
|
|
3419
|
+
// src/views/chat/entryRenderers/FileChangeRow.tsx
|
|
3420
|
+
import { Box as Box25, Text as Text25 } from "ink";
|
|
3421
|
+
import { jsx as jsx27, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
3422
|
+
function FileChangeRow({ entry }) {
|
|
3423
|
+
const color = entry.action === "create" ? "green" : entry.action === "modify" ? "yellow" : "red";
|
|
3424
|
+
return /* @__PURE__ */ jsxs25(Box25, { gap: 1, children: [
|
|
3425
|
+
/* @__PURE__ */ jsxs25(Text25, { color, children: [
|
|
3426
|
+
"[",
|
|
3427
|
+
entry.action,
|
|
3428
|
+
"]"
|
|
3429
|
+
] }),
|
|
3430
|
+
/* @__PURE__ */ jsx27(Text25, { children: entry.path })
|
|
3431
|
+
] });
|
|
3432
|
+
}
|
|
3433
|
+
|
|
3434
|
+
// src/views/chat/entryRenderers/CommandExecRow.tsx
|
|
3435
|
+
import { Box as Box26, Text as Text26 } from "ink";
|
|
3436
|
+
import { jsx as jsx28, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
3437
|
+
function CommandExecRow({ entry }) {
|
|
3438
|
+
return /* @__PURE__ */ jsxs26(Box26, { gap: 1, children: [
|
|
3439
|
+
/* @__PURE__ */ jsx28(Text26, { color: "blue", children: "[cmd]" }),
|
|
3440
|
+
/* @__PURE__ */ jsx28(Text26, { children: entry.command }),
|
|
3441
|
+
entry.exitCode != null && /* @__PURE__ */ jsxs26(Text26, { color: entry.exitCode === 0 ? "green" : "red", children: [
|
|
3442
|
+
"exit:",
|
|
3443
|
+
entry.exitCode
|
|
3444
|
+
] })
|
|
3445
|
+
] });
|
|
3446
|
+
}
|
|
3447
|
+
|
|
3448
|
+
// src/views/chat/entryRenderers/ApprovalRow.tsx
|
|
3449
|
+
import { Box as Box27, Text as Text27 } from "ink";
|
|
3450
|
+
import { jsx as jsx29, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
3451
|
+
function ApprovalRequestRow({ entry }) {
|
|
3452
|
+
return /* @__PURE__ */ jsxs27(Box27, { borderStyle: "single", borderColor: "yellow", paddingX: 1, children: [
|
|
3453
|
+
/* @__PURE__ */ jsx29(Text27, { color: "yellow", bold: true, children: "Approval: " }),
|
|
3454
|
+
/* @__PURE__ */ jsx29(Text27, { children: entry.toolName }),
|
|
3455
|
+
/* @__PURE__ */ jsx29(Text27, { dimColor: true, children: " [a]llow / [d]eny" })
|
|
3456
|
+
] });
|
|
3457
|
+
}
|
|
3458
|
+
function ApprovalResponseRow({ entry }) {
|
|
3459
|
+
return /* @__PURE__ */ jsx29(Box27, { children: /* @__PURE__ */ jsxs27(Text27, { dimColor: true, children: [
|
|
3460
|
+
"[",
|
|
3461
|
+
entry.allowed ? "allowed" : "denied",
|
|
3462
|
+
"] ",
|
|
3463
|
+
entry.requestId
|
|
3464
|
+
] }) });
|
|
3465
|
+
}
|
|
3466
|
+
|
|
3467
|
+
// src/views/chat/entryRenderers/ErrorRow.tsx
|
|
3468
|
+
import { Box as Box28, Text as Text28 } from "ink";
|
|
3469
|
+
import { jsx as jsx30, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
3470
|
+
function ErrorRow({ entry }) {
|
|
3471
|
+
return /* @__PURE__ */ jsx30(Box28, { children: /* @__PURE__ */ jsxs28(Text28, { color: "red", children: [
|
|
3472
|
+
"[error] ",
|
|
3473
|
+
entry.message
|
|
3474
|
+
] }) });
|
|
3475
|
+
}
|
|
3476
|
+
|
|
3477
|
+
// src/views/chat/entryRenderers/StatusChangeRow.tsx
|
|
3478
|
+
import { Box as Box29, Text as Text29 } from "ink";
|
|
3479
|
+
import { jsx as jsx31, jsxs as jsxs29 } from "react/jsx-runtime";
|
|
3480
|
+
function StatusChangeRow({ entry }) {
|
|
3481
|
+
return /* @__PURE__ */ jsx31(Box29, { children: /* @__PURE__ */ jsxs29(Text29, { dimColor: true, children: [
|
|
3482
|
+
"[status] ",
|
|
3483
|
+
entry.status,
|
|
3484
|
+
entry.reason ? `: ${entry.reason}` : ""
|
|
3485
|
+
] }) });
|
|
3486
|
+
}
|
|
3487
|
+
|
|
3488
|
+
// src/views/chat/entryRenderers/TokenUsageRow.tsx
|
|
3489
|
+
import { Box as Box30, Text as Text30 } from "ink";
|
|
3490
|
+
import { jsx as jsx32, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
3491
|
+
function TokenUsageRow({ entry }) {
|
|
3492
|
+
return /* @__PURE__ */ jsx32(Box30, { children: /* @__PURE__ */ jsxs30(Text30, { dimColor: true, children: [
|
|
3493
|
+
"[tokens] in:",
|
|
3494
|
+
entry.inputTokens,
|
|
3495
|
+
" out:",
|
|
3496
|
+
entry.outputTokens
|
|
3497
|
+
] }) });
|
|
3498
|
+
}
|
|
3499
|
+
|
|
3500
|
+
// src/views/chat/entryRenderers/index.ts
|
|
3501
|
+
var ENTRY_RENDERERS = {
|
|
3502
|
+
user_message: UserMessageRow,
|
|
3503
|
+
assistant_message: AssistantMessageRow,
|
|
3504
|
+
thinking: ThinkingRow,
|
|
3505
|
+
tool_use: ToolUseRow,
|
|
3506
|
+
file_change: FileChangeRow,
|
|
3507
|
+
command_exec: CommandExecRow,
|
|
3508
|
+
approval_request: ApprovalRequestRow,
|
|
3509
|
+
approval_response: ApprovalResponseRow,
|
|
3510
|
+
error: ErrorRow,
|
|
3511
|
+
status_change: StatusChangeRow,
|
|
3512
|
+
token_usage: TokenUsageRow
|
|
3513
|
+
};
|
|
3514
|
+
function EntryRow({ entry }) {
|
|
3515
|
+
const Renderer = ENTRY_RENDERERS[entry.type];
|
|
3516
|
+
if (!Renderer) return React14.createElement(Text31, { dimColor: true }, "[unknown entry]");
|
|
3517
|
+
return React14.createElement(Renderer, { entry });
|
|
3518
|
+
}
|
|
3519
|
+
|
|
3520
|
+
// src/views/chat/MessageList.tsx
|
|
3521
|
+
import { jsx as jsx33 } from "react/jsx-runtime";
|
|
3522
|
+
function MessageList({ entries, isFocused = true }) {
|
|
3523
|
+
const renderItem = useCallback14(
|
|
3524
|
+
(entry, _index, _isSelected) => /* @__PURE__ */ jsx33(EntryRow, { entry }),
|
|
3525
|
+
[]
|
|
3526
|
+
);
|
|
3527
|
+
return /* @__PURE__ */ jsx33(
|
|
3528
|
+
ScrollableList,
|
|
3529
|
+
{
|
|
3530
|
+
items: entries,
|
|
3531
|
+
renderItem,
|
|
3532
|
+
isFocused
|
|
3533
|
+
}
|
|
3534
|
+
);
|
|
3535
|
+
}
|
|
3536
|
+
|
|
3537
|
+
// src/views/chat/CliHistorySidebar.tsx
|
|
3538
|
+
import { useCallback as useCallback15 } from "react";
|
|
3539
|
+
import { Box as Box31, Text as Text32 } from "ink";
|
|
3540
|
+
import { jsx as jsx34, jsxs as jsxs31 } from "react/jsx-runtime";
|
|
3541
|
+
function CliHistorySidebar({ onSelect, isFocused = true }) {
|
|
3542
|
+
const { data: history, loading } = useApi(
|
|
3543
|
+
"/api/cli-history?limit=20"
|
|
3544
|
+
);
|
|
3545
|
+
const renderItem = useCallback15(
|
|
3546
|
+
(item, _index, isSelected) => /* @__PURE__ */ jsxs31(Box31, { gap: 1, children: [
|
|
3547
|
+
/* @__PURE__ */ jsx34(Text32, { dimColor: true, children: item.startedAt?.slice(11, 19) ?? "" }),
|
|
3548
|
+
/* @__PURE__ */ jsxs31(Text32, { color: item.status === "running" ? "yellow" : item.status === "done" ? "green" : "gray", children: [
|
|
3549
|
+
"[",
|
|
3550
|
+
item.status,
|
|
3551
|
+
"]"
|
|
3552
|
+
] }),
|
|
3553
|
+
/* @__PURE__ */ jsx34(Text32, { color: isSelected ? "cyan" : void 0, wrap: "truncate", children: item.command?.slice(0, 60) ?? item.id }),
|
|
3554
|
+
item.tool && /* @__PURE__ */ jsxs31(Text32, { dimColor: true, children: [
|
|
3555
|
+
"(",
|
|
3556
|
+
item.tool,
|
|
3557
|
+
")"
|
|
3558
|
+
] })
|
|
3559
|
+
] }),
|
|
3560
|
+
[]
|
|
3561
|
+
);
|
|
3562
|
+
if (loading && !history) {
|
|
3563
|
+
return /* @__PURE__ */ jsx34(Text32, { dimColor: true, children: "Loading CLI history..." });
|
|
3564
|
+
}
|
|
3565
|
+
const items = history ?? [];
|
|
3566
|
+
return /* @__PURE__ */ jsxs31(Box31, { flexDirection: "column", flexGrow: 1, children: [
|
|
3567
|
+
/* @__PURE__ */ jsxs31(Box31, { marginBottom: 1, children: [
|
|
3568
|
+
/* @__PURE__ */ jsx34(Text32, { bold: true, color: "cyan", children: "CLI History" }),
|
|
3569
|
+
/* @__PURE__ */ jsxs31(Text32, { dimColor: true, children: [
|
|
3570
|
+
" (",
|
|
3571
|
+
items.length,
|
|
3572
|
+
") Enter=load | Esc=back"
|
|
3573
|
+
] })
|
|
3574
|
+
] }),
|
|
3575
|
+
/* @__PURE__ */ jsx34(
|
|
3576
|
+
ScrollableList,
|
|
3577
|
+
{
|
|
3578
|
+
items,
|
|
3579
|
+
renderItem,
|
|
3580
|
+
onSelect,
|
|
3581
|
+
isFocused
|
|
3582
|
+
}
|
|
3583
|
+
)
|
|
3584
|
+
] });
|
|
3585
|
+
}
|
|
3586
|
+
|
|
3587
|
+
// src/views/ChatView.tsx
|
|
3588
|
+
import { jsx as jsx35, jsxs as jsxs32 } from "react/jsx-runtime";
|
|
3589
|
+
var SPAWN_STEPS = ["type", "prompt", "workDir", "approvalMode"];
|
|
3590
|
+
var AGENT_TYPE_OPTIONS = [
|
|
3591
|
+
{ label: "Claude Code", value: "claude-code" },
|
|
3592
|
+
{ label: "Codex", value: "codex" },
|
|
3593
|
+
{ label: "Gemini", value: "gemini" },
|
|
3594
|
+
{ label: "Qwen", value: "qwen" },
|
|
3595
|
+
{ label: "OpenCode", value: "opencode" }
|
|
3596
|
+
];
|
|
3597
|
+
var APPROVAL_OPTIONS = [
|
|
3598
|
+
{ label: "Suggest (manual)", value: "suggest" },
|
|
3599
|
+
{ label: "Auto (auto-approve)", value: "auto" }
|
|
3600
|
+
];
|
|
3601
|
+
function ChatView() {
|
|
3602
|
+
const [mode, setMode] = useState12("sessions");
|
|
3603
|
+
const [messageText, setMessageText] = useState12("");
|
|
3604
|
+
const [spawnStep, setSpawnStep] = useState12("type");
|
|
3605
|
+
const [spawnType, setSpawnType] = useState12("claude-code");
|
|
3606
|
+
const [spawnPrompt, setSpawnPrompt] = useState12("");
|
|
3607
|
+
const [spawnWorkDir, setSpawnWorkDir] = useState12(process.cwd());
|
|
3608
|
+
const { send } = useWs();
|
|
3609
|
+
const agent = useAgentState();
|
|
3610
|
+
const processList = useMemo4(
|
|
3611
|
+
() => Object.values(agent.processes).sort((a, b) => b.startedAt.localeCompare(a.startedAt)),
|
|
3612
|
+
[agent.processes]
|
|
3613
|
+
);
|
|
3614
|
+
const activeProcess = agent.activeProcessId ? agent.processes[agent.activeProcessId] : null;
|
|
3615
|
+
const activeEntries = agent.activeProcessId ? agent.entries[agent.activeProcessId] ?? [] : [];
|
|
3616
|
+
const activeThought = agent.activeProcessId ? agent.thoughts[agent.activeProcessId] : void 0;
|
|
3617
|
+
const activeStreaming = agent.activeProcessId ? agent.streaming[agent.activeProcessId] : false;
|
|
3618
|
+
const activeApproval = useMemo4(() => {
|
|
3619
|
+
if (!agent.activeProcessId) return null;
|
|
3620
|
+
return Object.values(agent.pendingApprovals).find(
|
|
3621
|
+
(a) => a.processId === agent.activeProcessId
|
|
3622
|
+
) ?? null;
|
|
3623
|
+
}, [agent.pendingApprovals, agent.activeProcessId]);
|
|
3624
|
+
const cycleSession = useCallback16((dir) => {
|
|
3625
|
+
if (processList.length === 0) return;
|
|
3626
|
+
const idx = processList.findIndex((p) => p.id === agent.activeProcessId);
|
|
3627
|
+
const next = (idx + dir + processList.length) % processList.length;
|
|
3628
|
+
agent.setActive(processList[next].id);
|
|
3629
|
+
}, [processList, agent]);
|
|
3630
|
+
const handleSelectSession = useCallback16((proc) => {
|
|
3631
|
+
agent.setActive(proc.id);
|
|
3632
|
+
setMode("chat");
|
|
3633
|
+
}, [agent]);
|
|
3634
|
+
const resetSpawn = useCallback16(() => {
|
|
3635
|
+
setSpawnStep("type");
|
|
3636
|
+
setSpawnType("claude-code");
|
|
3637
|
+
setSpawnPrompt("");
|
|
3638
|
+
setSpawnWorkDir(process.cwd());
|
|
3639
|
+
}, []);
|
|
3640
|
+
const submitSpawn = useCallback16((approvalMode) => {
|
|
3641
|
+
const config = {
|
|
3642
|
+
type: spawnType,
|
|
3643
|
+
prompt: spawnPrompt,
|
|
3644
|
+
workDir: spawnWorkDir,
|
|
3645
|
+
approvalMode
|
|
3646
|
+
};
|
|
3647
|
+
send({ action: "spawn", config });
|
|
3648
|
+
resetSpawn();
|
|
3649
|
+
setMode("sessions");
|
|
3650
|
+
}, [send, spawnType, spawnPrompt, spawnWorkDir, resetSpawn]);
|
|
3651
|
+
const submitMessage = useCallback16(() => {
|
|
3652
|
+
const text = messageText.trim();
|
|
3653
|
+
if (!text || !agent.activeProcessId) return;
|
|
3654
|
+
send({ action: "message", processId: agent.activeProcessId, content: text });
|
|
3655
|
+
setMessageText("");
|
|
3656
|
+
setMode("chat");
|
|
3657
|
+
}, [send, messageText, agent.activeProcessId]);
|
|
3658
|
+
const renderSession = useCallback16(
|
|
3659
|
+
(proc, _index, isSelected) => /* @__PURE__ */ jsxs32(Box32, { gap: 1, children: [
|
|
3660
|
+
/* @__PURE__ */ jsx35(StatusDot, { status: proc.status, showLabel: false }),
|
|
3661
|
+
/* @__PURE__ */ jsx35(Text33, { color: isSelected ? "cyan" : void 0, bold: isSelected, children: proc.type }),
|
|
3662
|
+
/* @__PURE__ */ jsx35(Text33, { dimColor: true, children: proc.id.slice(0, 12) }),
|
|
3663
|
+
/* @__PURE__ */ jsx35(Text33, { dimColor: true, children: proc.startedAt?.slice(11, 19) ?? "" })
|
|
3664
|
+
] }),
|
|
3665
|
+
[]
|
|
3666
|
+
);
|
|
3667
|
+
useInput12((input, key) => {
|
|
3668
|
+
if (key.escape) {
|
|
3669
|
+
if (mode === "chat") {
|
|
3670
|
+
setMode("sessions");
|
|
3671
|
+
return;
|
|
3672
|
+
}
|
|
3673
|
+
if (mode === "spawn") {
|
|
3674
|
+
resetSpawn();
|
|
3675
|
+
setMode("sessions");
|
|
3676
|
+
return;
|
|
3677
|
+
}
|
|
3678
|
+
if (mode === "message") {
|
|
3679
|
+
setMessageText("");
|
|
3680
|
+
setMode("chat");
|
|
3681
|
+
return;
|
|
3682
|
+
}
|
|
3683
|
+
if (mode === "history") {
|
|
3684
|
+
setMode("sessions");
|
|
3685
|
+
return;
|
|
3686
|
+
}
|
|
3687
|
+
return;
|
|
3688
|
+
}
|
|
3689
|
+
if (mode === "sessions") {
|
|
3690
|
+
if (input === "s") {
|
|
3691
|
+
resetSpawn();
|
|
3692
|
+
setMode("spawn");
|
|
3693
|
+
return;
|
|
3694
|
+
}
|
|
3695
|
+
if (input === "h") {
|
|
3696
|
+
setMode("history");
|
|
3697
|
+
return;
|
|
3698
|
+
}
|
|
3699
|
+
}
|
|
3700
|
+
if (mode === "chat") {
|
|
3701
|
+
if (input === "s") {
|
|
3702
|
+
resetSpawn();
|
|
3703
|
+
setMode("spawn");
|
|
3704
|
+
return;
|
|
3705
|
+
}
|
|
3706
|
+
if (input === "m" && activeProcess?.status === "running") {
|
|
3707
|
+
setMessageText("");
|
|
3708
|
+
setMode("message");
|
|
3709
|
+
return;
|
|
3710
|
+
}
|
|
3711
|
+
if (input === "x" && agent.activeProcessId) {
|
|
3712
|
+
send({ action: "stop", processId: agent.activeProcessId });
|
|
3713
|
+
return;
|
|
3714
|
+
}
|
|
3715
|
+
if (input === "a" && activeApproval) {
|
|
3716
|
+
send({ action: "approve", processId: agent.activeProcessId, requestId: activeApproval.id, allow: true });
|
|
3717
|
+
agent.resolveApproval(activeApproval.id);
|
|
3718
|
+
return;
|
|
3719
|
+
}
|
|
3720
|
+
if (input === "d" && activeApproval) {
|
|
3721
|
+
send({ action: "approve", processId: agent.activeProcessId, requestId: activeApproval.id, allow: false });
|
|
3722
|
+
agent.resolveApproval(activeApproval.id);
|
|
3723
|
+
return;
|
|
3724
|
+
}
|
|
3725
|
+
if (key.tab) {
|
|
3726
|
+
cycleSession(1);
|
|
3727
|
+
return;
|
|
3728
|
+
}
|
|
3729
|
+
}
|
|
3730
|
+
}, { isActive: mode !== "message" && mode !== "spawn" });
|
|
3731
|
+
if (mode === "history") {
|
|
3732
|
+
return /* @__PURE__ */ jsx35(
|
|
3733
|
+
CliHistorySidebar,
|
|
3734
|
+
{
|
|
3735
|
+
onSelect: () => setMode("sessions"),
|
|
3736
|
+
isFocused: true
|
|
3737
|
+
}
|
|
3738
|
+
);
|
|
3739
|
+
}
|
|
3740
|
+
if (mode === "spawn") {
|
|
3741
|
+
const stepIndex = SPAWN_STEPS.indexOf(spawnStep);
|
|
3742
|
+
return /* @__PURE__ */ jsxs32(Box32, { flexDirection: "column", flexGrow: 1, children: [
|
|
3743
|
+
/* @__PURE__ */ jsxs32(Box32, { marginBottom: 1, children: [
|
|
3744
|
+
/* @__PURE__ */ jsx35(Text33, { bold: true, color: "cyan", children: "Spawn Agent" }),
|
|
3745
|
+
/* @__PURE__ */ jsxs32(Text33, { dimColor: true, children: [
|
|
3746
|
+
" (Step ",
|
|
3747
|
+
stepIndex + 1,
|
|
3748
|
+
"/",
|
|
3749
|
+
SPAWN_STEPS.length,
|
|
3750
|
+
") Esc=cancel"
|
|
3751
|
+
] })
|
|
3752
|
+
] }),
|
|
3753
|
+
/* @__PURE__ */ jsx35(Box32, { gap: 1, marginBottom: 1, children: SPAWN_STEPS.map((s, i) => /* @__PURE__ */ jsxs32(Text33, { bold: s === spawnStep, color: i < stepIndex ? "green" : s === spawnStep ? "cyan" : "gray", children: [
|
|
3754
|
+
i < stepIndex ? "[x]" : s === spawnStep ? "[>]" : "[ ]",
|
|
3755
|
+
" ",
|
|
3756
|
+
s
|
|
3757
|
+
] }, s)) }),
|
|
3758
|
+
spawnStep === "type" && /* @__PURE__ */ jsxs32(Box32, { flexDirection: "column", children: [
|
|
3759
|
+
/* @__PURE__ */ jsx35(Text33, { children: "Agent Type:" }),
|
|
3760
|
+
/* @__PURE__ */ jsx35(
|
|
3761
|
+
Select3,
|
|
3762
|
+
{
|
|
3763
|
+
options: AGENT_TYPE_OPTIONS,
|
|
3764
|
+
defaultValue: spawnType,
|
|
3765
|
+
onChange: (value) => {
|
|
3766
|
+
setSpawnType(value);
|
|
3767
|
+
setSpawnStep("prompt");
|
|
3768
|
+
}
|
|
3769
|
+
}
|
|
3770
|
+
)
|
|
3771
|
+
] }),
|
|
3772
|
+
spawnStep === "prompt" && /* @__PURE__ */ jsxs32(Box32, { flexDirection: "column", children: [
|
|
3773
|
+
/* @__PURE__ */ jsx35(Text33, { children: "Prompt:" }),
|
|
3774
|
+
/* @__PURE__ */ jsx35(
|
|
3775
|
+
TextInput6,
|
|
3776
|
+
{
|
|
3777
|
+
placeholder: "Enter agent prompt...",
|
|
3778
|
+
defaultValue: spawnPrompt,
|
|
3779
|
+
onChange: setSpawnPrompt,
|
|
3780
|
+
onSubmit: () => setSpawnStep("workDir")
|
|
3781
|
+
}
|
|
3782
|
+
)
|
|
3783
|
+
] }),
|
|
3784
|
+
spawnStep === "workDir" && /* @__PURE__ */ jsxs32(Box32, { flexDirection: "column", children: [
|
|
3785
|
+
/* @__PURE__ */ jsx35(Text33, { children: "Working Directory:" }),
|
|
3786
|
+
/* @__PURE__ */ jsx35(
|
|
3787
|
+
TextInput6,
|
|
3788
|
+
{
|
|
3789
|
+
placeholder: process.cwd(),
|
|
3790
|
+
defaultValue: spawnWorkDir,
|
|
3791
|
+
onChange: setSpawnWorkDir,
|
|
3792
|
+
onSubmit: () => setSpawnStep("approvalMode")
|
|
3793
|
+
}
|
|
3794
|
+
)
|
|
3795
|
+
] }),
|
|
3796
|
+
spawnStep === "approvalMode" && /* @__PURE__ */ jsxs32(Box32, { flexDirection: "column", children: [
|
|
3797
|
+
/* @__PURE__ */ jsx35(Text33, { children: "Approval Mode:" }),
|
|
3798
|
+
/* @__PURE__ */ jsx35(
|
|
3799
|
+
Select3,
|
|
3800
|
+
{
|
|
3801
|
+
options: APPROVAL_OPTIONS,
|
|
3802
|
+
defaultValue: "suggest",
|
|
3803
|
+
onChange: (value) => submitSpawn(value)
|
|
3804
|
+
}
|
|
3805
|
+
)
|
|
3806
|
+
] }),
|
|
3807
|
+
stepIndex > 0 && /* @__PURE__ */ jsxs32(Box32, { flexDirection: "column", marginTop: 1, borderStyle: "single", paddingX: 1, children: [
|
|
3808
|
+
/* @__PURE__ */ jsx35(Text33, { dimColor: true, bold: true, children: "Filled:" }),
|
|
3809
|
+
/* @__PURE__ */ jsxs32(Text33, { dimColor: true, children: [
|
|
3810
|
+
" Type: ",
|
|
3811
|
+
spawnType
|
|
3812
|
+
] }),
|
|
3813
|
+
spawnPrompt && /* @__PURE__ */ jsxs32(Text33, { dimColor: true, children: [
|
|
3814
|
+
" Prompt: ",
|
|
3815
|
+
spawnPrompt.slice(0, 60),
|
|
3816
|
+
spawnPrompt.length > 60 ? "..." : ""
|
|
3817
|
+
] }),
|
|
3818
|
+
stepIndex > 2 && /* @__PURE__ */ jsxs32(Text33, { dimColor: true, children: [
|
|
3819
|
+
" WorkDir: ",
|
|
3820
|
+
spawnWorkDir
|
|
3821
|
+
] })
|
|
3822
|
+
] })
|
|
3823
|
+
] });
|
|
3824
|
+
}
|
|
3825
|
+
if (mode === "message") {
|
|
3826
|
+
return /* @__PURE__ */ jsxs32(Box32, { flexDirection: "column", flexGrow: 1, children: [
|
|
3827
|
+
/* @__PURE__ */ jsxs32(Box32, { marginBottom: 1, children: [
|
|
3828
|
+
/* @__PURE__ */ jsx35(Text33, { bold: true, color: "cyan", children: "Send Message" }),
|
|
3829
|
+
/* @__PURE__ */ jsxs32(Text33, { dimColor: true, children: [
|
|
3830
|
+
" to ",
|
|
3831
|
+
activeProcess?.type ?? "agent",
|
|
3832
|
+
" | Esc=cancel"
|
|
3833
|
+
] })
|
|
3834
|
+
] }),
|
|
3835
|
+
/* @__PURE__ */ jsx35(
|
|
3836
|
+
TextInput6,
|
|
3837
|
+
{
|
|
3838
|
+
placeholder: "Type your message...",
|
|
3839
|
+
defaultValue: messageText,
|
|
3840
|
+
onChange: setMessageText,
|
|
3841
|
+
onSubmit: submitMessage
|
|
3842
|
+
}
|
|
3843
|
+
)
|
|
3844
|
+
] });
|
|
3845
|
+
}
|
|
3846
|
+
if (mode === "chat" && activeProcess) {
|
|
3847
|
+
return /* @__PURE__ */ jsxs32(Box32, { flexDirection: "column", flexGrow: 1, children: [
|
|
3848
|
+
/* @__PURE__ */ jsxs32(Box32, { marginBottom: 1, gap: 2, children: [
|
|
3849
|
+
/* @__PURE__ */ jsx35(Text33, { bold: true, color: "cyan", children: "Chat" }),
|
|
3850
|
+
/* @__PURE__ */ jsx35(StatusDot, { status: activeProcess.status, showLabel: true }),
|
|
3851
|
+
/* @__PURE__ */ jsx35(Text33, { dimColor: true, children: activeProcess.type }),
|
|
3852
|
+
/* @__PURE__ */ jsxs32(Text33, { dimColor: true, children: [
|
|
3853
|
+
"(",
|
|
3854
|
+
activeEntries.length,
|
|
3855
|
+
" entries)"
|
|
3856
|
+
] }),
|
|
3857
|
+
activeStreaming && /* @__PURE__ */ jsx35(Text33, { color: "yellow", children: "streaming..." })
|
|
3858
|
+
] }),
|
|
3859
|
+
/* @__PURE__ */ jsx35(
|
|
3860
|
+
SplitPane,
|
|
3861
|
+
{
|
|
3862
|
+
ratio: 70,
|
|
3863
|
+
left: /* @__PURE__ */ jsx35(MessageList, { entries: activeEntries }),
|
|
3864
|
+
right: /* @__PURE__ */ jsxs32(Box32, { flexDirection: "column", paddingLeft: 1, children: [
|
|
3865
|
+
/* @__PURE__ */ jsx35(Text33, { bold: true, dimColor: true, children: "Process Info" }),
|
|
3866
|
+
/* @__PURE__ */ jsxs32(Box32, { gap: 1, children: [
|
|
3867
|
+
/* @__PURE__ */ jsx35(Text33, { dimColor: true, children: "ID:" }),
|
|
3868
|
+
/* @__PURE__ */ jsx35(Text33, { children: activeProcess.id.slice(0, 12) })
|
|
3869
|
+
] }),
|
|
3870
|
+
/* @__PURE__ */ jsxs32(Box32, { gap: 1, children: [
|
|
3871
|
+
/* @__PURE__ */ jsx35(Text33, { dimColor: true, children: "Type:" }),
|
|
3872
|
+
/* @__PURE__ */ jsx35(Text33, { children: activeProcess.type })
|
|
3873
|
+
] }),
|
|
3874
|
+
/* @__PURE__ */ jsxs32(Box32, { gap: 1, children: [
|
|
3875
|
+
/* @__PURE__ */ jsx35(Text33, { dimColor: true, children: "Status:" }),
|
|
3876
|
+
/* @__PURE__ */ jsx35(StatusDot, { status: activeProcess.status, showLabel: true })
|
|
3877
|
+
] }),
|
|
3878
|
+
/* @__PURE__ */ jsxs32(Box32, { gap: 1, children: [
|
|
3879
|
+
/* @__PURE__ */ jsx35(Text33, { dimColor: true, children: "Started:" }),
|
|
3880
|
+
/* @__PURE__ */ jsx35(Text33, { children: activeProcess.startedAt?.slice(11, 19) ?? "-" })
|
|
3881
|
+
] }),
|
|
3882
|
+
activeThought && /* @__PURE__ */ jsxs32(Box32, { flexDirection: "column", marginTop: 1, children: [
|
|
3883
|
+
/* @__PURE__ */ jsx35(Text33, { bold: true, dimColor: true, children: "Thinking" }),
|
|
3884
|
+
/* @__PURE__ */ jsx35(Text33, { color: "magenta", children: activeThought.subject }),
|
|
3885
|
+
/* @__PURE__ */ jsx35(Text33, { dimColor: true, children: activeThought.description })
|
|
3886
|
+
] }),
|
|
3887
|
+
activeApproval && /* @__PURE__ */ jsxs32(Box32, { flexDirection: "column", marginTop: 1, borderStyle: "single", borderColor: "yellow", paddingX: 1, children: [
|
|
3888
|
+
/* @__PURE__ */ jsx35(Text33, { bold: true, color: "yellow", children: "Pending Approval" }),
|
|
3889
|
+
/* @__PURE__ */ jsx35(Text33, { children: activeApproval.toolName }),
|
|
3890
|
+
/* @__PURE__ */ jsx35(Text33, { dimColor: true, children: "[a]llow / [d]eny" })
|
|
3891
|
+
] })
|
|
3892
|
+
] })
|
|
3893
|
+
}
|
|
3894
|
+
),
|
|
3895
|
+
/* @__PURE__ */ jsx35(Box32, { marginTop: 1, children: /* @__PURE__ */ jsx35(Text33, { dimColor: true, children: "s=spawn m=message x=stop a/d=approve Tab=cycle Esc=back" }) })
|
|
3896
|
+
] });
|
|
3897
|
+
}
|
|
3898
|
+
return /* @__PURE__ */ jsxs32(Box32, { flexDirection: "column", flexGrow: 1, children: [
|
|
3899
|
+
/* @__PURE__ */ jsxs32(Box32, { marginBottom: 1, gap: 2, children: [
|
|
3900
|
+
/* @__PURE__ */ jsx35(Text33, { bold: true, color: "cyan", children: "Agent Sessions" }),
|
|
3901
|
+
/* @__PURE__ */ jsxs32(Text33, { dimColor: true, children: [
|
|
3902
|
+
"(",
|
|
3903
|
+
processList.length,
|
|
3904
|
+
" sessions)"
|
|
3905
|
+
] })
|
|
3906
|
+
] }),
|
|
3907
|
+
processList.length === 0 ? /* @__PURE__ */ jsx35(Text33, { dimColor: true, children: "No agent sessions. Press [s] to spawn." }) : /* @__PURE__ */ jsx35(
|
|
3908
|
+
ScrollableList,
|
|
3909
|
+
{
|
|
3910
|
+
items: processList,
|
|
3911
|
+
renderItem: renderSession,
|
|
3912
|
+
onSelect: handleSelectSession
|
|
3913
|
+
}
|
|
3914
|
+
),
|
|
3915
|
+
/* @__PURE__ */ jsx35(Box32, { marginTop: 1, children: /* @__PURE__ */ jsx35(Text33, { dimColor: true, children: "s=spawn h=history Enter=select" }) })
|
|
3916
|
+
] });
|
|
3917
|
+
}
|
|
3918
|
+
|
|
3919
|
+
// src/router/Router.tsx
|
|
3920
|
+
import { jsx as jsx36, jsxs as jsxs33 } from "react/jsx-runtime";
|
|
3921
|
+
function PlaceholderView({ id, label }) {
|
|
3922
|
+
return /* @__PURE__ */ jsxs33(Box33, { flexDirection: "column", alignItems: "center", justifyContent: "center", flexGrow: 1, children: [
|
|
3923
|
+
/* @__PURE__ */ jsx36(Text34, { bold: true, color: "cyan", children: label }),
|
|
3924
|
+
/* @__PURE__ */ jsxs33(Text34, { dimColor: true, children: [
|
|
3925
|
+
"View: ",
|
|
3926
|
+
id
|
|
3927
|
+
] })
|
|
3928
|
+
] });
|
|
3929
|
+
}
|
|
3930
|
+
function Router({ activeView }) {
|
|
3931
|
+
const active = routes.find((r) => r.id === activeView) ?? routes[0];
|
|
3932
|
+
return /* @__PURE__ */ jsx36(Box33, { flexDirection: "column", flexGrow: 1, children: active.id === "issue" ? /* @__PURE__ */ jsx36(IssueView, {}) : active.id === "workflow" ? /* @__PURE__ */ jsx36(WorkflowView, {}) : active.id === "artifact" ? /* @__PURE__ */ jsx36(ArtifactView, {}) : active.id === "team" ? /* @__PURE__ */ jsx36(TeamView, {}) : active.id === "requirement" ? /* @__PURE__ */ jsx36(RequirementView, {}) : active.id === "execution" ? /* @__PURE__ */ jsx36(ExecutionView, {}) : active.id === "chat" ? /* @__PURE__ */ jsx36(ChatView, {}) : /* @__PURE__ */ jsx36(PlaceholderView, { id: active.id, label: active.label }) });
|
|
3933
|
+
}
|
|
3934
|
+
|
|
3935
|
+
// src/App.tsx
|
|
3936
|
+
import { jsx as jsx37, jsxs as jsxs34 } from "react/jsx-runtime";
|
|
3937
|
+
function AppContent() {
|
|
3938
|
+
const [activeView, setActiveView] = useState13("issue");
|
|
3939
|
+
const { connected } = useWs();
|
|
3940
|
+
useInput13((input, key) => {
|
|
3941
|
+
if (input === "q" && !key.ctrl) {
|
|
3942
|
+
process.exit(0);
|
|
3943
|
+
}
|
|
3944
|
+
const route = routes.find((r) => r.key === input);
|
|
3945
|
+
if (route) {
|
|
3946
|
+
setActiveView(route.id);
|
|
3947
|
+
}
|
|
3948
|
+
});
|
|
3949
|
+
return /* @__PURE__ */ jsxs34(Box34, { flexDirection: "column", width: "100%", height: "100%", children: [
|
|
3950
|
+
/* @__PURE__ */ jsx37(HeaderBar, { activeView }),
|
|
3951
|
+
/* @__PURE__ */ jsx37(Box34, { flexGrow: 1, children: /* @__PURE__ */ jsx37(Router, { activeView }) }),
|
|
3952
|
+
/* @__PURE__ */ jsx37(StatusBar, { connected, workspace: process.cwd() })
|
|
3953
|
+
] });
|
|
3954
|
+
}
|
|
3955
|
+
function App() {
|
|
3956
|
+
const port = process.env.PORT || "3001";
|
|
3957
|
+
const host = process.env.HOST || "localhost";
|
|
3958
|
+
const baseUrl = `http://${host}:${port}`;
|
|
3959
|
+
const wsUrl = `ws://${host}:${port}/ws`;
|
|
3960
|
+
return /* @__PURE__ */ jsx37(ApiProvider, { baseUrl, children: /* @__PURE__ */ jsx37(WsProvider, { url: wsUrl, children: /* @__PURE__ */ jsx37(AppContent, {}) }) });
|
|
3961
|
+
}
|
|
3962
|
+
|
|
3963
|
+
// src/index.tsx
|
|
3964
|
+
import { jsx as jsx38 } from "react/jsx-runtime";
|
|
3965
|
+
var { waitUntilExit, unmount } = render(/* @__PURE__ */ jsx38(App, {}), {
|
|
3966
|
+
exitOnCtrlC: true
|
|
3967
|
+
});
|
|
3968
|
+
function cleanup() {
|
|
3969
|
+
unmount();
|
|
3970
|
+
process.exit(0);
|
|
3971
|
+
}
|
|
3972
|
+
process.on("SIGINT", cleanup);
|
|
3973
|
+
process.on("SIGTERM", cleanup);
|
|
3974
|
+
await waitUntilExit();
|