Skip to content

Commit a458609

Browse files
committed
Refactor: Update TaskCostChartSection to work with extracted costUtils
- Ensures TaskCostChartSection works with the new costHistory calculation utility - Part of the cost calculation extraction refactoring
1 parent 74b9288 commit a458609

File tree

1 file changed

+10
-23
lines changed

1 file changed

+10
-23
lines changed

webview-ui/src/components/chat/TaskCostChartSection.tsx

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -87,21 +87,7 @@ const TaskCostChartSection: React.FC<TaskCostChartSectionProps> = ({ costHistory
8787
return t("chat:task.tokensOutChartTitle", "Output Tokens")
8888
case "costDelta":
8989
default:
90-
return t("chat:task.requestCostChartTitle", "Request Cost")
91-
}
92-
}
93-
94-
const getSingleChartTitle = (type: ChartType): string => {
95-
switch (type) {
96-
case "cumulativeCost":
97-
return t("chat:task.totalCostChartTitle", "Total Cost:")
98-
case "tokensIn":
99-
return t("chat:task.tokensInChartTitle", "Input Tokens:")
100-
case "tokensOut":
101-
return t("chat:task.tokensOutChartTitle", "Output Tokens:")
102-
case "costDelta":
103-
default:
104-
return t("chat:task.requestCostChartTitle", "Request Cost:")
90+
return t("chat:task.requestCostChartTitle", "Request Cost") // Grid view title remains without colon
10591
}
10692
}
10793

@@ -168,29 +154,30 @@ const TaskCostChartSection: React.FC<TaskCostChartSectionProps> = ({ costHistory
168154
return null
169155
}
170156

157+
// Determine the title based on the view type, adding colon for single view
171158
const displayTitle =
172159
selectedChartType === "gridView"
173160
? t("chat:task.costOverviewTitle", "Cost Overview")
174-
: getSingleChartTitle(selectedChartType)
161+
: `${getChartTitle(selectedChartType)}:` // Use grid title function and add colon
175162

176163
return (
177164
<div className="flex flex-col" onMouseLeave={handleMouseLeaveSection}>
165+
{/* Single Chart View Header */}
178166
{selectedChartType !== "gridView" && (
179167
<div className="flex items-center h-[24px] mb-2">
180-
{" "}
181168
<div className="flex items-center gap-1 flex-grow min-w-0">
182-
{" "}
183169
<span className="font-bold whitespace-nowrap overflow-hidden text-ellipsis flex-shrink min-w-0">
184-
{" "}
185170
{displayTitle}
186171
</span>
172+
{/* Updated Hover Text Format for Single View */}
187173
{chartHoverData?.isHovering &&
188174
chartHoverData.index !== undefined &&
189175
chartHoverData.value !== undefined &&
190176
chartHoverData.type !== undefined && (
191-
<span className="truncate flex-shrink-0 ml-1 text-vscode-descriptionForeground">
177+
<span className="truncate flex-shrink-0 text-vscode-descriptionForeground">
192178
{" "}
193-
{`${t("chat:task.requestShort", "Request {{index}}:", { index: chartHoverData.index })} ${formatHoverValue(chartHoverData.type, chartHoverData.value)}`}
179+
{/* Removed ml-1 */}
180+
{`${formatHoverValue(chartHoverData.type, chartHoverData.value)} : ${t("chat:task.requestShort", "Request {{index}}", { index: chartHoverData.index })}`}
194181
</span>
195182
)}
196183
</div>
@@ -236,8 +223,8 @@ const TaskCostChartSection: React.FC<TaskCostChartSectionProps> = ({ costHistory
236223
value = dataPoint.tokensOut || 0
237224
break
238225
}
239-
const requestText = `: ${chartHoverData.index}`
240-
hoverValueDisplay = `${formatHoverValue(type, value)} ${requestText}`
226+
// Corrected Hover Text Format for Grid View: value : index
227+
hoverValueDisplay = `${formatHoverValue(type, value)} : ${chartHoverData.index}`
241228
}
242229
}
243230

0 commit comments

Comments
 (0)