mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-21 12:51:17 -05:00
refactor: separate mode and support prompts
- Rename customPrompts to customModePrompts for mode-specific prompts - Add new customSupportPrompts type for support action prompts - Update types to be more specific (CustomModePrompts and CustomSupportPrompts) - Fix all related tests and component implementations
This commit is contained in:
@@ -23,7 +23,8 @@ type PromptsViewProps = {
|
||||
|
||||
const PromptsView = ({ onDone }: PromptsViewProps) => {
|
||||
const {
|
||||
customPrompts,
|
||||
customModePrompts,
|
||||
customSupportPrompts,
|
||||
listApiConfigMeta,
|
||||
enhancementApiConfigId,
|
||||
setEnhancementApiConfigId,
|
||||
@@ -50,7 +51,7 @@ const PromptsView = ({ onDone }: PromptsViewProps) => {
|
||||
// Direct update functions
|
||||
const updateAgentPrompt = useCallback(
|
||||
(mode: Mode, promptData: PromptComponent) => {
|
||||
const existingPrompt = customPrompts?.[mode] as PromptComponent
|
||||
const existingPrompt = customModePrompts?.[mode] as PromptComponent
|
||||
const updatedPrompt = { ...existingPrompt, ...promptData }
|
||||
|
||||
// Only include properties that differ from defaults
|
||||
@@ -64,7 +65,7 @@ const PromptsView = ({ onDone }: PromptsViewProps) => {
|
||||
customPrompt: updatedPrompt,
|
||||
})
|
||||
},
|
||||
[customPrompts],
|
||||
[customModePrompts],
|
||||
)
|
||||
|
||||
const updateCustomMode = useCallback((slug: string, modeConfig: ModeConfig) => {
|
||||
@@ -261,7 +262,7 @@ const PromptsView = ({ onDone }: PromptsViewProps) => {
|
||||
|
||||
const handleAgentReset = (modeSlug: string) => {
|
||||
// Only reset role definition for built-in modes
|
||||
const existingPrompt = customPrompts?.[modeSlug] as PromptComponent
|
||||
const existingPrompt = customModePrompts?.[modeSlug] as PromptComponent
|
||||
updateAgentPrompt(modeSlug, {
|
||||
...existingPrompt,
|
||||
roleDefinition: undefined,
|
||||
@@ -276,7 +277,7 @@ const PromptsView = ({ onDone }: PromptsViewProps) => {
|
||||
}
|
||||
|
||||
const getSupportPromptValue = (type: SupportPromptType): string => {
|
||||
return supportPrompt.get(customPrompts, type)
|
||||
return supportPrompt.get(customSupportPrompts, type)
|
||||
}
|
||||
|
||||
const handleTestEnhancement = () => {
|
||||
@@ -556,7 +557,7 @@ const PromptsView = ({ onDone }: PromptsViewProps) => {
|
||||
<VSCodeTextArea
|
||||
value={(() => {
|
||||
const customMode = findModeBySlug(mode, customModes)
|
||||
const prompt = customPrompts?.[mode] as PromptComponent
|
||||
const prompt = customModePrompts?.[mode] as PromptComponent
|
||||
return customMode?.roleDefinition ?? prompt?.roleDefinition ?? getRoleDefinition(mode)
|
||||
})()}
|
||||
onChange={(e) => {
|
||||
@@ -673,7 +674,7 @@ const PromptsView = ({ onDone }: PromptsViewProps) => {
|
||||
<VSCodeTextArea
|
||||
value={(() => {
|
||||
const customMode = findModeBySlug(mode, customModes)
|
||||
const prompt = customPrompts?.[mode] as PromptComponent
|
||||
const prompt = customModePrompts?.[mode] as PromptComponent
|
||||
return customMode?.customInstructions ?? prompt?.customInstructions ?? ""
|
||||
})()}
|
||||
onChange={(e) => {
|
||||
@@ -689,7 +690,7 @@ const PromptsView = ({ onDone }: PromptsViewProps) => {
|
||||
})
|
||||
} else {
|
||||
// For built-in modes, update the prompts
|
||||
const existingPrompt = customPrompts?.[mode] as PromptComponent
|
||||
const existingPrompt = customModePrompts?.[mode] as PromptComponent
|
||||
updateAgentPrompt(mode, {
|
||||
...existingPrompt,
|
||||
customInstructions: value.trim() || undefined,
|
||||
|
||||
@@ -12,7 +12,7 @@ jest.mock("../../../utils/vscode", () => ({
|
||||
}))
|
||||
|
||||
const mockExtensionState = {
|
||||
customPrompts: {},
|
||||
customModePrompts: {},
|
||||
listApiConfigMeta: [
|
||||
{ id: "config1", name: "Config 1" },
|
||||
{ id: "config2", name: "Config 2" },
|
||||
|
||||
Reference in New Issue
Block a user