Skip to content

Commit 1f417bb

Browse files
committed
Update the message displayed when a custom chat command is triggered.
1 parent 4d7635a commit 1f417bb

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

Core/Sources/Service/SuggestionCommandHandler/WindowBaseCommandHandler.swift

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,8 @@ struct WindowBaseCommandHandler: SuggestionCommandHandler {
236236
editor: editor,
237237
specifiedSystemPrompt: nil,
238238
extraSystemPrompt: nil,
239-
sendingMessageImmediately: nil
239+
sendingMessageImmediately: nil,
240+
name: nil
240241
)
241242
} catch {
242243
presenter.presentError(error)
@@ -290,14 +291,16 @@ extension WindowBaseCommandHandler {
290291
editor: editor,
291292
specifiedSystemPrompt: nil,
292293
extraSystemPrompt: extraSystemPrompt,
293-
sendingMessageImmediately: prompt
294+
sendingMessageImmediately: prompt,
295+
name: command.name
294296
)
295297
case let .customChat(systemPrompt, prompt):
296298
try await startChatWithSelection(
297299
editor: editor,
298300
specifiedSystemPrompt: systemPrompt,
299301
extraSystemPrompt: nil,
300-
sendingMessageImmediately: prompt
302+
sendingMessageImmediately: prompt,
303+
name: command.name
301304
)
302305
case let .promptToCode(extraSystemPrompt, prompt, continuousMode):
303306
try await presentPromptToCode(
@@ -386,7 +389,8 @@ extension WindowBaseCommandHandler {
386389
editor: EditorContent,
387390
specifiedSystemPrompt: String?,
388391
extraSystemPrompt: String?,
389-
sendingMessageImmediately: String?
392+
sendingMessageImmediately: String?,
393+
name: String?
390394
) async throws {
391395
presenter.markAsProcessing(true)
392396
defer { presenter.markAsProcessing(false) }
@@ -426,20 +430,25 @@ extension WindowBaseCommandHandler {
426430
await chat.mutateSystemPrompt(systemPrompt)
427431

428432
Task {
429-
if let specifiedSystemPrompt {
433+
let customCommandPrefix = {
434+
if let name { return "[\(name)]" }
435+
return ""
436+
}()
437+
438+
if specifiedSystemPrompt != nil {
430439
await chat.chatGPTService.mutateHistory { history in
431440
history.append(.init(
432441
role: .assistant,
433442
content: "",
434-
summary: "System prompt is updated: \n\(specifiedSystemPrompt)"
443+
summary: "\(customCommandPrefix) System prompt is updated."
435444
))
436445
}
437446
} else if !code.isEmpty, let selection = editor.selections.last {
438447
await chat.chatGPTService.mutateHistory { history in
439448
history.append(.init(
440449
role: .assistant,
441450
content: "",
442-
summary: "Chating about selected code in `\(fileURL.lastPathComponent)` from `\(selection.start.line + 1):\(selection.start.character + 1)` to `\(selection.end.line + 1):\(selection.end.character)`.\nThe code will persist in the conversation."
451+
summary: "\(customCommandPrefix) Chatting about selected code in `\(fileURL.lastPathComponent)` from `\(selection.start.line + 1):\(selection.start.character + 1)` to `\(selection.end.line + 1):\(selection.end.character)`.\nThe code will persist in the conversation."
443452
))
444453
}
445454
}

0 commit comments

Comments
 (0)