clear terminal on launch (#1870)

This commit is contained in:
ae
2025-08-05 22:01:34 -07:00
committed by GitHub
parent 31dcae67db
commit b90c15abc4

View File

@@ -3,11 +3,14 @@ use std::io::Stdout;
use std::io::stdout;
use codex_core::config::Config;
use crossterm::cursor::MoveTo;
use crossterm::event::DisableBracketedPaste;
use crossterm::event::EnableBracketedPaste;
use crossterm::event::KeyboardEnhancementFlags;
use crossterm::event::PopKeyboardEnhancementFlags;
use crossterm::event::PushKeyboardEnhancementFlags;
use crossterm::terminal::Clear;
use crossterm::terminal::ClearType;
use ratatui::backend::CrosstermBackend;
use ratatui::crossterm::execute;
use ratatui::crossterm::terminal::disable_raw_mode;
@@ -36,6 +39,12 @@ pub fn init(_config: &Config) -> Result<Tui> {
)?;
set_panic_hook();
// Ensure the UI starts at the top of the terminal by clearing the
// current screen and moving the cursor to (0, 0) before creating the
// Terminal. This makes the initial welcome message render at the very top
// of the viewport, while keeping the normal scrollback history intact.
execute!(stdout(), Clear(ClearType::All), MoveTo(0, 0))?;
let backend = CrosstermBackend::new(stdout());
let tui = Terminal::with_options(backend)?;
Ok(tui)