diff --git a/src/cortex-cli/src/debug_cmd/handlers/snapshot.rs b/src/cortex-cli/src/debug_cmd/handlers/snapshot.rs index 1fece90d2..a486393b6 100644 --- a/src/cortex-cli/src/debug_cmd/handlers/snapshot.rs +++ b/src/cortex-cli/src/debug_cmd/handlers/snapshot.rs @@ -7,7 +7,7 @@ use cortex_engine::rollout::get_rollout_path; use cortex_protocol::ConversationId; use crate::debug_cmd::commands::SnapshotArgs; -use crate::debug_cmd::types::{SnapshotDebugOutput, SnapshotInfo}; +use crate::debug_cmd::types::{SnapshotDebugOutput, SnapshotDiffInfo, SnapshotInfo}; use crate::debug_cmd::utils::{format_size, get_cortex_home}; /// Run the snapshot debug command. @@ -196,6 +196,10 @@ pub async fn run_snapshot(args: SnapshotArgs) -> Result<()> { snapshot_count, session_snapshots, total_size_bytes, + diff: args.diff.then(|| SnapshotDiffInfo { + status: "not_implemented".to_string(), + message: "Snapshot diff not yet implemented".to_string(), + }), }; if args.json { diff --git a/src/cortex-cli/src/debug_cmd/types.rs b/src/cortex-cli/src/debug_cmd/types.rs index c9aa495d1..db0eddcce 100644 --- a/src/cortex-cli/src/debug_cmd/types.rs +++ b/src/cortex-cli/src/debug_cmd/types.rs @@ -215,6 +215,8 @@ pub struct SnapshotDebugOutput { #[serde(skip_serializing_if = "Option::is_none")] pub session_snapshots: Option>, pub total_size_bytes: u64, + #[serde(skip_serializing_if = "Option::is_none")] + pub diff: Option, } /// Snapshot info. @@ -225,6 +227,13 @@ pub struct SnapshotInfo { pub size_bytes: u64, } +/// Snapshot diff status. +#[derive(Debug, Serialize)] +pub struct SnapshotDiffInfo { + pub status: String, + pub message: String, +} + // ============================================================================= // Paths types // ============================================================================= diff --git a/src/cortex-cli/tests/debug_snapshot_json_diff.rs b/src/cortex-cli/tests/debug_snapshot_json_diff.rs new file mode 100644 index 000000000..86f077cc5 --- /dev/null +++ b/src/cortex-cli/tests/debug_snapshot_json_diff.rs @@ -0,0 +1,28 @@ +use std::process::Command; + +#[test] +fn debug_snapshot_json_includes_diff_when_requested() { + let output = Command::new(env!("CARGO_BIN_EXE_Cortex")) + .args(["debug", "snapshot", "--json", "--diff"]) + .env("NO_COLOR", "1") + .output() + .expect("run Cortex debug snapshot"); + + let stdout = String::from_utf8_lossy(&output.stdout); + let stderr = String::from_utf8_lossy(&output.stderr); + + assert!( + output.status.success(), + "debug snapshot failed\nstdout:\n{stdout}\nstderr:\n{stderr}" + ); + + let json: serde_json::Value = + serde_json::from_str(&stdout).expect("debug snapshot output should be JSON"); + assert_eq!(json["diff"]["status"], "not_implemented"); + assert!( + json["diff"]["message"] + .as_str() + .is_some_and(|message| message.contains("not yet implemented")), + "diff message should explain snapshot diff status\nstdout:\n{stdout}" + ); +}