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
14 changes: 14 additions & 0 deletions src/core/webview/ClineProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -1161,6 +1162,14 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> 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<boolean> {
const promptFilePath = getSystemPromptFilePath(this.cwd, mode)
return await fileExistsAtPath(promptFilePath)
}

async getStateToPostToWebview() {
const {
apiConfiguration,
Expand Down Expand Up @@ -1224,6 +1233,10 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
const allowedCommands = vscode.workspace.getConfiguration("roo-cline").get<string[]>("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,
Expand Down Expand Up @@ -1296,6 +1309,7 @@ export class ClineProvider extends EventEmitter<ClineProviderEvents> implements
renderContext: this.renderContext,
maxReadFileLine: maxReadFileLine ?? 500,
settingsImportedAt: this.settingsImportedAt,
hasSystemPromptOverride,
}
}

Expand Down
1 change: 1 addition & 0 deletions src/shared/WebviewMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export interface WebviewMessage {
source?: "global" | "project"
requestId?: string
ids?: string[]
hasSystemPromptOverride?: boolean
}

export const checkoutDiffPayloadSchema = z.object({
Expand Down
9 changes: 9 additions & 0 deletions webview-ui/src/components/chat/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -77,6 +78,7 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
alwaysAllowSubtasks,
customModes,
telemetrySetting,
hasSystemPromptOverride,
} = useExtensionState()

//const task = messages.length > 0 ? (messages[0].say === "task" ? messages[0] : undefined) : undefined) : undefined
Expand Down Expand Up @@ -1205,6 +1207,13 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
onClose={handleTaskCloseButtonClick}
/>

{/* System prompt override warning */}
{hasSystemPromptOverride && (
<div className="px-3">
<SystemPromptWarning />
</div>
)}

{/* Checkpoint warning message */}
{showCheckpointWarning && (
<div className="px-3">
Expand Down
17 changes: 17 additions & 0 deletions webview-ui/src/components/chat/SystemPromptWarning.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from "react"
import { useAppTranslation } from "@/i18n/TranslationContext"

export const SystemPromptWarning: React.FC = () => {
const { t } = useAppTranslation()

return (
<div className="flex items-center px-4 py-2 mb-2 text-sm rounded bg-vscode-editorWarning-foreground text-vscode-editor-background">
<div className="flex items-center justify-center w-5 h-5 mr-2">
<span className="codicon codicon-warning" />
</div>
<span>{t("chat:systemPromptWarning")}</span>
</div>
)
}

export default SystemPromptWarning
1 change: 1 addition & 0 deletions webview-ui/src/context/ExtensionStateContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 }>
Expand Down
3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/ca/chat.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/de/chat.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/en/chat.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/es/chat.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/fr/chat.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/hi/chat.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,5 +211,6 @@
"scrollUp": "ऊपर स्क्रॉल करें",
"close": "ब्राउज़र बंद करें"
}
}
},
"systemPromptWarning": "चेतावनी: कस्टम सिस्टम प्रॉम्प्ट ओवरराइड सक्रिय है। यह कार्यक्षमता को गंभीर रूप से बाधित कर सकता है और अनियमित व्यवहार का कारण बन सकता है।"
}
3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/it/chat.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/ja/chat.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,5 +211,6 @@
"scrollUp": "上にスクロール",
"close": "ブラウザを閉じる"
}
}
},
"systemPromptWarning": "警告:カスタムシステムプロンプトの上書きが有効です。これにより機能が深刻に損なわれ、予測不可能な動作が発生する可能性があります。"
}
3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/ko/chat.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,5 +211,6 @@
"scrollUp": "위로 스크롤",
"close": "브라우저 닫기"
}
}
},
"systemPromptWarning": "경고: 사용자 정의 시스템 프롬프트 재정의가 활성화되었습니다. 이로 인해 기능이 심각하게 손상되고 예측할 수 없는 동작이 발생할 수 있습니다."
}
3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/pl/chat.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/pt-BR/chat.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/tr/chat.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/vi/chat.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/zh-CN/chat.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,5 +211,6 @@
"scrollUp": "向上滚动",
"close": "关闭浏览器"
}
}
},
"systemPromptWarning": "警告:自定义系统提示词覆盖已激活。这可能严重破坏功能并导致不可预测的行为。"
}
3 changes: 2 additions & 1 deletion webview-ui/src/i18n/locales/zh-TW/chat.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,5 +211,6 @@
"scrollUp": "向上捲動",
"close": "關閉瀏覽器"
}
}
},
"systemPromptWarning": "警告:自訂系統提示詞覆蓋已啟用。這可能嚴重破壞功能並導致不可預測的行為。"
}
3 changes: 3 additions & 0 deletions webview-ui/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down