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: resolve code quality findings across server and client

Adam Eivy1c3af9b9aa75
diff --git a/client/src/hooks/useTheme.js b/client/src/hooks/useTheme.js
index 1a1e144119..c3e9cc63dc 100644
--- a/client/src/hooks/useTheme.js
+++ b/client/src/hooks/useTheme.js
@@ -120,7 +120,7 @@ export default function useTheme() {
setThemeId(serverTheme);
}
})
- .catch(() => {}); // Server unreachable — use localStorage fallback
+ .catch(() => console.log('⚠️ Theme fetch failed, using localStorage fallback'));
}, []); // eslint-disable-line react-hooks/exhaustive-deps
const setTheme = useCallback((id) => {
@@ -133,7 +133,7 @@ export default function useTheme() {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ theme: id }),
- }).catch(() => {});
+ }).catch(() => console.warn('⚠️ Theme sync to server failed'));
}, []);
return { themeId, theme: THEMES[themeId], themes: THEMES, setTheme };
diff --git a/client/src/pages/Settings.jsx b/client/src/pages/Settings.jsx
index aa2d73c2d1..31a7c62bdf 100644
--- a/client/src/pages/Settings.jsx
+++ b/client/src/pages/Settings.jsx
@@ -20,14 +20,14 @@ export default function Settings() {
setEnabled(backup.enabled ?? false);
setCronExpression(backup.cronExpression || '0 2 * * *');
setExcludePaths(backup.excludePaths || []);
- }).catch(() => {}).finally(() => setLoading(false));
+ }).catch(() => toast.error('Failed to load settings')).finally(() => setLoading(false));
}, []);
const handleSave = async () => {
setSaving(true);
await updateSettings({ backup: { destPath, enabled, cronExpression, excludePaths } })
.then(() => toast.success('Settings saved'))
- .catch(() => {})
+ .catch(() => toast.error('Failed to save settings'))
.finally(() => setSaving(false));
};
diff --git a/server/lib/db.js b/server/lib/db.js
index ba0056324d..a19b88d9b0 100644
--- a/server/lib/db.js
+++ b/server/lib/db.js
@@ -85,6 +85,7 @@ export async function checkHealth() {
const { has_memories, has_links, has_sync } = result.rows[0];
return { connected: true, hasSchema: has_memories && has_links && has_sync };
} catch (err) {
+ console.error(`🗄️ Database health check failed: ${err.message}`);
return { connected: false, hasSchema: false, error: err.message };
}
}
diff --git a/server/services/mediaService.js b/server/services/mediaService.js
index 2cd96b57ee..5abd6bd000 100644
--- a/server/services/mediaService.js
+++ b/server/services/mediaService.js
@@ -1,188 +1,192 @@
import { spawn } from 'child_process';
import { PassThrough } from 'stream';
-class MediaService {
- constructor() {
- this.videoProcess = null;
- this.audioProcess = null;
- this.videoStream = null;
- this.audioStream = null;
- this.devices = {
- video: [],
- audio: []
- };
- }
-
- async listDevices() {
- return new Promise((resolve, reject) => {
- const ffmpeg = spawn('ffmpeg', [
- '-f', 'avfoundation',
- '-list_devices', 'true',
- '-i', ''
- ]);
-
- let output = '';
-
- ffmpeg.stderr.on('data', (data) => {
- output += data.toString();
- });
-
- ffmpeg.on('close', () => {
- const videoDevices = [];
- const audioDevices = [];
-
- const lines = output.split('\n');
- let inVideoSection = false;
- let inAudioSection = false;
-
- for (const line of lines) {
- if (line.includes('AVFoundation video devices:')) {
- inVideoSection = true;
- inAudioSection = false;
- continue;
- }
- if (line.includes('AVFoundation audio devices:')) {
- inVideoSection = false;
- inAudioSection = true;
- continue;
- }
-
- const match = line.match(/\[(\d+)\] (.+)/);
- if (match) {
- const [, id, name] = match;
- if (inVideoSection && !name.includes('Capture screen')) {
- videoDevices.push({ id, name: name.trim() });
- } else if (inAudioSection) {
- audioDevices.push({ id, name: name.trim() });
- }
- }
- }
+let videoProcess = null;
+let audioProcess = null;
+let videoStream = null;
+let audioStream = null;
+let devices = { video: [], audio: [] };
+
+async function listDevices() {
+ return new Promise((resolve, reject) => {
+ const ffmpeg = spawn('ffmpeg', [
+ '-f', 'avfoundation',
+ '-list_devices', 'true',
+ '-i', ''
+ ]);
- this.devices = { video: videoDevices, audio: audioDevices };
- resolve(this.devices);
- });
+ let output = '';
- ffmpeg.on('error', reject);
+ ffmpeg.stderr.on('data', (data) => {
+ output += data.toString();
});
- }
- startVideoStream(deviceId = '0') {
- if (!/^\d+$/.test(deviceId)) throw new Error('Invalid device ID');
- if (this.videoProcess) {
- this.stopVideoStream();
- }
+ ffmpeg.on('close', () => {
+ const videoDevices = [];
+ const audioDevices = [];
- this.videoStream = new PassThrough();
+ const lines = output.split('\n');
+ let inVideoSection = false;
+ let inAudioSection = false;
- // Use MJPEG format for compatibility and low latency
- this.videoProcess = spawn('ffmpeg', [
- '-f', 'avfoundation',
- '-video_size', '1280x720',
- '-framerate', '30',
- '-i', `${deviceId}:none`,
- '-f', 'mjpeg',
- '-q:v', '5',
- '-'
- ]);
-
- this.videoProcess.stdout.pipe(this.videoStream);
+ for (const line of lines) {
+ if (line.includes('AVFoundation video devices:')) {
+ inVideoSection = true;
+ inAudioSection = false;
+ continue;
+ }
+ if (line.includes('AVFoundation audio devices:')) {
+ inVideoSection = false;
+ inAudioSection = true;
+ continue;
+ }
- this.videoProcess.stderr.on('data', (data) => {
- const msg = data.toString();
- if (!msg.includes('frame=') && !msg.includes('fps=')) {
- console.log(`📹 FFmpeg video: ${msg.trim()}`);
+ const match = line.match(/\[(\d+)\] (.+)/);
+ if (match) {
+ const [, id, name] = match;
+ if (inVideoSection && !name.includes('Capture screen')) {
+ videoDevices.push({ id, name: name.trim() });
+ } else if (inAudioSection) {
+ audioDevices.push({ id, name: name.trim() });
+ }
+ }
}
- });
- this.videoProcess.on('error', (err) => {
- console.error(`❌ Video stream error: ${err.message}`);
+ devices = { video: videoDevices, audio: audioDevices };
+ resolve(devices);
});
- this.videoProcess.on('close', () => {
- console.log('📹 Video stream stopped');
- this.videoStream = null;
- });
+ ffmpeg.on('error', reject);
+ });
+}
- return this.videoStream;
+function startVideoStream(deviceId = '0') {
+ if (!/^\d+$/.test(deviceId)) throw new Error('Invalid device ID');
+ if (videoProcess) {
+ stopVideoStream();
}
- startAudioStream(deviceId = '0') {
- if (!/^\d+$/.test(deviceId)) throw new Error('Invalid device ID');
- if (this.audioProcess) {
- this.stopAudioStream();
+ videoStream = new PassThrough();
+
+ // Use MJPEG format for compatibility and low latency
+ videoProcess = spawn('ffmpeg', [
+ '-f', 'avfoundation',
+ '-video_size', '1280x720',
+ '-framerate', '30',
+ '-i', `${deviceId}:none`,
+ '-f', 'mjpeg',
+ '-q:v', '5',
+ '-'
+ ]);
+
+ videoProcess.stdout.pipe(videoStream);
+
+ videoProcess.stderr.on('data', (data) => {
+ const msg = data.toString();
+ if (!msg.includes('frame=') && !msg.includes('fps=')) {
+ console.log(`📹 FFmpeg video: ${msg.trim()}`);
}
+ });
- this.audioStream = new PassThrough();
+ videoProcess.on('error', (err) => {
+ console.error(`❌ Video stream error: ${err.message}`);
+ });
- // Use WebM format with Opus codec for web compatibility
- this.audioProcess = spawn('ffmpeg', [
- '-f', 'avfoundation',
- '-i', `:${deviceId}`,
- '-f', 'webm',
- '-acodec', 'libopus',
- '-ac', '1',
- '-ar', '48000',
- '-b:a', '128k',
- '-'
- ]);
+ videoProcess.on('close', () => {
+ console.log('📹 Video stream stopped');
+ videoStream = null;
+ });
- this.audioProcess.stdout.pipe(this.audioStream);
+ return videoStream;
+}
- this.audioProcess.stderr.on('data', (data) => {
- const msg = data.toString();
- if (!msg.includes('frame=') && !msg.includes('size=')) {
- console.log(`🎤 FFmpeg audio: ${msg.trim()}`);
- }
- });
+function startAudioStream(deviceId = '0') {
+ if (!/^\d+$/.test(deviceId)) throw new Error('Invalid device ID');
+ if (audioProcess) {
+ stopAudioStream();
+ }
- this.audioProcess.on('error', (err) => {
- console.error(`❌ Audio stream error: ${err.message}`);
- });
+ audioStream = new PassThrough();
+
+ // Use WebM format with Opus codec for web compatibility
+ audioProcess = spawn('ffmpeg', [
+ '-f', 'avfoundation',
+ '-i', `:${deviceId}`,
+ '-f', 'webm',
+ '-acodec', 'libopus',
+ '-ac', '1',
+ '-ar', '48000',
+ '-b:a', '128k',
+ '-'
+ ]);
+
+ audioProcess.stdout.pipe(audioStream);
+
+ audioProcess.stderr.on('data', (data) => {
+ const msg = data.toString();
+ if (!msg.includes('frame=') && !msg.includes('size=')) {
+ console.log(`🎤 FFmpeg audio: ${msg.trim()}`);
+ }
+ });
- this.audioProcess.on('close', () => {
- console.log('🎤 Audio stream stopped');
- this.audioStream = null;
- });
+ audioProcess.on('error', (err) => {
+ console.error(`❌ Audio stream error: ${err.message}`);
+ });
- return this.audioStream;
- }
+ audioProcess.on('close', () => {
+ console.log('🎤 Audio stream stopped');
+ audioStream = null;
+ });
- stopVideoStream() {
- if (this.videoProcess) {
- this.videoProcess.kill('SIGTERM');
- this.videoProcess = null;
- this.videoStream = null;
- }
- }
+ return audioStream;
+}
- stopAudioStream() {
- if (this.audioProcess) {
- this.audioProcess.kill('SIGTERM');
- this.audioProcess = null;
- this.audioStream = null;
- }
+function stopVideoStream() {
+ if (videoProcess) {
+ videoProcess.kill('SIGTERM');
+ videoProcess = null;
+ videoStream = null;
}
+}
- stopAll() {
- this.stopVideoStream();
- this.stopAudioStream();
+function stopAudioStream() {
+ if (audioProcess) {
+ audioProcess.kill('SIGTERM');
+ audioProcess = null;
+ audioStream = null;
}
+}
- isVideoStreaming() {
- return this.videoProcess !== null && this.videoStream !== null;
- }
+function stopAll() {
+ stopVideoStream();
+ stopAudioStream();
+}
- isAudioStreaming() {
- return this.audioProcess !== null && this.audioStream !== null;
- }
+function isVideoStreaming() {
+ return videoProcess !== null && videoStream !== null;
+}
- getVideoStream() {
- return this.videoStream;
- }
+function isAudioStreaming() {
+ return audioProcess !== null && audioStream !== null;
+}
- getAudioStream() {
- return this.audioStream;
- }
+function getVideoStream() {
+ return videoStream;
+}
+
+function getAudioStream() {
+ return audioStream;
}
-export default new MediaService();
+export default {
+ listDevices,
+ startVideoStream,
+ startAudioStream,
+ stopVideoStream,
+ stopAudioStream,
+ stopAll,
+ isVideoStreaming,
+ isAudioStreaming,
+ getVideoStream,
+ getAudioStream,
+};
diff --git a/server/services/runner.js b/server/services/runner.js
index 0769122146..bdaca77d44 100644
--- a/server/services/runner.js
+++ b/server/services/runner.js
@@ -137,7 +137,7 @@ export async function executeCliRun(runId, provider, prompt, workspacePath, onDa
const metadataStr = await readFile(metadataPath, 'utf-8').catch(() => '{}');
let metadata = {};
- try { metadata = JSON.parse(metadataStr); } catch { /* corrupted metadata, start fresh */ }
+ try { metadata = JSON.parse(metadataStr); } catch { console.log('⚠️ Corrupted metadata for run, using fresh'); }
metadata.endTime = new Date().toISOString();
metadata.duration = Date.now() - startTime;
metadata.exitCode = code;