mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-15 12:55:51 +00:00
feat: 添加 cacheWarningEnabled 配置项,支持在 /config 面板关闭缓存率警告
This commit is contained in:
@@ -331,6 +331,24 @@ export function Config({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: 'cacheWarningEnabled',
|
||||||
|
label: 'Cache warnings',
|
||||||
|
value: settingsData?.cacheWarningEnabled ?? true,
|
||||||
|
type: 'boolean' as const,
|
||||||
|
onChange(cacheWarningEnabled: boolean) {
|
||||||
|
updateSettingsForSource('localSettings', {
|
||||||
|
cacheWarningEnabled,
|
||||||
|
});
|
||||||
|
setSettingsData(prev => ({
|
||||||
|
...prev,
|
||||||
|
cacheWarningEnabled,
|
||||||
|
}));
|
||||||
|
logEvent('tengu_cache_warning_setting_changed', {
|
||||||
|
enabled: cacheWarningEnabled,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: 'prefersReducedMotion',
|
id: 'prefersReducedMotion',
|
||||||
label: 'Reduce motion',
|
label: 'Reduce motion',
|
||||||
|
|||||||
@@ -133,6 +133,7 @@ import { getAPIProvider } from './utils/model/providers.js'
|
|||||||
import {
|
import {
|
||||||
createCacheWarningMessage,
|
createCacheWarningMessage,
|
||||||
getCacheThreshold,
|
getCacheThreshold,
|
||||||
|
isCacheWarningEnabled,
|
||||||
shouldShowCacheWarning,
|
shouldShowCacheWarning,
|
||||||
} from './utils/cacheWarning.js'
|
} from './utils/cacheWarning.js'
|
||||||
|
|
||||||
@@ -1256,7 +1257,7 @@ async function* queryLoop(
|
|||||||
cache_read_input_tokens: number
|
cache_read_input_tokens: number
|
||||||
}
|
}
|
||||||
| undefined
|
| undefined
|
||||||
if (usage) {
|
if (usage && isCacheWarningEnabled()) {
|
||||||
const warningInfo = shouldShowCacheWarning(
|
const warningInfo = shouldShowCacheWarning(
|
||||||
usage,
|
usage,
|
||||||
querySource,
|
querySource,
|
||||||
|
|||||||
@@ -40,6 +40,14 @@ export function getCacheThreshold(): number {
|
|||||||
return settings.cacheThreshold ?? DEFAULT_CACHE_THRESHOLD
|
return settings.cacheThreshold ?? DEFAULT_CACHE_THRESHOLD
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查缓存警告是否启用。默认 true。
|
||||||
|
*/
|
||||||
|
export function isCacheWarningEnabled(): boolean {
|
||||||
|
const settings = getInitialSettings()
|
||||||
|
return settings.cacheWarningEnabled ?? true
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计算缓存命中率
|
* 计算缓存命中率
|
||||||
* 返回值范围 0-100,null 表示无有效数据
|
* 返回值范围 0-100,null 表示无有效数据
|
||||||
|
|||||||
@@ -1089,6 +1089,12 @@ export const SettingsSchema = lazySchema(() =>
|
|||||||
.describe(
|
.describe(
|
||||||
'Prompt cache hit rate threshold (0-100). Warnings shown when cache hit rate falls below this percentage. Default: 80.',
|
'Prompt cache hit rate threshold (0-100). Warnings shown when cache hit rate falls below this percentage. Default: 80.',
|
||||||
),
|
),
|
||||||
|
cacheWarningEnabled: z
|
||||||
|
.boolean()
|
||||||
|
.optional()
|
||||||
|
.describe(
|
||||||
|
'Whether to show cache hit rate warnings in the message flow when the rate falls below cacheThreshold. Default: true.',
|
||||||
|
),
|
||||||
pluginTrustMessage: z
|
pluginTrustMessage: z
|
||||||
.string()
|
.string()
|
||||||
.optional()
|
.optional()
|
||||||
|
|||||||
Reference in New Issue
Block a user