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
refactor: simplify goal feasibility and calendar responsive code
Adam Eivye2eb3e6bd017
diff --git a/client/src/components/meatspace/tabs/CalendarTab.jsx b/client/src/components/meatspace/tabs/CalendarTab.jsxindex 74cc92ad61..1b7c43c6a8 100644--- a/client/src/components/meatspace/tabs/CalendarTab.jsx+++ b/client/src/components/meatspace/tabs/CalendarTab.jsx@@ -363,7 +363,6 @@ function MiniMonth({ month, cellSize, gap, showEvents }) {return result;}, [month]);- const sz = cellSize;const rowStyle = { display: 'grid', gridTemplateColumns: 'repeat(7, 1fr)', gap: `${gap}px` };return (@@ -371,7 +370,7 @@ function MiniMonth({ month, cellSize, gap, showEvents }) {<div className="text-[10px] text-gray-400 font-medium mb-1 text-center">{month.name}</div><div style={rowStyle}>{DAY_LABELS.map((d, i) => (- <span key={i} className="text-center text-gray-600" style={{ fontSize: '7px', lineHeight: `${sz}px` }}>+ <span key={i} className="text-center text-gray-600" style={{ fontSize: '7px', lineHeight: `${cellSize}px` }}>{d}</span>))}@@ -413,7 +412,6 @@ function DayGridView({ birthDate, deathDate, cellCfg, stats, showEvents }) {const monthWidth = containerWidth ? Math.floor((containerWidth - (gridCols - 1) * gridGap) / gridCols) : null;// Fit 7 day columns + 6 gaps into monthWidthconst responsiveDaySize = monthWidth ? Math.max(8, Math.floor((monthWidth - cellCfg.gap * 6) / 7)) : cellCfg.size;- const responsiveDayGap = cellCfg.gap;return (<div ref={containerRef}>@@ -442,7 +440,7 @@ function DayGridView({ birthDate, deathDate, cellCfg, stats, showEvents }) {</div><div style={{ display: 'grid', gridTemplateColumns: `repeat(${gridCols}, 1fr)`, gap: `${gridGap}px` }}>{months.map((m, i) => (- <MiniMonth key={i} month={m} cellSize={responsiveDaySize} gap={responsiveDayGap} showEvents={showEvents} />+ <MiniMonth key={i} month={m} cellSize={responsiveDaySize} gap={cellCfg.gap} showEvents={showEvents} />))}</div></div>diff --git a/server/services/identity.js b/server/services/identity.jsindex 594a06898e..1b9622492b 100644--- a/server/services/identity.js+++ b/server/services/identity.js@@ -5,6 +5,7 @@ import { PATHS, ensureDir, safeJSONParse } from '../lib/fileUtils.js';import { ServerError } from '../lib/errorHandler.js';import { getGenomeSummary } from './genome.js';import { getTasteProfile } from './taste-questionnaire.js';+import { getActivities } from './meatspaceCalendar.js';const IDENTITY_DIR = PATHS.digitalTwin;const IDENTITY_FILE = join(IDENTITY_DIR, 'identity.json');@@ -318,18 +319,19 @@ export function computeLifeExpectancy(longevityMarkers, cardiovascularMarkers, b};}+function getHorizonYears(horizon, timeHorizons) {+ const map = { '1-year': 1, '3-year': 3, '5-year': 5, '10-year': 10, '20-year': 20, 'lifetime': timeHorizons.yearsRemaining };+ return map[horizon] ?? 5;+}+/*** Compute time feasibility for a goal based on its linked activities.- * Returns { feasible, hoursPerWeek, weeksNeeded, weeksAvailable } or null if no links.+ * Returns { feasible, totalPerWeek, weeksAvailable, links } or null if no links.*/export function computeGoalFeasibility(goal, timeHorizons, activities) {if (!goal.linkedActivities?.length || !timeHorizons) return null;- const horizonMap = {- '1-year': 1, '3-year': 3, '5-year': 5,- '10-year': 10, '20-year': 20, 'lifetime': timeHorizons.yearsRemaining- };- const horizonYears = horizonMap[goal.horizon] ?? 5;+ const horizonYears = getHorizonYears(goal.horizon, timeHorizons);const weeksAvailable = Math.floor(Math.min(horizonYears, timeHorizons.yearsRemaining) * 52);let totalPerWeek = 0;@@ -363,16 +365,7 @@ export function computeGoalFeasibility(goal, timeHorizons, activities) {export function computeGoalUrgency(goal, timeHorizons) {if (!timeHorizons || !goal.horizon) return null;- const horizonMap = {- '1-year': 1,- '3-year': 3,- '5-year': 5,- '10-year': 10,- '20-year': 20,- 'lifetime': timeHorizons.yearsRemaining- };-- const horizonYears = horizonMap[goal.horizon] ?? 5;+ const horizonYears = getHorizonYears(goal.horizon, timeHorizons);const yearsRemaining = timeHorizons.yearsRemaining;if (horizonYears <= 0 || yearsRemaining <= 0) return 1;@@ -805,7 +798,7 @@ export async function updateGoal(goalId, updates) {}}- const allowed = ['title', 'description', 'horizon', 'category', 'status', 'parentId', 'tags', 'linkedActivities'];+ const allowed = ['title', 'description', 'horizon', 'category', 'status', 'parentId', 'tags'];for (const key of allowed) {if (updates[key] !== undefined) goal[key] = updates[key];}@@ -850,7 +843,6 @@ export async function deleteGoal(goalId) {export async function getGoalsTree() {const goals = await getGoals();const longevity = await loadJSON(LONGEVITY_FILE, DEFAULT_LONGEVITY);- const { getActivities } = await import('./meatspaceCalendar.js');const activities = await getActivities();// Enrich goals with urgency and feasibility (shallow copies to avoid mutating persisted objects)