Skip to content

[Bugfix #205] Fix terminal garbled output and replay scroll#283

Merged
waleedkadous merged 2 commits intomainfrom
builder/bugfix-205-terminal-renders-garbled-outpu
Feb 15, 2026
Merged

[Bugfix #205] Fix terminal garbled output and replay scroll#283
waleedkadous merged 2 commits intomainfrom
builder/bugfix-205-terminal-renders-garbled-outpu

Conversation

@waleedkadous
Copy link
Copy Markdown
Contributor

@waleedkadous waleedkadous commented Feb 15, 2026

Summary

Adds regression test for the reopened scroll-to-bottom aspect of issue #205. The code fix (scrollToBottom after replay buffer flush + deferred resize to PTY) was previously applied in bd55422.

Fixes #205

Root Cause

Two related issues:

  1. Garbled output on tab switch (original): Terminal components were unmounted/remounted on every tab switch, triggering WebSocket reconnection and full ring-buffer replay on fresh xterm.js instances.

  2. Viewport stuck at top after replay (reopened): After Tower restart, replay buffer data was rendered but scrollToBottom() was never called, leaving the viewport at line 0.

Fix

  1. Tab persistence (PR [Bugfix #205] Fix terminal garbled output when revisiting tabs #207): Keep Terminal components mounted via CSS display:none instead of unmounting. Track activated terminals to avoid pre-mounting unvisited tabs.

  2. Scroll after replay (bd55422): Call scrollToBottom() in the term.write() callback after initial buffer flush, plus a deferred scrollToBottom() after 350ms to account for fitAddon.fit() resetting the viewport. Also sends a forced resize to the PTY so the shell redraws at correct dimensions.

Test Plan

  • Regression test added (Terminal.replay-scroll.test.tsx) — 5 test cases
  • Existing persistence tests pass (App.terminal-persistence.test.tsx) — 3 test cases
  • Build passes
  • All tests pass (excluding pre-existing IME dedup test failures)

CMAP Review

Model Verdict Notes
Gemini APPROVE Tests comprehensive, correctly target replay-buffer flush logic
Claude APPROVE Well-structured, aligned with Terminal.tsx implementation
Codex REQUEST_CHANGES → addressed Removed unused mockFitFn; CI dashboard coverage is pre-existing issue (all 10+ dashboard tests are in the same situation)

After Tower restart, terminal replay buffer data was rendered but the
viewport stayed at line 0 (top of scrollback) instead of scrolling to
the bottom. The fix (scrollToBottom after flush + deferred resize) is
already in the codebase; this adds the missing regression test covering:

- scrollToBottom called after initial buffer flush
- Deferred scrollToBottom (350ms) after fitAddon.fit settles
- Forced PTY resize sent after replay flush
- Handles empty replay buffer gracefully
- DA sequence filtering during replay
@waleedkadous waleedkadous merged commit 15f6c77 into main Feb 15, 2026
6 of 7 checks passed
@waleedkadous waleedkadous deleted the builder/bugfix-205-terminal-renders-garbled-outpu branch February 15, 2026 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Terminal renders garbled output when revisiting existing tabs

1 participant