From 40d34e925e2bec134a77898fb465e7a6d417c55a Mon Sep 17 00:00:00 2001
From: Anthony Ronning <101225832+AnthonyRonning@users.noreply.github.com>
Date: Tue, 8 Sep 2026 08:43:32 +0000
Subject: [PATCH] Fix Agent test portability and revocation timing
---
.../crates/maple-agent/src/acp/mod.rs | 16 +-
.../maple-agent/src/agent/developer_tools.rs | 145 +++++++++++++++---
2 files changed, 135 insertions(+), 26 deletions(-)
diff --git a/apps/maple-agent/crates/maple-agent/src/acp/mod.rs b/apps/maple-agent/crates/maple-agent/src/acp/mod.rs
index 88a57dd82..ba4bba6ae 100644
--- a/apps/maple-agent/crates/maple-agent/src/acp/mod.rs
+++ b/apps/maple-agent/crates/maple-agent/src/acp/mod.rs
@@ -2950,11 +2950,15 @@ mod tests {
#[test]
fn permission_request_without_prompt_previews_the_arguments() {
+ let path = std::env::temp_dir().join("notes.md");
+ assert!(path.is_absolute(), "the approval fixture must be absolute");
+ let path = path.to_string_lossy().into_owned();
+ let title = format!("edit: {path}");
let request = AgentPermissionRequest {
request_id: "request-2".to_string(),
tool_name: "edit".to_string(),
arguments: serde_json::Map::from_iter([
- ("path".to_string(), serde_json::json!("/tmp/notes.md")),
+ ("path".to_string(), serde_json::json!(path)),
(
"edits".to_string(),
serde_json::json!([{ "oldText": "foo", "newText": "bar" }]),
@@ -2966,7 +2970,7 @@ mod tests {
id: "permission-request-2".to_string(),
item_type: "permission".to_string(),
role: Some("system".to_string()),
- title: Some("edit: /tmp/notes.md".to_string()),
+ title: Some(title.clone()),
text: None,
status: Some("pending".to_string()),
input: Some(serde_json::Value::Object(request.arguments.clone())),
@@ -2980,14 +2984,14 @@ mod tests {
acp_permission_options(),
);
let encoded = serde_json::to_value(permission).unwrap();
- assert_eq!(encoded["toolCall"]["title"], "edit: /tmp/notes.md");
+ assert_eq!(encoded["toolCall"]["title"], title);
// Edit approvals render as diffs, the shape ACP clients show inline.
assert_eq!(encoded["toolCall"]["content"][0]["type"], "diff");
- assert_eq!(encoded["toolCall"]["content"][0]["path"], "/tmp/notes.md");
+ assert_eq!(encoded["toolCall"]["content"][0]["path"], path);
assert_eq!(encoded["toolCall"]["content"][0]["oldText"], "foo");
assert_eq!(encoded["toolCall"]["content"][0]["newText"], "bar");
// The card links to the file it approves.
- assert_eq!(encoded["toolCall"]["locations"][0]["path"], "/tmp/notes.md");
+ assert_eq!(encoded["toolCall"]["locations"][0]["path"], path);
// One approval card must not flood the caller with a huge edit.
let long = "x".repeat(20_000);
@@ -2995,7 +2999,7 @@ mod tests {
request_id: "request-3".to_string(),
tool_name: "edit".to_string(),
arguments: serde_json::Map::from_iter([
- ("path".to_string(), serde_json::json!("/tmp/notes.md")),
+ ("path".to_string(), serde_json::json!(path)),
(
"edits".to_string(),
serde_json::json!([{ "newText": long }]),
diff --git a/apps/maple-agent/crates/maple-agent/src/agent/developer_tools.rs b/apps/maple-agent/crates/maple-agent/src/agent/developer_tools.rs
index 0869f0ec2..838f48fe8 100644
--- a/apps/maple-agent/crates/maple-agent/src/agent/developer_tools.rs
+++ b/apps/maple-agent/crates/maple-agent/src/agent/developer_tools.rs
@@ -1072,6 +1072,9 @@ async fn execute_bounded_shell(
let _ = terminate_shell_process(&mut child).await;
}
+ #[cfg(all(test, unix))]
+ tests::pause_before_shell_output_drain(exit_code).await;
+
let drain_timeout = tokio::time::sleep(SHELL_OUTPUT_DRAIN_TIMEOUT);
tokio::pin!(drain_timeout);
let capture_result = tokio::select! {
@@ -2562,6 +2565,27 @@ mod tests {
static NEXT_TEST_DIR: AtomicU64 = AtomicU64::new(1);
+ #[cfg(unix)]
+ struct ShellOutputDrainHook {
+ parent_exited: tokio::sync::oneshot::Sender