Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

feat: life calendar view modes, birthday highlights, hide-spent toggle, nav link

Adam Eivyb210440d0226
diff --git a/client/src/components/Layout.jsx b/client/src/components/Layout.jsx
index d0af73eebf..60eea79670 100644
--- a/client/src/components/Layout.jsx
+++ b/client/src/components/Layout.jsx
@@ -167,6 +167,7 @@ const navItems = [
{ to: '/meatspace/alcohol', label: 'Alcohol', icon: Activity },
{ to: '/meatspace/blood', label: 'Blood', icon: HeartPulse },
{ to: '/meatspace/body', label: 'Body', icon: Scale },
+ { to: '/meatspace/calendar', label: 'Calendar', icon: Calendar },
{ to: '/meatspace/eyes', label: 'Eyes', icon: Eye },
{ to: '/meatspace/genome', label: 'Genome', icon: Dna },
{ to: '/meatspace/health', label: 'Health', icon: Heart },
diff --git a/client/src/components/meatspace/tabs/CalendarTab.jsx b/client/src/components/meatspace/tabs/CalendarTab.jsx
index 5edcea5afe..1f7c9ae6cc 100644
--- a/client/src/components/meatspace/tabs/CalendarTab.jsx
+++ b/client/src/components/meatspace/tabs/CalendarTab.jsx
@@ -2,7 +2,7 @@ import { useState, useEffect, useCallback, useMemo } from 'react';
import {
Calendar, Coffee, Droplets, Utensils, Dumbbell, BookOpen, Scissors,
Cake, Plane, Plus, Trash2, Circle, Sun, Moon, TreePine, Snowflake,
- Flower2, CloudSun
+ Flower2, CloudSun, Settings2
} from 'lucide-react';
import toast from 'react-hot-toast';
import * as api from '../../../services/api';
@@ -21,61 +21,239 @@ function IconForName({ name, size = 16, className }) {
return <Comp size={size} className={className} />;
}
+// === Event Colors ===
+
+const EVENT_COLORS = [
+ { id: 'birthday', label: 'Birthday', color: 'bg-pink-500', ring: 'ring-pink-500/50' },
+ { id: 'holiday', label: 'Holiday', color: 'bg-amber-500', ring: 'ring-amber-500/50' },
+ { id: 'vacation', label: 'Vacation', color: 'bg-cyan-500', ring: 'ring-cyan-500/50' },
+ { id: 'milestone', label: 'Milestone', color: 'bg-purple-500', ring: 'ring-purple-500/50' },
+ { id: 'health', label: 'Health', color: 'bg-red-500', ring: 'ring-red-500/50' },
+];
+
+/**
+ * Compute which weeks in the remaining grid correspond to birthdays.
+ * Returns a Map<string, string> where key is "age-week" and value is event id.
+ */
+function computeEventWeeks(birthDate, grid, stats) {
+ const events = new Map();
+ if (!birthDate) return events;
+
+ const birth = new Date(birthDate);
+ const birthMonth = birth.getMonth();
+ const birthDay = birth.getDate();
+ const currentAge = Math.floor(stats.age.years);
+
+ // Mark birthday weeks for remaining years
+ for (const row of grid) {
+ if (row.age <= currentAge) continue;
+ // Birthday falls in this year — find which week
+ const yearStart = new Date(birth);
+ yearStart.setFullYear(birth.getFullYear() + row.age);
+ const bday = new Date(yearStart.getFullYear(), birthMonth, birthDay);
+ const weekOfYear = Math.floor((bday - yearStart) / (7 * 86400000));
+ if (weekOfYear >= 0 && weekOfYear < 52) {
+ events.set(`${row.age}-${weekOfYear}`, 'birthday');
+ }
+ }
+
+ return events;
+}
+
+// === View Mode Config ===
+
+const VIEW_MODES = [
+ { id: 'year', label: 'Year (52 weeks/row)', weeksPerRow: 52 },
+ { id: 'half', label: 'Half Year (26 weeks/row)', weeksPerRow: 26 },
+ { id: 'quarter', label: 'Quarter (13 weeks/row)', weeksPerRow: 13 },
+ { id: 'auto', label: 'Auto-fit', weeksPerRow: null },
+];
+
+const CELL_SIZES = [
+ { id: 'xs', label: 'XS', size: 5, gap: 1 },
+ { id: 'sm', label: 'S', size: 7, gap: 1 },
+ { id: 'md', label: 'M', size: 9, gap: 1 },
+ { id: 'lg', label: 'L', size: 12, gap: 2 },
+];
+
// === Life Grid ===
-function LifeGrid({ grid, stats }) {
+function LifeGrid({ grid, stats, birthDate }) {
+ const [viewMode, setViewMode] = useState('auto');
+ const [cellSizeId, setCellSizeId] = useState('sm');
+ const [showEvents, setShowEvents] = useState(true);
+ const [hideSpent, setHideSpent] = useState(false);
+ const [showConfig, setShowConfig] = useState(false);
+
const currentAge = Math.floor(stats.age.years);
+ const cellCfg = CELL_SIZES.find(c => c.id === cellSizeId) || CELL_SIZES[1];
+ const viewCfg = VIEW_MODES.find(v => v.id === viewMode) || VIEW_MODES[0];
+
+ // Flatten all weeks into a single array with metadata
+ const allWeeks = useMemo(() => {
+ const weeks = [];
+ for (const row of grid) {
+ for (let w = 0; w < row.weeks.length; w++) {
+ weeks.push({ age: row.age, week: w, status: row.weeks[w] });
+ }
+ }
+ return weeks;
+ }, [grid]);
- // Decade labels
- const decades = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100];
+ // Compute event markers
+ const eventWeeks = useMemo(
+ () => showEvents ? computeEventWeeks(birthDate, grid, stats) : new Map(),
+ [birthDate, grid, stats, showEvents]
+ );
+
+ // Determine weeks per row
+ const weeksPerRow = viewCfg.weeksPerRow || 104; // auto = ~2 years per row for wide screens
+
+ // Filter grid when hiding spent
+ const filteredGrid = useMemo(() => {
+ if (!hideSpent) return grid;
+ return grid.filter(row => row.weeks.some(s => s === 'c' || s === 'r'));
+ }, [grid, hideSpent]);
+
+ // Group weeks into rows
+ const rows = useMemo(() => {
+ if (viewMode !== 'auto' && viewCfg.weeksPerRow) {
+ // Year-aligned: use grid rows directly, but split/merge as needed
+ if (viewCfg.weeksPerRow === 52) {
+ return filteredGrid.map(row => ({ label: row.age, weeks: row.weeks.map((s, w) => ({ age: row.age, week: w, status: s })) }));
+ }
+ // Sub-year: split each year row
+ const result = [];
+ for (const row of filteredGrid) {
+ for (let start = 0; start < row.weeks.length; start += viewCfg.weeksPerRow) {
+ const slice = row.weeks.slice(start, start + viewCfg.weeksPerRow);
+ const label = start === 0 ? row.age : null;
+ result.push({ label, weeks: slice.map((s, i) => ({ age: row.age, week: start + i, status: s })) });
+ }
+ }
+ return result;
+ }
+ // Auto-fit: pack all weeks into rows of weeksPerRow
+ const result = [];
+ for (let i = 0; i < allWeeks.length; i += weeksPerRow) {
+ const slice = allWeeks.slice(i, i + weeksPerRow);
+ const firstAge = slice[0]?.age;
+ const label = i === 0 || firstAge !== allWeeks[Math.max(0, i - 1)]?.age ? firstAge : null;
+ result.push({ label: firstAge, weeks: slice });
+ }
+ return result;
+ }, [filteredGrid, allWeeks, viewMode, viewCfg, weeksPerRow, hideSpent]);
+
+ // Decade/5-year labels
+ const shouldLabel = (age) => age != null && age % 10 === 0;
return (
<div className="bg-port-card border border-port-border rounded-lg p-4">
- <div className="flex items-center gap-2 mb-3">
+ <div className="flex items-center gap-2 mb-3 flex-wrap">
<Calendar size={16} className="text-port-accent" />
<h3 className="text-sm font-medium text-white">Life in Weeks</h3>
<span className="text-xs text-gray-500 ml-auto">
Week {stats.age.weeks.toLocaleString()} of {stats.total.weeks.toLocaleString()}
</span>
+ <button
+ onClick={() => setShowConfig(v => !v)}
+ className={`p-1 rounded transition-colors ${showConfig ? 'text-port-accent bg-port-accent/10' : 'text-gray-500 hover:text-white'}`}
+ title="Grid settings"
+ >
+ <Settings2 size={14} />
+ </button>
</div>
+ {/* Config panel */}
+ {showConfig && (
+ <div className="flex flex-wrap items-center gap-4 mb-3 p-2 bg-port-bg rounded-lg border border-port-border">
+ <div className="flex items-center gap-2">
+ <span className="text-xs text-gray-500">Layout:</span>
+ {VIEW_MODES.map(v => (
+ <button
+ key={v.id}
+ onClick={() => setViewMode(v.id)}
+ className={`px-2 py-0.5 text-xs rounded ${viewMode === v.id ? 'bg-port-accent/20 text-port-accent' : 'text-gray-400 hover:text-white'}`}
+ >
+ {v.id === 'auto' ? 'Auto' : v.id === 'year' ? '1Y' : v.id === 'half' ? '6M' : '3M'}
+ </button>
+ ))}
+ </div>
+ <div className="flex items-center gap-2">
+ <span className="text-xs text-gray-500">Size:</span>
+ {CELL_SIZES.map(c => (
+ <button
+ key={c.id}
+ onClick={() => setCellSizeId(c.id)}
+ className={`px-2 py-0.5 text-xs rounded ${cellSizeId === c.id ? 'bg-port-accent/20 text-port-accent' : 'text-gray-400 hover:text-white'}`}
+ >
+ {c.label}
+ </button>
+ ))}
+ </div>
+ <label className="flex items-center gap-1.5 text-xs text-gray-400 cursor-pointer">
+ <input type="checkbox" checked={showEvents} onChange={(e) => setShowEvents(e.target.checked)} className="rounded border-port-border" />
+ Birthdays
+ </label>
+ <label className="flex items-center gap-1.5 text-xs text-gray-400 cursor-pointer">
+ <input type="checkbox" checked={hideSpent} onChange={(e) => setHideSpent(e.target.checked)} className="rounded border-port-border" />
+ Hide spent
+ </label>
+ </div>
+ )}
+
{/* Legend */}
- <div className="flex items-center gap-4 mb-3 text-xs text-gray-500">
- <span className="flex items-center gap-1">
- <span className="w-2 h-2 rounded-sm bg-gray-600" /> Spent
- </span>
- <span className="flex items-center gap-1">
- <span className="w-2 h-2 rounded-sm bg-port-accent" /> Now
- </span>
- <span className="flex items-center gap-1">
- <span className="w-2 h-2 rounded-sm bg-port-success/30" /> Remaining
- </span>
+ <div className="flex items-center gap-4 mb-3 text-xs text-gray-500 flex-wrap">
+ <span className="flex items-center gap-1"><span className="w-2 h-2 rounded-sm bg-gray-600" /> Spent</span>
+ <span className="flex items-center gap-1"><span className="w-2 h-2 rounded-sm bg-port-accent" /> Now</span>
+ <span className="flex items-center gap-1"><span className="w-2 h-2 rounded-sm bg-port-success/30" /> Remaining</span>
+ {showEvents && (
+ <>
+ {EVENT_COLORS.filter(e => e.id === 'birthday').map(e => (
+ <span key={e.id} className="flex items-center gap-1">
+ <span className={`w-2 h-2 rounded-sm ${e.color}`} /> {e.label}
+ </span>
+ ))}
+ </>
+ )}
</div>
{/* Grid */}
<div className="overflow-x-auto">
- <div className="min-w-[600px]">
- {grid.map((row) => (
- <div key={row.age} className="flex items-center gap-px mb-px">
- {/* Age label every 10 years */}
- <span className={`w-6 text-right text-[9px] mr-1 shrink-0 ${
- decades.includes(row.age) ? 'text-gray-400 font-medium' : 'text-transparent'
- }`}>
- {decades.includes(row.age) ? row.age : '.'}
+ <div style={{ display: 'flex', flexDirection: 'column', gap: `${cellCfg.gap}px` }}>
+ {rows.map((row, ri) => (
+ <div key={ri} style={{ display: 'flex', alignItems: 'center', gap: `${cellCfg.gap}px` }}>
+ {/* Age label */}
+ <span
+ className={`text-right shrink-0 ${shouldLabel(row.label) ? 'text-gray-400 font-medium' : 'text-transparent'}`}
+ style={{ width: '24px', fontSize: '9px' }}
+ >
+ {shouldLabel(row.label) ? row.label : '.'}
</span>
- {row.weeks.map((status, w) => (
- <span
- key={w}
- className={`w-[9px] h-[9px] rounded-[1px] shrink-0 ${
- status === 'c'
- ? 'bg-port-accent shadow-[0_0_4px_rgba(59,130,246,0.5)]'
- : status === 's'
- ? row.age === currentAge ? 'bg-gray-500' : 'bg-gray-700'
- : 'bg-port-success/20'
- }`}
- title={`Age ${row.age}, Week ${w + 1}`}
- />
- ))}
+ {row.weeks.map((cell, wi) => {
+ const eventId = eventWeeks.get(`${cell.age}-${cell.week}`);
+ const eventCfg = eventId ? EVENT_COLORS.find(e => e.id === eventId) : null;
+
+ let bgClass;
+ if (eventCfg && cell.status === 'r') {
+ bgClass = eventCfg.color;
+ } else if (cell.status === 'c') {
+ bgClass = 'bg-port-accent shadow-[0_0_4px_rgba(59,130,246,0.5)]';
+ } else if (cell.status === 's') {
+ bgClass = cell.age === currentAge ? 'bg-gray-500' : 'bg-gray-700';
+ } else {
+ bgClass = 'bg-port-success/20';
+ }
+
+ return (
+ <span
+ key={wi}
+ className={`shrink-0 rounded-[1px] ${bgClass} ${eventCfg ? `ring-1 ${eventCfg.ring}` : ''}`}
+ style={{ width: `${cellCfg.size}px`, height: `${cellCfg.size}px` }}
+ title={`Age ${cell.age}, Week ${cell.week + 1}${eventCfg ? ` — ${eventCfg.label}` : ''}`}
+ />
+ );
+ })}
</div>
))}
</div>
@@ -134,9 +312,7 @@ function ActivityBudgets({ budgets, onRemove }) {
<IconForName name={b.icon} size={18} className="text-port-accent shrink-0" />
<div className="flex-1 min-w-0">
<div className="text-sm font-medium text-white">{b.name}</div>
- <div className="text-xs text-gray-500">
- {b.frequency}{CADENCE_LABELS[b.cadence]}
- </div>
+ <div className="text-xs text-gray-500">{b.frequency}{CADENCE_LABELS[b.cadence]}</div>
</div>
<div className="text-right">
<div className="text-lg font-bold text-white">{b.remaining.toLocaleString()}</div>
@@ -313,9 +489,8 @@ export default function CalendarTab() {
);
}
- const { stats, grid, budgets } = data;
+ const { stats, grid, budgets, birthDate } = data;
- // Header summary
const pctSpent = stats.age.weeks / stats.total.weeks * 100;
const pctColor = pctSpent < 50 ? 'text-port-accent' : pctSpent < 75 ? 'text-port-warning' : 'text-port-error';
@@ -354,7 +529,7 @@ export default function CalendarTab() {
</div>
{/* Life Grid */}
- <LifeGrid grid={grid} stats={stats} />
+ <LifeGrid grid={grid} stats={stats} birthDate={birthDate} />
{/* Time remaining stats */}
<TimeStats stats={stats} />