fix(ui): show token stats and simplify context window calculation
- Track messageInfoVersion in cache signature to rebuild when tokens arrive via SSE - Read tokens from step-finish part directly (embedded in SSE events) - Simplify available tokens to show full context window when no explicit input limit
This commit is contained in:
@@ -116,18 +116,11 @@ export function updateSessionInfo(instanceId: string, sessionId: string): void {
|
||||
// Prefer explicit input limits when provided by the API.
|
||||
// This is used by the UI "Avail" chip.
|
||||
contextAvailableTokens = modelInputLimit
|
||||
}
|
||||
|
||||
if (!contextAvailableFromPrevious && contextAvailableTokens === null) {
|
||||
if (contextWindow > 0) {
|
||||
if (latestHasContextUsage && actualUsageTokens > 0) {
|
||||
contextAvailableTokens = Math.max(contextWindow - (actualUsageTokens + outputBudget), 0)
|
||||
} else {
|
||||
contextAvailableTokens = contextWindow
|
||||
}
|
||||
} else {
|
||||
contextAvailableTokens = null
|
||||
}
|
||||
} else if (contextWindow > 0) {
|
||||
// When no explicit input limit, show full context window capacity.
|
||||
contextAvailableTokens = contextWindow
|
||||
} else {
|
||||
contextAvailableTokens = null
|
||||
}
|
||||
|
||||
setSessionInfoByInstance((prev) => {
|
||||
|
||||
Reference in New Issue
Block a user