Skip to content

Commit 841c6c7

Browse files
committed
feat: show dash instead of zero for missing data on evals page
1 parent 079b37a commit 841c6c7

File tree

5 files changed

+38
-14
lines changed

5 files changed

+38
-14
lines changed

apps/web-roo-code/src/app/evals/evals.tsx

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,13 @@ export function Evals({
129129
<TableRow key={run.id}>
130130
<TableCell title={run.model?.description}>
131131
<div className="font-sans">{run.label}</div>
132-
<div className="text-xs opacity-50">
133-
{formatTokens(run.modelInfo?.contextWindow ?? 0)}
134-
</div>
132+
<div className="text-xs opacity-50">{formatTokens(run.modelInfo?.contextWindow)}</div>
135133
</TableCell>
136134
<TableCell className="border-r">
137135
<div className="flex flex-row gap-2">
138-
<div>{formatCurrency(run.modelInfo?.inputPrice ?? 0)}</div>
136+
<div>{formatCurrency(run.modelInfo?.inputPrice)}</div>
139137
<div className="opacity-25">/</div>
140-
<div>{formatCurrency(run.modelInfo?.outputPrice ?? 0)}</div>
138+
<div>{formatCurrency(run.modelInfo?.outputPrice)}</div>
141139
</div>
142140
</TableCell>
143141
<TableCell className="font-mono">{formatDuration(run.taskMetrics.duration)}</TableCell>
@@ -150,19 +148,27 @@ export function Evals({
150148
</TableCell>
151149
<TableCell className="border-r">{formatCurrency(run.taskMetrics.cost)}</TableCell>
152150
<TableCell className="text-muted-foreground">
153-
{formatScore(run.languageScores?.go ?? 0)}%
151+
{run.languageScores?.go !== undefined ? `${formatScore(run.languageScores.go)}%` : "-"}
154152
</TableCell>
155153
<TableCell className="text-muted-foreground">
156-
{formatScore(run.languageScores?.java ?? 0)}%
154+
{run.languageScores?.java !== undefined
155+
? `${formatScore(run.languageScores.java)}%`
156+
: "-"}
157157
</TableCell>
158158
<TableCell className="text-muted-foreground">
159-
{formatScore(run.languageScores?.javascript ?? 0)}%
159+
{run.languageScores?.javascript !== undefined
160+
? `${formatScore(run.languageScores.javascript)}%`
161+
: "-"}
160162
</TableCell>
161163
<TableCell className="text-muted-foreground">
162-
{formatScore(run.languageScores?.python ?? 0)}%
164+
{run.languageScores?.python !== undefined
165+
? `${formatScore(run.languageScores.python)}%`
166+
: "-"}
163167
</TableCell>
164168
<TableCell className="text-muted-foreground">
165-
{formatScore(run.languageScores?.rust ?? 0)}%
169+
{run.languageScores?.rust !== undefined
170+
? `${formatScore(run.languageScores.rust)}%`
171+
: "-"}
166172
</TableCell>
167173
<TableCell className="font-bold">{run.score}%</TableCell>
168174
</TableRow>

apps/web-roo-code/src/lib/format-currency.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ const formatter = new Intl.NumberFormat("en-US", {
33
currency: "USD",
44
})
55

6-
export const formatCurrency = (amount: number) => formatter.format(amount)
6+
export const formatCurrency = (amount: number | null | undefined) => {
7+
if (amount === null || amount === undefined) {
8+
return "-"
9+
}
10+
return formatter.format(amount)
11+
}
712

813
export const parsePrice = (price?: string) => (price ? parseFloat(price) * 1_000_000 : undefined)

apps/web-roo-code/src/lib/format-duration.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
export const formatDuration = (durationMs: number) => {
1+
export const formatDuration = (durationMs: number | null | undefined) => {
2+
if (durationMs === null || durationMs === undefined) {
3+
return "-"
4+
}
5+
26
const seconds = Math.floor(durationMs / 1000)
37
const hours = Math.floor(seconds / 3600)
48
const minutes = Math.floor((seconds % 3600) / 60)
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
export const formatScore = (score: number) => Math.round(score * 100)
1+
export const formatScore = (score: number | null | undefined) => {
2+
if (score === null || score === undefined) {
3+
return "-"
4+
}
5+
return Math.round(score * 100)
6+
}

apps/web-roo-code/src/lib/format-tokens.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
export const formatTokens = (tokens: number, decimals = 0) => {
1+
export const formatTokens = (tokens: number | null | undefined, decimals = 0) => {
2+
if (tokens === null || tokens === undefined) {
3+
return "-"
4+
}
5+
26
if (tokens < 1000) {
37
return tokens.toString()
48
}

0 commit comments

Comments
 (0)