story-kit: merge 146_bug_permission_approval_still_returns_wrong_format_needs_updatedinput_not_behavior_allow

This commit is contained in:
Dave
2026-02-24 14:06:00 +00:00
parent 5a31d457f7
commit 57430d73bd

View File

@@ -1617,6 +1617,7 @@ async fn tool_prompt_permission(args: &Value, ctx: &AppContext) -> Result<String
let request_id = uuid::Uuid::new_v4().to_string(); let request_id = uuid::Uuid::new_v4().to_string();
let (response_tx, response_rx) = tokio::sync::oneshot::channel(); let (response_tx, response_rx) = tokio::sync::oneshot::channel();
let tool_input_copy = tool_input.clone();
ctx.perm_tx ctx.perm_tx
.send(crate::http::context::PermissionForward { .send(crate::http::context::PermissionForward {
request_id: request_id.clone(), request_id: request_id.clone(),
@@ -1639,7 +1640,7 @@ async fn tool_prompt_permission(args: &Value, ctx: &AppContext) -> Result<String
.map_err(|_| "Permission response channel closed unexpectedly".to_string())?; .map_err(|_| "Permission response channel closed unexpectedly".to_string())?;
if approved { if approved {
Ok(json!({"behavior": "allow"}).to_string()) Ok(json!({"updatedInput": tool_input_copy}).to_string())
} else { } else {
slog_warn!("[permission] User denied permission for '{tool_name}'"); slog_warn!("[permission] User denied permission for '{tool_name}'");
Ok(json!({ Ok(json!({
@@ -3052,7 +3053,7 @@ mod tests {
} }
#[tokio::test] #[tokio::test]
async fn tool_prompt_permission_approved_returns_allow_json() { async fn tool_prompt_permission_approved_returns_updated_input_json() {
let tmp = tempfile::tempdir().unwrap(); let tmp = tempfile::tempdir().unwrap();
let ctx = test_ctx(tmp.path()); let ctx = test_ctx(tmp.path());
@@ -3073,7 +3074,10 @@ mod tests {
.expect("should succeed on approval"); .expect("should succeed on approval");
let parsed: Value = serde_json::from_str(&result).expect("result should be valid JSON"); let parsed: Value = serde_json::from_str(&result).expect("result should be valid JSON");
assert_eq!(parsed["behavior"], "allow", "approved must return behavior:allow"); assert_eq!(
parsed["updatedInput"]["command"], "echo hello",
"approved must return updatedInput with original tool input"
);
} }
#[tokio::test] #[tokio::test]