|
@@ -23,8 +23,6 @@ import { SearchableSetting } from "./SearchableSetting"
|
|
|
interface PromptsSettingsProps {
|
|
interface PromptsSettingsProps {
|
|
|
customSupportPrompts: Record<string, string | undefined>
|
|
customSupportPrompts: Record<string, string | undefined>
|
|
|
setCustomSupportPrompts: (prompts: Record<string, string | undefined>) => void
|
|
setCustomSupportPrompts: (prompts: Record<string, string | undefined>) => void
|
|
|
- customCondensingPrompt?: string
|
|
|
|
|
- setCustomCondensingPrompt?: (value: string) => void
|
|
|
|
|
includeTaskHistoryInEnhance?: boolean
|
|
includeTaskHistoryInEnhance?: boolean
|
|
|
setIncludeTaskHistoryInEnhance?: (value: boolean) => void
|
|
setIncludeTaskHistoryInEnhance?: (value: boolean) => void
|
|
|
}
|
|
}
|
|
@@ -32,8 +30,6 @@ interface PromptsSettingsProps {
|
|
|
const PromptsSettings = ({
|
|
const PromptsSettings = ({
|
|
|
customSupportPrompts,
|
|
customSupportPrompts,
|
|
|
setCustomSupportPrompts,
|
|
setCustomSupportPrompts,
|
|
|
- customCondensingPrompt: propsCustomCondensingPrompt,
|
|
|
|
|
- setCustomCondensingPrompt: propsSetCustomCondensingPrompt,
|
|
|
|
|
includeTaskHistoryInEnhance: propsIncludeTaskHistoryInEnhance,
|
|
includeTaskHistoryInEnhance: propsIncludeTaskHistoryInEnhance,
|
|
|
setIncludeTaskHistoryInEnhance: propsSetIncludeTaskHistoryInEnhance,
|
|
setIncludeTaskHistoryInEnhance: propsSetIncludeTaskHistoryInEnhance,
|
|
|
}: PromptsSettingsProps) => {
|
|
}: PromptsSettingsProps) => {
|
|
@@ -44,16 +40,10 @@ const PromptsSettings = ({
|
|
|
setEnhancementApiConfigId,
|
|
setEnhancementApiConfigId,
|
|
|
condensingApiConfigId,
|
|
condensingApiConfigId,
|
|
|
setCondensingApiConfigId,
|
|
setCondensingApiConfigId,
|
|
|
- customCondensingPrompt: contextCustomCondensingPrompt,
|
|
|
|
|
- setCustomCondensingPrompt: contextSetCustomCondensingPrompt,
|
|
|
|
|
includeTaskHistoryInEnhance: contextIncludeTaskHistoryInEnhance,
|
|
includeTaskHistoryInEnhance: contextIncludeTaskHistoryInEnhance,
|
|
|
setIncludeTaskHistoryInEnhance: contextSetIncludeTaskHistoryInEnhance,
|
|
setIncludeTaskHistoryInEnhance: contextSetIncludeTaskHistoryInEnhance,
|
|
|
} = useExtensionState()
|
|
} = useExtensionState()
|
|
|
|
|
|
|
|
- // Use props if provided, otherwise fall back to context
|
|
|
|
|
- const customCondensingPrompt = propsCustomCondensingPrompt ?? contextCustomCondensingPrompt
|
|
|
|
|
- const setCustomCondensingPrompt = propsSetCustomCondensingPrompt ?? contextSetCustomCondensingPrompt
|
|
|
|
|
-
|
|
|
|
|
// Use props if provided, otherwise fall back to context
|
|
// Use props if provided, otherwise fall back to context
|
|
|
const includeTaskHistoryInEnhance = propsIncludeTaskHistoryInEnhance ?? contextIncludeTaskHistoryInEnhance ?? true
|
|
const includeTaskHistoryInEnhance = propsIncludeTaskHistoryInEnhance ?? contextIncludeTaskHistoryInEnhance ?? true
|
|
|
const setIncludeTaskHistoryInEnhance = propsSetIncludeTaskHistoryInEnhance ?? contextSetIncludeTaskHistoryInEnhance
|
|
const setIncludeTaskHistoryInEnhance = propsSetIncludeTaskHistoryInEnhance ?? contextSetIncludeTaskHistoryInEnhance
|
|
@@ -82,46 +72,22 @@ const PromptsSettings = ({
|
|
|
// Use nullish coalescing to preserve empty strings
|
|
// Use nullish coalescing to preserve empty strings
|
|
|
const finalValue = value ?? undefined
|
|
const finalValue = value ?? undefined
|
|
|
|
|
|
|
|
- if (type === "CONDENSE") {
|
|
|
|
|
- setCustomCondensingPrompt(finalValue ?? supportPrompt.default.CONDENSE)
|
|
|
|
|
- // Also update the customSupportPrompts to trigger change detection
|
|
|
|
|
- const updatedPrompts = { ...customSupportPrompts }
|
|
|
|
|
- if (finalValue === undefined) {
|
|
|
|
|
- delete updatedPrompts[type]
|
|
|
|
|
- } else {
|
|
|
|
|
- updatedPrompts[type] = finalValue
|
|
|
|
|
- }
|
|
|
|
|
- setCustomSupportPrompts(updatedPrompts)
|
|
|
|
|
|
|
+ const updatedPrompts = { ...customSupportPrompts }
|
|
|
|
|
+ if (finalValue === undefined) {
|
|
|
|
|
+ delete updatedPrompts[type]
|
|
|
} else {
|
|
} else {
|
|
|
- const updatedPrompts = { ...customSupportPrompts }
|
|
|
|
|
- if (finalValue === undefined) {
|
|
|
|
|
- delete updatedPrompts[type]
|
|
|
|
|
- } else {
|
|
|
|
|
- updatedPrompts[type] = finalValue
|
|
|
|
|
- }
|
|
|
|
|
- setCustomSupportPrompts(updatedPrompts)
|
|
|
|
|
|
|
+ updatedPrompts[type] = finalValue
|
|
|
}
|
|
}
|
|
|
|
|
+ setCustomSupportPrompts(updatedPrompts)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const handleSupportReset = (type: SupportPromptType) => {
|
|
const handleSupportReset = (type: SupportPromptType) => {
|
|
|
- if (type === "CONDENSE") {
|
|
|
|
|
- setCustomCondensingPrompt(supportPrompt.default.CONDENSE)
|
|
|
|
|
- // Also update the customSupportPrompts to trigger change detection
|
|
|
|
|
- const updatedPrompts = { ...customSupportPrompts }
|
|
|
|
|
- delete updatedPrompts[type]
|
|
|
|
|
- setCustomSupportPrompts(updatedPrompts)
|
|
|
|
|
- } else {
|
|
|
|
|
- const updatedPrompts = { ...customSupportPrompts }
|
|
|
|
|
- delete updatedPrompts[type]
|
|
|
|
|
- setCustomSupportPrompts(updatedPrompts)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ const updatedPrompts = { ...customSupportPrompts }
|
|
|
|
|
+ delete updatedPrompts[type]
|
|
|
|
|
+ setCustomSupportPrompts(updatedPrompts)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const getSupportPromptValue = (type: SupportPromptType): string => {
|
|
const getSupportPromptValue = (type: SupportPromptType): string => {
|
|
|
- if (type === "CONDENSE") {
|
|
|
|
|
- // Preserve empty string - only fall back to default when value is nullish
|
|
|
|
|
- return customCondensingPrompt ?? supportPrompt.default.CONDENSE
|
|
|
|
|
- }
|
|
|
|
|
return supportPrompt.get(customSupportPrompts, type)
|
|
return supportPrompt.get(customSupportPrompts, type)
|
|
|
}
|
|
}
|
|
|
|
|
|