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 Copilot review — emit operation-specific errors, guard nulls, wire expand buttons

Adam Eivyd2edbc278e3c
diff --git a/client/src/pages/HistoryPage.jsx b/client/src/pages/HistoryPage.jsx
index a70f1f08c2..4744674690 100644
--- a/client/src/pages/HistoryPage.jsx
+++ b/client/src/pages/HistoryPage.jsx
@@ -163,7 +163,12 @@ export function HistoryPage() {
<div className="flex flex-col sm:flex-row sm:items-center gap-2 sm:gap-4">
<div className="flex items-center gap-3 flex-1 min-w-0">
<button
+ type="button"
className="text-gray-400 hover:text-white shrink-0 focus:outline-hidden focus:ring-2 focus:ring-port-accent rounded"
+ onClick={(event) => {
+ event.stopPropagation();
+ toggleExpand(entry.id);
+ }}
aria-expanded={expandedId === entry.id}
aria-label={`${expandedId === entry.id ? 'Collapse' : 'Expand'} ${entry.action} details`}
>
diff --git a/client/src/pages/RunnerPage.jsx b/client/src/pages/RunnerPage.jsx
index 6db8cde26c..43880cffd1 100644
--- a/client/src/pages/RunnerPage.jsx
+++ b/client/src/pages/RunnerPage.jsx
@@ -268,6 +268,7 @@ ${prompt.trim()}`;
onClick={() => setContinueContext(null)}
className="p-1 text-gray-400 hover:text-white"
title="Dismiss context"
+ aria-label="Dismiss context"
>
<X size={16} />
</button>
@@ -423,8 +424,9 @@ ${prompt.trim()}`;
className="w-20 h-20 object-cover rounded-lg border border-port-border"
/>
<button
+ aria-label="Remove screenshot"
onClick={() => removeScreenshot(s.id)}
- className="absolute -top-2 -right-2 w-5 h-5 bg-port-error rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity"
+ className="absolute -top-2 -right-2 w-5 h-5 bg-port-error rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition-opacity"
>
<X size={12} />
</button>
diff --git a/client/src/pages/RunsHistoryPage.jsx b/client/src/pages/RunsHistoryPage.jsx
index 70c899ec50..234141fcb4 100644
--- a/client/src/pages/RunsHistoryPage.jsx
+++ b/client/src/pages/RunsHistoryPage.jsx
@@ -218,7 +218,15 @@ export function RunsHistoryPage() {
>
<div className="flex flex-col sm:flex-row sm:items-center gap-2 sm:gap-4">
<div className="flex items-center gap-3 flex-1 min-w-0">
- <button className="text-gray-400 hover:text-white shrink-0">
+ <button
+ type="button"
+ className="text-gray-400 hover:text-white shrink-0"
+ onClick={(event) => {
+ event.stopPropagation();
+ toggleExpand(run.id);
+ }}
+ aria-label={expandedId === run.id ? 'Collapse run details' : 'Expand run details'}
+ >
<span className={`inline-block transition-transform ${expandedId === run.id ? 'rotate-90' : ''}`}>▶</span>
</button>
<span className="text-xl shrink-0">🤖</span>
diff --git a/client/src/pages/UsagePage.jsx b/client/src/pages/UsagePage.jsx
index 60ed1b786d..992e09eed0 100644
--- a/client/src/pages/UsagePage.jsx
+++ b/client/src/pages/UsagePage.jsx
@@ -19,6 +19,7 @@ export function UsagePage() {
};
const formatNumber = (num) => {
+ if (num == null) return '—';
if (num >= 1000000) return `${(num / 1000000).toFixed(1)}M`;
if (num >= 1000) return `${(num / 1000).toFixed(1)}K`;
return String(num);
@@ -53,11 +54,11 @@ export function UsagePage() {
<div className="text-xs sm:text-sm text-gray-400">Tool Calls</div>
</div>
<div className="bg-port-card border border-port-border rounded-xl p-3 sm:p-4 text-center">
- <div className="text-xl sm:text-2xl font-bold text-white">{formatNumber(usage.totalTokens?.input + usage.totalTokens?.output)}</div>
+ <div className="text-xl sm:text-2xl font-bold text-white">{formatNumber((usage.totalTokens?.input ?? 0) + (usage.totalTokens?.output ?? 0))}</div>
<div className="text-xs sm:text-sm text-gray-400">Tokens</div>
</div>
<div className="bg-port-card border border-port-border rounded-xl p-3 sm:p-4 text-center col-span-2 sm:col-span-1">
- <div className="text-xl sm:text-2xl font-bold text-port-success">${usage.estimatedCost?.toFixed(2)}</div>
+ <div className="text-xl sm:text-2xl font-bold text-port-success">${(usage.estimatedCost ?? 0).toFixed(2)}</div>
<div className="text-xs sm:text-sm text-gray-400">Est. Cost</div>
</div>
</div>
diff --git a/server/services/socket.js b/server/services/socket.js
index 2d4f664771..e1853d538e 100644
--- a/server/services/socket.js
+++ b/server/services/socket.js
@@ -75,82 +75,83 @@ export function initSocket(io) {
// Handle PM2 standardization
socket.on('standardize:start', async (rawData) => {
try {
- const data = validateSocketData(standardizeStartSchema, rawData, socket, 'standardize:start');
- if (!data) return;
- const { repoPath, providerId } = data;
- console.log(`🔧 Starting PM2 standardization: ${repoPath}`);
+ const data = validateSocketData(standardizeStartSchema, rawData, socket, 'standardize:start');
+ if (!data) return;
+ const { repoPath, providerId } = data;
+ console.log(`🔧 Starting PM2 standardization: ${repoPath}`);
- const emit = (step, status, data = {}) => {
- socket.emit('standardize:step', { step, status, data, timestamp: Date.now() });
- };
+ const emit = (step, status, data = {}) => {
+ socket.emit('standardize:step', { step, status, data, timestamp: Date.now() });
+ };
- // Step 1: Analyze
- emit('analyze', 'running', { message: 'Analyzing project configuration...' });
+ // Step 1: Analyze
+ emit('analyze', 'running', { message: 'Analyzing project configuration...' });
- const analysis = await pm2Standardizer.analyzeApp(repoPath, providerId)
- .catch(err => ({ success: false, error: err.message }));
+ const analysis = await pm2Standardizer.analyzeApp(repoPath, providerId)
+ .catch(err => ({ success: false, error: err.message }));
- if (!analysis.success) {
- emit('analyze', 'error', { message: analysis.error });
- socket.emit('standardize:complete', { success: false, error: analysis.error });
- return;
- }
+ if (!analysis.success) {
+ emit('analyze', 'error', { message: analysis.error });
+ socket.emit('standardize:complete', { success: false, error: analysis.error });
+ return;
+ }
- emit('analyze', 'done', {
- message: `Found ${analysis.proposedChanges.processes?.length || 0} processes`,
- processes: analysis.proposedChanges.processes,
- strayPorts: analysis.proposedChanges.strayPorts
- });
+ emit('analyze', 'done', {
+ message: `Found ${analysis.proposedChanges.processes?.length || 0} processes`,
+ processes: analysis.proposedChanges.processes,
+ strayPorts: analysis.proposedChanges.strayPorts
+ });
- socket.emit('standardize:analyzed', { plan: analysis });
+ socket.emit('standardize:analyzed', { plan: analysis });
- // Step 2: Backup
- emit('backup', 'running', { message: 'Creating git backup...' });
+ // Step 2: Backup
+ emit('backup', 'running', { message: 'Creating git backup...' });
- const backup = await pm2Standardizer.createGitBackup(repoPath)
- .catch(err => ({ success: false, reason: err.message }));
+ const backup = await pm2Standardizer.createGitBackup(repoPath)
+ .catch(err => ({ success: false, reason: err.message }));
- if (backup.success) {
- emit('backup', 'done', { message: `Backup branch: ${backup.branch}`, branch: backup.branch });
- } else if (backup.code === 'DIRTY_WORKTREE') {
- emit('backup', 'error', { message: backup.reason });
- socket.emit('standardize:complete', { success: false, error: backup.reason });
- return;
- } else {
- emit('backup', 'skipped', { message: backup.reason || 'No git repository' });
- }
+ if (backup.success) {
+ emit('backup', 'done', { message: `Backup branch: ${backup.branch}`, branch: backup.branch });
+ } else if (backup.code === 'DIRTY_WORKTREE') {
+ emit('backup', 'error', { message: backup.reason });
+ socket.emit('standardize:complete', { success: false, error: backup.reason });
+ return;
+ } else {
+ emit('backup', 'skipped', { message: backup.reason || 'No git repository' });
+ }
- // Step 3: Apply changes
- emit('apply', 'running', { message: 'Writing ecosystem.config.cjs...' });
+ // Step 3: Apply changes
+ emit('apply', 'running', { message: 'Writing ecosystem.config.cjs...' });
- const result = await pm2Standardizer.applyStandardization(repoPath, analysis, { skipBackup: true })
- .catch(err => ({ success: false, errors: [err.message] }));
+ const result = await pm2Standardizer.applyStandardization(repoPath, analysis, { skipBackup: true })
+ .catch(err => ({ success: false, errors: [err.message] }));
- if (result.errors?.length > 0) {
- emit('apply', 'error', { message: result.errors.join(', ') });
- socket.emit('standardize:complete', { success: false, error: result.errors.join(', ') });
- return;
- }
+ if (result.errors?.length > 0) {
+ emit('apply', 'error', { message: result.errors.join(', ') });
+ socket.emit('standardize:complete', { success: false, error: result.errors.join(', ') });
+ return;
+ }
- emit('apply', 'done', {
- message: `Modified ${result.filesModified.length} files`,
- filesModified: result.filesModified
- });
+ emit('apply', 'done', {
+ message: `Modified ${result.filesModified.length} files`,
+ filesModified: result.filesModified
+ });
- // Complete — use backup branch from step 2 since step 3 skips backup
- socket.emit('standardize:complete', {
- success: true,
- result: {
- backupBranch: backup.branch || null,
- filesModified: result.filesModified,
- processes: analysis.proposedChanges.processes
- }
- });
+ // Complete — use backup branch from step 2 since step 3 skips backup
+ socket.emit('standardize:complete', {
+ success: true,
+ result: {
+ backupBranch: backup.branch || null,
+ filesModified: result.filesModified,
+ processes: analysis.proposedChanges.processes
+ }
+ });
- console.log(`✅ Standardization complete: ${result.filesModified.length} files modified`);
+ console.log(`✅ Standardization complete: ${result.filesModified.length} files modified`);
} catch (err) {
console.error(`❌ Socket handler error [standardize:start]: ${err.message}`);
socket.emit('error:server', { message: err.message });
+ socket.emit('standardize:complete', { success: false, error: err.message });
}
});
@@ -340,7 +341,8 @@ export function initSocket(io) {
}
} catch (err) {
console.error(`❌ Socket handler error [app:update]: ${err.message}`);
- socket.emit('error:server', { message: err.message });
+ socket.emit('app:update:error', { message: err.message });
+ socket.emit('app:update:complete', { success: false, steps: [] });
}
});
@@ -413,7 +415,7 @@ export function initSocket(io) {
console.log(`✅ Socket standardize complete for ${app.name}`);
} catch (err) {
console.error(`❌ Socket handler error [app:standardize]: ${err.message}`);
- socket.emit('error:server', { message: err.message });
+ socket.emit('app:standardize:error', { message: err.message });
}
});