fix(rcal): seed sample data for all spaces, not just demo

Auto-seed calendar sources and events on first visit to any space's
rcal page, and during space creation via seedTemplate hooks.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Jeff Emmett 2026-03-20 17:14:17 -07:00
parent 4f1eab3104
commit 1827b34f6b
2 changed files with 13 additions and 0 deletions

View File

@ -842,6 +842,8 @@ routes.get("/api/context/:tool", async (c) => {
routes.get("/", (c) => {
const space = c.req.param("space") || "demo";
const dataSpace = c.get("effectiveSpace") || space;
// Seed sample data for any space that has no events yet
seedDemoIfEmpty(dataSpace);
return c.html(renderShell({
title: `${space} — Calendar | rSpace`,
moduleId: "rcal",

View File

@ -176,6 +176,17 @@ export async function createSpace(opts: CreateSpaceOpts): Promise<CreateSpaceRes
console.error(`[createSpace:${source}] Template seeding failed for ${slug}:`, e);
}
// Seed module-specific demo data (calendar events, sample tasks, etc.)
for (const mod of getAllModules()) {
if (mod.seedTemplate) {
try {
mod.seedTemplate(slug);
} catch (e) {
console.error(`[createSpace:${source}] Module ${mod.id} seedTemplate failed for ${slug}:`, e);
}
}
}
console.log(`[createSpace:${source}] Created space: ${slug}`);
return { ok: true, slug, name, visibility, ownerDID };
}