Skip to content

Commit 6caa57b

Browse files
committed
Refactor: Clean up chart components state and styles
1 parent 5057411 commit 6caa57b

File tree

2 files changed

+3
-27
lines changed

2 files changed

+3
-27
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ const CostTrendChart: React.FC<CostTrendChartProps> = ({
160160
},
161161
ticks: {
162162
show: showXAxis,
163-
stroke: resolvedStyles.widgetBorder,
163+
stroke: resolvedStyles.tabsBorder, // Use grid color for ticks
164164
width: 1 / (window.devicePixelRatio || 1),
165165
size: 10,
166166
},
@@ -189,7 +189,7 @@ const CostTrendChart: React.FC<CostTrendChartProps> = ({
189189
},
190190
ticks: {
191191
show: showYAxis,
192-
stroke: resolvedStyles.widgetBorder,
192+
stroke: resolvedStyles.tabsBorder, // Use grid color for ticks
193193
width: 1 / (window.devicePixelRatio || 1),
194194
size: 10,
195195
},

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

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useCallback, useMemo, useRef, useEffect } from "react"
1+
import React, { useState, useCallback, useMemo, useRef } from "react"
22
import { useTranslation } from "react-i18next"
33
import CostTrendChart from "./CostTrendChart"
44
import {} from "@src/components/ui"
@@ -19,8 +19,6 @@ interface TaskCostChartSectionProps {
1919

2020
export type ChartType = "costDelta" | "cumulativeCost" | "tokensIn" | "tokensOut" | "gridView"
2121

22-
const NARROW_THRESHOLD_PX = 300
23-
2422
const TaskCostChartSection: React.FC<TaskCostChartSectionProps> = ({ costHistory }) => {
2523
const { t } = useTranslation()
2624
const [selectedChartType, setSelectedChartType] = useState<ChartType>("gridView")
@@ -31,30 +29,8 @@ const TaskCostChartSection: React.FC<TaskCostChartSectionProps> = ({ costHistory
3129
value?: number
3230
type?: ChartType
3331
} | null>(null)
34-
const [_isNarrow, setIsNarrow] = useState(false)
3532
const gridContainerRef = useRef<HTMLDivElement>(null)
3633

37-
useEffect(() => {
38-
const container = gridContainerRef.current
39-
if (!container) return
40-
41-
const observer = new ResizeObserver((entries) => {
42-
for (let entry of entries) {
43-
const width = entry.contentBoxSize?.[0]?.inlineSize ?? entry.contentRect.width
44-
setIsNarrow(width < NARROW_THRESHOLD_PX)
45-
}
46-
})
47-
48-
observer.observe(container)
49-
50-
const initialWidth = container.getBoundingClientRect().width
51-
setIsNarrow(initialWidth < NARROW_THRESHOLD_PX)
52-
53-
return () => {
54-
observer.disconnect()
55-
}
56-
}, [selectedChartType])
57-
5834
const handleChartHoverChange = useCallback(
5935
(
6036
hoverData: { isHovering: boolean; index?: number; yValue?: number } | null,

0 commit comments

Comments
 (0)