fix: remove stale canvas video provider references
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-21 00:30:54 +08:00
parent b22c4c5c2f
commit 7e7685410f

View File

@ -2982,31 +2982,48 @@ export function CanvasChatPanel({
[visualModels] [visualModels]
); );
const currentModel = allModels.find((model) => model.id === selectedModelId); const currentModel = allModels.find((model) => model.id === selectedModelId);
const isCanvasVideoModel = useCallback(
(model?: (typeof allModels)[number] | null) =>
Boolean(
model &&
isVideoModelDescriptor({
providerType: model.providerType,
modelId: model.modelId,
capabilities: model.capabilities,
supportsImageGen: model.supportsImageGen,
})
),
[]
);
const isCanvasImageModel = useCallback(
(model?: (typeof allModels)[number] | null) =>
Boolean(
model &&
isImageGenerationModelDescriptor({
providerType: model.providerType,
modelId: model.modelId,
capabilities: model.capabilities,
supportsImageGen: model.supportsImageGen,
})
),
[]
);
const isCanvasConversationOnlyModel = useCallback(
(model?: (typeof allModels)[number] | null) =>
Boolean(
model &&
model.id !== "auto" &&
model.isMultimodal &&
!isCanvasImageModel(model) &&
!isCanvasVideoModel(model)
),
[isCanvasImageModel, isCanvasVideoModel]
);
const isVideoModel = Boolean( const isVideoModel = Boolean(
currentModel && currentModel && isCanvasVideoModel(currentModel)
isVideoModelDescriptor({
providerType: currentModel.providerType,
modelId: currentModel.modelId,
capabilities: currentModel.capabilities,
supportsImageGen: currentModel.supportsImageGen,
})
); );
const isConversationModel = Boolean( const isConversationModel = Boolean(
currentModel && currentModel && isCanvasConversationOnlyModel(currentModel)
currentModel.id !== "auto" &&
currentModel.isMultimodal &&
!isImageGenerationModelDescriptor({
providerType: currentModel.providerType,
modelId: currentModel.modelId,
capabilities: currentModel.capabilities,
supportsImageGen: currentModel.supportsImageGen,
}) &&
!isVideoModelDescriptor({
providerType: currentModel.providerType,
modelId: currentModel.modelId,
capabilities: currentModel.capabilities,
supportsImageGen: currentModel.supportsImageGen,
})
); );
const isAgentModel = const isAgentModel =
!isDetailGenerationMode && !isDetailGenerationMode &&
@ -3530,8 +3547,7 @@ export function CanvasChatPanel({
allModels.find( allModels.find(
(model) => (model) =>
model.id === lastConversationModelId && model.id === lastConversationModelId &&
model.isMultimodal && isCanvasConversationOnlyModel(model)
!VIDEO_PROVIDER_TYPES.has(model.providerType)
)?.id || "auto"; )?.id || "auto";
currentModelIdRef.current = preferredAgentModelId; currentModelIdRef.current = preferredAgentModelId;
setSelectedModelId(preferredAgentModelId); setSelectedModelId(preferredAgentModelId);
@ -3557,8 +3573,8 @@ export function CanvasChatPanel({
(model) => (model) =>
model.id === lastImageModelId && model.id === lastImageModelId &&
model.id !== "auto" && model.id !== "auto" &&
!model.isMultimodal && isCanvasImageModel(model) &&
!VIDEO_PROVIDER_TYPES.has(model.providerType) !model.isMultimodal
)?.id || firstImageModelId; )?.id || firstImageModelId;
if (!preferredImageModelId) { if (!preferredImageModelId) {
@ -3572,9 +3588,8 @@ export function CanvasChatPanel({
} }
const preferredVideoModelId = const preferredVideoModelId =
allModels.find( allModels.find((model) => model.id === lastVideoModelId && isCanvasVideoModel(model))?.id ||
(model) => model.id === lastVideoModelId && VIDEO_PROVIDER_TYPES.has(model.providerType) firstVideoModelId;
)?.id || firstVideoModelId;
if (!preferredVideoModelId) { if (!preferredVideoModelId) {
toast.error("当前没有可用的视频模型"); toast.error("当前没有可用的视频模型");
@ -3591,6 +3606,9 @@ export function CanvasChatPanel({
firstVideoModelId, firstVideoModelId,
lastConversationModelId, lastConversationModelId,
lastImageModelId, lastImageModelId,
isCanvasConversationOnlyModel,
isCanvasImageModel,
isCanvasVideoModel,
lastVideoModelId, lastVideoModelId,
] ]
); );
@ -3968,16 +3986,8 @@ export function CanvasChatPanel({
const autoContext = autoContextRef.current || undefined; const autoContext = autoContextRef.current || undefined;
const contextPayload = buildContextPayload(); const contextPayload = buildContextPayload();
const requestModel = allModels.find((model) => model.id === currentModelIdRef.current); const requestModel = allModels.find((model) => model.id === currentModelIdRef.current);
const requestIsVideoModel = Boolean( const requestIsVideoModel = isCanvasVideoModel(requestModel);
requestModel && VIDEO_PROVIDER_TYPES.has(requestModel.providerType) const requestIsConversationModel = isCanvasConversationOnlyModel(requestModel);
);
const requestIsConversationModel = Boolean(
requestModel &&
requestModel.id !== "auto" &&
requestModel.isMultimodal &&
!requestModel.supportsImageGen &&
!requestIsVideoModel
);
hiddenPromptRef.current = null; hiddenPromptRef.current = null;
autoContextRef.current = null; autoContextRef.current = null;
return { return {
@ -10033,16 +10043,8 @@ export function CanvasChatPanel({
value={modelSelectValue} value={modelSelectValue}
onValueChange={(value) => { onValueChange={(value) => {
const nextModel = allModels.find((model) => model.id === value); const nextModel = allModels.find((model) => model.id === value);
const nextIsVideoModel = Boolean( const nextIsVideoModel = isCanvasVideoModel(nextModel);
nextModel && VIDEO_PROVIDER_TYPES.has(nextModel.providerType) const nextIsConversationModel = isCanvasConversationOnlyModel(nextModel);
);
const nextIsConversationModel = Boolean(
nextModel &&
nextModel.id !== "auto" &&
nextModel.isMultimodal &&
!nextModel.supportsImageGen &&
!nextIsVideoModel
);
currentModelIdRef.current = value; currentModelIdRef.current = value;
setSelectedModelId(value); setSelectedModelId(value);
if (value === "auto" || nextIsConversationModel) { if (value === "auto" || nextIsConversationModel) {