feat(FN-772): fix terminal startup and prompt delivery reliability

- Fix terminal service to ensure prompt is reliably delivered on startup and reconnect
- Add regression tests for terminal reconnect and first-paint behavior
- Remove dead code: unused global-settings tests, styles.css, Header/MissionManager tests
- Update terminal README with reliable prompt delivery guarantee documentation
- Add useTerminal hook tests and TerminalModal component tests
This commit is contained in:
gsxdsm
2026-04-03 09:16:34 -07:00
parent 6ab7f24bba
commit 057bd30645
6 changed files with 404 additions and 9 deletions

View File

@@ -99,6 +99,9 @@ export function useTerminal(sessionId: string | null): UseTerminalReturn {
const buffer = initialBufferRef.current;
if (buffer.data.length > 0) {
buffer.data.forEach((d) => callback(d));
// Clear after replay to prevent stale re-delivery if a new subscriber
// registers later (e.g. due to a re-render or reconnect).
buffer.data = [];
}
return () => onDataCallbacksRef.current.delete(callback);
}, []);
@@ -114,6 +117,8 @@ export function useTerminal(sessionId: string | null): UseTerminalReturn {
const buffer = initialBufferRef.current;
if (buffer.connected) {
callback(buffer.connected);
// Clear after replay — connected info is one-shot
buffer.connected = null;
}
return () => onConnectCallbacksRef.current.delete(callback);
}, []);
@@ -124,6 +129,8 @@ export function useTerminal(sessionId: string | null): UseTerminalReturn {
const buffer = initialBufferRef.current;
if (buffer.scrollback) {
callback(buffer.scrollback);
// Clear after replay — scrollback is one-shot per connection
buffer.scrollback = null;
}
return () => onScrollbackCallbacksRef.current.delete(callback);
}, []);