From 59c4c24959a90255db9c2e0ff0600bb2c7af0e1c Mon Sep 17 00:00:00 2001 From: Ehab Younes Date: Mon, 12 Oct 2026 18:18:07 +0300 Subject: [PATCH] fix(workspace): keep the last startup log line from wrapping Show Logs writes the logs when the terminal opens, before it has its final width, so lines wrap at a narrow width. xterm.js rejoins wrapped lines when the terminal widens, except the line with the cursor. The last log line had no line break, so it held the cursor and stayed wrapped or cut off. End every line with a line break. --- src/workspace/workspaceMonitor.ts | 6 ++++-- test/unit/workspace/workspaceMonitor.test.ts | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/workspace/workspaceMonitor.ts b/src/workspace/workspaceMonitor.ts index 8454b94b86..a2e2f5a5eb 100644 --- a/src/workspace/workspaceMonitor.ts +++ b/src/workspace/workspaceMonitor.ts @@ -371,9 +371,11 @@ export class WorkspaceMonitor implements vscode.Disposable { logs: readonly WorkspaceAgentLog[], ): vscode.Terminal { const writeEmitter = new vscode.EventEmitter(); + // End every line so the cursor sits below the logs: xterm.js never + // reflows the cursor's line, which `open` writes before the final width. const output = logs - .map((log) => log.output.replace(/\r?\n/g, "\r\n")) - .join("\r\n"); + .map((log) => log.output.replace(/\r?\n/g, "\r\n") + "\r\n") + .join(""); return vscode.window.createTerminal({ name, pty: { diff --git a/test/unit/workspace/workspaceMonitor.test.ts b/test/unit/workspace/workspaceMonitor.test.ts index 3f182f4dfe..dbc1d900d5 100644 --- a/test/unit/workspace/workspaceMonitor.test.ts +++ b/test/unit/workspace/workspaceMonitor.test.ts @@ -552,7 +552,7 @@ describe("WorkspaceMonitor", () => { await vi.waitFor(() => { expect(Object.fromEntries(writes)).toEqual({ - "Startup Logs: Install deps": ["installing\r\nnpm ERR!"], + "Startup Logs: Install deps": ["installing\r\nnpm ERR!\r\n"], }); }); });