Re-add markdown streaming (#2029)

Wait for newlines, then render markdown on a line by line basis. Word wrap it for the current terminal size and then spit it out line by line into the UI. Also adds tests and fixes some UI regressions.
This commit is contained in:
easong-openai
2025-08-12 17:37:28 -07:00
committed by GitHub
parent 97a27ffc77
commit 6340acd885
42 changed files with 35887 additions and 1026 deletions

View File

@@ -41,15 +41,24 @@ pub mod insert_history;
pub mod live_wrap;
mod log_layer;
mod markdown;
mod markdown_stream;
pub mod onboarding;
mod render;
mod session_log;
mod shimmer;
mod slash_command;
mod status_indicator_widget;
mod streaming;
mod text_block;
mod text_formatting;
mod tui;
mod user_approval_widget;
// Internal vt100-based replay tests live as a separate source file to keep them
// close to the widget code. Include them in unit tests.
#[cfg(test)]
mod chatwidget_stream_tests;
#[cfg(not(debug_assertions))]
mod updates;
#[cfg(not(debug_assertions))]
@@ -57,6 +66,8 @@ use color_eyre::owo_colors::OwoColorize;
pub use cli::Cli;
// (tests access modules directly within the crate)
pub async fn run_main(
cli: Cli,
codex_linux_sandbox_exe: Option<PathBuf>,
@@ -267,6 +278,9 @@ fn run_ratatui_app(
let mut terminal = tui::init(&config)?;
terminal.clear()?;
// Initialize high-fidelity session event logging if enabled.
session_log::maybe_init(&config);
let Cli { prompt, images, .. } = cli;
let mut app = App::new(config.clone(), prompt, images, should_show_trust_screen);
@@ -284,6 +298,8 @@ fn run_ratatui_app(
let usage = app.token_usage();
restore();
// Mark the end of the recorded session.
session_log::log_session_end();
// ignore error when collecting usage report underlying error instead
app_result.map(|_| usage)
}