Compare commits

...

2 Commits

Author SHA1 Message Date
Jeremy Rose
55226e2387 terminal.app 2025-12-09 14:40:43 -08:00
Jeremy Rose
a8f0106677 redraw on resize 2025-12-09 14:07:04 -08:00
5 changed files with 42 additions and 5 deletions

View File

@@ -480,6 +480,41 @@ impl App {
},
)?;
}
TuiEvent::Resized(size) => {
use std::io::Write;
write!(
tui.terminal.backend_mut(),
"\x1b]1337;ClearScrollback=yes\x07\x1b[2J\x1b[H\x1b[3J"
)?;
tui.terminal.clear()?;
self.has_emitted_history_lines = false;
for cell in &self.transcript_cells {
let mut display = cell.display_lines(size.width);
if !display.is_empty() {
// Only insert a separating blank line for new cells that are not
// part of an ongoing stream. Streaming continuations should not
// accrue extra blank lines between chunks.
if !cell.is_stream_continuation() {
if self.has_emitted_history_lines {
display.insert(0, Line::from(""));
} else {
self.has_emitted_history_lines = true;
}
}
if self.overlay.is_some() {
self.deferred_history_lines.extend(display);
} else {
tui.insert_history_lines(display);
}
}
}
tui.draw(self.chat_widget.desired_height(size.width), |frame| {
self.chat_widget.render(frame.area(), frame.buffer);
if let Some((x, y)) = self.chat_widget.cursor_pos(frame.area()) {
frame.set_cursor_position((x, y));
}
})?;
}
}
}
Ok(true)

View File

@@ -103,7 +103,7 @@ pub(crate) async fn run_model_migration_prompt(
match event {
TuiEvent::Key(key_event) => screen.handle_key(key_event),
TuiEvent::Paste(_) => {}
TuiEvent::Draw => {
TuiEvent::Draw | TuiEvent::Resized(_) => {
let _ = alt.tui.draw(u16::MAX, |frame| {
frame.render_widget_ref(&screen, frame.area());
});

View File

@@ -385,7 +385,7 @@ pub(crate) async fn run_onboarding_app(
TuiEvent::Paste(text) => {
onboarding_screen.handle_paste(text);
}
TuiEvent::Draw => {
TuiEvent::Draw | TuiEvent::Resized(_) => {
if !did_full_clear_after_success
&& onboarding_screen.steps.iter().any(|step| {
if let Step::Auth(w) = step {

View File

@@ -59,7 +59,7 @@ pub(crate) async fn run_skill_error_prompt(
match event {
TuiEvent::Key(key_event) => screen.handle_key(key_event),
TuiEvent::Paste(_) => {}
TuiEvent::Draw => {
TuiEvent::Draw | TuiEvent::Resized(_) => {
let _ = alt.tui.draw(u16::MAX, |frame| {
frame.render_widget_ref(&screen, frame.area());
});

View File

@@ -31,6 +31,7 @@ use ratatui::crossterm::terminal::disable_raw_mode;
use ratatui::crossterm::terminal::enable_raw_mode;
use ratatui::layout::Offset;
use ratatui::layout::Rect;
use ratatui::layout::Size;
use ratatui::text::Line;
use tokio::select;
use tokio::sync::broadcast;
@@ -158,6 +159,7 @@ pub enum TuiEvent {
Key(KeyEvent),
Paste(String),
Draw,
Resized(Size),
}
pub struct Tui {
@@ -248,8 +250,8 @@ impl Tui {
}
yield TuiEvent::Key(key_event);
}
Event::Resize(_, _) => {
yield TuiEvent::Draw;
Event::Resize(columns, rows) => {
yield TuiEvent::Resized(Size::new(columns, rows));
}
Event::Paste(pasted) => {
yield TuiEvent::Paste(pasted);