@@ -2,7 +2,7 @@ import { createFileRoute } from "@tanstack/react-router";
22import { z } from "zod" ;
33import { zodValidator } from "@tanstack/zod-adapter" ;
44import { Link , Outlet , useMatches } from "@tanstack/react-router" ;
5- import { XCircleIcon } from "lucide-react" ;
5+ import { XCircleIcon , Zap } from "lucide-react" ;
66import type * as React from "react" ;
77
88import { DisplayInput } from "~/components/display-input" ;
@@ -19,6 +19,11 @@ import {
1919 TableHeader ,
2020 TableRow ,
2121} from "~/components/ui/table" ;
22+ import {
23+ Tooltip ,
24+ TooltipTrigger ,
25+ TooltipContent ,
26+ } from "~/components/ui/tooltip" ;
2227import { cn } from "~/lib/utils" ;
2328import { formatTime , isArrayOfRenderedColumns } from "~/utils" ;
2429import { useServerStateUtils } from "~/hooks/use-server-state-utils" ;
@@ -65,6 +70,7 @@ type EvalTableRowProps = {
6570 isRunningEval : boolean ;
6671 hasScores : boolean ;
6772 prevSuite : Evalite . SDK . GetSuiteByNameResult [ "prevSuite" ] ;
73+ cacheHitCount : number ;
6874 trialConfig ?: {
6975 isFirstTrial : boolean ;
7076 rowSpan : number ;
@@ -104,17 +110,31 @@ function EvalTableRow({
104110 isRunningEval,
105111 hasScores,
106112 prevSuite : prevEvaluation ,
113+ cacheHitCount,
107114 trialConfig,
108115} : EvalTableRowProps ) {
109116 const Wrapper = useMemo (
110117 ( ) => makeWrapper ( { evalIndex, timestamp, name } ) ,
111118 [ evalIndex , timestamp , name ]
112119 ) ;
120+
113121 return (
114122 < TableRow className = { cn ( "has-[.active]:bg-foreground/20!" ) } >
123+ { cacheHitCount > 0 && (
124+ < TableCell className = "pt-4 pl-4" >
125+ < Tooltip >
126+ < TooltipTrigger asChild >
127+ < Zap className = "size-4 text-accent-foreground" />
128+ </ TooltipTrigger >
129+ < TooltipContent >
130+ { cacheHitCount } cache { cacheHitCount === 1 ? "hit" : "hits" }
131+ </ TooltipContent >
132+ </ Tooltip >
133+ </ TableCell >
134+ ) }
115135 { isArrayOfRenderedColumns ( _eval . rendered_columns ) ? (
116136 < >
117- { _eval . rendered_columns . map ( ( column ) => (
137+ { _eval . rendered_columns . map ( ( column , index ) => (
118138 < TableCell >
119139 < DisplayInput
120140 className = { cn (
@@ -185,15 +205,17 @@ function EvalTableRow({
185205 return (
186206 < TableCell key = { scorer . id } className = { cn ( index === 0 && "border-l" ) } >
187207 < Wrapper >
188- < Score
189- hasScores = { hasScores }
190- score = { scorer . score }
191- state = { getScoreState ( {
192- score : scorer . score ,
193- prevScore : scoreInPreviousEvaluation ?. score ,
194- status : _eval . status ,
195- } ) }
196- />
208+ < div className = "flex items-center gap-2" >
209+ < Score
210+ hasScores = { hasScores }
211+ score = { scorer . score }
212+ state = { getScoreState ( {
213+ score : scorer . score ,
214+ prevScore : scoreInPreviousEvaluation ?. score ,
215+ status : _eval . status ,
216+ } ) }
217+ />
218+ </ div >
197219 </ Wrapper >
198220 </ TableCell >
199221 ) ;
@@ -326,6 +348,10 @@ function SuiteComponent() {
326348 const hasScores =
327349 possiblyRunningSuite . evals . some ( ( r ) => r . scores . length > 0 ) ?? true ;
328350
351+ const doAnyEvalsHaveCacheHits = Object . values (
352+ serverState . cacheHitsByEval
353+ ) . some ( ( hits ) => hits > 0 ) ;
354+
329355 return (
330356 < >
331357 < title > { `${ name } | Evalite` } </ title >
@@ -474,6 +500,7 @@ function SuiteComponent() {
474500 < Table >
475501 < TableHeader >
476502 < TableRow >
503+ { doAnyEvalsHaveCacheHits && < TableHead > </ TableHead > }
477504 { isArrayOfRenderedColumns (
478505 evaluationWithoutLayoutShift . evals [ 0 ] ?. rendered_columns
479506 ) ? (
@@ -512,6 +539,8 @@ function SuiteComponent() {
512539 group . evals . map ( ( _eval , trialIndex ) => {
513540 const evalIndex =
514541 evaluationWithoutLayoutShift ! . evals . indexOf ( _eval ) ;
542+ const cacheHitCount =
543+ serverState . cacheHitsByEval [ _eval . id ] ?? 0 ;
515544 return (
516545 < EvalTableRow
517546 key = { `${ JSON . stringify ( _eval . input ) } -${ _eval . trial_index } ` }
@@ -523,6 +552,7 @@ function SuiteComponent() {
523552 isRunningEval = { isRunningEval }
524553 hasScores = { hasScores }
525554 prevSuite = { prevSuite }
555+ cacheHitCount = { cacheHitCount }
526556 trialConfig = { {
527557 isFirstTrial : trialIndex === 0 ,
528558 rowSpan : group . evals . length ,
@@ -533,19 +563,24 @@ function SuiteComponent() {
533563 } )
534564 )
535565 : // Original rendering for non-trial results
536- evaluationWithoutLayoutShift . evals . map ( ( _eval , index ) => (
537- < EvalTableRow
538- key = { JSON . stringify ( _eval . input ) }
539- eval = { _eval }
540- evalIndex = { index }
541- name = { name }
542- timestamp = { timestamp }
543- showExpectedColumn = { showExpectedColumn }
544- isRunningEval = { isRunningEval }
545- hasScores = { hasScores }
546- prevSuite = { prevSuite }
547- />
548- ) ) }
566+ evaluationWithoutLayoutShift . evals . map ( ( _eval , index ) => {
567+ const cacheHitCount =
568+ serverState . cacheHitsByEval [ _eval . id ] ?? 0 ;
569+ return (
570+ < EvalTableRow
571+ key = { JSON . stringify ( _eval . input ) }
572+ eval = { _eval }
573+ evalIndex = { index }
574+ name = { name }
575+ timestamp = { timestamp }
576+ showExpectedColumn = { showExpectedColumn }
577+ isRunningEval = { isRunningEval }
578+ hasScores = { hasScores }
579+ prevSuite = { prevSuite }
580+ cacheHitCount = { cacheHitCount }
581+ />
582+ ) ;
583+ } ) }
549584 </ TableBody >
550585 </ Table >
551586 </ >
0 commit comments