feat(image): complete reviewed generation delivery
Memind CI / Test, build, and release guards (pull_request) Successful in 2m47s

This commit is contained in:
john
2026-07-20 20:04:44 +08:00
parent fc3d27aae0
commit 4b15610aa8
42 changed files with 1764 additions and 97 deletions
+13 -2
View File
@@ -4,6 +4,16 @@ import path from 'node:path';
import { ensureThumbnailPng } from './mindspace-thumbnail-png.mjs';
import { ensureHtmlThumbnail } from './mindspace-thumbnails.mjs';
function reportSidecarFailure(kind, htmlRelativePath, error) {
// A page can be removed immediately after a fire-and-forget publish event.
// That is a normal cancellation, not a thumbnail generation failure.
if (error?.code === 'ENOENT') return;
console.warn(
`[MindSpaceThumbnail] ${kind} failed for ${htmlRelativePath}:`,
error instanceof Error ? error.message : error,
);
}
export function workspaceThumbnailRelativePath(htmlRelativePath) {
const normalized = String(htmlRelativePath ?? '').replace(/^\/+/, '');
const dir = path.posix.dirname(normalized);
@@ -23,14 +33,15 @@ function scheduleWorkspaceThumbnailPng(publishDir, htmlRelativePath) {
const svgPath = workspaceThumbnailAbsolutePath(publishDir, htmlRelativePath);
if (fs.existsSync(svgPath)) ensureThumbnailPng(svgPath);
})
.catch(() => {});
.catch((error) => reportSidecarFailure('PNG sidecar', htmlRelativePath, error));
});
}
/** Fire-and-forget SVG + PNG sidecars after public HTML is written (must not block Finish/chat). */
export function scheduleWorkspaceHtmlThumbnailSidecars(publishDir, htmlRelativePath) {
queueMicrotask(() => {
void ensureWorkspaceHtmlThumbnail(publishDir, htmlRelativePath).catch(() => {});
void ensureWorkspaceHtmlThumbnail(publishDir, htmlRelativePath).catch((error) =>
reportSidecarFailure('sidecar refresh', htmlRelativePath, error));
});
}