mirror of
https://github.com/openai/codex.git
synced 2026-04-24 14:45:27 +00:00
Clippy
This commit is contained in:
@@ -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<SavedSessionEntry> {
|
||||
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?;
|
||||
|
||||
@@ -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 <name>".to_string())
|
||||
.add_error_message("Usage: /save <name>".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<SavedSessionEntry, CodexErr> {
|
||||
async fn try_save_session(&mut self, name: &str) -> Result<SavedSessionEntry, CodexErr> {
|
||||
// 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 <name>".into());
|
||||
return Err(CodexErr::Fatal("Usage: /save <name>".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.
|
||||
|
||||
@@ -342,7 +342,10 @@ async fn resolve_rollout_path(
|
||||
codex_home: &Path,
|
||||
identifier: &str,
|
||||
) -> std::io::Result<Option<PathBuf>> {
|
||||
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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user