From 373ac3d07056574c1997b9fd17932c3d2101ca7b Mon Sep 17 00:00:00 2001 From: chillerno1 Date: Fri, 24 Jul 2026 21:43:20 +1000 Subject: [PATCH] fix(desktop): address workflow deletions at the workflow's actual owner MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit delete_workflow built the NIP-09 a-tag coordinate with the caller's pubkey, but kind:30620 is addressable by (author, d-tag). For an agent-created workflow the coordinate named a record that doesn't exist — the relay accepted the kind:5 and deleted nothing while the UI reported success. Fetch the workflow's kind:30620 event first (the same #d query update_workflow already uses) and build the coordinate from the event's author. Deleting an unknown workflow id now surfaces "workflow not found" instead of silently publishing an unmatchable delete. Client half of the end-to-end fix; the relay half (execute a-tag deletions against the a-tag owner rather than the signer) is #2242. Co-Authored-By: Claude Fable 5 Signed-off-by: chillerno1 --- desktop/src-tauri/src/commands/workflows.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/desktop/src-tauri/src/commands/workflows.rs b/desktop/src-tauri/src/commands/workflows.rs index 1d5f309fb5..9daa937ef4 100644 --- a/desktop/src-tauri/src/commands/workflows.rs +++ b/desktop/src-tauri/src/commands/workflows.rs @@ -233,7 +233,26 @@ pub async fn delete_workflow( workflow_id: String, state: State<'_, AppState>, ) -> Result<(), String> { - let builder = events::build_workflow_delete(&workflow_id, ¤t_pubkey_hex(&state)?)?; + // The NIP-09 `a` coordinate must name the workflow's actual author, not + // the caller: kind:30620 is addressable by (author, d-tag), and workflows + // are commonly agent-created. Addressing the delete at the caller's own + // pubkey targets a record that doesn't exist — the relay accepts the + // kind:5 and deletes nothing. + let prior = query_relay( + &state, + &[serde_json::json!({ + "kinds": [30620], + "#d": [workflow_id.clone()], + "limit": 1 + })], + ) + .await?; + let owner_pubkey = prior + .first() + .map(|ev| ev.pubkey.to_hex()) + .ok_or_else(|| "workflow not found".to_string())?; + + let builder = events::build_workflow_delete(&workflow_id, &owner_pubkey)?; submit_event(builder, &state).await?; Ok(()) }