66import * as dom from '../../../../../../base/browser/dom.js' ;
77import { decodeBase64 } from '../../../../../../base/common/buffer.js' ;
88import { CancellationToken } from '../../../../../../base/common/cancellation.js' ;
9+ import { Codicon } from '../../../../../../base/common/codicons.js' ;
10+ import { ThemeIcon } from '../../../../../../base/common/themables.js' ;
11+ import { localize } from '../../../../../../nls.js' ;
12+ import { IInstantiationService } from '../../../../../../platform/instantiation/common/instantiation.js' ;
913import { IChatToolInvocation , IChatToolInvocationSerialized , IToolResultOutputDetailsSerialized } from '../../../common/chatService.js' ;
1014import { IToolResultOutputDetails } from '../../../common/languageModelToolsService.js' ;
1115import { IChatCodeBlockInfo } from '../../chat.js' ;
1216import { IChatOutputRendererService } from '../../chatOutputItemRenderer.js' ;
1317import { IChatContentPartRenderContext } from '../chatContentParts.js' ;
18+ import { ChatCustomProgressPart } from '../chatProgressContentPart.js' ;
1419import { BaseChatToolInvocationSubPart } from './chatToolInvocationSubPart.js' ;
1520
1621export class ChatToolOutputSubPart extends BaseChatToolInvocationSubPart {
@@ -22,32 +27,37 @@ export class ChatToolOutputSubPart extends BaseChatToolInvocationSubPart {
2227 toolInvocation : IChatToolInvocation | IChatToolInvocationSerialized ,
2328 _context : IChatContentPartRenderContext ,
2429 @IChatOutputRendererService private readonly chatOutputItemRendererService : IChatOutputRendererService ,
30+ @IInstantiationService private readonly instantiationService : IInstantiationService ,
2531 ) {
2632 super ( toolInvocation ) ;
2733
28-
2934 const details : IToolResultOutputDetails = toolInvocation . kind === 'toolInvocation'
3035 ? toolInvocation . resultDetails as IToolResultOutputDetails
3136 : {
3237 output : {
3338 type : 'data' ,
34- mimeType : ( toolInvocation . resultDetails as IToolResultOutputDetailsSerialized ) . mimeType ,
35- value : decodeBase64 ( ( toolInvocation . resultDetails as IToolResultOutputDetailsSerialized ) . base64Data ) ,
39+ mimeType : ( toolInvocation . resultDetails as IToolResultOutputDetailsSerialized ) . output . mimeType ,
40+ value : decodeBase64 ( ( toolInvocation . resultDetails as IToolResultOutputDetailsSerialized ) . output . base64Data ) ,
3641 } ,
3742 } ;
3843
3944 this . domNode = this . createOutputPart ( details ) ;
4045 }
4146
4247 private createOutputPart ( details : IToolResultOutputDetails ) : HTMLElement {
43- // TODO: Show progress while rendering
44-
4548 const parent = dom . $ ( 'div.webview-output' ) ;
4649 parent . style . maxHeight = '80vh' ;
4750
51+ const progressMessage = dom . $ ( 'span' ) ;
52+ progressMessage . textContent = localize ( 'loading' , 'Rendering tool output...' ) ;
53+ const progressPart = this . instantiationService . createInstance ( ChatCustomProgressPart , progressMessage , ThemeIcon . modify ( Codicon . loading , 'spin' ) ) ;
54+ parent . appendChild ( progressPart . domNode ) ;
55+
4856 this . chatOutputItemRendererService . renderOutputPart ( details . output . mimeType , details . output . value . buffer , parent , CancellationToken . None ) . then ( ( renderedItem ) => {
4957 this . _register ( renderedItem ) ;
5058
59+ progressPart . domNode . remove ( ) ;
60+
5161 this . _onDidChangeHeight . fire ( ) ;
5262 this . _register ( renderedItem . onDidChangeHeight ( ( ) => {
5363 this . _onDidChangeHeight . fire ( ) ;
0 commit comments