@@ -22,16 +22,39 @@ import { Skeleton } from '@/components/ui/skeleton';
2222import { useInfiniteTasks } from '@/hooks/use-tasks' ;
2323import { cn } from '@/lib/utils' ;
2424
25- import type { Task } from 'agentex/resources' ;
25+ import type { TaskListResponse } from 'agentex/resources' ;
2626
2727type TaskButtonProps = {
28- task : Task ;
29- selectedTaskID : Task [ 'id' ] | null ;
30- selectTask : ( taskID : Task [ 'id' ] | null ) => void ;
28+ task : TaskListResponse . TaskListResponseItem ;
29+ selectedTaskID : TaskListResponse . TaskListResponseItem [ 'id' ] | null ;
30+ selectTask : (
31+ taskID : TaskListResponse . TaskListResponseItem [ 'id' ] | null
32+ ) => void ;
3133} ;
3234
3335function TaskButton ( { task, selectedTaskID, selectTask } : TaskButtonProps ) {
3436 const taskName = createTaskName ( task ) ;
37+ const createdAtString = useMemo (
38+ ( ) =>
39+ task . created_at
40+ ? formatDistanceToNow ( new Date ( task . created_at ) , {
41+ addSuffix : true ,
42+ } )
43+ : 'No date' ,
44+ [ task . created_at ]
45+ ) ;
46+ const agentsString = useMemo ( ( ) => {
47+ if ( ! task . agents || task . agents . length === 0 ) return 'No agents' ;
48+
49+ const firstAgent = task . agents [ 0 ] ;
50+ if ( ! firstAgent ) return 'No agents' ;
51+
52+ if ( task . agents . length === 1 ) {
53+ return firstAgent . name ;
54+ }
55+
56+ return `${ firstAgent . name } + ${ task . agents . length - 1 } more` ;
57+ } , [ task . agents ] ) ;
3558
3659 return (
3760 < motion . div
@@ -69,27 +92,29 @@ function TaskButton({ task, selectedTaskID, selectTask }: TaskButtonProps) {
6992 } }
7093 >
7194 < span className = "w-full truncate text-sm" > { taskName } </ span >
72- < span
95+ < div
7396 className = { cn (
74- 'text-muted-foreground text-xs' ,
75- task . created_at ? 'block' : 'invisible'
97+ 'text-muted-foreground w-full truncate text-xs' ,
98+ ( task . agents && task . agents . length > 0 ) || task . created_at
99+ ? 'block'
100+ : 'invisible'
76101 ) }
77102 >
78- { task . created_at
79- ? formatDistanceToNow ( new Date ( task . created_at ) , {
80- addSuffix : true ,
81- } )
82- : 'No date' }
83- </ span >
103+ { createdAtString }
104+ { task . agents && task . agents . length > 0 && task . created_at && ' • ' }
105+ { agentsString }
106+ </ div >
84107 </ Button >
85108 </ motion . div >
86109 ) ;
87110}
88111
89112export type TaskSidebarProps = {
90- selectedTaskID : Task [ 'id' ] | null ;
113+ selectedTaskID : TaskListResponse . TaskListResponseItem [ 'id' ] | null ;
91114 selectedAgentName ?: string ;
92- onSelectTask : ( taskID : Task [ 'id' ] | null ) => void ;
115+ onSelectTask : (
116+ taskID : TaskListResponse . TaskListResponseItem [ 'id' ] | null
117+ ) => void ;
93118} ;
94119
95120export function TaskSidebar ( {
@@ -138,7 +163,7 @@ export function TaskSidebar({
138163 } , [ hasNextPage , isFetchingNextPage , fetchNextPage ] ) ;
139164
140165 const handleTaskSelect = useCallback (
141- ( taskID : Task [ 'id' ] | null ) => {
166+ ( taskID : TaskListResponse . TaskListResponseItem [ 'id' ] | null ) => {
142167 onSelectTask ( taskID ) ;
143168 } ,
144169 [ onSelectTask ]
@@ -265,7 +290,7 @@ function SidebarHeader({
265290 ) ;
266291}
267292
268- function createTaskName ( task : Task ) : string {
293+ function createTaskName ( task : TaskListResponse . TaskListResponseItem ) : string {
269294 if (
270295 task ?. params ?. description &&
271296 typeof task . params . description === 'string'
0 commit comments