File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -331,6 +331,24 @@ export function Config({
331331 } ) ;
332332 } ,
333333 } ,
334+ {
335+ id : 'cacheWarningEnabled' ,
336+ label : 'Cache warnings' ,
337+ value : settingsData ?. cacheWarningEnabled ?? true ,
338+ type : 'boolean' as const ,
339+ onChange ( cacheWarningEnabled : boolean ) {
340+ updateSettingsForSource ( 'localSettings' , {
341+ cacheWarningEnabled,
342+ } ) ;
343+ setSettingsData ( prev => ( {
344+ ...prev ,
345+ cacheWarningEnabled,
346+ } ) ) ;
347+ logEvent ( 'tengu_cache_warning_setting_changed' , {
348+ enabled : cacheWarningEnabled ,
349+ } ) ;
350+ } ,
351+ } ,
334352 {
335353 id : 'prefersReducedMotion' ,
336354 label : 'Reduce motion' ,
Original file line number Diff line number Diff line change @@ -133,6 +133,7 @@ import { getAPIProvider } from './utils/model/providers.js'
133133import {
134134 createCacheWarningMessage ,
135135 getCacheThreshold ,
136+ isCacheWarningEnabled ,
136137 shouldShowCacheWarning ,
137138} from './utils/cacheWarning.js'
138139
@@ -1256,7 +1257,7 @@ async function* queryLoop(
12561257 cache_read_input_tokens : number
12571258 }
12581259 | undefined
1259- if ( usage ) {
1260+ if ( usage && isCacheWarningEnabled ( ) ) {
12601261 const warningInfo = shouldShowCacheWarning (
12611262 usage ,
12621263 querySource ,
Original file line number Diff line number Diff line change @@ -40,6 +40,14 @@ export function getCacheThreshold(): number {
4040 return settings . cacheThreshold ?? DEFAULT_CACHE_THRESHOLD
4141}
4242
43+ /**
44+ * 检查缓存警告是否启用。默认 true。
45+ */
46+ export function isCacheWarningEnabled ( ) : boolean {
47+ const settings = getInitialSettings ( )
48+ return settings . cacheWarningEnabled ?? true
49+ }
50+
4351/**
4452 * 计算缓存命中率
4553 * 返回值范围 0-100,null 表示无有效数据
Original file line number Diff line number Diff line change @@ -1089,6 +1089,12 @@ export const SettingsSchema = lazySchema(() =>
10891089 . describe (
10901090 'Prompt cache hit rate threshold (0-100). Warnings shown when cache hit rate falls below this percentage. Default: 80.' ,
10911091 ) ,
1092+ cacheWarningEnabled : z
1093+ . boolean ( )
1094+ . optional ( )
1095+ . describe (
1096+ 'Whether to show cache hit rate warnings in the message flow when the rate falls below cacheThreshold. Default: true.' ,
1097+ ) ,
10921098 pluginTrustMessage : z
10931099 . string ( )
10941100 . optional ( )
You can’t perform that action at this time.
0 commit comments