Skip to content

The open-source agent harness - the runtime layer that turns an LLM into a working agent.

Enhance agent metric chart styling (#654)

harshil-20960e01eba8bcdb
diff --git a/.changeset/pre/agent-metric-chart-styling.md b/.changeset/pre/agent-metric-chart-styling.md
new file mode 100644
index 000000000..fb521717d
--- /dev/null
+++ b/.changeset/pre/agent-metric-chart-styling.md
@@ -0,0 +1,5 @@
+---
+'@truefoundry/trueforge-ui': patch
+---
+
+Polish metric charts with sharp dot-free lines, distinct series colors, and a quieter Metrics tab background.
diff --git a/packages/trueforge-ui/src/atoms/agent-details/AgentMetricChart.tsx b/packages/trueforge-ui/src/atoms/agent-details/AgentMetricChart.tsx
index 279fbde3f..84ab20a50 100644
--- a/packages/trueforge-ui/src/atoms/agent-details/AgentMetricChart.tsx
+++ b/packages/trueforge-ui/src/atoms/agent-details/AgentMetricChart.tsx
@@ -20,8 +20,8 @@ import type { AgentMetricChartProps } from './types.js';
ChartJS.register(CategoryScale, LinearScale, LineElement, PointElement, Legend, Tooltip);
-const LIGHT_COLORS = ['#2563eb', '#16a34a', '#9333ea', '#ea580c', '#0891b2'];
-const DARK_COLORS = ['#60a5fa', '#4ade80', '#c084fc', '#fb923c', '#22d3ee'];
+const LIGHT_COLORS = ['#6366F1', '#2563eb', '#0EA5E9'];
+const DARK_COLORS = ['#6366F1', '#60a5fa', '#38BDF8'];
const numberFormatter = new Intl.NumberFormat(undefined, { maximumFractionDigits: 4 });
const timestampFormatter = new Intl.DateTimeFormat(undefined, {
month: 'short',
@@ -41,10 +41,10 @@ function formatTimestamp(timestamp: string): string {
return Number.isNaN(date.getTime()) ? timestamp : timestampFormatter.format(date);
}
-export function AgentMetricChart({ graph, definition, error }: AgentMetricChartProps) {
+export function AgentMetricChart({ graph, definition, error, colorIndex = 0 }: AgentMetricChartProps) {
const mode = useThemeMode();
const colors = mode === 'dark' ? DARK_COLORS : LIGHT_COLORS;
- const axisColor = mode === 'dark' ? '#a1a1aa' : '#71717a';
+ const axisColor = mode === 'dark' ? '#71717a' : '#a1a1aa';
const gridColor = mode === 'dark' ? '#27272a' : '#e4e4e7';
const labels = useMemo(
() =>
@@ -59,21 +59,23 @@ export function AgentMetricChart({ graph, definition, error }: AgentMetricChartP
datasets:
graph?.graphLines.map((line, index) => {
const valuesByTimestamp = new Map(line.values.map(point => [point.timestamp, point.value]));
- const color = colors[index % colors.length];
+ const color = colors[(colorIndex + index) % colors.length];
return {
label: line.name,
data: labels.map(timestamp => valuesByTimestamp.get(timestamp) ?? null),
borderColor: color,
backgroundColor: color,
- pointRadius: 2,
- pointHoverRadius: 4,
+ pointRadius: 0,
+ pointHoverRadius: 0,
borderWidth: 2,
- tension: 0.25,
+ borderCapStyle: 'butt',
+ borderJoinStyle: 'miter',
+ tension: 0,
spanGaps: true,
};
}) ?? [],
}),
- [colors, graph, labels],
+ [colorIndex, colors, graph, labels],
);
const options = useMemo<ChartOptions<'line'>>(
() => ({
diff --git a/packages/trueforge-ui/src/atoms/agent-details/AgentMetricsView.tsx b/packages/trueforge-ui/src/atoms/agent-details/AgentMetricsView.tsx
index 9b98c55bd..37b8efe5e 100644
--- a/packages/trueforge-ui/src/atoms/agent-details/AgentMetricsView.tsx
+++ b/packages/trueforge-ui/src/atoms/agent-details/AgentMetricsView.tsx
@@ -4,7 +4,7 @@ import type { ComponentType } from 'react';
import { useSlot } from '../../theme/SlotsProvider.js';
import { Skeleton } from '../primitives/Skeleton.js';
-import type { AgentMetricsViewProps } from './types.js';
+import type { AgentMetricChartProps, AgentMetricsViewProps } from './types.js';
export function AgentMetricsView({
meters,
@@ -20,7 +20,7 @@ export function AgentMetricsView({
const AgentMetricsTimeRangeFilter = useSlot('AgentMetricsTimeRangeFilter');
return (
- <div className="min-h-0 flex-1 overflow-auto p-4" data-slot="agent-metrics-view">
+ <div className="min-h-0 flex-1 overflow-auto bg-secondary-bg/40 p-4" data-slot="agent-metrics-view">
<div className="mb-4 flex justify-end">
<AgentMetricsTimeRangeFilter timeRange={timeRange} onTimeRangeChange={onTimeRangeChange} />
</div>
@@ -63,18 +63,21 @@ export function AgentMetricsView({
</div>
) : (
<div className="grid gap-4 lg:grid-cols-2">
- {charts.flatMap(chart =>
- chart.graphs != null && chart.graphs.length > 0
- ? chart.graphs.map(graph => (
- <AgentMetricChart
- key={`${chart.definition.name}:${graph.name}`}
- definition={chart.definition}
- graph={graph}
- error={chart.error}
- />
- ))
- : [<AgentMetricChart key={chart.definition.name} definition={chart.definition} error={chart.error} />],
- )}
+ {charts
+ .flatMap<AgentMetricChartProps>(chart =>
+ chart.graphs != null && chart.graphs.length > 0
+ ? chart.graphs.map(graph => ({ definition: chart.definition, graph, error: chart.error }))
+ : [{ definition: chart.definition, error: chart.error }],
+ )
+ .map(({ definition, graph, error }, colorIndex) => (
+ <AgentMetricChart
+ key={graph == null ? definition.name : `${definition.name}:${graph.name}`}
+ definition={definition}
+ error={error}
+ colorIndex={colorIndex}
+ {...(graph == null ? {} : { graph })}
+ />
+ ))}
</div>
)}
</div>
diff --git a/packages/trueforge-ui/src/atoms/agent-details/types.ts b/packages/trueforge-ui/src/atoms/agent-details/types.ts
index c6aca6073..1005ae4cb 100644
--- a/packages/trueforge-ui/src/atoms/agent-details/types.ts
+++ b/packages/trueforge-ui/src/atoms/agent-details/types.ts
@@ -131,6 +131,7 @@ export type AgentMetricChartProps = {
graph?: AgentMetricGraph;
definition: AgentMetricChartDefinition;
error?: string;
+ colorIndex?: number;
};
export type AgentOverviewProps = {