Fix OA workspace cover thumbnails and add space chat new session.

Resolve mindspace-cover images from workspace directories when generating feed thumbnails, refresh stale SVGs missing embedded photos, and disable thumbnail API caching so fixes take effect immediately. Also add a new session control to the space chat panel, including on mobile.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
John
2026-06-16 17:57:00 -07:00
parent 6d99d762da
commit ab0718938e
8 changed files with 133 additions and 8 deletions
+37
View File
@@ -8,7 +8,9 @@ import {
generateHtmlThumbnail,
isModernFeedThumbnail,
resolveCoverDataUri,
resolveWorkspaceHtmlContentBaseDir,
shouldUseScenicBackground,
thumbnailHasEmbeddedPhoto,
} from './mindspace-thumbnails.mjs';
import fs from 'node:fs/promises';
import os from 'node:os';
@@ -163,3 +165,38 @@ test('resolveCoverDataUri rejects paths outside content base', async () => {
});
assert.equal(dataUri, null);
});
test('resolveWorkspaceHtmlContentBaseDir resolves nested html paths', () => {
assert.equal(
resolveWorkspaceHtmlContentBaseDir('/workspace', 'oa/report.html'),
path.join('/workspace', 'oa'),
);
assert.equal(resolveWorkspaceHtmlContentBaseDir('/workspace', 'page.html'), '/workspace');
});
test('ensureHtmlThumbnail refreshes cached thumbnail when cover image becomes resolvable', async () => {
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'mindspace-thumb-refresh-'));
const htmlDir = path.join(root, 'oa');
await fs.mkdir(htmlDir, { recursive: true });
const png = Buffer.from(
'iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAFUlEQVR42mNk+M9Qz0AEYBxVSF+FABJADveWkH6oAAAAAElFTkSuQmCC',
'base64',
);
await fs.writeFile(path.join(htmlDir, 'hero.png'), png);
const html = `<!doctype html><html><head>
<title>OA 报告</title>
<meta name="mindspace-cover" content='{"cover":"hero.png","tag":"报告"}' />
</head><body></body></html>`;
const key = 'users/u1/pages/p1/thumbnail.svg';
const cached = buildFeedThumbnailSvg(extractCoverSignals(html, { title: 'OA 报告' }));
assert.equal(thumbnailHasEmbeddedPhoto(cached), false);
await fs.mkdir(path.dirname(path.join(root, key)), { recursive: true });
await fs.writeFile(path.join(root, key), cached, 'utf8');
const svg = await ensureHtmlThumbnail(root, key, html, {
title: 'OA 报告',
contentBaseDir: htmlDir,
});
assert.equal(thumbnailHasEmbeddedPhoto(svg), true);
assert.match(svg, /href="data:image\/png;base64,/);
});