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 <noreply@anthropic.com>
This commit is contained in:
arkon
2026-01-24 00:53:47 +01:00
co-authored by Claude Opus 4.5
parent 99919d6dfb
commit e40849da79
+5 -1
View File
@@ -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);
}