+ const handleSave = () => {
+ // Save all valid environment variables to the store
+ const validVars = envVars.filter(v => v.key && v.value)
+ validVars.forEach(v => setVariable(v.key, v.value))
+
+ // Remove any variables that were deleted
+ const currentKeys = new Set(validVars.map(v => v.key))
+ Object.keys(variables).forEach(key => {
+ if (!currentKeys.has(key)) {
+ removeVariable(key)
+ }
+ })
+
+ if (pendingClose.current) {
+ onOpenChange(false)
+ }
+ }
+
+ const renderEnvVarRow = (envVar: UIEnvironmentVariable, index: number) => (
+
updateEnvVar(index, 'key', e.target.value)}
@@ -132,15 +209,15 @@ export function SettingsModal({ open, onOpenChange }: SettingsModalProps) {
placeholder="e.g. API_KEY"
/>
setInputRef(el, index)}
value={envVar.value}
onChange={(e) => updateEnvVar(index, 'value', e.target.value)}
type={focusedValueIndex === index ? 'text' : 'password'}
- onFocus={() => handleValueFocus(index)}
- onClick={(e) => handleValueClick(e, index)}
+ onFocus={(e) => handleValueFocus(index, e)}
+ onClick={handleValueClick}
onBlur={() => setFocusedValueIndex(null)}
- onKeyDown={handleValueKeyDown}
+ onPaste={(e) => handlePaste(e, index)}
placeholder="Enter value"
+ className="allow-scroll"
/>