Fix async terminal.write() causing garbled dashboard output
The terminal.write() method from @xterm/headless is async - the data isn't in the buffer yet when we call serializeAsHTML() immediately after. This caused empty or partially rendered output in the browser. Now using the callback form of terminal.write(data, callback) to wait for the write to complete before serializing and broadcasting to SSE clients. This ensures the terminal buffer is fully updated before we generate HTML from it.
This commit is contained in:
parent
9bc77292cd
commit
31340fe0a8
1 changed files with 11 additions and 10 deletions
|
|
@ -520,12 +520,12 @@ const server = Bun.serve<SessionData>({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write to terminal emulator (handles all ANSI sequences)
|
|
||||||
termSession.terminal.write(msg.data);
|
|
||||||
|
|
||||||
// Store raw ANSI in database
|
// Store raw ANSI in database
|
||||||
appendOutput(sessionId, msg.data);
|
appendOutput(sessionId, msg.data);
|
||||||
|
|
||||||
|
// Write to terminal emulator (handles all ANSI sequences)
|
||||||
|
// Use callback to wait for write completion before serializing
|
||||||
|
termSession.terminal.write(msg.data, () => {
|
||||||
// Serialize current terminal state as HTML
|
// Serialize current terminal state as HTML
|
||||||
const html = serializeAsHTML(termSession);
|
const html = serializeAsHTML(termSession);
|
||||||
|
|
||||||
|
|
@ -535,6 +535,7 @@ const server = Bun.serve<SessionData>({
|
||||||
session_id: sessionId,
|
session_id: sessionId,
|
||||||
data: html,
|
data: html,
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue