Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# AGENTS.md

This file provides guidance to agents when working with code in this repository.

- Settings View Pattern: When working on `SettingsView`, inputs must bind to the local `cachedState`, NOT the live `useExtensionState()`. The `cachedState` acts as a buffer for user edits, isolating them from the `ContextProxy` source-of-truth until the user explicitly clicks "Save". Wiring inputs directly to the live state causes race conditions.
20 changes: 10 additions & 10 deletions webview-ui/src/components/settings/PromptsSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,17 @@ import { SearchableSetting } from "./SearchableSetting"
interface PromptsSettingsProps {
customSupportPrompts: Record<string, string | undefined>
setCustomSupportPrompts: (prompts: Record<string, string | undefined>) => void
customCondensingPrompt?: string
setCustomCondensingPrompt?: (value: string) => void
includeTaskHistoryInEnhance?: boolean
setIncludeTaskHistoryInEnhance?: (value: boolean) => void
}

const PromptsSettings = ({
customSupportPrompts,
setCustomSupportPrompts,
customCondensingPrompt: propsCustomCondensingPrompt,
setCustomCondensingPrompt: propsSetCustomCondensingPrompt,
includeTaskHistoryInEnhance: propsIncludeTaskHistoryInEnhance,
setIncludeTaskHistoryInEnhance: propsSetIncludeTaskHistoryInEnhance,
}: PromptsSettingsProps) => {
Expand All @@ -40,12 +44,16 @@ const PromptsSettings = ({
setEnhancementApiConfigId,
condensingApiConfigId,
setCondensingApiConfigId,
customCondensingPrompt,
setCustomCondensingPrompt,
customCondensingPrompt: contextCustomCondensingPrompt,
setCustomCondensingPrompt: contextSetCustomCondensingPrompt,
includeTaskHistoryInEnhance: contextIncludeTaskHistoryInEnhance,
setIncludeTaskHistoryInEnhance: contextSetIncludeTaskHistoryInEnhance,
} = 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
const includeTaskHistoryInEnhance = propsIncludeTaskHistoryInEnhance ?? contextIncludeTaskHistoryInEnhance ?? true
const setIncludeTaskHistoryInEnhance = propsSetIncludeTaskHistoryInEnhance ?? contextSetIncludeTaskHistoryInEnhance
Expand Down Expand Up @@ -76,10 +84,6 @@ const PromptsSettings = ({

if (type === "CONDENSE") {
setCustomCondensingPrompt(finalValue ?? supportPrompt.default.CONDENSE)
vscode.postMessage({
type: "updateCondensingPrompt",
text: finalValue ?? supportPrompt.default.CONDENSE,
})
// Also update the customSupportPrompts to trigger change detection
const updatedPrompts = { ...customSupportPrompts }
if (finalValue === undefined) {
Expand All @@ -102,10 +106,6 @@ const PromptsSettings = ({
const handleSupportReset = (type: SupportPromptType) => {
if (type === "CONDENSE") {
setCustomCondensingPrompt(supportPrompt.default.CONDENSE)
vscode.postMessage({
type: "updateCondensingPrompt",
text: supportPrompt.default.CONDENSE,
})
// Also update the customSupportPrompts to trigger change detection
const updatedPrompts = { ...customSupportPrompts }
delete updatedPrompts[type]
Expand Down
4 changes: 4 additions & 0 deletions webview-ui/src/components/settings/SettingsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,10 @@ const SettingsView = forwardRef<SettingsViewRef, SettingsViewProps>(({ onDone, t
<PromptsSettings
customSupportPrompts={customSupportPrompts || {}}
setCustomSupportPrompts={setCustomSupportPromptsField}
customCondensingPrompt={customCondensingPrompt}
setCustomCondensingPrompt={(value) =>
setCachedStateField("customCondensingPrompt", value)
}
includeTaskHistoryInEnhance={includeTaskHistoryInEnhance}
setIncludeTaskHistoryInEnhance={(value) =>
setCachedStateField("includeTaskHistoryInEnhance", value)
Expand Down
Loading