feat(image): complete reviewed generation delivery
Memind CI / Test, build, and release guards (pull_request) Successful in 2m47s
Memind CI / Test, build, and release guards (pull_request) Successful in 2m47s
This commit is contained in:
@@ -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));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user