@@ -66,7 +66,10 @@ struct CustomCommandView: View {
6666 Button ( action: {
6767 editingCommand = . init( isNew: true , command: CustomCommand (
6868 name: " New Command " ,
69- feature: . chatWithSelection( prompt: " Tell me about the code. " )
69+ feature: . chatWithSelection(
70+ extraSystemPrompt: nil ,
71+ prompt: " Tell me about the code. "
72+ )
7073 ) )
7174 } ) {
7275 Image ( systemName: " plus.circle.fill " )
@@ -163,10 +166,10 @@ struct EditCustomCommandView: View {
163166 originalName = editingCommand. wrappedValue? . command. name ?? " "
164167 name = originalName
165168 switch editingCommand. wrappedValue? . command. feature {
166- case let . chatWithSelection( prompt) :
169+ case let . chatWithSelection( extraSystemPrompt , prompt) :
167170 commandType = . chatWithSelection
168171 self . prompt = prompt ?? " "
169- systemPrompt = " "
172+ systemPrompt = extraSystemPrompt ?? " "
170173 continuousMode = false
171174 case let . customChat( systemPrompt, prompt) :
172175 commandType = . customChat
@@ -208,12 +211,13 @@ struct EditCustomCommandView: View {
208211
209212 switch commandType {
210213 case . chatWithSelection:
214+ systemPromptTextField ( title: " Extra System Prompt " )
211215 promptTextField
212216 case . promptToCode:
213217 promptTextField
214218 continuousModeToggle
215219 case . customChat:
216- systemPromptTextField
220+ systemPromptTextField ( )
217221 promptTextField
218222 }
219223 }
@@ -235,7 +239,10 @@ struct EditCustomCommandView: View {
235239 feature: {
236240 switch commandType {
237241 case . chatWithSelection:
238- return . chatWithSelection( prompt: prompt)
242+ return . chatWithSelection(
243+ extraSystemPrompt: systemPrompt,
244+ prompt: prompt
245+ )
239246 case . promptToCode:
240247 return . promptToCode( prompt: prompt, continuousMode: continuousMode)
241248 case . customChat:
@@ -259,7 +266,6 @@ struct EditCustomCommandView: View {
259266 }
260267 } else {
261268 Button ( " Update " ) {
262- guard let command = editingCommand? . command else { return }
263269 guard !settings. illegalNames. contains ( newCommand. name)
264270 || newCommand. name == originalName
265271 else {
@@ -288,7 +294,7 @@ struct EditCustomCommandView: View {
288294 }
289295 }
290296 . padding ( )
291- . frame ( minWidth : 500 )
297+ . frame ( width : 600 )
292298 }
293299
294300 var promptTextField : some View {
@@ -301,9 +307,9 @@ struct EditCustomCommandView: View {
301307 }
302308 }
303309
304- var systemPromptTextField : some View {
310+ func systemPromptTextField( title : String ? = nil ) -> some View {
305311 if #available( macOS 13 . 0 , * ) {
306- return TextField ( " System Prompt " , text: $systemPrompt, axis: . vertical)
312+ return TextField ( title ?? " System Prompt " , text: $systemPrompt, axis: . vertical)
307313 . multilineTextAlignment ( . leading)
308314 . lineLimit ( 4 , reservesSpace: true )
309315 } else {
@@ -323,7 +329,10 @@ struct CustomCommandView_Preview: PreviewProvider {
323329 CustomCommandView (
324330 isOpen: . constant( true ) ,
325331 settings: . init( customCommands: . init( wrappedValue: [
326- . init( name: " Explain Code " , feature: . chatWithSelection( prompt: " Hello " ) ) ,
332+ . init(
333+ name: " Explain Code " ,
334+ feature: . chatWithSelection( extraSystemPrompt: nil , prompt: " Hello " )
335+ ) ,
327336 . init(
328337 name: " Refactor Code " ,
329338 feature: . promptToCode( prompt: " Refactor " , continuousMode: false )
0 commit comments