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:
+6
-36
@@ -40,24 +40,6 @@ impl EditLog {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn load(path: &std::path::Path) -> std::io::Result<Self> {
|
||||
let content = std::fs::read_to_string(path)?;
|
||||
let entries: Vec<EditLogEntry> = content
|
||||
.lines()
|
||||
.filter_map(|l| serde_json::from_str(l).ok())
|
||||
.collect();
|
||||
Ok(EditLog {
|
||||
entries,
|
||||
path: path.to_path_buf(),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn recent(&self, n: usize) -> &[EditLogEntry] {
|
||||
let len = self.entries.len();
|
||||
let start = len.saturating_sub(n);
|
||||
&self.entries[start..]
|
||||
}
|
||||
|
||||
pub fn len(&self) -> usize {
|
||||
self.entries.len()
|
||||
}
|
||||
@@ -73,7 +55,6 @@ mod tests {
|
||||
let _ = std::fs::create_dir_all(&dir);
|
||||
let log = EditLog::new(&dir);
|
||||
assert_eq!(log.len(), 0);
|
||||
assert_eq!(log.recent(5).len(), 0);
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
|
||||
@@ -94,19 +75,10 @@ mod tests {
|
||||
};
|
||||
log.append(entry.clone()).unwrap();
|
||||
assert_eq!(log.len(), 1);
|
||||
|
||||
let loaded = EditLog::load(&log.path).unwrap();
|
||||
assert_eq!(loaded.len(), 1);
|
||||
assert_eq!(loaded.entries[0].reason, "test reason");
|
||||
assert_eq!(loaded.entries[0].tool, "write");
|
||||
assert_eq!(loaded.entries[0].path, "test.txt");
|
||||
|
||||
let recent = log.recent(1);
|
||||
assert_eq!(recent.len(), 1);
|
||||
assert_eq!(recent[0].bytes_delta, 42);
|
||||
|
||||
let empty = log.recent(0);
|
||||
assert_eq!(empty.len(), 0);
|
||||
assert_eq!(log.entries[0].reason, "test reason");
|
||||
assert_eq!(log.entries[0].tool, "write");
|
||||
assert_eq!(log.entries[0].path, "test.txt");
|
||||
assert_eq!(log.entries[0].bytes_delta, 42);
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
|
||||
@@ -128,10 +100,8 @@ mod tests {
|
||||
}).unwrap();
|
||||
}
|
||||
assert_eq!(log.len(), 5);
|
||||
let recent = log.recent(3);
|
||||
assert_eq!(recent.len(), 3);
|
||||
assert_eq!(recent[0].reason, "reason 2");
|
||||
assert_eq!(recent[2].reason, "reason 4");
|
||||
assert_eq!(log.entries[0].reason, "reason 0");
|
||||
assert_eq!(log.entries[4].reason, "reason 4");
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user