Skip to content

Commit de13d8a

Browse files
authored
fix: move context condensing prompt to Prompts section (RooCodeInc#4924) (RooCodeInc#5279)
* feat: move context condensing prompt from context to prompts page * fix: remove unused imports after lint fixes
1 parent c96b399 commit de13d8a

25 files changed

+317
-302
lines changed

src/core/webview/webviewMessageHandler.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,6 +1282,11 @@ export const webviewMessageHandler = async (
12821282
await provider.postStateToWebview()
12831283
break
12841284
case "updateCondensingPrompt":
1285+
// Store the condensing prompt in customSupportPrompts["CONDENSE"] instead of customCondensingPrompt
1286+
const currentSupportPrompts = getGlobalState("customSupportPrompts") ?? {}
1287+
const updatedSupportPrompts = { ...currentSupportPrompts, CONDENSE: message.text }
1288+
await updateGlobalState("customSupportPrompts", updatedSupportPrompts)
1289+
// Also update the old field for backward compatibility during migration
12851290
await updateGlobalState("customCondensingPrompt", message.text)
12861291
await provider.postStateToWebview()
12871292
break

src/shared/support-prompt.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ interface SupportPromptConfig {
3535

3636
type SupportPromptType =
3737
| "ENHANCE"
38+
| "CONDENSE"
3839
| "EXPLAIN"
3940
| "FIX"
4041
| "IMPROVE"
@@ -49,6 +50,45 @@ const supportPromptConfigs: Record<SupportPromptType, SupportPromptConfig> = {
4950
template: `Generate an enhanced version of this prompt (reply with only the enhanced prompt - no conversation, explanations, lead-in, bullet points, placeholders, or surrounding quotes):
5051
5152
\${userInput}`,
53+
},
54+
CONDENSE: {
55+
template: `Your task is to create a detailed summary of the conversation so far, paying close attention to the user's explicit requests and your previous actions.
56+
This summary should be thorough in capturing technical details, code patterns, and architectural decisions that would be essential for continuing with the conversation and supporting any continuing tasks.
57+
58+
Your summary should be structured as follows:
59+
Context: The context to continue the conversation with. If applicable based on the current task, this should include:
60+
1. Previous Conversation: High level details about what was discussed throughout the entire conversation with the user. This should be written to allow someone to be able to follow the general overarching conversation flow.
61+
2. Current Work: Describe in detail what was being worked on prior to this request to summarize the conversation. Pay special attention to the more recent messages in the conversation.
62+
3. Key Technical Concepts: List all important technical concepts, technologies, coding conventions, and frameworks discussed, which might be relevant for continuing with this work.
63+
4. Relevant Files and Code: If applicable, enumerate specific files and code sections examined, modified, or created for the task continuation. Pay special attention to the most recent messages and changes.
64+
5. Problem Solving: Document problems solved thus far and any ongoing troubleshooting efforts.
65+
6. Pending Tasks and Next Steps: Outline all pending tasks that you have explicitly been asked to work on, as well as list the next steps you will take for all outstanding work, if applicable. Include code snippets where they add clarity. For any next steps, include direct quotes from the most recent conversation showing exactly what task you were working on and where you left off. This should be verbatim to ensure there's no information loss in context between tasks.
66+
67+
Example summary structure:
68+
1. Previous Conversation:
69+
[Detailed description]
70+
2. Current Work:
71+
[Detailed description]
72+
3. Key Technical Concepts:
73+
- [Concept 1]
74+
- [Concept 2]
75+
- [...]
76+
4. Relevant Files and Code:
77+
- [File Name 1]
78+
- [Summary of why this file is important]
79+
- [Summary of the changes made to this file, if any]
80+
- [Important Code Snippet]
81+
- [File Name 2]
82+
- [Important Code Snippet]
83+
- [...]
84+
5. Problem Solving:
85+
[Detailed description]
86+
6. Pending Tasks and Next Steps:
87+
- [Task 1 details & next steps]
88+
- [Task 2 details & next steps]
89+
- [...]
90+
91+
Output only the summary of the conversation so far, without any additional commentary or explanation.`,
5292
},
5393
EXPLAIN: {
5494
template: `Explain the following code from file path \${filePath}:\${startLine}-\${endLine}

webview-ui/src/components/settings/ContextManagementSettings.tsx

Lines changed: 2 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,20 @@
11
import { HTMLAttributes } from "react"
22
import React from "react"
33
import { useAppTranslation } from "@/i18n/TranslationContext"
4-
import { VSCodeCheckbox, VSCodeTextArea } from "@vscode/webview-ui-toolkit/react"
4+
import { VSCodeCheckbox } from "@vscode/webview-ui-toolkit/react"
55
import { Database, FoldVertical } from "lucide-react"
66

77
import { cn } from "@/lib/utils"
8-
import { Button, Input, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Slider } from "@/components/ui"
8+
import { Input, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Slider } from "@/components/ui"
99

1010
import { SetCachedStateField } from "./types"
1111
import { SectionHeader } from "./SectionHeader"
1212
import { Section } from "./Section"
1313
import { vscode } from "@/utils/vscode"
1414

15-
const SUMMARY_PROMPT = `\
16-
Your task is to create a detailed summary of the conversation so far, paying close attention to the user's explicit requests and your previous actions.
17-
This summary should be thorough in capturing technical details, code patterns, and architectural decisions that would be essential for continuing with the conversation and supporting any continuing tasks.
18-
19-
Your summary should be structured as follows:
20-
Context: The context to continue the conversation with. If applicable based on the current task, this should include:
21-
1. Previous Conversation: High level details about what was discussed throughout the entire conversation with the user. This should be written to allow someone to be able to follow the general overarching conversation flow.
22-
2. Current Work: Describe in detail what was being worked on prior to this request to summarize the conversation. Pay special attention to the more recent messages in the conversation.
23-
3. Key Technical Concepts: List all important technical concepts, technologies, coding conventions, and frameworks discussed, which might be relevant for continuing with this work.
24-
4. Relevant Files and Code: If applicable, enumerate specific files and code sections examined, modified, or created for the task continuation. Pay special attention to the most recent messages and changes.
25-
5. Problem Solving: Document problems solved thus far and any ongoing troubleshooting efforts.
26-
6. Pending Tasks and Next Steps: Outline all pending tasks that you have explicitly been asked to work on, as well as list the next steps you will take for all outstanding work, if applicable. Include code snippets where they add clarity. For any next steps, include direct quotes from the most recent conversation showing exactly what task you were working on and where you left off. This should be verbatim to ensure there's no information loss in context between tasks.
27-
28-
Example summary structure:
29-
1. Previous Conversation:
30-
[Detailed description]
31-
2. Current Work:
32-
[Detailed description]
33-
3. Key Technical Concepts:
34-
- [Concept 1]
35-
- [Concept 2]
36-
- [...]
37-
4. Relevant Files and Code:
38-
- [File Name 1]
39-
- [Summary of why this file is important]
40-
- [Summary of the changes made to this file, if any]
41-
- [Important Code Snippet]
42-
- [File Name 2]
43-
- [Important Code Snippet]
44-
- [...]
45-
5. Problem Solving:
46-
[Detailed description]
47-
6. Pending Tasks and Next Steps:
48-
- [Task 1 details & next steps]
49-
- [Task 2 details & next steps]
50-
- [...]
51-
52-
Output only the summary of the conversation so far, without any additional commentary or explanation.
53-
`
54-
5515
type ContextManagementSettingsProps = HTMLAttributes<HTMLDivElement> & {
5616
autoCondenseContext: boolean
5717
autoCondenseContextPercent: number
58-
condensingApiConfigId?: string
59-
customCondensingPrompt?: string
6018
listApiConfigMeta: any[]
6119
maxOpenTabsContext: number
6220
maxWorkspaceFiles: number
@@ -67,8 +25,6 @@ type ContextManagementSettingsProps = HTMLAttributes<HTMLDivElement> & {
6725
setCachedStateField: SetCachedStateField<
6826
| "autoCondenseContext"
6927
| "autoCondenseContextPercent"
70-
| "condensingApiConfigId"
71-
| "customCondensingPrompt"
7228
| "maxOpenTabsContext"
7329
| "maxWorkspaceFiles"
7430
| "showRooIgnoredFiles"
@@ -81,8 +37,6 @@ type ContextManagementSettingsProps = HTMLAttributes<HTMLDivElement> & {
8137
export const ContextManagementSettings = ({
8238
autoCondenseContext,
8339
autoCondenseContextPercent,
84-
condensingApiConfigId,
85-
customCondensingPrompt,
8640
listApiConfigMeta,
8741
maxOpenTabsContext,
8842
maxWorkspaceFiles,
@@ -321,91 +275,6 @@ export const ContextManagementSettings = ({
321275
: t("settings:contextManagement.condensingThreshold.profileDescription")}
322276
</div>
323277
</div>
324-
325-
{/* API Configuration Selection */}
326-
<div>
327-
<div className="flex items-center gap-4 font-bold">
328-
<span className="codicon codicon-settings-gear" />
329-
<div>{t("settings:contextManagement.condensingApiConfiguration.label")}</div>
330-
</div>
331-
<div>
332-
<div className="text-[13px] text-vscode-descriptionForeground mb-2">
333-
{t("settings:contextManagement.condensingApiConfiguration.description")}
334-
</div>
335-
<Select
336-
value={condensingApiConfigId || "-"}
337-
onValueChange={(value) => {
338-
const newConfigId = value === "-" ? "" : value
339-
setCachedStateField("condensingApiConfigId", newConfigId)
340-
vscode.postMessage({
341-
type: "condensingApiConfigId",
342-
text: newConfigId,
343-
})
344-
}}
345-
data-testid="condensing-api-config-select">
346-
<SelectTrigger className="w-full">
347-
<SelectValue
348-
placeholder={t(
349-
"settings:contextManagement.condensingApiConfiguration.useCurrentConfig",
350-
)}
351-
/>
352-
</SelectTrigger>
353-
<SelectContent>
354-
<SelectItem value="-">
355-
{t(
356-
"settings:contextManagement.condensingApiConfiguration.useCurrentConfig",
357-
)}
358-
</SelectItem>
359-
{(listApiConfigMeta || []).map((config) => (
360-
<SelectItem key={config.id} value={config.id}>
361-
{config.name}
362-
</SelectItem>
363-
))}
364-
</SelectContent>
365-
</Select>
366-
</div>
367-
</div>
368-
369-
{/* Custom Prompt Section */}
370-
<div>
371-
<div className="flex items-center gap-4 font-bold">
372-
<span className="codicon codicon-edit" />
373-
<div>{t("settings:contextManagement.customCondensingPrompt.label")}</div>
374-
</div>
375-
<div>
376-
<div className="text-[13px] text-vscode-descriptionForeground mb-2">
377-
{t("settings:contextManagement.customCondensingPrompt.description")}
378-
</div>
379-
<VSCodeTextArea
380-
resize="vertical"
381-
value={customCondensingPrompt || SUMMARY_PROMPT}
382-
onChange={(e) => {
383-
const value = (e.target as HTMLTextAreaElement).value
384-
setCachedStateField("customCondensingPrompt", value)
385-
vscode.postMessage({
386-
type: "updateCondensingPrompt",
387-
text: value,
388-
})
389-
}}
390-
rows={8}
391-
className="w-full font-mono text-sm"
392-
/>
393-
<div className="mt-2">
394-
<Button
395-
variant="secondary"
396-
size="sm"
397-
onClick={() => {
398-
setCachedStateField("customCondensingPrompt", SUMMARY_PROMPT)
399-
vscode.postMessage({
400-
type: "updateCondensingPrompt",
401-
text: SUMMARY_PROMPT,
402-
})
403-
}}>
404-
{t("settings:contextManagement.customCondensingPrompt.reset")}
405-
</Button>
406-
</div>
407-
</div>
408-
</div>
409278
</div>
410279
)}
411280
</Section>

0 commit comments

Comments
 (0)