fix: 修复缓存命中率警告消息不显示 — 改用 system 类型消息绕过 isMeta 过滤

This commit is contained in:
claude-code-best 2026-05-09 15:22:34 +08:00
parent a77d8316c9
commit f6f2ad3220

View File

@ -1,4 +1,4 @@
import { createUserMessage } from './messages.js'
import { randomUUID } from 'crypto'
import { getInitialSettings } from './settings/settings.js'
import type { Message } from '../types/message.js'
@ -109,12 +109,11 @@ export function shouldShowCacheWarning(
/**
*
* @param info
* @returns isVisibleInTranscriptOnly
* @returns system REPL transcript
*/
export function createCacheWarningMessage(info: CacheHitRateInfo): Message {
const { hitRate, threshold, trend } = info
// 构建消息内容
let content = `Cache hit rate ${hitRate.toFixed(0)}%, below ${threshold}% threshold`
if (trend !== null && Math.abs(trend) > 0.1) {
@ -123,9 +122,13 @@ export function createCacheWarningMessage(info: CacheHitRateInfo): Message {
content += ` (${trendIcon}${trendPercent}%)`
}
return createUserMessage({
return {
type: 'system',
subtype: 'cache_warning',
level: 'warning' as const,
content,
isMeta: true,
isVisibleInTranscriptOnly: true,
})
timestamp: new Date().toISOString(),
uuid: randomUUID(),
isMeta: false,
} as Message
}