diff --git a/VoiceInk/Services/AIEnhancementService.swift b/VoiceInk/Services/AIEnhancementService.swift
index 01c80f6..3d07523 100644
--- a/VoiceInk/Services/AIEnhancementService.swift
+++ b/VoiceInk/Services/AIEnhancementService.swift
@@ -140,18 +140,21 @@ class AIEnhancementService: ObservableObject {
let clipboardSnapshot = NSPasteboard.general.string(forType: .string)
let selectedText = SelectedTextService.fetchSelectedText()
- if let activePrompt = activePrompt,
- activePrompt.id == PredefinedPrompts.assistantPromptId,
- let selectedText = selectedText, !selectedText.isEmpty {
+ if let selectedText = selectedText, !selectedText.isEmpty {
+ let generalContextSection = "\n\n\n\(selectedText)\n"
- let selectedTextContext = "\n\nSelected Text: \(selectedText)"
- let generalContextSection = "\n\n\(selectedTextContext)\n"
- let dictionaryContextSection = if !dictionaryContextService.getDictionaryContext().isEmpty {
- "\n\n\(dictionaryContextService.getDictionaryContext())\n"
+ if let activePrompt = activePrompt {
+ if activePrompt.id == PredefinedPrompts.assistantPromptId {
+ return activePrompt.promptText + generalContextSection
+ } else {
+ return activePrompt.finalPromptText + generalContextSection
+ }
} else {
- ""
+ if let defaultPrompt = allPrompts.first(where: { $0.id == PredefinedPrompts.defaultPromptId }) {
+ return defaultPrompt.finalPromptText + generalContextSection
+ }
+ return AIPrompts.assistantMode + generalContextSection
}
- return activePrompt.promptText + generalContextSection + dictionaryContextSection
}
let clipboardContext = if useClipboardContext,
@@ -192,7 +195,7 @@ class AIEnhancementService: ObservableObject {
if activePrompt.id == PredefinedPrompts.assistantPromptId {
return activePrompt.promptText + generalContextSection + dictionaryContextSection
}
-
+
var systemMessage = activePrompt.finalPromptText
systemMessage += generalContextSection + dictionaryContextSection
return systemMessage
diff --git a/VoiceInk/Services/SelectedTextService.swift b/VoiceInk/Services/SelectedTextService.swift
index 19fd0e6..27d732a 100644
--- a/VoiceInk/Services/SelectedTextService.swift
+++ b/VoiceInk/Services/SelectedTextService.swift
@@ -5,11 +5,6 @@ class SelectedTextService {
private static let privatePasteboardType = NSPasteboard.PasteboardType("com.prakashjoshipax.VoiceInk.transient")
static func fetchSelectedText() -> String? {
- // Don't check for selected text within VoiceInk itself
- guard let frontmostApp = NSWorkspace.shared.frontmostApplication,
- frontmostApp.bundleIdentifier != "com.prakashjoshipax.VoiceInk" else {
- return nil
- }
let pasteboard = NSPasteboard.general
let originalClipboardText = pasteboard.string(forType: .string)