fix: deliver WeChat pages when image_make fails
Fall back to workspace share thumbnails so already-published HTML can be sent instead of blocking on REQUIRED_FRESH. Also allow an explicit ALLOW_DIRECT_STABLE_RELEASE path matching the pre-2026-07-23 direct stable packaging flow. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+66
-4
@@ -1866,7 +1866,9 @@ export function createWechatMpService({
|
||||
imagePolicy,
|
||||
notifyFailure = true,
|
||||
}) => {
|
||||
if (imagePolicy?.pageThumbnailMode !== WECHAT_PAGE_THUMBNAIL_MODE.REQUIRED_FRESH) return;
|
||||
if (imagePolicy?.pageThumbnailMode !== WECHAT_PAGE_THUMBNAIL_MODE.REQUIRED_FRESH) {
|
||||
return { ok: true, reason: null, matchRelativePaths: [] };
|
||||
}
|
||||
const images = collectWechatGeneratedImages(replyRequestMessages(reply));
|
||||
const ensureFresh =
|
||||
htmlDeliveryAuthority
|
||||
@@ -1913,7 +1915,15 @@ export function createWechatMpService({
|
||||
);
|
||||
}
|
||||
if (verification?.ok) {
|
||||
return;
|
||||
if (verification.reason === 'workspace_thumbnail_fallback') {
|
||||
logger.info?.(
|
||||
'WeChat MP page delivery accepted workspace thumbnail fallback:',
|
||||
{
|
||||
matchRelativePaths: verification.matchRelativePaths ?? [],
|
||||
},
|
||||
);
|
||||
}
|
||||
return verification;
|
||||
}
|
||||
logger.warn?.(
|
||||
'WeChat MP fresh thumbnail verification failed:',
|
||||
@@ -2666,8 +2676,13 @@ export function createWechatMpService({
|
||||
forcePageData: isPageDataRequest,
|
||||
});
|
||||
if (wechatIntent.kind === 'page.generate') {
|
||||
const deliveryArtifacts = uniqueArtifactsByUrl([
|
||||
...publishArtifacts,
|
||||
...confirmedArtifacts,
|
||||
...verifiedArtifacts,
|
||||
]);
|
||||
await enforceFreshPageThumbnailDelivery({
|
||||
artifacts: publishArtifacts,
|
||||
artifacts: deliveryArtifacts,
|
||||
reply,
|
||||
openid: inbound.fromUserName,
|
||||
user,
|
||||
@@ -2676,6 +2691,27 @@ export function createWechatMpService({
|
||||
imagePolicy,
|
||||
notifyFailure: false,
|
||||
});
|
||||
if (deliveryArtifacts.length > 0) {
|
||||
publishArtifacts = deliveryArtifacts;
|
||||
} else {
|
||||
const recovered = await resolveHtmlPublishArtifacts({
|
||||
reply,
|
||||
intent,
|
||||
requestStartedAt,
|
||||
userId: user.userId,
|
||||
sessionId,
|
||||
onPageGenerated,
|
||||
allowRecentArtifacts: true,
|
||||
htmlDeliveryAuthority,
|
||||
});
|
||||
publishArtifacts = uniqueArtifactsByUrl([
|
||||
...selectSendableHtmlArtifacts({
|
||||
verifiedArtifacts: recovered.verifiedArtifacts,
|
||||
confirmedArtifacts: recovered.confirmedArtifacts,
|
||||
}),
|
||||
...recovered.confirmedArtifacts,
|
||||
]);
|
||||
}
|
||||
}
|
||||
const pageDataOutcome = await enforcePageDataCollectDelivery({
|
||||
reply,
|
||||
@@ -2939,8 +2975,13 @@ export function createWechatMpService({
|
||||
forcePageData: isPageDataRequest,
|
||||
});
|
||||
if (wechatIntent.kind === 'page.generate') {
|
||||
const deliveryArtifacts = uniqueArtifactsByUrl([
|
||||
...publishArtifacts,
|
||||
...confirmedArtifacts,
|
||||
...verifiedArtifacts,
|
||||
]);
|
||||
await enforceFreshPageThumbnailDelivery({
|
||||
artifacts: publishArtifacts,
|
||||
artifacts: deliveryArtifacts,
|
||||
reply,
|
||||
openid: inbound.fromUserName,
|
||||
user,
|
||||
@@ -2948,6 +2989,27 @@ export function createWechatMpService({
|
||||
sessionId,
|
||||
imagePolicy,
|
||||
});
|
||||
if (deliveryArtifacts.length > 0) {
|
||||
publishArtifacts = deliveryArtifacts;
|
||||
} else {
|
||||
const recovered = await resolveHtmlPublishArtifacts({
|
||||
reply,
|
||||
intent,
|
||||
requestStartedAt: retryStartedAt,
|
||||
userId: user.userId,
|
||||
sessionId,
|
||||
onPageGenerated,
|
||||
allowRecentArtifacts: true,
|
||||
htmlDeliveryAuthority,
|
||||
});
|
||||
publishArtifacts = uniqueArtifactsByUrl([
|
||||
...selectSendableHtmlArtifacts({
|
||||
verifiedArtifacts: recovered.verifiedArtifacts,
|
||||
confirmedArtifacts: recovered.confirmedArtifacts,
|
||||
}),
|
||||
...recovered.confirmedArtifacts,
|
||||
]);
|
||||
}
|
||||
}
|
||||
const pageDataOutcome = await enforcePageDataCollectDelivery({
|
||||
reply,
|
||||
|
||||
Reference in New Issue
Block a user