fix(wechat): repair share preview on disk for sanitized delivery artifacts
Memind CI / Test, build, and release guards (push) Failing after 6s

Production WeChat delivery strips localPath from artifacts, so share-preview
auto-repair never wrote back to HTML. Resolve paths via publishDir +
relativePath, repair at materialize and delivery prep, and pass h5Root from
Portal so page.generate can patch missing meta before sending links.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-08-02 08:47:51 +08:00
parent 0a71370bf4
commit 1faba62f9b
11 changed files with 238 additions and 75 deletions
+13
View File
@@ -61,6 +61,7 @@ import {
collectWechatGeneratedImages,
} from './wechat/verify/generated-thumbnail.mjs';
import { resolveBillingTokenState } from './billing-token-state.mjs';
import { resolveMindSpaceUserPublishDir } from './mindspace-runtime-config.mjs';
import {
buildPageDataCollectFailureText,
} from './mindspace-page-data-finish-guard.mjs';
@@ -1503,6 +1504,7 @@ export function createWechatMpService({
pageDataDeliveryReviewer = null,
wechatFetch = undiciFetch,
linkExists = defaultPublicHtmlLinkExists,
h5Root = '',
logger = console,
}) {
const sessionStore = resolveSessionAccess({ userAuth, sessionAccess });
@@ -1513,6 +1515,11 @@ export function createWechatMpService({
}
const requireFreshPageThumbnail = config.requireFreshPageThumbnail === true;
const repairFreshPageThumbnail = config.repairFreshPageThumbnail === true;
const resolveUserPublishDir = (userId) => {
const normalizedUserId = String(userId ?? '').trim();
if (!normalizedUserId || !String(h5Root ?? '').trim()) return '';
return resolveMindSpaceUserPublishDir(h5Root, { id: normalizedUserId });
};
config = {
...loadWechatMpConfig({}),
...config,
@@ -2650,6 +2657,9 @@ export function createWechatMpService({
htmlGenerationNeedsRetry,
replyHasPublicLinks,
topic: wechatIntent?.topic ?? intent?.agentText ?? '',
repairContext: {
publishDir: resolveUserPublishDir(user.userId),
},
});
if (pageOutcome.action === 'session_retry') {
throw new Error('stale_session_poisoned_completion');
@@ -2969,6 +2979,9 @@ export function createWechatMpService({
htmlGenerationNeedsRetry,
replyHasPublicLinks,
topic: wechatIntent?.topic ?? intent?.agentText ?? '',
repairContext: {
publishDir: resolveUserPublishDir(user.userId),
},
});
if (pageOutcome.action === 'session_retry' || pageOutcome.action === 'fail') {
const text = pageOutcome.failureText ?? buildPagePublishFailureText();