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: refresh-config derives uiPort/devUiPort/buildCommand from ecosystem config

Adam Eivy8b35e37de1dc
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 58350f5fda..691de4c3f4 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -6,5 +6,7 @@
## Fixed
- Update scripts (update.sh/update.ps1) now build UI assets before restarting PM2, ensuring production serves the latest client build
+- App refresh-config now correctly derives uiPort, devUiPort, and apiPort from ecosystem process labels (fixes apps showing dev UI port as Launch)
+- App refresh-config and detection now auto-detect buildCommand from package.json, enabling Build button for apps with production builds
## Removed
diff --git a/server/routes/apps.js b/server/routes/apps.js
index 1ddddf8dda..ad72c99f3b 100644
--- a/server/routes/apps.js
+++ b/server/routes/apps.js
@@ -625,6 +625,16 @@ router.post('/:id/refresh-config', loadApp, asyncHandler(async (req, res) => {
// Update app with new process data
const updates = {};
+ // Detect buildCommand from package.json if not already set
+ if (!app.buildCommand) {
+ const pkgPath = join(app.repoPath, 'package.json');
+ const pkgContent = await readFile(pkgPath, 'utf-8').catch(() => null);
+ if (pkgContent) {
+ const pkg = JSON.parse(pkgContent);
+ if (pkg.scripts?.build) updates.buildCommand = 'npm run build';
+ }
+ }
+
// Update pm2Home if detected and different from current
if (pm2Home && pm2Home !== app.pm2Home) {
updates.pm2Home = pm2Home;
@@ -634,10 +644,20 @@ router.post('/:id/refresh-config', loadApp, asyncHandler(async (req, res) => {
updates.processes = processes;
updates.pm2ProcessNames = processes.map(p => p.name);
- // Update apiPort if we found one and it's different
- const processWithPort = processes.find(p => p.port);
- if (processWithPort && processWithPort.port !== app.apiPort) {
- updates.apiPort = processWithPort.port;
+ // Derive ports from parsed process labels (same logic as streamDetection)
+ const apiProc = processes.find(p => p.ports?.api);
+ if (apiProc) updates.apiPort = apiProc.ports.api;
+
+ const uiProc = processes.find(p => p.ports?.ui);
+ if (uiProc) updates.uiPort = uiProc.ports.ui;
+
+ const devUiProc = processes.find(p => p.ports?.devUi);
+ if (devUiProc) updates.devUiPort = devUiProc.ports.devUi;
+
+ // When app has API + Vite dev but no dedicated UI port,
+ // the prod UI is served by the API server
+ if (!updates.uiPort && updates.apiPort && (updates.devUiPort || app.devUiPort)) {
+ updates.uiPort = updates.apiPort;
}
}
diff --git a/server/services/streamingDetect.js b/server/services/streamingDetect.js
index dd48d1297c..7287ba8e7b 100644
--- a/server/services/streamingDetect.js
+++ b/server/services/streamingDetect.js
@@ -359,6 +359,7 @@ export async function streamDetection(socket, dirPath) {
uiPort: null,
devUiPort: null,
apiPort: null,
+ buildCommand: null,
startCommands: [],
pm2ProcessNames: [],
pm2Status: null,
@@ -413,10 +414,11 @@ export async function streamDetection(socket, dirPath) {
else if (deps.express || deps.fastify || deps.koa) result.type = 'single-node-server';
else if (deps.next) result.type = 'nextjs';
- // Get start commands
+ // Get start commands and build command
const scripts = pkg.scripts || {};
if (scripts.dev) result.startCommands.push('npm run dev');
if (scripts.start && !scripts.dev) result.startCommands.push('npm start');
+ if (scripts.build) result.buildCommand = 'npm run build';
emit('package', 'done', {
message: `Found: ${result.name}`,