From 5e36ca7afe72127f8ddf349312541b121e0556f4 Mon Sep 17 00:00:00 2001 From: Developer Date: Sat, 18 Jul 2026 03:29:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=80=9A=E7=9F=A5=E9=A1=B5=E8=84=9A?= =?UTF-8?q?=E7=94=A8=E9=A1=B9=E7=9B=AE=E7=9B=AE=E5=BD=95=E5=90=8D=E6=9B=BF?= =?UTF-8?q?=E4=BB=A3UUID=E4=BC=9A=E8=AF=9D=E6=A0=87=E8=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 微信/Telegram 通知底部原本显示 UUID 会话标识,改为显示项目目录名(如 tank-battle), 同时把标签从会话改为项目。 修改文件: - lucarne-wechat: render_agent_message + render_wechat_new_session - lucarne-telegram: render_agent_notification + final_footer Closes #43 --- crates/lucarne-telegram/src/bot.rs | 24 ++++++++++++++++-------- crates/lucarne-wechat/src/service.rs | 17 ++++++++++++++--- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/crates/lucarne-telegram/src/bot.rs b/crates/lucarne-telegram/src/bot.rs index 0ddba2d..9264c2b 100644 --- a/crates/lucarne-telegram/src/bot.rs +++ b/crates/lucarne-telegram/src/bot.rs @@ -1739,11 +1739,12 @@ impl Bot { } let mut live = session.live.clone().expect("bound above"); let final_footer = include_agent_footer.then(|| { - let session_ref = self - .state - .active_provider_session_ref(&session.workspace) - .ok() - .or_else(|| session.resume_ref.clone()) + // Use project directory basename instead of UUID session ref + let session_label = session + .project_path + .as_ref() + .and_then(|p| p.file_name()) + .map(|n| n.to_string_lossy().to_string()) .unwrap_or_else(|| "-".to_string()); let cwd = session .project_path @@ -1752,7 +1753,7 @@ impl Bot { .unwrap_or_else(|| "-".to_string()); AgentMessageFooter { cost: None, - session: Some(session_ref), + session: Some(session_label), cwd: Some(cwd), } }); @@ -5107,7 +5108,14 @@ fn render_agent_notification( session_ref: Option<&str>, text: &str, ) -> OutgoingMessage { - let session_ref = session_ref.unwrap_or("-"); + // Use project directory basename (e.g. "tank-battle") instead of UUID session ref + let session_label = session + .project_path + .as_ref() + .and_then(|p| p.file_name()) + .map(|n| n.to_string_lossy().to_string()) + .or_else(|| session_ref.map(|s| s.to_string())) + .unwrap_or_else(|| "-".to_string()); let cwd = session .project_path .as_ref() @@ -5118,7 +5126,7 @@ fn render_agent_notification( text.as_ref(), &AgentMessageFooter { cost: None, - session: Some(session_ref.to_string()), + session: Some(session_label), cwd: Some(cwd), }, ); diff --git a/crates/lucarne-wechat/src/service.rs b/crates/lucarne-wechat/src/service.rs index 1452d20..768425e 100644 --- a/crates/lucarne-wechat/src/service.rs +++ b/crates/lucarne-wechat/src/service.rs @@ -2833,7 +2833,13 @@ fn render_agent_message( if let Some(cost) = cost.as_deref().or(extracted_cost) { footer_lines.push(format!("耗时:{cost}")); } - footer_lines.push(format!("会话:{session_ref}")); + // Use project directory basename (e.g. "tank-battle") instead of UUID + let workspace_name = workspace + .project_path + .file_name() + .map(|n| n.to_string_lossy().to_string()) + .unwrap_or_else(|| session_ref.to_string()); + footer_lines.push(format!("项目:{workspace_name}")); footer_lines.push(format!( "目录:{}", compact_path(&workspace.project_path.display().to_string(), 58) @@ -3614,11 +3620,16 @@ fn render_wechat_new_usage() -> &'static str { fn render_wechat_new_session( provider_id: &str, - session_ref: &str, + _session_ref: &str, workspace: &WorkspaceBinding, ) -> String { + let workspace_name = workspace + .project_path + .file_name() + .map(|n| n.to_string_lossy().to_string()) + .unwrap_or_else(|| _session_ref.to_string()); format!( - "🆕 新的 {provider_id} 会话\n目录:`{}`\n会话:`{session_ref}`\n\n回复此消息即可开始。", + "🆕 新的 {provider_id} 会话\n目录:`{}`\n项目:{workspace_name}\n\n回复此消息即可开始。", workspace.project_path.display() ) }