From 2645c18145d9c55edd89a33ef8768137a4a9699c Mon Sep 17 00:00:00 2001 From: NessZerra <90105158+Finesssee@users.noreply.github.com> Date: Sun, 20 Sep 2026 03:35:11 +0700 Subject: [PATCH] Preserve Claude usage probe settings --- rust/src/providers/claude/mod.rs | 34 ++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/rust/src/providers/claude/mod.rs b/rust/src/providers/claude/mod.rs index 75dc76ecd7..71cd2a8bd2 100755 --- a/rust/src/providers/claude/mod.rs +++ b/rust/src/providers/claude/mod.rs @@ -220,17 +220,28 @@ fn cleanup_probe_session_jsonl(probe_dir: &std::path::Path) { } } +/// Arguments shared by every Claude CLI `/usage` probe. +/// +/// The remote-control startup hook can otherwise change the interactive +/// session before the usage command is collected. Keep this override in one +/// helper so future CLI probe paths cannot silently omit it. +fn claude_usage_settings_args() -> [String; 2] { + [ + "--settings".to_string(), + r#"{"remoteControlAtStartup":false}"#.to_string(), + ] +} + fn claude_probe_launch_args(session_id: &str) -> Vec { - vec![ + let mut args = vec![ "--setting-sources".to_string(), "user".to_string(), "--allowed-tools".to_string(), String::new(), - "--settings".to_string(), - r#"{"remoteControlAtStartup":false}"#.to_string(), - "--session-id".to_string(), - session_id.to_string(), - ] + ]; + args.extend(claude_usage_settings_args()); + args.extend(["--session-id".to_string(), session_id.to_string()]); + args } struct ClaudePtyProbeOptions { @@ -1204,6 +1215,17 @@ mod tests { ); } + #[test] + fn usage_probe_settings_disable_remote_control_startup() { + assert_eq!( + claude_usage_settings_args(), + [ + "--settings".to_string(), + r#"{"remoteControlAtStartup":false}"#.to_string(), + ] + ); + } + #[test] fn probe_session_jsonl_cleanup_removes_transcript_files() { let dir = tempfile::tempdir().unwrap();