Agent log screen: show agent output, not hook log

spawn_agent() now returns SpawnResult { pid, log_path } so the
log path is known at spawn time. No more filesystem scanning.
AgentInfo carries log_path, TUI reads it directly.

F2 → Enter shows the actual agent log (stdout/stderr from the
poc-memory agent process), not the hook orchestration log.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
Kent Overstreet 2026-04-02 01:04:54 -04:00
parent 1c190a3925
commit a90bd4fd47
3 changed files with 65 additions and 79 deletions

View file

@ -252,11 +252,17 @@ pub fn scan_pid_files(state_dir: &std::path::Path, timeout_secs: u64) -> Vec<(St
/// Spawn an agent asynchronously. Writes the pid file before returning
/// so the caller immediately sees the agent as running.
/// Spawn result: pid and path to the agent's log file.
pub struct SpawnResult {
pub pid: u32,
pub log_path: PathBuf,
}
pub fn spawn_agent(
agent_name: &str,
state_dir: &std::path::Path,
session_id: &str,
) -> Option<u32> {
) -> Option<SpawnResult> {
let def = super::defs::get_def(agent_name)?;
let first_phase = def.steps.first()
.map(|s| s.phase.as_str())
@ -265,8 +271,8 @@ pub fn spawn_agent(
let log_dir = dirs::home_dir().unwrap_or_default()
.join(format!(".consciousness/logs/{}", agent_name));
fs::create_dir_all(&log_dir).ok();
let agent_log = fs::File::create(
log_dir.join(format!("{}.log", store::compact_timestamp())))
let log_path = log_dir.join(format!("{}.log", store::compact_timestamp()));
let agent_log = fs::File::create(&log_path)
.unwrap_or_else(|_| fs::File::create("/dev/null").unwrap());
let child = std::process::Command::new("poc-memory")
@ -281,7 +287,7 @@ pub fn spawn_agent(
let pid = child.id();
let pid_path = state_dir.join(format!("pid-{}", pid));
fs::write(&pid_path, first_phase).ok();
Some(pid)
Some(SpawnResult { pid, log_path })
}
fn run_one_agent_inner(