优化: 清理无意义注释(走查编号前缀/过时历史标注/死代码注释)
This commit is contained in:
+21
-21
@@ -162,7 +162,7 @@ const router = useRouter()
|
||||
const appSettings = useAppSettingsStore()
|
||||
const unifiedApproval = appSettings.useSetting<boolean>('df-ai-unified-approval', true)
|
||||
|
||||
// ── UX-2025-20: 空状态示例问题随 MessageList 子组件迁移(examplePrompts 数组在子组件内);
|
||||
// ── 空状态示例问题随 MessageList 子组件迁移(examplePrompts 数组在子组件内);
|
||||
// 父仅保留 sendExamplePrompt 转发(子 emit 'send-example-prompt' → 父委托 ChatInput.sendExamplePrompt)。──
|
||||
|
||||
/** 跳 Settings 配置 provider:嵌入模式 router.push;分离窗口无 Settings 路由,降级 toast 提示 */
|
||||
@@ -184,9 +184,9 @@ function sendExamplePrompt(i18nKey: string) {
|
||||
// i18n 不在本任务白名单,文案硬编码,后续补 aiChat.toastSendFail key
|
||||
const { toast, showToast } = useToast()
|
||||
|
||||
// B-260616-12: 工具慢执行提示事件 unlistener(onMounted 注册,onBeforeUnmount 释放)
|
||||
// 工具慢执行提示事件 unlistener(onMounted 注册,onBeforeUnmount 释放)
|
||||
let _unlistenToolSlow: (() => void) | null = null
|
||||
// AE-2025-04: 会话信任自动放行 toast unlistener(useAiEvents 经事件总线中转,同 _unlistenToolSlow 模式)
|
||||
// 会话信任自动放行 toast unlistener(useAiEvents 经事件总线中转,同 _unlistenToolSlow 模式)
|
||||
let _unlistenAutoApproved: (() => void) | null = null
|
||||
// P1-e-d: 审批失败 toast unlistener(useAiApproval 审批 IPC 未送达经事件总线 emit,同 _unlistenToolSlow 模式)
|
||||
let _unlistenAiToast: (() => void) | null = null
|
||||
@@ -206,10 +206,10 @@ function onChatInputError(payload: { msg: string; type: 'error' | 'warning' | 'i
|
||||
// 第四批抽离: MessageList 子组件引用(expose scrollToBottom/scrollToFirstPending)
|
||||
const messageListRef = ref<InstanceType<typeof MessageList> | null>(null)
|
||||
|
||||
// AE-2025-02:头部审批徽标 — 当前对话积压的待审批工具数(>0 时显示)
|
||||
// 头部审批徽标 — 当前对话积压的待审批工具数(>0 时显示)
|
||||
const pendingApprovalCount = computed(() => store.state.pendingApprovals.length)
|
||||
|
||||
// AE-2025-07: Agentic 循环进度条
|
||||
// Agentic 循环进度条
|
||||
// 仅 agentic 多轮(streaming 且 agentRound>0)显示;单轮问答不收 AiAgentRound 故恒隐藏。
|
||||
const showAgenticProgress = computed(() =>
|
||||
store.state.streaming && store.state.agentRound > 0,
|
||||
@@ -236,7 +236,7 @@ async function confirmDeleteConversation(id: string) {
|
||||
const conv = store.state.conversations.find(c => c.id === id)
|
||||
if (!conv) console.warn('confirmDeleteConversation: conv not found, id=', id)
|
||||
const title = conv?.title || t('aiChat.newConversation')
|
||||
// UX-260617-24:删除当前活跃对话加醒目提示(通用文案不区分,活跃对话误删影响更大)。
|
||||
// 删除当前活跃对话加醒目提示(通用文案不区分,活跃对话误删影响更大)。
|
||||
const isActive = id === store.state.activeConversationId
|
||||
const msgKey = isActive ? 'aiChat.confirmDeleteActiveConversation' : 'aiChat.confirmDeleteConversation'
|
||||
if (!await confirmDialog(t(msgKey, { title }))) return
|
||||
@@ -270,13 +270,13 @@ async function confirmNewConversation() {
|
||||
// projectsStore 仍由父持有(onMounted 预加载 projects/tasks 供子组件 @ 联想读取)
|
||||
const projectsStore = useProjectStore()
|
||||
|
||||
// UX-09:切换对话/新对话时取消编辑态(编辑态绑定末条 user,切走后无效)
|
||||
// 切换对话/新对话时取消编辑态(编辑态绑定末条 user,切走后无效)
|
||||
// 2026-06-18 改:打开/切换会话默认进 specify 模式并选中权重最高 model(用户诉求:默认确定选中、
|
||||
// 不随机/不摇摆)。enabledModels 已按 weight 降序,[0]=最高。空池(未拉取)落 null=auto 兜底。
|
||||
// 后端 run_agentic_loop 对 override 兜底校验池内才用,前端预选无副作用。
|
||||
// 第三批抽离: 默认 model 选中逻辑(modelOverride=enabledModels[0])随 enabledModels 迁移至
|
||||
// TopBar.vue 的 activeConversationId watch;本组件仅保留编辑态取消。
|
||||
// 滚动边沿/跟随意图重置(SW-260618-18)随 MessageList 迁移,由子组件自管。
|
||||
// 滚动边沿/跟随意图重置随 MessageList 迁移,由子组件自管。
|
||||
watch(() => store.state.activeConversationId, () => {
|
||||
if (editingMsgId.value) cancelEdit()
|
||||
})
|
||||
@@ -291,13 +291,13 @@ const convSidebarRef = ref<InstanceType<typeof ConversationSidebar> | null>(null
|
||||
// cycleProvider/providerBarVisible/showProviderSwitched 已迁移至 ai/TopBar.vue
|
||||
// (顶部工具栏 + provider/model 选择逻辑,零行为变更,store 单例共享 modelOverride)。
|
||||
|
||||
/** UX-09:进入编辑态 — 置 editingMsgId(透传 ChatInput prop)+ 委托 ChatInput.startEditFocus 回填/聚焦。 */
|
||||
/** 进入编辑态 — 置 editingMsgId(透传 ChatInput prop)+ 委托 ChatInput.startEditFocus 回填/聚焦。 */
|
||||
function startEdit(msg: AiMessage): void {
|
||||
editingMsgId.value = msg.id
|
||||
chatInputRef.value?.startEditFocus(msg)
|
||||
}
|
||||
|
||||
/** UX-09:取消编辑态(切换对话/清空/ESC)。清 editingMsgId + 委托 ChatInput.clearInput 清输入。 */
|
||||
/** 取消编辑态(切换对话/清空/ESC)。清 editingMsgId + 委托 ChatInput.clearInput 清输入。 */
|
||||
function cancelEdit(): void {
|
||||
editingMsgId.value = null
|
||||
chatInputRef.value?.clearInput()
|
||||
@@ -366,7 +366,7 @@ function onGlobalKeydown(e: KeyboardEvent) {
|
||||
}
|
||||
|
||||
/**
|
||||
* UX-260617-16:未发送输入保护。检测 inputText/pendingImages/pendingSkill 任一非空,
|
||||
* 未发送输入保护。检测 inputText/pendingImages/pendingSkill 任一非空,
|
||||
* 用于 beforeunload 拦截(分离窗口关闭/刷新)与未来 onBeforeUnmount 拦截(面板切换)。
|
||||
*/
|
||||
function hasUnsentInput(): boolean {
|
||||
@@ -452,15 +452,15 @@ function scrollToBottom(smooth = false) {
|
||||
messageListRef.value?.scrollToBottom(smooth)
|
||||
}
|
||||
onBeforeUnmount(() => {
|
||||
// 全局快捷键(UX-2025-07):卸载时移除 window listener,防分离窗口/切组件后泄漏
|
||||
// 全局快捷键卸载时移除 window listener,防分离窗口/切组件后泄漏
|
||||
window.removeEventListener('keydown', onGlobalKeydown)
|
||||
// UX-260617-16:摘除未发送输入保护(分离窗口关闭/页面刷新触发 beforeunload)
|
||||
// 摘除未发送输入保护(分离窗口关闭/页面刷新触发 beforeunload)
|
||||
window.removeEventListener('beforeunload', onBeforeUnloadGuard)
|
||||
// 注:导出菜单外部点击监听/侧栏拖拽 listener/标题淡入计时器现由 ConversationSidebar
|
||||
// 子组件 onBeforeUnmount 自管(第一批抽离),父不再持有这些引用。
|
||||
// 流式 rAF 清理(streaming watch 内 cancelAnimationFrame)随 MessageList 迁移,子组件
|
||||
// onBeforeUnmount 自管(子 watch streaming 已注册,卸载自动停)。
|
||||
// CR-260615-24: 释放后端 listener(ai-chat-event/ai-conversation-changed)+清流式看门狗。
|
||||
// 释放后端 listener(ai-chat-event/ai-conversation-changed)+清流式看门狗。
|
||||
// 之前 stopListener 定义但全仓零调用 → listener+watchdog 永久泄漏;分离窗口主窗口 AiChat
|
||||
// 卸载(走 App.vue v-if detach)时 listener 仍挂后端,watchdog 130s 后写已卸载 state。
|
||||
store.stopListener()
|
||||
@@ -473,9 +473,9 @@ onBeforeUnmount(() => {
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
// 全局快捷键(UX-2025-07):window 级 listener,卸载时移除(对齐 _unlistenToolSlow 生命周期)
|
||||
// 全局快捷键window 级 listener,卸载时移除(对齐 _unlistenToolSlow 生命周期)
|
||||
window.addEventListener('keydown', onGlobalKeydown)
|
||||
// UX-260617-16:未发送输入保护。AiChat 非路由组件(App.vue 内嵌 + AiDetached 路由),
|
||||
// 未发送输入保护。AiChat 非路由组件(App.vue 内嵌 + AiDetached 路由),
|
||||
// beforeRouteLeave 不适用。分离窗口关闭/页面刷新时若有未发送 inputText/pendingImages/
|
||||
// pendingSkill,经 beforeunload 拦截提示用户。注意:e.preventDefault() 才是现代浏览器
|
||||
// 触发原生「确定离开?」的标准做法 returnValue 仅 Chrome 兼容旧写法。
|
||||
@@ -496,13 +496,13 @@ onMounted(async () => {
|
||||
// 此处按需预加载(已加载则跳过), 不阻塞首屏(无 await, 后台执行)。
|
||||
if (!projectsStore.projects.length) void projectsStore.loadProjects()
|
||||
if (!projectsStore.tasks.length) void projectsStore.loadTasks()
|
||||
// B-260616-12: 监听工具慢执行提示(useAiEvents 经 Tauri 事件总线广播;composable 无组件上下文,
|
||||
// 监听工具慢执行提示(useAiEvents 经 Tauri 事件总线广播;composable 无组件上下文,
|
||||
// 由本组件弹本地 toast。主窗口与分离窗口各挂一份 AiChat,各自消费,无重复——emit 单发,
|
||||
// 两窗口的 listener 各收一次但 msg 相同,toast 各自渲染互不干扰)
|
||||
_unlistenToolSlow = await listen<{ name: string }>('ai-tool-slow-toast', (e) => {
|
||||
showToast(t('aiTool.executionSlow', { name: e.payload.name }), 'warning')
|
||||
})
|
||||
// AE-2025-04: 会话信任自动放行 toast(轻量 info,非审批气泡,避免干扰主流程)
|
||||
// 会话信任自动放行 toast(轻量 info,非审批气泡,避免干扰主流程)
|
||||
_unlistenAutoApproved = await listen<{ tool: string; dir: string }>('ai-tool-auto-approved-toast', (e) => {
|
||||
showToast(t('aiChat.autoApprovedToast', { tool: e.payload.tool, dir: e.payload.dir }), 'info')
|
||||
})
|
||||
@@ -516,7 +516,7 @@ onMounted(async () => {
|
||||
// 恢复生成中态(刷新后/分离窗口接管):
|
||||
// - 分离模式(detached=true):resumeInDetached 接管主窗口当前对话
|
||||
// - 主面板模式(detached=false):restoreGeneratingState 恢复主面板自身的生成态
|
||||
// (UX-260617-13: 主面板刷新后无等价恢复链 → streaming=false + 无占位气泡 + 后端
|
||||
// 主面板刷新后无等价恢复链 → streaming=false + 无占位气泡 + 后端
|
||||
// 事件不进流式分支,退化为非流式。现对齐 resumeInDetached 同款恢复链)。
|
||||
// 两者互斥(detached 三元决定),不会双重恢复;restoreGeneratingState 内幂等守卫(state.streaming 已 true 则跳过)。
|
||||
// 在 startListener(L0 ai-client-ready 握手)之后调用,握手仍先于恢复逻辑生效。
|
||||
@@ -691,7 +691,7 @@ async function initContextEventListeners(): Promise<void> {
|
||||
}
|
||||
/* 第五批抽离: F-260616-03 max_iterations 操作卡样式已迁移至 ai/MaxRoundsCard.vue */
|
||||
|
||||
/* ── AE-2025-07: Agentic 循环进度条 ── */
|
||||
/* ── Agentic 循环进度条 ── */
|
||||
.ai-agentic-progress {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -803,7 +803,7 @@ async function initContextEventListeners(): Promise<void> {
|
||||
.ai-toast-error { background: var(--df-danger-bg); color: var(--df-danger); border: 0.5px solid var(--df-danger); }
|
||||
.ai-toast-warning { background: var(--df-warning-bg); color: var(--df-warning); border: 0.5px solid var(--df-warning); }
|
||||
.ai-toast-info { background: var(--df-accent-bg); color: var(--df-accent); border: 0.5px solid var(--df-accent); }
|
||||
/* P0-2: ToastType 新增 'success' 兜底样式 */
|
||||
/* ToastType 新增 'success' 兜底样式 */
|
||||
.ai-toast-success { background: var(--df-success-bg); color: var(--df-success); border: 0.5px solid var(--df-success); }
|
||||
.ai-toast-enter-active, .ai-toast-leave-active { transition: opacity 0.2s, transform 0.2s; }
|
||||
.ai-toast-enter-from, .ai-toast-leave-to { opacity: 0; transform: translate(-50%, -8px); }
|
||||
|
||||
Reference in New Issue
Block a user