fix(chat): keep mode switch selection without auto rollback
Some checks failed
Lint / build (20) (push) Has been cancelled
Playwright Tests / test (push) Has been cancelled

This commit is contained in:
Your Name 2026-03-02 22:15:59 +08:00
parent eec91f3c6f
commit 0d9824cb81
2 changed files with 9 additions and 8 deletions

View File

@ -116,14 +116,10 @@ async function NewChatPage() {
const cookieModel = initialModelId
? visibleModels.find(({ model }) => model.id === initialModelId)
: undefined;
const cookieIsVideoModel = Boolean(
cookieModel && VIDEO_PROVIDER_TYPES.has(cookieModel.provider.type)
);
if (
!initialModelId ||
!cookieModel ||
(cookieIsVideoModel && Boolean(nanoBananaModel))
!cookieModel
) {
if (nanoBananaModel) {
initialModelId = nanoBananaModel.model.id;

View File

@ -1529,8 +1529,13 @@ function PureModelSelectorCompact({
useEffect(() => {
if (displayModels.length === 0) return;
const currentExists = displayModels.some((m) => m.id === selectedModelId);
if (currentExists) return;
const currentExistsInDisplay = displayModels.some((m) => m.id === selectedModelId);
if (currentExistsInDisplay) return;
const currentExistsInAll = allModels.some((m) => m.id === selectedModelId);
if (currentExistsInAll) {
return;
}
const fallbackImageModel =
modeFilteredModels.find((model) => isNanoBananaProModel(model)) ||
@ -1546,7 +1551,7 @@ function PureModelSelectorCompact({
startTransition(() => {
saveChatModelAsCookie(fallbackModelId);
});
}, [canShowAutoModel, displayModels, modeFilteredModels, onModelChange, selectedModelId]);
}, [allModels, canShowAutoModel, displayModels, modeFilteredModels, onModelChange, selectedModelId]);
// 自动选择模型的逻辑 - 必须在所有条件 return 之前定义
const selectBestModel = useCallback(() => {