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: 1 addition & 0 deletions crates/graphicle/src/agent_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1483,6 +1483,7 @@ fn hook_file(client: &str, cwd: &Path) -> Result<PathBuf> {
"claude-code" => Ok(cwd.join(".claude/settings.local.json")),
"codex" => {
let home = std::env::var_os("CODEX_HOME")
.filter(|value| !value.is_empty())
.map(PathBuf::from)
.or_else(|| crate::platform::home_dir().map(|h| h.join(".codex")))
.ok_or_else(|| Error::bad("Home directory unavailable"))?;
Expand Down
2 changes: 2 additions & 0 deletions crates/graphicle/src/capture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1404,9 +1404,11 @@ pub fn default_root(client: Client) -> Option<std::path::PathBuf> {
let home = crate::platform::home_dir();
match client {
Client::ClaudeCode => std::env::var_os("CLAUDE_CONFIG_DIR")
.filter(|d| !d.is_empty())
.map(|d| std::path::PathBuf::from(d).join("projects"))
.or_else(|| home.map(|h| h.join(".claude/projects"))),
Client::Codex => std::env::var_os("CODEX_HOME")
.filter(|d| !d.is_empty())
.map(|d| std::path::PathBuf::from(d).join("sessions"))
.or_else(|| home.map(|h| h.join(".codex/sessions"))),
// Muse Code keeps its data under the XDG data folder on every
Expand Down
43 changes: 43 additions & 0 deletions crates/graphicle/tests/it/capture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1740,6 +1740,49 @@ fn sessions_cli_imports_only_transcripts_of_synced_projects() {
assert!(f.stored("am_connector_docs").is_empty());
}

#[test]
fn sessions_cli_empty_client_home_uses_the_default_folder() {
let f = Fixture::new();
let home = TempDir::new().unwrap();
let current = TempDir::new().unwrap();
let cwd = f.root.to_string_lossy();
let cases = [
(
"claude-code",
"CLAUDE_CONFIG_DIR",
home.path().join(".claude/projects/project/x.jsonl"),
claude(&cwd, true),
2,
),
(
"codex",
"CODEX_HOME",
home.path().join(".codex/sessions/2026/09/30/rollout.jsonl"),
codex(&cwd),
1,
),
];
for (client, variable, transcript, contents, turns) in cases {
std::fs::create_dir_all(transcript.parent().unwrap()).unwrap();
std::fs::write(transcript, contents).unwrap();
let mut command = binary(&f);
crate::child_env::home(&mut command, home.path());
command
.args(["sessions", "import", "--client", client])
.current_dir(current.path())
.env(variable, "");
let output = run_without_input(&mut command);
assert!(
output.status.success(),
"{}",
String::from_utf8_lossy(&output.stderr)
);
let report: Value = serde_json::from_slice(&output.stdout).unwrap();
assert_eq!(report["transcripts"], 1, "{report:#}");
assert_eq!(report["turns_imported"], turns, "{report:#}");
}
}

#[test]
fn connect_merges_claude_code_hooks_and_stays_idempotent() {
let f = Fixture::new();
Expand Down
18 changes: 18 additions & 0 deletions crates/graphicle/tests/it/easy_review.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,24 @@ fn disconnect_all_leaves_other_data_folders_alone() {
);
}

#[test]
fn setup_codex_empty_home_writes_hooks_under_the_default_home() {
let m = Machine::new();
let repo = m.repo("code/app");
assert!(repo.exists());
let args = ["setup", "--yes", "--clients", "codex", "--no-instructions"];
json_of(
&m.run_with(&repo, &m.data, &args, &[("CODEX_HOME", "")]),
&args,
);
let hooks = m.home.join(".codex/hooks.json");
assert!(hooks.exists());
let stop = read_json(&hooks)["hooks"]["Stop"].clone();
assert!(!stop.as_array().unwrap().is_empty(), "{stop:#}");
assert!(stop.to_string().contains("graphicle"), "{stop:#}");
assert!(!repo.join("hooks.json").exists());
}

/// Entries and capture hooks run the program through the link on PATH, so a
/// Homebrew upgrade that removes the old version leaves them working; hooks
/// an older setup pinned to a version that is gone are repaired by `doctor
Expand Down
Loading