重构: 移除调试日志以简化消息处理流程
This commit is contained in:
parent
cf6d57c568
commit
bcee62713f
@ -25,13 +25,6 @@ impl OutboundDispatcher {
|
|||||||
|
|
||||||
loop {
|
loop {
|
||||||
let msg = self.bus.consume_outbound().await;
|
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_name = msg.channel.clone();
|
||||||
let channel = self.channel_manager.get_channel(&channel_name).await;
|
let channel = self.channel_manager.get_channel(&channel_name).await;
|
||||||
|
|||||||
@ -121,12 +121,17 @@ impl CliChatChannel {
|
|||||||
|
|
||||||
let session_id = current_session_guard.clone().unwrap();
|
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
|
// Publish to bus for AI processing
|
||||||
let msg = InboundMessage {
|
let msg = InboundMessage {
|
||||||
channel: self.name().to_string(),
|
channel: channel_name,
|
||||||
sender_id: "cli".to_string(),
|
sender_id: "cli".to_string(),
|
||||||
chat_id: session_id.clone(),
|
chat_id: chat_id_part,
|
||||||
dialog_id: None, // Use default/current dialog
|
dialog_id: dialog_id_part,
|
||||||
content,
|
content,
|
||||||
timestamp: crate::bus::message::current_timestamp(),
|
timestamp: crate::bus::message::current_timestamp(),
|
||||||
media: Vec::new(),
|
media: Vec::new(),
|
||||||
|
|||||||
@ -72,23 +72,6 @@ impl GatewayState {
|
|||||||
tokio::select! {
|
tokio::select! {
|
||||||
// Inbound: AI message flow
|
// Inbound: AI message flow
|
||||||
inbound = bus.consume_inbound() => {
|
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(
|
match session_manager.handle_message(
|
||||||
&inbound.channel,
|
&inbound.channel,
|
||||||
&inbound.sender_id,
|
&inbound.sender_id,
|
||||||
|
|||||||
@ -543,21 +543,6 @@ impl SessionManager {
|
|||||||
content: &str,
|
content: &str,
|
||||||
media: Vec<crate::bus::MediaItem>,
|
media: Vec<crate::bus::MediaItem>,
|
||||||
) -> Result<String, AgentError> {
|
) -> 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
|
// 确定 dialog_id
|
||||||
let dialog_id = dialog_id.unwrap_or(DEFAULT_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?;
|
let new_session = self.get_or_create_session(&new_unified_id).await?;
|
||||||
(new_session, true)
|
(new_session, true)
|
||||||
}
|
}
|
||||||
None => (Arc::clone(&session), false),
|
None => {
|
||||||
|
drop(session_guard); // Drop before using same session
|
||||||
|
(Arc::clone(&session), false)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 使用选定的 session 进行处理
|
// 使用选定的 session 进行处理
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user