Skip to content

Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.

fix(studio): prevent token chart axis label clipping (#4105)

Axiomoth6e944cc3e148
diff --git a/web-studio/src/routes/home/-components/token-trend-chart.test.tsx b/web-studio/src/routes/home/-components/token-trend-chart.test.tsx
new file mode 100644
index 000000000..1697e65b5
--- /dev/null
+++ b/web-studio/src/routes/home/-components/token-trend-chart.test.tsx
@@ -0,0 +1,45 @@
+// @vitest-environment jsdom
+
+import type { PropsWithChildren } from 'react'
+import { cleanup, render, screen } from '@testing-library/react'
+import { afterEach, describe, expect, it, vi } from 'vitest'
+
+import type { HomeT } from '../-types/dashboard'
+import { TokenTrendChart } from './token-trend-chart'
+
+vi.mock('recharts', () => ({
+ Area: () => null,
+ AreaChart: ({ children }: PropsWithChildren) => <svg>{children}</svg>,
+ CartesianGrid: () => null,
+ ResponsiveContainer: ({ children }: PropsWithChildren) => <>{children}</>,
+ Tooltip: () => null,
+ XAxis: () => null,
+ YAxis: ({ width }: { width?: number | 'auto' }) => (
+ <g data-testid="token-trend-y-axis" data-width={width} />
+ ),
+}))
+
+afterEach(cleanup)
+
+describe('TokenTrendChart', () => {
+ it('lets the Y-axis fit million-scale labels without clipping', () => {
+ render(
+ <TokenTrendChart
+ items={[
+ {
+ date: '2026-08-18',
+ embedding_input: 1_411_688,
+ total: 26_946_050,
+ vlm_input: 21_445_905,
+ vlm_output: 4_088_457,
+ },
+ ]}
+ t={((key: string) => key) as HomeT}
+ />,
+ )
+
+ expect(
+ screen.getByTestId('token-trend-y-axis').getAttribute('data-width'),
+ ).toBe('auto')
+ })
+})
diff --git a/web-studio/src/routes/home/-components/token-trend-chart.tsx b/web-studio/src/routes/home/-components/token-trend-chart.tsx
index 98ebc70be..f91550afb 100644
--- a/web-studio/src/routes/home/-components/token-trend-chart.tsx
+++ b/web-studio/src/routes/home/-components/token-trend-chart.tsx
@@ -112,7 +112,7 @@ export function TokenTrendChart({
tick={{ fill: 'currentColor', fontSize: 12 }}
tickFormatter={(value) => Number(value).toLocaleString()}
tickLine={false}
- width={64}
+ width="auto"
/>
<Tooltip
cursor={{ stroke: 'currentColor', strokeOpacity: 0.12 }}