PRM-52 restore six home modules

This commit is contained in:
Sai-karthik
2026-06-08 19:35:20 +00:00
parent 9fd478c095
commit 6f03a133d5
3 changed files with 25 additions and 20 deletions

View File

@@ -180,7 +180,7 @@ function buildDayOneSeeds(): SeedNotification[] {
} }
function buildDynamicSeeds(ctx: HomeContext): SeedNotification[] { function buildDynamicSeeds(ctx: HomeContext): SeedNotification[] {
const seeds = buildDayOneSeeds().filter((seed) => seed.moduleId === "pathways" || seed.moduleId === "rewards"); const seeds = buildDayOneSeeds().filter((seed) => seed.moduleId === "pathways" || seed.moduleId === "social" || seed.moduleId === "rewards");
const profile = profileFromPreferences(ctx.preferences); const profile = profileFromPreferences(ctx.preferences);
const qscore = ctx.qscore?.score ?? Math.round(ctx.qscoreSignals.reduce((sum, s) => sum + s.score, 0) / Math.max(ctx.qscoreSignals.length, 1)); const qscore = ctx.qscore?.score ?? Math.round(ctx.qscoreSignals.reduce((sum, s) => sum + s.score, 0) / Math.max(ctx.qscoreSignals.length, 1));
const ats = latestScore(ctx.qscoreSignals, "resume.ats_compatibility"); const ats = latestScore(ctx.qscoreSignals, "resume.ats_compatibility");
@@ -289,13 +289,13 @@ function buildDynamicSeeds(ctx: HomeContext): SeedNotification[] {
pushSeed(seeds, { pushSeed(seeds, {
moduleId: "social", moduleId: "social",
title: "Turn proof into LinkedIn updates", title: "Social branding is coming soon",
subtitle: ctx.artifacts.length ? `${ctx.artifacts.length} artifact${ctx.artifacts.length === 1 ? "" : "s"} can feed headline, featured, or post ideas.` : `Connect LinkedIn and use ${profile.targetRole} proof to improve your profile.`, subtitle: "Mission proof and resume artifacts will become profile and LinkedIn nudges here.",
tag: ctx.artifacts.length ? "Proof" : "Setup", tag: "Soon",
urgency: ctx.artifacts.length ? "today" : "soon", urgency: "calm",
href: SERVICE_HREFS.social, href: SERVICE_HREFS.social,
source: "social", source: "social",
priority: 70, priority: 38,
}); });
if (resumeAnalysis || resumeSession || ats !== undefined) { if (resumeAnalysis || resumeSession || ats !== undefined) {
@@ -509,9 +509,9 @@ function moduleCount(moduleId: HomeModuleId, notifications: HomeNotification[],
const active = ctx.sessions.filter((s) => s.status === "active" || s.status === "configured" || s.status === "processing").length; const active = ctx.sessions.filter((s) => s.status === "active" || s.status === "configured" || s.status === "processing").length;
return active ? `${active} active` : String(notifications.length); return active ? `${active} active` : String(notifications.length);
} }
if (moduleId === "pathways") return mode === "day1" ? "Soon" : "Locked"; if (moduleId === "pathways") return "Soon";
if (moduleId === "rewards") return mode === "day1" ? "0" : "Demo"; if (moduleId === "rewards") return "Soon";
if (moduleId === "social") return mode === "day1" ? "Setup" : `${notifications.length} updates`; if (moduleId === "social") return "Soon";
return String(notifications.length); return String(notifications.length);
} }
@@ -566,8 +566,9 @@ export async function getHomeFeed(userId: string, opts: { refresh?: boolean; use
const newest = persisted[0]?.createdAt?.getTime() ?? 0; const newest = persisted[0]?.createdAt?.getTime() ?? 0;
const hasDemo = persisted.some((row) => row.generatedBy === "demo"); const hasDemo = persisted.some((row) => row.generatedBy === "demo");
const fresh = newest > Date.now() - FRESH_MS; const fresh = newest > Date.now() - FRESH_MS;
const hasModuleCoverage = MODULE_IDS.every((moduleId) => persisted.some((row) => row.moduleId === moduleId));
if (persisted.length && (hasDemo || (!opts.refresh && fresh))) { if (persisted.length && hasModuleCoverage && (hasDemo || (!opts.refresh && fresh))) {
const mode = hasDemo ? "demo" : hasAnyRealActivity(ctx) ? "dynamic" : "day1"; const mode = hasDemo ? "demo" : hasAnyRealActivity(ctx) ? "dynamic" : "day1";
return { return {
generatedAt: new Date().toISOString(), generatedAt: new Date().toISOString(),

View File

@@ -44,11 +44,11 @@ export const MODULE_META: Record<HomeModuleId, Omit<HomeModule, "count" | "notif
missions: { id: "missions", label: "Missions", href: "/missions", accent: "orange" }, missions: { id: "missions", label: "Missions", href: "/missions", accent: "orange" },
social: { id: "social", label: "Social Branding", href: "/social", accent: "blue" }, social: { id: "social", label: "Social Branding", href: "/social", accent: "blue" },
pathways: { id: "pathways", label: "Pathways", href: "/pathways", accent: "teal" }, pathways: { id: "pathways", label: "Pathways", href: "/pathways", accent: "teal" },
productivity: { id: "productivity", label: "Interview · Roleplay · Resume", href: "/agents", accent: "orange" }, productivity: { id: "productivity", label: "Productivity", href: "/agents", accent: "orange" },
rewards: { id: "rewards", label: "Rewards", href: "/rewards", accent: "amber" }, rewards: { id: "rewards", label: "Rewards", href: "/rewards", accent: "amber" },
}; };
export const MODULE_IDS: HomeModuleId[] = ["suggestions", "missions", "productivity"]; export const MODULE_IDS: HomeModuleId[] = ["suggestions", "missions", "pathways", "productivity", "social", "rewards"];
export const ALLOWED_NOTIFICATION_HREFS = new Set([ export const ALLOWED_NOTIFICATION_HREFS = new Set([
"/suggestions", "/suggestions",

View File

@@ -13,14 +13,18 @@ async function getUserServiceProfile(req: Request): Promise<{ userProfile?: Reco
const headers = new Headers(req.headers); const headers = new Headers(req.headers);
headers.delete("host"); headers.delete("host");
headers.delete("cookie"); headers.delete("cookie");
const res = await fetch(target, { method: "GET", headers }); try {
if (!res.ok) return {}; const res = await fetch(target, { method: "GET", headers });
const userProfile = await res.json().catch(() => null) as Record<string, unknown> | null; if (!res.ok) return {};
const preferences = userProfile?.preferences; const userProfile = await res.json().catch(() => null) as Record<string, unknown> | null;
return { const preferences = userProfile?.preferences;
userProfile: userProfile ?? undefined, return {
preferences: preferences && typeof preferences === "object" && !Array.isArray(preferences) ? preferences as Record<string, unknown> : {}, userProfile: userProfile ?? undefined,
}; preferences: preferences && typeof preferences === "object" && !Array.isArray(preferences) ? preferences as Record<string, unknown> : {},
};
} catch {
return {};
}
} }
export function homeRoutes() { export function homeRoutes() {