fix(ui): model selection now updates all tiers correctly

- Add updateEnvBulk function for atomic multi-key updates
- Pass onEnvBulkChange prop to FriendlyUISection
- Fixes race condition where only last tier (haiku) was updated
This commit is contained in:
kaitranntt
2025-12-20 23:23:50 -05:00
parent f947aeb21b
commit 723ce28431
@@ -67,6 +67,13 @@ export function ProfileEditor({ profileName, onDelete }: ProfileEditorProps) {
setRawJsonEdits(JSON.stringify({ ...currentSettings, env: newEnv }, null, 2));
};
// Bulk update multiple env vars at once (avoids race conditions)
const updateEnvBulk = (env: Record<string, string>) => {
const newEnv = { ...(currentSettings?.env || {}), ...env };
setLocalEdits((prev) => ({ ...prev, ...env }));
setRawJsonEdits(JSON.stringify({ ...currentSettings, env: newEnv }, null, 2));
};
const addNewEnvVar = () => {
if (!newEnvKey.trim()) return;
const key = newEnvKey.trim();
@@ -179,6 +186,7 @@ export function ProfileEditor({ profileName, onDelete }: ProfileEditorProps) {
onNewEnvKeyChange={setNewEnvKey}
onNewEnvValueChange={setNewEnvValue}
onEnvValueChange={updateEnvValue}
onEnvBulkChange={updateEnvBulk}
onAddEnvVar={addNewEnvVar}
/>
</div>