fix: prevent canvas agent requests without preset
This commit is contained in:
parent
50d487dbcb
commit
1269e5f562
@ -1983,7 +1983,7 @@ export default function CanvasEditorPage({ params }: PageProps) {
|
|||||||
chatId={`canvas-${id}`}
|
chatId={`canvas-${id}`}
|
||||||
onClose={() => setIsPanelOpen(false)}
|
onClose={() => setIsPanelOpen(false)}
|
||||||
onOpenFileList={() => setPanelMode('fileList')}
|
onOpenFileList={() => setPanelMode('fileList')}
|
||||||
selectedAgentPresetId={null}
|
selectedAgentPresetId={isCanvasAgentModeEnabled ? selectedAgentPresetId : null}
|
||||||
chatScope="canvas"
|
chatScope="canvas"
|
||||||
agentEnabled={isCanvasAgentModeEnabled}
|
agentEnabled={isCanvasAgentModeEnabled}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -3116,8 +3116,10 @@ export function CanvasChatPanel({
|
|||||||
const isConversationModel = Boolean(
|
const isConversationModel = Boolean(
|
||||||
currentModel && isCanvasConversationOnlyModel(currentModel)
|
currentModel && isCanvasConversationOnlyModel(currentModel)
|
||||||
);
|
);
|
||||||
|
const hasSelectedAgentPreset = Boolean(String(selectedAgentPresetId || "").trim());
|
||||||
const isAgentModel =
|
const isAgentModel =
|
||||||
agentEnabled &&
|
agentEnabled &&
|
||||||
|
hasSelectedAgentPreset &&
|
||||||
!isDetailGenerationMode &&
|
!isDetailGenerationMode &&
|
||||||
(!selectedModelId || selectedModelId === "auto" || isConversationModel);
|
(!selectedModelId || selectedModelId === "auto" || isConversationModel);
|
||||||
const computedComposerMode = useMemo<"agent" | "image" | "video" | "detail">(() => {
|
const computedComposerMode = useMemo<"agent" | "image" | "video" | "detail">(() => {
|
||||||
@ -3660,6 +3662,11 @@ export function CanvasChatPanel({
|
|||||||
if (!agentEnabled) {
|
if (!agentEnabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!hasSelectedAgentPreset) {
|
||||||
|
toast.error("请先选择生图模式后再使用 Agent 模式");
|
||||||
|
activeComposerModeRef.current = computedComposerMode;
|
||||||
|
return;
|
||||||
|
}
|
||||||
const preferredAgentModelId =
|
const preferredAgentModelId =
|
||||||
allModels.find(
|
allModels.find(
|
||||||
(model) =>
|
(model) =>
|
||||||
@ -3721,8 +3728,10 @@ export function CanvasChatPanel({
|
|||||||
aiDetailGenerationEnabled,
|
aiDetailGenerationEnabled,
|
||||||
agentEnabled,
|
agentEnabled,
|
||||||
allModels,
|
allModels,
|
||||||
|
computedComposerMode,
|
||||||
firstImageModelId,
|
firstImageModelId,
|
||||||
firstVideoModelId,
|
firstVideoModelId,
|
||||||
|
hasSelectedAgentPreset,
|
||||||
lastConversationModelId,
|
lastConversationModelId,
|
||||||
lastImageModelId,
|
lastImageModelId,
|
||||||
isCanvasConversationOnlyModel,
|
isCanvasConversationOnlyModel,
|
||||||
@ -8176,7 +8185,9 @@ export function CanvasChatPanel({
|
|||||||
: 0;
|
: 0;
|
||||||
const canSend = isDetailGenerationMode
|
const canSend = isDetailGenerationMode
|
||||||
? detailValidationIssues.length === 0 && !isDetailGenerating
|
? detailValidationIssues.length === 0 && !isDetailGenerating
|
||||||
: hasInputOrAttachments && hasEnoughAgentUploads;
|
: hasInputOrAttachments &&
|
||||||
|
hasEnoughAgentUploads &&
|
||||||
|
(activeComposerMode !== "agent" || hasSelectedAgentPreset);
|
||||||
const currentVideoImageLimit = isVideoModel
|
const currentVideoImageLimit = isVideoModel
|
||||||
? getVideoImageLimit(videoParams, currentModel?.providerType, currentModel?.videoToolCapability)
|
? getVideoImageLimit(videoParams, currentModel?.providerType, currentModel?.videoToolCapability)
|
||||||
: null;
|
: null;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user