Refactor IPC and DTO structures; remove unused code and streamline message handling
- Removed unused structs and methods from `response.rs`, `usage.rs`, and `client.rs`. - Simplified `Connection` handling in `conn.rs` to only support Unix sockets. - Updated `IpcServer` to exclusively use Unix sockets and removed TCP handling. - Cleaned up `editlog.rs` by removing loading and recent entry methods. - Refactored `memory.rs` to eliminate unused functions related to lesson promotion and retrospective creation. - Enhanced `search.rs` to support multiple search providers and improved error handling. - Updated chat view logic to simplify message display and improve user experience. - Removed deprecated modules and constants from various files to streamline the codebase.
This commit is contained in:
+14
-37
@@ -38,23 +38,9 @@ pub fn draw_chat(frame: &mut Frame, area: Rect, state: &crate::app::state::rest:
|
||||
|
||||
let mut display_lines: Vec<Line> = Vec::new();
|
||||
|
||||
if scroll_offset > 0 {
|
||||
let above = messages.len().saturating_sub(scroll_offset + max_visible).saturating_sub(1);
|
||||
if above > 0 {
|
||||
display_lines.push(Line::from(Span::styled(
|
||||
format!(" ↑ {} more messages above", above),
|
||||
Style::default().fg(Theme::DIM),
|
||||
)));
|
||||
}
|
||||
}
|
||||
let _total_msgs = messages.len();
|
||||
|
||||
let iter_start = if scroll_offset + max_visible >= messages.len() {
|
||||
0usize
|
||||
} else {
|
||||
messages.len().saturating_sub(scroll_offset + max_visible)
|
||||
};
|
||||
|
||||
for msg in messages.iter().skip(iter_start).take(scroll_offset + max_visible) {
|
||||
for msg in messages.iter() {
|
||||
let role_color = match msg.role {
|
||||
crate::dto::chat::message::Role::User => Theme::ROLE_USER,
|
||||
crate::dto::chat::message::Role::Assistant => Theme::ROLE_ASSISTANT,
|
||||
@@ -98,23 +84,12 @@ pub fn draw_chat(frame: &mut Frame, area: Rect, state: &crate::app::state::rest:
|
||||
display_lines.push(Line::from(Span::raw("")));
|
||||
}
|
||||
|
||||
if state.turn_in_flight() {
|
||||
let last_is_user = messages.last().map(|m| matches!(m.role, crate::dto::chat::message::Role::User)).unwrap_or(false);
|
||||
if last_is_user {
|
||||
display_lines.push(Line::from(vec![
|
||||
Span::styled(" AI ", Style::default().fg(Theme::BG).bg(Theme::ROLE_ASSISTANT).add_modifier(Modifier::BOLD)),
|
||||
Span::styled(" Thinking...", Style::default().fg(Theme::DIM)),
|
||||
]));
|
||||
display_lines.push(Line::from(Span::raw("")));
|
||||
}
|
||||
}
|
||||
|
||||
if messages.len() > scroll_offset + max_visible {
|
||||
let below = messages.len().saturating_sub(scroll_offset + max_visible);
|
||||
display_lines.push(Line::from(Span::styled(
|
||||
format!(" ↓ {} more messages below", below),
|
||||
Style::default().fg(Theme::DIM),
|
||||
)));
|
||||
if state.misc.thinking {
|
||||
display_lines.push(Line::from(vec![
|
||||
Span::styled(" AI ", Style::default().fg(Theme::BG).bg(Theme::ROLE_ASSISTANT).add_modifier(Modifier::BOLD)),
|
||||
Span::styled(" Thinking...", Style::default().fg(Theme::DIM)),
|
||||
]));
|
||||
display_lines.push(Line::from(Span::raw("")));
|
||||
}
|
||||
|
||||
let mut title = String::from(" Chat ");
|
||||
@@ -128,13 +103,15 @@ pub fn draw_chat(frame: &mut Frame, area: Rect, state: &crate::app::state::rest:
|
||||
.title(title);
|
||||
|
||||
let total = display_lines.len();
|
||||
let end_idx = total.saturating_sub(scroll_offset);
|
||||
let max_offset = total.saturating_sub(max_visible);
|
||||
let offset = scroll_offset.min(max_offset);
|
||||
|
||||
let end_idx = total.saturating_sub(offset);
|
||||
let start_idx = end_idx.saturating_sub(max_visible);
|
||||
let end_idx = end_idx.min(total);
|
||||
let visible: Vec<Line> = if start_idx < end_idx {
|
||||
let visible: Vec<Line> = if start_idx < end_idx && start_idx < total {
|
||||
display_lines[start_idx..end_idx].to_vec()
|
||||
} else {
|
||||
Vec::new()
|
||||
display_lines[total.saturating_sub(max_visible)..total].to_vec()
|
||||
};
|
||||
|
||||
let paragraph = Paragraph::new(visible)
|
||||
|
||||
Reference in New Issue
Block a user