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: add optimal time indicator to QuickSummary

Adam Eivya15cdd8202bf
diff --git a/.changelog/v0.20.x.md b/.changelog/v0.20.x.md
new file mode 100644
index 0000000000..45a6e66c17
--- /dev/null
+++ b/.changelog/v0.20.x.md
@@ -0,0 +1,15 @@
+# Release v0.20.x - Changelog
+
+Released: YYYY-MM-DD
+
+## Overview
+
+Productivity insights for the QuickSummary dashboard.
+
+## Features
+
+### Optimal time indicator in QuickSummary
+- **Peak hour detection** analyzes hourly success rate patterns to show whether the current hour is a peak productivity window
+- Displays "Peak Hour" (top 25% hours), "Good" (above average), or next peak hour time when suboptimal
+- Requires 3+ hours of historical data with 3+ tasks each before activating
+- Hover tooltip shows current success rate or next peak time for quick context
diff --git a/client/src/components/cos/QuickSummary.jsx b/client/src/components/cos/QuickSummary.jsx
index d1823c7c21..425a69caa0 100644
--- a/client/src/components/cos/QuickSummary.jsx
+++ b/client/src/components/cos/QuickSummary.jsx
@@ -13,7 +13,9 @@ import {
ChevronRight,
Award,
Hourglass,
- Calendar
+ Calendar,
+ Sun,
+ Sunset
} from 'lucide-react';
import * as api from '../../services/api';
@@ -43,7 +45,7 @@ export default function QuickSummary() {
return null;
}
- const { today, streak, nextJob, queue, velocity, weekComparison } = summary;
+ const { today, streak, nextJob, queue, velocity, weekComparison, optimalTime } = summary;
// Only show if there's meaningful data to display
const hasActivity = today.completed > 0 || today.running > 0 || streak.current > 0 || queue.total > 0;
@@ -147,6 +149,45 @@ export default function QuickSummary() {
</div>
)}
+ {/* Optimal Time Indicator */}
+ {optimalTime?.hasData && (
+ <div
+ className="flex items-center gap-1.5"
+ title={optimalTime.isOptimal
+ ? `This is a peak productivity hour (${optimalTime.currentSuccessRate}% success rate)`
+ : optimalTime.nextOptimalFormatted
+ ? `Next peak hour: ${optimalTime.nextOptimalFormatted}`
+ : 'Current hour performance data'
+ }
+ >
+ {optimalTime.isOptimal ? (
+ <>
+ <Sun size={14} className="text-yellow-400" />
+ <span className="text-gray-400">Time:</span>
+ <span className="font-medium text-yellow-400 px-1.5 py-0.5 rounded bg-yellow-500/15">
+ Peak Hour
+ </span>
+ </>
+ ) : optimalTime.isAboveAverage ? (
+ <>
+ <Sun size={14} className="text-port-success/70" />
+ <span className="text-gray-400">Time:</span>
+ <span className="font-medium text-port-success px-1.5 py-0.5 rounded bg-port-success/10">
+ Good
+ </span>
+ </>
+ ) : optimalTime.nextOptimalFormatted ? (
+ <>
+ <Sunset size={14} className="text-gray-500" />
+ <span className="text-gray-400">Peak:</span>
+ <span className="font-medium text-gray-300">
+ {optimalTime.nextOptimalFormatted}
+ </span>
+ </>
+ ) : null}
+ </div>
+ )}
+
{/* Week over Week Comparison */}
{weekComparison && weekComparison.lastWeek?.tasks > 0 && (
<div className="flex items-center gap-1.5" title={`This week: ${weekComparison.thisWeek?.tasks || 0} tasks, Last week (same days): ${weekComparison.lastWeek?.tasks} tasks`}>
diff --git a/package-lock.json b/package-lock.json
index ba215ac421..2f8f1fece6 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "portos",
- "version": "0.19.1",
+ "version": "0.20.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "portos",
- "version": "0.19.1",
+ "version": "0.20.0",
"license": "MIT",
"workspaces": [
"packages/*",
diff --git a/package.json b/package.json
index 0b11718abd..b06f139b9f 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "portos",
- "version": "0.19.1",
+ "version": "0.20.0",
"private": true,
"description": "Local dev machine App OS portal",
"author": "Adam Eivy (@antic|@atomantic)",
diff --git a/server/routes/cos.js b/server/routes/cos.js
index 5a61ca0b76..99f317e64a 100644
--- a/server/routes/cos.js
+++ b/server/routes/cos.js
@@ -1055,13 +1055,14 @@ router.get('/recent-tasks', asyncHandler(async (req, res) => {
// GET /api/cos/quick-summary - Get at-a-glance dashboard summary
// Combines today's activity, streak status, next job, and pending approvals into one efficient call
router.get('/quick-summary', asyncHandler(async (req, res) => {
- const [todayActivity, productivityData, tasksData, jobStats, velocityData, weekData] = await Promise.all([
+ const [todayActivity, productivityData, tasksData, jobStats, velocityData, weekData, optimalTime] = await Promise.all([
cos.getTodayActivity(),
productivity.getProductivitySummary(),
cos.getAllTasks(),
autonomousJobs.getJobStats(),
productivity.getVelocityMetrics(),
- productivity.getWeekComparison()
+ productivity.getWeekComparison(),
+ productivity.getOptimalTimeInfo()
]);
// Count pending approvals from system tasks
@@ -1116,7 +1117,8 @@ router.get('/quick-summary', asyncHandler(async (req, res) => {
paused: todayActivity.isPaused,
lastEvaluation: todayActivity.lastEvaluation
},
- weekComparison: weekData
+ weekComparison: weekData,
+ optimalTime
});
}));
diff --git a/server/services/productivity.js b/server/services/productivity.js
index 6c6ed22fad..6a4b7fa87d 100644
--- a/server/services/productivity.js
+++ b/server/services/productivity.js
@@ -719,3 +719,80 @@ export async function getActivityCalendar(weeks = 12) {
currentStreak: data.streaks?.currentDaily || 0
};
}
+
+/**
+ * Get optimal time indicator for current hour
+ * Compares current hour's success rate to find peak windows
+ * @returns {Object} Optimal time data
+ */
+export async function getOptimalTimeInfo() {
+ const data = await loadProductivity();
+ const hourlyPatterns = data.hourlyPatterns || {};
+ const currentHour = new Date().getHours();
+
+ // Need minimum data to make meaningful recommendations
+ const minTasksForReliable = 3;
+
+ // Get hours with enough data, sorted by success rate
+ const rankedHours = Object.entries(hourlyPatterns)
+ .filter(([, p]) => p.tasks >= minTasksForReliable)
+ .map(([hour, p]) => ({
+ hour: parseInt(hour, 10),
+ tasks: p.tasks,
+ successRate: p.successRate
+ }))
+ .sort((a, b) => b.successRate - a.successRate);
+
+ // Not enough data
+ if (rankedHours.length < 3) {
+ return { hasData: false };
+ }
+
+ // Find current hour's data
+ const currentHourData = hourlyPatterns[currentHour];
+ const currentSuccessRate = currentHourData?.successRate ?? null;
+ const currentTasks = currentHourData?.tasks ?? 0;
+
+ // Calculate average success rate
+ const avgSuccessRate = rankedHours.reduce((sum, h) => sum + h.successRate, 0) / rankedHours.length;
+
+ // Determine if current hour is optimal (top 25%), good (above avg), or suboptimal
+ const topThreshold = Math.ceil(rankedHours.length * 0.25);
+ const topHours = rankedHours.slice(0, topThreshold).map(h => h.hour);
+ const isOptimal = topHours.includes(currentHour);
+ const isAboveAverage = currentSuccessRate !== null && currentSuccessRate >= avgSuccessRate;
+
+ // Find next optimal hour if current isn't optimal
+ let nextOptimalHour = null;
+ if (!isOptimal) {
+ // Find nearest future top hour
+ for (let offset = 1; offset < 24; offset++) {
+ const checkHour = (currentHour + offset) % 24;
+ if (topHours.includes(checkHour)) {
+ nextOptimalHour = checkHour;
+ break;
+ }
+ }
+ }
+
+ // Format hour for display
+ const formatHour = (h) => {
+ if (h === 0) return '12AM';
+ if (h === 12) return '12PM';
+ return h < 12 ? `${h}AM` : `${h - 12}PM`;
+ };
+
+ return {
+ hasData: true,
+ currentHour,
+ currentSuccessRate,
+ currentTasks,
+ isOptimal,
+ isAboveAverage,
+ topHours,
+ nextOptimalHour,
+ nextOptimalFormatted: nextOptimalHour !== null ? formatHour(nextOptimalHour) : null,
+ avgSuccessRate: Math.round(avgSuccessRate),
+ peakSuccessRate: rankedHours[0]?.successRate ?? 0
+ };
+}