Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions webview-ui/src/components/chat/TaskHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,20 @@ const TaskHeader = ({
const textRef = useRef<HTMLDivElement>(null)
const contextWindow = model?.contextWindow || 1

// Calculate maxTokens (reserved for output) once for reuse in percentage and tooltip
const maxTokens = useMemo(
() =>
model
? getModelMaxOutputTokens({
modelId,
model,
settings: apiConfiguration,
})
: 0,
[model, modelId, apiConfiguration],
)
const reservedForOutput = maxTokens || 0

// Detect if this task had any browser session activity so we can show a grey globe when inactive
const browserSessionStartIndex = useMemo(() => {
const msgs = clineMessages || []
Expand Down Expand Up @@ -226,14 +240,6 @@ const TaskHeader = ({
<div className="flex items-center gap-2">
<StandardTooltip
content={(() => {
const maxTokens = model
? getModelMaxOutputTokens({
modelId,
model,
settings: apiConfiguration,
})
: 0
const reservedForOutput = maxTokens || 0
const availableSpace = contextWindow - (contextTokens || 0) - reservedForOutput

return (
Expand Down Expand Up @@ -276,7 +282,9 @@ const TaskHeader = ({
sideOffset={8}>
<span className="flex items-center gap-1.5">
{(() => {
const percentage = Math.round(((contextTokens || 0) / contextWindow) * 100)
const percentage = Math.round(
(((contextTokens || 0) + reservedForOutput) / contextWindow) * 100,
)
return (
<>
<CircularProgress percentage={percentage} />
Expand Down Expand Up @@ -397,15 +405,7 @@ const TaskHeader = ({
<ContextWindowProgress
contextWindow={contextWindow}
contextTokens={contextTokens || 0}
maxTokens={
model
? getModelMaxOutputTokens({
modelId,
model,
settings: apiConfiguration,
})
: undefined
}
maxTokens={maxTokens || undefined}
/>
{condenseButton}
</div>
Expand Down
Loading