@@ -44,11 +44,16 @@ export class RequestLogTree extends Disposable implements IExtensionContribution
4444
4545 let server : RequestServer | undefined ;
4646
47- const getExportableLogEntries = ( treeItem : ChatPromptItem ) : LoggedInfo [ ] => {
47+ const getExportableLogEntries = ( treeItem : ChatPromptItem , lastChatRequestItem ?: ChatRequestItem ) : LoggedInfo [ ] => {
4848 if ( ! treeItem || ! treeItem . children ) {
4949 return [ ] ;
5050 }
5151
52+ // lastChatRequestItem logs the actual request info, so use it if present
53+ if ( lastChatRequestItem && treeItem . children . length > 0 && treeItem . children [ 0 ] instanceof ChatRequestItem ) {
54+ treeItem . children [ 0 ] = lastChatRequestItem ;
55+ }
56+
5257 const logEntries = treeItem . children . map ( child => {
5358 if ( child instanceof ChatRequestItem || child instanceof ToolCallItem || child instanceof ChatElementItem ) {
5459 return child . info ;
@@ -60,8 +65,8 @@ export class RequestLogTree extends Disposable implements IExtensionContribution
6065 } ;
6166
6267 // Helper method to process log entries for a single prompt
63- const preparePromptLogsAsJson = async ( treeItem : ChatPromptItem ) : Promise < any > => {
64- const logEntries = getExportableLogEntries ( treeItem ) ;
68+ const preparePromptLogsAsJson = async ( treeItem : ChatPromptItem , lastChatRequestItem ?: ChatRequestItem ) : Promise < any > => {
69+ const logEntries = getExportableLogEntries ( treeItem , lastChatRequestItem ) ;
6570
6671 if ( logEntries . length === 0 ) {
6772 return ;
@@ -414,10 +419,9 @@ export class RequestLogTree extends Disposable implements IExtensionContribution
414419 return ;
415420 }
416421
417- // Filter to get only ChatPromptItem instances
418- const chatPromptItems = allTreeItems . filter ( ( item ) : item is ChatPromptItem => item instanceof ChatPromptItem ) ;
422+ const exportableItems = allTreeItems . filter ( item => item instanceof ChatPromptItem || item instanceof ChatRequestItem ) ;
419423
420- if ( chatPromptItems . length === 0 ) {
424+ if ( exportableItems . length === 0 ) {
421425 vscode . window . showInformationMessage ( 'No chat prompts found to export.' ) ;
422426 return ;
423427 }
@@ -452,13 +456,17 @@ export class RequestLogTree extends Disposable implements IExtensionContribution
452456 const allPromptsContent : any [ ] = [ ] ;
453457 let totalLogEntries = 0 ;
454458
455- // Process each chat prompt item using the shared function
456- for ( const chatPromptItem of chatPromptItems ) {
457- // Use the shared processing function
458- const promptObject = await preparePromptLogsAsJson ( chatPromptItem ) ;
459- if ( promptObject ) {
460- allPromptsContent . push ( promptObject ) ;
461- totalLogEntries += promptObject . logCount ;
459+ let lastChatRequestItem : ChatRequestItem | undefined ;
460+ for ( const exportableItem of exportableItems ) {
461+ if ( exportableItem instanceof ChatRequestItem ) {
462+ lastChatRequestItem = exportableItem ;
463+ } else if ( exportableItem instanceof ChatPromptItem ) {
464+ const promptObject = await preparePromptLogsAsJson ( exportableItem , lastChatRequestItem ) ;
465+ if ( promptObject ) {
466+ allPromptsContent . push ( promptObject ) ;
467+ totalLogEntries += promptObject . logCount ;
468+ }
469+ lastChatRequestItem = undefined ;
462470 }
463471 }
464472
0 commit comments