重构: 移除调试日志以简化消息处理流程

This commit is contained in:
xiaoxixi 2026-04-26 21:26:27 +08:00
parent cf6d57c568
commit bcee62713f
4 changed files with 12 additions and 43 deletions

View File

@ -25,13 +25,6 @@ impl OutboundDispatcher {
loop {
let msg = self.bus.consume_outbound().await;
#[cfg(debug_assertions)]
tracing::debug!(
channel = %msg.channel,
chat_id = %msg.chat_id,
content_len = msg.content.len(),
"OutboundDispatcher received message"
);
let channel_name = msg.channel.clone();
let channel = self.channel_manager.get_channel(&channel_name).await;

View File

@ -121,12 +121,17 @@ impl CliChatChannel {
let session_id = current_session_guard.clone().unwrap();
// Parse UnifiedSessionId to get chat_id and dialog_id
let (channel_name, chat_id_part, dialog_id_part) = UnifiedSessionId::parse(&session_id)
.map(|sid| (sid.channel, sid.chat_id, Some(sid.dialog_id.clone())))
.unwrap_or_else(|| (self.name().to_string(), session_id.clone(), None));
// Publish to bus for AI processing
let msg = InboundMessage {
channel: self.name().to_string(),
channel: channel_name,
sender_id: "cli".to_string(),
chat_id: session_id.clone(),
dialog_id: None, // Use default/current dialog
chat_id: chat_id_part,
dialog_id: dialog_id_part,
content,
timestamp: crate::bus::message::current_timestamp(),
media: Vec::new(),

View File

@ -72,23 +72,6 @@ impl GatewayState {
tokio::select! {
// Inbound: AI message flow
inbound = bus.consume_inbound() => {
#[cfg(debug_assertions)]
{
tracing::debug!(
channel = %inbound.channel,
chat_id = %inbound.chat_id,
sender = %inbound.sender_id,
content = %inbound.content,
media_count = %inbound.media.len(),
"Processing inbound message"
);
if !inbound.media.is_empty() {
for (i, m) in inbound.media.iter().enumerate() {
tracing::debug!(media_index = i, media_type = %m.media_type, path = %m.path, "Media item");
}
}
}
match session_manager.handle_message(
&inbound.channel,
&inbound.sender_id,

View File

@ -543,21 +543,6 @@ impl SessionManager {
content: &str,
media: Vec<crate::bus::MediaItem>,
) -> Result<String, AgentError> {
#[cfg(debug_assertions)]
{
tracing::debug!(
channel = %channel,
chat_id = %chat_id,
dialog_id = ?dialog_id,
content_len = content.len(),
media_count = %media.len(),
"Routing message to agent"
);
for (i, m) in media.iter().enumerate() {
tracing::debug!(media_index = i, media_type = %m.media_type, path = %m.path, "Media in handle_message");
}
}
// 确定 dialog_id
let dialog_id = dialog_id.unwrap_or(DEFAULT_DIALOG_ID);
@ -585,7 +570,10 @@ impl SessionManager {
let new_session = self.get_or_create_session(&new_unified_id).await?;
(new_session, true)
}
None => (Arc::clone(&session), false),
None => {
drop(session_guard); // Drop before using same session
(Arc::clone(&session), false)
}
};
// 使用选定的 session 进行处理