mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-25 13:45:03 +08:00
fix: add toast feedback for OMO "Fill Recommended" button silent failures
This commit is contained in:
@@ -722,14 +722,23 @@ export function OmoFormFields({
|
||||
return;
|
||||
}
|
||||
|
||||
let filledCount = 0;
|
||||
let alreadySetCount = 0;
|
||||
let unmatchedCount = 0;
|
||||
|
||||
const updatedAgents = { ...agents };
|
||||
for (const agentDef of builtinAgentDefs) {
|
||||
const recommendedValue = resolveRecommendedModel(agentDef.recommended);
|
||||
if (recommendedValue && !updatedAgents[agentDef.key]?.model) {
|
||||
if (!recommendedValue) {
|
||||
unmatchedCount++;
|
||||
} else if (updatedAgents[agentDef.key]?.model) {
|
||||
alreadySetCount++;
|
||||
} else {
|
||||
updatedAgents[agentDef.key] = {
|
||||
...updatedAgents[agentDef.key],
|
||||
model: recommendedValue,
|
||||
};
|
||||
filledCount++;
|
||||
}
|
||||
}
|
||||
onAgentsChange(updatedAgents);
|
||||
@@ -738,15 +747,50 @@ export function OmoFormFields({
|
||||
const updatedCategories = { ...categories };
|
||||
for (const catDef of OMO_BUILTIN_CATEGORIES) {
|
||||
const recommendedValue = resolveRecommendedModel(catDef.recommended);
|
||||
if (recommendedValue && !updatedCategories[catDef.key]?.model) {
|
||||
if (!recommendedValue) {
|
||||
unmatchedCount++;
|
||||
} else if (updatedCategories[catDef.key]?.model) {
|
||||
alreadySetCount++;
|
||||
} else {
|
||||
updatedCategories[catDef.key] = {
|
||||
...updatedCategories[catDef.key],
|
||||
model: recommendedValue,
|
||||
};
|
||||
filledCount++;
|
||||
}
|
||||
}
|
||||
onCategoriesChange(updatedCategories);
|
||||
}
|
||||
|
||||
if (filledCount > 0 && unmatchedCount === 0) {
|
||||
toast.success(
|
||||
t("omo.fillRecommendedSuccess", {
|
||||
defaultValue: "Filled {{count}} recommended models",
|
||||
count: filledCount,
|
||||
}),
|
||||
);
|
||||
} else if (filledCount > 0 && unmatchedCount > 0) {
|
||||
toast.success(
|
||||
t("omo.fillRecommendedPartial", {
|
||||
defaultValue:
|
||||
"Filled {{filled}} recommended models, {{unmatched}} unmatched",
|
||||
filled: filledCount,
|
||||
unmatched: unmatchedCount,
|
||||
}),
|
||||
);
|
||||
} else if (alreadySetCount > 0 && unmatchedCount === 0) {
|
||||
toast.info(
|
||||
t("omo.fillRecommendedAllSet", {
|
||||
defaultValue: "All slots already have models configured",
|
||||
}),
|
||||
);
|
||||
} else {
|
||||
toast.warning(
|
||||
t("omo.fillRecommendedNoMatch", {
|
||||
defaultValue: "Recommended models not found in configured providers",
|
||||
}),
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const configuredAgentCount = Object.keys(agents).length;
|
||||
|
||||
Reference in New Issue
Block a user