fix(wechat): sync MindSpace pages after MP generation and redirect on 401
Memind CI / Test, build, and release guards (push) Failing after 3m31s

WeChat page delivery now triggers syncUserGeneratedPages so write_file HTML
gets page records; public share widget redirects unauthenticated owners to
WeChat OAuth instead of only showing an error.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-09-11 19:58:25 +08:00
parent 2c3c1f7a52
commit 0e7e4829db
6 changed files with 191 additions and 8 deletions
+18 -4
View File
@@ -637,6 +637,7 @@ async function bootstrapUserAuth() {
apiSecret: API_SECRET,
mindSpacePages,
mindSpacePageLiveEdit,
syncUserGeneratedPages,
healthChannelStore,
healthObservationStore: healthDataRuntime.observationStore,
healthObservationService: healthDataRuntime.observationService,
@@ -1288,11 +1289,21 @@ async function listSessionPublicHtmlRelativePaths(userId, sessionId, { sinceMs =
.filter((relativePath) => relativePath?.startsWith('public/') && relativePath.toLowerCase().endsWith('.html')))];
}
async function syncUserGeneratedPages(userId, { sessionId = null, sinceMs = null } = {}) {
async function syncUserGeneratedPages(
userId,
{ sessionId = null, sinceMs = null, onlyRelativePaths = null } = {},
) {
if (!userId) return;
// Agent-run/Finish delivery must stay scoped to the current conversation.
// A stale Page Data page elsewhere in the user's workspace must not turn a
// successfully completed current task into a failed run.
const explicitRelativePaths = Array.isArray(onlyRelativePaths)
? [...new Set(
onlyRelativePaths
.map((relativePath) => normalizeWorkspaceRelativePath(relativePath))
.filter(Boolean),
)]
: null;
const discoveredRelativePaths = sessionId
? await listSessionPublicHtmlRelativePaths(userId, sessionId, { sinceMs })
: null;
@@ -1302,6 +1313,7 @@ async function syncUserGeneratedPages(userId, { sessionId = null, sinceMs = null
// block an unrelated delivery.
const recentWorkspaceRelativePaths =
sessionId &&
!explicitRelativePaths?.length &&
!discoveredRelativePaths?.length &&
mindSpaceWorkspacePublicationDelivery
? (
@@ -1312,9 +1324,11 @@ async function syncUserGeneratedPages(userId, { sessionId = null, sinceMs = null
})
)?.relativePaths ?? []
: [];
const pageDataRelativePaths = sessionId
? (discoveredRelativePaths?.length ? discoveredRelativePaths : recentWorkspaceRelativePaths)
: null;
const pageDataRelativePaths = explicitRelativePaths?.length
? explicitRelativePaths
: sessionId
? (discoveredRelativePaths?.length ? discoveredRelativePaths : recentWorkspaceRelativePaths)
: null;
if (workspacePageDeliver?.syncAndDeliver) {
return await workspacePageDeliver.syncAndDeliver(userId, { pageDataRelativePaths });
}