@@ -3,12 +3,13 @@ import { useSearchParams } from "react-router";
33import { AnimatePresence , motion } from "motion/react" ;
44import { format , isToday , isYesterday } from "date-fns" ;
55import { useTranslation } from "react-i18next" ;
6+ import type { TFunction } from "i18next" ;
67import { Activity , RefreshCw , Search } from "lucide-react" ;
78import type { Agent , Run , RunStatus , RunTrigger } from "@godmode/shared" ;
89import { useAllAgents , useRuns } from "@/lib/hooks" ;
9- import { dateLocale , t as translate } from "@/i18n" ;
10+ import { dateLocale } from "@/i18n" ;
1011import { errorMessage } from "@/lib/api" ;
11- import { useLive , type LiveRun } from "@/stores/live" ;
12+ import { useLiveRunsMap , type LiveRun } from "@/stores/live" ;
1213import { cn } from "@/lib/utils" ;
1314import { AgentAvatar , EmptyState } from "@/components/common" ;
1415import { Orb } from "@/components/aicss/Orb" ;
@@ -26,16 +27,16 @@ const STATUSES: ("all" | RunStatus)[] = ["all", "running", "paused", "succeeded"
2627
2728const TRIGGERS : RunTrigger [ ] = [ "chat" , "routine" , "check" , "dream" , "delegation" , "task" , "followup" , "heartbeat" , "manual" , "api" ] ;
2829
29- function dayLabel ( d : Date ) {
30- if ( isToday ( d ) ) return translate ( "common:words.today" ) ;
31- if ( isYesterday ( d ) ) return translate ( "common:words.yesterday" ) ;
32- return format ( d , translate ( "activity:dayFormat" ) , { locale : dateLocale ( ) } ) ;
30+ function dayLabel ( d : Date , t : TFunction < [ "activity" , "runs" , "common" ] > ) {
31+ if ( isToday ( d ) ) return t ( "common:words.today" ) ;
32+ if ( isYesterday ( d ) ) return t ( "common:words.yesterday" ) ;
33+ return format ( d , t ( "activity:dayFormat" ) , { locale : dateLocale ( ) } ) ;
3334}
3435
3536/** Every run of every agent, filtered by agent, trigger and outcome; `?run=` opens one. */
3637export function ActivityOverview ( ) {
3738 const reduce = useReduceAnimations ( ) ;
38- const { t, i18n } = useTranslation ( [ "activity" , "runs" , "common" ] ) ;
39+ const { t } = useTranslation ( [ "activity" , "runs" , "common" ] ) ;
3940 const [ params , setParams ] = useSearchParams ( ) ;
4041 const agentFilter = params . get ( "agent" ) ?? "all" ;
4142 const statusFilter = params . get ( "status" ) ?? "all" ;
@@ -46,7 +47,7 @@ export function ActivityOverview() {
4647 const runsQ = useRuns ( agentFilter , statusFilter ) ;
4748 const { data : agents = [ ] } = useAllAgents ( ) ;
4849 const agentById = useMemo ( ( ) => new Map ( agents . map ( ( a ) => [ a . id , a ] ) ) , [ agents ] ) ;
49- const liveRuns = useLive ( ( s ) => s . runs ) ;
50+ const liveRuns = useLiveRunsMap ( ) ;
5051 const liveList = useMemo (
5152 // Working right now; a queued run shows in the list below as queued.
5253 ( ) => Object . values ( liveRuns ) . filter ( ( r ) => r . status === "running" && ( agentFilter === "all" || r . agentId === agentFilter ) ) ,
@@ -75,13 +76,13 @@ export function ActivityOverview() {
7576 const groups = useMemo ( ( ) => {
7677 const out : { label : string ; runs : Run [ ] } [ ] = [ ] ;
7778 for ( const r of runs ) {
78- const label = dayLabel ( new Date ( r . startedAt ?? r . createdAt ) ) ;
79+ const label = dayLabel ( new Date ( r . startedAt ?? r . createdAt ) , t ) ;
7980 const last = out [ out . length - 1 ] ;
8081 if ( last ?. label === label ) last . runs . push ( r ) ;
8182 else out . push ( { label, runs : [ r ] } ) ;
8283 }
8384 return out ;
84- } , [ runs , i18n . language ] ) ;
85+ } , [ runs , t ] ) ;
8586
8687 const successRate = useMemo ( ( ) => {
8788 const finished = runs . filter ( ( r ) => r . status === "succeeded" || r . status === "failed" ) ;
0 commit comments