优化: 上下文管理与提示词链路批
- T1 usage 口径: anthropic usage 两层容错+cache 三口径归一(prompt=input+read+creation) - T2 压缩水位判据: compress_should_trigger 双模式+ratio 钳位,开关关逐字节等价 - T3 跨会话检索: history_search 工具(两跳式)+message_repo 关键词检索+prompt 指引 - T4 代语义闭环: status 终局补写+飞书停靠/换代推卡+交付引导+watcher 兜底补漏 - 段序缓存重排: build_runtime_prompt 恒静段上移/工作上下文压尾(前缀缓存失效面收窄) - 智谱缓存解析: anthropic 臂补 prompt_tokens_details.cached_tokens 嵌套回退 - 工时禁令: 提示词双语加「禁止预估工时,AI Coding 工时无意义」 - 拖拽文件落盘: 非图片附件存引用行,防整段文本灌入输入框 - 事实修正: 提示词「40+ 工具」→「80+」(基线 81);tool_failure_memory 测试串行锁除竞态 - UI 拆分: TopBar/ToolResultBody 壳层化(top-bar/tool-result-body 子件目录)
This commit is contained in:
@@ -7,7 +7,6 @@ import { emit } from '@tauri-apps/api/event'
|
||||
import { state } from '@/stores/ai'
|
||||
import { t } from '@/i18n/i18n-helpers'
|
||||
import { findToolCall, clearApprovalTimer, startApprovalTimer, startToolSlowTimer, clearToolSlowTimer, addPendingApproval, removePendingApprovalById, bumpToolEpoch } from './aiShared'
|
||||
import { removePendingDirAuth } from './useAiPendingState'
|
||||
import { clearStreamWatchdog } from './useAiStream'
|
||||
import type { AiChatEvent, AiToolCallInfo } from '@/api/types'
|
||||
|
||||
@@ -92,8 +91,7 @@ export function handleToolEvent(event: AiChatEvent): boolean {
|
||||
name: event.name,
|
||||
args: event.args,
|
||||
status: 'pending_approval',
|
||||
kind: event.kind ?? 'risk',
|
||||
// reason 必须写入 info,否则浮窗 ApprovalPopup 的 tc.reason 永远空(审批说明丢失)
|
||||
// reason 必须写入 info,否则 ToolCard/浮层的 tc.reason 永远空(审批说明丢失)
|
||||
reason: event.reason,
|
||||
conversationId: event.conversation_id ?? state.activeConversationId ?? undefined,
|
||||
}
|
||||
@@ -106,9 +104,10 @@ export function handleToolEvent(event: AiChatEvent): boolean {
|
||||
// write_file 审批注入行级 diff(旧文件 vs 新内容),前端审批卡预览
|
||||
if (event.diff) tc.diff = event.diff
|
||||
}
|
||||
// 进入审批等待 → 取消该工具慢执行计时器(审批耗时由用户主导,非执行慢),再启动审批超时计时器
|
||||
// 进入审批等待 → 取消该工具慢执行计时器(审批耗时由用户主导,非执行慢),
|
||||
// 再登记后端透传的到期时刻(超时收敛单一真值=后端,前端无本地自动拒绝)
|
||||
clearToolSlowTimer(event.id)
|
||||
startApprovalTimer(event.id, event.name, 'risk')
|
||||
startApprovalTimer(event.id, event.expires_at_millis ?? null)
|
||||
// 通知 ToolCardList 展开折叠组 + scroll(pending 卡落折叠分组不可见时)
|
||||
void emit('ai-pending-arrived', { toolCallId: event.id })
|
||||
}
|
||||
@@ -134,8 +133,6 @@ export function handleToolEvent(event: AiChatEvent): boolean {
|
||||
startToolSlowTimer(event.id, tc?.name || '')
|
||||
clearApprovalTimer(event.id)
|
||||
}
|
||||
// 路径授权挂起的工具收到 ApprovalResult → 按 id 移除该条(数组化后只清这一条)
|
||||
removePendingDirAuth(event.id)
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user