mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-10-07 02:58:15 +00:00
Merge pull request #1507 from hannesrudolph/optional-mode-creation
feat: Add toggle for custom mode creation
This commit is contained in:
commit
c70595b9f0
7 changed files with 66 additions and 3 deletions
|
|
@ -11,12 +11,19 @@ export async function getModesSection(context: vscode.ExtensionContext): Promise
|
|||
// Get all modes with their overrides from extension state
|
||||
const allModes = await getAllModesWithPrompts(context)
|
||||
|
||||
return `====
|
||||
// Get enableCustomModeCreation setting from extension state
|
||||
const shouldEnableCustomModeCreation = await context.globalState.get<boolean>("enableCustomModeCreation") ?? true
|
||||
|
||||
let modesContent = `====
|
||||
|
||||
MODES
|
||||
|
||||
- These are the currently available modes:
|
||||
${allModes.map((mode: ModeConfig) => ` * "${mode.name}" mode (${mode.slug}) - ${mode.roleDefinition.split(".")[0]}`).join("\n")}
|
||||
${allModes.map((mode: ModeConfig) => ` * "${mode.name}" mode (${mode.slug}) - ${mode.roleDefinition.split(".")[0]}`).join("\n")}`
|
||||
|
||||
// Only include custom modes documentation if the feature is enabled
|
||||
if (shouldEnableCustomModeCreation) {
|
||||
modesContent += `
|
||||
|
||||
- Custom modes can be configured in two ways:
|
||||
1. Globally via '${customModesPath}' (created automatically on startup)
|
||||
|
|
@ -56,4 +63,7 @@ Both files should follow this structure:
|
|||
}
|
||||
]
|
||||
}`
|
||||
}
|
||||
|
||||
return modesContent
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1478,6 +1478,10 @@ export class ClineProvider implements vscode.WebviewViewProvider {
|
|||
await this.updateGlobalState("enhancementApiConfigId", message.text)
|
||||
await this.postStateToWebview()
|
||||
break
|
||||
case "enableCustomModeCreation":
|
||||
await this.updateGlobalState("enableCustomModeCreation", message.bool ?? true)
|
||||
await this.postStateToWebview()
|
||||
break
|
||||
case "autoApprovalEnabled":
|
||||
await this.updateGlobalState("autoApprovalEnabled", message.bool ?? false)
|
||||
await this.postStateToWebview()
|
||||
|
|
|
|||
|
|
@ -129,6 +129,7 @@ export interface ExtensionState {
|
|||
terminalOutputLimit?: number
|
||||
mcpEnabled: boolean
|
||||
enableMcpServerCreation: boolean
|
||||
enableCustomModeCreation?: boolean
|
||||
mode: Mode
|
||||
modeApiConfigs?: Record<Mode, string>
|
||||
enhancementApiConfigId?: string
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ export interface WebviewMessage {
|
|||
| "terminalOutputLimit"
|
||||
| "mcpEnabled"
|
||||
| "enableMcpServerCreation"
|
||||
| "enableCustomModeCreation"
|
||||
| "searchCommits"
|
||||
| "alwaysApproveResubmit"
|
||||
| "requestDelaySeconds"
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ export const GLOBAL_STATE_KEYS = [
|
|||
"enhancementApiConfigId",
|
||||
"experiments", // Map of experiment IDs to their enabled state
|
||||
"autoApprovalEnabled",
|
||||
"enableCustomModeCreation", // Enable the ability for Roo to create custom modes
|
||||
"customModes", // Array of custom modes
|
||||
"unboundModelId",
|
||||
"requestyModelId",
|
||||
|
|
|
|||
|
|
@ -71,6 +71,8 @@ const PromptsView = ({ onDone }: PromptsViewProps) => {
|
|||
preferredLanguage,
|
||||
setPreferredLanguage,
|
||||
customModes,
|
||||
enableCustomModeCreation,
|
||||
setEnableCustomModeCreation,
|
||||
} = useExtensionState()
|
||||
|
||||
// Memoize modes to preserve array order
|
||||
|
|
@ -341,6 +343,17 @@ const PromptsView = ({ onDone }: PromptsViewProps) => {
|
|||
return () => document.removeEventListener("click", handleClickOutside)
|
||||
}, [showConfigMenu])
|
||||
|
||||
// Add effect to sync enableCustomModeCreation with backend
|
||||
useEffect(() => {
|
||||
if (enableCustomModeCreation !== undefined) {
|
||||
// Send the value to the extension's global state
|
||||
vscode.postMessage({
|
||||
type: "enableCustomModeCreation", // Using dedicated message type
|
||||
bool: enableCustomModeCreation,
|
||||
})
|
||||
}
|
||||
}, [enableCustomModeCreation])
|
||||
|
||||
useEffect(() => {
|
||||
const handler = (event: MessageEvent) => {
|
||||
const message = event.data
|
||||
|
|
@ -541,7 +554,6 @@ const PromptsView = ({ onDone }: PromptsViewProps) => {
|
|||
in your workspace.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="mt-5">
|
||||
<div onClick={(e) => e.stopPropagation()} className="flex justify-between items-center mb-3">
|
||||
<h3 className="text-vscode-foreground m-0">Modes</h3>
|
||||
|
|
@ -1010,6 +1022,35 @@ const PromptsView = ({ onDone }: PromptsViewProps) => {
|
|||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/*
|
||||
NOTE: This setting is placed in PromptsView rather than SettingsView since it
|
||||
directly affects the functionality related to modes and custom mode creation,
|
||||
which are managed in this component. This is an intentional deviation from
|
||||
the standard pattern described in cline_docs/settings.md.
|
||||
*/}
|
||||
<div className="mb-4 mt-4">
|
||||
<VSCodeCheckbox
|
||||
checked={enableCustomModeCreation ?? true}
|
||||
onChange={(e: any) => {
|
||||
// Just update the local state through React context
|
||||
// The React context will update the global state
|
||||
setEnableCustomModeCreation(e.target.checked)
|
||||
}}>
|
||||
<span style={{ fontWeight: "500" }}>Enable Custom Mode Creation Through Prompts</span>
|
||||
</VSCodeCheckbox>
|
||||
<p
|
||||
style={{
|
||||
fontSize: "12px",
|
||||
marginTop: "5px",
|
||||
color: "var(--vscode-descriptionForeground)",
|
||||
}}>
|
||||
When enabled, Roo allows you to create custom modes using prompts like ‘Make me a custom
|
||||
mode that…’. Disabling this reduces your system prompt by about 700 tokens when this feature
|
||||
isn’t needed. When disabled you can still manually create custom modes using the + button
|
||||
above or by editing the related config JSON.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
|
|
|
|||
|
|
@ -53,6 +53,8 @@ export interface ExtensionStateContextType extends ExtensionState {
|
|||
setMcpEnabled: (value: boolean) => void
|
||||
enableMcpServerCreation: boolean
|
||||
setEnableMcpServerCreation: (value: boolean) => void
|
||||
enableCustomModeCreation?: boolean
|
||||
setEnableCustomModeCreation: (value: boolean) => void
|
||||
alwaysApproveResubmit?: boolean
|
||||
setAlwaysApproveResubmit: (value: boolean) => void
|
||||
requestDelaySeconds: number
|
||||
|
|
@ -118,6 +120,7 @@ export const ExtensionStateContextProvider: React.FC<{ children: React.ReactNode
|
|||
checkpointStorage: "task",
|
||||
fuzzyMatchThreshold: 1.0,
|
||||
preferredLanguage: "English",
|
||||
enableCustomModeCreation: true,
|
||||
writeDelayMs: 1000,
|
||||
browserViewportSize: "900x600",
|
||||
screenshotQuality: 75,
|
||||
|
|
@ -275,6 +278,8 @@ export const ExtensionStateContextProvider: React.FC<{ children: React.ReactNode
|
|||
setCustomSupportPrompts: (value) => setState((prevState) => ({ ...prevState, customSupportPrompts: value })),
|
||||
setEnhancementApiConfigId: (value) =>
|
||||
setState((prevState) => ({ ...prevState, enhancementApiConfigId: value })),
|
||||
setEnableCustomModeCreation: (value) =>
|
||||
setState((prevState) => ({ ...prevState, enableCustomModeCreation: value })),
|
||||
setAutoApprovalEnabled: (value) => setState((prevState) => ({ ...prevState, autoApprovalEnabled: value })),
|
||||
setCustomModes: (value) => setState((prevState) => ({ ...prevState, customModes: value })),
|
||||
setMaxOpenTabsContext: (value) => setState((prevState) => ({ ...prevState, maxOpenTabsContext: value })),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue