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

address review (codex round 2): public-asset builds + fast-restart detection

[._.]/ Adam Eivy1239ab943f59
diff --git a/client/src/components/apps/tabs/UpdateTab.jsx b/client/src/components/apps/tabs/UpdateTab.jsx
index c07224e41a..35a40a2410 100644
--- a/client/src/components/apps/tabs/UpdateTab.jsx
+++ b/client/src/components/apps/tabs/UpdateTab.jsx
@@ -47,6 +47,11 @@ export default function UpdateTab() {
// release bump), so version-change detection alone can't confirm completion —
// a down→up transition does.
const healthWentDownRef = useRef(false);
+ // Highest /system/health uptime seen so far. The server's uptime resets to
+ // ~0 on restart, so an uptime that drops well below the previous peak proves
+ // a restart happened — catching a same-version reconcile whose restart is too
+ // fast for the 2s poll to ever sample the down window.
+ const maxUptimeRef = useRef(0);
const fetchStatus = useCallback(async () => {
const data = await api.getUpdateStatus().catch(() => null);
@@ -138,15 +143,24 @@ export default function UpdateTab() {
toast.success(`Updated to v${ok.version}`, { id: 'portos-update-restart' });
setTimeout(() => window.location.reload(), 1000);
return;
- } else if (healthWentDownRef.current && ok.version) {
- // Came back up after a confirmed down→up dip at the same version — a
- // reconcile (no release bump). The restart succeeded; reload to pick up
- // the freshly built client.
+ } else if (
+ ok.version &&
+ (healthWentDownRef.current ||
+ (typeof ok.uptime === 'number' && ok.uptime < maxUptimeRef.current - 5))
+ ) {
+ // Same version, but the restart is proven either by a down→up dip or by
+ // the server's uptime resetting below its pre-restart peak (the 5s slack
+ // absorbs clock jitter). Catches a reconcile whose restart was too fast
+ // for the 2s poll to ever sample the down window.
setPolling(false);
toast.success('Install reconciled — reloading', { id: 'portos-update-restart' });
setTimeout(() => window.location.reload(), 1000);
return;
}
+ // Track the running peak so a later uptime drop is detectable.
+ if (typeof ok.uptime === 'number' && ok.uptime > maxUptimeRef.current) {
+ maxUptimeRef.current = ok.uptime;
+ }
if (attemptsRef.current >= 30) {
setPolling(false);
toast.error('Restart timed out — try reloading manually', { id: 'portos-update-restart' });
@@ -172,6 +186,11 @@ export default function UpdateTab() {
targetVersionRef.current = s.latestRelease.version;
}
preUpdateVersionRef.current = s?.currentVersion || null;
+ // Seed the uptime peak with the still-running server's uptime, so even an
+ // instant restart (whose first post-restart poll already reports a small
+ // uptime) is detected as a drop below this pre-update value.
+ const preHealth = await api.checkHealth().catch(() => null);
+ maxUptimeRef.current = typeof preHealth?.uptime === 'number' ? preHealth.uptime : 0;
setUpdating(true);
setSteps([]);
setUpdateError(null);
diff --git a/server/services/installState.js b/server/services/installState.js
index 2fd11521d9..e124c1aa51 100644
--- a/server/services/installState.js
+++ b/server/services/installState.js
@@ -108,15 +108,18 @@ async function statMtimeMs(path) {
* as soon as a newer source file is found, false if the build is current.
*/
async function isClientSourceNewer(rootDir, buildMtimeMs, { statMtime = statMtimeMs } = {}) {
- // Top-level client files that affect the build but live outside src/.
+ // Top-level client files that affect the build but live outside the walked
+ // dirs.
const topLevel = ['client/index.html', 'client/package.json', 'client/vite.config.js'];
for (const rel of topLevel) {
const m = await statMtime(join(rootDir, rel));
if (m != null && m > buildMtimeMs) return true;
}
- const srcRoot = join(rootDir, 'client', 'src');
- const stack = [srcRoot];
+ // Both client/src AND client/public feed the build — Vite copies public/
+ // verbatim into dist/, so a public-asset-only change (e.g. a swapped favicon)
+ // still requires a rebuild and must keep staleBuild true.
+ const stack = [join(rootDir, 'client', 'src'), join(rootDir, 'client', 'public')];
while (stack.length) {
const dir = stack.pop();
const entries = await readdir(dir, { withFileTypes: true }).catch(() => []);