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: fix JSDoc, useAutoRefetch stale closure, missing existsSync import

Adam Eivy0f3d557c371e
diff --git a/client/src/hooks/useAutoRefetch.js b/client/src/hooks/useAutoRefetch.js
index 933e582144..8d9ab1e70b 100644
--- a/client/src/hooks/useAutoRefetch.js
+++ b/client/src/hooks/useAutoRefetch.js
@@ -1,4 +1,4 @@
-import { useState, useEffect } from 'react';
+import { useState, useEffect, useRef } from 'react';
/**
* Hook for auto-refetching data on an interval.
@@ -11,10 +11,16 @@ import { useState, useEffect } from 'react';
export function useAutoRefetch(fetchFn, intervalMs) {
const [data, setData] = useState(null);
const [loading, setLoading] = useState(true);
+ const fetchRef = useRef(fetchFn);
+
+ // Keep ref current so interval callbacks don't capture stale closures
+ useEffect(() => {
+ fetchRef.current = fetchFn;
+ }, [fetchFn]);
useEffect(() => {
const loadData = async () => {
- const result = await fetchFn();
+ const result = await fetchRef.current();
setData(result);
setLoading(false);
};
@@ -22,7 +28,7 @@ export function useAutoRefetch(fetchFn, intervalMs) {
loadData();
const interval = setInterval(loadData, intervalMs);
return () => clearInterval(interval);
- }, []); // eslint-disable-line react-hooks/exhaustive-deps
+ }, [intervalMs]);
return { data, loading };
}
diff --git a/server/routes/apps.js b/server/routes/apps.js
index 8712fc5332..d3a918687e 100644
--- a/server/routes/apps.js
+++ b/server/routes/apps.js
@@ -12,7 +12,7 @@ import { parseEcosystemFromPath } from '../services/streamingDetect.js';
const router = Router();
/**
- * Middleware to load app by :id param and attach to req.app
+ * Middleware to load app by :id param and attach to req.loadedApp
* Throws 404 if not found, eliminating repeated null checks across routes
*/
const loadApp = asyncHandler(async (req, res, next) => {
diff --git a/server/services/scriptRunner.js b/server/services/scriptRunner.js
index ec28caea34..c61666102b 100644
--- a/server/services/scriptRunner.js
+++ b/server/services/scriptRunner.js
@@ -8,6 +8,7 @@
import { spawn } from 'child_process';
import { join, dirname } from 'path';
import { fileURLToPath } from 'url';
+import { existsSync } from 'fs';
import { writeFile, mkdir, readdir, rm } from 'fs/promises';
import { v4 as uuidv4 } from 'uuid';
import Cron from 'croner';