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
7 changes: 7 additions & 0 deletions rust/src/agent_sessions/claude_desktop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
//! walks only the two known session roots to a shallow fixed depth and returns
//! nested `.claude/projects` directories. Every directory/type/path operation
//! shares the caller's metadata scan budget.
#![cfg_attr(
not(windows),
allow(
dead_code,
reason = "the traversal stays platform-neutral so tests cover it, but only Windows calls it"
)
)]

use super::pi_family::DirectoryScanBudget;
use std::collections::HashSet;
Expand Down
4 changes: 4 additions & 0 deletions rust/src/agent_sessions/pi_family/roots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ impl DirectoryScanBudget {
Some(canonicalize_for_scan(path))
}

#[cfg_attr(
not(windows),
allow(dead_code, reason = "only Windows Claude Desktop discovery reads it")
)]
pub(crate) fn max_depth(&self) -> usize {
self.max_depth
}
Expand Down
7 changes: 6 additions & 1 deletion rust/src/agent_sessions/pi_family_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ mod pi_family_tests {
assert_eq!(pi_family_dialect(records[6].command.as_deref().unwrap()), None);
}

#[cfg(windows)]
#[test]
fn windows_shims_and_paths_are_normalized_for_dialect() {
assert_eq!(
Expand Down Expand Up @@ -682,7 +683,11 @@ mod pi_family_tests {
fn config_dir_must_stay_within_home() {
let home = tempfile::tempdir().expect("tempdir");
let cwd = home.path().to_path_buf();
for bad in ["/abs/path", "..", "../escape", "~/x", "C:\\escape"] {
let mut bad_dirs = vec!["/abs/path", "..", "../escape", "~/x"];
if cfg!(windows) {
bad_dirs.push("C:\\escape");
}
for bad in bad_dirs {
let env = env_map(&[("PI_CONFIG_DIR", bad)]);
assert!(
omp_default_profile_root(&env, &cwd, home.path()).is_none(),
Expand Down
2 changes: 1 addition & 1 deletion rust/src/codex_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
//! TTY launching do not drift into separate path lists.

use std::path::{Path, PathBuf};
use std::process::Command;

/// Locate the Codex CLI for shell integrations that need to reopen a session.
pub fn locate_codex_binary() -> Option<PathBuf> {
Expand Down Expand Up @@ -81,6 +80,7 @@ fn versioned_binaries(root: &Path) -> Vec<PathBuf> {
#[cfg(windows)]
fn desktop_package_binary() -> Option<PathBuf> {
use std::os::windows::process::CommandExt;
use std::process::Command;

let powershell = PathBuf::from(std::env::var_os("WINDIR")?)
.join("System32/WindowsPowerShell/v1.0/powershell.exe");
Expand Down
1 change: 1 addition & 0 deletions rust/src/codex_sessions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ fn push_unique_path(dirs: &mut Vec<PathBuf>, seen: &mut HashSet<String>, path: P
mod tests {
use super::*;

#[cfg(windows)]
#[test]
fn normalizes_codex_root_to_sessions_dir() {
assert_eq!(
Expand Down
12 changes: 10 additions & 2 deletions rust/src/core/hooks/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ fn config_matching_respects_enabled_flag() {
events: vec![],
provider: None,
threshold: None,
executable: PathBuf::from("C:\\Windows\\System32\\cmd.exe"),
executable: absolute_executable("cmd.exe"),
arguments: vec![],
timeout_secs: 5,
};
Expand Down Expand Up @@ -204,14 +204,22 @@ fn rate_limiter_key_is_stable() {
let _ = Arc::new(a);
}

fn absolute_executable(name: &str) -> PathBuf {
if cfg!(windows) {
PathBuf::from(r"C:\Tools").join(name)
} else {
PathBuf::from("/usr/local/bin").join(name)
}
}

fn rule_with(arguments: usize) -> HookRule {
HookRule {
enabled: true,
event: Some(HookEventType::QuotaReached),
events: Vec::new(),
provider: None,
threshold: None,
executable: PathBuf::from(r"C:\Tools\notify.exe"),
executable: absolute_executable("notify.exe"),
arguments: (0..arguments).map(|i| format!("--arg{i}")).collect(),
timeout_secs: 10,
}
Expand Down
1 change: 1 addition & 0 deletions rust/src/core/timezone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
//! proceed, so no thread can reach `iana_time_zone` while pinning is still
//! in progress.

#[cfg(windows)]
use std::sync::LazyLock;

/// Zone used when the OS timezone cannot be read safely.
Expand Down
1 change: 1 addition & 0 deletions rust/src/providers/codex/reset_observations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ mod tests {
));
}

#[cfg(windows)]
#[test]
fn persisted_file_is_secure_wrapped() {
let root = temp_root("secure");
Expand Down
1 change: 1 addition & 0 deletions rust/src/providers/jetbrains/ide.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ mod tests {
assert!(log_path_for(&traversal, &roots).is_none());
}

#[cfg(windows)]
#[test]
fn log_path_match_ignores_trailing_separator_and_case() {
let dir = tempfile::tempdir().expect("tempdir");
Expand Down
15 changes: 15 additions & 0 deletions rust/src/providers/muse/local_usage/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pub(crate) fn file_stamp(path: &Path) -> Option<FileStamp> {
.as_millis(),
})
}
#[cfg(windows)]
pub(crate) fn platform_file_identity(path: &Path, _metadata: &fs::Metadata) -> Option<String> {
use std::os::windows::io::AsRawHandle;

Expand All @@ -56,6 +57,20 @@ pub(crate) fn platform_file_identity(path: &Path, _metadata: &fs::Metadata) -> O
let file_index = ((info.nFileIndexHigh as u64) << 32) | info.nFileIndexLow as u64;
Some(format!("{}:{file_index}", info.dwVolumeSerialNumber))
}
#[cfg(unix)]
pub(crate) fn platform_file_identity(_path: &Path, metadata: &fs::Metadata) -> Option<String> {
use std::os::unix::fs::MetadataExt;

Some(format!("{}:{}", metadata.dev(), metadata.ino()))
}
#[cfg(not(any(unix, windows)))]
pub(crate) fn platform_file_identity(_path: &Path, metadata: &fs::Metadata) -> Option<String> {
metadata
.created()
.ok()
.and_then(|value| value.duration_since(UNIX_EPOCH).ok())
.map(|value| value.as_nanos().to_string())
}
pub(crate) fn digest_bytes(
path: &Path,
stamp: &FileStamp,
Expand Down
17 changes: 0 additions & 17 deletions rust/src/providers/muse/local_usage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,23 +165,6 @@ fn day_window(days: u32) -> (String, String) {
)
}

#[cfg(windows)]
#[cfg(unix)]
fn platform_file_identity(_path: &Path, metadata: &fs::Metadata) -> Option<String> {
use std::os::unix::fs::MetadataExt;

Some(format!("{}:{}", metadata.dev(), metadata.ino()))
}

#[cfg(not(any(unix, windows)))]
fn platform_file_identity(_path: &Path, metadata: &fs::Metadata) -> Option<String> {
metadata
.created()
.ok()
.and_then(|value| value.duration_since(UNIX_EPOCH).ok())
.map(|value| value.as_nanos().to_string())
}

fn discover(root: &Path, state: &mut ScanState) -> (Vec<PathBuf>, bool) {
let mut files = Vec::new();
let mut complete = true;
Expand Down