Refactor API integration and enhance command handling

- Removed unused modules and updated module paths for clarity.
- Added autocomplete functionality for command input in InputState.
- Updated AppStateRest to include a method for checking if a turn is in flight.
- Refactored subagent engine to use new API client structure.
- Changed default provider from "openrouter" to "zen" with updated API keys and models.
- Implemented tests for memory management and edit log functionalities.
- Enhanced error handling in API requests and improved response parsing.
- Updated UI components to reflect new API provider and status indicators.
This commit is contained in:
asepharyana
2026-07-11 22:10:17 +07:00
parent f6389018f5
commit 3dee2a1427
30 changed files with 788 additions and 222 deletions
+73
View File
@@ -62,3 +62,76 @@ impl EditLog {
self.entries.len()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_editlog_new_empty() {
let dir = std::env::temp_dir().join("editlog_test");
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);
}
#[test]
fn test_editlog_append_and_reload() {
let dir = std::env::temp_dir().join("editlog_append_test");
let _ = std::fs::create_dir_all(&dir);
let mut log = EditLog::new(&dir);
let entry = EditLogEntry {
ts: 1,
tool: "write".to_string(),
path: "test.txt".to_string(),
reason: "test reason".to_string(),
content_sha256: "abc123".to_string(),
bytes_delta: 42,
origin: "main".to_string(),
session_id: "sess-1".to_string(),
};
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);
let _ = std::fs::remove_dir_all(&dir);
}
#[test]
fn test_editlog_multiple_entries() {
let dir = std::env::temp_dir().join("editlog_multiple_test");
let _ = std::fs::create_dir_all(&dir);
let mut log = EditLog::new(&dir);
for i in 0..5 {
log.append(EditLogEntry {
ts: i,
tool: "edit".to_string(),
path: format!("file{}.txt", i),
reason: format!("reason {}", i),
content_sha256: "hash".to_string(),
bytes_delta: 10 + i,
origin: "main".to_string(),
session_id: "sess-1".to_string(),
}).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");
let _ = std::fs::remove_dir_all(&dir);
}
}