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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
feat(calendar): add chronotype energy zone overlay to day and week views
Adam Eivy7a28acd6bf15
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 2c71f6eebc..1f3148ac8c 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -28,6 +28,7 @@- Autobiography prompt chains — LLM-generated follow-up questions after saving a story, enabling deeper exploration of life themes with linked story chains- RSS/Atom feed ingestion — subscribe to feeds, fetch/parse articles, read/mark-read from Brain > Feeds tab- AI-powered goal check-ins — "Run Check-In" button on goal detail panel generates LLM assessment of goal health (on-track/behind/at-risk), actionable recommendations, and motivational encouragement based on progress, velocity, milestones, and activity attendance+- Chronotype-aware scheduling — Calendar Day and Week views now show genome-derived energy zone overlays (peak focus, exercise, wind-down) and cutoff markers (caffeine, last meal) based on the user's chronotype profile## Changeddiff --git a/PLAN.md b/PLAN.mdindex 9618ca7fe9..8d232bdb90 100644--- a/PLAN.md+++ b/PLAN.md@@ -21,7 +21,7 @@ For project goals, see [GOALS.md](./GOALS.md). For completed work, see [DONE.md]## Future Ideas-- **Chronotype-Aware Scheduling** — Genome sleep markers for peak-focus task scheduling+- [x] **Chronotype-Aware Scheduling** — Genome sleep markers for peak-focus task scheduling- **Identity Context Injection** — Per-task-type digital twin preamble toggle- **Agent Confidence & Autonomy Levels** — Dynamic tiers based on success rates- **Content Calendar** — Unified calendar across platformsdiff --git a/client/src/components/calendar/ChronotypeOverlay.jsx b/client/src/components/calendar/ChronotypeOverlay.jsxnew file mode 100644index 0000000000..0bec0d8dee--- /dev/null+++ b/client/src/components/calendar/ChronotypeOverlay.jsx@@ -0,0 +1,87 @@+import { useState, useEffect } from 'react';+import * as api from '../../services/api';++/**+ * ChronotypeOverlay renders colored energy zone bands and marker lines+ * behind the Calendar DayView time grid. It fetches the user's+ * genome-derived chronotype schedule and renders:+ * - Colored bands for zones (peak focus, exercise, wind-down)+ * - Dashed marker lines for cutoffs (caffeine, last meal)+ * - Hover labels for each zone/marker+ */+export default function ChronotypeOverlay({ startHour, pxPerHour }) {+ const [schedule, setSchedule] = useState(null);+ const [hoveredZone, setHoveredZone] = useState(null);++ useEffect(() => {+ api.getChronotypeEnergySchedule().then(setSchedule).catch(() => null);+ }, []);++ if (!schedule?.zones?.length) return null;++ const startMinutes = startHour * 60;++ const minToTop = (min) => ((min - startMinutes) / 60) * pxPerHour;++ return (+ <>+ {schedule.zones.map(zone => {+ if (zone.marker) {+ // Render a dashed horizontal marker line+ const top = minToTop(zone.startMin);+ if (top < 0) return null;+ return (+ <div+ key={zone.id}+ className="absolute left-0 right-0 flex items-center pointer-events-auto z-0"+ style={{ top }}+ onMouseEnter={() => setHoveredZone(zone.id)}+ onMouseLeave={() => setHoveredZone(null)}+ >+ <div+ className="flex-1 border-t border-dashed"+ style={{ borderColor: zone.color }}+ />+ {hoveredZone === zone.id && (+ <span+ className="absolute right-1 -top-4 text-[10px] font-medium px-1.5 py-0.5 rounded"+ style={{ color: zone.color, backgroundColor: `${zone.color}20` }}+ >+ {zone.label}+ </span>+ )}+ </div>+ );+ }++ // Render a zone band+ const top = minToTop(zone.startMin);+ const height = ((zone.endMin - zone.startMin) / 60) * pxPerHour;+ if (height <= 0) return null;+ return (+ <div+ key={zone.id}+ className="absolute left-0 right-0 pointer-events-auto z-0"+ style={{+ top: Math.max(top, 0),+ height,+ backgroundColor: zone.color,+ opacity: zone.opacity+ }}+ onMouseEnter={() => setHoveredZone(zone.id)}+ onMouseLeave={() => setHoveredZone(null)}+ >+ {hoveredZone === zone.id && (+ <span+ className="absolute right-1 top-0.5 text-[10px] font-medium px-1.5 py-0.5 rounded"+ style={{ color: zone.color, backgroundColor: `${zone.color}30`, opacity: 1 }}+ >+ {zone.label}+ </span>+ )}+ </div>+ );+ })}+ </>+ );+}diff --git a/client/src/components/calendar/DayView.jsx b/client/src/components/calendar/DayView.jsxindex 31e0d394bf..d5f221589b 100644--- a/client/src/components/calendar/DayView.jsx+++ b/client/src/components/calendar/DayView.jsx@@ -3,6 +3,7 @@ import { ChevronLeft, ChevronRight, RefreshCw, MapPin } from 'lucide-react';import * as api from '../../services/api';import socket from '../../services/socket';import EventDetail from './EventDetail';+import ChronotypeOverlay from './ChronotypeOverlay';import { buildSubcalendarColorMap } from './calendarUtils';import { formatDateFull } from '../../utils/formatters';@@ -220,6 +221,9 @@ export default function DayView({ accounts }) {{/* Events overlay */}<div className="absolute top-0 left-16 right-0 bottom-0">+ {/* Chronotype energy zones (behind events) */}+ <ChronotypeOverlay startHour={START_HOUR} pxPerHour={PX_PER_HOUR} />+{timedEvents.map(event => {const { top, height } = getEventPosition(event);const key = eventKey(event);diff --git a/client/src/components/calendar/WeekView.jsx b/client/src/components/calendar/WeekView.jsxindex cfb067b8ef..fc2ea2f040 100644--- a/client/src/components/calendar/WeekView.jsx+++ b/client/src/components/calendar/WeekView.jsx@@ -3,6 +3,7 @@ import { ChevronLeft, ChevronRight, RefreshCw } from 'lucide-react';import * as api from '../../services/api';import socket from '../../services/socket';import EventDetail from './EventDetail';+import ChronotypeOverlay from './ChronotypeOverlay';import { buildSubcalendarColorMap } from './calendarUtils';const START_HOUR = 6;@@ -264,6 +265,11 @@ export default function WeekView({ accounts }) {</div>))}+ {/* Chronotype energy zones (behind events) */}+ <div className="absolute top-0 bottom-0 left-14 right-0 pointer-events-none">+ <ChronotypeOverlay startHour={START_HOUR} pxPerHour={PX_PER_HOUR} />+ </div>+{/* Events overlay per column */}<div className="absolute top-0 bottom-0 left-14 right-0 flex">{eventsByDay.map((dayEvents, dayIndex) => {diff --git a/client/src/services/api.js b/client/src/services/api.jsindex 0a220c7209..27f5157abc 100644--- a/client/src/services/api.js+++ b/client/src/services/api.js@@ -1411,6 +1411,7 @@ export const deleteEpigeneticIntervention = (id) => request(`/meatspace/genome/eexport const getIdentityStatus = () => request('/digital-twin/identity');export const getCrossInsights = () => request('/digital-twin/identity/cross-insights');export const getChronotype = () => request('/digital-twin/identity/chronotype');+export const getChronotypeEnergySchedule = () => request('/digital-twin/identity/chronotype/energy-schedule');export const deriveChronotype = () => request('/digital-twin/identity/chronotype/derive', { method: 'POST' });export const updateChronotypeBehavioral = (data) => request('/digital-twin/identity/chronotype', {method: 'PUT',diff --git a/server/routes/identity.js b/server/routes/identity.jsindex 1018a2607b..b3b8286313 100644--- a/server/routes/identity.js+++ b/server/routes/identity.js@@ -57,6 +57,12 @@ router.put('/chronotype', asyncHandler(async (req, res) => {res.json(chronotype);}));+// GET /api/digital-twin/identity/chronotype/energy-schedule — Energy zones for day view+router.get('/chronotype/energy-schedule', asyncHandler(async (req, res) => {+ const schedule = await identityService.getEnergySchedule();+ res.json(schedule);+}));+// =============================================================================// CROSS-INSIGHTS// =============================================================================diff --git a/server/services/identity.js b/server/services/identity.jsindex 3f43a195be..6b91d51108 100644--- a/server/services/identity.js+++ b/server/services/identity.js@@ -648,6 +648,82 @@ export async function updateChronotypeBehavioral(overrides) {return deriveChronotype();}+/**+ * Get structured energy zones for the day based on chronotype.+ * Returns time blocks with zone type, start/end times, and display metadata.+ */+export async function getEnergySchedule() {+ const chronotype = await getChronotype();+ if (!chronotype?.recommendations) return { zones: [], type: null, confidence: 0 };++ const rec = chronotype.recommendations;++ const parseTime = (str) => {+ const [h, m] = (str || '').split(':').map(Number);+ return h * 60 + (m || 0);+ };++ const zones = [];++ // Wake-up zone+ if (rec.wakeTime) {+ const wake = parseTime(rec.wakeTime);+ zones.push({ id: 'wake', label: 'Wake Up', startMin: wake, endMin: wake + 30, color: '#f59e0b', opacity: 0.12 });+ }++ // Exercise window (e.g., "06:30-08:00")+ if (rec.exerciseWindow) {+ const [exStart, exEnd] = rec.exerciseWindow.split('-').map(parseTime);+ if (!isNaN(exStart) && !isNaN(exEnd)) {+ zones.push({ id: 'exercise', label: 'Exercise', startMin: exStart, endMin: exEnd, color: '#22c55e', opacity: 0.10 });+ }+ }++ // Peak focus+ if (rec.peakFocusStart && rec.peakFocusEnd) {+ zones.push({+ id: 'peak-focus',+ label: 'Peak Focus',+ startMin: parseTime(rec.peakFocusStart),+ endMin: parseTime(rec.peakFocusEnd),+ color: '#3b82f6',+ opacity: 0.12+ });+ }++ // Caffeine cutoff (marker, not a zone)+ if (rec.caffeineCutoff) {+ const cutoff = parseTime(rec.caffeineCutoff);+ zones.push({ id: 'caffeine-cutoff', label: 'Caffeine Cutoff', startMin: cutoff, endMin: cutoff, color: '#ef4444', opacity: 0, marker: true });+ }++ // Last meal cutoff+ if (rec.lastMealCutoff) {+ const meal = parseTime(rec.lastMealCutoff);+ zones.push({ id: 'meal-cutoff', label: 'Last Meal', startMin: meal, endMin: meal, color: '#f97316', opacity: 0, marker: true });+ }++ // Wind-down+ if (rec.windDownStart && rec.sleepTime) {+ zones.push({+ id: 'wind-down',+ label: 'Wind Down',+ startMin: parseTime(rec.windDownStart),+ endMin: parseTime(rec.sleepTime),+ color: '#8b5cf6',+ opacity: 0.10+ });+ }++ return {+ zones,+ type: chronotype.type,+ confidence: chronotype.confidence,+ wakeTime: rec.wakeTime,+ sleepTime: rec.sleepTime+ };+}+// === Longevity Service Functions ===export async function getLongevity() {