feat: add model deselection functionality in ComboFormModal and ComboDetailPage (#889)

- Implemented handleDeselectModel function to allow users to deselect models in both ComboFormModal and ComboDetailPage.
- Updated ModelSelectModal to handle deselection and visually indicate selected models.
- Enhanced user experience by allowing models to be removed from the selection without closing the modal.
This commit is contained in:
Fajar Hidayat
2026-05-07 15:55:43 +07:00
committed by GitHub
parent 7f93df3a92
commit 0667a26b5a
3 changed files with 65 additions and 17 deletions
@@ -390,6 +390,10 @@ function ComboFormModal({ isOpen, combo, onClose, onSave, activeProviders, kindF
}
};
const handleDeselectModel = (model) => {
setModels(models.filter((m) => m !== model.value));
};
const handleRemoveModel = (index) => {
setModels(models.filter((_, i) => i !== index));
};
@@ -502,10 +506,13 @@ function ComboFormModal({ isOpen, combo, onClose, onSave, activeProviders, kindF
isOpen={showModelSelect}
onClose={() => setShowModelSelect(false)}
onSelect={handleAddModel}
onDeselect={handleDeselectModel}
activeProviders={activeProviders}
modelAliases={modelAliases}
title="Add Model to Combo"
kindFilter={kindFilter}
addedModelValues={models}
closeOnSelect={false}
/>
</>
);
@@ -126,6 +126,14 @@ export default function ComboDetailPage() {
await saveCombo({ models: next });
};
const handleDeselectModel = async (model) => {
const value = model?.value || model;
if (!value || !providers.includes(value)) return;
const next = providers.filter((p) => p !== value);
setProviders(next);
await saveCombo({ models: next });
};
const handleRemoveProvider = async (idx) => {
const next = providers.filter((_, i) => i !== idx);
setProviders(next);
@@ -389,10 +397,13 @@ export default function ComboDetailPage() {
isOpen={showPicker}
onClose={() => setShowPicker(false)}
onSelect={handleAddModel}
onDeselect={handleDeselectModel}
activeProviders={connections}
modelAliases={modelAliases}
title={`Add ${kindLabel} Model`}
kindFilter={combo.kind}
addedModelValues={providers}
closeOnSelect={false}
/>
</div>
);