mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 12:21:13 -05:00
feat(ui): add context window percentage to task header
Display the percentage of total context window used alongside token count in the task header. This helps users better understand their context usage relative to the model's capacity. Implementation details: - Retrieve model's context window size from normalized API configuration - Calculate percentage of context window used based on current context tokens - Display percentage in parentheses next to token count (e.g. "40,000 (20%)") - Default to context window size of 1 if model info is unavailable - Format numbers with commas for better readability
This commit is contained in:
@@ -3043,7 +3043,11 @@ export class Cline {
|
||||
|
||||
// Add context tokens information
|
||||
const { contextTokens } = getApiMetrics(this.clineMessages)
|
||||
details += `\n\n# Current Context Size (Tokens)\n${contextTokens ? contextTokens.toLocaleString() : "(Not available)"}`
|
||||
const modelInfo = this.api.getModel().info
|
||||
const contextWindow = modelInfo.contextWindow
|
||||
const contextPercentage =
|
||||
contextTokens && contextWindow ? Math.round((contextTokens / contextWindow) * 100) : undefined
|
||||
details += `\n\n# Current Context Size (Tokens)\n${contextTokens ? `${contextTokens.toLocaleString()} (${contextPercentage}%)` : "(Not available)"}`
|
||||
|
||||
// Add current mode and any mode-specific warnings
|
||||
const { mode, customModes } = (await this.providerRef.deref()?.getState()) ?? {}
|
||||
|
||||
Reference in New Issue
Block a user