Codex/generation task reliability #27
@@ -38,9 +38,14 @@ function normalizeModelOption(raw: unknown): ModelCapabilityOption | null {
|
|||||||
const enabled = raw.enabled === undefined ? status !== "maintenance" && status !== "disabled" : Boolean(raw.enabled);
|
const enabled = raw.enabled === undefined ? status !== "maintenance" && status !== "disabled" : Boolean(raw.enabled);
|
||||||
if (!enabled) return null;
|
if (!enabled) return null;
|
||||||
|
|
||||||
|
const label = toStringValue(raw.label ?? raw.displayName ?? raw.display_name ?? raw.name, value);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
value,
|
value,
|
||||||
label: toStringValue(raw.label ?? raw.displayName ?? raw.display_name ?? raw.name, value),
|
label:
|
||||||
|
value === "wan2.7-image-pro"
|
||||||
|
? label.replace(/\s*4k\b/i, "").trim() || "wan 2.7 Pro"
|
||||||
|
: label,
|
||||||
description: toStringValue(raw.description) || undefined,
|
description: toStringValue(raw.description) || undefined,
|
||||||
badge: toStringValue(raw.badge) || undefined,
|
badge: toStringValue(raw.badge) || undefined,
|
||||||
enabled,
|
enabled,
|
||||||
|
|||||||
@@ -81,7 +81,9 @@ import { resolveVideoRequestModel } from "../../utils/resolveVideoModel";
|
|||||||
import { calculateEnterpriseVideoCredits, ENTERPRISE_DEFAULT_VIDEO_MODEL } from "../../utils/enterpriseVideoPolicy";
|
import { calculateEnterpriseVideoCredits, ENTERPRISE_DEFAULT_VIDEO_MODEL } from "../../utils/enterpriseVideoPolicy";
|
||||||
import {
|
import {
|
||||||
getImageQualityOptions,
|
getImageQualityOptions,
|
||||||
|
getImageQualityOptionsForContext,
|
||||||
getDefaultImageQuality,
|
getDefaultImageQuality,
|
||||||
|
getDefaultImageQualityForContext,
|
||||||
getVideoQualityOptions,
|
getVideoQualityOptions,
|
||||||
getDefaultVideoQuality,
|
getDefaultVideoQuality,
|
||||||
getVideoQualityLabel,
|
getVideoQualityLabel,
|
||||||
@@ -469,7 +471,26 @@ function WorkbenchPage({
|
|||||||
setSidebarCollapsed(!hasSidebarRecords);
|
setSidebarCollapsed(!hasSidebarRecords);
|
||||||
}, [hasSidebarRecords]);
|
}, [hasSidebarRecords]);
|
||||||
|
|
||||||
const imageQualityOptions = useMemo(() => getImageQualityOptions(imageModel), [imageModel]);
|
const hasImageReferences = activeMode === "image" && referenceItems.some((item) => item.kind === "image");
|
||||||
|
const isImageGridMode = activeMode === "image" && imageGridMode !== "single";
|
||||||
|
const imageQualityContext = useMemo(
|
||||||
|
() => ({
|
||||||
|
hasReferenceImages: hasImageReferences,
|
||||||
|
isGridMode: isImageGridMode,
|
||||||
|
}),
|
||||||
|
[hasImageReferences, isImageGridMode],
|
||||||
|
);
|
||||||
|
const imageQualityOptions = useMemo(
|
||||||
|
() => getImageQualityOptionsForContext(imageModel, imageQualityContext),
|
||||||
|
[imageModel, imageQualityContext],
|
||||||
|
);
|
||||||
|
const imageGridModeOptions = useMemo(
|
||||||
|
() =>
|
||||||
|
String(imageModel || "").toLowerCase().startsWith("wan2.7-")
|
||||||
|
? GRID_MODE_OPTIONS.filter((option) => option.value !== "grid-25")
|
||||||
|
: GRID_MODE_OPTIONS,
|
||||||
|
[imageModel],
|
||||||
|
);
|
||||||
const videoQualityOptions = getVideoQualityOptions(videoModel);
|
const videoQualityOptions = getVideoQualityOptions(videoModel);
|
||||||
const videoQualityLabel = getVideoQualityLabel(videoModel, videoQuality);
|
const videoQualityLabel = getVideoQualityLabel(videoModel, videoQuality);
|
||||||
|
|
||||||
@@ -1205,9 +1226,15 @@ function WorkbenchPage({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!imageQualityOptions.some((option) => option.value === imageQuality)) {
|
if (!imageQualityOptions.some((option) => option.value === imageQuality)) {
|
||||||
setImageQuality(getDefaultImageQuality(imageModel));
|
setImageQuality(getDefaultImageQualityForContext(imageModel, imageQualityContext));
|
||||||
}
|
}
|
||||||
}, [imageModel, imageQuality, imageQualityOptions]);
|
}, [imageModel, imageQuality, imageQualityContext, imageQualityOptions]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!imageGridModeOptions.some((option) => option.value === imageGridMode)) {
|
||||||
|
setImageGridMode("single");
|
||||||
|
}
|
||||||
|
}, [imageGridMode, imageGridModeOptions]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (activeMode !== "video" || videoFrameMode !== "start-end" || referenceItems.length <= 2) return;
|
if (activeMode !== "video" || videoFrameMode !== "start-end" || referenceItems.length <= 2) return;
|
||||||
@@ -2905,7 +2932,7 @@ function WorkbenchPage({
|
|||||||
<SelectChip
|
<SelectChip
|
||||||
chipId="image-grid-mode"
|
chipId="image-grid-mode"
|
||||||
value={imageGridMode}
|
value={imageGridMode}
|
||||||
options={GRID_MODE_OPTIONS}
|
options={imageGridModeOptions}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
isOpen={toolbarMenuId === "image-grid-mode"}
|
isOpen={toolbarMenuId === "image-grid-mode"}
|
||||||
onToggle={() => toggleToolbarMenu("image-grid-mode")}
|
onToggle={() => toggleToolbarMenu("image-grid-mode")}
|
||||||
|
|||||||
@@ -231,7 +231,7 @@ export const MODE_OPTIONS: WorkbenchOption[] = (Object.keys(MODE_META) as Workbe
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
export const IMAGE_MODEL_OPTIONS: WorkbenchOption[] = [
|
export const IMAGE_MODEL_OPTIONS: WorkbenchOption[] = [
|
||||||
{ value: "wan2.7-image-pro", label: "wan 2.7 Pro 4K" },
|
{ value: "wan2.7-image-pro", label: "wan 2.7 Pro" },
|
||||||
{ value: "wan2.7-image", label: "wan 2.7" },
|
{ value: "wan2.7-image", label: "wan 2.7" },
|
||||||
{ value: "gpt-image-2", label: "omni-GPT" },
|
{ value: "gpt-image-2", label: "omni-GPT" },
|
||||||
{ value: "gpt-image-2-vip", label: "omni-GPT VIP" },
|
{ value: "gpt-image-2-vip", label: "omni-GPT VIP" },
|
||||||
|
|||||||
@@ -25,11 +25,30 @@ export function getImageQualityOptions(model: string): CanvasOption[] {
|
|||||||
: imageQualityOptions.filter((option) => option.value !== "4K");
|
: imageQualityOptions.filter((option) => option.value !== "4K");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getImageQualityOptionsForContext(
|
||||||
|
model: string,
|
||||||
|
context?: { hasReferenceImages?: boolean; isGridMode?: boolean },
|
||||||
|
): CanvasOption[] {
|
||||||
|
const options = getImageQualityOptions(model);
|
||||||
|
const shouldLimitTo2K =
|
||||||
|
String(model || "").toLowerCase() === "wan2.7-image-pro" &&
|
||||||
|
(context?.hasReferenceImages || context?.isGridMode);
|
||||||
|
return shouldLimitTo2K ? options.filter((option) => option.value !== "4K") : options;
|
||||||
|
}
|
||||||
|
|
||||||
export function getDefaultImageQuality(model: string): string {
|
export function getDefaultImageQuality(model: string): string {
|
||||||
const options = getImageQualityOptions(model);
|
const options = getImageQualityOptions(model);
|
||||||
return options.some((option) => option.value === "2K") ? "2K" : options[0]?.value || "1K";
|
return options.some((option) => option.value === "2K") ? "2K" : options[0]?.value || "1K";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getDefaultImageQualityForContext(
|
||||||
|
model: string,
|
||||||
|
context?: { hasReferenceImages?: boolean; isGridMode?: boolean },
|
||||||
|
): string {
|
||||||
|
const options = getImageQualityOptionsForContext(model, context);
|
||||||
|
return options.some((option) => option.value === "2K") ? "2K" : options[0]?.value || "1K";
|
||||||
|
}
|
||||||
|
|
||||||
// ─── Video quality ────────────────────────────────────────────────────────────
|
// ─── Video quality ────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
function normalizeVideoModel(model: string): string {
|
function normalizeVideoModel(model: string): string {
|
||||||
|
|||||||
Reference in New Issue
Block a user