From 3ac866be98832d6f7f2cde1ee1a452971ea50a81 Mon Sep 17 00:00:00 2001 From: claude-code-best Date: Sat, 9 May 2026 15:22:34 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E5=91=BD=E4=B8=AD=E7=8E=87=E8=AD=A6=E5=91=8A=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E4=B8=8D=E6=98=BE=E7=A4=BA=20=E2=80=94=20=E6=94=B9=E7=94=A8=20?= =?UTF-8?q?system=20=E7=B1=BB=E5=9E=8B=E6=B6=88=E6=81=AF=E7=BB=95=E8=BF=87?= =?UTF-8?q?=20isMeta=20=E8=BF=87=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/cacheWarning.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/utils/cacheWarning.ts b/src/utils/cacheWarning.ts index 0334fdeb8..39ba5a599 100644 --- a/src/utils/cacheWarning.ts +++ b/src/utils/cacheWarning.ts @@ -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 }