Refactor scrolling methods in ScrollState to accept an amount parameter

- Updated `scroll_up` and `scroll_down` methods to take an `amount` parameter for more flexible scrolling.
- Removed the `AgentMode` enum and related methods from the types module to simplify state management.
- Modified `AppStateRest` to remove the `mode` field and adjusted related logic.
- Enhanced `run_subagent` to build tool definitions and handle API key resolution from configuration.
- Updated command parsing to reflect changes in login handling.
- Removed onboarding overlays and related logic from input handling and rendering.
- Improved status bar to reflect connection status and agent readiness.
- Adjusted workflow panel rendering to simplify phase status display.
- Refactored edit log initialization to load from disk if available.
- Updated settings structure to use a HashMap for API keys.
- Enhanced error handling in LlmClient for authentication issues.
This commit is contained in:
asepharyana
2026-07-12 03:14:52 +07:00
parent 71d3494372
commit 36573e7e3b
28 changed files with 435 additions and 482 deletions
+12 -4
View File
@@ -22,9 +22,17 @@ pub fn bash_output(id: &str) -> Option<Vec<String>> {
pub fn bash_kill(id: &str) -> anyhow::Result<()> {
let mut map = bash_jobs_map().lock().map_err(|e| anyhow::anyhow!("lock error: {}", e))?;
let job = map.remove(id);
if job.is_some() {
Ok(())
} else {
anyhow::bail!("bash job '{}' not found", id)
match job {
Some(job) => {
// Actually terminate the child process via its PID
if job.child_pid > 0 {
#[cfg(unix)]
unsafe {
libc::kill(job.child_pid as i32, libc::SIGTERM);
}
}
Ok(())
}
None => anyhow::bail!("bash job '{}' not found", id),
}
}
+24 -15
View File
@@ -5,6 +5,7 @@ use std::io::BufRead;
pub struct BashJob {
pub id: String,
pub child_pid: u32,
pub output_rx: mpsc::Receiver<String>,
pub exit_code: Option<i32>,
}
@@ -12,36 +13,44 @@ pub struct BashJob {
pub fn spawn_bash_job(command: String) -> BashJob {
let id = uuid::Uuid::new_v4().to_string();
let (output_tx, output_rx) = mpsc::channel::<String>();
let (pid_tx, pid_rx) = mpsc::channel::<u32>();
let cmd = command.clone();
let _handle = thread::spawn(move || {
let child = Command::new("sh")
thread::spawn(move || {
let mut child = match Command::new("sh")
.arg("-c")
.arg(&cmd)
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.spawn();
match child {
Ok(mut child) => {
if let Some(stdout) = child.stdout.take() {
let reader = std::io::BufReader::new(stdout);
for line in reader.lines().map_while(Result::ok) {
let _ = output_tx.send(line);
}
}
let status = child.wait();
let code = status.ok().and_then(|s| s.code());
let _ = output_tx.send(format!("__exit:{}", code.unwrap_or(-1)));
}
.spawn()
{
Ok(c) => c,
Err(e) => {
let _ = output_tx.send(format!("__error:{}", e));
let _ = output_tx.send("__exit:-1".to_string());
return;
}
};
// Send the child PID back to the caller so bash_kill can terminate it
let _ = pid_tx.send(child.id());
if let Some(stdout) = child.stdout.take() {
let reader = std::io::BufReader::new(stdout);
for line in reader.lines().map_while(Result::ok) {
let _ = output_tx.send(line);
}
}
let status = child.wait();
let code = status.ok().and_then(|s| s.code());
let _ = output_tx.send(format!("__exit:{}", code.unwrap_or(-1)));
});
let child_pid = pid_rx.recv().unwrap_or(0);
BashJob {
id,
child_pid,
output_rx,
exit_code: None,
}