From 72af9e30920cf65d83934025d5ee1b9e378d5164 Mon Sep 17 00:00:00 2001 From: jif-oai Date: Wed, 19 Nov 2025 12:39:28 +0000 Subject: [PATCH] Clippy --- codex-rs/core/tests/suite/saved_sessions.rs | 6 ++--- codex-rs/tui/src/app.rs | 29 ++++++++++----------- codex-rs/tui/src/lib.rs | 5 +++- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/codex-rs/core/tests/suite/saved_sessions.rs b/codex-rs/core/tests/suite/saved_sessions.rs index c4dc7803c1..648a3ff849 100644 --- a/codex-rs/core/tests/suite/saved_sessions.rs +++ b/codex-rs/core/tests/suite/saved_sessions.rs @@ -1,3 +1,4 @@ +#![allow(clippy::expect_used)] use anyhow::Result; use codex_core::AuthManager; use codex_core::CodexAuth; @@ -87,10 +88,7 @@ async fn save_session( model: &str, ) -> Result { codex.flush_rollout().await?; - codex - .set_session_name(Some(name.to_string())) - .await - .expect("session name set"); + codex.set_session_name(Some(name.to_string())).await?; let entry = build_saved_session_entry(name.to_string(), codex.rollout_path(), model.to_string()) .await?; diff --git a/codex-rs/tui/src/app.rs b/codex-rs/tui/src/app.rs index ede195de01..65fc6c136a 100644 --- a/codex-rs/tui/src/app.rs +++ b/codex-rs/tui/src/app.rs @@ -441,17 +441,19 @@ impl App { } async fn save_session(&mut self, requested_name: String) { - let name = requested_name.clone().trim(); + let name = requested_name.trim().to_string(); if name.is_empty() { self.chat_widget - .add_error_message("Usage: /save ".to_string()) + .add_error_message("Usage: /save ".to_string()); + return; } - match self.try_save_session(requested_name).await { + match self.try_save_session(&name).await { Ok(entry) => { let name = &entry.name; self.chat_widget.add_info_message( format!( - "Saved session '{name}' (conversation {}).", entry.conversation_id + "Saved session '{name}' (conversation {}).", + entry.conversation_id ), Some(format!( "Resume with `codex resume {name}` or fork with `codex fork {name}`.", @@ -464,24 +466,21 @@ impl App { } } - async fn try_save_session( - &mut self, - requested_name: String, - ) -> Result { + async fn try_save_session(&mut self, name: &str) -> Result { // Normalize and validate the user-provided name early so downstream async work // only runs for actionable requests. - let name = requested_name.trim(); if name.is_empty() { - return Err("Usage: /save ".into()); + return Err(CodexErr::Fatal("Usage: /save ".to_string())); } // Capture identifiers from the active chat widget; these are cheap and fast. - let conversation_id = self - .chat_widget - .conversation_id() - .ok_or_else(|| "Session is not ready yet; try /save again in a moment.".to_string())?; + let conversation_id = self.chat_widget.conversation_id().ok_or_else(|| { + CodexErr::Fatal("Session is not ready yet; try /save again in a moment.".to_string()) + })?; let rollout_path = self.chat_widget.rollout_path().ok_or_else(|| { - "Rollout path is not available yet; try /save again shortly.".to_string() + CodexErr::Fatal( + "Rollout path is not available yet; try /save again shortly.".to_string(), + ) })?; // Resolve the conversation handle; all subsequent operations use this shared reference. diff --git a/codex-rs/tui/src/lib.rs b/codex-rs/tui/src/lib.rs index 1879de82ee..0eca2c5f95 100644 --- a/codex-rs/tui/src/lib.rs +++ b/codex-rs/tui/src/lib.rs @@ -342,7 +342,10 @@ async fn resolve_rollout_path( codex_home: &Path, identifier: &str, ) -> std::io::Result> { - if let Some(entry) = resolve_saved_session(codex_home, identifier).await? { + if let Some(entry) = resolve_saved_session(codex_home, identifier) + .await + .map_err(|err| std::io::Error::other(err.to_string()))? + { if entry.rollout_path.exists() { return Ok(Some(entry.rollout_path)); }