@@ -18,7 +18,7 @@ import InfoView from './components/InfoView';
1818import UpdateNotification from './components/UpdateNotification' ;
1919import CreateFromTemplateModal from './components/CreateFromTemplateModal' ;
2020import DocumentHistoryView from './components/PromptHistoryView' ;
21- import FolderOverview , { FolderOverviewMetrics , FolderSearchResult , RecentDocumentSummary } from './components/FolderOverview' ;
21+ import FolderOverview , { type FolderOverviewMetrics , type FolderSearchResult , type RecentDocumentSummary , type DocTypeCount , type LanguageCount } from './components/FolderOverview' ;
2222import { PlusIcon , FolderPlusIcon , TrashIcon , GearIcon , InfoIcon , TerminalIcon , DocumentDuplicateIcon , PencilIcon , CopyIcon , CommandIcon , CodeIcon , FolderDownIcon , FormatIcon , SparklesIcon } from './components/Icons' ;
2323import AboutModal from './components/AboutModal' ;
2424import Header from './components/Header' ;
@@ -27,7 +27,7 @@ import ConfirmModal from './components/ConfirmModal';
2727import FatalError from './components/FatalError' ;
2828import ContextMenu , { MenuItem } from './components/ContextMenu' ;
2929import NewCodeFileModal from './components/NewCodeFileModal' ;
30- import type { DocumentOrFolder , Command , LogMessage , DiscoveredLLMModel , DiscoveredLLMService , Settings , DocumentTemplate , ViewMode } from './types' ;
30+ import type { DocumentOrFolder , Command , LogMessage , DiscoveredLLMModel , DiscoveredLLMService , Settings , DocumentTemplate , ViewMode , DocType } from './types' ;
3131import { IconProvider } from './contexts/IconContext' ;
3232import { storageService } from './services/storageService' ;
3333import { llmDiscoveryService } from './services/llmDiscoveryService' ;
@@ -371,6 +371,55 @@ const MainApp: React.FC = () => {
371371 return node . type === 'folder' ? 'Untitled Folder' : 'Untitled Document' ;
372372 } ;
373373
374+ const toTitleCase = ( value : string ) => {
375+ return value
376+ . split ( / [ - _ \s ] + / )
377+ . filter ( Boolean )
378+ . map ( part => part . charAt ( 0 ) . toUpperCase ( ) + part . slice ( 1 ) )
379+ . join ( ' ' ) ;
380+ } ;
381+
382+ const addDocTypeCount = ( map : Map < DocType , number > , docType : DocType ) => {
383+ map . set ( docType , ( map . get ( docType ) ?? 0 ) + 1 ) ;
384+ } ;
385+
386+ const addLanguageCount = (
387+ map : Map < string , { label : string ; count : number } > ,
388+ value ?: string | null ,
389+ ) => {
390+ const trimmed = ( value ?? '' ) . trim ( ) ;
391+ const key = trimmed ? trimmed . toLowerCase ( ) : 'unknown' ;
392+ const label = trimmed ? toTitleCase ( trimmed ) : 'Unknown' ;
393+ const existing = map . get ( key ) ;
394+ if ( existing ) {
395+ existing . count += 1 ;
396+ } else {
397+ map . set ( key , { label, count : 1 } ) ;
398+ }
399+ } ;
400+
401+ const finalizeDocTypeCounts = ( map : Map < DocType , number > ) : DocTypeCount [ ] =>
402+ Array . from ( map . entries ( ) )
403+ . map ( ( [ type , count ] ) => ( { type, count } ) )
404+ . sort ( ( a , b ) => {
405+ if ( a . count !== b . count ) {
406+ return b . count - a . count ;
407+ }
408+ return a . type . localeCompare ( b . type ) ;
409+ } ) ;
410+
411+ const finalizeLanguageCounts = (
412+ map : Map < string , { label : string ; count : number } > ,
413+ ) : LanguageCount [ ] =>
414+ Array . from ( map . values ( ) )
415+ . map ( ( { label, count } ) => ( { label, count } ) )
416+ . sort ( ( a , b ) => {
417+ if ( a . count !== b . count ) {
418+ return b . count - a . count ;
419+ }
420+ return a . label . localeCompare ( b . label ) ;
421+ } ) ;
422+
374423 const computeFromTree = ( folderNode : DocumentNode ) => {
375424 const recordLatest = ( ( ) => {
376425 let latest : Date | null = null ;
@@ -400,17 +449,24 @@ const MainApp: React.FC = () => {
400449 parentPath : [ ] ,
401450 } ) ) ;
402451 const allDocuments : RecentDocumentSummary [ ] = [ ] ;
452+ const docTypeMap = new Map < DocType , number > ( ) ;
453+ const languageMap = new Map < string , { label : string ; count : number } > ( ) ;
403454
404455 while ( stack . length > 0 ) {
405456 const { node : current , parentPath } = stack . pop ( ) ! ;
406457 recordLatest . update ( current . updatedAt ) ;
407458 if ( current . type === 'document' ) {
408459 totalDocumentCount += 1 ;
460+ const docType = ( current . doc_type ?? 'prompt' ) as DocType ;
461+ addDocTypeCount ( docTypeMap , docType ) ;
462+ addLanguageCount ( languageMap , current . language_hint ) ;
409463 allDocuments . push ( {
410464 id : current . id ,
411465 title : current . title ,
412466 updatedAt : current . updatedAt ,
413467 parentPath,
468+ docType,
469+ languageHint : current . language_hint ?? null ,
414470 } ) ;
415471 } else if ( current . type === 'folder' ) {
416472 totalFolderCount += 1 ;
@@ -438,6 +494,8 @@ const MainApp: React.FC = () => {
438494 totalItemCount : totalDocumentCount + totalFolderCount ,
439495 lastUpdated : latestDate ? latestDate . toISOString ( ) : null ,
440496 recentDocuments,
497+ docTypeCounts : finalizeDocTypeCounts ( docTypeMap ) ,
498+ languageCounts : finalizeLanguageCounts ( languageMap ) ,
441499 } ,
442500 documents : allDocuments ,
443501 } ;
@@ -486,17 +544,24 @@ const MainApp: React.FC = () => {
486544 parentPath : [ ] ,
487545 } ) ) ;
488546 const allDocuments : RecentDocumentSummary [ ] = [ ] ;
547+ const docTypeMap = new Map < DocType , number > ( ) ;
548+ const languageMap = new Map < string , { label : string ; count : number } > ( ) ;
489549
490550 while ( stack . length > 0 ) {
491551 const { node : current , parentPath } = stack . pop ( ) ! ;
492552 recordLatest . update ( current . updatedAt ) ;
493553 if ( current . type === 'document' ) {
494554 totalDocumentCount += 1 ;
555+ const docType = ( current . doc_type ?? 'prompt' ) as DocType ;
556+ addDocTypeCount ( docTypeMap , docType ) ;
557+ addLanguageCount ( languageMap , current . language_hint ) ;
495558 allDocuments . push ( {
496559 id : current . id ,
497560 title : current . title ,
498561 updatedAt : current . updatedAt ,
499562 parentPath,
563+ docType,
564+ languageHint : current . language_hint ?? null ,
500565 } ) ;
501566 } else {
502567 totalFolderCount += 1 ;
@@ -524,6 +589,8 @@ const MainApp: React.FC = () => {
524589 totalItemCount : totalDocumentCount + totalFolderCount ,
525590 lastUpdated : latestDate ? latestDate . toISOString ( ) : null ,
526591 recentDocuments,
592+ docTypeCounts : finalizeDocTypeCounts ( docTypeMap ) ,
593+ languageCounts : finalizeLanguageCounts ( languageMap ) ,
527594 } ,
528595 documents : allDocuments ,
529596 } ;
@@ -1493,6 +1560,8 @@ const MainApp: React.FC = () => {
14931560 totalItemCount : 0 ,
14941561 lastUpdated : activeNode . updatedAt ,
14951562 recentDocuments : [ ] ,
1563+ docTypeCounts : [ ] ,
1564+ languageCounts : [ ] ,
14961565 } ;
14971566 return (
14981567 < FolderOverview
0 commit comments