11import { HTMLAttributes } from "react"
22import React from "react"
33import { useAppTranslation } from "@/i18n/TranslationContext"
4- import { VSCodeCheckbox } from "@vscode/webview-ui-toolkit/react"
4+ import { VSCodeCheckbox , VSCodeTextArea } from "@vscode/webview-ui-toolkit/react"
55import { FoldVertical } from "lucide-react"
66
7+ import { supportPrompt } from "@roo/support-prompt"
8+
79import { cn } from "@/lib/utils"
8- import { Input , Select , SelectContent , SelectItem , SelectTrigger , SelectValue , Slider , Button } from "@/components/ui"
10+ import {
11+ Input ,
12+ Select ,
13+ SelectContent ,
14+ SelectItem ,
15+ SelectTrigger ,
16+ SelectValue ,
17+ Slider ,
18+ Button ,
19+ StandardTooltip ,
20+ } from "@/components/ui"
921
1022import { SetCachedStateField } from "./types"
1123import { SectionHeader } from "./SectionHeader"
@@ -32,6 +44,8 @@ type ContextManagementSettingsProps = HTMLAttributes<HTMLDivElement> & {
3244 includeCurrentTime ?: boolean
3345 includeCurrentCost ?: boolean
3446 maxGitStatusFiles ?: number
47+ customSupportPrompts : Record < string , string | undefined >
48+ setCustomSupportPrompts : ( prompts : Record < string , string | undefined > ) => void
3549 setCachedStateField : SetCachedStateField <
3650 | "autoCondenseContext"
3751 | "autoCondenseContextPercent"
@@ -73,12 +87,37 @@ export const ContextManagementSettings = ({
7387 includeCurrentTime,
7488 includeCurrentCost,
7589 maxGitStatusFiles,
90+ customSupportPrompts,
91+ setCustomSupportPrompts,
7692 className,
7793 ...props
7894} : ContextManagementSettingsProps ) => {
7995 const { t } = useAppTranslation ( )
8096 const [ selectedThresholdProfile , setSelectedThresholdProfile ] = React . useState < string > ( "default" )
8197
98+ // Helper function to get the CONDENSE prompt value
99+ const getCondensePromptValue = ( ) : string => {
100+ return supportPrompt . get ( customSupportPrompts , "CONDENSE" )
101+ }
102+
103+ // Helper function to update the CONDENSE prompt
104+ const updateCondensePrompt = ( value : string | undefined ) => {
105+ const updatedPrompts = { ...customSupportPrompts }
106+ if ( value === undefined ) {
107+ delete updatedPrompts [ "CONDENSE" ]
108+ } else {
109+ updatedPrompts [ "CONDENSE" ] = value
110+ }
111+ setCustomSupportPrompts ( updatedPrompts )
112+ }
113+
114+ // Helper function to reset the CONDENSE prompt to default
115+ const handleCondenseReset = ( ) => {
116+ const updatedPrompts = { ...customSupportPrompts }
117+ delete updatedPrompts [ "CONDENSE" ]
118+ setCustomSupportPrompts ( updatedPrompts )
119+ }
120+
82121 // Helper function to get the current threshold value based on selected profile
83122 const getCurrentThresholdValue = ( ) => {
84123 if ( selectedThresholdProfile === "default" ) {
@@ -470,6 +509,38 @@ export const ContextManagementSettings = ({
470509 </ SearchableSetting >
471510 </ Section >
472511 < Section className = "pt-2" >
512+ { /* Context Condensing Prompt Editor */ }
513+ < SearchableSetting
514+ settingId = "context-condense-prompt"
515+ section = "contextManagement"
516+ label = { t ( "prompts:supportPrompts.types.CONDENSE.label" ) } >
517+ < div className = "flex justify-between items-center mb-1" >
518+ < label className = "block font-medium" > { t ( "prompts:supportPrompts.types.CONDENSE.label" ) } </ label >
519+ < StandardTooltip content = { t ( "prompts:supportPrompts.resetPrompt" , { promptType : "CONDENSE" } ) } >
520+ < Button variant = "ghost" size = "icon" onClick = { handleCondenseReset } >
521+ < span className = "codicon codicon-discard" > </ span >
522+ </ Button >
523+ </ StandardTooltip >
524+ </ div >
525+ < div className = "text-sm text-vscode-descriptionForeground mb-2" >
526+ { t ( "prompts:supportPrompts.types.CONDENSE.description" ) }
527+ </ div >
528+ < VSCodeTextArea
529+ resize = "vertical"
530+ value = { getCondensePromptValue ( ) }
531+ onInput = { ( e ) => {
532+ const value =
533+ ( e as unknown as CustomEvent ) ?. detail ?. target ?. value ??
534+ ( ( e as any ) . target as HTMLTextAreaElement ) . value
535+ updateCondensePrompt ( value )
536+ } }
537+ rows = { 6 }
538+ className = "w-full"
539+ data-testid = "condense-prompt-textarea"
540+ />
541+ </ SearchableSetting >
542+
543+ { /* Auto Condense Context */ }
473544 < SearchableSetting
474545 settingId = "context-auto-condense"
475546 section = "contextManagement"
0 commit comments