diff --git a/src/core/webview/ClineProvider.ts b/src/core/webview/ClineProvider.ts index f4c26c3dfc..432ac6420b 100644 --- a/src/core/webview/ClineProvider.ts +++ b/src/core/webview/ClineProvider.ts @@ -49,6 +49,7 @@ import { ACTION_NAMES } from "../CodeActionProvider" import { Cline, ClineOptions } from "../Cline" import { getNonce } from "./getNonce" import { getUri } from "./getUri" +import { getSystemPromptFilePath } from "../prompts/sections/custom-system-prompt" import { telemetryService } from "../../services/telemetry/TelemetryService" import { getWorkspacePath } from "../../utils/path" import { webviewMessageHandler } from "./webviewMessageHandler" @@ -1161,6 +1162,14 @@ export class ClineProvider extends EventEmitter implements this.postMessageToWebview({ type: "state", state }) } + /** + * Checks if there is a file-based system prompt override for the given mode + */ + async hasFileBasedSystemPromptOverride(mode: Mode): Promise { + const promptFilePath = getSystemPromptFilePath(this.cwd, mode) + return await fileExistsAtPath(promptFilePath) + } + async getStateToPostToWebview() { const { apiConfiguration, @@ -1224,6 +1233,10 @@ export class ClineProvider extends EventEmitter implements const allowedCommands = vscode.workspace.getConfiguration("roo-cline").get("allowedCommands") || [] const cwd = this.cwd + // Check if there's a system prompt override for the current mode + const currentMode = mode ?? defaultModeSlug + const hasSystemPromptOverride = await this.hasFileBasedSystemPromptOverride(currentMode) + return { version: this.context.extension?.packageJSON?.version ?? "", apiConfiguration, @@ -1296,6 +1309,7 @@ export class ClineProvider extends EventEmitter implements renderContext: this.renderContext, maxReadFileLine: maxReadFileLine ?? 500, settingsImportedAt: this.settingsImportedAt, + hasSystemPromptOverride, } } diff --git a/src/shared/WebviewMessage.ts b/src/shared/WebviewMessage.ts index f1ab993679..83725bc5c3 100644 --- a/src/shared/WebviewMessage.ts +++ b/src/shared/WebviewMessage.ts @@ -150,6 +150,7 @@ export interface WebviewMessage { source?: "global" | "project" requestId?: string ids?: string[] + hasSystemPromptOverride?: boolean } export const checkoutDiffPayloadSchema = z.object({ diff --git a/webview-ui/src/components/chat/ChatView.tsx b/webview-ui/src/components/chat/ChatView.tsx index 23072e7b9c..7b84b81ab9 100644 --- a/webview-ui/src/components/chat/ChatView.tsx +++ b/webview-ui/src/components/chat/ChatView.tsx @@ -27,6 +27,7 @@ import ChatRow from "./ChatRow" import ChatTextArea from "./ChatTextArea" import TaskHeader from "./TaskHeader" import AutoApproveMenu from "./AutoApproveMenu" +import SystemPromptWarning from "./SystemPromptWarning" import { AudioType } from "@roo/shared/WebviewMessage" import { validateCommand } from "@src/utils/command-validation" import { getAllModes } from "@roo/shared/modes" @@ -77,6 +78,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction 0 ? (messages[0].say === "task" ? messages[0] : undefined) : undefined) : undefined @@ -1205,6 +1207,13 @@ const ChatViewComponent: React.ForwardRefRenderFunction + {/* System prompt override warning */} + {hasSystemPromptOverride && ( +
+ +
+ )} + {/* Checkpoint warning message */} {showCheckpointWarning && (
diff --git a/webview-ui/src/components/chat/SystemPromptWarning.tsx b/webview-ui/src/components/chat/SystemPromptWarning.tsx new file mode 100644 index 0000000000..0ed7a72733 --- /dev/null +++ b/webview-ui/src/components/chat/SystemPromptWarning.tsx @@ -0,0 +1,17 @@ +import React from "react" +import { useAppTranslation } from "@/i18n/TranslationContext" + +export const SystemPromptWarning: React.FC = () => { + const { t } = useAppTranslation() + + return ( +
+
+ +
+ {t("chat:systemPromptWarning")} +
+ ) +} + +export default SystemPromptWarning diff --git a/webview-ui/src/context/ExtensionStateContext.tsx b/webview-ui/src/context/ExtensionStateContext.tsx index 26f43db81a..90629edfb1 100644 --- a/webview-ui/src/context/ExtensionStateContext.tsx +++ b/webview-ui/src/context/ExtensionStateContext.tsx @@ -17,6 +17,7 @@ export interface ExtensionStateContextType extends ExtensionState { showWelcome: boolean theme: any mcpServers: McpServer[] + hasSystemPromptOverride?: boolean currentCheckpoint?: string filePaths: string[] openedTabs: Array<{ label: string; isActive: boolean; path?: string }> diff --git a/webview-ui/src/i18n/locales/ca/chat.json b/webview-ui/src/i18n/locales/ca/chat.json index 702a86fc1f..fcad714a7e 100644 --- a/webview-ui/src/i18n/locales/ca/chat.json +++ b/webview-ui/src/i18n/locales/ca/chat.json @@ -211,5 +211,6 @@ "scrollUp": "Desplaçar amunt", "close": "Tancar navegador" } - } + }, + "systemPromptWarning": "ADVERTÈNCIA: S'ha activat una substitució personalitzada d'instruccions del sistema. Això pot trencar greument la funcionalitat i causar un comportament impredictible." } diff --git a/webview-ui/src/i18n/locales/de/chat.json b/webview-ui/src/i18n/locales/de/chat.json index e416423f98..ef92900bac 100644 --- a/webview-ui/src/i18n/locales/de/chat.json +++ b/webview-ui/src/i18n/locales/de/chat.json @@ -211,5 +211,6 @@ "scrollUp": "Nach oben scrollen", "close": "Browser schließen" } - } + }, + "systemPromptWarning": "WARNUNG: Benutzerdefinierte Systemaufforderung aktiv. Dies kann die Funktionalität erheblich beeinträchtigen und zu unvorhersehbarem Verhalten führen." } diff --git a/webview-ui/src/i18n/locales/en/chat.json b/webview-ui/src/i18n/locales/en/chat.json index 6f4a0a1e54..1c077b1761 100644 --- a/webview-ui/src/i18n/locales/en/chat.json +++ b/webview-ui/src/i18n/locales/en/chat.json @@ -211,5 +211,6 @@ "scrollUp": "Scroll up", "close": "Close browser" } - } + }, + "systemPromptWarning": "WARNING: Custom system prompt override active. This can severely break functionality and cause unpredictable behavior." } diff --git a/webview-ui/src/i18n/locales/es/chat.json b/webview-ui/src/i18n/locales/es/chat.json index 9743ed85f5..ac46118723 100644 --- a/webview-ui/src/i18n/locales/es/chat.json +++ b/webview-ui/src/i18n/locales/es/chat.json @@ -211,5 +211,6 @@ "scrollUp": "Desplazar hacia arriba", "close": "Cerrar navegador" } - } + }, + "systemPromptWarning": "ADVERTENCIA: Anulación de instrucciones del sistema personalizada activa. Esto puede romper gravemente la funcionalidad y causar un comportamiento impredecible." } diff --git a/webview-ui/src/i18n/locales/fr/chat.json b/webview-ui/src/i18n/locales/fr/chat.json index 0025d82889..f5b6a6135e 100644 --- a/webview-ui/src/i18n/locales/fr/chat.json +++ b/webview-ui/src/i18n/locales/fr/chat.json @@ -211,5 +211,6 @@ "scrollUp": "Défiler vers le haut", "close": "Fermer le navigateur" } - } + }, + "systemPromptWarning": "AVERTISSEMENT : Remplacement d'instructions système personnalisées actif. Cela peut gravement perturber la fonctionnalité et provoquer un comportement imprévisible." } diff --git a/webview-ui/src/i18n/locales/hi/chat.json b/webview-ui/src/i18n/locales/hi/chat.json index f4391e624f..91491cf3e6 100644 --- a/webview-ui/src/i18n/locales/hi/chat.json +++ b/webview-ui/src/i18n/locales/hi/chat.json @@ -211,5 +211,6 @@ "scrollUp": "ऊपर स्क्रॉल करें", "close": "ब्राउज़र बंद करें" } - } + }, + "systemPromptWarning": "चेतावनी: कस्टम सिस्टम प्रॉम्प्ट ओवरराइड सक्रिय है। यह कार्यक्षमता को गंभीर रूप से बाधित कर सकता है और अनियमित व्यवहार का कारण बन सकता है।" } diff --git a/webview-ui/src/i18n/locales/it/chat.json b/webview-ui/src/i18n/locales/it/chat.json index 62921786d1..d54dd9a95c 100644 --- a/webview-ui/src/i18n/locales/it/chat.json +++ b/webview-ui/src/i18n/locales/it/chat.json @@ -211,5 +211,6 @@ "scrollUp": "Scorri verso l'alto", "close": "Chiudi browser" } - } + }, + "systemPromptWarning": "ATTENZIONE: Sovrascrittura personalizzata delle istruzioni di sistema attiva. Questo può compromettere gravemente le funzionalità e causare comportamenti imprevedibili." } diff --git a/webview-ui/src/i18n/locales/ja/chat.json b/webview-ui/src/i18n/locales/ja/chat.json index 4d0b2d6413..31094a763c 100644 --- a/webview-ui/src/i18n/locales/ja/chat.json +++ b/webview-ui/src/i18n/locales/ja/chat.json @@ -211,5 +211,6 @@ "scrollUp": "上にスクロール", "close": "ブラウザを閉じる" } - } + }, + "systemPromptWarning": "警告:カスタムシステムプロンプトの上書きが有効です。これにより機能が深刻に損なわれ、予測不可能な動作が発生する可能性があります。" } diff --git a/webview-ui/src/i18n/locales/ko/chat.json b/webview-ui/src/i18n/locales/ko/chat.json index 40c3c580d7..938bdca76b 100644 --- a/webview-ui/src/i18n/locales/ko/chat.json +++ b/webview-ui/src/i18n/locales/ko/chat.json @@ -211,5 +211,6 @@ "scrollUp": "위로 스크롤", "close": "브라우저 닫기" } - } + }, + "systemPromptWarning": "경고: 사용자 정의 시스템 프롬프트 재정의가 활성화되었습니다. 이로 인해 기능이 심각하게 손상되고 예측할 수 없는 동작이 발생할 수 있습니다." } diff --git a/webview-ui/src/i18n/locales/pl/chat.json b/webview-ui/src/i18n/locales/pl/chat.json index db17efd24f..10884b102a 100644 --- a/webview-ui/src/i18n/locales/pl/chat.json +++ b/webview-ui/src/i18n/locales/pl/chat.json @@ -211,5 +211,6 @@ "scrollUp": "Przewiń w górę", "close": "Zamknij przeglądarkę" } - } + }, + "systemPromptWarning": "OSTRZEŻENIE: Aktywne niestandardowe zastąpienie instrukcji systemowych. Może to poważnie zakłócić funkcjonalność i powodować nieprzewidywalne zachowanie." } diff --git a/webview-ui/src/i18n/locales/pt-BR/chat.json b/webview-ui/src/i18n/locales/pt-BR/chat.json index 8d6c420236..fe6ef1bdef 100644 --- a/webview-ui/src/i18n/locales/pt-BR/chat.json +++ b/webview-ui/src/i18n/locales/pt-BR/chat.json @@ -211,5 +211,6 @@ "scrollUp": "Rolar para cima", "close": "Fechar navegador" } - } + }, + "systemPromptWarning": "AVISO: Substituição personalizada de instrução do sistema ativa. Isso pode comprometer gravemente a funcionalidade e causar comportamento imprevisível." } diff --git a/webview-ui/src/i18n/locales/tr/chat.json b/webview-ui/src/i18n/locales/tr/chat.json index 1f46537a31..34c5fd2911 100644 --- a/webview-ui/src/i18n/locales/tr/chat.json +++ b/webview-ui/src/i18n/locales/tr/chat.json @@ -211,5 +211,6 @@ "scrollUp": "Yukarı kaydır", "close": "Tarayıcıyı kapat" } - } + }, + "systemPromptWarning": "UYARI: Özel sistem komut geçersiz kılma aktif. Bu işlevselliği ciddi şekilde bozabilir ve öngörülemeyen davranışlara neden olabilir." } diff --git a/webview-ui/src/i18n/locales/vi/chat.json b/webview-ui/src/i18n/locales/vi/chat.json index 08e5ef4fe8..3fe66b54ba 100644 --- a/webview-ui/src/i18n/locales/vi/chat.json +++ b/webview-ui/src/i18n/locales/vi/chat.json @@ -211,5 +211,6 @@ "scrollUp": "Cuộn lên", "close": "Đóng trình duyệt" } - } + }, + "systemPromptWarning": "CẢNH BÁO: Đã kích hoạt ghi đè lệnh nhắc hệ thống tùy chỉnh. Điều này có thể phá vỡ nghiêm trọng chức năng và gây ra hành vi không thể dự đoán." } diff --git a/webview-ui/src/i18n/locales/zh-CN/chat.json b/webview-ui/src/i18n/locales/zh-CN/chat.json index 569c80be9f..3772e10884 100644 --- a/webview-ui/src/i18n/locales/zh-CN/chat.json +++ b/webview-ui/src/i18n/locales/zh-CN/chat.json @@ -211,5 +211,6 @@ "scrollUp": "向上滚动", "close": "关闭浏览器" } - } + }, + "systemPromptWarning": "警告:自定义系统提示词覆盖已激活。这可能严重破坏功能并导致不可预测的行为。" } diff --git a/webview-ui/src/i18n/locales/zh-TW/chat.json b/webview-ui/src/i18n/locales/zh-TW/chat.json index e7d239e930..d9c745ebf3 100644 --- a/webview-ui/src/i18n/locales/zh-TW/chat.json +++ b/webview-ui/src/i18n/locales/zh-TW/chat.json @@ -211,5 +211,6 @@ "scrollUp": "向上捲動", "close": "關閉瀏覽器" } - } + }, + "systemPromptWarning": "警告:自訂系統提示詞覆蓋已啟用。這可能嚴重破壞功能並導致不可預測的行為。" } diff --git a/webview-ui/src/index.css b/webview-ui/src/index.css index 21421c66ac..efc7e8c11e 100644 --- a/webview-ui/src/index.css +++ b/webview-ui/src/index.css @@ -68,6 +68,9 @@ --color-vscode-editorGroup-border: var(--vscode-editorGroup-border); + --color-vscode-editorWarning-foreground: var(--vscode-editorWarning-foreground); + --color-vscode-editorWarning-background: var(--vscode-editorWarning-background); + --color-vscode-button-foreground: var(--vscode-button-foreground); --color-vscode-button-background: var(--vscode-button-background); --color-vscode-button-secondaryForeground: var(--vscode-button-secondaryForeground);