diff --git a/src/shared/experiments.ts b/src/shared/experiments.ts index 0418334..71eda74 100644 --- a/src/shared/experiments.ts +++ b/src/shared/experiments.ts @@ -8,7 +8,6 @@ export type ExperimentKey = keyof typeof EXPERIMENT_IDS export type ExperimentId = valueof export interface ExperimentConfig { - id: ExperimentId name: string description: string enabled: boolean @@ -18,21 +17,18 @@ type valueof = X[keyof X] export const experimentConfigsMap: Record = { DIFF_STRATEGY: { - id: EXPERIMENT_IDS.DIFF_STRATEGY, name: "Use experimental unified diff strategy", description: "Enable the experimental unified diff strategy. This strategy might reduce the number of retries caused by model errors but may cause unexpected behavior or incorrect edits. Only enable if you understand the risks and are willing to carefully review all changes.", enabled: false, }, SEARCH_AND_REPLACE: { - id: EXPERIMENT_IDS.SEARCH_AND_REPLACE, name: "Use experimental search and replace tool", description: "Enable the experimental search and replace tool, allowing Roo to replace multiple instances of a search term in one request.", enabled: false, }, INSERT_BLOCK: { - id: EXPERIMENT_IDS.INSERT_BLOCK, name: "Use experimental insert block tool", description: @@ -42,7 +38,10 @@ export const experimentConfigsMap: Record = { } export const experimentDefault = Object.fromEntries( - Object.entries(experimentConfigsMap).map(([_, config]) => [config.id, config.enabled]), + Object.entries(experimentConfigsMap).map(([_, config]) => [ + EXPERIMENT_IDS[_ as keyof typeof EXPERIMENT_IDS] as ExperimentId, + config.enabled, + ]), ) as Record export const experiments = { @@ -56,9 +55,15 @@ export const experiments = { // Expose experiment details for UI - pre-compute from map for better performance export const experimentLabels = Object.fromEntries( - Object.values(experimentConfigsMap).map((config) => [config.id, config.name]), + Object.entries(experimentConfigsMap).map(([_, config]) => [ + EXPERIMENT_IDS[_ as keyof typeof EXPERIMENT_IDS] as ExperimentId, + config.name, + ]), ) as Record export const experimentDescriptions = Object.fromEntries( - Object.values(experimentConfigsMap).map((config) => [config.id, config.description]), + Object.entries(experimentConfigsMap).map(([_, config]) => [ + EXPERIMENT_IDS[_ as keyof typeof EXPERIMENT_IDS] as ExperimentId, + config.description, + ]), ) as Record diff --git a/webview-ui/src/components/settings/ExperimentalFeature.tsx b/webview-ui/src/components/settings/ExperimentalFeature.tsx index b5542b9..b896e8e 100644 --- a/webview-ui/src/components/settings/ExperimentalFeature.tsx +++ b/webview-ui/src/components/settings/ExperimentalFeature.tsx @@ -1,14 +1,13 @@ import { VSCodeCheckbox } from "@vscode/webview-ui-toolkit/react" interface ExperimentalFeatureProps { - id: string name: string description: string enabled: boolean onChange: (value: boolean) => void } -const ExperimentalFeature = ({ id, name, description, enabled, onChange }: ExperimentalFeatureProps) => { +const ExperimentalFeature = ({ name, description, enabled, onChange }: ExperimentalFeatureProps) => { return (
{ apiConfiguration, }) + console.log("Experiments", experiments) + vscode.postMessage({ type: "updateExperimental", values: experiments, @@ -646,14 +648,21 @@ const SettingsView = ({ onDone }: SettingsViewProps) => {

)} - {Object.values(experimentConfigsMap) - .filter((config) => config.id !== EXPERIMENT_IDS.DIFF_STRATEGY) + {Object.entries(experimentConfigsMap) + .filter((config) => config[0] !== "DIFF_STRATEGY") .map((config) => ( setExperimentEnabled(config.id, enabled)} + key={config[0]} + {...config[1]} + enabled={ + experiments[EXPERIMENT_IDS[config[0] as keyof typeof EXPERIMENT_IDS]] ?? false + } + onChange={(enabled) => + setExperimentEnabled( + EXPERIMENT_IDS[config[0] as keyof typeof EXPERIMENT_IDS], + enabled, + ) + } /> ))}