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
address review (codex): don't false-persist ui edits via env/args for a ports-reference block
Adam Eivy23ac4dda5eaf
diff --git a/server/services/streamingDetect.js b/server/services/streamingDetect.jsindex 1f771311f9..292fe49ef6 100644--- a/server/services/streamingDetect.js+++ b/server/services/streamingDetect.js@@ -611,8 +611,16 @@ function rewriteLabelInBlock(block, label, oldP, newP) {const hasDevUiKey = /\bdevUi\s*:\s*\d/.test(block);pats.push(label === 'devUi' ? `(\\bdevUi\\s*:\\s*)${NUM}` : `(\\bui\\s*:\\s*)${NUM}`); // exact keyif (label === 'devUi' && !hasDevUiKey) pats.push(`(\\bui\\s*:\\s*)${NUM}`); // relabeled-from-ui source- pats.push(`(['"\`]?\\bVITE_PORT\\b['"\`]?\\s*:\\s*)${NUM}`); // env VITE_PORT: N- pats.push(`(--port\\s+)${NUM}`); // args --port N+ if (!hasPortsReference) {+ // VITE_PORT/--port mirror the runtime UI/dev port: rewrite them alongside+ // an inline ports key (desirable — config + runtime move together) or as+ // the sole source when there's no ports object. But NOT for a ports+ // REFERENCE whose external const the parser actually reads — rewriting+ // only the env/args value there is false success (the unchanged const+ // re-derives the old port on the next refresh).+ pats.push(`(['"\`]?\\bVITE_PORT\\b['"\`]?\\s*:\\s*)${NUM}`); // env VITE_PORT: N+ pats.push(`(--port\\s+)${NUM}`); // args --port N+ }if (!hasExplicitPortsSource) pats.push(`(${PORT_KEY})${NUM}`); // bare PORT of a UI-named process}diff --git a/server/services/streamingDetect.test.js b/server/services/streamingDetect.test.jsindex 386bd2974f..513ce168a2 100644--- a/server/services/streamingDetect.test.js+++ b/server/services/streamingDetect.test.js@@ -542,6 +542,39 @@ module.exports = { apps: [expect(ports.devUi).toBe(6000); // sibling untouched});+ it('does NOT report success from an env-only ui rewrite when the ui port comes from a ports reference', () => {+ // ui is derived from `ports: PORTS.client` (external const), but the block+ // ALSO carries a same-valued VITE_PORT. Rewriting only VITE_PORT would be+ // false success — the parser re-derives ui from the unchanged const. So the+ // env/args fallback must be skipped for a reference block → unapplied.+ const content = `const PORTS = { client: { ui: 6000 } };+module.exports = { apps: [+ { name: 'srv-ui', script: 'npx', args: 'vite --host', ports: PORTS.client, env: { VITE_PORT: 6000 } }+] };+`;+ const r = rewriteEcosystemPortsByProcess(content, [+ { processName: 'srv-ui', label: 'ui', oldPort: 6000, newPort: 7000 },+ ]);+ expect(r.applied).toHaveLength(0);+ expect(r.unapplied).toHaveLength(1);+ expect(r.content).toBe(content); // VITE_PORT untouched, no false rewrite+ });++ it('still rewrites VITE_PORT/--port for a ui edit when there is no ports reference (inline or sole source)', () => {+ // No ports reference → VITE_PORT is the real source; rewrite it.+ const content = `module.exports = { apps: [+ { name: 'srv', script: 's.js', env: { PORT: 5555 } },+ { name: 'srv-ui', script: 'npx', args: 'vite --host --port 5556', env: { VITE_PORT: 5556 } }+] };+`;+ const r = rewriteEcosystemPortsByProcess(content, [+ { processName: 'srv-ui', label: 'ui', oldPort: 5556, newPort: 7000 },+ ]);+ expect(r.applied).toHaveLength(1);+ expect(r.content).toContain('VITE_PORT: 7000');+ expect(r.content).toContain('--port 7000');+ });+it('reports an edit as unapplied when the process name is not found', () => {const content = `module.exports = { apps: [{ name: 'srv', script: 's.js', env: { PORT: 6000 } }] };`;const r = rewriteEcosystemPortsByProcess(content, [