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"], }); }); });