From bf1967f16ce7941ad0c5865b61d266e12c9bdcba Mon Sep 17 00:00:00 2001 From: minh Date: Sat, 13 Dec 2025 14:43:09 -0800 Subject: [PATCH 1/2] read all pending responses via loop --- lib/terminal.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/terminal.ts b/lib/terminal.ts index 3c2fc2f..df189be 100644 --- a/lib/terminal.ts +++ b/lib/terminal.ts @@ -1749,13 +1749,18 @@ export class Terminal implements ITerminalCore { * * Without this, shells like nushell that rely on cursor position queries * will hang waiting for a response that never comes. + * + * Note: We loop to read all pending responses, not just one. This is important + * when multiple queries are processed in a single write() call (e.g., when + * buffered data is written all at once during terminal initialization). */ private processTerminalResponses(): void { if (!this.wasmTerm) return; - // Read any pending responses from the WASM terminal - const response = this.wasmTerm.readResponse(); - if (response) { + // Read all pending responses from the WASM terminal + // Multiple responses can be queued if a single write() contained multiple queries + let response: string | null; + while ((response = this.wasmTerm.readResponse()) !== null) { // Send response back to the PTY via onData // This is the same path as user keyboard input this.dataEmitter.fire(response); From ced78a035bb260163db24407cde115d7ea97fde5 Mon Sep 17 00:00:00 2001 From: minh Date: Sun, 14 Dec 2025 11:06:46 -0800 Subject: [PATCH 2/2] lint: remove assignment inside expression --- lib/terminal.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/terminal.ts b/lib/terminal.ts index df189be..dda74e9 100644 --- a/lib/terminal.ts +++ b/lib/terminal.ts @@ -1759,8 +1759,9 @@ export class Terminal implements ITerminalCore { // Read all pending responses from the WASM terminal // Multiple responses can be queued if a single write() contained multiple queries - let response: string | null; - while ((response = this.wasmTerm.readResponse()) !== null) { + while (true) { + const response = this.wasmTerm.readResponse(); + if (response === null) break; // Send response back to the PTY via onData // This is the same path as user keyboard input this.dataEmitter.fire(response);