mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 04:11:10 -05:00
feat: Add context tokens to environment details
Adds the current conversation's context token count to the environment details section by: - Using existing getApiMetrics() to retrieve contextTokens from the last API request - Adding a new "Context Tokens" section between "Current Time" and "Current Mode" - Formatting the token count with toLocaleString() for better readability - Showing "(Not available)" when no context tokens are present This provides visibility into the current conversation's token usage directly in the environment details, helping track context window utilization.
This commit is contained in:
@@ -3041,6 +3041,10 @@ export class Cline {
|
|||||||
const timeZoneOffsetStr = `${timeZoneOffset >= 0 ? "+" : ""}${timeZoneOffset}:00`
|
const timeZoneOffsetStr = `${timeZoneOffset >= 0 ? "+" : ""}${timeZoneOffset}:00`
|
||||||
details += `\n\n# Current Time\n${formatter.format(now)} (${timeZone}, UTC${timeZoneOffsetStr})`
|
details += `\n\n# Current Time\n${formatter.format(now)} (${timeZone}, UTC${timeZoneOffsetStr})`
|
||||||
|
|
||||||
|
// Add context tokens information
|
||||||
|
const { contextTokens } = getApiMetrics(this.clineMessages)
|
||||||
|
details += `\n\n# Current Context Size (Tokens)\n${contextTokens ? contextTokens.toLocaleString() : "(Not available)"}`
|
||||||
|
|
||||||
// Add current mode and any mode-specific warnings
|
// Add current mode and any mode-specific warnings
|
||||||
const { mode, customModes } = (await this.providerRef.deref()?.getState()) ?? {}
|
const { mode, customModes } = (await this.providerRef.deref()?.getState()) ?? {}
|
||||||
const currentMode = mode ?? defaultModeSlug
|
const currentMode = mode ?? defaultModeSlug
|
||||||
|
|||||||
Reference in New Issue
Block a user