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

fix: address release review — hooks violation, null guards, missing catch handlers

Adam Eivyd57bb8be38ea
diff --git a/client/src/components/goals/GoalDetailPanel.jsx b/client/src/components/goals/GoalDetailPanel.jsx
index 797e969fe5..60030bcbf0 100644
--- a/client/src/components/goals/GoalDetailPanel.jsx
+++ b/client/src/components/goals/GoalDetailPanel.jsx
@@ -38,7 +38,7 @@ export default function GoalDetailPanel({ goal, allGoals, onClose, onRefresh })
const [selectedActivity, setSelectedActivity] = useState('');
useEffect(() => {
- api.getActivities().then(setActivities);
+ api.getActivities().then(setActivities).catch(() => {});
}, []);
if (!goal) return null;
diff --git a/client/src/components/meatspace/post/MemoryPractice.jsx b/client/src/components/meatspace/post/MemoryPractice.jsx
index 69cec69eb2..987bcae492 100644
--- a/client/src/components/meatspace/post/MemoryPractice.jsx
+++ b/client/src/components/meatspace/post/MemoryPractice.jsx
@@ -1,4 +1,4 @@
-import { useState, useRef, useEffect } from 'react';
+import { useState, useRef, useEffect, useMemo } from 'react';
import { ChevronLeft, Play, Check, X, SkipForward, RotateCcw, Target, ChevronDown } from 'lucide-react';
import { submitMemoryPractice, getChunkMastery } from '../../../services/api';
@@ -419,19 +419,23 @@ export default function MemoryPractice({ item, onBack, onComplete }) {
);
}
- // FILL-IN-THE-BLANK mode
+ // FILL-IN-THE-BLANK mode — compute blanks outside conditional to respect Rules of Hooks
+ const fillBlankLine = mode === 'fill-blank' ? lines[currentIdx] : null;
+ const fillBlankWords = fillBlankLine?.text.split(/\s+/) || [];
+ // Blank out ~40% of words — recompute when line changes
+ const blanks = useMemo(() => {
+ if (!fillBlankWords.length) return new Set();
+ const blankSet = new Set();
+ const count = Math.max(1, Math.floor(fillBlankWords.length * 0.4));
+ while (blankSet.size < count && blankSet.size < fillBlankWords.length) {
+ blankSet.add(Math.floor(Math.random() * fillBlankWords.length));
+ }
+ return blankSet;
+ }, [currentIdx, mode, fillBlankWords.length]);
+
if (mode === 'fill-blank') {
- const line = lines[currentIdx];
- const words = line?.text.split(/\s+/) || [];
- // Blank out ~40% of words
- const [blanks] = useState(() => {
- const blankSet = new Set();
- const count = Math.max(1, Math.floor(words.length * 0.4));
- while (blankSet.size < count && blankSet.size < words.length) {
- blankSet.add(Math.floor(Math.random() * words.length));
- }
- return blankSet;
- });
+ const line = fillBlankLine;
+ const words = fillBlankWords;
const blankWords = [...blanks].sort((a, b) => a - b).map(i => words[i]?.replace(/[,.]$/, ''));
const displayText = words.map((w, i) => blanks.has(i) ? '____' : w).join(' ');
diff --git a/server/routes/apps.js b/server/routes/apps.js
index 4a2bee28ec..f2df7ae4c3 100644
--- a/server/routes/apps.js
+++ b/server/routes/apps.js
@@ -13,6 +13,7 @@ import { z } from 'zod';
import { validateRequest, appSchema, appUpdateSchema } from '../lib/validation.js';
import * as git from '../services/git.js';
import { asyncHandler, ServerError } from '../lib/errorHandler.js';
+import { safeJSONParse } from '../lib/fileUtils.js';
import { parseEcosystemFromPath } from '../services/streamingDetect.js';
const router = Router();
@@ -650,8 +651,8 @@ router.post('/:id/refresh-config', loadApp, asyncHandler(async (req, res) => {
const pkgPath = join(app.repoPath, 'package.json');
const pkgContent = await readFile(pkgPath, 'utf-8').catch(() => null);
if (pkgContent) {
- const pkg = JSON.parse(pkgContent);
- if (pkg.scripts?.build) updates.buildCommand = 'npm run build';
+ const pkg = safeJSONParse(pkgContent);
+ if (pkg?.scripts?.build) updates.buildCommand = 'npm run build';
}
}
diff --git a/server/routes/cos.js b/server/routes/cos.js
index 68cd19758a..9daf09909e 100644
--- a/server/routes/cos.js
+++ b/server/routes/cos.js
@@ -1046,11 +1046,11 @@ router.get('/actionable-insights', asyncHandler(async (req, res) => {
cos.getAllTasks().catch(err => { console.error(`❌ Failed to load tasks: ${err.message}`); return { user: null, cos: null }; }),
taskLearning.getLearningInsights().catch(err => { console.error(`❌ Failed to load learning insights: ${err.message}`); return null; }),
cos.runHealthCheck().catch(err => { console.error(`❌ Failed to run health check: ${err.message}`); return { issues: [] }; }),
- import('../services/notifications.js'),
+ import('../services/notifications.js').catch(err => { console.error(`❌ Failed to load notifications: ${err.message}`); return null; }),
productivity.getOptimalTimeInfo().catch(() => ({ hasData: false }))
]);
- const notificationsData = await notificationsModule.getNotifications({ unreadOnly: true, limit: 10 }).catch(() => []);
+ const notificationsData = notificationsModule ? await notificationsModule.getNotifications({ unreadOnly: true, limit: 10 }).catch(() => []) : [];
const insights = [];
diff --git a/server/routes/messages.js b/server/routes/messages.js
index 6b7fca99bc..247aceb5a1 100644
--- a/server/routes/messages.js
+++ b/server/routes/messages.js
@@ -269,7 +269,7 @@ router.post('/drafts/:id/send', asyncHandler(async (req, res) => {
const io = req.app.get('io');
const result = await messageSender.sendDraft(req.params.id, io);
if (!result.success) {
- return res.status(result.status).json({ code: result.code, error: result.error });
+ return res.status(result.status || 500).json({ code: result.code, error: result.error });
}
res.json(result);
}));