mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 04:11:10 -05:00
feat: Add conversation context token counter
- Add contextTokens to ApiMetrics interface - Calculate context size using last API request's tokens - Display context token count in TaskHeader below total tokens - Use exact token counts instead of character estimation This helps users track the total size of their conversation context, which is useful for managing context window limits.
This commit is contained in:
@@ -915,6 +915,7 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
|
||||
cacheWrites={apiMetrics.totalCacheWrites}
|
||||
cacheReads={apiMetrics.totalCacheReads}
|
||||
totalCost={apiMetrics.totalCost}
|
||||
contextTokens={apiMetrics.contextTokens}
|
||||
onClose={handleTaskCloseButtonClick}
|
||||
/>
|
||||
) : (
|
||||
|
||||
@@ -16,6 +16,7 @@ interface TaskHeaderProps {
|
||||
cacheWrites?: number
|
||||
cacheReads?: number
|
||||
totalCost: number
|
||||
contextTokens: number
|
||||
onClose: () => void
|
||||
}
|
||||
|
||||
@@ -27,6 +28,7 @@ const TaskHeader: React.FC<TaskHeaderProps> = ({
|
||||
cacheWrites,
|
||||
cacheReads,
|
||||
totalCost,
|
||||
contextTokens,
|
||||
onClose,
|
||||
}) => {
|
||||
const { apiConfiguration } = useExtensionState()
|
||||
@@ -272,6 +274,13 @@ const TaskHeader: React.FC<TaskHeaderProps> = ({
|
||||
{!isCostAvailable && <ExportButton />}
|
||||
</div>
|
||||
|
||||
<div style={{ display: "flex", alignItems: "center", gap: "4px", flexWrap: "wrap" }}>
|
||||
<span style={{ fontWeight: "bold" }}>Context:</span>
|
||||
<span style={{ display: "flex", alignItems: "center", gap: "3px" }}>
|
||||
{formatLargeNumber(contextTokens || 0)}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{shouldShowPromptCacheInfo && (cacheReads !== undefined || cacheWrites !== undefined) && (
|
||||
<div style={{ display: "flex", alignItems: "center", gap: "4px", flexWrap: "wrap" }}>
|
||||
<span style={{ fontWeight: "bold" }}>Cache:</span>
|
||||
|
||||
Reference in New Issue
Block a user