diff --git a/desktop/scripts/check-file-sizes.mjs b/desktop/scripts/check-file-sizes.mjs index 0595adfc78..eb7d3fbfb4 100644 --- a/desktop/scripts/check-file-sizes.mjs +++ b/desktop/scripts/check-file-sizes.mjs @@ -50,7 +50,7 @@ const overrides = new Map([ ["src-tauri/src/migration.rs", 1010], // worktree shared-agent-data symlink sync (SHARED_AGENT_FILES + SHARED_AGENT_DIRS symlink-to-canonical + sibling pack migration) + mcp_command provider reconciliation + persona_pack_path reconciliation + tests ["src-tauri/src/commands/media.rs", 730], // ffmpeg video transcode + poster frame extraction + run_ffmpeg_with_timeout (find_ffmpeg via resolve_command, is_video_file, transcode_to_mp4, extract_poster_frame, transcode_and_extract_poster) + spawn_blocking wrappers + tests ["src-tauri/src/commands/agents.rs", 881], // remote agent lifecycle routing (local + provider branches) + scope enforcement + persona pack metadata wiring + mcp_toolsets field + NIP-OA auth_tag in deploy payload - ["src-tauri/src/commands/messages.rs", 700], // + NIP-17 encrypted send routing (encrypted_recipients + send_encrypted_message gift-wraps to all members for serverless DMs/private channels) // + encrypted threaded replies (in-rumor NIP-10 thread tags, no plaintext leak) // feed multi-query + NIP-50 search + forum thread resolution + thread ref + reactions via REQ + edit_message media_tags param (Slack-style attachment-editable edits) + ["src-tauri/src/commands/messages.rs", 720], // + NIP-17 encrypted send routing (encrypted_recipients picks NEWEST 39002 across relays + fails loudly if no other members resolve, no silent self-only encrypt) // + encrypted threaded replies (in-rumor NIP-10 thread tags, no plaintext leak) // feed multi-query + NIP-50 search + forum thread resolution + thread ref + reactions via REQ + edit_message media_tags param (Slack-style attachment-editable edits) ["src-tauri/src/nostr_convert.rs", 1150], // 12 Nostr event→model converters (channels, profiles, members, notes, search, agents, relay members) + rank_user_search_results helper for NIP-50 user search + 33 unit tests ["src-tauri/src/managed_agents/runtime.rs", 1320], // + SPROUT_SERVERLESS env passthrough to ACP subprocess (serverless mode) // ... + respond-to gate env (SPROUT_ACP_RESPOND_TO[_ALLOWLIST]) + per-mode env builder + tests + persona/agent env_vars spawn merge (helper + tests now in env_vars.rs) + system-wide orphan sweep (proc_listallpids/proc on macOS, /proc on Linux) + SPROUT_MANAGED_AGENT env marker check (KERN_PROCARGS2 on macOS, /proc/environ on Linux) ["src-tauri/src/managed_agents/discovery.rs", 680], // KNOWN_ACP_PROVIDERS catalog + resolve_command cache + login_shell_path + classify_provider (four-state: Available/AdapterMissing/CliMissing/NotInstalled) + discover_acp_providers with dynamic install_hint + known_acp_provider/known_acp_provider_exact + normalize_agent_args + 15 unit tests diff --git a/desktop/src-tauri/src/commands/messages.rs b/desktop/src-tauri/src/commands/messages.rs index aa8a5ab613..35e6c078b4 100644 --- a/desktop/src-tauri/src/commands/messages.rs +++ b/desktop/src-tauri/src/commands/messages.rs @@ -46,15 +46,21 @@ async fn encrypted_recipients( return Ok(None); } - // Members come from the kind:39002 list; always include ourselves so we can - // read back our own sent messages. + // Members come from the kind:39002 list. 39002 is ADDRESSABLE: different + // relays may hold different versions (and a multi-relay merge returns them + // all), so pick the NEWEST by created_at — never an arbitrary `.first()`, + // which could be a stale/empty copy and silently drop real members. + // (No `limit:1`: we want every relay's copy so the merge can pick the + // latest; capping at 1 per relay is fine but selection must be by recency.) let member_events = query_relay( state, - &[serde_json::json!({"kinds":[39002],"#d":[channel_id],"limit":1})], + &[serde_json::json!({"kinds":[39002],"#d":[channel_id]})], ) .await?; - let mut members: Vec = member_events - .first() + let newest = member_events + .iter() + .max_by_key(|ev| ev.created_at.as_secs()); + let mut members: Vec = newest .map(|ev| { ev.tags .iter() @@ -74,6 +80,21 @@ async fn encrypted_recipients( let keys = state.keys.lock().map_err(|e| e.to_string())?; keys.public_key().to_hex() }; + + // Fail LOUDLY rather than silently encrypting to only ourselves. An + // encrypted channel with no other members means the 39002 lookup came back + // empty (relay hiccup / propagation lag) — encrypting to just `me` would + // make the message undeliverable to everyone else (e.g. the agent) with no + // visible error. Surface it so the caller can retry instead of dropping it. + let others: Vec<&String> = members.iter().filter(|p| *p != &me).collect(); + if others.is_empty() { + return Err(format!( + "could not resolve members for encrypted channel {channel_id} \ + (kind:39002 lookup returned no other participants — relay may be \ + lagging; try again)" + )); + } + if !members.contains(&me) { members.push(me); }