feat(tui): implement agent turn engine for background processing and enhance input handling

This commit is contained in:
asepharyana
2026-07-20 10:55:09 +07:00
parent da2ed6da25
commit 792695b65a
31 changed files with 603 additions and 153 deletions
+9 -1
View File
@@ -3,6 +3,8 @@
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
use tracing::error;
use super::job::BashJob;
/// Central registry of all running background bash jobs.
@@ -37,7 +39,13 @@ impl BashControl {
/// List all active jobs.
pub fn list(&self) -> Vec<(String, String, bool)> {
let mut guard = self.jobs.lock().unwrap();
let mut guard = match self.jobs.lock() {
Ok(g) => g,
Err(poisoned) => {
error!("bgbash jobs mutex poisoned, recovering");
poisoned.into_inner()
}
};
guard.retain(|_, j| j.is_running());
guard
.iter()
+9 -1
View File
@@ -4,6 +4,8 @@ use std::process::{Child, Command, Stdio};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Mutex};
use tracing::error;
/// A handle to a spawned background bash job.
pub struct BashJob {
pub id: String,
@@ -34,7 +36,13 @@ pub fn spawn_bash_job(cmd: String) -> Arc<BashJob> {
// Spawn a monitor thread (in production this would use an async task)
let job_clone = Arc::clone(&job);
std::thread::spawn(move || {
let mut guard = job_clone.process.lock().unwrap();
let mut guard = match job_clone.process.lock() {
Ok(g) => g,
Err(poisoned) => {
error!("bgbash job mutex poisoned, recovering");
poisoned.into_inner()
}
};
if let Some(ref mut child) = *guard {
let _ = child.wait();
}