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
fix: address round 2 review — restore progress piping, restarting signal, EPIPE guards
Adam Eivy6059afd2d4f8
diff --git a/client/src/components/apps/tabs/UpdateTab.jsx b/client/src/components/apps/tabs/UpdateTab.jsxindex 4e5e1812b9..86cc0ba789 100644--- a/client/src/components/apps/tabs/UpdateTab.jsx+++ b/client/src/components/apps/tabs/UpdateTab.jsx@@ -59,6 +59,13 @@ export default function UpdateTab() {}return [...prev, entry];});+ // When the server signals it's restarting, begin health polling immediately.+ // The PM2 restart may kill the server before portos:update:complete fires.+ if (step === 'restarting' || step === 'restart') {+ setUpdating(false);+ setPolling(true);+ toast.loading('PortOS is restarting...', { id: 'portos-update-restart', duration: Infinity });+ }};const handleComplete = ({ success, newVersion }) => {diff --git a/server/routes/update.js b/server/routes/update.jsindex 72026f8fbc..ebe9644793 100644--- a/server/routes/update.js+++ b/server/routes/update.js@@ -66,6 +66,9 @@ router.post('/execute', asyncHandler(async (req, res) => {// Don't await — respond immediately, progress streams via socketexecuteUpdate(tag, emit).then(result => {+ // Note: this .then() may never fire if the update script's PM2 restart+ // kills this server process first. The client handles this by polling+ // /api/system/health after receiving the 'restarting' step (see below).if (io) {if (result.success) {io.emit('portos:update:complete', { success: true, newVersion: tag.replace(/^v/, '') });@@ -79,6 +82,10 @@ router.post('/execute', asyncHandler(async (req, res) => {}});+ // Emit a restarting step immediately so the client knows to start+ // health polling now, before the PM2 restart kills this process+ emit('restarting', 'running', 'Server will restart momentarily...');+res.json({ started: true, tag });}));diff --git a/server/services/updateExecutor.js b/server/services/updateExecutor.jsindex 9e681b0b61..f96e6f8679 100644--- a/server/services/updateExecutor.js+++ b/server/services/updateExecutor.js@@ -26,12 +26,42 @@ export async function executeUpdate(tag, emit) {return new Promise((resolve) => {const child = spawn('bash', [SCRIPT_PATH, tag], {detached: true,- stdio: 'ignore',+ stdio: ['ignore', 'pipe', 'pipe'],cwd: PATHS.root});let lastStep = 'starting';+ // Parse STEP:name:status:message lines from stdout/stderr streams+ const makeLineHandler = () => {+ let buffer = '';+ return (data) => {+ buffer += data.toString();+ let newlineIdx;+ while ((newlineIdx = buffer.indexOf('\n')) !== -1) {+ const line = buffer.slice(0, newlineIdx);+ buffer = buffer.slice(newlineIdx + 1);+ const match = line.match(/STEP:([^:]+):([^:]+):(.+)/);+ if (match) {+ const [, name, status, message] = match;+ lastStep = name;+ emit(name, status, message);+ }+ }+ };+ };++ // Pipe stdout/stderr for progress tracking, with EPIPE guards+ // in case the parent process exits before the detached child finishes writing+ if (child.stdout) {+ child.stdout.on('error', () => {}); // Swallow EPIPE if parent exits+ child.stdout.on('data', makeLineHandler());+ }+ if (child.stderr) {+ child.stderr.on('error', () => {}); // Swallow EPIPE if parent exits+ child.stderr.on('data', makeLineHandler());+ }+child.on('close', (code) => {const success = code === 0;recordUpdateResult({