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: align port guidance, fix devUiPort heuristics, remove duplicate field, deterministic test

Adam Eivy094f77dee3d3
diff --git a/server/services/messageSync.test.js b/server/services/messageSync.test.js
index a6ada7a946..364f3a1c44 100644
--- a/server/services/messageSync.test.js
+++ b/server/services/messageSync.test.js
@@ -413,7 +413,7 @@ describe('syncAccount', () => {
// Start first sync (don't await — it will hang on loadCache)
const firstSync = syncAccount(VALID_UUID_2, mockIo);
// Yield to let the first sync reach the lock point
- await new Promise(r => setTimeout(r, 10));
+ await new Promise(r => setImmediate(r));
// Second sync should be rejected with 409
const secondResult = await syncAccount(VALID_UUID_2, mockIo);
diff --git a/server/services/pm2Standardizer.js b/server/services/pm2Standardizer.js
index 8fe17d4561..62703ce7c2 100644
--- a/server/services/pm2Standardizer.js
+++ b/server/services/pm2Standardizer.js
@@ -121,7 +121,7 @@ ${context.viteConfigs.map(f => `#### ${f.name}\n\`\`\`javascript\n${f.content}\n
5. **Vite processes**: Use \`npx vite --host --port XXXX\` in args, disable watch (Vite has HMR)
6. **Set cwd** for each process pointing to its directory
7. **Include NODE_ENV** in all env blocks
-8. **UI vs Dev UI ports**: When the API server serves the production build of the frontend (Express static files), the production UI port equals the API port. The Vite dev server port is a separate "dev UI" port only used during development. Label Vite dev ports as WEB/DEV_UI in the PORTS object, not as UI.
+8. **UI vs Dev UI ports**: When the API server serves the production build of the frontend (Express static files), the production UI port equals the API port. The Vite dev server port is a separate "dev UI" port only used during development. Label Vite dev ports as UI or DEV_UI in the PORTS object (both conventions are acceptable).
## Output Format
diff --git a/server/services/streamingDetect.js b/server/services/streamingDetect.js
index c371a1d0e8..dd48d1297c 100644
--- a/server/services/streamingDetect.js
+++ b/server/services/streamingDetect.js
@@ -276,7 +276,7 @@ export function parseEcosystemConfig(content) {
// Match explicit "vite" command OR VITE_PORT in env config
const usesVite = /\bvite\b/i.test(appBlock) || /VITE_PORT/i.test(appBlock);
- processes.push({ name: processName, port, ports, cwd, usesVite, isViteProcess: usesVite });
+ processes.push({ name: processName, port, ports, cwd, usesVite });
lastIndex = endPos;
}
@@ -285,7 +285,7 @@ export function parseEcosystemConfig(content) {
const hasApiProcess = processes.some(p => p.ports?.api);
if (hasApiProcess) {
for (const proc of processes) {
- if (proc.isViteProcess && proc.ports?.ui && !proc.ports?.devUi) {
+ if (proc.usesVite && proc.ports?.ui && !proc.ports?.devUi) {
proc.ports.devUi = proc.ports.ui;
delete proc.ports.ui;
// Update primary port reference
@@ -337,7 +337,6 @@ export async function parseEcosystemFromPath(dirPath) {
// Clean up internal properties before returning
delete proc.cwd;
delete proc.usesVite;
- delete proc.isViteProcess;
}
return { processes, pm2Home };
@@ -443,7 +442,7 @@ export async function streamDetection(socket, dirPath) {
const portMatch = content.match(/PORT\s*=\s*(\d+)/i);
if (portMatch) result.apiPort = parseInt(portMatch[1], 10);
const viteMatch = content.match(/VITE_PORT\s*=\s*(\d+)/i);
- if (viteMatch) result.uiPort = parseInt(viteMatch[1], 10);
+ if (viteMatch) result.devUiPort = parseInt(viteMatch[1], 10);
configFiles.push('.env');
}
@@ -453,7 +452,7 @@ export async function streamDetection(socket, dirPath) {
if (existsSync(configPath)) {
const content = await readFile(configPath, 'utf-8').catch(() => '');
const portMatch = content.match(/port\s*:\s*(\d+)/);
- if (portMatch) result.uiPort = parseInt(portMatch[1], 10);
+ if (portMatch) result.devUiPort = parseInt(portMatch[1], 10);
configFiles.push(viteConfig);
}
}
@@ -489,8 +488,7 @@ export async function streamDetection(socket, dirPath) {
// Clean up internal properties
delete proc.cwd;
delete proc.usesVite;
- delete proc.isViteProcess;
- }
+ }
result.processes = parsedProcesses;
result.pm2ProcessNames = parsedProcesses.map(p => p.name);
@@ -526,6 +524,12 @@ export async function streamDetection(socket, dirPath) {
}
}
+ // When config-file heuristics found a Vite dev port but no dedicated uiPort,
+ // derive uiPort: API serves prod UI if present, otherwise devUiPort is the only UI
+ if (!result.uiPort && result.devUiPort) {
+ result.uiPort = result.apiPort ?? result.devUiPort;
+ }
+
emit('config', 'done', {
message: configFiles.length ? `Found: ${configFiles.join(', ')}` : 'No config files found',
uiPort: result.uiPort,