修复: PowerShell 路径转义 + shell 失败提示 + 标题合并同 role + L0 防抖

- run_command 路径反斜杠传递修正
- 命令失败追加 PowerShell 适配提示引导 LLM 改正
- 标题生成前合并连续同 role 消息避免 Anthropic 1214
- V33 迁移追加 workflow_executions.updated_at 列
- ai-client-ready 3 秒防抖避免重复握手
This commit is contained in:
2026-06-28 13:57:53 +08:00
parent 6ffcba7e4d
commit 7adaf97377
5 changed files with 103 additions and 6 deletions

View File

@@ -57,11 +57,31 @@ pub fn run() {
app.manage(app_state);
// B-260616-01: L0 握手 — 监听前端就绪事件,清除 HMR/刷新导致的残留 generating 状态
// 任务5: 3 秒防抖 —— 前端 HMR/快速连击会连发 ai-client-ready(实测 <1s 内多次),
// 每次都走完整 握手(spawn + 锁 session + emit)造成事务事并行冲突 + emit 风暴。
// 记录上次处理时间,3s 内重复事件跳过(只取首次,使能状态复位一次即可)。
let last_handshake_at = std::sync::Arc::new(tokio::sync::Mutex::new(
std::time::Instant::now() - std::time::Duration::from_secs(3600),
));
let app_handle = app.handle().clone();
app.listen("ai-client-ready", move |_event| {
let session_arc = session_for_handshake.clone();
let app_h = app_handle.clone();
let last_at = last_handshake_at.clone();
tauri::async_runtime::spawn(async move {
// 防抖检查:锁 last_at 读上次时间,3s 内跳过(仅记录日志,不做实际握手动作)。
{
let mut last = last_at.lock().await;
let elapsed = last.elapsed();
if elapsed < std::time::Duration::from_secs(3) {
tracing::info!(
"[L0-handshake] 跳过(距上次握手 {}ms < 3000ms 防抖)",
elapsed.as_millis()
);
return;
}
*last = std::time::Instant::now();
}
let mut session = session_arc.lock().await;
// F-260616-09 B 批8(设计 §3 batch8 + §5.2):遍历 per_conv(HashMap)清多 conv
// 残留 generating(HMR/dev 热载场景多 conv 并发跑 loop 致多 conv 卡 generating)。