tycono 0.3.1 → 0.3.3
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 +1 -1
- package/src/tui/app.tsx +31 -0
- package/src/tui/hooks/useSSE.ts +6 -1
package/package.json
CHANGED
package/src/tui/app.tsx
CHANGED
|
@@ -258,6 +258,30 @@ export const App: React.FC = () => {
|
|
|
258
258
|
});
|
|
259
259
|
}, []);
|
|
260
260
|
|
|
261
|
+
// Load wave history into SSE events (for Panel Mode Stream tab)
|
|
262
|
+
const loadWaveHistoryEvents = useCallback(async (waveId: string) => {
|
|
263
|
+
try {
|
|
264
|
+
const sessions = api.sessions.filter(s => s.waveId === waveId && s.roleId === 'ceo');
|
|
265
|
+
const allEvents: import('./api').SSEEvent[] = [];
|
|
266
|
+
|
|
267
|
+
for (const ses of sessions.slice(-2)) {
|
|
268
|
+
try {
|
|
269
|
+
const resp = await import('./api').then(m => m.fetchJson<{ events: any[] }>(`/api/jobs/${ses.id}/history`));
|
|
270
|
+
const events = resp?.events ?? [];
|
|
271
|
+
for (const e of events) {
|
|
272
|
+
if (['text', 'tool:start', 'tool:result', 'msg:start', 'msg:done', 'msg:error', 'dispatch:start', 'thinking'].includes(e.type)) {
|
|
273
|
+
allEvents.push(e as import('./api').SSEEvent);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
} catch { /* skip */ }
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
if (allEvents.length > 0) {
|
|
280
|
+
sse.loadHistory(allEvents);
|
|
281
|
+
}
|
|
282
|
+
} catch { /* ignore */ }
|
|
283
|
+
}, [api.sessions, sse]);
|
|
284
|
+
|
|
261
285
|
// Load previous conversation from wave's activity stream into system messages
|
|
262
286
|
const loadPreviousConversation = useCallback(async (waveId: string) => {
|
|
263
287
|
try {
|
|
@@ -338,6 +362,7 @@ export const App: React.FC = () => {
|
|
|
338
362
|
// Load previous conversation into stream (like claude --resume)
|
|
339
363
|
if (lastWave) {
|
|
340
364
|
loadPreviousConversation(lastWave.waveId);
|
|
365
|
+
loadWaveHistoryEvents(lastWave.waveId);
|
|
341
366
|
}
|
|
342
367
|
} else if (api.loaded) {
|
|
343
368
|
// No active waves, no past waves — fresh start
|
|
@@ -402,6 +427,9 @@ export const App: React.FC = () => {
|
|
|
402
427
|
onFocusWave: (waveId) => {
|
|
403
428
|
setFocusedWaveId(waveId);
|
|
404
429
|
sse.clearEvents();
|
|
430
|
+
setSystemMessages([]);
|
|
431
|
+
loadPreviousConversation(waveId);
|
|
432
|
+
loadWaveHistoryEvents(waveId);
|
|
405
433
|
},
|
|
406
434
|
onQuit: () => exit(),
|
|
407
435
|
onShowPanel: () => setMode('panel'),
|
|
@@ -647,6 +675,9 @@ export const App: React.FC = () => {
|
|
|
647
675
|
onFocusWave={(newWaveId) => {
|
|
648
676
|
setFocusedWaveId(newWaveId);
|
|
649
677
|
sse.clearEvents();
|
|
678
|
+
setSystemMessages([]);
|
|
679
|
+
loadPreviousConversation(newWaveId);
|
|
680
|
+
loadWaveHistoryEvents(newWaveId);
|
|
650
681
|
}}
|
|
651
682
|
/>
|
|
652
683
|
</Box>
|
package/src/tui/hooks/useSSE.ts
CHANGED
|
@@ -45,6 +45,7 @@ export interface SSEState {
|
|
|
45
45
|
events: SSEEvent[];
|
|
46
46
|
streamStatus: 'idle' | 'streaming' | 'done' | 'error';
|
|
47
47
|
clearEvents(): void;
|
|
48
|
+
loadHistory(events: SSEEvent[]): void;
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
export function useSSE(waveId: string | null): SSEState {
|
|
@@ -78,6 +79,10 @@ export function useSSE(waveId: string | null): SSEState {
|
|
|
78
79
|
maxSeqRef.current = 0;
|
|
79
80
|
}, []);
|
|
80
81
|
|
|
82
|
+
const loadHistory = useCallback((historyEvents: SSEEvent[]) => {
|
|
83
|
+
setEvents(historyEvents.slice(-MAX_EVENTS));
|
|
84
|
+
}, []);
|
|
85
|
+
|
|
81
86
|
useEffect(() => {
|
|
82
87
|
if (waveIdRef.current !== waveId) {
|
|
83
88
|
connRef.current?.close();
|
|
@@ -171,5 +176,5 @@ export function useSSE(waveId: string | null): SSEState {
|
|
|
171
176
|
};
|
|
172
177
|
}, [waveId, flushBatch]);
|
|
173
178
|
|
|
174
|
-
return { events, streamStatus, clearEvents };
|
|
179
|
+
return { events, streamStatus, clearEvents, loadHistory };
|
|
175
180
|
}
|