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

address review: fix 10 Copilot review findings

Adam Eivycbbfdbb7d6d8
diff --git a/browser/server.js b/browser/server.js
index 56b66ecb0b..dccae77c83 100644
--- a/browser/server.js
+++ b/browser/server.js
@@ -45,6 +45,11 @@ async function configureDownloadBehavior(downloadDir) {
if (!wsUrl) return;
// CDP requires explicit Browser.setDownloadBehavior — without it headless Chrome silently drops downloads
+ // WebSocket is a global in Node.js 21+ (project targets Node 22+)
+ if (typeof WebSocket === 'undefined') {
+ console.log('⚠️ WebSocket not available — download configuration skipped (requires Node.js 21+)');
+ return;
+ }
await new Promise((resolve) => {
const ws = new WebSocket(wsUrl);
const timer = setTimeout(() => { ws.close(); resolve(); }, 5000);
diff --git a/client/src/components/calendar/ChronotypeOverlay.jsx b/client/src/components/calendar/ChronotypeOverlay.jsx
index 0bec0d8dee..f6d7c2c064 100644
--- a/client/src/components/calendar/ChronotypeOverlay.jsx
+++ b/client/src/components/calendar/ChronotypeOverlay.jsx
@@ -7,11 +7,11 @@ import * as api from '../../services/api';
* 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
+ * - Labels that appear on hover via CSS (pointer-events-none so
+ * calendar events remain clickable through the overlay)
*/
export default function ChronotypeOverlay({ startHour, pxPerHour }) {
const [schedule, setSchedule] = useState(null);
- const [hoveredZone, setHoveredZone] = useState(null);
useEffect(() => {
api.getChronotypeEnergySchedule().then(setSchedule).catch(() => null);
@@ -33,23 +33,19 @@ export default function ChronotypeOverlay({ startHour, pxPerHour }) {
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)}
+ className="absolute left-0 right-0 flex items-center pointer-events-none z-0 group/marker"
>
+ <style>{`.group\\/marker:hover .chrono-label { opacity: 1; }`}</style>
<div
className="flex-1 border-t border-dashed"
- style={{ borderColor: zone.color }}
+ style={{ top, 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>
- )}
+ <span
+ className="chrono-label absolute right-1 -top-4 text-[10px] font-medium px-1.5 py-0.5 rounded opacity-0 transition-opacity"
+ style={{ color: zone.color, backgroundColor: `${zone.color}20` }}
+ >
+ {zone.label}
+ </span>
</div>
);
}
@@ -61,24 +57,20 @@ export default function ChronotypeOverlay({ startHour, pxPerHour }) {
return (
<div
key={zone.id}
- className="absolute left-0 right-0 pointer-events-auto z-0"
+ className="absolute left-0 right-0 pointer-events-none 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>
- )}
+ <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/WeekView.jsx b/client/src/components/calendar/WeekView.jsx
index fc2ea2f040..90c33673f1 100644
--- a/client/src/components/calendar/WeekView.jsx
+++ b/client/src/components/calendar/WeekView.jsx
@@ -266,7 +266,7 @@ export default function WeekView({ accounts }) {
))}
{/* Chronotype energy zones (behind events) */}
- <div className="absolute top-0 bottom-0 left-14 right-0 pointer-events-none">
+ <div className="absolute top-0 bottom-0 left-14 right-0">
<ChronotypeOverlay startHour={START_HOUR} pxPerHour={PX_PER_HOUR} />
</div>
diff --git a/data/cos/reports/2026-03-27-short-stories-progress-check.md b/data/cos/reports/2026-03-27-short-stories-progress-check.md
deleted file mode 100644
index 6ea30166c9..0000000000
--- a/data/cos/reports/2026-03-27-short-stories-progress-check.md
+++ /dev/null
@@ -1,64 +0,0 @@
-# Short Stories Book Project — Progress Check
-
-**Date**: 2026-03-27
-**Project**: Short Stories Book Project (e5cfb84e)
-**Status**: AT RISK — no confirmed progress since reactivation
-
-## Situation
-
-The Mar 24 escalation deadline (set during the Mar 20 project review) has passed with no update from the user. Two Saturday sessions should have occurred since the last confirmed activity:
-
-| Session | Date | Status |
-|---------|------|--------|
-| Mar 22 Saturday | 9:00-11:30 AM | **Unknown** — update 5 days overdue |
-| Mar 29 Saturday | 9:00-11:30 AM | Upcoming (2 days away) |
-
-The project was reactivated on Mar 14 after the user confirmed "Saturday writing sessions have started." Since then, the Mar 22 briefing noted "Saturday morning writing habit maintained" (based on user's prior statement), but no concrete output has been reported — no story concepts logged, no drafts confirmed, no PortOS goals integration set up.
-
-## Key Questions (Unanswered)
-
-1. **Did the Mar 22 Saturday session happen?** If yes, what was produced?
-2. **How many story concepts have been brainstormed?** Month 1 target was 10-12 concepts by end of Week 1.
-3. **Any drafts started?** Month 1 target is 3 first drafts by Mar 31 — 4 days away.
-4. **Is progress being tracked anywhere?** PortOS goals integration was flagged as a focus area on Mar 22 and Mar 24 but hasn't been set up.
-
-## Timeline Assessment
-
-| Milestone | Target | Status |
-|-----------|--------|--------|
-| Month 1 (Mar) | 3 story drafts | **AT RISK** — 4 days remain, no confirmed output |
-| Month 2 (Apr) | 6 total drafts | Dependent on M1 |
-| Month 3 (May) | 10 drafts + revisions | Dependent on M1-M2 |
-| 6-month deadline | Finished manuscript | Aug 31, 2026 |
-
-## Escalation History
-
-| # | Date | Action | Result |
-|---|------|--------|--------|
-| 1 | Mar 1 | Schedule proposal created | No calendar blocks set |
-| 2 | Mar 5 | Escalation — reduced to 4 calendar events | No action |
-| 3 | Mar 6 | Escalation — reduced to 1 Saturday block | No action |
-| 4 | Mar 13 | Moved to someday after 12 days, 0 progress | — |
-| 5 | Mar 14 | Reactivated — user confirmed sessions started | — |
-| 6 | Mar 20 | Project review — marked HEALTHY, check-in created | — |
-| 7 | Mar 27 | **This check** — Mar 24 deadline missed, no update | Pending |
-
-## Recommendation
-
-**Adopt lighter-touch tracking, not another escalation cycle.**
-
-The previous escalation pattern (4 escalations in 12 days, Mar 1-13) created friction without producing results. The user reactivated the project themselves on Mar 14, indicating genuine interest. The issue is visibility, not motivation.
-
-**Proposed next steps:**
-1. **At next weekly review (or daily briefing interaction)**: Ask a single question — "How are Saturday writing sessions going?" Don't frame it as an escalation.
-2. **If sessions are happening**: Help set up PortOS goals tracking so progress is passively visible to CoS without requiring explicit check-ins.
-3. **If sessions have stalled again**: Discuss at next review whether to move back to someday. Two stall cycles on the same project is a clear signal about current bandwidth.
-4. **Do not create additional automated escalation tasks** — the daily briefing already flags the overdue status. Adding more tasks just generates noise.
-
-## Pattern Recognition
-
-This project follows a common pattern for creative/personal projects managed by CoS:
-- High initial enthusiasm (detailed 6-month plan with milestones)
-- Execution requires sustained human discipline (no tech can automate writing)
-- CoS can track but cannot drive — over-tracking creates guilt/avoidance, not momentum
-- The right CoS posture is: passive visibility (goals dashboard) + gentle periodic check-in, not active escalation
diff --git a/server/services/dataManager.js b/server/services/dataManager.js
index 549c40e20d..88a6e8d1e2 100644
--- a/server/services/dataManager.js
+++ b/server/services/dataManager.js
@@ -1,10 +1,10 @@
import { readdir, stat, rm, mkdir, writeFile as fsWriteFile } from 'fs/promises';
import { join, relative } from 'path';
import { existsSync } from 'fs';
-import { exec } from 'child_process';
+import { execFile } from 'child_process';
import { promisify } from 'util';
-const execAsync = promisify(exec);
+const execFileAsync = promisify(execFile);
const DATA_DIR = join(process.cwd(), 'data');
const CATEGORIES = {
@@ -36,11 +36,16 @@ const SAFE_NAME = /^[a-z0-9_-]+$/;
async function getDirSizeAndCount(dirPath) {
if (!existsSync(dirPath)) return { size: 0, fileCount: 0 };
const [duOut, findOut] = await Promise.all([
- execAsync(`du -sk "${dirPath}" 2>/dev/null || echo "0"`, { windowsHide: true }).then(r => r.stdout.trim()),
- execAsync(`find "${dirPath}" -type f 2>/dev/null | wc -l`, { windowsHide: true }).then(r => r.stdout.trim())
+ execFileAsync('du', ['-sk', dirPath], { windowsHide: true })
+ .then(r => r.stdout.trim())
+ .catch(() => '0'),
+ execFileAsync('find', [dirPath, '-type', 'f'], { windowsHide: true })
+ .then(r => r.stdout.trim().split('\n').filter(Boolean).length)
+ .catch(() => 0)
]);
- const kb = parseInt(duOut.split('\t')[0], 10) || 0;
- return { size: kb * 1024, fileCount: parseInt(findOut, 10) || 0 };
+ const kb = typeof duOut === 'string' ? (parseInt(duOut.split('\t')[0], 10) || 0) : 0;
+ const fileCount = typeof findOut === 'number' ? findOut : (parseInt(findOut, 10) || 0);
+ return { size: kb * 1024, fileCount };
}
export async function getDataOverview() {
@@ -133,7 +138,7 @@ export async function archiveCategory(categoryKey, options = {}) {
// Write file list to temp file to avoid shell argument limits
const listPath = join(backupDir, `.filelist-${Date.now()}.txt`);
await fsWriteFile(listPath, oldFiles.join('\n'));
- await execAsync(`tar -czf "${archivePath}" -C "${dirPath}" -T "${listPath}"`, { timeout: 120000, windowsHide: true });
+ await execFileAsync('tar', ['-czf', archivePath, '-C', dirPath, '-T', listPath], { timeout: 120000, windowsHide: true });
await rm(listPath).catch(() => {});
for (const f of oldFiles) {
@@ -145,7 +150,7 @@ export async function archiveCategory(categoryKey, options = {}) {
}
// Generic: archive entire category contents
- await execAsync(`tar -czf "${archivePath}" -C "${DATA_DIR}" "${categoryKey}"`, { timeout: 120000, windowsHide: true });
+ await execFileAsync('tar', ['-czf', archivePath, '-C', DATA_DIR, categoryKey], { timeout: 120000, windowsHide: true });
const archiveStat = await stat(archivePath).catch(() => null);
return {
diff --git a/server/services/dataSync.js b/server/services/dataSync.js
index 4a3d0cf245..4f3dbb6f91 100644
--- a/server/services/dataSync.js
+++ b/server/services/dataSync.js
@@ -102,7 +102,7 @@ function mergeDeepUnion(local, remote, timestampField = 'derivedAt') {
// Skip timestamp fields — set after merge
if (key === timestampField) continue;
- // Nested objects (markers): union keys, remote wins per-key conflicts
+ // Nested objects (markers): union keys, local wins per-key conflicts
if (remoteVal && typeof remoteVal === 'object' && !Array.isArray(remoteVal)
&& localVal && typeof localVal === 'object' && !Array.isArray(localVal)) {
const mergedObj = { ...localVal };
diff --git a/server/services/git.js b/server/services/git.js
index cf5c8a3a5e..af67392c5a 100644
--- a/server/services/git.js
+++ b/server/services/git.js
@@ -589,10 +589,11 @@ export function hasChangelogDir(dir) {
*/
async function popStashSafely(dir) {
const result = await execGit(['stash', 'pop'], dir, { ignoreExitCode: true });
- if (result.stderr?.includes('CONFLICT')) {
+ const output = `${result.stdout || ''} ${result.stderr || ''}`;
+ if (output.includes('CONFLICT') || result.exitCode !== 0) {
await execGit(['checkout', '--', '.'], dir, { ignoreExitCode: true });
await execGit(['stash', 'drop'], dir, { ignoreExitCode: true });
- return { conflict: true, stderr: result.stderr };
+ return { conflict: true, stderr: result.stderr || '' };
}
return { conflict: false, stderr: '' };
}
diff --git a/server/services/identity.js b/server/services/identity.js
index 6b91d51108..1b1cf58f0d 100644
--- a/server/services/identity.js
+++ b/server/services/identity.js
@@ -660,59 +660,76 @@ export async function getEnergySchedule() {
const parseTime = (str) => {
const [h, m] = (str || '').split(':').map(Number);
- return h * 60 + (m || 0);
+ const mins = h * 60 + (m || 0);
+ return Number.isFinite(mins) && mins >= 0 && mins <= 1440 ? mins : NaN;
};
+ const validMinutes = (...vals) => vals.every(v => Number.isFinite(v));
+
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 });
+ if (validMinutes(wake)) {
+ 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)) {
+ if (validMinutes(exStart, exEnd) && exEnd >= exStart) {
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
- });
+ const start = parseTime(rec.peakFocusStart);
+ const end = parseTime(rec.peakFocusEnd);
+ if (validMinutes(start, end) && end >= start) {
+ zones.push({
+ id: 'peak-focus',
+ label: 'Peak Focus',
+ startMin: start,
+ endMin: end,
+ 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 });
+ if (validMinutes(cutoff)) {
+ 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 });
+ if (validMinutes(meal)) {
+ 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
- });
+ const windStart = parseTime(rec.windDownStart);
+ const windEnd = parseTime(rec.sleepTime);
+ if (validMinutes(windStart, windEnd) && windEnd >= windStart) {
+ zones.push({
+ id: 'wind-down',
+ label: 'Wind Down',
+ startMin: windStart,
+ endMin: windEnd,
+ color: '#8b5cf6',
+ opacity: 0.10
+ });
+ }
}
return {
@@ -1450,6 +1467,7 @@ Respond with JSON only (no markdown fences). The response must be an object with
createdAt: new Date().toISOString()
};
+ if (!Array.isArray(goal.checkIns)) goal.checkIns = [];
goal.checkIns.push(checkIn);
goal.updatedAt = new Date().toISOString();
goals.updatedAt = new Date().toISOString();
diff --git a/server/services/worktreeManager.js b/server/services/worktreeManager.js
index eb98acf9c5..c0005636ab 100644
--- a/server/services/worktreeManager.js
+++ b/server/services/worktreeManager.js
@@ -131,6 +131,7 @@ export async function removeWorktree(agentId, sourceWorkspace, branchName, optio
}
let merged = false;
+ let commitsAhead = 0;
if (options.merge) {
const currentBranch = (await execGit(
@@ -138,12 +139,12 @@ export async function removeWorktree(agentId, sourceWorkspace, branchName, optio
sourceWorkspace
)).trim();
- const aheadCount = (await execGit(
+ commitsAhead = parseInt((await execGit(
['rev-list', '--count', `${currentBranch}..${branchName}`],
sourceWorkspace
- ).catch(() => '0')).trim();
+ ).catch(() => '0')).trim(), 10) || 0;
- if (parseInt(aheadCount, 10) > 0) {
+ if (commitsAhead > 0) {
await execGit(['merge', branchName, '--no-edit'], sourceWorkspace)
.then(() => { merged = true; })
.catch(async (err) => {
@@ -165,14 +166,15 @@ export async function removeWorktree(agentId, sourceWorkspace, branchName, optio
});
});
- const shouldDeleteBranch = merged || !options.merge;
- if (shouldDeleteBranch) {
+ // Only preserve branch when merge was attempted, failed, and there were unmerged commits
+ const hasUnmergedCommits = options.merge && !merged && commitsAhead > 0;
+ if (hasUnmergedCommits) {
+ console.log(`⚠️ Preserving branch ${branchName} — merge failed, commits need manual recovery`);
+ } else {
await execGit(['branch', '-D', branchName], sourceWorkspace)
.catch(err => {
console.log(`⚠️ Branch delete failed for ${branchName}: ${err.message}`);
});
- } else {
- console.log(`⚠️ Preserving branch ${branchName} — merge failed, commits need manual recovery`);
}
console.log(`🌳 Removed worktree for ${agentId}${merged ? ' (merged)' : ''}`);