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([issue-711]): While You Were Away dashboard briefing card
Adam Eivy8cd4f7cb7260
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 847b7d7819..af77f6eb87 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -3,6 +3,7 @@## Added- **[issue-708] Digital Twin "Voice" tab — spoken vs. written style** — Paste a transcript of yourself speaking and the Digital Twin compares it against how you write (a pasted sample, or your existing twin documents), surfacing where your spoken voice differs from your writing — formality, verbosity, sentence length, directness, filler words — and suggesting a communication profile for voice contexts that you can apply in one click.+- **[issue-711] "While You Were Away" dashboard card** — A new dashboard widget recaps what your agents did since your last visit: a count of completed runs, success/failure tally, total time worked, and the most recent wins plus anything that failed and needs a look. Each item links straight to the agent, and a "Mark as seen" button resets the window to now. It appears on the Everything and Agent Watch layouts and can be added to any layout via Arrange.## Changeddiff --git a/client/src/components/WhileAwayWidget.jsx b/client/src/components/WhileAwayWidget.jsxnew file mode 100644index 0000000000..205ee41ddf--- /dev/null+++ b/client/src/components/WhileAwayWidget.jsx@@ -0,0 +1,187 @@+import { useState, useEffect, useCallback, useRef } from 'react';+import { Link } from 'react-router-dom';+import {+ Moon,+ CheckCircle,+ XCircle,+ Clock,+ Eye,+ Loader2,+ Sparkles+} from 'lucide-react';+import * as api from '../services/api';+import socket from '../services/socket';+import { timeAgo } from '../utils/formatters';++// Per-device "last visit" marker. The widget shows agent activity that+// completed since this timestamp; "Mark as seen" advances it to now. Kept in+// localStorage (per the issue's while-away briefing slice) so there's no+// server-side presence state to migrate — it's intentionally per-browser.+const LAST_SEEN_KEY = 'portos.whileAway.lastSeen';++const readLastSeen = () => {+ const raw = localStorage.getItem(LAST_SEEN_KEY);+ // A finite, non-future ISO string is the only valid marker; anything else+ // (absent, garbage, clock-skewed) means "no marker" → server applies its+ // own 24h fallback so the card still renders.+ if (!raw) return null;+ const t = new Date(raw).getTime();+ if (!Number.isFinite(t) || t > Date.now()) return null;+ return raw;+};++const writeLastSeen = (iso) => {+ localStorage.setItem(LAST_SEEN_KEY, iso);+};++function ActivityRow({ item, kind }) {+ const Icon = kind === 'incident' ? XCircle : CheckCircle;+ const tone = kind === 'incident' ? 'text-port-error' : 'text-port-success';+ return (+ <Link+ to="/cos/agents"+ className="flex items-start gap-2.5 p-2 rounded-lg border border-port-border bg-port-bg/40 hover:border-port-accent/40 transition-colors group"+ >+ <Icon size={14} className={`mt-0.5 shrink-0 ${tone}`} />+ <div className="min-w-0 flex-1">+ <div className="text-sm text-gray-200 truncate">{item.description}</div>+ <div className="flex items-center gap-2 text-xs text-gray-500 mt-0.5">+ <span className="truncate">{item.taskType}</span>+ {item.app && <span className="truncate text-gray-600">· {item.app}</span>}+ <span className="shrink-0 ml-auto">{item.completedRelative}</span>+ </div>+ </div>+ </Link>+ );+}++export default function WhileAwayWidget() {+ const [data, setData] = useState(null);+ const [loading, setLoading] = useState(true);+ // The marker captured at fetch time, so "Mark as seen" and the header label+ // reflect the window we actually queried (not a value that drifted since).+ const sinceRef = useRef(null);++ const load = useCallback(() => {+ const since = readLastSeen();+ sinceRef.current = since;+ return api.getCosWhileAwayActivity(since, { silent: true })+ .then((res) => setData(res))+ .catch(() => null)+ .finally(() => setLoading(false));+ }, []);++ useEffect(() => {+ load();+ // A finished agent run can change the queue while you're looking at it —+ // refresh on completion so the card stays live (mirrors ReviewHubCard).+ const refresh = () => load();+ socket.on('cos:agent:completed', refresh);+ return () => socket.off('cos:agent:completed', refresh);+ }, [load]);++ const markSeen = () => {+ writeLastSeen(new Date().toISOString());+ setLoading(true);+ load();+ };++ if (loading && !data) {+ return (+ <div className="bg-port-card border border-port-border rounded-xl p-4 flex items-center justify-center min-h-[120px]">+ <Loader2 className="w-5 h-5 text-gray-500 animate-spin" />+ </div>+ );+ }++ if (!data) return null;++ const { stats, time, accomplishments = [], incidents = [] } = data;+ const total = stats?.completed ?? 0;+ // The header window: prefer the per-device marker; if absent, the server+ // fell back to 24h and reports the window it actually used via sinceIso.+ const windowSince = sinceRef.current || data.sinceIso;++ return (+ <div className="bg-port-card border border-port-border rounded-xl p-4 sm:p-6">+ {/* Header */}+ <div className="flex items-center justify-between mb-3 gap-3">+ <div className="flex items-center gap-3 min-w-0">+ <div className="p-2 rounded-lg bg-port-accent/10 shrink-0">+ <Moon className="w-5 h-5 text-port-accent" />+ </div>+ <div className="min-w-0">+ <h3 className="text-lg font-semibold text-white">While You Were Away</h3>+ <p className="text-sm text-gray-500 truncate">+ {total > 0+ ? `${total} agent run${total !== 1 ? 's' : ''} since ${timeAgo(windowSince)}`+ : `Nothing since ${timeAgo(windowSince)}`}+ </p>+ </div>+ </div>+ {total > 0 && (+ <button+ type="button"+ onClick={markSeen}+ className="flex items-center gap-1.5 px-2.5 py-1.5 text-xs bg-port-bg border border-port-border hover:border-port-accent/50 text-gray-300 rounded-lg transition-colors shrink-0 min-h-[36px]"+ title="Reset the window to now"+ >+ <Eye size={13} />+ <span className="hidden sm:inline">Mark as seen</span>+ </button>+ )}+ </div>++ {total === 0 ? (+ <div className="flex items-center gap-2 text-sm text-gray-500 py-4 justify-center">+ <Sparkles size={14} className="text-port-accent/60" />+ No agent activity while you were away.+ </div>+ ) : (+ <>+ {/* Stat strip */}+ <div className="flex flex-wrap items-center gap-2 mb-3">+ <span className="inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs bg-port-success/20 text-port-success">+ <CheckCircle size={10} />+ {stats.succeeded} succeeded+ </span>+ {stats.failed > 0 && (+ <span className="inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs bg-port-error/20 text-port-error">+ <XCircle size={10} />+ {stats.failed} failed+ </span>+ )}+ <span className="inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs bg-port-accent/20 text-port-accent">+ {stats.successRate}% success+ </span>+ {time?.totalDurationMs > 0 && (+ <span className="inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs bg-port-bg text-gray-400 border border-port-border">+ <Clock size={10} />+ {time.totalDuration} of work+ </span>+ )}+ </div>++ {/* Accomplishments */}+ {accomplishments.length > 0 && (+ <div className="space-y-1.5 mb-2">+ {accomplishments.map((item) => (+ <ActivityRow key={item.id} item={item} kind="accomplishment" />+ ))}+ </div>+ )}++ {/* Incidents */}+ {incidents.length > 0 && (+ <div className="space-y-1.5">+ <div className="text-xs font-medium text-port-error/80 mt-2 mb-1">Needs a look</div>+ {incidents.map((item) => (+ <ActivityRow key={item.id} item={item} kind="incident" />+ ))}+ </div>+ )}+ </>+ )}+ </div>+ );+}diff --git a/client/src/components/dashboard/widgetRegistry.jsx b/client/src/components/dashboard/widgetRegistry.jsxindex 2cce03a962..c7d1ce55ac 100644--- a/client/src/components/dashboard/widgetRegistry.jsx+++ b/client/src/components/dashboard/widgetRegistry.jsx@@ -17,6 +17,7 @@ const QuickIdeaCapture = lazyWithReload(() => import('../QuickIdeaCapture')const QuickImagePrompt = lazyWithReload(() => import('../QuickImagePrompt'));const QuickTaskWidget = lazyWithReload(() => import('../QuickTaskWidget'));const ReviewHubCard = lazyWithReload(() => import('../ReviewHubCard'));+const WhileAwayWidget = lazyWithReload(() => import('../WhileAwayWidget'));const AppsGridWidget = lazyWithReload(() => import('./builtins/AppsGridWidget'));const QuickStatsWidget = lazyWithReload(() => import('./builtins/QuickStatsWidget'));const ActivityStreakWidget = lazyWithReload(() => import('./builtins/ActivityStreakWidget'));@@ -48,6 +49,7 @@ export const WIDGETS = [{ id: 'upcoming-tasks', label: 'Upcoming Tasks', Component: UpcomingTasksWidget, width: 'third', defaultH: 5 },{ id: 'proactive-alerts', label: 'Proactive Alerts', Component: ProactiveAlertsWidget, width: 'quarter', defaultH: 4, module: { id: '04', status: 'ALERTS', glyph: 'warning-tri' } },{ id: 'review-hub', label: 'Review Hub', Component: ReviewHubCard, width: 'quarter', defaultH: 4, module: { id: '05', status: 'REVIEW', glyph: 'reticle' } },+ { id: 'while-away', label: 'While You Were Away', Component: WhileAwayWidget, width: 'third', defaultH: 5, module: { id: '08', status: 'AWAY', glyph: 'orbit' } },{ id: 'system-health', label: 'System Health', Component: SystemHealthWidget, width: 'quarter', defaultH: 8, module: { id: '01', status: 'HEALTH', glyph: 'matrix' } },{ id: 'network-exposure', label: 'Network Exposure', Component: NetworkExposureWidget, width: 'quarter', defaultH: 5, module: { id: '07', status: 'EXPOSURE', glyph: 'reticle' } },{ id: 'backup', label: 'Backup', Component: BackupWidget, width: 'quarter', defaultH: 5 },diff --git a/client/src/services/apiAgents.js b/client/src/services/apiAgents.jsindex ff1b87de02..ab9f7641dc 100644--- a/client/src/services/apiAgents.js+++ b/client/src/services/apiAgents.js@@ -110,6 +110,10 @@ export const getCosBriefing = (date) => request(`/cos/briefings/${date}`);// CoS Activityexport const getCosTodayActivity = () => request('/cos/activity/today');+// "While you were away" — agent runs since the client's last-visit marker.+// `since` is an ISO-8601 string; omit it to let the server fall back to 24h.+export const getCosWhileAwayActivity = (since, options) =>+ request(`/cos/activity/while-away${since ? `?since=${encodeURIComponent(since)}` : ''}`, options);// CoS Learningexport const getCosLearning = () => request('/cos/learning');diff --git a/server/routes/cosReportRoutes.js b/server/routes/cosReportRoutes.jsindex 484fd65b3b..0dc50aaded 100644--- a/server/routes/cosReportRoutes.js+++ b/server/routes/cosReportRoutes.js@@ -3,14 +3,24 @@*/import { Router } from 'express';+import { z } from 'zod';import * as cos from '../services/cos.js';import * as taskWatcher from '../services/taskWatcher.js';import * as appActivity from '../services/appActivity.js';import * as claudeChangelog from '../services/claudeChangelog.js';import { asyncHandler, ServerError } from '../lib/errorHandler.js';+import { validateRequest } from '../lib/validation.js';const router = Router();+// `since` is the client's last-visit marker (ISO-8601). Optional and tolerant:+// an absent/garbage value is clamped server-side to a 24h fallback, so we only+// reject a malformed datetime to keep the contract honest — we don't 400 on+// omission.+const whileAwayQuerySchema = z.object({+ since: z.string().datetime({ offset: true }).optional()+});+// GET /api/cos/reports - List all reportsrouter.get('/reports', asyncHandler(async (req, res) => {const reports = await cos.listReports();@@ -120,4 +130,12 @@ router.get('/activity/today', asyncHandler(async (req, res) => {res.json(activity);}));+// GET /api/cos/activity/while-away - What agents did since ?since=<ISO> (the+// client's last-visit marker). Powers the "While You Were Away" dashboard card.+router.get('/activity/while-away', asyncHandler(async (req, res) => {+ const { since } = validateRequest(whileAwayQuerySchema, req.query);+ const activity = await cos.getWhileAwayActivity(since);+ res.json(activity);+}));+export default router;diff --git a/server/services/cos.js b/server/services/cos.jsindex 799522291e..0974d1cd82 100644--- a/server/services/cos.js+++ b/server/services/cos.js@@ -39,7 +39,7 @@ export { cosEvents, emitLog };export { registerAgent, updateAgent, completeAgent, appendAgentOutput, getAgents, getAgentDates, getAgentsByDate, getAgent, getAgentPrompt, terminateAgent, pauseAgent, killAgent, sendBtwToAgent, getAgentProcessStats, cleanupZombieAgents, deleteAgent, submitAgentFeedback, getFeedbackStats, extractTaskType, archiveStaleAgents, clearCompletedAgents, pruneOldAgentArchives } from './cosAgents.js';// Reports and activity (re-export for backward compat with `import * as cos`)-export { generateReport, getReport, getTodayReport, listReports, listBriefings, getBriefing, getLatestBriefing, getTodayActivity, getRecentTasks, formatRelativeTime } from './cosReports.js';+export { generateReport, getReport, getTodayReport, listReports, listBriefings, getBriefing, getLatestBriefing, getTodayActivity, getWhileAwayActivity, getRecentTasks, formatRelativeTime } from './cosReports.js';// Health monitoring (imported for internal use by start()/init() and re-exported// for backward compat with `import * as cos` and the cos route handlers)diff --git a/server/services/cosReports.js b/server/services/cosReports.jsindex 55b7c3df83..ea54cf5afe 100644--- a/server/services/cosReports.js+++ b/server/services/cosReports.js@@ -9,6 +9,7 @@ import { readFile, writeFile, readdir } from 'fs/promises';import { existsSync } from 'fs';import { join } from 'path';import { loadState, ensureDirectories, REPORTS_DIR, isDaemonRunning } from './cosState.js';+import { getAgentsByDate } from './cosAgents.js';import { formatDuration, safeJSONParse } from '../lib/fileUtils.js';export async function generateReport(date = null) {@@ -173,6 +174,108 @@ export async function getTodayActivity() {};}+// Build a compact accomplishment/incident card for the "While You Were Away"+// briefing. Pure shaping helper — no I/O — so it's trivially unit-testable.+function summarizeAwayActivity(agents, sinceIso) {+ const succeeded = agents.filter(a => a.result?.success);+ const failed = agents.filter(a => !a.result?.success);++ const durationOf = (a) => a.result?.duration+ || (a.completedAt && a.startedAt+ ? new Date(a.completedAt).getTime() - new Date(a.startedAt).getTime()+ : 0);++ const toCard = (a) => ({+ id: a.id,+ taskId: a.taskId,+ description: a.metadata?.taskDescription?.substring(0, 120) || a.taskId,+ taskType: a.metadata?.analysisType || a.metadata?.taskType || 'task',+ app: a.metadata?.app || null,+ success: a.result?.success || false,+ durationMs: durationOf(a),+ durationFormatted: formatDuration(durationOf(a) > 0 ? durationOf(a) : 0),+ completedAt: a.completedAt,+ completedRelative: formatRelativeTime(a.completedAt)+ });++ // Most-recent first so the freshest work tops each list.+ const byRecency = (a, b) => new Date(b.completedAt) - new Date(a.completedAt);+ const totalDurationMs = agents.reduce((sum, a) => {+ const d = durationOf(a);+ return sum + (d > 0 ? d : 0);+ }, 0);++ return {+ sinceIso,+ stats: {+ completed: agents.length,+ succeeded: succeeded.length,+ failed: failed.length,+ successRate: agents.length > 0+ ? Math.round((succeeded.length / agents.length) * 100)+ : 0+ },+ time: {+ totalDurationMs,+ totalDuration: formatDuration(totalDurationMs)+ },+ accomplishments: succeeded.sort(byRecency).slice(0, 8).map(toCard),+ incidents: failed.sort(byRecency).slice(0, 8).map(toCard)+ };+}++// "What did agents do while I was away?" — completed agent runs since a+// client-supplied `sinceIso` (the browser's last-visit marker). Reads+// in-memory state for fresh runs PLUS the date-bucket archives for any day+// touched by the window, so a multi-day absence still surfaces work that+// has already been archived off the live state.+//+// Invalid/absent `sinceIso` falls back to the last 24h so the card always+// renders something useful rather than erroring. The window is clamped to a+// 30-day lookback to bound the number of archive buckets we read.+const AWAY_MAX_LOOKBACK_MS = 30 * 86400000;+export async function getWhileAwayActivity(sinceIso) {+ const now = Date.now();+ const parsed = sinceIso ? new Date(sinceIso).getTime() : NaN;+ // Clamp: a missing/garbage marker → 24h; a marker older than 30d → 30d ago;+ // a future marker → 24h (a clock-skewed client shouldn't blank the card).+ let sinceMs = Number.isFinite(parsed) ? parsed : now - 86400000;+ if (sinceMs > now) sinceMs = now - 86400000;+ if (sinceMs < now - AWAY_MAX_LOOKBACK_MS) sinceMs = now - AWAY_MAX_LOOKBACK_MS;+ const effectiveSinceIso = new Date(sinceMs).toISOString();++ const inWindow = (a) => {+ if (!a.completedAt) return false;+ const t = new Date(a.completedAt).getTime();+ return Number.isFinite(t) && t >= sinceMs && t <= now;+ };++ // Live (in-memory) completed agents within the window.+ const state = await loadState();+ const live = Object.values(state.agents).filter(a => a.status === 'completed' && inWindow(a));++ // Archived agents: read each date bucket the window spans (UTC day strings).+ const seen = new Set(live.map(a => a.id));+ const archived = [];+ const startDay = new Date(sinceMs);+ const endDay = new Date(now);+ for (let d = new Date(Date.UTC(startDay.getUTCFullYear(), startDay.getUTCMonth(), startDay.getUTCDate()));+ d.getTime() <= endDay.getTime();+ d = new Date(d.getTime() + 86400000)) {+ const dateStr = d.toISOString().slice(0, 10);+ const agents = await getAgentsByDate(dateStr);+ for (const a of agents) {+ if (seen.has(a.id)) continue; // live copy wins (fresher result/output)+ if (!inWindow(a)) continue;+ seen.add(a.id);+ archived.push(a);+ }+ }++ const summary = summarizeAwayActivity([...live, ...archived], effectiveSinceIso);+ return { ...summary, isRunning: isDaemonRunning(), isPaused: state.paused };+}+// Returns recently completed tasks from in-memory state only.// Agents older than the retention window are archived to date-bucketed dirs// and are not included here — use getAgentsByDate() for historical lookups.diff --git a/server/services/cosReports.test.js b/server/services/cosReports.test.jsnew file mode 100644index 0000000000..39a42b29c3--- /dev/null+++ b/server/services/cosReports.test.js@@ -0,0 +1,160 @@+import { describe, it, expect, beforeEach, vi, afterEach } from 'vitest';++const mock = vi.hoisted(() => ({+ state: null,+ daemonRunning: true,+ // agentsByDate: { 'YYYY-MM-DD': [agent, ...] }+ agentsByDate: {}+}));++vi.mock('./cosState.js', () => ({+ loadState: vi.fn(async () => mock.state),+ ensureDirectories: vi.fn(async () => {}),+ REPORTS_DIR: '/tmp/reports',+ isDaemonRunning: () => mock.daemonRunning+}));++vi.mock('./cosAgents.js', () => ({+ getAgentsByDate: vi.fn(async (date) => mock.agentsByDate[date] || [])+}));++import { getWhileAwayActivity } from './cosReports.js';++// Build a completed agent record at a fixed completedAt offset (ms before now).+const agentAt = (id, { msAgo, success = true, desc = 'did a thing', taskType = 'review', app = null } = {}) => {+ const completedAt = new Date(Date.now() - msAgo).toISOString();+ const startedAt = new Date(Date.now() - msAgo - 60000).toISOString();+ return {+ id,+ taskId: `task-${id}`,+ status: 'completed',+ startedAt,+ completedAt,+ result: { success, duration: 60000 },+ metadata: { taskDescription: desc, taskType, app }+ };+};++const stateWith = (agentList) => ({+ agents: Object.fromEntries(agentList.map(a => [a.id, a])),+ stats: {},+ paused: false+});++describe('getWhileAwayActivity', () => {+ beforeEach(() => {+ mock.daemonRunning = true;+ mock.agentsByDate = {};+ mock.state = stateWith([]);+ });++ afterEach(() => vi.clearAllMocks());++ it('returns only completed agents within the since-window', async () => {+ const recent = agentAt('a1', { msAgo: 60 * 60000 }); // 1h ago — in window+ const old = agentAt('a2', { msAgo: 5 * 3600000 }); // 5h ago — out of window+ mock.state = stateWith([recent, old]);++ const since = new Date(Date.now() - 2 * 3600000).toISOString(); // 2h ago+ const result = await getWhileAwayActivity(since);++ expect(result.stats.completed).toBe(1);+ expect(result.accomplishments).toHaveLength(1);+ expect(result.accomplishments[0].id).toBe('a1');+ });++ it('splits successes into accomplishments and failures into incidents', async () => {+ mock.state = stateWith([+ agentAt('ok1', { msAgo: 10 * 60000, success: true }),+ agentAt('ok2', { msAgo: 20 * 60000, success: true }),+ agentAt('bad1', { msAgo: 30 * 60000, success: false })+ ]);++ const since = new Date(Date.now() - 3600000).toISOString();+ const result = await getWhileAwayActivity(since);++ expect(result.stats).toMatchObject({ completed: 3, succeeded: 2, failed: 1, successRate: 67 });+ expect(result.accomplishments.map(a => a.id)).toEqual(['ok1', 'ok2']); // most-recent first+ expect(result.incidents.map(a => a.id)).toEqual(['bad1']);+ });++ it('merges archived agents from date buckets the window spans', async () => {+ const liveAgent = agentAt('live', { msAgo: 30 * 60000 });+ mock.state = stateWith([liveAgent]);+ // An archived agent that completed ~1h ago lives in today's bucket.+ const todayStr = new Date().toISOString().slice(0, 10);+ mock.agentsByDate[todayStr] = [agentAt('archived', { msAgo: 50 * 60000 })];++ const since = new Date(Date.now() - 2 * 3600000).toISOString();+ const result = await getWhileAwayActivity(since);++ const ids = result.accomplishments.map(a => a.id).sort();+ expect(ids).toEqual(['archived', 'live']);+ expect(result.stats.completed).toBe(2);+ });++ it('prefers the live copy over an archived duplicate of the same id', async () => {+ const live = agentAt('dup', { msAgo: 30 * 60000, success: true, desc: 'live version' });+ mock.state = stateWith([live]);+ const todayStr = new Date().toISOString().slice(0, 10);+ mock.agentsByDate[todayStr] = [agentAt('dup', { msAgo: 30 * 60000, success: false, desc: 'stale archived version' })];++ const since = new Date(Date.now() - 3600000).toISOString();+ const result = await getWhileAwayActivity(since);++ expect(result.stats.completed).toBe(1);+ expect(result.accomplishments).toHaveLength(1);+ expect(result.accomplishments[0].description).toBe('live version');+ expect(result.incidents).toHaveLength(0);+ });++ it('falls back to a 24h window when since is absent or garbage', async () => {+ const within = agentAt('w', { msAgo: 12 * 3600000 }); // 12h ago — inside 24h+ const beyond = agentAt('b', { msAgo: 40 * 3600000 }); // 40h ago — outside 24h+ mock.state = stateWith([within, beyond]);++ for (const bad of [undefined, '', 'not-a-date', 'null']) {+ const result = await getWhileAwayActivity(bad);+ expect(result.stats.completed).toBe(1);+ expect(result.accomplishments[0].id).toBe('w');+ }+ });++ it('treats a future since marker as the 24h fallback (clock skew guard)', async () => {+ const within = agentAt('w', { msAgo: 6 * 3600000 });+ mock.state = stateWith([within]);++ const future = new Date(Date.now() + 3600000).toISOString();+ const result = await getWhileAwayActivity(future);++ expect(result.stats.completed).toBe(1);+ expect(result.accomplishments[0].id).toBe('w');+ });++ it('reports daemon running/paused state', async () => {+ mock.daemonRunning = false;+ mock.state = { agents: {}, stats: {}, paused: true };++ const result = await getWhileAwayActivity(new Date(Date.now() - 3600000).toISOString());++ expect(result.isRunning).toBe(false);+ expect(result.isPaused).toBe(true);+ expect(result.stats.completed).toBe(0);+ expect(result.accomplishments).toEqual([]);+ expect(result.incidents).toEqual([]);+ });++ it('caps accomplishments and incidents at 8 each', async () => {+ const many = [];+ for (let i = 0; i < 12; i++) many.push(agentAt(`ok${i}`, { msAgo: (i + 1) * 60000, success: true }));+ for (let i = 0; i < 12; i++) many.push(agentAt(`bad${i}`, { msAgo: (i + 1) * 60000, success: false }));+ mock.state = stateWith(many);++ const since = new Date(Date.now() - 3600000).toISOString();+ const result = await getWhileAwayActivity(since);++ expect(result.accomplishments).toHaveLength(8);+ expect(result.incidents).toHaveLength(8);+ expect(result.stats.completed).toBe(24);+ });+});diff --git a/server/services/dashboardLayouts.js b/server/services/dashboardLayouts.jsindex 80f728dc30..43f92f7e44 100644--- a/server/services/dashboardLayouts.js+++ b/server/services/dashboardLayouts.js@@ -63,13 +63,14 @@ export const INTENT_LAYOUTS = [{id: 'agent-watch',name: 'Agent Watch',- widgets: ['cos', 'proactive-alerts', 'review-hub', 'system-health', 'decision-log'],+ widgets: ['cos', 'proactive-alerts', 'review-hub', 'while-away', 'system-health', 'decision-log'],grid: [{ id: 'cos', x: 0, y: 0, w: 6, h: 5 },{ id: 'proactive-alerts', x: 6, y: 0, w: 3, h: 3 },{ id: 'review-hub', x: 9, y: 0, w: 3, h: 3 },- { id: 'system-health', x: 6, y: 3, w: 6, h: 5 },- { id: 'decision-log', x: 0, y: 5, w: 6, h: 3 },+ { id: 'while-away', x: 6, y: 3, w: 6, h: 5 },+ { id: 'system-health', x: 0, y: 5, w: 6, h: 5 },+ { id: 'decision-log', x: 6, y: 8, w: 6, h: 3 },],},];@@ -83,7 +84,7 @@ const DEFAULT_LAYOUTS = ['quick-brain', 'quick-idea', 'quick-image', 'quick-task','apps','cos', 'goal-progress', 'upcoming-tasks',- 'proactive-alerts', 'review-hub', 'system-health', 'network-exposure', 'backup', 'death-clock', 'quick-stats', 'decision-log',+ 'proactive-alerts', 'review-hub', 'while-away', 'system-health', 'network-exposure', 'backup', 'death-clock', 'quick-stats', 'decision-log','activity-streak', 'hourly-activity',],// Above-the-fold capture row stretches to h=5 so the Quick Task card@@ -110,6 +111,7 @@ const DEFAULT_LAYOUTS = [// Row 14–17: lower-priority + cos{ id: 'decision-log', x: 0, y: 14, w: 4, h: 2 },{ id: 'cos', x: 4, y: 14, w: 5, h: 4 },+ { id: 'while-away', x: 9, y: 14, w: 3, h: 5 },// Row 18+: full-width visualizations + apps{ id: 'hourly-activity', x: 0, y: 18, w: 12, h: 3 },{ id: 'apps', x: 0, y: 21, w: 12, h: 8 },