Enhance loading feedback: add loading animation for Assistant replies, improve TUI message updates, and refine response handling logic. Update README to reflect roadmap progress.
This commit is contained in:
@@ -377,10 +377,23 @@ fn render_messages(frame: &mut Frame<'_>, area: Rect, app: &mut ChatApp) {
|
||||
let indent = if show_role_labels { " " } else { "" };
|
||||
|
||||
if show_role_labels {
|
||||
lines.push(Line::from(Span::styled(
|
||||
let mut role_spans = vec![Span::styled(
|
||||
prefix,
|
||||
role_color(role).add_modifier(Modifier::BOLD),
|
||||
)));
|
||||
)];
|
||||
|
||||
// Add loading animation for Assistant if currently loading and this is the last message
|
||||
if matches!(role, Role::Assistant) &&
|
||||
app.get_loading_indicator() != "" &&
|
||||
message_index == conversation.messages.len() - 1 &&
|
||||
is_streaming {
|
||||
role_spans.push(Span::styled(
|
||||
format!(" {}", app.get_loading_indicator()),
|
||||
Style::default().fg(Color::Yellow),
|
||||
));
|
||||
}
|
||||
|
||||
lines.push(Line::from(role_spans));
|
||||
}
|
||||
|
||||
for (i, line) in formatted.iter().enumerate() {
|
||||
@@ -397,6 +410,26 @@ fn render_messages(frame: &mut Frame<'_>, area: Rect, app: &mut ChatApp) {
|
||||
}
|
||||
}
|
||||
|
||||
// Add loading indicator ONLY if we're loading and there are no messages at all,
|
||||
// or if the last message is from the user (no Assistant response started yet)
|
||||
let last_message_is_user = conversation.messages.last()
|
||||
.map(|msg| matches!(msg.role, Role::User))
|
||||
.unwrap_or(true);
|
||||
|
||||
if app.get_loading_indicator() != "" && last_message_is_user {
|
||||
let loading_spans = vec![
|
||||
Span::styled(
|
||||
"🤖 Assistant:",
|
||||
Style::default().fg(Color::LightMagenta).add_modifier(Modifier::BOLD),
|
||||
),
|
||||
Span::styled(
|
||||
format!(" {}", app.get_loading_indicator()),
|
||||
Style::default().fg(Color::Yellow),
|
||||
),
|
||||
];
|
||||
lines.push(Line::from(loading_spans));
|
||||
}
|
||||
|
||||
if lines.is_empty() {
|
||||
lines.push(Line::from("No messages yet. Press 'i' to start typing."));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user