@@ -8,13 +8,15 @@ import { ServicesAccessor } from '../../../../../editor/browser/editorExtensions
88import { localize2 } from '../../../../../nls.js' ;
99import { Categories } from '../../../../../platform/action/common/actionCommonCategories.js' ;
1010import { Action2 , registerAction2 } from '../../../../../platform/actions/common/actions.js' ;
11+ import { IEditorService } from '../../../../services/editor/common/editorService.js' ;
1112import { ChatContextKeys } from '../../common/actions/chatContextKeys.js' ;
1213import { IChatService } from '../../common/chatService/chatService.js' ;
1314import { IChatWidgetService } from '../chat.js' ;
1415
1516export function registerChatDeveloperActions ( ) {
1617 registerAction2 ( LogChatInputHistoryAction ) ;
1718 registerAction2 ( LogChatIndexAction ) ;
19+ registerAction2 ( InspectChatModelAction ) ;
1820}
1921
2022class LogChatInputHistoryAction extends Action2 {
@@ -56,3 +58,57 @@ class LogChatIndexAction extends Action2 {
5658 chatService . logChatIndex ( ) ;
5759 }
5860}
61+
62+ class InspectChatModelAction extends Action2 {
63+ static readonly ID = 'workbench.action.chat.inspectChatModel' ;
64+
65+ constructor ( ) {
66+ super ( {
67+ id : InspectChatModelAction . ID ,
68+ title : localize2 ( 'workbench.action.chat.inspectChatModel.label' , "Inspect Chat Model" ) ,
69+ icon : Codicon . inspect ,
70+ category : Categories . Developer ,
71+ f1 : true ,
72+ precondition : ChatContextKeys . enabled
73+ } ) ;
74+ }
75+
76+ override async run ( accessor : ServicesAccessor , ...args : unknown [ ] ) : Promise < void > {
77+ const chatWidgetService = accessor . get ( IChatWidgetService ) ;
78+ const editorService = accessor . get ( IEditorService ) ;
79+ const widget = chatWidgetService . lastFocusedWidget ;
80+
81+ if ( ! widget ?. viewModel ) {
82+ return ;
83+ }
84+
85+ const model = widget . viewModel . model ;
86+ const modelData = model . toJSON ( ) ;
87+
88+ // Build markdown output with latest response at the top
89+ let output = '# Chat Model Inspection\n\n' ;
90+
91+ // Show latest response first if it exists
92+ const requests = modelData . requests ;
93+ if ( requests && requests . length > 0 ) {
94+ const latestRequest = requests [ requests . length - 1 ] ;
95+ if ( latestRequest . response ) {
96+ output += '## Latest Response\n\n' ;
97+ output += '```json\n' + JSON . stringify ( latestRequest . response , null , 2 ) + '\n```\n\n' ;
98+ }
99+ }
100+
101+ // Show full model data
102+ output += '## Full Chat Model\n\n' ;
103+ output += '```json\n' + JSON . stringify ( modelData , null , 2 ) + '\n```\n' ;
104+
105+ await editorService . openEditor ( {
106+ resource : undefined ,
107+ contents : output ,
108+ languageId : 'markdown' ,
109+ options : {
110+ pinned : true
111+ }
112+ } ) ;
113+ }
114+ }
0 commit comments