fix(tui): use alternate screen buffer for login screen#492
Merged
Conversation
This fixes the issue where the login screen would spam 'Welcome to Cortex CLI' messages on some Ubuntu terminals instead of properly rendering the interactive TUI. The root cause was that the inline rendering approach using cursor escape sequences (MoveUp/MoveDown) was not reliable across all terminal emulators. Some terminals don't properly support these cursor control sequences, especially in SSH sessions or with certain terminal multiplexer configurations. Solution: Refactored the login screen to use ratatui with the alternate screen buffer, similar to how the trust screen already works. This approach: - Uses EnterAlternateScreen for reliable full-screen rendering - Leverages ratatui's proper terminal abstraction - Works consistently across all terminal emulators - Prevents content from leaking to the scrollback buffer Fixes rendering issues on Ubuntu terminals where cursor escape sequences were not properly interpreted.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Customers reported that on Ubuntu terminals, the TUI login screen was not rendering properly - instead of showing the interactive TUI, it would spam 'Welcome to Cortex CLI v0.0.6' messages repeatedly.
Root Cause
The login screen was using an 'inline' rendering approach that relied on cursor escape sequences (MoveUp/MoveDown) to redraw the content in place. This approach is not reliable across all terminal emulators:
Each render frame would print 12 lines of content and then attempt to move the cursor back up. When the cursor move failed, each frame added more lines instead of overwriting, causing the 'spam' behavior.
Solution
Refactored the login screen to use ratatui with the alternate screen buffer, matching the approach already used by the trust screen:
EnterAlternateScreenfor reliable full-screen renderingTerminal::draw()for atomic frame renderingChanges
Testing