@@ -71,34 +71,18 @@ function groupMessages( messages: Message[] ): TranscriptItem[] {
7171
7272function computeChatLabels ( chats : ChatMeta [ ] ) : Map < string , string > {
7373 const labels = new Map < string , string > ( ) ;
74- const untitledByKind = new Map < ChatMeta [ 'kind' ] , number > ( ) ;
75- for ( const c of chats ) {
76- if ( c . title ) {
77- continue ;
78- }
79- untitledByKind . set ( c . kind , ( untitledByKind . get ( c . kind ) ?? 0 ) + 1 ) ;
80- }
81- const seenByKind = new Map < ChatMeta [ 'kind' ] , number > ( ) ;
74+ const untitledTotal = chats . filter ( ( c ) => ! c . title ) . length ;
75+ let untitledSeen = 0 ;
8276 for ( const c of chats ) {
8377 if ( c . title ) {
8478 labels . set ( c . id , c . title ) ;
8579 continue ;
8680 }
87- const kindBase : Record < ChatMeta [ 'kind' ] , string > = {
88- general : 'Untitled' ,
89- ...Object . fromEntries (
90- CHAT_ACTIONS . map ( ( a ) => [ a . id , a . chatTitle ] )
91- ) ,
92- } as Record < ChatMeta [ 'kind' ] , string > ;
93- const base = kindBase [ c . kind ] ;
94- const total = untitledByKind . get ( c . kind ) ?? 1 ;
95- if ( total === 1 ) {
96- labels . set ( c . id , base ) ;
97- } else {
98- const idx = ( seenByKind . get ( c . kind ) ?? 0 ) + 1 ;
99- seenByKind . set ( c . kind , idx ) ;
100- labels . set ( c . id , `${ base } ${ idx } ` ) ;
101- }
81+ untitledSeen += 1 ;
82+ labels . set (
83+ c . id ,
84+ untitledTotal === 1 ? 'Untitled' : `Untitled ${ untitledSeen } `
85+ ) ;
10286 }
10387 return labels ;
10488}
0 commit comments