@burdenoff/microfe-timecampus 2026.1031.8 → 2026.1031.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"RecommendationsPage.js","names":[],"sources":["../../../../src/timecampus/pages/lifetime/RecommendationsPage.tsx"],"sourcesContent":["import { useMemo, useState, type ComponentType } from \"react\";\nimport {\n Sparkles,\n Check,\n CheckCircle2,\n ChevronDown,\n X,\n Clock,\n BellOff,\n CalendarClock,\n Microscope,\n ShieldCheck,\n Lightbulb,\n Briefcase,\n Moon,\n HeartPulse,\n Users,\n GraduationCap,\n Coffee,\n Bus,\n Hourglass,\n Home,\n Heart,\n Handshake,\n Wallet,\n Circle,\n ExternalLink,\n} from \"lucide-react\";\nimport { GlassCard } from \"@burdenoff/fe-libs/ui\";\nimport {\n PageLayout,\n StatCard,\n StatusBadge,\n EmptyState,\n LoadingSkeleton,\n Modal,\n ToastContainer,\n useToast,\n} from \"../../components\";\nimport { cn } from \"../../utils/helpers\";\nimport {\n useTimeCampus,\n useTimeCampusNavigate,\n} from \"../../providers/TimeCampusProvider\";\nimport { TimeCampusLifeDomain } from \"@/generated/wspace-types\";\nimport {\n useMyRecommendationsQuery,\n useMyRecommendationPreferencesQuery,\n useGenerateMyRecommendationsMutation,\n useAcceptRecommendationMutation,\n useDismissRecommendationMutation,\n useSnoozeRecommendationMutation,\n useUpdateMyRecommendationPreferencesMutation,\n type RecommendationFieldsFragment,\n type RecommendationPreferenceFieldsFragment,\n} from \"@/generated/wspace-operations\";\nimport { lifeDomainLabel } from \"./domains\";\nimport {\n evidenceWeeks,\n formatEvidenceRef,\n formatHourOfDay,\n humaniseToken,\n parseEvidenceRefs,\n parseSuggestedAction,\n recommendationKindLabel,\n recommendationProvenance,\n} from \"./recommendationEvidence\";\n\ntype RecItem = RecommendationFieldsFragment;\n\ntype PrefItem = RecommendationPreferenceFieldsFragment;\n\n// ---------------------------------------------------------------------------\n// Recommendation states are stored as free strings on the backend\n// (NEW / ACCEPTED / DISMISSED / SNOOZED / EXPIRED — see the svc schema). We\n// segment the feed by them; unknown states simply don't match a tab.\n// ---------------------------------------------------------------------------\nconst REC_STATE = {\n New: \"NEW\",\n Snoozed: \"SNOOZED\",\n Accepted: \"ACCEPTED\",\n Dismissed: \"DISMISSED\",\n Expired: \"EXPIRED\",\n} as const;\n\nconst SEGMENTS = [\n { key: REC_STATE.New, label: \"New\" },\n { key: REC_STATE.Snoozed, label: \"Snoozed\" },\n { key: REC_STATE.Accepted, label: \"Accepted\" },\n { key: REC_STATE.Dismissed, label: \"Dismissed\" },\n] as const;\n\ntype SegmentKey = (typeof SEGMENTS)[number][\"key\"];\n\n/** A NEW or SNOOZED recommendation is still actionable (accept / snooze / dismiss). */\nfunction isActionable(state: string): boolean {\n return state === REC_STATE.New || state === REC_STATE.Snoozed;\n}\n\n/** Snooze a week out — long enough to be non-nagging, short enough to resurface. */\nfunction snoozeUntilIso(): string {\n return new Date(Date.now() + 7 * 86_400_000).toISOString();\n}\n\nconst clamp01 = (n: number) => Math.min(1, Math.max(0, n));\nconst asPercent = (n: number) => `${Math.round(clamp01(n) * 100)}%`;\n\nfunction formatDate(iso: string): string {\n return new Date(iso).toLocaleDateString(undefined, {\n month: \"short\",\n day: \"numeric\",\n year: \"numeric\",\n });\n}\n\n/** Hours of the day offered by the quiet-hours pickers. */\nconst HOUR_OPTIONS = Array.from({ length: 24 }, (_, hour) => hour);\n\nconst DOMAIN_ICON: Record<\n TimeCampusLifeDomain,\n ComponentType<{ className?: string }>\n> = {\n [TimeCampusLifeDomain.Work]: Briefcase,\n [TimeCampusLifeDomain.Sleep]: Moon,\n [TimeCampusLifeDomain.Health]: HeartPulse,\n [TimeCampusLifeDomain.Family]: Users,\n [TimeCampusLifeDomain.Learning]: GraduationCap,\n [TimeCampusLifeDomain.Leisure]: Coffee,\n [TimeCampusLifeDomain.Commute]: Bus,\n [TimeCampusLifeDomain.Waiting]: Hourglass,\n [TimeCampusLifeDomain.Chores]: Home,\n [TimeCampusLifeDomain.SelfCare]: Heart,\n [TimeCampusLifeDomain.Social]: Handshake,\n [TimeCampusLifeDomain.FinanceAdmin]: Wallet,\n [TimeCampusLifeDomain.Reflection]: Sparkles,\n [TimeCampusLifeDomain.Other]: Circle,\n};\n\nfunction recIcon(\n domain?: TimeCampusLifeDomain | null,\n): ComponentType<{ className?: string }> {\n if (!domain) return Lightbulb;\n return DOMAIN_ICON[domain] ?? Lightbulb;\n}\n\ntype BadgeTone = \"success\" | \"warning\" | \"muted\" | \"info\";\n\nfunction stateBadge(state: string): { variant: BadgeTone; label: string } {\n switch (state) {\n case REC_STATE.Accepted:\n return { variant: \"success\", label: \"Accepted\" };\n case REC_STATE.Snoozed:\n return { variant: \"warning\", label: \"Snoozed\" };\n case REC_STATE.Dismissed:\n return { variant: \"muted\", label: \"Dismissed\" };\n case REC_STATE.Expired:\n return { variant: \"muted\", label: \"Expired\" };\n default:\n return { variant: \"info\", label: \"New\" };\n }\n}\n\nconst primaryBtn =\n \"inline-flex items-center gap-1.5 rounded-md bg-action-primary-bg px-3 py-1.5 text-sm font-medium text-action-primary-text hover:bg-action-primary-bg/90 disabled:opacity-50\";\nconst neutralBtn =\n \"inline-flex items-center gap-1.5 rounded-md border border-border-subtle px-3 py-1.5 text-sm font-medium text-text-primary hover:bg-bg-sunken/50 disabled:opacity-50\";\nconst chipClass =\n \"inline-flex items-center gap-1 rounded-full bg-bg-sunken px-2.5 py-0.5 text-xs font-medium text-text-secondary\";\n\n/**\n * Local, token-styled switch (the shared UI kit isn't imported here). The knob\n * translates only on the checked state — never on hover — per the repo's\n * no-hover-movement mandate.\n */\nfunction ToggleSwitch({\n checked,\n onChange,\n label,\n disabled,\n}: {\n checked: boolean;\n onChange: (next: boolean) => void;\n label: string;\n disabled?: boolean;\n}) {\n return (\n <button\n type=\"button\"\n role=\"switch\"\n aria-checked={checked}\n aria-label={label}\n disabled={disabled}\n onClick={() => onChange(!checked)}\n className={cn(\n \"relative inline-flex h-5 w-9 shrink-0 items-center rounded-full border transition-colors disabled:cursor-not-allowed disabled:opacity-50\",\n checked\n ? \"border-transparent bg-action-primary-bg\"\n : \"border-border-subtle bg-bg-sunken\",\n )}\n >\n <span\n className={cn(\n \"inline-block h-3.5 w-3.5 transform rounded-full shadow-sm transition-transform\",\n checked\n ? \"translate-x-4 bg-action-primary-text\"\n : \"translate-x-0.5 bg-text-secondary\",\n )}\n />\n </button>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Recommendation card\n// ---------------------------------------------------------------------------\ninterface RecommendationCardProps {\n rec: RecItem;\n busy: boolean;\n muted: boolean;\n onAccept: (id: string) => void;\n onSnooze: (id: string) => void;\n onDismiss: (rec: RecItem) => void;\n onMuteKind: (kind: string) => void;\n}\n\nfunction RecommendationCard({\n rec,\n busy,\n muted,\n onAccept,\n onSnooze,\n onDismiss,\n onMuteKind,\n}: RecommendationCardProps) {\n const Icon = recIcon(rec.domain);\n const actionable = isActionable(rec.state);\n const badge = stateBadge(rec.state);\n const [evidenceOpen, setEvidenceOpen] = useState(false);\n\n // Both come off this card's own query result — the JSON the generator wrote\n // when it raised the recommendation. Nothing is derived or estimated here.\n const evidence = parseEvidenceRefs(rec.evidenceRefs);\n const action = parseSuggestedAction(rec.suggestedAction);\n const evidenceId = `rec-evidence-${rec.id}`;\n const measuredWeeks = evidenceWeeks(rec.createdAt, evidence);\n const navigate = useTimeCampusNavigate();\n\n return (\n <GlassCard treatment=\"glass\" className=\"flex flex-col gap-3 p-4 sm:p-5\">\n <div className=\"flex items-start justify-between gap-3\">\n <div className=\"flex min-w-0 items-center gap-3\">\n <span className=\"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-action-primary-bg/10 text-primary\">\n <Icon className=\"h-5 w-5\" />\n </span>\n <div className=\"min-w-0\">\n <p className=\"flex min-w-0 items-center gap-1.5 text-xs font-medium uppercase tracking-wide text-text-secondary\">\n {rec.source === \"AI\" && (\n <span className={chipClass} data-testid=\"rec-ai-chip\">\n <Sparkles className=\"h-3 w-3\" />\n AI\n </span>\n )}\n <span className=\"truncate\">\n {recommendationKindLabel(rec.kind)}\n </span>\n </p>\n <h3 className=\"mt-0.5 text-base font-semibold text-text-primary\">\n {rec.title}\n </h3>\n </div>\n </div>\n {rec.confidence != null && (\n <StatusBadge\n variant=\"info\"\n label={`${asPercent(rec.confidence)} confident`}\n className=\"shrink-0\"\n />\n )}\n </div>\n\n <p className=\"text-sm text-text-secondary\">{rec.rationale}</p>\n <p className=\"text-xs text-text-tertiary\" data-testid=\"rec-provenance\">\n {recommendationProvenance(rec.source, rec.aiModel)}\n </p>\n\n <div className=\"flex flex-wrap items-center gap-1.5\">\n {rec.domain && (\n <span className={chipClass}>{lifeDomainLabel(rec.domain)}</span>\n )}\n {rec.valueAlignment != null && (\n <span className={chipClass}>\n <ShieldCheck className=\"h-3 w-3\" />\n Aligns with your values · {asPercent(rec.valueAlignment)}\n </span>\n )}\n {rec.state === REC_STATE.Snoozed && rec.snoozeUntil && (\n <span className={chipClass}>\n <Clock className=\"h-3 w-3\" />\n Snoozed until {formatDate(rec.snoozeUntil)}\n </span>\n )}\n {actionable && rec.expiresAt && (\n <span className={chipClass}>\n <CalendarClock className=\"h-3 w-3\" />\n Expires {formatDate(rec.expiresAt)}\n </span>\n )}\n </div>\n\n {/* The concrete next step the generator attached, if any. */}\n {action && (\n <div className=\"rounded-lg border border-border-seam bg-bg-sunken/40 p-3\">\n <p className=\"text-xs font-medium uppercase tracking-wide text-text-secondary\">\n Suggested action\n </p>\n <p className=\"mt-1 text-sm font-medium text-text-primary\">\n {humaniseToken(action.type)}\n </p>\n {action.details.length > 0 && (\n <dl className=\"mt-1.5 flex flex-wrap gap-x-4 gap-y-1\">\n {action.details.map((detail) => (\n <div key={detail.key} className=\"flex items-center gap-1.5\">\n <dt className=\"text-xs text-text-secondary\">{detail.key}</dt>\n <dd className=\"text-xs font-medium tabular-nums text-text-primary\">\n {detail.value}\n </dd>\n </div>\n ))}\n </dl>\n )}\n </div>\n )}\n\n {/* Why this was raised — the exact metrics the generator measured. */}\n {evidence.length > 0 && (\n <div className=\"rounded-lg border border-border-seam bg-bg-sunken/40\">\n <button\n type=\"button\"\n onClick={() => setEvidenceOpen((open) => !open)}\n aria-expanded={evidenceOpen}\n aria-controls={evidenceId}\n className=\"flex w-full items-center justify-between gap-2 px-3 py-2 text-left\"\n >\n <span className=\"flex min-w-0 items-center gap-2\">\n <Microscope className=\"h-3.5 w-3.5 shrink-0 text-text-secondary\" />\n <span className=\"truncate text-xs text-text-secondary\">\n Evidence: {formatEvidenceRef(evidence[0])}\n {evidence.length > 1 ? ` · +${evidence.length - 1} more` : \"\"}\n </span>\n </span>\n <ChevronDown\n className={cn(\n \"h-4 w-4 shrink-0 text-text-secondary transition-transform\",\n evidenceOpen && \"rotate-180\",\n )}\n />\n </button>\n {evidenceOpen && (\n <dl\n id={evidenceId}\n className=\"space-y-1.5 border-t border-border-seam px-3 py-2.5\"\n >\n {evidence.map((ref, index) => (\n <div\n key={`${ref.metric}-${ref.period ?? ref.domain ?? index}`}\n className=\"flex items-baseline justify-between gap-3\"\n >\n <dt className=\"text-xs text-text-secondary\">\n {formatEvidenceRef(ref).split(\": \")[0]}\n </dt>\n <dd className=\"text-xs font-medium tabular-nums text-text-primary\">\n {formatEvidenceRef(ref).split(\": \").slice(1).join(\": \")}\n </dd>\n </div>\n ))}\n {measuredWeeks.length > 0 && (\n <div className=\"flex flex-wrap gap-2 pt-1\">\n {measuredWeeks.map((weekStart) => (\n <button\n key={weekStart}\n type=\"button\"\n onClick={() =>\n navigate(\n `/timeline?date=${encodeURIComponent(weekStart)}`,\n )\n }\n data-testid=\"rec-evidence-timeline-link\"\n className=\"inline-flex items-center gap-1 text-xs font-medium text-primary hover:underline focus:outline-none focus-visible:ring-2 focus-visible:ring-action-primary-bg/40\"\n >\n <ExternalLink className=\"h-3 w-3\" />\n Open the week of {formatDate(`${weekStart}T12:00:00`)} on\n your timeline\n </button>\n ))}\n </div>\n )}\n <p className=\"pt-1 text-xs text-text-tertiary\">\n Measured from your own tracked week. Nothing is applied until\n you accept.\n </p>\n </dl>\n )}\n </div>\n )}\n\n {actionable ? (\n <div className=\"flex flex-wrap items-center gap-2 pt-1\">\n <button\n type=\"button\"\n onClick={() => onAccept(rec.id)}\n disabled={busy}\n className={primaryBtn}\n >\n <Check className=\"h-4 w-4\" />\n Accept\n </button>\n <button\n type=\"button\"\n onClick={() => onSnooze(rec.id)}\n disabled={busy}\n className={neutralBtn}\n >\n <Clock className=\"h-4 w-4\" />\n Snooze\n </button>\n <button\n type=\"button\"\n onClick={() => onDismiss(rec)}\n disabled={busy}\n className={neutralBtn}\n >\n <X className=\"h-4 w-4\" />\n Dismiss\n </button>\n <button\n type=\"button\"\n onClick={() => onMuteKind(rec.kind)}\n disabled={busy || muted}\n className={neutralBtn}\n title={\n muted\n ? `${recommendationKindLabel(rec.kind)} suggestions are already muted`\n : `Stop generating ${recommendationKindLabel(rec.kind)} suggestions`\n }\n >\n <BellOff className=\"h-4 w-4\" />\n {muted ? \"Muted\" : \"Mute this kind\"}\n </button>\n </div>\n ) : (\n <div className=\"flex flex-col gap-2 pt-1\">\n <div className=\"flex items-center justify-between gap-2\">\n <StatusBadge variant={badge.variant} label={badge.label} />\n <span className=\"text-xs text-text-secondary\">\n {formatDate(rec.createdAt)}\n </span>\n </div>\n {rec.state === REC_STATE.Dismissed && rec.dismissReason && (\n <p className=\"text-xs text-text-secondary\">\n Reason given: {rec.dismissReason}\n </p>\n )}\n </div>\n )}\n </GlassCard>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Guardrails — the preferences that decide what may be suggested at all.\n// Every value here is read from `myRecommendationPreferences`; the controls\n// write back through `updateMyRecommendationPreferences`.\n// ---------------------------------------------------------------------------\ninterface GuardrailsPanelProps {\n prefs: PrefItem | undefined;\n loading: boolean;\n saving: boolean;\n onToggleOutputGuard: (next: boolean) => void;\n onQuietHoursChange: (start: number | null, end: number | null) => void;\n onUnmuteKind: (kind: string) => void;\n}\n\nfunction GuardrailsPanel({\n prefs,\n loading,\n saving,\n onToggleOutputGuard,\n onQuietHoursChange,\n onUnmuteKind,\n}: GuardrailsPanelProps) {\n if (loading) {\n return <LoadingSkeleton variant=\"card\" count={1} />;\n }\n if (!prefs) return null;\n\n const quietStart = formatHourOfDay(prefs.quietHoursStart);\n const quietEnd = formatHourOfDay(prefs.quietHoursEnd);\n const quietSet = quietStart !== null && quietEnd !== null;\n\n const hourSelectClass =\n \"rounded-md border border-border-subtle bg-bg-surface px-2 py-1 text-xs text-text-primary focus:outline-none focus:ring-2 focus:ring-action-primary-bg/40 disabled:opacity-50\";\n\n return (\n <GlassCard treatment=\"glass\" className=\"p-4 sm:p-5\">\n <div className=\"flex items-center gap-2\">\n <ShieldCheck className=\"h-4 w-4 text-text-secondary\" />\n <h3 className=\"text-sm font-semibold text-text-primary\">Guardrails</h3>\n </div>\n <p className=\"mt-1 text-xs text-text-secondary\">\n What TimeCampus is allowed to suggest, and when.\n </p>\n\n <div className=\"mt-4 space-y-4\">\n <div className=\"flex items-start justify-between gap-3\">\n <div className=\"min-w-0\">\n <p className=\"text-sm font-medium text-text-primary\">\n Never suggest more work\n </p>\n <p className=\"mt-0.5 text-xs text-text-secondary\">\n Output-increasing suggestions are filtered out before they reach\n you.\n </p>\n </div>\n <ToggleSwitch\n checked={prefs.neverOptimiseForOutput}\n disabled={saving}\n label=\"Never suggest more work\"\n onChange={onToggleOutputGuard}\n />\n </div>\n\n <div className=\"border-t border-border-seam pt-4\">\n <div className=\"flex items-center justify-between gap-3\">\n <p className=\"text-sm font-medium text-text-primary\">Quiet hours</p>\n <span className=\"text-xs text-text-secondary\">\n {quietSet ? `${quietStart}–${quietEnd}` : \"Not set\"}\n </span>\n </div>\n <p className=\"mt-0.5 text-xs text-text-secondary\">\n No nudges are sent inside this window.\n </p>\n <div className=\"mt-2 flex flex-wrap items-center gap-2\">\n <label className=\"flex items-center gap-1.5 text-xs text-text-secondary\">\n From\n <select\n className={hourSelectClass}\n disabled={saving}\n value={prefs.quietHoursStart ?? \"\"}\n onChange={(event) =>\n onQuietHoursChange(\n event.target.value === \"\"\n ? null\n : Number(event.target.value),\n prefs.quietHoursEnd ?? null,\n )\n }\n >\n <option value=\"\">—</option>\n {HOUR_OPTIONS.map((hour) => (\n <option key={hour} value={hour}>\n {formatHourOfDay(hour)}\n </option>\n ))}\n </select>\n </label>\n <label className=\"flex items-center gap-1.5 text-xs text-text-secondary\">\n To\n <select\n className={hourSelectClass}\n disabled={saving}\n value={prefs.quietHoursEnd ?? \"\"}\n onChange={(event) =>\n onQuietHoursChange(\n prefs.quietHoursStart ?? null,\n event.target.value === \"\"\n ? null\n : Number(event.target.value),\n )\n }\n >\n <option value=\"\">—</option>\n {HOUR_OPTIONS.map((hour) => (\n <option key={hour} value={hour}>\n {formatHourOfDay(hour)}\n </option>\n ))}\n </select>\n </label>\n {quietSet && (\n <button\n type=\"button\"\n disabled={saving}\n onClick={() => onQuietHoursChange(null, null)}\n className=\"text-xs font-medium text-text-secondary underline-offset-2 hover:text-text-primary hover:underline disabled:opacity-50\"\n >\n Clear\n </button>\n )}\n </div>\n </div>\n\n <div className=\"border-t border-border-seam pt-4\">\n <div className=\"flex items-center justify-between gap-3\">\n <p className=\"text-sm font-medium text-text-primary\">Muted kinds</p>\n <span className={chipClass}>{prefs.mutedKinds.length}</span>\n </div>\n {prefs.mutedKinds.length === 0 ? (\n <p className=\"mt-0.5 text-xs text-text-secondary\">\n Nothing muted — mute a kind from any suggestion to stop it coming\n back.\n </p>\n ) : (\n <div className=\"mt-2 flex flex-wrap gap-1.5\">\n {prefs.mutedKinds.map((kind) => (\n <button\n key={kind}\n type=\"button\"\n disabled={saving}\n onClick={() => onUnmuteKind(kind)}\n className={cn(\n chipClass,\n \"hover:text-text-primary disabled:opacity-50\",\n )}\n title={`Unmute ${recommendationKindLabel(kind)} suggestions`}\n >\n {recommendationKindLabel(kind)}\n <X className=\"h-3 w-3\" />\n </button>\n ))}\n </div>\n )}\n </div>\n\n <div className=\"border-t border-border-seam pt-4\">\n <div className=\"flex items-center justify-between gap-3\">\n <p className=\"text-sm font-medium text-text-primary\">Cadence</p>\n <span className=\"text-xs text-text-secondary\">\n {humaniseToken(prefs.cadence)}\n </span>\n </div>\n {prefs.optedInDomains.length > 0 && (\n <>\n <p className=\"mt-3 text-sm font-medium text-text-primary\">\n Opted-in domains\n </p>\n <div className=\"mt-1.5 flex flex-wrap gap-1.5\">\n {prefs.optedInDomains.map((domain) => (\n <span key={domain} className={chipClass}>\n {lifeDomainLabel(domain)}\n </span>\n ))}\n </div>\n </>\n )}\n </div>\n </div>\n </GlassCard>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Page\n// ---------------------------------------------------------------------------\nfunction segmentEmptyCopy(segment: SegmentKey): {\n title: string;\n description: string;\n} {\n switch (segment) {\n case REC_STATE.Snoozed:\n return {\n title: \"Nothing snoozed\",\n description:\n \"Suggestions you snooze for later will wait here quietly until they're worth another look.\",\n };\n case REC_STATE.Accepted:\n return {\n title: \"Nothing accepted yet\",\n description:\n \"When you accept a suggestion it moves here, so you can see the changes you chose to make.\",\n };\n case REC_STATE.Dismissed:\n return {\n title: \"Nothing dismissed\",\n description:\n \"Suggestions you dismiss are kept here — TimeCampus learns from them and won't keep nagging.\",\n };\n default:\n return {\n title: \"You're all caught up\",\n description:\n \"No new suggestions right now. Generate again after a few more days of tracked time.\",\n };\n }\n}\n\nexport function RecommendationsPage() {\n const { workspaceId } = useTimeCampus();\n const { toasts, addToast, dismissToast } = useToast();\n const [segment, setSegment] = useState<SegmentKey>(REC_STATE.New);\n const [busyId, setBusyId] = useState<string | null>(null);\n const [dismissTarget, setDismissTarget] = useState<RecItem | null>(null);\n const [dismissReason, setDismissReason] = useState(\"\");\n\n const { data, loading, error, refetch } = useMyRecommendationsQuery({\n variables: { state: null },\n skip: !workspaceId,\n });\n\n const {\n data: prefsData,\n loading: prefsLoading,\n refetch: refetchPrefs,\n } = useMyRecommendationPreferencesQuery({ skip: !workspaceId });\n\n const [generate, { loading: generating }] =\n useGenerateMyRecommendationsMutation();\n const [acceptRec] = useAcceptRecommendationMutation();\n const [dismissRec] = useDismissRecommendationMutation();\n const [snoozeRec] = useSnoozeRecommendationMutation();\n const [updatePrefs, { loading: savingPrefs }] =\n useUpdateMyRecommendationPreferencesMutation();\n\n const prefs = prefsData?.myRecommendationPreferences;\n const mutedKinds = useMemo<Set<string>>(\n () => new Set<string>(prefs?.mutedKinds ?? []),\n [prefs?.mutedKinds],\n );\n\n const recommendations: RecItem[] = useMemo(\n () => data?.myRecommendations ?? [],\n [data?.myRecommendations],\n );\n\n const counts = useMemo(() => {\n const map: Record<string, number> = {};\n for (const rec of recommendations) {\n map[rec.state] = (map[rec.state] ?? 0) + 1;\n }\n return map;\n }, [recommendations]);\n\n const visible = useMemo(\n () => recommendations.filter((rec) => rec.state === segment),\n [recommendations, segment],\n );\n\n const newCount = counts[REC_STATE.New] ?? 0;\n const acceptedCount = counts[REC_STATE.Accepted] ?? 0;\n const snoozedCount = counts[REC_STATE.Snoozed] ?? 0;\n\n const handleGenerate = async () => {\n try {\n const res = await generate();\n const generated = res.data?.generateMyRecommendations ?? [];\n addToast({\n title:\n generated.length > 0\n ? `${generated.length} suggestion${generated.length === 1 ? \"\" : \"s\"} ready`\n : \"No new suggestions\",\n description:\n generated.length > 0\n ? \"Fresh, values-aware ideas are in your New feed.\"\n : \"You're all caught up — nothing new to suggest right now.\",\n variant: generated.length > 0 ? \"success\" : \"info\",\n });\n setSegment(REC_STATE.New);\n await refetch();\n } catch {\n addToast({\n title: \"Couldn't generate recommendations\",\n description: \"Please try again in a moment.\",\n variant: \"error\",\n });\n }\n };\n\n const handleAccept = async (id: string) => {\n setBusyId(id);\n try {\n await acceptRec({ variables: { id } });\n addToast({ title: \"Accepted — nice\", variant: \"success\" });\n await refetch();\n } catch {\n addToast({ title: \"Couldn't accept that one\", variant: \"error\" });\n } finally {\n setBusyId(null);\n }\n };\n\n const handleSnooze = async (id: string) => {\n setBusyId(id);\n try {\n await snoozeRec({ variables: { id, until: snoozeUntilIso() } });\n addToast({\n title: \"Snoozed for a week\",\n description: \"It'll resurface later — no nagging in between.\",\n variant: \"info\",\n });\n await refetch();\n } catch {\n addToast({ title: \"Couldn't snooze that one\", variant: \"error\" });\n } finally {\n setBusyId(null);\n }\n };\n\n const requestDismiss = (rec: RecItem) => {\n setDismissReason(\"\");\n setDismissTarget(rec);\n };\n\n /**\n * Dismissing asks for an optional reason first — `dismissRecommendation`\n * takes one and the card reads it back, so the note the user leaves is the\n * note they later see.\n */\n const handleConfirmDismiss = async () => {\n const target = dismissTarget;\n if (!target) return;\n const reason = dismissReason.trim();\n setBusyId(target.id);\n try {\n await dismissRec({\n variables: { id: target.id, reason: reason.length > 0 ? reason : null },\n });\n addToast({ title: \"Dismissed\", variant: \"success\" });\n setDismissTarget(null);\n setDismissReason(\"\");\n await refetch();\n } catch {\n addToast({ title: \"Couldn't dismiss that one\", variant: \"error\" });\n } finally {\n setBusyId(null);\n }\n };\n\n /** One write path for every guardrail control, so failures read the same. */\n const savePrefs = async (\n input: {\n neverOptimiseForOutput?: boolean;\n quietHoursStart?: number | null;\n quietHoursEnd?: number | null;\n mutedKinds?: string[];\n },\n successTitle: string,\n ) => {\n try {\n await updatePrefs({ variables: { input } });\n addToast({ title: successTitle, variant: \"success\" });\n await refetchPrefs();\n } catch {\n addToast({\n title: \"Couldn't save that guardrail\",\n description: \"Please try again in a moment.\",\n variant: \"error\",\n });\n }\n };\n\n const handleToggleOutputGuard = (next: boolean) =>\n void savePrefs(\n { neverOptimiseForOutput: next },\n next\n ? \"Output-increasing suggestions are off\"\n : \"Output-increasing suggestions allowed\",\n );\n\n const handleQuietHoursChange = (start: number | null, end: number | null) =>\n void savePrefs(\n { quietHoursStart: start, quietHoursEnd: end },\n start === null && end === null\n ? \"Quiet hours cleared\"\n : \"Quiet hours saved\",\n );\n\n const handleMuteKind = (kind: string) => {\n if (mutedKinds.has(kind)) return;\n void savePrefs(\n { mutedKinds: [...mutedKinds, kind] },\n `${recommendationKindLabel(kind)} suggestions muted`,\n );\n };\n\n const handleUnmuteKind = (kind: string) =>\n void savePrefs(\n { mutedKinds: [...mutedKinds].filter((entry) => entry !== kind) },\n `${recommendationKindLabel(kind)} suggestions unmuted`,\n );\n\n const guardrailsPanel = (\n <GuardrailsPanel\n prefs={prefs}\n loading={prefsLoading}\n saving={savingPrefs}\n onToggleOutputGuard={handleToggleOutputGuard}\n onQuietHoursChange={handleQuietHoursChange}\n onUnmuteKind={handleUnmuteKind}\n />\n );\n\n const generateButton = (\n <button\n type=\"button\"\n onClick={handleGenerate}\n disabled={generating || !workspaceId}\n className={primaryBtn}\n >\n <Sparkles className=\"h-4 w-4\" />\n {generating ? \"Generating…\" : \"Generate recommendations\"}\n </button>\n );\n\n const purpose =\n \"Gentle, values-aware nudges built from your real timeline — protect a focus block, \" +\n \"reclaim a commute, guard family time. Accept the ones that fit, snooze the rest, and \" +\n \"dismiss what doesn't. TimeCampus never optimises for more output — only for time that \" +\n \"matches what you value.\";\n\n const footerNote = (\n <GlassCard treatment=\"insight\" className=\"mt-6 p-4 sm:p-5\">\n <div className=\"flex items-start gap-3\">\n <span className=\"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-status-info-bg text-status-info-text\">\n <ShieldCheck className=\"h-5 w-5\" />\n </span>\n <div className=\"min-w-0\">\n <h3 className=\"text-sm font-semibold text-text-primary\">\n Never optimises for more output.\n </h3>\n <p className=\"mt-1 text-sm text-text-secondary\">\n Every suggestion protects something you value — rest, focus,\n relationships — not your throughput. Snooze or dismiss freely;\n TimeCampus takes the hint and won't keep nagging.\n </p>\n </div>\n </div>\n </GlassCard>\n );\n\n if (!workspaceId || loading) {\n return (\n <PageLayout\n title=\"Recommendations\"\n description=\"Values-aware suggestions from your real timeline\"\n purpose={purpose}\n actions={generateButton}\n >\n <LoadingSkeleton variant=\"list\" count={4} />\n </PageLayout>\n );\n }\n\n if (error) {\n return (\n <PageLayout\n title=\"Recommendations\"\n description=\"Values-aware suggestions from your real timeline\"\n purpose={purpose}\n actions={generateButton}\n >\n <div className=\"rounded-xl border border-status-error-border/50 bg-status-error-bg/10 p-4 text-sm text-status-error-text\">\n Couldn&apos;t load your recommendations right now. Please try again in\n a moment.\n </div>\n </PageLayout>\n );\n }\n\n const hasAny = recommendations.length > 0;\n const emptyCopy = segmentEmptyCopy(segment);\n\n return (\n <PageLayout\n title=\"Recommendations\"\n description=\"Values-aware suggestions from your real timeline\"\n purpose={purpose}\n actions={generateButton}\n >\n {!hasAny ? (\n <div className=\"grid grid-cols-1 gap-6 lg:grid-cols-[minmax(0,1fr)_20rem]\">\n <div>\n <EmptyState\n illustration=\"empty-data\"\n title=\"No recommendations yet\"\n description=\"TimeCampus turns your real timeline into gentle, values-aware suggestions — like protecting a focus block or reclaiming a commute. Generate your first set to see what it notices.\"\n action={generateButton}\n />\n {footerNote}\n </div>\n <div>{guardrailsPanel}</div>\n </div>\n ) : (\n <div className=\"grid grid-cols-1 gap-6 lg:grid-cols-[minmax(0,1fr)_20rem]\">\n <div className=\"min-w-0 space-y-6\">\n {/* Summary of where each suggestion stands — from the query only. */}\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-3\">\n <StatCard\n featured\n title=\"New for you\"\n value={String(newCount)}\n icon={<Sparkles className=\"h-5 w-5\" />}\n description=\"Awaiting your call\"\n />\n <StatCard\n title=\"Accepted\"\n value={String(acceptedCount)}\n icon={<CheckCircle2 className=\"h-5 w-5\" />}\n description=\"Changes you chose to make\"\n />\n <StatCard\n title=\"Snoozed\"\n value={String(snoozedCount)}\n icon={<Clock className=\"h-5 w-5\" />}\n description=\"Waiting for a better moment\"\n />\n </div>\n\n {/* Segmented control by state. */}\n <div className=\"overflow-x-auto\">\n <div\n className=\"inline-flex items-center rounded-lg border border-border-subtle bg-bg-sunken/50 p-0.5\"\n role=\"tablist\"\n aria-label=\"Filter recommendations by state\"\n >\n {SEGMENTS.map((seg) => {\n const active = seg.key === segment;\n const count = counts[seg.key] ?? 0;\n return (\n <button\n key={seg.key}\n type=\"button\"\n role=\"tab\"\n aria-selected={active}\n onClick={() => setSegment(seg.key)}\n className={\n active\n ? \"flex items-center gap-1.5 rounded-md bg-bg-surface px-3 py-1.5 text-sm font-medium text-text-primary shadow-sm\"\n : \"flex items-center gap-1.5 rounded-md px-3 py-1.5 text-sm font-medium text-text-secondary transition-colors hover:text-text-primary\"\n }\n >\n {seg.label}\n <span\n className={\n active\n ? \"rounded-full bg-action-primary-bg/15 px-1.5 text-xs font-semibold text-primary\"\n : \"rounded-full bg-bg-sunken px-1.5 text-xs font-semibold text-text-secondary\"\n }\n >\n {count}\n </span>\n </button>\n );\n })}\n </div>\n </div>\n\n {/* The feed for the active segment. */}\n {visible.length === 0 ? (\n <EmptyState\n illustration=\"empty-data\"\n title={emptyCopy.title}\n description={emptyCopy.description}\n action={segment === REC_STATE.New ? generateButton : undefined}\n />\n ) : (\n <div className=\"space-y-4\">\n {visible.map((rec) => (\n <RecommendationCard\n key={rec.id}\n rec={rec}\n busy={busyId === rec.id || savingPrefs}\n muted={mutedKinds.has(rec.kind)}\n onAccept={handleAccept}\n onSnooze={handleSnooze}\n onDismiss={requestDismiss}\n onMuteKind={handleMuteKind}\n />\n ))}\n </div>\n )}\n\n {footerNote}\n </div>\n <div>{guardrailsPanel}</div>\n </div>\n )}\n\n {/* Dismissing captures the optional reason the mutation accepts, so the\n note is there when the card is read back under Dismissed. */}\n <Modal\n open={dismissTarget !== null}\n onClose={() => setDismissTarget(null)}\n title=\"Dismiss this suggestion\"\n description={dismissTarget?.title}\n size=\"sm\"\n footer={\n <>\n <button\n type=\"button\"\n onClick={() => setDismissTarget(null)}\n className={neutralBtn}\n >\n Cancel\n </button>\n <button\n type=\"button\"\n onClick={() => void handleConfirmDismiss()}\n disabled={busyId !== null}\n className={primaryBtn}\n >\n <X className=\"h-4 w-4\" />\n Dismiss\n </button>\n </>\n }\n >\n <label\n htmlFor=\"rec-dismiss-reason\"\n className=\"block text-sm font-medium text-text-primary\"\n >\n Why isn&apos;t this one for you?{\" \"}\n <span className=\"font-normal text-text-secondary\">(optional)</span>\n </label>\n <textarea\n id=\"rec-dismiss-reason\"\n rows={3}\n value={dismissReason}\n onChange={(event) => setDismissReason(event.target.value)}\n placeholder=\"e.g. already handled, not the right week\"\n className=\"mt-1.5 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary placeholder:text-text-secondary\"\n />\n <p className=\"mt-2 text-xs text-text-secondary\">\n Saved with the suggestion so you can see why you passed on it later.\n To stop this kind of suggestion entirely, use Mute this kind.\n </p>\n </Modal>\n\n <ToastContainer toasts={toasts} onDismiss={dismissToast} />\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA6EA,IAAM,IAAY;CAChB,KAAK;CACL,SAAS;CACT,UAAU;CACV,WAAW;CACX,SAAS;AACX,GAEM,KAAW;CACf;EAAE,KAAK,EAAU;EAAK,OAAO;CAAM;CACnC;EAAE,KAAK,EAAU;EAAS,OAAO;CAAU;CAC3C;EAAE,KAAK,EAAU;EAAU,OAAO;CAAW;CAC7C;EAAE,KAAK,EAAU;EAAW,OAAO;CAAY;AACjD;AAKA,SAAS,GAAa,GAAwB;CAC5C,OAAO,MAAU,EAAU,OAAO,MAAU,EAAU;AACxD;AAGA,SAAS,KAAyB;CAChC,OAAO,IAAI,KAAK,KAAK,IAAI,IAAI,MAAc,CAAC,CAAC,YAAY;AAC3D;AAEA,IAAM,MAAW,MAAc,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,CAAC,CAAC,GACnD,KAAa,MAAc,GAAG,KAAK,MAAM,GAAQ,CAAC,IAAI,GAAG,EAAE;AAEjE,SAAS,EAAW,GAAqB;CACvC,OAAO,IAAI,KAAK,CAAG,CAAC,CAAC,mBAAmB,KAAA,GAAW;EACjD,OAAO;EACP,KAAK;EACL,MAAM;CACR,CAAC;AACH;AAGA,IAAM,IAA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AxBN,UAAA;KA2BE,kBAAC,SAAD;MACE,SAAQ;MACR,WAAU;MAFZ,UAAA;OAGC;OACkC;OACjC,kBAAC,QAAD;QAAM,WAAU;QAAkC,UAAA;OAAgB,CAAA;MAC7D;;KACP,kBAAC,YAAD;MACE,IAAG;MACH,MAAM;MACN,OAAO;MACP,WAAW,MAAU,EAAiB,EAAM,OAAO,KAAK;MACxD,aAAY;MACZ,WAAU;KACX,CAAA;KACD,kBAAC,KAAD;MAAG,WAAU;MAAmC,UAAA;KAG7C,CAAA;IACE;;GAEP,kBAAC,GAAD;IAAwB;IAAQ,WAAW;GAAe,CAAA;EAChD;;AAEhB"}
1
+ {"version":3,"file":"RecommendationsPage.js","names":[],"sources":["../../../../src/timecampus/pages/lifetime/RecommendationsPage.tsx"],"sourcesContent":["import { useMemo, useState, type ComponentType } from \"react\";\nimport {\n Sparkles,\n Check,\n CheckCircle2,\n ChevronDown,\n X,\n Clock,\n BellOff,\n CalendarClock,\n Microscope,\n ShieldCheck,\n Lightbulb,\n Briefcase,\n Moon,\n HeartPulse,\n Users,\n GraduationCap,\n Coffee,\n Bus,\n Hourglass,\n Home,\n Heart,\n Handshake,\n Wallet,\n Circle,\n ExternalLink,\n} from \"lucide-react\";\nimport { GlassCard } from \"@burdenoff/fe-libs/ui\";\nimport {\n PageLayout,\n StatCard,\n StatusBadge,\n EmptyState,\n LoadingSkeleton,\n Modal,\n ToastContainer,\n useToast,\n} from \"../../components\";\nimport { cn } from \"../../utils/helpers\";\nimport {\n useTimeCampus,\n useTimeCampusNavigate,\n} from \"../../providers/TimeCampusProvider\";\nimport { TimeCampusLifeDomain } from \"@/generated/wspace-types\";\nimport {\n useMyRecommendationsQuery,\n useMyRecommendationPreferencesQuery,\n useGenerateMyRecommendationsMutation,\n useAcceptRecommendationMutation,\n useDismissRecommendationMutation,\n useSnoozeRecommendationMutation,\n useUpdateMyRecommendationPreferencesMutation,\n useMyTimeIntelligenceDeliveriesQuery,\n type RecommendationFieldsFragment,\n type RecommendationPreferenceFieldsFragment,\n type TimeIntelligenceDeliveryFieldsFragment,\n} from \"@/generated/wspace-operations\";\nimport { lifeDomainLabel } from \"./domains\";\nimport {\n evidenceWeeks,\n formatEvidenceRef,\n formatHourOfDay,\n humaniseToken,\n parseEvidenceRefs,\n parseSuggestedAction,\n recommendationKindLabel,\n recommendationProvenance,\n} from \"./recommendationEvidence\";\nimport {\n DIGEST_CADENCE_OPTIONS,\n DIGEST_DAY_OPTIONS,\n describeDelivery,\n formatUtcHourWithLocal,\n type DeliveryTone,\n} from \"./timeIntelligence\";\n\ntype RecItem = RecommendationFieldsFragment;\n\ntype PrefItem = RecommendationPreferenceFieldsFragment;\n\n// ---------------------------------------------------------------------------\n// Recommendation states are stored as free strings on the backend\n// (NEW / ACCEPTED / DISMISSED / SNOOZED / EXPIRED — see the svc schema). We\n// segment the feed by them; unknown states simply don't match a tab.\n// ---------------------------------------------------------------------------\nconst REC_STATE = {\n New: \"NEW\",\n Snoozed: \"SNOOZED\",\n Accepted: \"ACCEPTED\",\n Dismissed: \"DISMISSED\",\n Expired: \"EXPIRED\",\n} as const;\n\nconst SEGMENTS = [\n { key: REC_STATE.New, label: \"New\" },\n { key: REC_STATE.Snoozed, label: \"Snoozed\" },\n { key: REC_STATE.Accepted, label: \"Accepted\" },\n { key: REC_STATE.Dismissed, label: \"Dismissed\" },\n] as const;\n\ntype SegmentKey = (typeof SEGMENTS)[number][\"key\"];\n\n/** A NEW or SNOOZED recommendation is still actionable (accept / snooze / dismiss). */\nfunction isActionable(state: string): boolean {\n return state === REC_STATE.New || state === REC_STATE.Snoozed;\n}\n\n/** Snooze a week out — long enough to be non-nagging, short enough to resurface. */\nfunction snoozeUntilIso(): string {\n return new Date(Date.now() + 7 * 86_400_000).toISOString();\n}\n\nconst clamp01 = (n: number) => Math.min(1, Math.max(0, n));\nconst asPercent = (n: number) => `${Math.round(clamp01(n) * 100)}%`;\n\nfunction formatDate(iso: string): string {\n return new Date(iso).toLocaleDateString(undefined, {\n month: \"short\",\n day: \"numeric\",\n year: \"numeric\",\n });\n}\n\n/** Hours of the day offered by the quiet-hours pickers. */\nconst HOUR_OPTIONS = Array.from({ length: 24 }, (_, hour) => hour);\n\nconst DOMAIN_ICON: Record<\n TimeCampusLifeDomain,\n ComponentType<{ className?: string }>\n> = {\n [TimeCampusLifeDomain.Work]: Briefcase,\n [TimeCampusLifeDomain.Sleep]: Moon,\n [TimeCampusLifeDomain.Health]: HeartPulse,\n [TimeCampusLifeDomain.Family]: Users,\n [TimeCampusLifeDomain.Learning]: GraduationCap,\n [TimeCampusLifeDomain.Leisure]: Coffee,\n [TimeCampusLifeDomain.Commute]: Bus,\n [TimeCampusLifeDomain.Waiting]: Hourglass,\n [TimeCampusLifeDomain.Chores]: Home,\n [TimeCampusLifeDomain.SelfCare]: Heart,\n [TimeCampusLifeDomain.Social]: Handshake,\n [TimeCampusLifeDomain.FinanceAdmin]: Wallet,\n [TimeCampusLifeDomain.Reflection]: Sparkles,\n [TimeCampusLifeDomain.Other]: Circle,\n};\n\nfunction recIcon(\n domain?: TimeCampusLifeDomain | null,\n): ComponentType<{ className?: string }> {\n if (!domain) return Lightbulb;\n return DOMAIN_ICON[domain] ?? Lightbulb;\n}\n\ntype BadgeTone = \"success\" | \"warning\" | \"muted\" | \"info\";\n\nfunction stateBadge(state: string): { variant: BadgeTone; label: string } {\n switch (state) {\n case REC_STATE.Accepted:\n return { variant: \"success\", label: \"Accepted\" };\n case REC_STATE.Snoozed:\n return { variant: \"warning\", label: \"Snoozed\" };\n case REC_STATE.Dismissed:\n return { variant: \"muted\", label: \"Dismissed\" };\n case REC_STATE.Expired:\n return { variant: \"muted\", label: \"Expired\" };\n default:\n return { variant: \"info\", label: \"New\" };\n }\n}\n\nconst primaryBtn =\n \"inline-flex items-center gap-1.5 rounded-md bg-action-primary-bg px-3 py-1.5 text-sm font-medium text-action-primary-text hover:bg-action-primary-bg/90 disabled:opacity-50\";\nconst neutralBtn =\n \"inline-flex items-center gap-1.5 rounded-md border border-border-subtle px-3 py-1.5 text-sm font-medium text-text-primary hover:bg-bg-sunken/50 disabled:opacity-50\";\nconst chipClass =\n \"inline-flex items-center gap-1 rounded-full bg-bg-sunken px-2.5 py-0.5 text-xs font-medium text-text-secondary\";\n\n/**\n * Local, token-styled switch (the shared UI kit isn't imported here). The knob\n * translates only on the checked state — never on hover — per the repo's\n * no-hover-movement mandate.\n */\nfunction ToggleSwitch({\n checked,\n onChange,\n label,\n disabled,\n}: {\n checked: boolean;\n onChange: (next: boolean) => void;\n label: string;\n disabled?: boolean;\n}) {\n return (\n <button\n type=\"button\"\n role=\"switch\"\n aria-checked={checked}\n aria-label={label}\n disabled={disabled}\n onClick={() => onChange(!checked)}\n className={cn(\n \"relative inline-flex h-5 w-9 shrink-0 items-center rounded-full border transition-colors disabled:cursor-not-allowed disabled:opacity-50\",\n checked\n ? \"border-transparent bg-action-primary-bg\"\n : \"border-border-subtle bg-bg-sunken\",\n )}\n >\n <span\n className={cn(\n \"inline-block h-3.5 w-3.5 transform rounded-full shadow-sm transition-transform\",\n checked\n ? \"translate-x-4 bg-action-primary-text\"\n : \"translate-x-0.5 bg-text-secondary\",\n )}\n />\n </button>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Recommendation card\n// ---------------------------------------------------------------------------\ninterface RecommendationCardProps {\n rec: RecItem;\n busy: boolean;\n muted: boolean;\n onAccept: (id: string) => void;\n onSnooze: (id: string) => void;\n onDismiss: (rec: RecItem) => void;\n onMuteKind: (kind: string) => void;\n}\n\nfunction RecommendationCard({\n rec,\n busy,\n muted,\n onAccept,\n onSnooze,\n onDismiss,\n onMuteKind,\n}: RecommendationCardProps) {\n const Icon = recIcon(rec.domain);\n const actionable = isActionable(rec.state);\n const badge = stateBadge(rec.state);\n const [evidenceOpen, setEvidenceOpen] = useState(false);\n\n // Both come off this card's own query result — the JSON the generator wrote\n // when it raised the recommendation. Nothing is derived or estimated here.\n const evidence = parseEvidenceRefs(rec.evidenceRefs);\n const action = parseSuggestedAction(rec.suggestedAction);\n const evidenceId = `rec-evidence-${rec.id}`;\n const measuredWeeks = evidenceWeeks(rec.createdAt, evidence);\n const navigate = useTimeCampusNavigate();\n\n return (\n <GlassCard treatment=\"glass\" className=\"flex flex-col gap-3 p-4 sm:p-5\">\n <div className=\"flex items-start justify-between gap-3\">\n <div className=\"flex min-w-0 items-center gap-3\">\n <span className=\"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-action-primary-bg/10 text-primary\">\n <Icon className=\"h-5 w-5\" />\n </span>\n <div className=\"min-w-0\">\n <p className=\"flex min-w-0 items-center gap-1.5 text-xs font-medium uppercase tracking-wide text-text-secondary\">\n {rec.source === \"AI\" && (\n <span className={chipClass} data-testid=\"rec-ai-chip\">\n <Sparkles className=\"h-3 w-3\" />\n AI\n </span>\n )}\n <span className=\"truncate\">\n {recommendationKindLabel(rec.kind)}\n </span>\n </p>\n <h3 className=\"mt-0.5 text-base font-semibold text-text-primary\">\n {rec.title}\n </h3>\n </div>\n </div>\n {rec.confidence != null && (\n <StatusBadge\n variant=\"info\"\n label={`${asPercent(rec.confidence)} confident`}\n className=\"shrink-0\"\n />\n )}\n </div>\n\n <p className=\"text-sm text-text-secondary\">{rec.rationale}</p>\n <p className=\"text-xs text-text-tertiary\" data-testid=\"rec-provenance\">\n {recommendationProvenance(rec.source, rec.aiModel)}\n </p>\n\n <div className=\"flex flex-wrap items-center gap-1.5\">\n {rec.domain && (\n <span className={chipClass}>{lifeDomainLabel(rec.domain)}</span>\n )}\n {rec.valueAlignment != null && (\n <span className={chipClass}>\n <ShieldCheck className=\"h-3 w-3\" />\n Aligns with your values · {asPercent(rec.valueAlignment)}\n </span>\n )}\n {rec.state === REC_STATE.Snoozed && rec.snoozeUntil && (\n <span className={chipClass}>\n <Clock className=\"h-3 w-3\" />\n Snoozed until {formatDate(rec.snoozeUntil)}\n </span>\n )}\n {actionable && rec.expiresAt && (\n <span className={chipClass}>\n <CalendarClock className=\"h-3 w-3\" />\n Expires {formatDate(rec.expiresAt)}\n </span>\n )}\n </div>\n\n {/* The concrete next step the generator attached, if any. */}\n {action && (\n <div className=\"rounded-lg border border-border-seam bg-bg-sunken/40 p-3\">\n <p className=\"text-xs font-medium uppercase tracking-wide text-text-secondary\">\n Suggested action\n </p>\n <p className=\"mt-1 text-sm font-medium text-text-primary\">\n {humaniseToken(action.type)}\n </p>\n {action.details.length > 0 && (\n <dl className=\"mt-1.5 flex flex-wrap gap-x-4 gap-y-1\">\n {action.details.map((detail) => (\n <div key={detail.key} className=\"flex items-center gap-1.5\">\n <dt className=\"text-xs text-text-secondary\">{detail.key}</dt>\n <dd className=\"text-xs font-medium tabular-nums text-text-primary\">\n {detail.value}\n </dd>\n </div>\n ))}\n </dl>\n )}\n </div>\n )}\n\n {/* Why this was raised — the exact metrics the generator measured. */}\n {evidence.length > 0 && (\n <div className=\"rounded-lg border border-border-seam bg-bg-sunken/40\">\n <button\n type=\"button\"\n onClick={() => setEvidenceOpen((open) => !open)}\n aria-expanded={evidenceOpen}\n aria-controls={evidenceId}\n className=\"flex w-full items-center justify-between gap-2 px-3 py-2 text-left\"\n >\n <span className=\"flex min-w-0 items-center gap-2\">\n <Microscope className=\"h-3.5 w-3.5 shrink-0 text-text-secondary\" />\n <span className=\"truncate text-xs text-text-secondary\">\n Evidence: {formatEvidenceRef(evidence[0])}\n {evidence.length > 1 ? ` · +${evidence.length - 1} more` : \"\"}\n </span>\n </span>\n <ChevronDown\n className={cn(\n \"h-4 w-4 shrink-0 text-text-secondary transition-transform\",\n evidenceOpen && \"rotate-180\",\n )}\n />\n </button>\n {evidenceOpen && (\n <dl\n id={evidenceId}\n className=\"space-y-1.5 border-t border-border-seam px-3 py-2.5\"\n >\n {evidence.map((ref, index) => (\n <div\n key={`${ref.metric}-${ref.period ?? ref.domain ?? index}`}\n className=\"flex items-baseline justify-between gap-3\"\n >\n <dt className=\"text-xs text-text-secondary\">\n {formatEvidenceRef(ref).split(\": \")[0]}\n </dt>\n <dd className=\"text-xs font-medium tabular-nums text-text-primary\">\n {formatEvidenceRef(ref).split(\": \").slice(1).join(\": \")}\n </dd>\n </div>\n ))}\n {measuredWeeks.length > 0 && (\n <div className=\"flex flex-wrap gap-2 pt-1\">\n {measuredWeeks.map((weekStart) => (\n <button\n key={weekStart}\n type=\"button\"\n onClick={() =>\n navigate(\n `/timeline?date=${encodeURIComponent(weekStart)}`,\n )\n }\n data-testid=\"rec-evidence-timeline-link\"\n className=\"inline-flex items-center gap-1 text-xs font-medium text-primary hover:underline focus:outline-none focus-visible:ring-2 focus-visible:ring-action-primary-bg/40\"\n >\n <ExternalLink className=\"h-3 w-3\" />\n Open the week of {formatDate(`${weekStart}T12:00:00`)} on\n your timeline\n </button>\n ))}\n </div>\n )}\n <p className=\"pt-1 text-xs text-text-tertiary\">\n Measured from your own tracked week. Nothing is applied until\n you accept.\n </p>\n </dl>\n )}\n </div>\n )}\n\n {actionable ? (\n <div className=\"flex flex-wrap items-center gap-2 pt-1\">\n <button\n type=\"button\"\n onClick={() => onAccept(rec.id)}\n disabled={busy}\n className={primaryBtn}\n >\n <Check className=\"h-4 w-4\" />\n Accept\n </button>\n <button\n type=\"button\"\n onClick={() => onSnooze(rec.id)}\n disabled={busy}\n className={neutralBtn}\n >\n <Clock className=\"h-4 w-4\" />\n Snooze\n </button>\n <button\n type=\"button\"\n onClick={() => onDismiss(rec)}\n disabled={busy}\n className={neutralBtn}\n >\n <X className=\"h-4 w-4\" />\n Dismiss\n </button>\n <button\n type=\"button\"\n onClick={() => onMuteKind(rec.kind)}\n disabled={busy || muted}\n className={neutralBtn}\n title={\n muted\n ? `${recommendationKindLabel(rec.kind)} suggestions are already muted`\n : `Stop generating ${recommendationKindLabel(rec.kind)} suggestions`\n }\n >\n <BellOff className=\"h-4 w-4\" />\n {muted ? \"Muted\" : \"Mute this kind\"}\n </button>\n </div>\n ) : (\n <div className=\"flex flex-col gap-2 pt-1\">\n <div className=\"flex items-center justify-between gap-2\">\n <StatusBadge variant={badge.variant} label={badge.label} />\n <span className=\"text-xs text-text-secondary\">\n {formatDate(rec.createdAt)}\n </span>\n </div>\n {rec.state === REC_STATE.Dismissed && rec.dismissReason && (\n <p className=\"text-xs text-text-secondary\">\n Reason given: {rec.dismissReason}\n </p>\n )}\n </div>\n )}\n </GlassCard>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Guardrails — the preferences that decide what may be suggested at all.\n// Every value here is read from `myRecommendationPreferences`; the controls\n// write back through `updateMyRecommendationPreferences`.\n// ---------------------------------------------------------------------------\ninterface GuardrailsPanelProps {\n prefs: PrefItem | undefined;\n loading: boolean;\n saving: boolean;\n onToggleOutputGuard: (next: boolean) => void;\n onQuietHoursChange: (start: number | null, end: number | null) => void;\n onUnmuteKind: (kind: string) => void;\n onAutonomousChange: (input: AutonomousInput) => void;\n}\n\n/** The autonomous-digest settings the guardrails panel can write (BOFF-3887). */\ninterface AutonomousInput {\n autonomousEnabled?: boolean;\n cadence?: string;\n digestHourUtc?: number;\n weeklyDigestDay?: number;\n}\n\nfunction GuardrailsPanel({\n prefs,\n loading,\n saving,\n onToggleOutputGuard,\n onQuietHoursChange,\n onUnmuteKind,\n onAutonomousChange,\n}: GuardrailsPanelProps) {\n if (loading) {\n return <LoadingSkeleton variant=\"card\" count={1} />;\n }\n if (!prefs) return null;\n\n const quietStart = formatHourOfDay(prefs.quietHoursStart);\n const quietEnd = formatHourOfDay(prefs.quietHoursEnd);\n const quietSet = quietStart !== null && quietEnd !== null;\n\n const hourSelectClass =\n \"rounded-md border border-border-subtle bg-bg-surface px-2 py-1 text-xs text-text-primary focus:outline-none focus:ring-2 focus:ring-action-primary-bg/40 disabled:opacity-50\";\n\n return (\n <GlassCard treatment=\"glass\" className=\"p-4 sm:p-5\">\n <div className=\"flex items-center gap-2\">\n <ShieldCheck className=\"h-4 w-4 text-text-secondary\" />\n <h3 className=\"text-sm font-semibold text-text-primary\">Guardrails</h3>\n </div>\n <p className=\"mt-1 text-xs text-text-secondary\">\n What TimeCampus is allowed to suggest, and when.\n </p>\n\n <div className=\"mt-4 space-y-4\">\n <div className=\"flex items-start justify-between gap-3\">\n <div className=\"min-w-0\">\n <p className=\"text-sm font-medium text-text-primary\">\n Never suggest more work\n </p>\n <p className=\"mt-0.5 text-xs text-text-secondary\">\n Output-increasing suggestions are filtered out before they reach\n you.\n </p>\n </div>\n <ToggleSwitch\n checked={prefs.neverOptimiseForOutput}\n disabled={saving}\n label=\"Never suggest more work\"\n onChange={onToggleOutputGuard}\n />\n </div>\n\n <div className=\"border-t border-border-seam pt-4\">\n <div className=\"flex items-center justify-between gap-3\">\n <p className=\"text-sm font-medium text-text-primary\">Quiet hours</p>\n <span className=\"text-xs text-text-secondary\">\n {quietSet ? `${quietStart}–${quietEnd}` : \"Not set\"}\n </span>\n </div>\n <p className=\"mt-0.5 text-xs text-text-secondary\">\n No nudges are sent inside this window.\n </p>\n <div className=\"mt-2 flex flex-wrap items-center gap-2\">\n <label className=\"flex items-center gap-1.5 text-xs text-text-secondary\">\n From\n <select\n className={hourSelectClass}\n disabled={saving}\n value={prefs.quietHoursStart ?? \"\"}\n onChange={(event) =>\n onQuietHoursChange(\n event.target.value === \"\"\n ? null\n : Number(event.target.value),\n prefs.quietHoursEnd ?? null,\n )\n }\n >\n <option value=\"\">—</option>\n {HOUR_OPTIONS.map((hour) => (\n <option key={hour} value={hour}>\n {formatHourOfDay(hour)}\n </option>\n ))}\n </select>\n </label>\n <label className=\"flex items-center gap-1.5 text-xs text-text-secondary\">\n To\n <select\n className={hourSelectClass}\n disabled={saving}\n value={prefs.quietHoursEnd ?? \"\"}\n onChange={(event) =>\n onQuietHoursChange(\n prefs.quietHoursStart ?? null,\n event.target.value === \"\"\n ? null\n : Number(event.target.value),\n )\n }\n >\n <option value=\"\">—</option>\n {HOUR_OPTIONS.map((hour) => (\n <option key={hour} value={hour}>\n {formatHourOfDay(hour)}\n </option>\n ))}\n </select>\n </label>\n {quietSet && (\n <button\n type=\"button\"\n disabled={saving}\n onClick={() => onQuietHoursChange(null, null)}\n className=\"text-xs font-medium text-text-secondary underline-offset-2 hover:text-text-primary hover:underline disabled:opacity-50\"\n >\n Clear\n </button>\n )}\n </div>\n </div>\n\n <div className=\"border-t border-border-seam pt-4\">\n <div className=\"flex items-center justify-between gap-3\">\n <p className=\"text-sm font-medium text-text-primary\">Muted kinds</p>\n <span className={chipClass}>{prefs.mutedKinds.length}</span>\n </div>\n {prefs.mutedKinds.length === 0 ? (\n <p className=\"mt-0.5 text-xs text-text-secondary\">\n Nothing muted — mute a kind from any suggestion to stop it coming\n back.\n </p>\n ) : (\n <div className=\"mt-2 flex flex-wrap gap-1.5\">\n {prefs.mutedKinds.map((kind) => (\n <button\n key={kind}\n type=\"button\"\n disabled={saving}\n onClick={() => onUnmuteKind(kind)}\n className={cn(\n chipClass,\n \"hover:text-text-primary disabled:opacity-50\",\n )}\n title={`Unmute ${recommendationKindLabel(kind)} suggestions`}\n >\n {recommendationKindLabel(kind)}\n <X className=\"h-3 w-3\" />\n </button>\n ))}\n </div>\n )}\n </div>\n\n <div\n className=\"border-t border-border-seam pt-4\"\n data-testid=\"autonomous-digests\"\n >\n <div className=\"flex items-start justify-between gap-3\">\n <div className=\"min-w-0\">\n <p className=\"text-sm font-medium text-text-primary\">\n Send me digests without asking\n </p>\n <p className=\"mt-0.5 text-xs text-text-secondary\">\n Off unless you turn it on. TimeCampus then sends a short summary\n of your own tracked time to your notifications, and you can turn\n it off here at any time. Quiet hours and muted kinds still\n apply.\n </p>\n </div>\n <ToggleSwitch\n checked={prefs.autonomousEnabled}\n disabled={saving}\n label=\"Send me digests without asking\"\n onChange={(next) =>\n onAutonomousChange({ autonomousEnabled: next })\n }\n />\n </div>\n {prefs.autonomousEnabled && (\n <div className=\"mt-3 flex flex-col gap-2\">\n <label className=\"flex flex-wrap items-center gap-1.5 text-xs text-text-secondary\">\n What to send\n <select\n className={hourSelectClass}\n disabled={saving}\n value={prefs.cadence}\n aria-label=\"What to send\"\n onChange={(event) =>\n onAutonomousChange({ cadence: event.target.value })\n }\n >\n {DIGEST_CADENCE_OPTIONS.map((option) => (\n <option key={option.value} value={option.value}>\n {option.label}\n </option>\n ))}\n </select>\n </label>\n <label className=\"flex flex-wrap items-center gap-1.5 text-xs text-text-secondary\">\n Not before\n <select\n className={hourSelectClass}\n disabled={saving}\n value={prefs.digestHourUtc}\n aria-label=\"Not before\"\n onChange={(event) =>\n onAutonomousChange({\n digestHourUtc: Number(event.target.value),\n })\n }\n >\n {HOUR_OPTIONS.map((hour) => (\n <option key={hour} value={hour}>\n {formatUtcHourWithLocal(hour)}\n </option>\n ))}\n </select>\n </label>\n <label className=\"flex flex-wrap items-center gap-1.5 text-xs text-text-secondary\">\n Weekly digest on\n <select\n className={hourSelectClass}\n disabled={saving}\n value={prefs.weeklyDigestDay}\n aria-label=\"Weekly digest on\"\n onChange={(event) =>\n onAutonomousChange({\n weeklyDigestDay: Number(event.target.value),\n })\n }\n >\n {DIGEST_DAY_OPTIONS.map((option) => (\n <option key={option.value} value={option.value}>\n {option.label}\n </option>\n ))}\n </select>\n </label>\n </div>\n )}\n {prefs.optedInDomains.length > 0 && (\n <>\n <p className=\"mt-3 text-sm font-medium text-text-primary\">\n Opted-in domains\n </p>\n <div className=\"mt-1.5 flex flex-wrap gap-1.5\">\n {prefs.optedInDomains.map((domain) => (\n <span key={domain} className={chipClass}>\n {lifeDomainLabel(domain)}\n </span>\n ))}\n </div>\n </>\n )}\n </div>\n </div>\n </GlassCard>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Recent digests — what the autonomous loop did for this user (BOFF-3887).\n// Read from `myTimeIntelligenceDeliveries`, which only ever returns the\n// caller's own rows.\n// ---------------------------------------------------------------------------\nconst DELIVERY_BADGE: Record<DeliveryTone, \"success\" | \"muted\" | \"warning\"> = {\n success: \"success\",\n neutral: \"muted\",\n warning: \"warning\",\n};\n\nfunction RecentDigests({\n deliveries,\n loading,\n enabled,\n}: {\n deliveries: TimeIntelligenceDeliveryFieldsFragment[];\n loading: boolean;\n enabled: boolean;\n}) {\n if (loading) return null;\n if (!enabled && deliveries.length === 0) return null;\n return (\n <GlassCard\n treatment=\"glass\"\n className=\"mt-4 p-4 sm:p-5\"\n data-testid=\"recent-digests\"\n >\n <h3 className=\"text-sm font-semibold text-text-primary\">\n Recent digests\n </h3>\n {deliveries.length === 0 ? (\n <p className=\"mt-1 text-xs text-text-secondary\">\n Nothing yet. Your first digest arrives after the time you chose.\n </p>\n ) : (\n <ul className=\"mt-3 space-y-3\">\n {deliveries.map((delivery) => {\n const view = describeDelivery(delivery);\n return (\n <li key={delivery.id} className=\"flex flex-col gap-1\">\n <div className=\"flex items-center justify-between gap-2\">\n <span className=\"text-xs font-medium text-text-primary\">\n {view.title}\n </span>\n <StatusBadge\n variant={DELIVERY_BADGE[view.tone]}\n label={\n delivery.trigger === \"SCHEDULED\" ? \"Automatic\" : \"Manual\"\n }\n />\n </div>\n <span className=\"text-xs text-text-secondary\">\n {view.status} · {formatDate(delivery.createdAt)}\n </span>\n </li>\n );\n })}\n </ul>\n )}\n </GlassCard>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Page\n// ---------------------------------------------------------------------------\nfunction segmentEmptyCopy(segment: SegmentKey): {\n title: string;\n description: string;\n} {\n switch (segment) {\n case REC_STATE.Snoozed:\n return {\n title: \"Nothing snoozed\",\n description:\n \"Suggestions you snooze for later will wait here quietly until they're worth another look.\",\n };\n case REC_STATE.Accepted:\n return {\n title: \"Nothing accepted yet\",\n description:\n \"When you accept a suggestion it moves here, so you can see the changes you chose to make.\",\n };\n case REC_STATE.Dismissed:\n return {\n title: \"Nothing dismissed\",\n description:\n \"Suggestions you dismiss are kept here — TimeCampus learns from them and won't keep nagging.\",\n };\n default:\n return {\n title: \"You're all caught up\",\n description:\n \"No new suggestions right now. Generate again after a few more days of tracked time.\",\n };\n }\n}\n\nexport function RecommendationsPage() {\n const { workspaceId } = useTimeCampus();\n const { toasts, addToast, dismissToast } = useToast();\n const [segment, setSegment] = useState<SegmentKey>(REC_STATE.New);\n const [busyId, setBusyId] = useState<string | null>(null);\n const [dismissTarget, setDismissTarget] = useState<RecItem | null>(null);\n const [dismissReason, setDismissReason] = useState(\"\");\n\n const { data, loading, error, refetch } = useMyRecommendationsQuery({\n variables: { state: null },\n skip: !workspaceId,\n });\n\n const {\n data: prefsData,\n loading: prefsLoading,\n refetch: refetchPrefs,\n } = useMyRecommendationPreferencesQuery({ skip: !workspaceId });\n\n const [generate, { loading: generating }] =\n useGenerateMyRecommendationsMutation();\n const [acceptRec] = useAcceptRecommendationMutation();\n const [dismissRec] = useDismissRecommendationMutation();\n const [snoozeRec] = useSnoozeRecommendationMutation();\n const [updatePrefs, { loading: savingPrefs }] =\n useUpdateMyRecommendationPreferencesMutation();\n const {\n data: deliveriesData,\n loading: deliveriesLoading,\n refetch: refetchDeliveries,\n } = useMyTimeIntelligenceDeliveriesQuery({\n variables: { limit: 5 },\n skip: !workspaceId,\n });\n\n const prefs = prefsData?.myRecommendationPreferences;\n const mutedKinds = useMemo<Set<string>>(\n () => new Set<string>(prefs?.mutedKinds ?? []),\n [prefs?.mutedKinds],\n );\n\n const recommendations: RecItem[] = useMemo(\n () => data?.myRecommendations ?? [],\n [data?.myRecommendations],\n );\n\n const counts = useMemo(() => {\n const map: Record<string, number> = {};\n for (const rec of recommendations) {\n map[rec.state] = (map[rec.state] ?? 0) + 1;\n }\n return map;\n }, [recommendations]);\n\n const visible = useMemo(\n () => recommendations.filter((rec) => rec.state === segment),\n [recommendations, segment],\n );\n\n const newCount = counts[REC_STATE.New] ?? 0;\n const acceptedCount = counts[REC_STATE.Accepted] ?? 0;\n const snoozedCount = counts[REC_STATE.Snoozed] ?? 0;\n\n const handleGenerate = async () => {\n try {\n const res = await generate();\n const generated = res.data?.generateMyRecommendations ?? [];\n addToast({\n title:\n generated.length > 0\n ? `${generated.length} suggestion${generated.length === 1 ? \"\" : \"s\"} ready`\n : \"No new suggestions\",\n description:\n generated.length > 0\n ? \"Fresh, values-aware ideas are in your New feed.\"\n : \"You're all caught up — nothing new to suggest right now.\",\n variant: generated.length > 0 ? \"success\" : \"info\",\n });\n setSegment(REC_STATE.New);\n await refetch();\n } catch {\n addToast({\n title: \"Couldn't generate recommendations\",\n description: \"Please try again in a moment.\",\n variant: \"error\",\n });\n }\n };\n\n const handleAccept = async (id: string) => {\n setBusyId(id);\n try {\n await acceptRec({ variables: { id } });\n addToast({ title: \"Accepted — nice\", variant: \"success\" });\n await refetch();\n } catch {\n addToast({ title: \"Couldn't accept that one\", variant: \"error\" });\n } finally {\n setBusyId(null);\n }\n };\n\n const handleSnooze = async (id: string) => {\n setBusyId(id);\n try {\n await snoozeRec({ variables: { id, until: snoozeUntilIso() } });\n addToast({\n title: \"Snoozed for a week\",\n description: \"It'll resurface later — no nagging in between.\",\n variant: \"info\",\n });\n await refetch();\n } catch {\n addToast({ title: \"Couldn't snooze that one\", variant: \"error\" });\n } finally {\n setBusyId(null);\n }\n };\n\n const requestDismiss = (rec: RecItem) => {\n setDismissReason(\"\");\n setDismissTarget(rec);\n };\n\n /**\n * Dismissing asks for an optional reason first — `dismissRecommendation`\n * takes one and the card reads it back, so the note the user leaves is the\n * note they later see.\n */\n const handleConfirmDismiss = async () => {\n const target = dismissTarget;\n if (!target) return;\n const reason = dismissReason.trim();\n setBusyId(target.id);\n try {\n await dismissRec({\n variables: { id: target.id, reason: reason.length > 0 ? reason : null },\n });\n addToast({ title: \"Dismissed\", variant: \"success\" });\n setDismissTarget(null);\n setDismissReason(\"\");\n await refetch();\n } catch {\n addToast({ title: \"Couldn't dismiss that one\", variant: \"error\" });\n } finally {\n setBusyId(null);\n }\n };\n\n /** One write path for every guardrail control, so failures read the same. */\n const savePrefs = async (\n input: {\n neverOptimiseForOutput?: boolean;\n quietHoursStart?: number | null;\n quietHoursEnd?: number | null;\n mutedKinds?: string[];\n autonomousEnabled?: boolean;\n cadence?: string;\n digestHourUtc?: number;\n weeklyDigestDay?: number;\n },\n successTitle: string,\n ) => {\n try {\n await updatePrefs({ variables: { input } });\n addToast({ title: successTitle, variant: \"success\" });\n await refetchPrefs();\n } catch {\n addToast({\n title: \"Couldn't save that guardrail\",\n description: \"Please try again in a moment.\",\n variant: \"error\",\n });\n }\n };\n\n const handleToggleOutputGuard = (next: boolean) =>\n void savePrefs(\n { neverOptimiseForOutput: next },\n next\n ? \"Output-increasing suggestions are off\"\n : \"Output-increasing suggestions allowed\",\n );\n\n const handleQuietHoursChange = (start: number | null, end: number | null) =>\n void savePrefs(\n { quietHoursStart: start, quietHoursEnd: end },\n start === null && end === null\n ? \"Quiet hours cleared\"\n : \"Quiet hours saved\",\n );\n\n const handleMuteKind = (kind: string) => {\n if (mutedKinds.has(kind)) return;\n void savePrefs(\n { mutedKinds: [...mutedKinds, kind] },\n `${recommendationKindLabel(kind)} suggestions muted`,\n );\n };\n\n const handleUnmuteKind = (kind: string) =>\n void savePrefs(\n { mutedKinds: [...mutedKinds].filter((entry) => entry !== kind) },\n `${recommendationKindLabel(kind)} suggestions unmuted`,\n );\n\n const handleAutonomousChange = (input: AutonomousInput) => {\n void (async () => {\n let title = \"Digest settings saved\";\n if (input.autonomousEnabled === true) title = \"Digests turned on\";\n if (input.autonomousEnabled === false) title = \"Digests turned off\";\n await savePrefs(input, title);\n await refetchDeliveries();\n })();\n };\n\n const guardrailsPanel = (\n <GuardrailsPanel\n prefs={prefs}\n loading={prefsLoading}\n saving={savingPrefs}\n onToggleOutputGuard={handleToggleOutputGuard}\n onQuietHoursChange={handleQuietHoursChange}\n onUnmuteKind={handleUnmuteKind}\n onAutonomousChange={handleAutonomousChange}\n />\n );\n\n const recentDigests = (\n <RecentDigests\n deliveries={deliveriesData?.myTimeIntelligenceDeliveries ?? []}\n loading={deliveriesLoading}\n enabled={prefs?.autonomousEnabled ?? false}\n />\n );\n\n const generateButton = (\n <button\n type=\"button\"\n onClick={handleGenerate}\n disabled={generating || !workspaceId}\n className={primaryBtn}\n >\n <Sparkles className=\"h-4 w-4\" />\n {generating ? \"Generating…\" : \"Generate recommendations\"}\n </button>\n );\n\n const purpose =\n \"Gentle, values-aware nudges built from your real timeline — protect a focus block, \" +\n \"reclaim a commute, guard family time. Accept the ones that fit, snooze the rest, and \" +\n \"dismiss what doesn't. TimeCampus never optimises for more output — only for time that \" +\n \"matches what you value.\";\n\n const footerNote = (\n <GlassCard treatment=\"insight\" className=\"mt-6 p-4 sm:p-5\">\n <div className=\"flex items-start gap-3\">\n <span className=\"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-status-info-bg text-status-info-text\">\n <ShieldCheck className=\"h-5 w-5\" />\n </span>\n <div className=\"min-w-0\">\n <h3 className=\"text-sm font-semibold text-text-primary\">\n Never optimises for more output.\n </h3>\n <p className=\"mt-1 text-sm text-text-secondary\">\n Every suggestion protects something you value — rest, focus,\n relationships — not your throughput. Snooze or dismiss freely;\n TimeCampus takes the hint and won't keep nagging.\n </p>\n </div>\n </div>\n </GlassCard>\n );\n\n if (!workspaceId || loading) {\n return (\n <PageLayout\n title=\"Recommendations\"\n description=\"Values-aware suggestions from your real timeline\"\n purpose={purpose}\n actions={generateButton}\n >\n <LoadingSkeleton variant=\"list\" count={4} />\n </PageLayout>\n );\n }\n\n if (error) {\n return (\n <PageLayout\n title=\"Recommendations\"\n description=\"Values-aware suggestions from your real timeline\"\n purpose={purpose}\n actions={generateButton}\n >\n <div className=\"rounded-xl border border-status-error-border/50 bg-status-error-bg/10 p-4 text-sm text-status-error-text\">\n Couldn&apos;t load your recommendations right now. Please try again in\n a moment.\n </div>\n </PageLayout>\n );\n }\n\n const hasAny = recommendations.length > 0;\n const emptyCopy = segmentEmptyCopy(segment);\n\n return (\n <PageLayout\n title=\"Recommendations\"\n description=\"Values-aware suggestions from your real timeline\"\n purpose={purpose}\n actions={generateButton}\n >\n {!hasAny ? (\n <div className=\"grid grid-cols-1 gap-6 lg:grid-cols-[minmax(0,1fr)_20rem]\">\n <div>\n <EmptyState\n illustration=\"empty-data\"\n title=\"No recommendations yet\"\n description=\"TimeCampus turns your real timeline into gentle, values-aware suggestions — like protecting a focus block or reclaiming a commute. Generate your first set to see what it notices.\"\n action={generateButton}\n />\n {footerNote}\n </div>\n <div>\n {guardrailsPanel}\n {recentDigests}\n </div>\n </div>\n ) : (\n <div className=\"grid grid-cols-1 gap-6 lg:grid-cols-[minmax(0,1fr)_20rem]\">\n <div className=\"min-w-0 space-y-6\">\n {/* Summary of where each suggestion stands — from the query only. */}\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-3\">\n <StatCard\n featured\n title=\"New for you\"\n value={String(newCount)}\n icon={<Sparkles className=\"h-5 w-5\" />}\n description=\"Awaiting your call\"\n />\n <StatCard\n title=\"Accepted\"\n value={String(acceptedCount)}\n icon={<CheckCircle2 className=\"h-5 w-5\" />}\n description=\"Changes you chose to make\"\n />\n <StatCard\n title=\"Snoozed\"\n value={String(snoozedCount)}\n icon={<Clock className=\"h-5 w-5\" />}\n description=\"Waiting for a better moment\"\n />\n </div>\n\n {/* Segmented control by state. */}\n <div className=\"overflow-x-auto\">\n <div\n className=\"inline-flex items-center rounded-lg border border-border-subtle bg-bg-sunken/50 p-0.5\"\n role=\"tablist\"\n aria-label=\"Filter recommendations by state\"\n >\n {SEGMENTS.map((seg) => {\n const active = seg.key === segment;\n const count = counts[seg.key] ?? 0;\n return (\n <button\n key={seg.key}\n type=\"button\"\n role=\"tab\"\n aria-selected={active}\n onClick={() => setSegment(seg.key)}\n className={\n active\n ? \"flex items-center gap-1.5 rounded-md bg-bg-surface px-3 py-1.5 text-sm font-medium text-text-primary shadow-sm\"\n : \"flex items-center gap-1.5 rounded-md px-3 py-1.5 text-sm font-medium text-text-secondary transition-colors hover:text-text-primary\"\n }\n >\n {seg.label}\n <span\n className={\n active\n ? \"rounded-full bg-action-primary-bg/15 px-1.5 text-xs font-semibold text-primary\"\n : \"rounded-full bg-bg-sunken px-1.5 text-xs font-semibold text-text-secondary\"\n }\n >\n {count}\n </span>\n </button>\n );\n })}\n </div>\n </div>\n\n {/* The feed for the active segment. */}\n {visible.length === 0 ? (\n <EmptyState\n illustration=\"empty-data\"\n title={emptyCopy.title}\n description={emptyCopy.description}\n action={segment === REC_STATE.New ? generateButton : undefined}\n />\n ) : (\n <div className=\"space-y-4\">\n {visible.map((rec) => (\n <RecommendationCard\n key={rec.id}\n rec={rec}\n busy={busyId === rec.id || savingPrefs}\n muted={mutedKinds.has(rec.kind)}\n onAccept={handleAccept}\n onSnooze={handleSnooze}\n onDismiss={requestDismiss}\n onMuteKind={handleMuteKind}\n />\n ))}\n </div>\n )}\n\n {footerNote}\n </div>\n <div>\n {guardrailsPanel}\n {recentDigests}\n </div>\n </div>\n )}\n\n {/* Dismissing captures the optional reason the mutation accepts, so the\n note is there when the card is read back under Dismissed. */}\n <Modal\n open={dismissTarget !== null}\n onClose={() => setDismissTarget(null)}\n title=\"Dismiss this suggestion\"\n description={dismissTarget?.title}\n size=\"sm\"\n footer={\n <>\n <button\n type=\"button\"\n onClick={() => setDismissTarget(null)}\n className={neutralBtn}\n >\n Cancel\n </button>\n <button\n type=\"button\"\n onClick={() => void handleConfirmDismiss()}\n disabled={busyId !== null}\n className={primaryBtn}\n >\n <X className=\"h-4 w-4\" />\n Dismiss\n </button>\n </>\n }\n >\n <label\n htmlFor=\"rec-dismiss-reason\"\n className=\"block text-sm font-medium text-text-primary\"\n >\n Why isn&apos;t this one for you?{\" \"}\n <span className=\"font-normal text-text-secondary\">(optional)</span>\n </label>\n <textarea\n id=\"rec-dismiss-reason\"\n rows={3}\n value={dismissReason}\n onChange={(event) => setDismissReason(event.target.value)}\n placeholder=\"e.g. already handled, not the right week\"\n className=\"mt-1.5 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary placeholder:text-text-secondary\"\n />\n <p className=\"mt-2 text-xs text-text-secondary\">\n Saved with the suggestion so you can see why you passed on it later.\n To stop this kind of suggestion entirely, use Mute this kind.\n </p>\n </Modal>\n\n <ToastContainer toasts={toasts} onDismiss={dismissToast} />\n </PageLayout>\n );\n}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2
+ * Autonomous digest helpers (BOFF-3887).
3
+ * =========================================================================
4
+ *
5
+ * The service's autonomous loop sends an opted-in user a day summary and a
6
+ * weekly digest. Its settings are UTC hours and ISO weekdays; these helpers
7
+ * turn them into labels and turn the delivery history into plain language,
8
+ * without inventing anything the service did not send.
9
+ *
10
+ * @module timecampus
11
+ */
12
+ export declare const DIGEST_CADENCE_OPTIONS: readonly [{
13
+ readonly value: "DAILY";
14
+ readonly label: "Day summary and weekly digest";
15
+ }, {
16
+ readonly value: "WEEKLY";
17
+ readonly label: "Weekly digest only";
18
+ }];
19
+ /** ISO weekdays, 1 = Monday .. 7 = Sunday, as the service stores them. */
20
+ export declare const DIGEST_DAY_OPTIONS: readonly [{
21
+ readonly value: 1;
22
+ readonly label: "Monday";
23
+ }, {
24
+ readonly value: 2;
25
+ readonly label: "Tuesday";
26
+ }, {
27
+ readonly value: 3;
28
+ readonly label: "Wednesday";
29
+ }, {
30
+ readonly value: 4;
31
+ readonly label: "Thursday";
32
+ }, {
33
+ readonly value: 5;
34
+ readonly label: "Friday";
35
+ }, {
36
+ readonly value: 6;
37
+ readonly label: "Saturday";
38
+ }, {
39
+ readonly value: 7;
40
+ readonly label: "Sunday";
41
+ }];
42
+ export declare function digestDayLabel(day: number | null | undefined): string;
43
+ /**
44
+ * "17:00 UTC (10:30 PM your time)" — the stored hour is UTC; the local time
45
+ * is shown alongside so nobody has to convert in their head.
46
+ */
47
+ export declare function formatUtcHourWithLocal(hour: number, timeZone?: string, reference?: Date): string;
48
+ export interface DeliveryLike {
49
+ period: string;
50
+ periodKey: string;
51
+ status: string;
52
+ trigger: string;
53
+ }
54
+ export type DeliveryTone = "success" | "neutral" | "warning";
55
+ /** What a delivery row means for the user, in their words. */
56
+ export declare function describeDelivery(delivery: DeliveryLike): {
57
+ title: string;
58
+ status: string;
59
+ tone: DeliveryTone;
60
+ };
61
+ //# sourceMappingURL=timeIntelligence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timeIntelligence.d.ts","sourceRoot":"","sources":["../../../../src/timecampus/pages/lifetime/timeIntelligence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,eAAO,MAAM,sBAAsB;;;;;;EAGzB,CAAC;AAEX,0EAA0E;AAC1E,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;EAQrB,CAAC;AAEX,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAIrE;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,MAAM,EACZ,QAAQ,CAAC,EAAE,MAAM,EACjB,SAAS,GAAE,IAAiB,GAC3B,MAAM,CAqBR;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;AAE7D,8DAA8D;AAC9D,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,YAAY,GAAG;IACxD,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,YAAY,CAAC;CACpB,CA0BA"}
@@ -0,0 +1,78 @@
1
+ //#region src/timecampus/pages/lifetime/timeIntelligence.ts
2
+ var e = [{
3
+ value: "DAILY",
4
+ label: "Day summary and weekly digest"
5
+ }, {
6
+ value: "WEEKLY",
7
+ label: "Weekly digest only"
8
+ }], t = [
9
+ {
10
+ value: 1,
11
+ label: "Monday"
12
+ },
13
+ {
14
+ value: 2,
15
+ label: "Tuesday"
16
+ },
17
+ {
18
+ value: 3,
19
+ label: "Wednesday"
20
+ },
21
+ {
22
+ value: 4,
23
+ label: "Thursday"
24
+ },
25
+ {
26
+ value: 5,
27
+ label: "Friday"
28
+ },
29
+ {
30
+ value: 6,
31
+ label: "Saturday"
32
+ },
33
+ {
34
+ value: 7,
35
+ label: "Sunday"
36
+ }
37
+ ];
38
+ function n(e, t, n = /* @__PURE__ */ new Date()) {
39
+ let r = (Math.trunc(e) % 24 + 24) % 24, i = `${String(r).padStart(2, "0")}:00 UTC`, a = new Date(Date.UTC(n.getUTCFullYear(), n.getUTCMonth(), n.getUTCDate(), r));
40
+ try {
41
+ return `${i} (${new Intl.DateTimeFormat(void 0, {
42
+ hour: "numeric",
43
+ minute: "2-digit",
44
+ ...t ? { timeZone: t } : {}
45
+ }).format(a)} your time)`;
46
+ } catch {
47
+ return i;
48
+ }
49
+ }
50
+ function r(e) {
51
+ let t = e.period === "DAILY" ? `Day summary for ${e.periodKey}` : `Weekly digest for ${e.periodKey}`;
52
+ switch (e.status) {
53
+ case "SENT": return {
54
+ title: t,
55
+ status: "Sent to your notifications",
56
+ tone: "success"
57
+ };
58
+ case "EMPTY": return {
59
+ title: t,
60
+ status: e.period === "DAILY" ? "Nothing tracked that day, so nothing was sent" : "No new suggestions that week, so nothing was sent",
61
+ tone: "neutral"
62
+ };
63
+ case "FAILED": return {
64
+ title: t,
65
+ status: "The notification could not be delivered",
66
+ tone: "warning"
67
+ };
68
+ default: return {
69
+ title: t,
70
+ status: "In progress",
71
+ tone: "neutral"
72
+ };
73
+ }
74
+ }
75
+ //#endregion
76
+ export { e as DIGEST_CADENCE_OPTIONS, t as DIGEST_DAY_OPTIONS, r as describeDelivery, n as formatUtcHourWithLocal };
77
+
78
+ //# sourceMappingURL=timeIntelligence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timeIntelligence.js","names":[],"sources":["../../../../src/timecampus/pages/lifetime/timeIntelligence.ts"],"sourcesContent":["/**\n * Autonomous digest helpers (BOFF-3887).\n * =========================================================================\n *\n * The service's autonomous loop sends an opted-in user a day summary and a\n * weekly digest. Its settings are UTC hours and ISO weekdays; these helpers\n * turn them into labels and turn the delivery history into plain language,\n * without inventing anything the service did not send.\n *\n * @module timecampus\n */\n\nexport const DIGEST_CADENCE_OPTIONS = [\n { value: \"DAILY\", label: \"Day summary and weekly digest\" },\n { value: \"WEEKLY\", label: \"Weekly digest only\" },\n] as const;\n\n/** ISO weekdays, 1 = Monday .. 7 = Sunday, as the service stores them. */\nexport const DIGEST_DAY_OPTIONS = [\n { value: 1, label: \"Monday\" },\n { value: 2, label: \"Tuesday\" },\n { value: 3, label: \"Wednesday\" },\n { value: 4, label: \"Thursday\" },\n { value: 5, label: \"Friday\" },\n { value: 6, label: \"Saturday\" },\n { value: 7, label: \"Sunday\" },\n] as const;\n\nexport function digestDayLabel(day: number | null | undefined): string {\n return (\n DIGEST_DAY_OPTIONS.find((option) => option.value === day)?.label ?? \"—\"\n );\n}\n\n/**\n * \"17:00 UTC (10:30 PM your time)\" — the stored hour is UTC; the local time\n * is shown alongside so nobody has to convert in their head.\n */\nexport function formatUtcHourWithLocal(\n hour: number,\n timeZone?: string,\n reference: Date = new Date(),\n): string {\n const normalised = ((Math.trunc(hour) % 24) + 24) % 24;\n const utc = `${String(normalised).padStart(2, \"0\")}:00 UTC`;\n const instant = new Date(\n Date.UTC(\n reference.getUTCFullYear(),\n reference.getUTCMonth(),\n reference.getUTCDate(),\n normalised,\n ),\n );\n try {\n const local = new Intl.DateTimeFormat(undefined, {\n hour: \"numeric\",\n minute: \"2-digit\",\n ...(timeZone ? { timeZone } : {}),\n }).format(instant);\n return `${utc} (${local} your time)`;\n } catch {\n return utc;\n }\n}\n\nexport interface DeliveryLike {\n period: string;\n periodKey: string;\n status: string;\n trigger: string;\n}\n\nexport type DeliveryTone = \"success\" | \"neutral\" | \"warning\";\n\n/** What a delivery row means for the user, in their words. */\nexport function describeDelivery(delivery: DeliveryLike): {\n title: string;\n status: string;\n tone: DeliveryTone;\n} {\n const title =\n delivery.period === \"DAILY\"\n ? `Day summary for ${delivery.periodKey}`\n : `Weekly digest for ${delivery.periodKey}`;\n switch (delivery.status) {\n case \"SENT\":\n return { title, status: \"Sent to your notifications\", tone: \"success\" };\n case \"EMPTY\":\n return {\n title,\n status:\n delivery.period === \"DAILY\"\n ? \"Nothing tracked that day, so nothing was sent\"\n : \"No new suggestions that week, so nothing was sent\",\n tone: \"neutral\",\n };\n case \"FAILED\":\n return {\n title,\n status: \"The notification could not be delivered\",\n tone: \"warning\",\n };\n default:\n return { title, status: \"In progress\", tone: \"neutral\" };\n }\n}\n"],"mappings":";AAYA,IAAa,IAAyB,CACpC;CAAE,OAAO;CAAS,OAAO;AAAgC,GACzD;CAAE,OAAO;CAAU,OAAO;AAAqB,CACjD,GAGa,IAAqB;CAChC;EAAE,OAAO;EAAG,OAAO;CAAS;CAC5B;EAAE,OAAO;EAAG,OAAO;CAAU;CAC7B;EAAE,OAAO;EAAG,OAAO;CAAY;CAC/B;EAAE,OAAO;EAAG,OAAO;CAAW;CAC9B;EAAE,OAAO;EAAG,OAAO;CAAS;CAC5B;EAAE,OAAO;EAAG,OAAO;CAAW;CAC9B;EAAE,OAAO;EAAG,OAAO;CAAS;AAC9B;AAYA,SAAgB,EACd,GACA,GACA,oBAAkB,IAAI,KAAK,GACnB;CACR,IAAM,KAAe,KAAK,MAAM,CAAI,IAAI,KAAM,MAAM,IAC9C,IAAM,GAAG,OAAO,CAAU,CAAC,CAAC,SAAS,GAAG,GAAG,EAAE,UAC7C,IAAU,IAAI,KAClB,KAAK,IACH,EAAU,eAAe,GACzB,EAAU,YAAY,GACtB,EAAU,WAAW,GACrB,CACF,CACF;CACA,IAAI;EAMF,OAAO,GAAG,EAAI,IALA,IAAI,KAAK,eAAe,KAAA,GAAW;GAC/C,MAAM;GACN,QAAQ;GACR,GAAI,IAAW,EAAE,YAAS,IAAI,CAAC;EACjC,CAAC,CAAC,CAAC,OAAO,CACQ,EAAM;CAC1B,QAAQ;EACN,OAAO;CACT;AACF;AAYA,SAAgB,EAAiB,GAI/B;CACA,IAAM,IACJ,EAAS,WAAW,UAChB,mBAAmB,EAAS,cAC5B,qBAAqB,EAAS;CACpC,QAAQ,EAAS,QAAjB;EACE,KAAK,QACH,OAAO;GAAE;GAAO,QAAQ;GAA8B,MAAM;EAAU;EACxE,KAAK,SACH,OAAO;GACL;GACA,QACE,EAAS,WAAW,UAChB,kDACA;GACN,MAAM;EACR;EACF,KAAK,UACH,OAAO;GACL;GACA,QAAQ;GACR,MAAM;EACR;EACF,SACE,OAAO;GAAE;GAAO,QAAQ;GAAe,MAAM;EAAU;CAC3D;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"WorkPatternsPage.d.ts","sourceRoot":"","sources":["../../../../src/timecampus/pages/work-patterns/WorkPatternsPage.tsx"],"names":[],"mappings":"AA2FA,wBAAgB,gBAAgB,gCA6O/B"}
1
+ {"version":3,"file":"WorkPatternsPage.d.ts","sourceRoot":"","sources":["../../../../src/timecampus/pages/work-patterns/WorkPatternsPage.tsx"],"names":[],"mappings":"AA2FA,wBAAgB,gBAAgB,gCA0O/B"}
@@ -117,11 +117,7 @@ function j() {
117
117
  featured: !0,
118
118
  title: "Productivity Score",
119
119
  value: W,
120
- icon: /* @__PURE__ */ y(_, { className: "h-5 w-5" }),
121
- trend: z?.averageProductivity == null ? void 0 : {
122
- value: 5,
123
- label: "vs last week"
124
- }
120
+ icon: /* @__PURE__ */ y(_, { className: "h-5 w-5" })
125
121
  }),
126
122
  /* @__PURE__ */ y(t, {
127
123
  title: "Focus Hours",
@@ -1 +1 @@
1
- {"version":3,"file":"WorkPatternsPage.js","names":[],"sources":["../../../../src/timecampus/pages/work-patterns/WorkPatternsPage.tsx"],"sourcesContent":["import {\n TrendingUp,\n Clock,\n Zap,\n Brain,\n Lightbulb,\n ArrowRight,\n} from \"lucide-react\";\nimport { GlassCard } from \"@burdenoff/fe-libs/ui\";\nimport {\n PageLayout,\n StatCard,\n ChartCard,\n Heatmap,\n TrendChart,\n StatusBadge,\n EmptyState,\n LoadingSkeleton,\n type HeatmapValue,\n} from \"../../components\";\nimport { useTimeCampus } from \"../../providers/TimeCampusProvider\";\nimport { SustainedLoadCard } from \"./SustainedLoadCard\";\nimport {\n useListWorkPatternsQuery,\n useGetWorkPatternSummaryQuery,\n} from \"@/generated/wspace-operations\";\nimport {\n WorkPatternInsightType,\n type WorkPatternInsight,\n} from \"@/generated/wspace-types\";\n\nconst DAY_LABELS = [\"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\", \"Sun\"] as const;\n\n/** JS `getDay()` is 0=Sun..6=Sat; remap so Monday is index 0. */\nfunction dayOfWeekIndex(d: Date): number {\n return (d.getDay() + 6) % 7;\n}\n\n/** Monday (local midnight) of the week containing `d`. */\nfunction weekStart(d: Date): Date {\n const s = new Date(d);\n s.setDate(d.getDate() - dayOfWeekIndex(d));\n s.setHours(0, 0, 0, 0);\n return s;\n}\n\nfunction shortDate(iso: string): string {\n const d = new Date(iso);\n if (Number.isNaN(d.getTime())) return \"\";\n return d.toLocaleDateString(undefined, { month: \"short\", day: \"numeric\" });\n}\n\n// Self-reported ordinals mapped onto a shared 1 (worst) – 5 (best) scale so\n// energy and mood can be trended together. Only real, fetched enum values map;\n// anything else stays null (a gap in the line, never a fabricated point).\nconst ENERGY_SCORE: Record<string, number> = {\n VERY_LOW: 1,\n LOW: 2,\n MEDIUM: 3,\n HIGH: 4,\n VERY_HIGH: 5,\n};\nconst MOOD_SCORE: Record<string, number> = {\n VERY_NEGATIVE: 1,\n NEGATIVE: 2,\n NEUTRAL: 3,\n POSITIVE: 4,\n VERY_POSITIVE: 5,\n};\n\nconst formatHoursValue = (v: number) => `${v.toFixed(1)}h`;\n\nconst INSIGHT_VARIANT: Record<\n WorkPatternInsightType,\n \"success\" | \"error\" | \"warning\" | \"info\" | \"muted\"\n> = {\n [WorkPatternInsightType.Positive]: \"success\",\n [WorkPatternInsightType.Negative]: \"error\",\n [WorkPatternInsightType.Warning]: \"warning\",\n [WorkPatternInsightType.Recommendation]: \"info\",\n [WorkPatternInsightType.Neutral]: \"muted\",\n};\n\nconst INSIGHT_LABEL: Record<WorkPatternInsightType, string> = {\n [WorkPatternInsightType.Positive]: \"Positive\",\n [WorkPatternInsightType.Negative]: \"Negative\",\n [WorkPatternInsightType.Warning]: \"Warning\",\n [WorkPatternInsightType.Recommendation]: \"Tip\",\n [WorkPatternInsightType.Neutral]: \"Neutral\",\n};\n\nexport function WorkPatternsPage() {\n const { workspaceId = \"\" } = useTimeCampus();\n const {\n data: patternsData,\n loading: patternsLoading,\n error: patternsError,\n } = useListWorkPatternsQuery({\n variables: { pagination: { limit: 30 } },\n skip: !workspaceId,\n });\n\n const {\n data: summaryData,\n loading: summaryLoading,\n error: summaryError,\n } = useGetWorkPatternSummaryQuery({\n skip: !workspaceId,\n });\n\n const loading = patternsLoading || summaryLoading;\n const error = patternsError || summaryError;\n const summary = summaryData?.workPatternSummary;\n const patterns = patternsData?.workPatterns ?? [];\n const insights = summary?.insights ?? [];\n\n // Chronological order for time-based visuals; the list itself is newest-first.\n const chronological = [...patterns].sort((a, b) => {\n const ta = new Date(a.date).getTime();\n const tb = new Date(b.date).getTime();\n return (Number.isNaN(ta) ? 0 : ta) - (Number.isNaN(tb) ? 0 : tb);\n });\n\n // Derive stats from the latest pattern entry\n const latestPattern = patterns[0];\n const productivityScore =\n summary?.averageProductivity != null\n ? `${Math.round(summary.averageProductivity)}%`\n : \"--\";\n const focusHours =\n latestPattern?.focusHours != null\n ? `${latestPattern.focusHours.toFixed(1)}h`\n : \"--\";\n const totalHours = latestPattern\n ? (\n latestPattern.focusHours +\n latestPattern.meetingHours +\n latestPattern.breakHours\n ).toFixed(0)\n : \"8\";\n const deepWorkSessions =\n latestPattern?.deepWorkSessions != null\n ? String(latestPattern.deepWorkSessions)\n : \"--\";\n const mostProductiveDay = summary?.mostProductiveDay ?? \"--\";\n\n // ---- Heatmap: focus (productive) hours by weekday × week -----------------\n const weekKeys: number[] = [];\n for (const p of chronological) {\n const d = new Date(p.date);\n if (Number.isNaN(d.getTime())) continue;\n const key = weekStart(d).getTime();\n if (!weekKeys.includes(key)) weekKeys.push(key);\n }\n const selectedWeeks = weekKeys.slice(-6); // most recent 6 weeks\n const columnLabels = selectedWeeks.map((ts) =>\n shortDate(new Date(ts).toISOString()),\n );\n const heatmapData: HeatmapValue[][] = DAY_LABELS.map(() =>\n selectedWeeks.map<HeatmapValue>(() => null),\n );\n for (const p of chronological) {\n const d = new Date(p.date);\n if (Number.isNaN(d.getTime())) continue;\n const weekIdx = selectedWeeks.indexOf(weekStart(d).getTime());\n if (weekIdx < 0) continue;\n heatmapData[dayOfWeekIndex(d)][weekIdx] = p.focusHours;\n }\n\n // ---- Energy & mood trend --------------------------------------------------\n const trendData = chronological.map((p) => ({\n date: shortDate(p.date),\n energy:\n p.energyLevel != null ? (ENERGY_SCORE[p.energyLevel] ?? null) : null,\n mood: p.mood != null ? (MOOD_SCORE[p.mood] ?? null) : null,\n }));\n const hasEnergyMood = trendData.some(\n (d) => d.energy != null || d.mood != null,\n );\n\n if (loading) {\n return (\n <PageLayout\n title=\"Work Patterns\"\n description=\"Analyze your work habits and productivity patterns\"\n >\n <LoadingSkeleton variant=\"card\" count={4} />\n </PageLayout>\n );\n }\n\n if (error) {\n return (\n <PageLayout\n title=\"Work Patterns\"\n description=\"Analyze your work habits and productivity patterns\"\n >\n <div className=\"rounded-xl border border-status-error-border/50 bg-status-error-bg/10 p-4 text-sm text-status-error-text\">\n Failed to load work patterns. Please try again later.\n </div>\n </PageLayout>\n );\n }\n\n return (\n <PageLayout\n title=\"Work Patterns\"\n description=\"Analyze your work habits and productivity patterns\"\n purpose=\"Learn how you actually work across a typical week — when you focus best, where meetings pile up, and which day is your peak — so you can schedule deep work for the hours you're sharpest.\"\n >\n <div className=\"space-y-6\">\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4\">\n <StatCard\n featured\n title=\"Productivity Score\"\n value={productivityScore}\n icon={<TrendingUp className=\"h-5 w-5\" />}\n trend={\n summary?.averageProductivity != null\n ? { value: 5, label: \"vs last week\" }\n : undefined\n }\n />\n <StatCard\n title=\"Focus Hours\"\n value={focusHours}\n icon={<Brain className=\"h-5 w-5\" />}\n description={`Out of ${totalHours}h total`}\n />\n <StatCard\n title=\"Peak Day\"\n value={mostProductiveDay}\n icon={<Zap className=\"h-5 w-5\" />}\n description=\"Most productive day\"\n />\n <StatCard\n title=\"Deep Work\"\n value={`${deepWorkSessions} sessions`}\n icon={<Clock className=\"h-5 w-5\" />}\n description=\"90+ min uninterrupted\"\n />\n </div>\n\n {/* Sustained-load signal (BOFF-10427): level, rationale and evidence from the service */}\n <SustainedLoadCard workspaceId={workspaceId} />\n\n <div className=\"grid grid-cols-1 gap-6 lg:grid-cols-2\">\n <ChartCard\n title=\"Weekly Productive Hours\"\n description=\"Focused hours logged by weekday across recent weeks\"\n >\n <Heatmap\n data={heatmapData}\n rowLabels={[...DAY_LABELS]}\n columnLabels={columnLabels}\n rowsLabel=\"Day\"\n valueFormat={formatHoursValue}\n legendLabels={[\"Fewer\", \"More\"]}\n height={240}\n emptyLabel=\"No work-pattern days logged yet.\"\n ariaLabel=\"Focused hours by weekday and week\"\n />\n </ChartCard>\n\n <ChartCard\n title=\"Energy & Mood Trends\"\n description=\"Self-reported energy and mood, each on a 1 (low) – 5 (high) scale\"\n >\n {hasEnergyMood ? (\n <TrendChart\n data={trendData}\n xKey=\"date\"\n series={[\n { key: \"energy\", label: \"Energy\" },\n { key: \"mood\", label: \"Mood\" },\n ]}\n type=\"area\"\n height={240}\n emptyLabel=\"No energy or mood check-ins yet.\"\n ariaLabel=\"Energy and mood over time\"\n />\n ) : (\n <EmptyState\n title=\"No energy or mood data yet\"\n description=\"Log how you feel on your work-pattern entries to see the trend here.\"\n />\n )}\n </ChartCard>\n </div>\n\n {insights.length > 0 && (\n <GlassCard treatment=\"glass\" className=\"p-5 sm:p-6\">\n <h3 className=\"mb-4 flex items-center gap-2 text-sm font-semibold text-text-primary\">\n <Lightbulb className=\"h-4 w-4 text-primary\" />\n Insights\n </h3>\n <div className=\"space-y-3\">\n {insights.map((insight: WorkPatternInsight, idx: number) => (\n <div\n key={`${insight.type}-${idx}`}\n className=\"rounded-lg border border-border-subtle bg-bg-surface/40 p-4\"\n >\n <div className=\"flex flex-wrap items-center gap-2\">\n <StatusBadge\n variant={INSIGHT_VARIANT[insight.type]}\n label={INSIGHT_LABEL[insight.type]}\n />\n <p className=\"text-sm font-medium text-text-primary\">\n {insight.title}\n </p>\n </div>\n <p className=\"mt-1.5 text-sm text-text-secondary\">\n {insight.description}\n </p>\n {insight.recommendation && (\n <p className=\"mt-2 flex items-start gap-1.5 text-xs text-text-primary\">\n <ArrowRight className=\"mt-0.5 h-3.5 w-3.5 shrink-0 text-primary\" />\n <span>{insight.recommendation}</span>\n </p>\n )}\n </div>\n ))}\n </div>\n </GlassCard>\n )}\n </div>\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA+BA,IAAM,IAAa;CAAC;CAAO;CAAO;CAAO;CAAO;CAAO;CAAO;AAAK;AAGnE,SAAS,EAAe,GAAiB;CACvC,QAAQ,EAAE,OAAO,IAAI,KAAK;AAC5B;AAGA,SAAS,EAAU,GAAe;CAChC,IAAM,IAAI,IAAI,KAAK,CAAC;CAGpB,OAFA,EAAE,QAAQ,EAAE,QAAQ,IAAI,EAAe,CAAC,CAAC,GACzC,EAAE,SAAS,GAAG,GAAG,GAAG,CAAC,GACd;AACT;AAEA,SAAS,EAAU,GAAqB;CACtC,IAAM,IAAI,IAAI,KAAK,CAAG;CAEtB,OADI,OAAO,MAAM,EAAE,QAAQ,CAAC,IAAU,KAC/B,EAAE,mBAAmB,KAAA,GAAW;EAAE,OAAO;EAAS,KAAK;CAAU,CAAC;AAC3E;AAKA,IAAM,IAAuC;CAC3C,UAAU;CACV,KAAK;CACL,QAAQ;CACR,MAAM;CACN,WAAW;AACb,GACM,IAAqC;CACzC,eAAe;CACf,UAAU;CACV,SAAS;CACT,UAAU;CACV,eAAe;AACjB,GAEM,KAAoB,MAAc,GAAG,EAAE,QAAQ,CAAC,EAAE,IAElD,IAGF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;OACN,aAAY;MACb,CAAA;KAEM,CAAA,CACR;;IAEJ,EAAS,SAAS,KACjB,kBAAC,GAAD;KAAW,WAAU;KAAQ,WAAU;KAAvC,UAAA,CACE,kBAAC,MAAD;MAAI,WAAU;MAAd,UAAA,CACE,kBAAC,GAAD,EAAW,WAAU,uBAAwB,CAAA,GAAC,UAE5C;KACJ,CAAA,GAAA,kBAAC,OAAD;MAAK,WAAU;MACZ,UAAA,EAAS,KAAK,GAA6B,MAC1C,kBAAC,OAAD;OAEE,WAAU;OAFZ,UAAA;QAIE,kBAAC,OAAD;SAAK,WAAU;SAAf,UAAA,CACE,kBAAC,GAAD;UACE,SAAS,EAAgB,EAAQ;UACjC,OAAO,EAAc,EAAQ;SAC9B,CAAA,GACD,kBAAC,KAAD;UAAG,WAAU;UACV,UAAA,EAAQ;SACR,CAAA,CACA;;QACL,kBAAC,KAAD;SAAG,WAAU;SACV,UAAA,EAAQ;QACR,CAAA;QACF,EAAQ,kBACP,kBAAC,KAAD;SAAG,WAAU;SAAb,UAAA,CACE,kBAAC,GAAD,EAAY,WAAU,2CAA4C,CAAA,GAClE,kBAAC,QAAD,EAAA,UAAO,EAAQ,eAAqB,CAAA,CACnC;;OAEF;MArBE,GAAA,GAAG,EAAQ,KAAK,GAAG,GAqBrB,CACN;KACE,CAAA,CACI;;GAEV;;CACK,CAAA;AAEhB"}
1
+ {"version":3,"file":"WorkPatternsPage.js","names":[],"sources":["../../../../src/timecampus/pages/work-patterns/WorkPatternsPage.tsx"],"sourcesContent":["import {\n TrendingUp,\n Clock,\n Zap,\n Brain,\n Lightbulb,\n ArrowRight,\n} from \"lucide-react\";\nimport { GlassCard } from \"@burdenoff/fe-libs/ui\";\nimport {\n PageLayout,\n StatCard,\n ChartCard,\n Heatmap,\n TrendChart,\n StatusBadge,\n EmptyState,\n LoadingSkeleton,\n type HeatmapValue,\n} from \"../../components\";\nimport { useTimeCampus } from \"../../providers/TimeCampusProvider\";\nimport { SustainedLoadCard } from \"./SustainedLoadCard\";\nimport {\n useListWorkPatternsQuery,\n useGetWorkPatternSummaryQuery,\n} from \"@/generated/wspace-operations\";\nimport {\n WorkPatternInsightType,\n type WorkPatternInsight,\n} from \"@/generated/wspace-types\";\n\nconst DAY_LABELS = [\"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\", \"Sun\"] as const;\n\n/** JS `getDay()` is 0=Sun..6=Sat; remap so Monday is index 0. */\nfunction dayOfWeekIndex(d: Date): number {\n return (d.getDay() + 6) % 7;\n}\n\n/** Monday (local midnight) of the week containing `d`. */\nfunction weekStart(d: Date): Date {\n const s = new Date(d);\n s.setDate(d.getDate() - dayOfWeekIndex(d));\n s.setHours(0, 0, 0, 0);\n return s;\n}\n\nfunction shortDate(iso: string): string {\n const d = new Date(iso);\n if (Number.isNaN(d.getTime())) return \"\";\n return d.toLocaleDateString(undefined, { month: \"short\", day: \"numeric\" });\n}\n\n// Self-reported ordinals mapped onto a shared 1 (worst) – 5 (best) scale so\n// energy and mood can be trended together. Only real, fetched enum values map;\n// anything else stays null (a gap in the line, never a fabricated point).\nconst ENERGY_SCORE: Record<string, number> = {\n VERY_LOW: 1,\n LOW: 2,\n MEDIUM: 3,\n HIGH: 4,\n VERY_HIGH: 5,\n};\nconst MOOD_SCORE: Record<string, number> = {\n VERY_NEGATIVE: 1,\n NEGATIVE: 2,\n NEUTRAL: 3,\n POSITIVE: 4,\n VERY_POSITIVE: 5,\n};\n\nconst formatHoursValue = (v: number) => `${v.toFixed(1)}h`;\n\nconst INSIGHT_VARIANT: Record<\n WorkPatternInsightType,\n \"success\" | \"error\" | \"warning\" | \"info\" | \"muted\"\n> = {\n [WorkPatternInsightType.Positive]: \"success\",\n [WorkPatternInsightType.Negative]: \"error\",\n [WorkPatternInsightType.Warning]: \"warning\",\n [WorkPatternInsightType.Recommendation]: \"info\",\n [WorkPatternInsightType.Neutral]: \"muted\",\n};\n\nconst INSIGHT_LABEL: Record<WorkPatternInsightType, string> = {\n [WorkPatternInsightType.Positive]: \"Positive\",\n [WorkPatternInsightType.Negative]: \"Negative\",\n [WorkPatternInsightType.Warning]: \"Warning\",\n [WorkPatternInsightType.Recommendation]: \"Tip\",\n [WorkPatternInsightType.Neutral]: \"Neutral\",\n};\n\nexport function WorkPatternsPage() {\n const { workspaceId = \"\" } = useTimeCampus();\n const {\n data: patternsData,\n loading: patternsLoading,\n error: patternsError,\n } = useListWorkPatternsQuery({\n variables: { pagination: { limit: 30 } },\n skip: !workspaceId,\n });\n\n const {\n data: summaryData,\n loading: summaryLoading,\n error: summaryError,\n } = useGetWorkPatternSummaryQuery({\n skip: !workspaceId,\n });\n\n const loading = patternsLoading || summaryLoading;\n const error = patternsError || summaryError;\n const summary = summaryData?.workPatternSummary;\n const patterns = patternsData?.workPatterns ?? [];\n const insights = summary?.insights ?? [];\n\n // Chronological order for time-based visuals; the list itself is newest-first.\n const chronological = [...patterns].sort((a, b) => {\n const ta = new Date(a.date).getTime();\n const tb = new Date(b.date).getTime();\n return (Number.isNaN(ta) ? 0 : ta) - (Number.isNaN(tb) ? 0 : tb);\n });\n\n // Derive stats from the latest pattern entry\n const latestPattern = patterns[0];\n const productivityScore =\n summary?.averageProductivity != null\n ? `${Math.round(summary.averageProductivity)}%`\n : \"--\";\n const focusHours =\n latestPattern?.focusHours != null\n ? `${latestPattern.focusHours.toFixed(1)}h`\n : \"--\";\n const totalHours = latestPattern\n ? (\n latestPattern.focusHours +\n latestPattern.meetingHours +\n latestPattern.breakHours\n ).toFixed(0)\n : \"8\";\n const deepWorkSessions =\n latestPattern?.deepWorkSessions != null\n ? String(latestPattern.deepWorkSessions)\n : \"--\";\n const mostProductiveDay = summary?.mostProductiveDay ?? \"--\";\n\n // ---- Heatmap: focus (productive) hours by weekday × week -----------------\n const weekKeys: number[] = [];\n for (const p of chronological) {\n const d = new Date(p.date);\n if (Number.isNaN(d.getTime())) continue;\n const key = weekStart(d).getTime();\n if (!weekKeys.includes(key)) weekKeys.push(key);\n }\n const selectedWeeks = weekKeys.slice(-6); // most recent 6 weeks\n const columnLabels = selectedWeeks.map((ts) =>\n shortDate(new Date(ts).toISOString()),\n );\n const heatmapData: HeatmapValue[][] = DAY_LABELS.map(() =>\n selectedWeeks.map<HeatmapValue>(() => null),\n );\n for (const p of chronological) {\n const d = new Date(p.date);\n if (Number.isNaN(d.getTime())) continue;\n const weekIdx = selectedWeeks.indexOf(weekStart(d).getTime());\n if (weekIdx < 0) continue;\n heatmapData[dayOfWeekIndex(d)][weekIdx] = p.focusHours;\n }\n\n // ---- Energy & mood trend --------------------------------------------------\n const trendData = chronological.map((p) => ({\n date: shortDate(p.date),\n energy:\n p.energyLevel != null ? (ENERGY_SCORE[p.energyLevel] ?? null) : null,\n mood: p.mood != null ? (MOOD_SCORE[p.mood] ?? null) : null,\n }));\n const hasEnergyMood = trendData.some(\n (d) => d.energy != null || d.mood != null,\n );\n\n if (loading) {\n return (\n <PageLayout\n title=\"Work Patterns\"\n description=\"Analyze your work habits and productivity patterns\"\n >\n <LoadingSkeleton variant=\"card\" count={4} />\n </PageLayout>\n );\n }\n\n if (error) {\n return (\n <PageLayout\n title=\"Work Patterns\"\n description=\"Analyze your work habits and productivity patterns\"\n >\n <div className=\"rounded-xl border border-status-error-border/50 bg-status-error-bg/10 p-4 text-sm text-status-error-text\">\n Failed to load work patterns. Please try again later.\n </div>\n </PageLayout>\n );\n }\n\n return (\n <PageLayout\n title=\"Work Patterns\"\n description=\"Analyze your work habits and productivity patterns\"\n purpose=\"Learn how you actually work across a typical week — when you focus best, where meetings pile up, and which day is your peak — so you can schedule deep work for the hours you're sharpest.\"\n >\n <div className=\"space-y-6\">\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4\">\n {/* No week-over-week trend: workPatternSummary returns a single\n period, so any delta shown here would be invented. */}\n <StatCard\n featured\n title=\"Productivity Score\"\n value={productivityScore}\n icon={<TrendingUp className=\"h-5 w-5\" />}\n />\n <StatCard\n title=\"Focus Hours\"\n value={focusHours}\n icon={<Brain className=\"h-5 w-5\" />}\n description={`Out of ${totalHours}h total`}\n />\n <StatCard\n title=\"Peak Day\"\n value={mostProductiveDay}\n icon={<Zap className=\"h-5 w-5\" />}\n description=\"Most productive day\"\n />\n <StatCard\n title=\"Deep Work\"\n value={`${deepWorkSessions} sessions`}\n icon={<Clock className=\"h-5 w-5\" />}\n description=\"90+ min uninterrupted\"\n />\n </div>\n\n {/* Sustained-load signal (BOFF-10427): level, rationale and evidence from the service */}\n <SustainedLoadCard workspaceId={workspaceId} />\n\n <div className=\"grid grid-cols-1 gap-6 lg:grid-cols-2\">\n <ChartCard\n title=\"Weekly Productive Hours\"\n description=\"Focused hours logged by weekday across recent weeks\"\n >\n <Heatmap\n data={heatmapData}\n rowLabels={[...DAY_LABELS]}\n columnLabels={columnLabels}\n rowsLabel=\"Day\"\n valueFormat={formatHoursValue}\n legendLabels={[\"Fewer\", \"More\"]}\n height={240}\n emptyLabel=\"No work-pattern days logged yet.\"\n ariaLabel=\"Focused hours by weekday and week\"\n />\n </ChartCard>\n\n <ChartCard\n title=\"Energy & Mood Trends\"\n description=\"Self-reported energy and mood, each on a 1 (low) – 5 (high) scale\"\n >\n {hasEnergyMood ? (\n <TrendChart\n data={trendData}\n xKey=\"date\"\n series={[\n { key: \"energy\", label: \"Energy\" },\n { key: \"mood\", label: \"Mood\" },\n ]}\n type=\"area\"\n height={240}\n emptyLabel=\"No energy or mood check-ins yet.\"\n ariaLabel=\"Energy and mood over time\"\n />\n ) : (\n <EmptyState\n title=\"No energy or mood data yet\"\n description=\"Log how you feel on your work-pattern entries to see the trend here.\"\n />\n )}\n </ChartCard>\n </div>\n\n {insights.length > 0 && (\n <GlassCard treatment=\"glass\" className=\"p-5 sm:p-6\">\n <h3 className=\"mb-4 flex items-center gap-2 text-sm font-semibold text-text-primary\">\n <Lightbulb className=\"h-4 w-4 text-primary\" />\n Insights\n </h3>\n <div className=\"space-y-3\">\n {insights.map((insight: WorkPatternInsight, idx: number) => (\n <div\n key={`${insight.type}-${idx}`}\n className=\"rounded-lg border border-border-subtle bg-bg-surface/40 p-4\"\n >\n <div className=\"flex flex-wrap items-center gap-2\">\n <StatusBadge\n variant={INSIGHT_VARIANT[insight.type]}\n label={INSIGHT_LABEL[insight.type]}\n />\n <p className=\"text-sm font-medium text-text-primary\">\n {insight.title}\n </p>\n </div>\n <p className=\"mt-1.5 text-sm text-text-secondary\">\n {insight.description}\n </p>\n {insight.recommendation && (\n <p className=\"mt-2 flex items-start gap-1.5 text-xs text-text-primary\">\n <ArrowRight className=\"mt-0.5 h-3.5 w-3.5 shrink-0 text-primary\" />\n <span>{insight.recommendation}</span>\n </p>\n )}\n </div>\n ))}\n </div>\n </GlassCard>\n )}\n </div>\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA+BA,IAAM,IAAa;CAAC;CAAO;CAAO;CAAO;CAAO;CAAO;CAAO;AAAK;AAGnE,SAAS,EAAe,GAAiB;CACvC,QAAQ,EAAE,OAAO,IAAI,KAAK;AAC5B;AAGA,SAAS,EAAU,GAAe;CAChC,IAAM,IAAI,IAAI,KAAK,CAAC;CAGpB,OAFA,EAAE,QAAQ,EAAE,QAAQ,IAAI,EAAe,CAAC,CAAC,GACzC,EAAE,SAAS,GAAG,GAAG,GAAG,CAAC,GACd;AACT;AAEA,SAAS,EAAU,GAAqB;CACtC,IAAM,IAAI,IAAI,KAAK,CAAG;CAEtB,OADI,OAAO,MAAM,EAAE,QAAQ,CAAC,IAAU,KAC/B,EAAE,mBAAmB,KAAA,GAAW;EAAE,OAAO;EAAS,KAAK;CAAU,CAAC;AAC3E;AAKA,IAAM,IAAuC;CAC3C,UAAU;CACV,KAAK;CACL,QAAQ;CACR,MAAM;CACN,WAAW;AACb,GACM,IAAqC;CACzC,eAAe;CACf,UAAU;CACV,SAAS;CACT,UAAU;CACV,eAAe;AACjB,GAEM,KAAoB,MAAc,GAAG,EAAE,QAAQ,CAAC,EAAE,IAElD,IAGF;EACD,EAAuB,W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AU;KAAQ,WAAU;KAAvC,UAAA,CACE,kBAAC,MAAD;MAAI,WAAU;MAAd,UAAA,CACE,kBAAC,GAAD,EAAW,WAAU,uBAAwB,CAAA,GAAC,UAE5C;KACJ,CAAA,GAAA,kBAAC,OAAD;MAAK,WAAU;MACZ,UAAA,EAAS,KAAK,GAA6B,MAC1C,kBAAC,OAAD;OAEE,WAAU;OAFZ,UAAA;QAIE,kBAAC,OAAD;SAAK,WAAU;SAAf,UAAA,CACE,kBAAC,GAAD;UACE,SAAS,EAAgB,EAAQ;UACjC,OAAO,EAAc,EAAQ;SAC9B,CAAA,GACD,kBAAC,KAAD;UAAG,WAAU;UACV,UAAA,EAAQ;SACR,CAAA,CACA;;QACL,kBAAC,KAAD;SAAG,WAAU;SACV,UAAA,EAAQ;QACR,CAAA;QACF,EAAQ,kBACP,kBAAC,KAAD;SAAG,WAAU;SAAb,UAAA,CACE,kBAAC,GAAD,EAAY,WAAU,2CAA4C,CAAA,GAClE,kBAAC,QAAD,EAAA,UAAO,EAAQ,eAAqB,CAAA,CACnC;;OAEF;MArBE,GAAA,GAAG,EAAQ,KAAK,GAAG,GAqBrB,CACN;KACE,CAAA,CACI;;GAEV;;CACK,CAAA;AAEhB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burdenoff/microfe-timecampus",
3
- "version": "2026.1031.8",
3
+ "version": "2026.1031.10",
4
4
  "description": "Burdenoff TimeCampus Microfrontend - AI-powered time management and productivity platform",
5
5
  "type": "module",
6
6
  "files": [