diff options
Diffstat (limited to 'crates/phone-opus')
| -rw-r--r-- | crates/phone-opus/src/mcp/service.rs | 10 | ||||
| -rw-r--r-- | crates/phone-opus/tests/mcp_hardening.rs | 2 |
2 files changed, 9 insertions, 3 deletions
diff --git a/crates/phone-opus/src/mcp/service.rs b/crates/phone-opus/src/mcp/service.rs index 2baa744..ff25433 100644 --- a/crates/phone-opus/src/mcp/service.rs +++ b/crates/phone-opus/src/mcp/service.rs @@ -691,14 +691,18 @@ impl ClaudeSandbox { struct PersistedConsultPath(PathBuf); impl PersistedConsultPath { - fn new(request: &ConsultRequest) -> io::Result<Self> { + fn new(request: &ConsultRequest, session_id: Option<&str>) -> io::Result<Self> { fs::create_dir_all(CONSULT_OUTPUT_ROOT)?; let timestamp = OffsetDateTime::now_utc() .format(CONSULT_TIMESTAMP_FORMAT) .map_err(|error| io::Error::other(error.to_string()))?; let slug = consult_slug(request.prompt.as_str()); + let session_slug = session_id.map_or_else( + || "session-none".to_owned(), + |session_id| format!("session-{}", consult_slug(session_id)), + ); Ok(Self(Path::new(CONSULT_OUTPUT_ROOT).join(format!( - "{timestamp}-{slug}-{}.json", + "{timestamp}-{slug}-{session_slug}-{}.json", Uuid::new_v4() )))) } @@ -1270,7 +1274,7 @@ fn persist_consult_output( result: &str, envelope: &ClaudeJsonEnvelope, ) -> io::Result<PersistedConsultPath> { - let path = PersistedConsultPath::new(request)?; + let path = PersistedConsultPath::new(request, envelope.session_id.as_deref())?; let saved_at = OffsetDateTime::now_utc() .format(&Rfc3339) .map_err(|error| io::Error::other(error.to_string()))?; diff --git a/crates/phone-opus/tests/mcp_hardening.rs b/crates/phone-opus/tests/mcp_hardening.rs index f7ce125..f4a8a89 100644 --- a/crates/phone-opus/tests/mcp_hardening.rs +++ b/crates/phone-opus/tests/mcp_hardening.rs @@ -417,6 +417,7 @@ fn consult_can_resume_a_prior_session_with_read_only_toolset_and_requested_worki "persisted output path", )?; assert!(persisted_output_path.starts_with("/tmp/phone_opus-consults/")); + assert!(persisted_output_path.contains(resumed_session)); let persisted_output = must( fs::read_to_string(&persisted_output_path), "read persisted consult output", @@ -644,6 +645,7 @@ fn consult_can_run_in_background_and_be_polled() -> TestResult { "background persisted output path", )?; assert!(persisted_output_path.starts_with("/tmp/phone_opus-consults/")); + assert!(persisted_output_path.contains("3fc69f58-7752-4d9d-a95d-19a217814b6a")); let persisted_output = must( fs::read_to_string(&persisted_output_path), "read background persisted consult output", |