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
+25 -5
View File
@@ -17,6 +17,9 @@ import {
import {
verifySharePreviewMeta,
} from './wechat/verify/share-preview.mjs';
import {
ensureArtifactsSharePreviewReady,
} from './wechat/verify/share-preview-repair.mjs';
const PUBLIC_HTML_LINK_PATTERN =
/https?:\/\/[^\s<>"')\]]+\/MindSpace\/([0-9a-f-]{36}|[a-z0-9._-]+)\/public\/([^\s<>"')\]]+\.html)/gi;
@@ -397,11 +400,26 @@ export function prepareWechatHtmlDeliveryAtWorkspace({
requestStartedAt,
})
: [];
const confirmedArtifacts = uniqueArtifacts([
...publishedArtifacts,
...expectedArtifacts,
...recentArtifacts,
]);
const confirmedArtifacts = ensureArtifactsSharePreviewReady(
uniqueArtifacts([
...publishedArtifacts,
...expectedArtifacts,
...recentArtifacts,
]),
{
publishDir,
topic: String(
intent?.agentText ?? intent?.displayText ?? '',
).trim(),
},
).map(
(artifact) =>
readArtifactDescriptor(artifact.relativePath, {
publishDir,
buildCanonicalUrl,
copyIntoPublic: false,
}) ?? artifact,
);
const linkedFilenames =
collectLinkedHtmlFilenames(reply?.text);
const matchedArtifacts =
@@ -610,6 +628,7 @@ export async function ensureWechatFreshPageThumbnailsAtWorkspace({
verifyFreshWechatPageThumbnails(
workspaceArtifacts,
images,
{ publishDir },
);
let repair = null;
if (
@@ -638,6 +657,7 @@ export async function ensureWechatFreshPageThumbnailsAtWorkspace({
verifyFreshWechatPageThumbnails(
workspaceArtifacts,
images,
{ publishDir },
);
}
}