Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/core/webview/webviewMessageHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1163,6 +1163,11 @@ export const webviewMessageHandler = async (
await provider.postStateToWebview()
break
case "updateCondensingPrompt":
// Store the condensing prompt in customSupportPrompts["CONDENSE"] instead of customCondensingPrompt
const currentSupportPrompts = getGlobalState("customSupportPrompts") ?? {}
const updatedSupportPrompts = { ...currentSupportPrompts, CONDENSE: message.text }
await updateGlobalState("customSupportPrompts", updatedSupportPrompts)
// Also update the old field for backward compatibility during migration
await updateGlobalState("customCondensingPrompt", message.text)
await provider.postStateToWebview()
break
Expand Down
40 changes: 40 additions & 0 deletions src/shared/support-prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ interface SupportPromptConfig {

type SupportPromptType =
| "ENHANCE"
| "CONDENSE"
| "EXPLAIN"
| "FIX"
| "IMPROVE"
Expand All @@ -49,6 +50,45 @@ const supportPromptConfigs: Record<SupportPromptType, SupportPromptConfig> = {
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):

\${userInput}`,
},
CONDENSE: {
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.
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.

Your summary should be structured as follows:
Context: The context to continue the conversation with. If applicable based on the current task, this should include:
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.
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.
3. Key Technical Concepts: List all important technical concepts, technologies, coding conventions, and frameworks discussed, which might be relevant for continuing with this work.
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.
5. Problem Solving: Document problems solved thus far and any ongoing troubleshooting efforts.
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.

Example summary structure:
1. Previous Conversation:
[Detailed description]
2. Current Work:
[Detailed description]
3. Key Technical Concepts:
- [Concept 1]
- [Concept 2]
- [...]
4. Relevant Files and Code:
- [File Name 1]
- [Summary of why this file is important]
- [Summary of the changes made to this file, if any]
- [Important Code Snippet]
- [File Name 2]
- [Important Code Snippet]
- [...]
5. Problem Solving:
[Detailed description]
6. Pending Tasks and Next Steps:
- [Task 1 details & next steps]
- [Task 2 details & next steps]
- [...]

Output only the summary of the conversation so far, without any additional commentary or explanation.`,
},
EXPLAIN: {
template: `Explain the following code from file path \${filePath}:\${startLine}-\${endLine}
Expand Down
135 changes: 2 additions & 133 deletions webview-ui/src/components/settings/ContextManagementSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,62 +1,20 @@
import { HTMLAttributes } from "react"
import React from "react"
import { useAppTranslation } from "@/i18n/TranslationContext"
import { VSCodeCheckbox, VSCodeTextArea } from "@vscode/webview-ui-toolkit/react"
import { VSCodeCheckbox } from "@vscode/webview-ui-toolkit/react"
import { Database, FoldVertical } from "lucide-react"

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

import { SetCachedStateField } from "./types"
import { SectionHeader } from "./SectionHeader"
import { Section } from "./Section"
import { vscode } from "@/utils/vscode"

const SUMMARY_PROMPT = `\
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.
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.

Your summary should be structured as follows:
Context: The context to continue the conversation with. If applicable based on the current task, this should include:
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.
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.
3. Key Technical Concepts: List all important technical concepts, technologies, coding conventions, and frameworks discussed, which might be relevant for continuing with this work.
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.
5. Problem Solving: Document problems solved thus far and any ongoing troubleshooting efforts.
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.

Example summary structure:
1. Previous Conversation:
[Detailed description]
2. Current Work:
[Detailed description]
3. Key Technical Concepts:
- [Concept 1]
- [Concept 2]
- [...]
4. Relevant Files and Code:
- [File Name 1]
- [Summary of why this file is important]
- [Summary of the changes made to this file, if any]
- [Important Code Snippet]
- [File Name 2]
- [Important Code Snippet]
- [...]
5. Problem Solving:
[Detailed description]
6. Pending Tasks and Next Steps:
- [Task 1 details & next steps]
- [Task 2 details & next steps]
- [...]

Output only the summary of the conversation so far, without any additional commentary or explanation.
`

type ContextManagementSettingsProps = HTMLAttributes<HTMLDivElement> & {
autoCondenseContext: boolean
autoCondenseContextPercent: number
condensingApiConfigId?: string
customCondensingPrompt?: string
listApiConfigMeta: any[]
maxOpenTabsContext: number
maxWorkspaceFiles: number
Expand All @@ -67,8 +25,6 @@ type ContextManagementSettingsProps = HTMLAttributes<HTMLDivElement> & {
setCachedStateField: SetCachedStateField<
| "autoCondenseContext"
| "autoCondenseContextPercent"
| "condensingApiConfigId"
| "customCondensingPrompt"
| "maxOpenTabsContext"
| "maxWorkspaceFiles"
| "showRooIgnoredFiles"
Expand All @@ -81,8 +37,6 @@ type ContextManagementSettingsProps = HTMLAttributes<HTMLDivElement> & {
export const ContextManagementSettings = ({
autoCondenseContext,
autoCondenseContextPercent,
condensingApiConfigId,
customCondensingPrompt,
listApiConfigMeta,
maxOpenTabsContext,
maxWorkspaceFiles,
Expand Down Expand Up @@ -321,91 +275,6 @@ export const ContextManagementSettings = ({
: t("settings:contextManagement.condensingThreshold.profileDescription")}
</div>
</div>

{/* API Configuration Selection */}
<div>
<div className="flex items-center gap-4 font-bold">
<span className="codicon codicon-settings-gear" />
<div>{t("settings:contextManagement.condensingApiConfiguration.label")}</div>
</div>
<div>
<div className="text-[13px] text-vscode-descriptionForeground mb-2">
{t("settings:contextManagement.condensingApiConfiguration.description")}
</div>
<Select
value={condensingApiConfigId || "-"}
onValueChange={(value) => {
const newConfigId = value === "-" ? "" : value
setCachedStateField("condensingApiConfigId", newConfigId)
vscode.postMessage({
type: "condensingApiConfigId",
text: newConfigId,
})
}}
data-testid="condensing-api-config-select">
<SelectTrigger className="w-full">
<SelectValue
placeholder={t(
"settings:contextManagement.condensingApiConfiguration.useCurrentConfig",
)}
/>
</SelectTrigger>
<SelectContent>
<SelectItem value="-">
{t(
"settings:contextManagement.condensingApiConfiguration.useCurrentConfig",
)}
</SelectItem>
{(listApiConfigMeta || []).map((config) => (
<SelectItem key={config.id} value={config.id}>
{config.name}
</SelectItem>
))}
</SelectContent>
</Select>
</div>
</div>

{/* Custom Prompt Section */}
<div>
<div className="flex items-center gap-4 font-bold">
<span className="codicon codicon-edit" />
<div>{t("settings:contextManagement.customCondensingPrompt.label")}</div>
</div>
<div>
<div className="text-[13px] text-vscode-descriptionForeground mb-2">
{t("settings:contextManagement.customCondensingPrompt.description")}
</div>
<VSCodeTextArea
resize="vertical"
value={customCondensingPrompt || SUMMARY_PROMPT}
onChange={(e) => {
const value = (e.target as HTMLTextAreaElement).value
setCachedStateField("customCondensingPrompt", value)
vscode.postMessage({
type: "updateCondensingPrompt",
text: value,
})
}}
rows={8}
className="w-full font-mono text-sm"
/>
<div className="mt-2">
<Button
variant="secondary"
size="sm"
onClick={() => {
setCachedStateField("customCondensingPrompt", SUMMARY_PROMPT)
vscode.postMessage({
type: "updateCondensingPrompt",
text: SUMMARY_PROMPT,
})
}}>
{t("settings:contextManagement.customCondensingPrompt.reset")}
</Button>
</div>
</div>
</div>
</div>
)}
</Section>
Expand Down
Loading