Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src-tauri/src/bin/codex_monitor_daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,6 @@ impl DaemonState {
};

let codex_home = codex_home::resolve_workspace_codex_home(&entry, parent_path.as_deref())
.or_else(codex_home::resolve_default_codex_home)
.ok_or("Unable to resolve CODEX_HOME".to_string())?;
let rules_path = rules::default_rules_path(&codex_home);
rules::append_prefix_rule(&rules_path, &command)?;
Expand Down
3 changes: 1 addition & 2 deletions src-tauri/src/codex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::backend::app_server::{
build_codex_command_with_bin, build_codex_path_env, check_codex_installation,
spawn_workspace_session as spawn_workspace_session_inner,
};
use crate::codex_home::{resolve_default_codex_home, resolve_workspace_codex_home};
use crate::codex_home::resolve_workspace_codex_home;
use crate::event_sink::TauriEventSink;
use crate::remote_backend;
use crate::rules;
Expand Down Expand Up @@ -584,7 +584,6 @@ pub(crate) async fn remember_approval_rule(
};

let codex_home = resolve_workspace_codex_home(&entry, parent_path.as_deref())
.or_else(resolve_default_codex_home)
.ok_or("Unable to resolve CODEX_HOME".to_string())?;
let rules_path = rules::default_rules_path(&codex_home);
rules::append_prefix_rule(&rules_path, &command)?;
Expand Down
26 changes: 1 addition & 25 deletions src-tauri/src/codex_config.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::env;
use std::fs;
use std::path::PathBuf;

Expand Down Expand Up @@ -58,30 +57,7 @@ fn write_feature_flag(key: &str, enabled: bool) -> Result<(), String> {
}

pub(crate) fn config_toml_path() -> Option<PathBuf> {
resolve_codex_home().map(|home| home.join("config.toml"))
}

fn resolve_codex_home() -> Option<PathBuf> {
if let Ok(value) = env::var("CODEX_HOME") {
if !value.trim().is_empty() {
return Some(PathBuf::from(value.trim()));
}
}
resolve_home_dir().map(|home| home.join(".codex"))
}

fn resolve_home_dir() -> Option<PathBuf> {
if let Ok(value) = env::var("HOME") {
if !value.trim().is_empty() {
return Some(PathBuf::from(value));
}
}
if let Ok(value) = env::var("USERPROFILE") {
if !value.trim().is_empty() {
return Some(PathBuf::from(value));
}
}
None
crate::codex_home::resolve_default_codex_home().map(|home| home.join("config.toml"))
}

fn find_feature_flag(contents: &str, key: &str) -> Option<bool> {
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/src/codex_home.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub(crate) fn resolve_workspace_codex_home(
if legacy_home.is_dir() {
return Some(legacy_home);
}
None
resolve_default_codex_home()
}

pub(crate) fn resolve_default_codex_home() -> Option<PathBuf> {
Expand Down
28 changes: 1 addition & 27 deletions src-tauri/src/local_usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,33 +497,7 @@ fn make_day_keys(days: u32) -> Vec<String> {
}

fn resolve_codex_sessions_root() -> Option<PathBuf> {
resolve_codex_home().map(|home| home.join("sessions"))
}

fn resolve_codex_home() -> Option<PathBuf> {
if let Ok(value) = std::env::var("CODEX_HOME") {
let trimmed = value.trim();
if !trimmed.is_empty() {
return Some(PathBuf::from(trimmed));
}
}
resolve_home_dir().map(|home| home.join(".codex"))
}

fn resolve_home_dir() -> Option<PathBuf> {
if let Ok(value) = std::env::var("HOME") {
let trimmed = value.trim();
if !trimmed.is_empty() {
return Some(PathBuf::from(trimmed));
}
}
if let Ok(value) = std::env::var("USERPROFILE") {
let trimmed = value.trim();
if !trimmed.is_empty() {
return Some(PathBuf::from(trimmed));
}
}
None
crate::codex_home::resolve_default_codex_home().map(|home| home.join("sessions"))
}

fn day_dir_for_key(root: &Path, day_key: &str) -> PathBuf {
Expand Down
30 changes: 1 addition & 29 deletions src-tauri/src/prompts.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use serde::Serialize;
use std::collections::HashMap;
use std::env;
use std::fs;
use std::path::{Path, PathBuf};
use tokio::task;
Expand All @@ -21,35 +20,8 @@ pub(crate) struct CustomPromptEntry {
pub(crate) scope: Option<String>,
}

fn resolve_home_dir() -> Option<PathBuf> {
if let Ok(value) = env::var("HOME") {
if !value.trim().is_empty() {
return Some(PathBuf::from(value));
}
}
if let Ok(value) = env::var("USERPROFILE") {
if !value.trim().is_empty() {
return Some(PathBuf::from(value));
}
}
None
}

fn resolve_codex_home() -> Option<PathBuf> {
if let Ok(value) = env::var("CODEX_HOME") {
if !value.trim().is_empty() {
let path = PathBuf::from(value.trim());
if path.exists() {
return path.canonicalize().ok().or(Some(path));
}
return None;
}
}
resolve_home_dir().map(|home| home.join(".codex"))
}

fn default_prompts_dir() -> Option<PathBuf> {
resolve_codex_home().map(|home| home.join("prompts"))
crate::codex_home::resolve_default_codex_home().map(|home| home.join("prompts"))
}

fn require_workspace_entry(
Expand Down