11import ChatService
2- import SuggestionModel
3- import GitHubCopilotService
42import Environment
53import Foundation
4+ import GitHubCopilotService
65import LanguageServerProtocol
76import Logger
87import OpenAIService
98import SuggestionInjector
9+ import SuggestionModel
1010import SuggestionWidget
1111import XPCShared
1212
@@ -53,7 +53,7 @@ struct WindowBaseCommandHandler: SuggestionCommandHandler {
5353 forFileAt: fileURL,
5454 editor: editor
5555 )
56-
56+
5757 try Task . checkCancellation ( )
5858
5959 if filespace. presentingSuggestion != nil {
@@ -388,7 +388,7 @@ extension WindowBaseCommandHandler {
388388
389389 presenter. presentPromptToCode ( fileURL: fileURL)
390390 }
391-
391+
392392 private func startChat(
393393 specifiedSystemPrompt: String ? ,
394394 extraSystemPrompt: String ? ,
@@ -402,15 +402,16 @@ extension WindowBaseCommandHandler {
402402
403403 let chat = WidgetDataSource . shared. createChatIfNeeded ( for: focusedElementURI)
404404
405- chat. mutateSystemPrompt ( specifiedSystemPrompt)
406- chat. mutateExtraSystemPrompt ( extraSystemPrompt ?? " " )
405+ let templateProcessor = CustomCommandTemplateProcessor ( )
406+ chat. mutateSystemPrompt ( specifiedSystemPrompt. map ( templateProcessor. process) )
407+ chat. mutateExtraSystemPrompt ( extraSystemPrompt. map ( templateProcessor. process) ?? " " )
407408
408409 Task {
409410 let customCommandPrefix = {
410411 if let name { return " [ \( name) ] " }
411412 return " "
412413 } ( )
413-
414+
414415 if specifiedSystemPrompt != nil || extraSystemPrompt != nil {
415416 await chat. chatGPTService. mutateHistory { history in
416417 history. append ( . init(
@@ -422,10 +423,12 @@ extension WindowBaseCommandHandler {
422423 }
423424
424425 if let sendingMessageImmediately, !sendingMessageImmediately. isEmpty {
425- try await chat. send ( content: sendingMessageImmediately)
426+ try await chat
427+ . send ( content: templateProcessor. process ( sendingMessageImmediately) )
426428 }
427429 }
428430
429431 presenter. presentChatRoom ( fileURL: focusedElementURI)
430432 }
431433}
434+
0 commit comments