mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 04:11:10 -05:00
refactor(experiments): simplify experiment config structure
- Remove redundant id field from ExperimentConfig interface - Update UI components to use experiment keys directly - Improve type safety by using key-based mapping instead of object values
This commit is contained in:
@@ -8,7 +8,6 @@ export type ExperimentKey = keyof typeof EXPERIMENT_IDS
|
||||
export type ExperimentId = valueof<typeof EXPERIMENT_IDS>
|
||||
|
||||
export interface ExperimentConfig {
|
||||
id: ExperimentId
|
||||
name: string
|
||||
description: string
|
||||
enabled: boolean
|
||||
@@ -18,21 +17,18 @@ type valueof<X> = X[keyof X]
|
||||
|
||||
export const experimentConfigsMap: Record<ExperimentKey, ExperimentConfig> = {
|
||||
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<ExperimentKey, ExperimentConfig> = {
|
||||
}
|
||||
|
||||
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<ExperimentId, boolean>
|
||||
|
||||
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<string, string>
|
||||
|
||||
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<string, string>
|
||||
|
||||
Reference in New Issue
Block a user