This repository was archived by the owner on May 15, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Expand file tree
/
Copy pathExperimentalSettings.tsx
More file actions
126 lines (117 loc) · 4.16 KB
/
Copy pathExperimentalSettings.tsx
File metadata and controls
126 lines (117 loc) · 4.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import { HTMLAttributes } from "react"
import type { Experiments, ImageGenerationProvider } from "@roo-code/types"
import { EXPERIMENT_IDS, experimentConfigsMap } from "@roo/experiments"
import { useAppTranslation } from "@src/i18n/TranslationContext"
import { cn } from "@src/lib/utils"
import { SetExperimentEnabled } from "./types"
import { SectionHeader } from "./SectionHeader"
import { Section } from "./Section"
import { SearchableSetting } from "./SearchableSetting"
import { ExperimentalFeature } from "./ExperimentalFeature"
import { ImageGenerationSettings } from "./ImageGenerationSettings"
import { CustomToolsSettings } from "./CustomToolsSettings"
type ExperimentalSettingsProps = HTMLAttributes<HTMLDivElement> & {
experiments: Experiments
setExperimentEnabled: SetExperimentEnabled
apiConfiguration?: any
setApiConfigurationField?: any
imageGenerationProvider?: ImageGenerationProvider
openRouterImageApiKeyConfigured: boolean
openRouterImageGenerationSelectedModel?: string
setImageGenerationProvider?: (provider: ImageGenerationProvider) => void
setOpenRouterImageApiKey?: (apiKey: string) => void
setImageGenerationSelectedModel?: (model: string) => void
}
export const ExperimentalSettings = ({
experiments,
setExperimentEnabled,
apiConfiguration,
setApiConfigurationField,
imageGenerationProvider,
openRouterImageApiKeyConfigured,
openRouterImageGenerationSelectedModel,
setImageGenerationProvider,
setOpenRouterImageApiKey,
setImageGenerationSelectedModel,
className,
...props
}: ExperimentalSettingsProps) => {
const { t } = useAppTranslation()
return (
<div className={cn("flex flex-col gap-2", className)} {...props}>
<SectionHeader>{t("settings:sections.experimental")}</SectionHeader>
<Section>
{Object.entries(experimentConfigsMap)
.filter(([key]) => key in EXPERIMENT_IDS)
.map((config) => {
// Use the same translation key pattern as ExperimentalFeature
const experimentKey = config[0]
const label = t(`settings:experimental.${experimentKey}.name`)
if (
config[0] === "IMAGE_GENERATION" &&
setImageGenerationProvider &&
setOpenRouterImageApiKey &&
setImageGenerationSelectedModel
) {
return (
<SearchableSetting
key={config[0]}
settingId={`experimental-${config[0].toLowerCase()}`}
section="experimental"
label={label}>
<ImageGenerationSettings
enabled={experiments[EXPERIMENT_IDS.IMAGE_GENERATION] ?? false}
onChange={(enabled) =>
setExperimentEnabled(EXPERIMENT_IDS.IMAGE_GENERATION, enabled)
}
imageGenerationProvider={imageGenerationProvider}
openRouterImageApiKeyConfigured={openRouterImageApiKeyConfigured}
openRouterImageGenerationSelectedModel={openRouterImageGenerationSelectedModel}
setImageGenerationProvider={setImageGenerationProvider}
setOpenRouterImageApiKey={setOpenRouterImageApiKey}
setImageGenerationSelectedModel={setImageGenerationSelectedModel}
/>
</SearchableSetting>
)
}
if (config[0] === "CUSTOM_TOOLS") {
return (
<SearchableSetting
key={config[0]}
settingId={`experimental-${config[0].toLowerCase()}`}
section="experimental"
label={label}>
<CustomToolsSettings
enabled={experiments[EXPERIMENT_IDS.CUSTOM_TOOLS] ?? false}
onChange={(enabled) =>
setExperimentEnabled(EXPERIMENT_IDS.CUSTOM_TOOLS, enabled)
}
/>
</SearchableSetting>
)
}
return (
<SearchableSetting
key={config[0]}
settingId={`experimental-${config[0].toLowerCase()}`}
section="experimental"
label={label}>
<ExperimentalFeature
experimentKey={config[0]}
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,
)
}
/>
</SearchableSetting>
)
})}
</Section>
</div>
)
}