refactor(sdk): improve goView video/iframe inference

This commit is contained in:
clawdbot 2026-01-28 04:47:00 +08:00
parent b67d6be00f
commit b30d0ff069

View File

@ -421,13 +421,22 @@ export function convertGoViewProjectToScreen(input: GoViewProjectLike | GoViewSt
// Important: run media/embed checks before text checks. // Important: run media/embed checks before text checks.
// Some goView/fork widgets have misleading keys that contain "text" even though // Some goView/fork widgets have misleading keys that contain "text" even though
// the option payload is clearly video/iframe. // the option payload is clearly video/iframe.
// Prefer evidence from the option payload over the widget key.
// Some goView/fork widgets mislabel embedded platforms (YouTube/Vimeo/etc) as "Video" even
// though they are best represented as an iframe.
const optionSaysVideo = looksLikeVideoOption(option);
const optionSaysIframe = looksLikeIframeOption(option);
const inferredType: 'text' | 'image' | 'iframe' | 'video' | undefined = const inferredType: 'text' | 'image' | 'iframe' | 'video' | undefined =
isImage(c) || looksLikeImageOption(option) isImage(c) || looksLikeImageOption(option)
? 'image' ? 'image'
: // Important: run video checks before iframe checks; iframe URL detection is broader. : optionSaysVideo
isVideo(c) || looksLikeVideoOption(option)
? 'video' ? 'video'
: isIframe(c) || looksLikeIframeOption(option) : optionSaysIframe
? 'iframe'
: isVideo(c)
? 'video'
: isIframe(c)
? 'iframe' ? 'iframe'
: isTextCommon(c) : isTextCommon(c)
? 'text' ? 'text'