优化上下文事件更新的处理逻辑

This commit is contained in:
xintaofei
2026-03-13 22:07:29 +08:00
parent bf14a99168
commit 0c843ec14e
3 changed files with 131 additions and 2 deletions

View File

@@ -975,6 +975,12 @@ function connectionsReducer(
case "USAGE_UPDATE": {
const conn = state.get(action.contextKey)
if (!conn) return state
// Ignore usage updates that reset used to 0 when we already have
// valid data — these come from synthetic responses for local commands
// like /context and would overwrite the real context window usage.
if (action.usage.used === 0 && conn.usage && conn.usage.used > 0) {
return state
}
if (
conn.usage?.used === action.usage.used &&
conn.usage?.size === action.usage.size