重构+修复: ARC-06 composables/ai 循环依赖破环 + B-34 多选审批 select_type 回归

- ARC-06: 提 aiShared.ts 下沉 nextMsgId+_msgCounter(叶子模块),useAiEvents/useAiStream/useAiSend/useAiWindow import 源改 aiShared,useAiStream 不再 import useAiEvents 环消除。watchdog 三函数留 useAiStream(持计时器状态非纯函数)。行为零变化。
- B-34(另一会话走查发现 P0): stores/project.ts:273 selectType→select_type(Tauri 2 IPC 不转 camelCase),对齐后端 workflow.rs:211。F-260615-01 多选审批回归修复——前端传 selectType 后端收 None 归一化 Single 致多选被拒。删错误注释。
批1 wwllb4ith(ARC-06)+主代理(B-34),vue-tsc 0 err
This commit is contained in:
2026-06-15 05:25:38 +08:00
parent c7386a12c5
commit 8720b9424d
6 changed files with 30 additions and 14 deletions

View File

@@ -3,18 +3,18 @@
//! 模块级私有状态(不进 reactive):
//! - _unlistenAiEvent / _unlistenConvChanged: 已注册的 unlistener
//! - _startPromise: startListener 并发去重(防 onMounted 与 sendMessage 首发竞态重复注册)
//! - _msgCounter: 客户端消息自增 id(全局唯一,多个 composable 共用 nextMsgId)
//!
//! 耦合:
//! - handleEvent 调 useAiConversations.loadConversations、useAiSend.drainQueue、
//! useAiStream.{resetStreamWatchdog,clearStreamWatchdog}、本模块 flushCurrentText/findToolCall/notifyConversationChanged
//! - onStreamTimeout(useAiStream) 调本模块 nextMsgId
//! - nextMsgId 已下沉到 aiShared(原为本模块导出,useAiStream 亦依赖之构成循环依赖,故抽出)
import { listen, emit } from '@tauri-apps/api/event'
import { aiApi } from '../../api'
import { useAppSettingsStore } from '../../stores/appSettings'
import { state } from '../../stores/ai'
import i18n from '../../i18n'
import { nextMsgId } from './aiShared'
import { resetStreamWatchdog, clearStreamWatchdog } from './useAiStream'
import { drainQueue } from './useAiSend'
import { loadConversations } from './useAiConversations'
@@ -29,15 +29,9 @@ let _unlistenConvChanged: (() => void) | null = null
// startListener 并发去重:防 onMounted 与 sendMessage 首发竞态下重复注册 listener
// (两回调写同一 state.currentText → 流式文字双倍)
let _startPromise: Promise<void> | null = null
let _msgCounter = 0
const appSettings = useAppSettingsStore()
/** 全局消息 id 自增(供 events/stream/send/window 各 composable 共享同一计数器) */
export function nextMsgId(): number {
return ++_msgCounter
}
/** 通知会话列表发生变化(供 newConversation/deleteConversation/rename/archive 等触发刷新侧栏) */
export function notifyConversationChanged() {
emit('ai-conversation-changed', {})