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:
asepharyana
2026-07-11 23:45:13 +07:00
parent 93d1bbb7c1
commit fcef85a327
51 changed files with 1431 additions and 1246 deletions
+14 -37
View File
@@ -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)
-1
View File
@@ -1,5 +1,4 @@
pub mod chat;
pub mod markdown;
pub mod status;
pub mod theme;
pub mod workflow;
-1
View File
@@ -4,7 +4,6 @@ pub struct Theme;
impl Theme {
pub const PRIMARY: Color = Color::Cyan;
pub const SECONDARY: Color = Color::Magenta;
pub const SUCCESS: Color = Color::Green;
pub const WARNING: Color = Color::Yellow;
pub const ERROR: Color = Color::Red;