chore: expose codex_home via Config (#941)

This commit is contained in:
Michael Bolin
2025-05-15 00:30:13 -07:00
committed by GitHub
parent 0b9ef93da5
commit 5fc9fc3e3e
10 changed files with 212 additions and 98 deletions

View File

@@ -17,7 +17,7 @@ use tokio::sync::mpsc::Sender;
use tokio::sync::mpsc::{self};
use uuid::Uuid;
use crate::config::codex_dir;
use crate::config::Config;
use crate::models::ResponseItem;
/// Folder inside `~/.codex` that holds saved rollouts.
@@ -49,12 +49,16 @@ impl RolloutRecorder {
/// Attempt to create a new [`RolloutRecorder`]. If the sessions directory
/// cannot be created or the rollout file cannot be opened we return the
/// error so the caller can decide whether to disable persistence.
pub async fn new(uuid: Uuid, instructions: Option<String>) -> std::io::Result<Self> {
pub async fn new(
config: &Config,
uuid: Uuid,
instructions: Option<String>,
) -> std::io::Result<Self> {
let LogFileInfo {
file,
session_id,
timestamp,
} = create_log_file(uuid)?;
} = create_log_file(config, uuid)?;
// Build the static session metadata JSON first.
let timestamp_format: &[FormatItem] = format_description!(
@@ -154,9 +158,9 @@ struct LogFileInfo {
timestamp: OffsetDateTime,
}
fn create_log_file(session_id: Uuid) -> std::io::Result<LogFileInfo> {
fn create_log_file(config: &Config, session_id: Uuid) -> std::io::Result<LogFileInfo> {
// Resolve ~/.codex/sessions and create it if missing.
let mut dir = codex_dir()?;
let mut dir = config.codex_home.clone();
dir.push(SESSIONS_SUBDIR);
fs::create_dir_all(&dir)?;