diff --git a/codex-rs/session/src/cli.rs b/codex-rs/session/src/cli.rs index 01b0e9f9c3..f806647641 100644 --- a/codex-rs/session/src/cli.rs +++ b/codex-rs/session/src/cli.rs @@ -134,28 +134,26 @@ impl CreateCmd { // bubbling up the error to the caller. // ----------------------------------------------------------------- - let spawn_result: Result<(u32, Option, store::SessionKind)> = (|| { - match self.agent { - AgentKind::Exec(cmd) => { - let args = build_exec_args(&cmd.exec_cli); - let child = spawn::spawn_exec(&paths, &args)?; - let preview = cmd.exec_cli.prompt.as_ref().map(|p| truncate_preview(p)); - Ok(( - child.id().unwrap_or_default(), - preview, - store::SessionKind::Exec, - )) - } - AgentKind::Repl(cmd) => { - let args = build_repl_args(&cmd.repl_cli); - let child = spawn::spawn_repl(&paths, &args)?; - let preview = cmd.repl_cli.prompt.as_ref().map(|p| truncate_preview(p)); - Ok(( - child.id().unwrap_or_default(), - preview, - store::SessionKind::Repl, - )) - } + let spawn_result: Result<(u32, Option, store::SessionKind)> = (|| match self.agent { + AgentKind::Exec(cmd) => { + let args = build_exec_args(&cmd.exec_cli); + let child = spawn::spawn_exec(&paths, &args)?; + let preview = cmd.exec_cli.prompt.as_ref().map(|p| truncate_preview(p)); + Ok(( + child.id().unwrap_or_default(), + preview, + store::SessionKind::Exec, + )) + } + AgentKind::Repl(cmd) => { + let args = build_repl_args(&cmd.repl_cli); + let child = spawn::spawn_repl(&paths, &args)?; + let preview = cmd.repl_cli.prompt.as_ref().map(|p| truncate_preview(p)); + Ok(( + child.id().unwrap_or_default(), + preview, + store::SessionKind::Repl, + )) } })(); @@ -475,7 +473,7 @@ impl LogsCmd { let file = tokio::fs::File::open(target).await?; - if self.follow { + if self.follow { // ------------------------------------------------------------------ // Improved `--follow` implementation (tail -f semantics) // @@ -486,8 +484,11 @@ impl LogsCmd { // 2. Keep retrying after EOF so the behaviour matches the familiar // `tail -f` utility. - use tokio::io::{AsyncBufReadExt, AsyncSeekExt, BufReader}; - use tokio::time::{sleep, Duration}; + use tokio::io::AsyncBufReadExt; + use tokio::io::AsyncSeekExt; + use tokio::io::BufReader; + use tokio::time::sleep; + use tokio::time::Duration; // Jump to EOF before we start reading so we don't emit historical // data. Ignore errors from `seek` on special files – in that case diff --git a/codex-rs/session/src/store.rs b/codex-rs/session/src/store.rs index 8c017ced22..6cc06bc0a3 100644 --- a/codex-rs/session/src/store.rs +++ b/codex-rs/session/src/store.rs @@ -206,8 +206,8 @@ pub async fn kill_session(id: &str) -> Result<()> { // Load meta.json – we need the PID written at spawn time. let bytes = std::fs::read(&paths.meta) .with_context(|| format!("could not read metadata for session '{id}'"))?; - let meta: SessionMeta = serde_json::from_slice(&bytes) - .context("failed to deserialize session metadata")?; + let meta: SessionMeta = + serde_json::from_slice(&bytes).context("failed to deserialize session metadata")?; let pid_u32 = meta.pid; @@ -219,8 +219,11 @@ pub async fn kill_session(id: &str) -> Result<()> { #[cfg(windows)] fn is_alive(pid: u32) -> bool { - use windows_sys::Win32::Foundation::{CloseHandle, HANDLE}; - use windows_sys::Win32::System::Threading::{OpenProcess, PROCESS_QUERY_LIMITED_INFORMATION, GetExitCodeProcess}; + use windows_sys::Win32::Foundation::CloseHandle; + use windows_sys::Win32::Foundation::HANDLE; + use windows_sys::Win32::System::Threading::GetExitCodeProcess; + use windows_sys::Win32::System::Threading::OpenProcess; + use windows_sys::Win32::System::Threading::PROCESS_QUERY_LIMITED_INFORMATION; const STILL_ACTIVE: u32 = 259; unsafe { @@ -265,7 +268,7 @@ pub async fn kill_session(id: &str) -> Result<()> { { use windows_sys::Win32::System::Console::GenerateConsoleCtrlEvent; const CTRL_BREAK_EVENT: u32 = 1; // Using BREAK instead of C for detached groups. - // The process group id on Windows *is* the pid that we passed to CREATE_NEW_PROCESS_GROUP. + // The process group id on Windows *is* the pid that we passed to CREATE_NEW_PROCESS_GROUP. unsafe { GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, pid_u32); } @@ -309,8 +312,11 @@ pub async fn kill_session(id: &str) -> Result<()> { #[cfg(windows)] { - use windows_sys::Win32::Foundation::{CloseHandle, HANDLE}; - use windows_sys::Win32::System::Threading::{OpenProcess, TerminateProcess, PROCESS_TERMINATE}; + use windows_sys::Win32::Foundation::CloseHandle; + use windows_sys::Win32::Foundation::HANDLE; + use windows_sys::Win32::System::Threading::OpenProcess; + use windows_sys::Win32::System::Threading::TerminateProcess; + use windows_sys::Win32::System::Threading::PROCESS_TERMINATE; unsafe { let handle: HANDLE = OpenProcess(PROCESS_TERMINATE, 0, pid_u32);