@@ -16,18 +16,18 @@ marked.use(
16
16
} )
17
17
) ;
18
18
19
- enum ChatResultOutcome {
19
+ export enum ChatResultOutcome {
20
20
Success = "success" ,
21
21
Error = "error" ,
22
22
Finished = "finished" ,
23
23
}
24
24
25
- enum ChatResultRole {
25
+ export enum ChatResultRole {
26
26
Assistant = "assistant" ,
27
27
User = "user" ,
28
28
}
29
29
30
- type ChatResult = {
30
+ export type ChatResult = {
31
31
outcome : ChatResultOutcome ;
32
32
textContent : string ;
33
33
role : ChatResultRole ;
@@ -38,15 +38,21 @@ export type ChatRequestData = {
38
38
message : string ;
39
39
} ;
40
40
41
+ export type CodeReviewRequestData = {
42
+ kind : "review_request" ;
43
+ main : string ;
44
+ current : string ;
45
+ } ;
46
+
41
47
export type RecipeRequestData = {
42
48
kind : "recipe_request" ;
43
49
name : string ;
44
50
id : string ;
45
51
} ;
46
52
47
53
export type ChatRequest = {
48
- type : "recipe_request" | "chat_request" ;
49
- data : ChatRequestData | RecipeRequestData ;
54
+ type : "recipe_request" | "chat_request" | "review_request" ;
55
+ data : ChatRequestData | RecipeRequestData | CodeReviewRequestData ;
50
56
context_range ?: any ;
51
57
} ;
52
58
@@ -60,7 +66,7 @@ export type OpenLinkRequest = {
60
66
link : string ;
61
67
} ;
62
68
63
- type InsertAtCursorInstruction = {
69
+ export type InsertAtCursorInstruction = {
64
70
type : "insert_at_cursor" ;
65
71
content : string ;
66
72
} ;
@@ -214,7 +220,7 @@ export class ChatProvider implements vscode.WebviewViewProvider {
214
220
this . _currentAssistantMessage = result . textContent ;
215
221
}
216
222
217
- let sanitized = this . renderAssistantMessage ( this . _currentAssistantMessage ) ;
223
+ let sanitized = renderAssistantMessage ( this . _currentAssistantMessage ) ;
218
224
219
225
this . _view . webview . postMessage ( {
220
226
command : "add_result" ,
@@ -226,23 +232,6 @@ export class ChatProvider implements vscode.WebviewViewProvider {
226
232
} ) ;
227
233
}
228
234
229
- private renderAssistantMessage ( message : string ) {
230
- // Send the whole message we've been streamed so far to the webview,
231
- // after converting from markdown to html
232
-
233
- const rendered = marked ( message , {
234
- gfm : true ,
235
- breaks : true ,
236
- mangle : false ,
237
- headerIds : false ,
238
- } ) ;
239
-
240
- // Allow any classes on span and code blocks or highlightjs classes get removed
241
- return sanitizeHtml ( rendered , {
242
- allowedClasses : { span : false , code : false } ,
243
- } ) ;
244
- }
245
-
246
235
public clearChat ( ) {
247
236
this . _view . webview . postMessage ( { command : "clear_chat" } ) ;
248
237
this . _currentAssistantMessage = "" ;
@@ -316,7 +305,6 @@ export class ChatProvider implements vscode.WebviewViewProvider {
316
305
<section id="message-container" class="sidebar__section-container active" data-section="chat-assistant">
317
306
<ul class="sidebar__chat-assistant--dialogue-container">
318
307
319
- <li id="anchor"></li>
320
308
</ul>
321
309
</section>
322
310
<footer class="sidebar__chat-assistant--footer">
@@ -344,3 +332,24 @@ export class ChatProvider implements vscode.WebviewViewProvider {
344
332
</html>` ;
345
333
}
346
334
}
335
+
336
+ export function renderAssistantMessage ( message : string ) {
337
+ // Send the whole message we've been streamed so far to the webview,
338
+ // after converting from markdown to html
339
+
340
+ const rendered = marked ( message , {
341
+ gfm : true ,
342
+ breaks : true ,
343
+ mangle : false ,
344
+ headerIds : false ,
345
+ } ) ;
346
+
347
+ // Allow any classes on span and code blocks or highlightjs classes get removed
348
+ return sanitizeHtml ( rendered , {
349
+ allowedTags : sanitizeHtml . defaults . allowedTags . concat ( [
350
+ "details" ,
351
+ "summary" ,
352
+ ] ) ,
353
+ allowedClasses : { span : false , code : false } ,
354
+ } ) ;
355
+ }
0 commit comments