fix(tui): propagate errors in insert_history_lines_to_writer (#4266)
## What? Fixed error handling in `insert_history_lines_to_writer` where all terminal operations were silently ignoring errors via `.ok()`. ## Why? Silent I/O failures could leave the terminal in an inconsistent state (e.g., scroll region not reset) with no way to debug. This violates Rust error handling best practices. ## How? - Changed function signature to return `io::Result<()>` - Replaced all `.ok()` calls with `?` operator to propagate errors - Added `tracing::warn!` in wrapper function for backward compatibility - Updated 15 test call sites to handle Result with `.expect()` ## Testing - ✅ Pass all tests ## Type of Change - [x] Bug fix (non-breaking change) --------- Signed-off-by: Huaiwu Li <lhwzds@gmail.com> Co-authored-by: Eric Traut <etraut@openai.com>
This commit is contained in:
@@ -1582,7 +1582,8 @@ async fn binary_size_transcript_snapshot() {
|
||||
}
|
||||
has_emitted_history = true;
|
||||
transcript.push_str(&lines_to_single_string(&lines));
|
||||
crate::insert_history::insert_history_lines(&mut terminal, lines);
|
||||
crate::insert_history::insert_history_lines(&mut terminal, lines)
|
||||
.expect("Failed to insert history lines in test");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1603,7 +1604,8 @@ async fn binary_size_transcript_snapshot() {
|
||||
}
|
||||
has_emitted_history = true;
|
||||
transcript.push_str(&lines_to_single_string(&lines));
|
||||
crate::insert_history::insert_history_lines(&mut terminal, lines);
|
||||
crate::insert_history::insert_history_lines(&mut terminal, lines)
|
||||
.expect("Failed to insert history lines in test");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2654,7 +2656,8 @@ fn chatwidget_exec_and_status_layout_vt100_snapshot() {
|
||||
term.set_viewport_area(viewport);
|
||||
|
||||
for lines in drain_insert_history(&mut rx) {
|
||||
crate::insert_history::insert_history_lines(&mut term, lines);
|
||||
crate::insert_history::insert_history_lines(&mut term, lines)
|
||||
.expect("Failed to insert history lines in test");
|
||||
}
|
||||
|
||||
term.draw(|f| {
|
||||
@@ -2731,7 +2734,8 @@ printf 'fenced within fenced\n'
|
||||
while let Ok(app_ev) = rx.try_recv() {
|
||||
if let AppEvent::InsertHistoryCell(cell) = app_ev {
|
||||
let lines = cell.display_lines(width);
|
||||
crate::insert_history::insert_history_lines(&mut term, lines);
|
||||
crate::insert_history::insert_history_lines(&mut term, lines)
|
||||
.expect("Failed to insert history lines in test");
|
||||
inserted_any = true;
|
||||
}
|
||||
}
|
||||
@@ -2749,7 +2753,8 @@ printf 'fenced within fenced\n'
|
||||
}),
|
||||
});
|
||||
for lines in drain_insert_history(&mut rx) {
|
||||
crate::insert_history::insert_history_lines(&mut term, lines);
|
||||
crate::insert_history::insert_history_lines(&mut term, lines)
|
||||
.expect("Failed to insert history lines in test");
|
||||
}
|
||||
|
||||
assert_snapshot!(term.backend().vt100().screen().contents());
|
||||
|
||||
Reference in New Issue
Block a user