tycono 0.1.96-beta.0 → 0.1.96-beta.2
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/package.json +2 -1
- package/src/tui/api.ts +273 -0
- package/src/tui/app.tsx +266 -0
- package/src/tui/components/CommandInput.tsx +32 -0
- package/src/tui/components/HelpOverlay.tsx +51 -0
- package/src/tui/components/OrgTree.tsx +119 -0
- package/src/tui/components/SessionList.tsx +74 -0
- package/src/tui/components/SetupWizard.tsx +206 -0
- package/src/tui/components/StatusBar.tsx +49 -0
- package/src/tui/components/StreamPanel.tsx +182 -0
- package/src/tui/components/WaveDialog.tsx +56 -0
- package/src/tui/hooks/useApi.ts +77 -0
- package/src/tui/hooks/useKeyboard.ts +62 -0
- package/src/tui/hooks/useSSE.ts +69 -0
- package/src/tui/index.tsx +25 -0
- package/src/tui/store.ts +99 -0
- package/src/tui/theme.ts +78 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tycono",
|
|
3
|
-
"version": "0.1.96-beta.
|
|
3
|
+
"version": "0.1.96-beta.2",
|
|
4
4
|
"description": "Build an AI company. Watch them work.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"src/api/src/",
|
|
12
12
|
"src/api/package.json",
|
|
13
13
|
"src/shared/",
|
|
14
|
+
"src/tui/",
|
|
14
15
|
"src/web/dist/",
|
|
15
16
|
"templates/"
|
|
16
17
|
],
|
package/src/tui/api.ts
ADDED
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TUI API Client — HTTP + SSE for communicating with Tycono API server
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import http from 'node:http';
|
|
6
|
+
|
|
7
|
+
let BASE_URL = 'http://localhost:3000';
|
|
8
|
+
|
|
9
|
+
export function setBaseUrl(url: string): void {
|
|
10
|
+
BASE_URL = url.replace(/\/$/, '');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function getBaseUrl(): string {
|
|
14
|
+
return BASE_URL;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/* ─── HTTP helpers ─── */
|
|
18
|
+
|
|
19
|
+
async function fetchJson<T>(path: string, options?: { method?: string; body?: unknown }): Promise<T> {
|
|
20
|
+
const url = `${BASE_URL}${path}`;
|
|
21
|
+
const method = options?.method ?? 'GET';
|
|
22
|
+
const bodyStr = options?.body ? JSON.stringify(options.body) : undefined;
|
|
23
|
+
|
|
24
|
+
return new Promise((resolve, reject) => {
|
|
25
|
+
const urlObj = new URL(url);
|
|
26
|
+
const req = http.request(
|
|
27
|
+
{
|
|
28
|
+
hostname: urlObj.hostname,
|
|
29
|
+
port: urlObj.port,
|
|
30
|
+
path: urlObj.pathname + urlObj.search,
|
|
31
|
+
method,
|
|
32
|
+
headers: {
|
|
33
|
+
'Content-Type': 'application/json',
|
|
34
|
+
...(bodyStr ? { 'Content-Length': Buffer.byteLength(bodyStr) } : {}),
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
(res) => {
|
|
38
|
+
let data = '';
|
|
39
|
+
res.on('data', (chunk) => { data += chunk; });
|
|
40
|
+
res.on('end', () => {
|
|
41
|
+
try {
|
|
42
|
+
resolve(JSON.parse(data) as T);
|
|
43
|
+
} catch {
|
|
44
|
+
reject(new Error(`Invalid JSON from ${path}: ${data.slice(0, 200)}`));
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
);
|
|
49
|
+
req.on('error', reject);
|
|
50
|
+
if (bodyStr) req.write(bodyStr);
|
|
51
|
+
req.end();
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* ─── API Types ─── */
|
|
56
|
+
|
|
57
|
+
export interface RoleInfo {
|
|
58
|
+
id: string;
|
|
59
|
+
name: string;
|
|
60
|
+
level: string;
|
|
61
|
+
reportsTo: string;
|
|
62
|
+
status: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface CompanyInfo {
|
|
66
|
+
name: string;
|
|
67
|
+
domain: string;
|
|
68
|
+
founded: string;
|
|
69
|
+
mission: string;
|
|
70
|
+
roles: RoleInfo[];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface SessionInfo {
|
|
74
|
+
id: string;
|
|
75
|
+
roleId: string;
|
|
76
|
+
title: string;
|
|
77
|
+
mode: string;
|
|
78
|
+
status: string;
|
|
79
|
+
source: string;
|
|
80
|
+
waveId?: string;
|
|
81
|
+
createdAt: string;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface ExecStatus {
|
|
85
|
+
statuses: Record<string, string>;
|
|
86
|
+
activeExecutions: Array<{
|
|
87
|
+
id: string;
|
|
88
|
+
roleId: string;
|
|
89
|
+
task: string;
|
|
90
|
+
startedAt: string;
|
|
91
|
+
}>;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface WaveResponse {
|
|
95
|
+
waveId: string;
|
|
96
|
+
supervisorSessionId?: string;
|
|
97
|
+
mode: string;
|
|
98
|
+
directive: string;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface SSEEvent {
|
|
102
|
+
seq: number;
|
|
103
|
+
ts: string;
|
|
104
|
+
type: string;
|
|
105
|
+
roleId: string;
|
|
106
|
+
data: Record<string, unknown>;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/* ─── API calls ─── */
|
|
110
|
+
|
|
111
|
+
export async function fetchCompany(): Promise<CompanyInfo> {
|
|
112
|
+
return fetchJson<CompanyInfo>('/api/company');
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export async function fetchRoles(): Promise<RoleInfo[]> {
|
|
116
|
+
return fetchJson<RoleInfo[]>('/api/roles');
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export async function fetchSessions(): Promise<SessionInfo[]> {
|
|
120
|
+
return fetchJson<SessionInfo[]>('/api/sessions');
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export async function fetchExecStatus(): Promise<ExecStatus> {
|
|
124
|
+
return fetchJson<ExecStatus>('/api/exec/status');
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export async function dispatchWave(directive: string, options?: {
|
|
128
|
+
targetRoles?: string[];
|
|
129
|
+
continuous?: boolean;
|
|
130
|
+
}): Promise<WaveResponse> {
|
|
131
|
+
return fetchJson<WaveResponse>('/api/jobs', {
|
|
132
|
+
method: 'POST',
|
|
133
|
+
body: {
|
|
134
|
+
type: 'wave',
|
|
135
|
+
directive,
|
|
136
|
+
targetRoles: options?.targetRoles,
|
|
137
|
+
continuous: options?.continuous ?? false,
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export async function sendDirective(waveId: string, text: string): Promise<{ ok: boolean }> {
|
|
143
|
+
return fetchJson<{ ok: boolean }>(`/api/waves/${waveId}/directive`, {
|
|
144
|
+
method: 'POST',
|
|
145
|
+
body: { text },
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export async function fetchActiveWaves(): Promise<{ waves: Array<{ waveId: string; sessionIds: string[] }> }> {
|
|
150
|
+
return fetchJson('/api/waves/active');
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/* ─── Setup API calls ─── */
|
|
154
|
+
|
|
155
|
+
export interface TeamTemplate {
|
|
156
|
+
id: string;
|
|
157
|
+
name: string;
|
|
158
|
+
description: string;
|
|
159
|
+
roles: string[];
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export interface ScaffoldResult {
|
|
163
|
+
path: string;
|
|
164
|
+
rolesCreated: number;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export async function fetchSetupTeams(): Promise<TeamTemplate[]> {
|
|
168
|
+
return fetchJson<TeamTemplate[]>('/api/setup/teams');
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export async function postSetupScaffold(companyName: string, teamId: string): Promise<ScaffoldResult> {
|
|
172
|
+
return fetchJson<ScaffoldResult>('/api/setup/scaffold', {
|
|
173
|
+
method: 'POST',
|
|
174
|
+
body: { companyName, teamId },
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export async function postSetupCodeRoot(codeRoot: string): Promise<{ ok: boolean }> {
|
|
179
|
+
return fetchJson<{ ok: boolean }>('/api/setup/code-root', {
|
|
180
|
+
method: 'POST',
|
|
181
|
+
body: { codeRoot },
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/* ─── SSE stream ─── */
|
|
186
|
+
|
|
187
|
+
export interface SSEConnection {
|
|
188
|
+
close(): void;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export function subscribeToWaveStream(
|
|
192
|
+
waveId: string,
|
|
193
|
+
onEvent: (event: SSEEvent) => void,
|
|
194
|
+
onEnd?: (reason: string) => void,
|
|
195
|
+
fromSeq?: number,
|
|
196
|
+
): SSEConnection {
|
|
197
|
+
const url = new URL(`${BASE_URL}/api/waves/${waveId}/stream`);
|
|
198
|
+
if (fromSeq) url.searchParams.set('from', String(fromSeq));
|
|
199
|
+
|
|
200
|
+
let destroyed = false;
|
|
201
|
+
let req: http.ClientRequest | null = null;
|
|
202
|
+
|
|
203
|
+
const connect = () => {
|
|
204
|
+
req = http.get(url.toString(), (res) => {
|
|
205
|
+
let buffer = '';
|
|
206
|
+
|
|
207
|
+
res.on('data', (chunk: Buffer) => {
|
|
208
|
+
if (destroyed) return;
|
|
209
|
+
buffer += chunk.toString();
|
|
210
|
+
|
|
211
|
+
// Parse SSE format
|
|
212
|
+
const parts = buffer.split('\n\n');
|
|
213
|
+
buffer = parts.pop() ?? '';
|
|
214
|
+
|
|
215
|
+
for (const part of parts) {
|
|
216
|
+
if (!part.trim() || part.startsWith(':')) continue;
|
|
217
|
+
|
|
218
|
+
const lines = part.split('\n');
|
|
219
|
+
let eventType = '';
|
|
220
|
+
let data = '';
|
|
221
|
+
|
|
222
|
+
for (const line of lines) {
|
|
223
|
+
if (line.startsWith('event: ')) {
|
|
224
|
+
eventType = line.slice(7);
|
|
225
|
+
} else if (line.startsWith('data: ')) {
|
|
226
|
+
data = line.slice(6);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (eventType === 'activity' && data) {
|
|
231
|
+
try {
|
|
232
|
+
onEvent(JSON.parse(data) as SSEEvent);
|
|
233
|
+
} catch { /* ignore parse errors */ }
|
|
234
|
+
} else if (eventType === 'stream:end' && data) {
|
|
235
|
+
try {
|
|
236
|
+
const parsed = JSON.parse(data);
|
|
237
|
+
onEnd?.(parsed.reason ?? 'unknown');
|
|
238
|
+
} catch {
|
|
239
|
+
onEnd?.('unknown');
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
res.on('end', () => {
|
|
246
|
+
if (!destroyed) {
|
|
247
|
+
onEnd?.('disconnected');
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
res.on('error', () => {
|
|
252
|
+
if (!destroyed) {
|
|
253
|
+
onEnd?.('error');
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
req.on('error', () => {
|
|
259
|
+
if (!destroyed) {
|
|
260
|
+
onEnd?.('error');
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
connect();
|
|
266
|
+
|
|
267
|
+
return {
|
|
268
|
+
close() {
|
|
269
|
+
destroyed = true;
|
|
270
|
+
req?.destroy();
|
|
271
|
+
},
|
|
272
|
+
};
|
|
273
|
+
}
|
package/src/tui/app.tsx
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TUI App — main layout with 4 panels
|
|
3
|
+
*
|
|
4
|
+
* Layout:
|
|
5
|
+
* ┌─────────────────────────────────────────┐
|
|
6
|
+
* │ StatusBar │
|
|
7
|
+
* ├──────────────┬──────────────────────────┤
|
|
8
|
+
* │ OrgTree │ StreamPanel │
|
|
9
|
+
* │ │ │
|
|
10
|
+
* ├──────────────┤ │
|
|
11
|
+
* │ SessionList │ │
|
|
12
|
+
* ├──────────────┴──────────────────────────┤
|
|
13
|
+
* │ CommandInput │
|
|
14
|
+
* └─────────────────────────────────────────┘
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import React, { useState, useCallback, useMemo } from 'react';
|
|
18
|
+
import { Box, Text, useApp } from 'ink';
|
|
19
|
+
import { StatusBar } from './components/StatusBar';
|
|
20
|
+
import { OrgTree } from './components/OrgTree';
|
|
21
|
+
import { SessionList } from './components/SessionList';
|
|
22
|
+
import { StreamPanel } from './components/StreamPanel';
|
|
23
|
+
import { CommandInput } from './components/CommandInput';
|
|
24
|
+
import { WaveDialog } from './components/WaveDialog';
|
|
25
|
+
import { HelpOverlay } from './components/HelpOverlay';
|
|
26
|
+
import { SetupWizard } from './components/SetupWizard';
|
|
27
|
+
import { useApi } from './hooks/useApi';
|
|
28
|
+
import { useSSE } from './hooks/useSSE';
|
|
29
|
+
import { useKeyboard } from './hooks/useKeyboard';
|
|
30
|
+
import { buildOrgTree } from './store';
|
|
31
|
+
import { dispatchWave } from './api';
|
|
32
|
+
|
|
33
|
+
type Panel = 'org' | 'sessions' | 'stream' | 'command';
|
|
34
|
+
type Dialog = 'none' | 'wave' | 'help';
|
|
35
|
+
type View = 'loading' | 'setup' | 'dashboard';
|
|
36
|
+
|
|
37
|
+
const PANELS: Panel[] = ['org', 'sessions', 'stream', 'command'];
|
|
38
|
+
|
|
39
|
+
export const App: React.FC = () => {
|
|
40
|
+
const { exit } = useApp();
|
|
41
|
+
const api = useApi();
|
|
42
|
+
|
|
43
|
+
// Determine view: loading → setup (no company) → dashboard
|
|
44
|
+
const [view, setView] = useState<View>('loading');
|
|
45
|
+
|
|
46
|
+
React.useEffect(() => {
|
|
47
|
+
if (!api.loaded) return;
|
|
48
|
+
if (view === 'loading') {
|
|
49
|
+
setView(api.company ? 'dashboard' : 'setup');
|
|
50
|
+
}
|
|
51
|
+
}, [api.loaded, api.company, view]);
|
|
52
|
+
|
|
53
|
+
const handleSetupComplete = useCallback(() => {
|
|
54
|
+
api.refresh();
|
|
55
|
+
setView('dashboard');
|
|
56
|
+
}, [api]);
|
|
57
|
+
|
|
58
|
+
const [activePanel, setActivePanel] = useState<Panel>('org');
|
|
59
|
+
const [dialog, setDialog] = useState<Dialog>('none');
|
|
60
|
+
const [selectedRoleIndex, setSelectedRoleIndex] = useState(0);
|
|
61
|
+
const [selectedSessionIndex, setSelectedSessionIndex] = useState(0);
|
|
62
|
+
const [waveId, setWaveId] = useState<string | null>(null);
|
|
63
|
+
const [waveStatus, setWaveStatus] = useState<'idle' | 'running' | 'done'>('idle');
|
|
64
|
+
|
|
65
|
+
// Derive active wave from API if we don't have one
|
|
66
|
+
const effectiveWaveId = waveId ?? api.activeWaveId;
|
|
67
|
+
|
|
68
|
+
const sse = useSSE(effectiveWaveId);
|
|
69
|
+
|
|
70
|
+
// Build org tree
|
|
71
|
+
const roles = api.company?.roles ?? [];
|
|
72
|
+
const flatRoleIds = useMemo(() => roles.map(r => r.id), [roles]);
|
|
73
|
+
const statuses = api.execStatus?.statuses ?? {};
|
|
74
|
+
const orgTree = useMemo(() => buildOrgTree(roles, statuses), [roles, statuses]);
|
|
75
|
+
|
|
76
|
+
// Count active
|
|
77
|
+
const activeCount = Object.values(statuses).filter(s => s === 'working' || s === 'streaming').length;
|
|
78
|
+
|
|
79
|
+
// Determine wave status from SSE
|
|
80
|
+
const derivedWaveStatus = useMemo(() => {
|
|
81
|
+
if (sse.streamStatus === 'streaming') return 'running' as const;
|
|
82
|
+
if (sse.streamStatus === 'done') return 'done' as const;
|
|
83
|
+
if (waveStatus === 'running' && activeCount > 0) return 'running' as const;
|
|
84
|
+
return waveStatus;
|
|
85
|
+
}, [sse.streamStatus, waveStatus, activeCount]);
|
|
86
|
+
|
|
87
|
+
// Handle wave dispatch
|
|
88
|
+
const handleWaveSubmit = useCallback(async (directive: string) => {
|
|
89
|
+
setDialog('none');
|
|
90
|
+
try {
|
|
91
|
+
const result = await dispatchWave(directive);
|
|
92
|
+
setWaveId(result.waveId);
|
|
93
|
+
setWaveStatus('running');
|
|
94
|
+
sse.clearEvents();
|
|
95
|
+
api.refresh();
|
|
96
|
+
} catch (err) {
|
|
97
|
+
// Show error briefly
|
|
98
|
+
console.error('Wave dispatch failed:', err);
|
|
99
|
+
}
|
|
100
|
+
}, [sse, api]);
|
|
101
|
+
|
|
102
|
+
// Keyboard actions — disabled when dialog is open
|
|
103
|
+
const keyboardEnabled = dialog === 'none';
|
|
104
|
+
|
|
105
|
+
useKeyboard({
|
|
106
|
+
onWave: () => setDialog('wave'),
|
|
107
|
+
onQuit: () => exit(),
|
|
108
|
+
onHelp: () => setDialog(dialog === 'help' ? 'none' : 'help'),
|
|
109
|
+
onTab: () => {
|
|
110
|
+
const idx = PANELS.indexOf(activePanel);
|
|
111
|
+
setActivePanel(PANELS[(idx + 1) % PANELS.length]);
|
|
112
|
+
},
|
|
113
|
+
onUp: () => {
|
|
114
|
+
if (activePanel === 'org') {
|
|
115
|
+
setSelectedRoleIndex(Math.max(0, selectedRoleIndex - 1));
|
|
116
|
+
} else if (activePanel === 'sessions') {
|
|
117
|
+
setSelectedSessionIndex(Math.max(0, selectedSessionIndex - 1));
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
onDown: () => {
|
|
121
|
+
if (activePanel === 'org') {
|
|
122
|
+
setSelectedRoleIndex(Math.min(flatRoleIds.length - 1, selectedRoleIndex + 1));
|
|
123
|
+
} else if (activePanel === 'sessions') {
|
|
124
|
+
setSelectedSessionIndex(Math.min(Math.max(0, api.sessions.length - 1), selectedSessionIndex + 1));
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
onEnter: () => {
|
|
128
|
+
// Future: select role/session to show in stream
|
|
129
|
+
},
|
|
130
|
+
onEscape: () => {
|
|
131
|
+
if (dialog !== 'none') {
|
|
132
|
+
setDialog('none');
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
}, keyboardEnabled);
|
|
136
|
+
|
|
137
|
+
// Loading state
|
|
138
|
+
if (view === 'loading') {
|
|
139
|
+
return (
|
|
140
|
+
<Box flexDirection="column" paddingX={1}>
|
|
141
|
+
<Text color="cyan" bold>TYCONO TUI</Text>
|
|
142
|
+
<Text color="gray">Connecting to API server...</Text>
|
|
143
|
+
</Box>
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Setup wizard — no company found
|
|
148
|
+
if (view === 'setup') {
|
|
149
|
+
return (
|
|
150
|
+
<Box flexDirection="column" paddingX={1}>
|
|
151
|
+
<SetupWizard onComplete={handleSetupComplete} />
|
|
152
|
+
</Box>
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Error display
|
|
157
|
+
if (api.error) {
|
|
158
|
+
return (
|
|
159
|
+
<Box flexDirection="column" paddingX={1}>
|
|
160
|
+
<Text color="cyan" bold>TYCONO TUI</Text>
|
|
161
|
+
<Text color="red">API Error: {api.error}</Text>
|
|
162
|
+
<Text color="gray">Make sure the API server is running on the configured port.</Text>
|
|
163
|
+
<Text color="gray" dimColor>Press q to quit</Text>
|
|
164
|
+
</Box>
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Help overlay
|
|
169
|
+
if (dialog === 'help') {
|
|
170
|
+
return (
|
|
171
|
+
<Box flexDirection="column">
|
|
172
|
+
<StatusBar
|
|
173
|
+
companyName={api.company?.name ?? 'Loading...'}
|
|
174
|
+
waveId={effectiveWaveId}
|
|
175
|
+
waveStatus={derivedWaveStatus}
|
|
176
|
+
activeCount={activeCount}
|
|
177
|
+
totalCost={0}
|
|
178
|
+
/>
|
|
179
|
+
<HelpOverlay onClose={() => setDialog('none')} />
|
|
180
|
+
</Box>
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Wave dialog
|
|
185
|
+
if (dialog === 'wave') {
|
|
186
|
+
return (
|
|
187
|
+
<Box flexDirection="column">
|
|
188
|
+
<StatusBar
|
|
189
|
+
companyName={api.company?.name ?? 'Loading...'}
|
|
190
|
+
waveId={effectiveWaveId}
|
|
191
|
+
waveStatus={derivedWaveStatus}
|
|
192
|
+
activeCount={activeCount}
|
|
193
|
+
totalCost={0}
|
|
194
|
+
/>
|
|
195
|
+
<WaveDialog
|
|
196
|
+
onSubmit={handleWaveSubmit}
|
|
197
|
+
onCancel={() => setDialog('none')}
|
|
198
|
+
/>
|
|
199
|
+
</Box>
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return (
|
|
204
|
+
<Box flexDirection="column">
|
|
205
|
+
{/* Status Bar */}
|
|
206
|
+
<StatusBar
|
|
207
|
+
companyName={api.company?.name ?? 'Loading...'}
|
|
208
|
+
waveId={effectiveWaveId}
|
|
209
|
+
waveStatus={derivedWaveStatus}
|
|
210
|
+
activeCount={activeCount}
|
|
211
|
+
totalCost={0}
|
|
212
|
+
/>
|
|
213
|
+
|
|
214
|
+
{/* Separator */}
|
|
215
|
+
<Box width="100%">
|
|
216
|
+
<Text color="gray">{'\u2500'.repeat(70)}</Text>
|
|
217
|
+
</Box>
|
|
218
|
+
|
|
219
|
+
{/* Main content: left (org + sessions) | right (stream) */}
|
|
220
|
+
<Box flexGrow={1}>
|
|
221
|
+
{/* Left column */}
|
|
222
|
+
<Box flexDirection="column" width={28}>
|
|
223
|
+
<OrgTree
|
|
224
|
+
tree={orgTree}
|
|
225
|
+
focused={activePanel === 'org'}
|
|
226
|
+
selectedIndex={selectedRoleIndex}
|
|
227
|
+
flatRoles={flatRoleIds}
|
|
228
|
+
/>
|
|
229
|
+
<Box marginTop={1}>
|
|
230
|
+
<SessionList
|
|
231
|
+
sessions={api.sessions}
|
|
232
|
+
focused={activePanel === 'sessions'}
|
|
233
|
+
selectedIndex={selectedSessionIndex}
|
|
234
|
+
/>
|
|
235
|
+
</Box>
|
|
236
|
+
</Box>
|
|
237
|
+
|
|
238
|
+
{/* Vertical separator */}
|
|
239
|
+
<Box flexDirection="column" marginX={0}>
|
|
240
|
+
<Text color="gray">{'\u2502\n'.repeat(15)}</Text>
|
|
241
|
+
</Box>
|
|
242
|
+
|
|
243
|
+
{/* Right column: Stream */}
|
|
244
|
+
<StreamPanel
|
|
245
|
+
events={sse.events}
|
|
246
|
+
allRoleIds={flatRoleIds}
|
|
247
|
+
focused={activePanel === 'stream'}
|
|
248
|
+
streamStatus={sse.streamStatus}
|
|
249
|
+
waveId={effectiveWaveId}
|
|
250
|
+
/>
|
|
251
|
+
</Box>
|
|
252
|
+
|
|
253
|
+
{/* Separator */}
|
|
254
|
+
<Box width="100%">
|
|
255
|
+
<Text color="gray">{'\u2500'.repeat(70)}</Text>
|
|
256
|
+
</Box>
|
|
257
|
+
|
|
258
|
+
{/* Command Input */}
|
|
259
|
+
<CommandInput
|
|
260
|
+
focused={activePanel === 'command'}
|
|
261
|
+
waveStatus={derivedWaveStatus}
|
|
262
|
+
dialog={dialog}
|
|
263
|
+
/>
|
|
264
|
+
</Box>
|
|
265
|
+
);
|
|
266
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CommandInput — bottom bar with command input and shortcut hints
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { Box, Text } from 'ink';
|
|
7
|
+
|
|
8
|
+
interface CommandInputProps {
|
|
9
|
+
focused: boolean;
|
|
10
|
+
waveStatus: 'idle' | 'running' | 'done';
|
|
11
|
+
dialog: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const CommandInput: React.FC<CommandInputProps> = ({ focused, waveStatus, dialog }) => {
|
|
15
|
+
if (dialog !== 'none') return null;
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<Box width="100%" paddingX={1} justifyContent="space-between">
|
|
19
|
+
<Box>
|
|
20
|
+
<Text color="green" bold>> </Text>
|
|
21
|
+
<Text color={focused ? 'white' : 'gray'}>
|
|
22
|
+
{waveStatus === 'running' ? 'Wave running...' : 'Ready'}
|
|
23
|
+
</Text>
|
|
24
|
+
</Box>
|
|
25
|
+
<Box>
|
|
26
|
+
<Text color="gray" dimColor>
|
|
27
|
+
[w]ave [?]help [q]uit [Tab]panel
|
|
28
|
+
</Text>
|
|
29
|
+
</Box>
|
|
30
|
+
</Box>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HelpOverlay — keyboard shortcut reference
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { Box, Text, useInput } from 'ink';
|
|
7
|
+
|
|
8
|
+
interface HelpOverlayProps {
|
|
9
|
+
onClose(): void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const shortcuts = [
|
|
13
|
+
['w', 'Wave dispatch'],
|
|
14
|
+
['q', 'Quit'],
|
|
15
|
+
['?', 'Toggle help'],
|
|
16
|
+
['Tab', 'Cycle panels'],
|
|
17
|
+
['j/k', 'Navigate (in focused panel)'],
|
|
18
|
+
['Enter', 'Select'],
|
|
19
|
+
['Esc', 'Close dialog / deselect'],
|
|
20
|
+
] as const;
|
|
21
|
+
|
|
22
|
+
export const HelpOverlay: React.FC<HelpOverlayProps> = ({ onClose }) => {
|
|
23
|
+
useInput((input, key) => {
|
|
24
|
+
if (input === '?' || input === 'q' || key.escape) {
|
|
25
|
+
onClose();
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<Box
|
|
31
|
+
flexDirection="column"
|
|
32
|
+
borderStyle="round"
|
|
33
|
+
borderColor="yellow"
|
|
34
|
+
paddingX={2}
|
|
35
|
+
paddingY={1}
|
|
36
|
+
>
|
|
37
|
+
<Text bold color="yellow">{'\u2500\u2500'} Keyboard Shortcuts {'\u2500\u2500'}</Text>
|
|
38
|
+
<Box marginTop={1} flexDirection="column">
|
|
39
|
+
{shortcuts.map(([key, desc]) => (
|
|
40
|
+
<Box key={key}>
|
|
41
|
+
<Text color="cyan" bold>{key.padEnd(8)}</Text>
|
|
42
|
+
<Text color="white">{desc}</Text>
|
|
43
|
+
</Box>
|
|
44
|
+
))}
|
|
45
|
+
</Box>
|
|
46
|
+
<Box marginTop={1}>
|
|
47
|
+
<Text color="gray" dimColor>Press ? or Esc to close</Text>
|
|
48
|
+
</Box>
|
|
49
|
+
</Box>
|
|
50
|
+
);
|
|
51
|
+
};
|