@@ -6,27 +6,68 @@ export async function formatSessionList(sessions: SessionMetadata[]): Promise<st
66 return "No sessions found."
77 }
88
9- const infos : SessionInfo [ ] = [ ]
9+ interface EnrichedInfo extends SessionInfo {
10+ preview ?: string
11+ files ?: number
12+ additions ?: number
13+ deletions ?: number
14+ }
15+
16+ const infos : EnrichedInfo [ ] = [ ]
1017 for ( const meta of sessions ) {
1118 const info = await getSessionInfo ( meta . id )
1219 if ( info ) {
13- info . title = meta . title
14- infos . push ( info )
20+ const enriched : EnrichedInfo = {
21+ ...info ,
22+ title : meta . title ,
23+ preview : meta . preview ,
24+ files : meta . summary ?. files ,
25+ additions : meta . summary ?. additions ,
26+ deletions : meta . summary ?. deletions ,
27+ }
28+ infos . push ( enriched )
1529 }
1630 }
1731
1832 if ( infos . length === 0 ) {
1933 return "No valid sessions found."
2034 }
2135
22- const headers = [ "Session ID" , "Title" , "Messages" , "First" , "Last" , "Agents" ]
36+ const formatDateTime = ( date : Date | undefined ) : string => {
37+ if ( ! date ) return "N/A"
38+ const d = date . toISOString ( ) . split ( "T" )
39+ const time = d [ 1 ] . substring ( 0 , 5 )
40+ return `${ d [ 0 ] } ${ time } `
41+ }
42+
43+ const formatChanges = ( info : EnrichedInfo ) : string => {
44+ if ( info . files === undefined ) return "-"
45+ const parts : string [ ] = [ ]
46+ if ( info . files > 0 ) parts . push ( `${ info . files } F` )
47+ if ( info . additions && info . additions > 0 ) parts . push ( `+${ info . additions } ` )
48+ if ( info . deletions && info . deletions > 0 ) parts . push ( `-${ info . deletions } ` )
49+ return parts . length > 0 ? parts . join ( "/" ) : "-"
50+ }
51+
52+ const getDisplayTitle = ( info : EnrichedInfo ) : string => {
53+ if ( info . title && info . title . trim ( ) ) return truncate ( info . title , 30 )
54+ if ( info . preview ) return truncate ( info . preview , 30 )
55+ return "(untitled)"
56+ }
57+
58+ const truncate = ( str : string , maxLen : number ) : string => {
59+ if ( str . length <= maxLen ) return str
60+ return str . substring ( 0 , maxLen - 3 ) + "..."
61+ }
62+
63+ const headers = [ "Session ID" , "Title/Preview" , "Msgs" , "Updated" , "Changes" , "Agents" ]
2364 const rows = infos . map ( ( info ) => [
2465 info . id ,
25- info . title ?? "(untitled)" ,
66+ getDisplayTitle ( info ) ,
2667 info . message_count . toString ( ) ,
27- info . first_message ?. toISOString ( ) . split ( "T" ) [ 0 ] ?? "N/A" ,
28- info . last_message ?. toISOString ( ) . split ( "T" ) [ 0 ] ?? "N/A" ,
29- info . agents_used . join ( ", " ) || "none" ,
68+ formatDateTime ( info . last_message ) ,
69+ formatChanges ( info ) ,
70+ truncate ( info . agents_used . join ( ", " ) || "none" , 20 ) ,
3071 ] )
3172
3273 const colWidths = headers . map ( ( h , i ) => Math . max ( h . length , ...rows . map ( ( r ) => r [ i ] . length ) ) )
0 commit comments