6
6
import * as dom from '../../../../../../base/browser/dom.js' ;
7
7
import { decodeBase64 } from '../../../../../../base/common/buffer.js' ;
8
8
import { 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' ;
9
13
import { IChatToolInvocation , IChatToolInvocationSerialized , IToolResultOutputDetailsSerialized } from '../../../common/chatService.js' ;
10
14
import { IToolResultOutputDetails } from '../../../common/languageModelToolsService.js' ;
11
15
import { IChatCodeBlockInfo } from '../../chat.js' ;
12
16
import { IChatOutputRendererService } from '../../chatOutputItemRenderer.js' ;
13
17
import { IChatContentPartRenderContext } from '../chatContentParts.js' ;
18
+ import { ChatCustomProgressPart } from '../chatProgressContentPart.js' ;
14
19
import { BaseChatToolInvocationSubPart } from './chatToolInvocationSubPart.js' ;
15
20
16
21
export class ChatToolOutputSubPart extends BaseChatToolInvocationSubPart {
@@ -22,32 +27,37 @@ export class ChatToolOutputSubPart extends BaseChatToolInvocationSubPart {
22
27
toolInvocation : IChatToolInvocation | IChatToolInvocationSerialized ,
23
28
_context : IChatContentPartRenderContext ,
24
29
@IChatOutputRendererService private readonly chatOutputItemRendererService : IChatOutputRendererService ,
30
+ @IInstantiationService private readonly instantiationService : IInstantiationService ,
25
31
) {
26
32
super ( toolInvocation ) ;
27
33
28
-
29
34
const details : IToolResultOutputDetails = toolInvocation . kind === 'toolInvocation'
30
35
? toolInvocation . resultDetails as IToolResultOutputDetails
31
36
: {
32
37
output : {
33
38
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 ) ,
36
41
} ,
37
42
} ;
38
43
39
44
this . domNode = this . createOutputPart ( details ) ;
40
45
}
41
46
42
47
private createOutputPart ( details : IToolResultOutputDetails ) : HTMLElement {
43
- // TODO: Show progress while rendering
44
-
45
48
const parent = dom . $ ( 'div.webview-output' ) ;
46
49
parent . style . maxHeight = '80vh' ;
47
50
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
+
48
56
this . chatOutputItemRendererService . renderOutputPart ( details . output . mimeType , details . output . value . buffer , parent , CancellationToken . None ) . then ( ( renderedItem ) => {
49
57
this . _register ( renderedItem ) ;
50
58
59
+ progressPart . domNode . remove ( ) ;
60
+
51
61
this . _onDidChangeHeight . fire ( ) ;
52
62
this . _register ( renderedItem . onDidChangeHeight ( ( ) => {
53
63
this . _onDidChangeHeight . fire ( ) ;
0 commit comments