Prevent terminal replay from sending input

This commit is contained in:
Federico Jaramillo Martinez
2026-05-11 15:20:59 +02:00
parent 6a21d6768e
commit 3be4489ee7
3 changed files with 33 additions and 8 deletions
+1 -1
View File
@@ -25,7 +25,7 @@ export function registerTerminalRoutes(app: FastifyInstance, terminals: Terminal
let detach: (() => void) | undefined;
try {
detach = terminals.attach(request.params.terminalId, {
output: (data) => { socket.send(JSON.stringify({ type: "output", data })); },
output: (data, replay) => { socket.send(JSON.stringify({ type: "output", data, replay })); },
exit: (exitCode) => { socket.send(JSON.stringify({ type: "exit", exitCode })); },
});
} catch (error) {
+3 -3
View File
@@ -76,11 +76,11 @@ export class TerminalService {
return terminal === undefined ? undefined : toInfo(terminal);
}
attach(id: string, handlers: { output: (data: string) => void; exit: (exitCode: number | undefined) => void }): () => void {
attach(id: string, handlers: { output: (data: string, replay: boolean) => void; exit: (exitCode: number | undefined) => void }): () => void {
const terminal = this.require(id);
if (terminal.buffer !== "") handlers.output(terminal.buffer);
if (terminal.buffer !== "") handlers.output(terminal.buffer, true);
if (terminal.exited) handlers.exit(terminal.exitCode);
const onOutput = (data: string) => { handlers.output(data); };
const onOutput = (data: string) => { handlers.output(data, false); };
const onExit = (exitCode: number | undefined) => { handlers.exit(exitCode); };
terminal.events.on("output", onOutput);
terminal.events.on("exit", onExit);