From ec4fcc094ad3502bf2d00d599a5ca7dde8f1d3aa Mon Sep 17 00:00:00 2001 From: "Rodrigo Rodriguez (Pragmatismo)" Date: Wed, 18 Mar 2026 10:39:27 -0300 Subject: [PATCH] Fix: Use bot_id instead of user_id in suggestion Redis keys - Changed all suggestion key formats from suggestions:user_id:session_id to suggestions:bot_id:session_id - Fixes bug where suggestions were stored under wrong key, preventing frontend from retrieving them - Affects: CLEAR SUGGESTIONS, ADD SUGGESTION, ADD SUGGESTION TEXT, ADD_SUGGESTION_TOOL - Impact: Suggestions now correctly associated with bot, not user --- src/basic/keywords/add_suggestion.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/basic/keywords/add_suggestion.rs b/src/basic/keywords/add_suggestion.rs index 0ffa3f8d..1ec58bc5 100644 --- a/src/basic/keywords/add_suggestion.rs +++ b/src/basic/keywords/add_suggestion.rs @@ -25,7 +25,7 @@ pub fn clear_suggestions_keyword( engine .register_custom_syntax(["CLEAR", "SUGGESTIONS"], true, move |_context, _inputs| { if let Some(cache_client) = &cache { - let redis_key = format!("suggestions:{}:{}", user_session.user_id, user_session.id); + let redis_key = format!("suggestions:{}:{}", user_session.bot_id, user_session.id); let mut conn: redis::Connection = match cache_client.get_connection() { Ok(conn) => conn, Err(e) => { @@ -200,7 +200,7 @@ fn add_context_suggestion( button_text: &str, ) -> Result<(), Box> { if let Some(cache_client) = cache { - let redis_key = format!("suggestions:{}:{}", user_session.user_id, user_session.id); + let redis_key = format!("suggestions:{}:{}", user_session.bot_id, user_session.id); let suggestion = json!({ "type": "context", @@ -236,7 +236,7 @@ fn add_context_suggestion( let active_key = format!( "active_context:{}:{}", - user_session.user_id, user_session.id + user_session.bot_id, user_session.id ); let _: Result = redis::cmd("HSET") @@ -261,7 +261,7 @@ fn add_text_suggestion( button_text: &str, ) -> Result<(), Box> { if let Some(cache_client) = cache { - let redis_key = format!("suggestions:{}:{}", user_session.user_id, user_session.id); + let redis_key = format!("suggestions:{}:{}", user_session.bot_id, user_session.id); let suggestion = json!({ "type": "text_value", @@ -316,7 +316,7 @@ fn add_tool_suggestion( tool_name, button_text ); if let Some(cache_client) = cache { - let redis_key = format!("suggestions:{}:{}", user_session.user_id, user_session.id); + let redis_key = format!("suggestions:{}:{}", user_session.bot_id, user_session.id); info!("Adding suggestion to Redis key: {}", redis_key); // Create action object and serialize it to JSON string