新增: 执行中轨迹卡展开与占用期消息必达
- 执行中 step 卡支持点击展开(复用轨迹展开态, 实时过程工具卡回看) - 占用期消息改落待发箱自动续投, 不再拒绝让用户重发(959) - 待发项派发后完成结果回推来源飞书会话(35min 弃守) - 961 轮次语义/960 聚合防抖设计要点登记
This commit is contained in:
@@ -242,6 +242,9 @@ async fn dispatch_claimed(
|
||||
emit(app, "ai-outbox-sent", &item.id, &conv, None, None);
|
||||
emit(app, "ai-outbox-changed", &item.id, &conv, None, None);
|
||||
tracing::info!("[outbox] 派发 {} → 会话 {conv}", item.id);
|
||||
// 959 结果回推:待发项派发后完成结果推回来源渠道(飞书 chat 映射)。
|
||||
// 桌面端在看的会话重复可见无害;未绑 chat 时 push_to_chat 内部静默跳过
|
||||
spawn_completion_push(app.clone(), conv.clone());
|
||||
Ok(conv_id)
|
||||
}
|
||||
Err(err) => {
|
||||
@@ -444,6 +447,19 @@ pub async fn ai_outbox_enqueue(
|
||||
skill: Option<String>,
|
||||
model_override: Option<String>,
|
||||
conversation_id: String,
|
||||
) -> Result<String, String> {
|
||||
enqueue_internal(&app, &state, text, due_at, skill, model_override, conversation_id).await
|
||||
}
|
||||
|
||||
/// 入队内部口(#959):前端 command 与飞书受理守卫拒绝路径共用,单点校验/唤醒/事件。
|
||||
pub(crate) async fn enqueue_internal(
|
||||
app: &AppHandle,
|
||||
state: &AppState,
|
||||
text: String,
|
||||
due_at: Option<i64>,
|
||||
skill: Option<String>,
|
||||
model_override: Option<String>,
|
||||
conversation_id: String,
|
||||
) -> Result<String, String> {
|
||||
validate_text(&text)?;
|
||||
validate_conv_id(&conversation_id)?;
|
||||
@@ -477,7 +493,7 @@ pub async fn ai_outbox_enqueue(
|
||||
.map_err(|e| format!("待发项写入失败: {e}"))?;
|
||||
// 尽快项/到期项即时唤醒调度器(周期 tick 仅兜底);事件供各窗口视图刷新。
|
||||
notify().notify_one();
|
||||
emit(&app, "ai-outbox-changed", &id, &conversation_id, None, None);
|
||||
emit(app, "ai-outbox-changed", &id, &conversation_id, None, None);
|
||||
Ok(id)
|
||||
}
|
||||
|
||||
@@ -731,3 +747,43 @@ mod tests {
|
||||
assert!(ensure_cancellable(STATUS_CANCELED).is_err());
|
||||
}
|
||||
}
|
||||
|
||||
/// 959 结果回推任务:订阅事件总线等该会话完成(AiAgentFinished),终版报告推回
|
||||
/// 来源渠道(push_to_chat 按 conv 反查飞书 chat 映射)。35min 超时弃守(对齐渠道
|
||||
/// watcher 量级;引擎仍在跑则结果在桌面端可见,不阻塞)。
|
||||
fn spawn_completion_push(app: AppHandle, conv: String) {
|
||||
tauri::async_runtime::spawn(async move {
|
||||
let state = app.state::<AppState>();
|
||||
let mut rx = state.ai_event_bus.subscribe();
|
||||
let deadline = tokio::time::Instant::now() + std::time::Duration::from_secs(35 * 60);
|
||||
loop {
|
||||
let ev = tokio::time::timeout_at(deadline, rx.recv()).await;
|
||||
match ev {
|
||||
Err(_) => {
|
||||
tracing::warn!("[outbox] 完成回推超时弃守 conv={conv}");
|
||||
return;
|
||||
}
|
||||
Ok(Err(tokio::sync::broadcast::error::RecvError::Closed)) => return,
|
||||
Ok(Err(tokio::sync::broadcast::error::RecvError::Lagged(_))) => continue,
|
||||
Ok(Ok(v)) => {
|
||||
if v.get("type").and_then(|t| t.as_str()) != Some("AiAgentFinished") {
|
||||
continue;
|
||||
}
|
||||
if v.get("conversation_id").and_then(|c| c.as_str()) != Some(conv.as_str()) {
|
||||
continue;
|
||||
}
|
||||
let summary = v
|
||||
.get("summary")
|
||||
.and_then(|s| s.as_str())
|
||||
.unwrap_or("")
|
||||
.to_string();
|
||||
if summary.is_empty() {
|
||||
return;
|
||||
}
|
||||
crate::feishu_channel::push_to_chat(&app, &summary, Some(&conv)).await;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user