fix(wechat): only auto-repair substantial HTML during materialize
Memind CI / Test, build, and release guards (push) Failing after 8s
Memind CI / Test, build, and release guards (push) Failing after 8s
Skip share-preview repair for tiny HTML fragments so sandbox write tests and partial tool outputs stay unchanged while real pages still get metadata. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -5,6 +5,7 @@ import { extractStaticPageLinks, materializePrivateAssetsInPublicHtmlFiles } fro
|
||||
import { DOWNLOADABLE_FILE_PATTERN } from './mindspace-html-download-links.mjs';
|
||||
import { scheduleWorkspaceHtmlThumbnailSidecars } from './mindspace-workspace-thumbnails.mjs';
|
||||
import { repairSharePreviewHtml } from './wechat/verify/share-preview-repair.mjs';
|
||||
import { verifySharePreviewMeta } from './wechat/verify/share-preview.mjs';
|
||||
|
||||
/**
|
||||
* Public HTML finish-sync invariants (regression guard — do not simplify away).
|
||||
@@ -378,6 +379,14 @@ function shouldReplaceExistingPublicHtml(destination, nextContent) {
|
||||
}
|
||||
}
|
||||
|
||||
function shouldRepairMaterializedPublicHtml(content) {
|
||||
const value = String(content ?? '');
|
||||
if (value.length < 512) return false;
|
||||
if (isStubPublicHtmlContent(value)) return false;
|
||||
if (!/<(?:html|body|main|article)\b/i.test(value)) return false;
|
||||
return !verifySharePreviewMeta(value).ok;
|
||||
}
|
||||
|
||||
export function materializeMissingPublicHtmlWrites({ messages, publishDir }) {
|
||||
const root = path.resolve(String(publishDir ?? ''));
|
||||
if (!root) return { materialized: [], skipped: [] };
|
||||
@@ -398,7 +407,10 @@ export function materializeMissingPublicHtmlWrites({ messages, publishDir }) {
|
||||
}
|
||||
try {
|
||||
fs.mkdirSync(path.dirname(destination), { recursive: true });
|
||||
const preparedContent = repairSharePreviewHtml(String(artifact.content ?? ''), {});
|
||||
const rawContent = String(artifact.content ?? '');
|
||||
const preparedContent = shouldRepairMaterializedPublicHtml(rawContent)
|
||||
? repairSharePreviewHtml(rawContent, {})
|
||||
: rawContent;
|
||||
fs.writeFileSync(destination, preparedContent, 'utf8');
|
||||
materialized.push(artifact.relativePath);
|
||||
scheduleWorkspaceHtmlThumbnailSidecars(root, artifact.relativePath);
|
||||
|
||||
Reference in New Issue
Block a user