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
address review: validate backup destPath, bound command output, guard keyboard nav, validate XML numerics, add stream error handler, fix alcohol 0-as-falsy
Adam Eivyeadc3c4e79de
diff --git a/client/src/components/CmdKSearch.jsx b/client/src/components/CmdKSearch.jsxindex 817bfd6e09..6d6464e11d 100644--- a/client/src/components/CmdKSearch.jsx+++ b/client/src/components/CmdKSearch.jsx@@ -101,10 +101,10 @@ export default function CmdKSearch() {const handleKeyDown = (e) => {if (e.key === 'ArrowDown') {e.preventDefault();- setFocusedIndex(i => Math.min(i + 1, flatResults.length - 1));+ if (flatResults.length > 0) setFocusedIndex(i => Math.min(i + 1, flatResults.length - 1));} else if (e.key === 'ArrowUp') {e.preventDefault();- setFocusedIndex(i => Math.max(i - 1, 0));+ if (flatResults.length > 0) setFocusedIndex(i => Math.max(i - 1, 0));} else if (e.key === 'Enter') {const item = flatResults[focusedIndex];if (item) handleNavigate(item.url);diff --git a/server/package-lock.json b/server/package-lock.jsonindex 6d86c6325e..00b4371ee6 100644--- a/server/package-lock.json+++ b/server/package-lock.json@@ -1,12 +1,12 @@{"name": "portos-server",- "version": "1.7.0",+ "version": "1.7.1","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "portos-server",- "version": "1.7.0",+ "version": "1.7.1","dependencies": {"axios": "^1.7.9","cors": "^2.8.5",diff --git a/server/package.json b/server/package.jsonindex 0c01d41970..4e30d7249b 100644--- a/server/package.json+++ b/server/package.json@@ -1,6 +1,6 @@{"name": "portos-server",- "version": "1.7.0",+ "version": "1.7.1","private": true,"type": "module","scripts": {diff --git a/server/routes/backup.js b/server/routes/backup.jsindex cfa22f705a..d87def856e 100644--- a/server/routes/backup.js+++ b/server/routes/backup.js@@ -17,8 +17,12 @@ router.get('/status', asyncHandler(async (req, res) => {// POST /api/backup/runrouter.post('/run', asyncHandler(async (req, res) => {const settings = await getSettings();+ const destPath = settings.backup?.destPath;+ if (!destPath) {+ return res.status(400).json({ error: 'BACKUP_NOT_CONFIGURED', message: 'No backup destination configured in settings' });+ }const io = req.app.get('io');- const result = await backup.runBackup(settings.backup?.destPath, io);+ const result = await backup.runBackup(destPath, io);res.json(result);}));diff --git a/server/services/appUpdater.js b/server/services/appUpdater.jsindex c8be281e55..57a878218e 100644--- a/server/services/appUpdater.js+++ b/server/services/appUpdater.js@@ -8,13 +8,21 @@ import * as pm2Service from './pm2.js';/*** Run a command and return stdout/stderr*/+const MAX_OUTPUT_BYTES = 64 * 1024; // 64KB tail per stream+function runCommand(cmd, args, cwd) {return new Promise((resolve, reject) => {const child = spawn(cmd, args, { cwd, shell: false, windowsHide: true });let stdout = '';let stderr = '';- child.stdout.on('data', d => stdout += d);- child.stderr.on('data', d => stderr += d);+ child.stdout.on('data', d => {+ stdout += d;+ if (stdout.length > MAX_OUTPUT_BYTES) stdout = stdout.slice(-MAX_OUTPUT_BYTES);+ });+ child.stderr.on('data', d => {+ stderr += d;+ if (stderr.length > MAX_OUTPUT_BYTES) stderr = stderr.slice(-MAX_OUTPUT_BYTES);+ });child.on('close', code => {if (code !== 0) reject(new Error(stderr.trim() || `${cmd} exited with code ${code}`));else resolve({ stdout, stderr });diff --git a/server/services/appleHealthQuery.js b/server/services/appleHealthQuery.jsindex 400f7a0dc4..cfbfc9cc5a 100644--- a/server/services/appleHealthQuery.js+++ b/server/services/appleHealthQuery.js@@ -210,7 +210,7 @@ export async function getCorrelationData(from, to) {.map(date => ({date,hrv: hrvByDate.get(date) ?? null,- alcoholGrams: alcoholByDate.get(date)+ alcoholGrams: alcoholByDate.get(date) != null? Math.round(alcoholByDate.get(date) * 14 * 100) / 100 // std drinks to grams: null,steps: stepsByDate.get(date) ?? nulldiff --git a/server/services/appleHealthXml.js b/server/services/appleHealthXml.jsindex a6f0124503..db17834ef3 100644--- a/server/services/appleHealthXml.js+++ b/server/services/appleHealthXml.js@@ -71,9 +71,11 @@ export function normalizeXmlRecord(node) {// Heart rate: include end timestampif (typeLower === 'hkquantitytypeidentifierheartrate') {+ const parsed = parseFloat(value);+ if (!Number.isFinite(parsed)) return null;const dataPoint = {date: startdate,- qty: parseFloat(value),+ qty: parsed,unit: unit ?? null,src: sourcename ?? null,end: enddate ?? null,@@ -82,9 +84,11 @@ export function normalizeXmlRecord(node) {}// All other numeric types+ const parsed = parseFloat(value);+ if (!Number.isFinite(parsed)) return null;const dataPoint = {date: startdate,- qty: parseFloat(value),+ qty: parsed,unit: unit ?? null,src: sourcename ?? null,};@@ -179,13 +183,18 @@ export async function importAppleHealthXml(filePath, io = null) {saxStream.on('end', resolve);saxStream.on('close', resolve);- createReadStream(filePath).pipe(saxStream);+ const readStream = createReadStream(filePath);+ readStream.on('error', reject);+ readStream.pipe(saxStream);});console.log(`🍎 XML parsing done: ${processedRecords} raw records across ${Object.keys(dayBuckets).length} days — starting aggregation`);- // === Post-parse aggregation (outside SAX event loop) ===- for (const dateStr of Object.keys(dayBuckets)) {+ // === Aggregate and write day files, freeing each bucket after write ===+ const allDates = Object.keys(dayBuckets);+ let daysCount = allDates.length;++ for (const dateStr of allDates) {const metrics = dayBuckets[dateStr];// Aggregate step_count: sum all qty values into single daily total@@ -197,13 +206,8 @@ export async function importAppleHealthXml(filePath, io = null) {if (metrics.sleep_analysis) {metrics.sleep_analysis = aggregateSleepAnalysis(metrics.sleep_analysis);}- }- // === Write day files sequentially ===- const allDates = Object.keys(dayBuckets);- for (const dateStr of allDates) {const dayData = await readDayFile(dateStr);- const metrics = dayBuckets[dateStr];for (const [metricName, newPoints] of Object.entries(metrics)) {const existing = dayData.metrics[metricName] || [];@@ -215,10 +219,9 @@ export async function importAppleHealthXml(filePath, io = null) {}await writeDayFile(dateStr, dayData);+ delete dayBuckets[dateStr];}- const daysCount = allDates.length;-// Clean up temp fileunlink(filePath, () => {});