({
task,
tokensIn,
tokensOut,
cacheWrites,
cacheReads,
totalCost,
aggregatedCost,
hasSubtasks,
parentTaskId,
costBreakdown,
contextTokens,
buttonsDisabled,
handleCondenseContext,
todos,
}: TaskHeaderProps)
| 40 | } |
| 41 | |
| 42 | const TaskHeader = ({ |
| 43 | task, |
| 44 | tokensIn, |
| 45 | tokensOut, |
| 46 | cacheWrites, |
| 47 | cacheReads, |
| 48 | totalCost, |
| 49 | aggregatedCost, |
| 50 | hasSubtasks, |
| 51 | parentTaskId, |
| 52 | costBreakdown, |
| 53 | contextTokens, |
| 54 | buttonsDisabled, |
| 55 | handleCondenseContext, |
| 56 | todos, |
| 57 | }: TaskHeaderProps) => { |
| 58 | const { t } = useTranslation() |
| 59 | const { apiConfiguration, currentTaskItem } = useExtensionState() |
| 60 | const { id: modelId, info: model } = useSelectedModel(apiConfiguration) |
| 61 | const [isTaskExpanded, setIsTaskExpanded] = useState(false) |
| 62 | |
| 63 | const textContainerRef = useRef<HTMLDivElement>(null) |
| 64 | const textRef = useRef<HTMLDivElement>(null) |
| 65 | const contextWindow = model?.contextWindow || 1 |
| 66 | |
| 67 | // Calculate maxTokens (reserved for output) once for reuse in percentage and tooltip |
| 68 | const maxTokens = useMemo( |
| 69 | () => |
| 70 | model |
| 71 | ? getModelMaxOutputTokens({ |
| 72 | modelId, |
| 73 | model, |
| 74 | settings: apiConfiguration, |
| 75 | }) |
| 76 | : 0, |
| 77 | [model, modelId, apiConfiguration], |
| 78 | ) |
| 79 | // vscode-lm reports maxTokens: -1 (unlimited); a negative reserve must not distort the window math. |
| 80 | const reservedForOutput = maxTokens && maxTokens > 0 ? maxTokens : 0 |
| 81 | |
| 82 | const condenseButton = ( |
| 83 | <LucideIconButton |
| 84 | title={t("chat:task.condenseContext")} |
| 85 | icon={FoldVertical} |
| 86 | disabled={buttonsDisabled} |
| 87 | onClick={() => currentTaskItem && handleCondenseContext(currentTaskItem.id)} |
| 88 | /> |
| 89 | ) |
| 90 | |
| 91 | const hasTodos = todos && Array.isArray(todos) && todos.length > 0 |
| 92 | |
| 93 | // Determine if this is a subtask (has a parent) |
| 94 | const isSubtask = !!parentTaskId |
| 95 | |
| 96 | const handleBackToParent = () => { |
| 97 | if (parentTaskId) { |
| 98 | vscode.postMessage({ type: "showTaskWithId", text: parentTaskId }) |
| 99 | } |
nothing calls this directly
no test coverage detected