Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions apps/desktop/src/main/terminal-host/pty-subprocess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const INPUT_QUEUE_HARD_LIMIT_BYTES = 64 * 1024 * 1024; // 64MB
let outputChunks: string[] = [];
let outputBytesQueued = 0;
let outputFlushScheduled = false;
const OUTPUT_FLUSH_INTERVAL_MS = 16; // Match terminal-style frame batching (~60fps)
const MAX_OUTPUT_BATCH_SIZE_BYTES = 128 * 1024; // 128KB max per flush

// Backpressure - track if stdout is draining
Expand Down Expand Up @@ -103,9 +104,9 @@ function queueOutput(data: string): void {

if (!outputFlushScheduled) {
outputFlushScheduled = true;
// Flush on the next event-loop turn so interactive echo feels immediate,
// while still coalescing bursts that arrive in the same PTY callback cycle.
setImmediate(flushOutput);
// Timed batching keeps TUI redraws coherent and avoids flooding the renderer
// with tiny per-turn frames while still staying under a single display frame.
setTimeout(flushOutput, OUTPUT_FLUSH_INTERVAL_MS);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,12 @@ export const Terminal = ({ paneId, tabId, workspaceId }: TerminalProps) => {
{ enabled: isWorkspaceRunPane },
);

const workspaceRunRestartCommand = isWorkspaceRunPane
? buildTerminalCommand(workspaceRunConfig?.commands)
: null;
const defaultRestartCommandRef = useRef<string | undefined>(undefined);
defaultRestartCommandRef.current =
(isWorkspaceRunPane
? (buildTerminalCommand(workspaceRunConfig?.commands) ?? undefined)
: undefined) ?? pane?.workspaceRun?.command;
workspaceRunRestartCommand ?? pane?.workspaceRun?.command;

const utils = electronTrpc.useUtils();
const updateWorkspace = electronTrpc.workspaces.update.useMutation({
Expand Down
Loading