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: week view 15-minute blocks with side-by-side overlap layout
Adam Eivy4128741bf22c
diff --git a/client/src/components/calendar/WeekView.jsx b/client/src/components/calendar/WeekView.jsxindex c327ff43c5..8517f73a2b 100644--- a/client/src/components/calendar/WeekView.jsx+++ b/client/src/components/calendar/WeekView.jsx@@ -1,10 +1,15 @@-import { useState, useEffect, useCallback } from 'react';+import { useState, useEffect, useCallback, useMemo } from 'react';import { ChevronLeft, ChevronRight, RefreshCw } from 'lucide-react';import * as api from '../../services/api';import socket from '../../services/socket';import EventDetail from './EventDetail';-const HOURS = Array.from({ length: 17 }, (_, i) => i + 6); // 6am to 10pm+const START_HOUR = 6;+const END_HOUR = 23;+const HOURS = Array.from({ length: END_HOUR - START_HOUR }, (_, i) => i + START_HOUR);+const PX_PER_HOUR = 48;+const PX_PER_15MIN = PX_PER_HOUR / 4; // 12px per 15-min block+const START_MINUTES = START_HOUR * 60;function formatHour(hour) {if (hour === 0) return '12 AM';@@ -28,16 +33,75 @@ function getWeekDays(weekStart) {});}-function getEventPosition(event) {+function getEventMinutes(event) {const start = new Date(event.startTime);const end = new Date(event.endTime);- const startMinutes = start.getHours() * 60 + start.getMinutes();- const endMinutes = end.getHours() * 60 + end.getMinutes();- const top = ((startMinutes - 360) / 60) * 48; // 48px per hour, starting at 6am- const height = Math.max(((endMinutes - startMinutes) / 60) * 48, 18);+ return {+ startMin: start.getHours() * 60 + start.getMinutes(),+ endMin: end.getHours() * 60 + end.getMinutes()+ };+}++function getEventPosition(event) {+ const { startMin, endMin } = getEventMinutes(event);+ const top = ((startMin - START_MINUTES) / 60) * PX_PER_HOUR;+ const height = Math.max(((endMin - startMin) / 60) * PX_PER_HOUR, PX_PER_15MIN);return { top: Math.max(top, 0), height };}+function eventKey(e) {+ return `${e.accountId}-${e.id}`;+}++function layoutEvents(events) {+ const items = events.map(e => {+ const { startMin, endMin } = getEventMinutes(e);+ return { event: e, startMin, endMin: Math.max(endMin, startMin + 15) };+ }).sort((a, b) => a.startMin - b.startMin || a.endMin - b.endMin);++ const groups = [];+ let currentGroup = [];+ let groupEnd = -1;++ for (const item of items) {+ if (currentGroup.length === 0 || item.startMin < groupEnd) {+ currentGroup.push(item);+ groupEnd = Math.max(groupEnd, item.endMin);+ } else {+ groups.push(currentGroup);+ currentGroup = [item];+ groupEnd = item.endMin;+ }+ }+ if (currentGroup.length > 0) groups.push(currentGroup);++ const layout = new Map();+ for (const group of groups) {+ const columns = [];+ for (const item of group) {+ let placed = false;+ for (let col = 0; col < columns.length; col++) {+ if (columns[col] <= item.startMin) {+ columns[col] = item.endMin;+ layout.set(eventKey(item.event), { column: col, totalColumns: 0 });+ placed = true;+ break;+ }+ }+ if (!placed) {+ layout.set(eventKey(item.event), { column: columns.length, totalColumns: 0 });+ columns.push(item.endMin);+ }+ }+ const total = columns.length;+ for (const item of group) {+ const l = layout.get(eventKey(item.event));+ if (l) l.totalColumns = total;+ }+ }+ return layout;+}+export default function WeekView() {const [weekStart, setWeekStart] = useState(() => getWeekStart(new Date()));const [events, setEvents] = useState([]);@@ -81,7 +145,7 @@ export default function WeekView() {// Group events by dayconst eventsByDay = weekDays.map(day => {const dayStr = day.toDateString();- return events.filter(e => new Date(e.startTime).toDateString() === dayStr);+ return events.filter(e => !e.isAllDay && new Date(e.startTime).toDateString() === dayStr);});const allDayByDay = weekDays.map(day => {@@ -89,10 +153,16 @@ export default function WeekView() {return events.filter(e => e.isAllDay && new Date(e.startTime).toDateString() === dayStr);});+ // Memoize layouts per day+ const layoutsByDay = useMemo(+ () => eventsByDay.map(dayEvents => layoutEvents(dayEvents)),+ [events, weekStart.getTime()]+ );+const now = new Date();const todayStr = now.toDateString();const nowMinutes = now.getHours() * 60 + now.getMinutes();- const nowTop = ((nowMinutes - 360) / 60) * 48;+ const nowTop = ((nowMinutes - START_MINUTES) / 60) * PX_PER_HOUR;const weekLabel = `${weekDays[0].toLocaleDateString([], { month: 'short', day: 'numeric' })} - ${weekDays[6].toLocaleDateString([], { month: 'short', day: 'numeric', year: 'numeric' })}`;@@ -147,7 +217,7 @@ export default function WeekView() {<div key={i} className="flex-1 border-l border-port-border p-0.5 min-h-[28px]">{dayEvents.map(event => (<button- key={`${event.accountId}-${event.id}`}+ key={eventKey(event)}onClick={() => setSelectedEvent(event)}className="w-full text-left px-1 py-0.5 bg-port-accent/15 text-port-accent rounded text-[10px] truncate hover:bg-port-accent/25 transition-colors">@@ -162,12 +232,20 @@ export default function WeekView() {{/* Time grid */}<div className="relative">{HOURS.map(hour => (- <div key={hour} className="flex border-b border-port-border/50 last:border-b-0" style={{ height: 48 }}>+ <div key={hour} className="flex border-b border-port-border/50 last:border-b-0" style={{ height: PX_PER_HOUR }}><div className="w-14 shrink-0 text-[10px] text-gray-500 text-right pr-1 -mt-1.5">{formatHour(hour)}</div>{weekDays.map((_, i) => (- <div key={i} className="flex-1 border-l border-port-border/50" />+ <div key={i} className="flex-1 border-l border-port-border/50 flex flex-col">+ {[0, 1, 2, 3].map(q => (+ <div+ key={q}+ className={`flex-1 ${q > 0 ? 'border-t border-port-border/20' : ''}`}+ style={{ height: PX_PER_15MIN }}+ />+ ))}+ </div>))}</div>))}@@ -176,23 +254,34 @@ export default function WeekView() {<div className="absolute top-0 bottom-0 left-14 right-0 flex">{eventsByDay.map((dayEvents, dayIndex) => {const isToday = weekDays[dayIndex].toDateString() === todayStr;+ const layout = layoutsByDay[dayIndex];return (<div key={dayIndex} className="flex-1 relative border-l border-port-border/50">- {dayEvents.filter(e => !e.isAllDay).map(event => {+ {dayEvents.map(event => {const { top, height } = getEventPosition(event);+ const key = eventKey(event);+ const { column, totalColumns } = layout.get(key) || { column: 0, totalColumns: 1 };+ const widthPercent = 100 / totalColumns;+ const leftPercent = column * widthPercent;return (<button- key={`${event.accountId}-${event.id}`}+ key={key}onClick={() => setSelectedEvent(event)}- className="absolute left-0.5 right-0.5 px-1 py-0.5 bg-port-accent/20 border-l-2 border-port-accent rounded text-left overflow-hidden hover:bg-port-accent/30 transition-colors"- style={{ top, height, minHeight: 18 }}+ className="absolute px-0.5 py-0.5 bg-port-accent/20 border-l-2 border-port-accent rounded text-left overflow-hidden hover:bg-port-accent/30 transition-colors"+ style={{+ top,+ height,+ minHeight: PX_PER_15MIN,+ left: `calc(${leftPercent}% + 1px)`,+ width: `calc(${widthPercent}% - 2px)`+ }}><div className="text-[10px] font-medium text-white truncate">{event.title}</div></button>);})}{/* Current time line */}- {isToday && nowTop >= 0 && nowTop <= HOURS.length * 48 && (+ {isToday && nowTop >= 0 && nowTop <= HOURS.length * PX_PER_HOUR && (<div className="absolute left-0 right-0 flex items-center pointer-events-none z-10" style={{ top: nowTop }}><div className="w-1.5 h-1.5 rounded-full bg-port-error -ml-0.5" /><div className="flex-1 h-px bg-port-error" />