refactor(session): 移除 InboundMessage.dialog_id,dialog_id 完全由 SessionManager 管理
Channel 消息不再携带 dialog_id,完全由 SessionManager 通过 current_sessions 内部管理。/new 后下一条消息会自动路由到新 session。 改动: - InboundMessage 移除 dialog_id 字段 - handle_message 移除 dialog_id 参数 - Feishu/CLI channel 创建 InboundMessage 时不再设置 dialog_id - 路由逻辑简化为:current_sessions → find_active_session → 创建新 session
This commit is contained in:
parent
e235268133
commit
c48ed83a23
@ -164,7 +164,6 @@ pub struct InboundMessage {
|
||||
pub channel: String,
|
||||
pub sender_id: String,
|
||||
pub chat_id: String,
|
||||
pub dialog_id: Option<String>,
|
||||
pub content: String,
|
||||
pub timestamp: i64,
|
||||
pub media: Vec<MediaItem>,
|
||||
|
||||
@ -117,7 +117,6 @@ impl CliChatChannel {
|
||||
channel: self.name().to_string(),
|
||||
sender_id: "cli".to_string(),
|
||||
chat_id: chat_id.unwrap_or_else(short_id),
|
||||
dialog_id: None,
|
||||
content,
|
||||
timestamp: crate::bus::message::current_timestamp(),
|
||||
media: Vec::new(),
|
||||
|
||||
@ -1110,7 +1110,6 @@ impl FeishuChannel {
|
||||
channel: "feishu".to_string(),
|
||||
sender_id: parsed.open_id.clone(),
|
||||
chat_id: parsed.chat_id.clone(),
|
||||
dialog_id: None, // Use default/current dialog
|
||||
content: parsed.content.clone(),
|
||||
timestamp: crate::bus::message::current_timestamp(),
|
||||
media: parsed.media.map(|m| vec![m]).unwrap_or_default(),
|
||||
|
||||
@ -107,7 +107,6 @@ impl GatewayState {
|
||||
&inbound.channel,
|
||||
&inbound.sender_id,
|
||||
&inbound.chat_id,
|
||||
inbound.dialog_id.as_deref(),
|
||||
&inbound.content,
|
||||
inbound.media,
|
||||
).await {
|
||||
|
||||
@ -1039,15 +1039,11 @@ impl SessionManager {
|
||||
channel: &str,
|
||||
_sender_id: &str,
|
||||
chat_id: &str,
|
||||
dialog_id: Option<&str>,
|
||||
content: &str,
|
||||
media: Vec<crate::bus::MediaItem>,
|
||||
) -> Result<HandleResult, AgentError> {
|
||||
// Determine dialog_id: if not provided, use current session or find active or create new
|
||||
let unified_id = if let Some(did) = dialog_id {
|
||||
UnifiedSessionId::new(channel, chat_id, did)
|
||||
} else {
|
||||
// Check if we have a current session tracked for this channel:chat_id
|
||||
// Channel messages never carry dialog_id — routing is entirely via current_sessions
|
||||
let unified_id = {
|
||||
let chat_scope = format!("{}:{}", channel, chat_id);
|
||||
let current_session_id = {
|
||||
let inner = self.inner.lock().await;
|
||||
@ -1056,8 +1052,8 @@ impl SessionManager {
|
||||
if let Some(current_id) = current_session_id {
|
||||
// Verify current session still exists in Storage
|
||||
match self.storage.get_session(¤t_id).await {
|
||||
Ok(meta) => {
|
||||
// Current session still valid
|
||||
Ok(_) => {
|
||||
// Current session still valid, extract dialog_id
|
||||
let parts: Vec<&str> = current_id.split(':').collect();
|
||||
if parts.len() == 3 {
|
||||
UnifiedSessionId::new(channel, chat_id, parts[2])
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user