From e40849da799292b86a5abccc167c3f26ea73ca67 Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 24 Jan 2026 00:53:47 +0100 Subject: [PATCH] fix: scroll terminal to bottom on tab switch After loading the terminal buffer on tab switch, xterm.js wasn't guaranteed to be scrolled to the bottom, requiring users to manually scroll down. Fix by: 1. Adding scrollToBottom() after chunkedTerminalWrite completes 2. Adding scrollToBottom() after terminal.focus() 3. Delaying chunkedTerminalWrite resolution by one extra rAF to ensure xterm.js has finished rendering the final chunk Co-Authored-By: Claude Opus 4.5 --- src/web/public/app.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/web/public/app.js b/src/web/public/app.js index 5105952f..50db916f 100644 --- a/src/web/public/app.js +++ b/src/web/public/app.js @@ -231,7 +231,8 @@ class ClaudemanApp { let offset = 0; const writeChunk = () => { if (offset >= buffer.length) { - resolve(); + // Wait one more frame for xterm to finish rendering before resolving + requestAnimationFrame(() => resolve()); return; } @@ -845,6 +846,8 @@ class ClaudemanApp { } // Use chunked write for large buffers to avoid UI jank await this.chunkedTerminalWrite(data.terminalBuffer); + // Ensure terminal is scrolled to bottom after buffer load + this.terminal.scrollToBottom(); } // Send resize and Ctrl+L to trigger Claude to redraw at correct size @@ -883,6 +886,7 @@ class ClaudemanApp { this.renderRalphStatePanel(); this.terminal.focus(); + this.terminal.scrollToBottom(); } catch (err) { console.error('Failed to load session terminal:', err); }