fix: 3 项问题

1. 审批DB更新精确匹配 — code_hash 从 removed entry 提取
2. delete memo 提取 id — prompt 中数字 → id 参数
3. 清理未使用的 current_user_id 全局变量
This commit is contained in:
2026-06-02 15:44:28 +08:00
parent fe83687495
commit 6708fe33a0
3 changed files with 12 additions and 16 deletions
+1 -9
View File
@@ -208,9 +208,6 @@ async fn cmd_listen(
database.as_ref().map(|db| Arc::new(db.pool().clone()))
));
// 共享的当前用户 ID(用于审批消息)
let current_user_id = Arc::new(tokio::sync::Mutex::new(String::new()));
let conversation = if enable_llm {
let sys_prompt = std::env::var("WEIXIN_LLM_SYSTEM_PROMPT")
.unwrap_or_else(|_| DEFAULT_SYSTEM_PROMPT.to_string());
@@ -326,14 +323,12 @@ async fn cmd_listen(
})
};
let executor_user_id = current_user_id.clone();
let executor: ToolExecutor = Arc::new(move |name: &str, args_json: &str| {
let reg = registry_opt.clone();
let approval = approval.clone();
let send = send_wechat.clone();
let session = session.clone();
let memory_store = memory_store.clone();
let current_user = executor_user_id.clone();
let n = name.to_string();
let args = args_json.to_string();
@@ -447,8 +442,6 @@ async fn cmd_listen(
let shutdown = async { tokio::signal::ctrl_c().await.expect("Ctrl+C 失败") };
let listen_user_id = current_user_id.clone();
tokio::select! {
_ = shutdown => {
info!("收到退出信号,注销监听器...");
@@ -456,7 +449,7 @@ async fn cmd_listen(
file_state.save_runtime(&client.get_updates_buf().await);
info!("已退出");
}
_ = listen_loop(&client, enable_llm, echo, &account_id, database, file_state, conversation, &approval_manager, listen_user_id, memory_store) => {}
_ = listen_loop(&client, enable_llm, echo, &account_id, database, file_state, conversation, &approval_manager, memory_store) => {}
}
}
@@ -469,7 +462,6 @@ async fn listen_loop(
file_state: &state::StateManager,
conversation: Option<Arc<Conversation>>,
approval_manager: &ApprovalManager,
current_user_id: Arc<tokio::sync::Mutex<String>>,
memory_store: &Arc<MemoryStore>,
) {
let last_user_id = Arc::new(tokio::sync::Mutex::new(String::new()));