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(apps): self-app Launch respects active session + surface 5553 loopback port

Adam Eivye14b579b31e5
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 37b5378a84..27c80ad631 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -43,6 +43,10 @@
## Fixed
+- **Self-app "Launch" button opened an unreachable URL from the HTTP loopback mirror** — clicking Launch on `/apps/portos-default/overview` while browsing via `http://localhost:5553` built `http://localhost:5555` (hard-coded to the baseline app's `uiPort`), but port 5555 only speaks HTTPS when the Tailscale cert is active — so the tab opened to an empty reply. The tile grid (`AppTile.jsx`) and the detail view's Launch button (`AppDetailView.jsx`) now detect the self-app (`PORTOS_APP_ID`) and launch at `window.location.origin` so the scheme + port match the active session (HTTPS on 5555 or the HTTP loopback on 5553). Other apps still use `{protocol}//{hostname}:{uiPort}` as before.
+
+- **Loopback HTTP port 5553 was invisible in the UI and hard-coded as `PORT - 2` magic in server code** — the port that hosts the plain-HTTP mirror of the API wasn't declared alongside the other PortOS ports, so the Overview tab listed `portos-server:5555` with no hint that `:5553` was also in use (and for what). `ecosystem.config.cjs` now declares `PORTS.API_LOCAL = 5553` and wires it into the `portos-server` env as `PORTOS_HTTP_PORT`. `server/lib/ports.js` mirrors the constant so server code can reference it by name; `server/index.js` uses `PORTS.API_LOCAL` as the loopback fallback instead of `Number(PORT) - 2`. `buildPortosApp()` lists `api-local: 5553` on the portos-server process entry, so Overview now renders `portos-server (api:5555, api-local:5553)` — the existing `processes[].ports` iterator picked it up for free.
+
- **Lifestyle tab — biological sex is now editable and round-trips to MortalLoom iCloud sync** — `/meatspace/lifestyle` previously showed Biological Sex as a read-only text label, so users had no way to correct an auto-genome-detected sex or set it manually when no genome was uploaded. The Profile card now renders a Male/Female/Unknown segmented picker in the same style as the other lifestyle buttons, and Save now uses `PUT /api/meatspace/config` (instead of `/lifestyle`) so sex, sexSource, and the questionnaire write in one round-trip. `sexSource` is stamped to `'questionnaire'` whenever the user sets it manually so the next `getConfig()` call doesn't silently overwrite it via the auto-detect-from-genome code path. **MortalLoom iCloud parity**: `getConfig()` now treats `store.profile` in the iCloud MortalLoom.json as authoritative when sync is enabled — `biologicalSex`, `birthDate`, and the `lifestyle` subset of fields (smoking/exercise/sleep/diet/stress/BMI — the keys MortalLoom's Swift `LifestyleData` struct defines) get merged into the returned config so edits made in the iOS/macOS app show up in PortOS without a manual import. Writes mirror the other direction too: `updateConfig()`, `updateLifestyle()`, and `updateBirthDate()` now patch `store.profile.biologicalSex` / `store.profile.lifestyle` / `store.profile.birthDate` via a new `mlPatchProfileIfEnabled()` helper, which deep-merges nested objects so lifestyle can be patched field-by-field without clobbering siblings. PortOS-only lifestyle fields (`alcoholDrinksPerDay`, `chronicConditions`) are filtered out of the MortalLoom write via a `MORTALLOOM_LIFESTYLE_KEYS` allowlist so the store only gains keys MortalLoom's Swift decoder accepts. `configSchema.sex` now allows `null` so clearing the sex from the UI validates.
- **Genome-Health cards mislabeled longevity/protective markers as "Elevated Risk Marker"** — the `/insights/genome-health` tab tagged every `concern` status with the risk language `CONFIDENCE_FROM_STATUS` produced ("Elevated Risk Marker", "Significant Risk Marker"), which was wrong for protective-variant markers like FOXO3A/rs2802292 where `concern` just means "doesn't carry the longevity G allele" — not an elevated risk, just a typical population outcome. The card also hid the user's genotype so you couldn't tell whether you carried the marker at all. Fix: added a polarity inference on `CuratedMarker` — rules containing `major_concern` describe a risk marker, rules going beneficial→typical→concern describe a protective marker — and two separate confidence tables (`CONFIDENCE_PROTECTIVE` = "Beneficial Variant / Partial Variant / No Benefit Variant" in neutral grays, `CONFIDENCE_RISK` = "No Risk Variant / Typical / Carrier / Risk Variant" in green→yellow→orange→red). The server now stamps each enriched marker with its `polarity` and `genotype`; the client card shows a "Your result" row with the genotype rendered in a color-coded pill (neutral gray when a protective marker's status is just "no variant"), surfaces a subtle "protective variant" hint with a tooltip explaining the framing, and prefixes the implication text with "What this means:". Added a new `neutral` level to `ConfidenceBadge` for the no-variant-on-protective-marker case. MortalLoom parity: `CuratedMarker` gained the same inferred `polarity` extension and `GenomeView.swift`'s `colorForStatus`/`iconForStatus`/`statusLabel` helpers now accept a polarity argument and return protective-aware labels ("Beneficial Variant" / "No Benefit Variant" in `.secondary` gray with a `minus.circle.fill` icon) so a FOXO3A T/T result no longer shows an orange warning triangle. Scanned all 116 curated markers — the inference holds: longevity/tumor_suppression/cognitive markers use protective polarity, disease-risk markers (iron, cardiovascular, autoimmune) use risk polarity.
diff --git a/client/src/components/AppTile.jsx b/client/src/components/AppTile.jsx
index 147536e70d..a568aa70f7 100644
--- a/client/src/components/AppTile.jsx
+++ b/client/src/components/AppTile.jsx
@@ -3,10 +3,15 @@ import { Link } from 'react-router-dom';
import StatusBadge from './StatusBadge';
import AppIcon from './AppIcon';
import * as api from '../services/api';
+import { PORTOS_APP_ID } from '../services/apiCore';
// Construct app URL using current hostname (works with Tailscale)
function getAppUrl(app) {
if (app.uiUrl) return app.uiUrl;
+ // Self-app: launch at the current origin so the scheme matches the active
+ // session (HTTPS on 5555 vs HTTP loopback on 5553) instead of hard-coding
+ // uiPort, which only accepts HTTPS.
+ if (app.id === PORTOS_APP_ID) return window.location.origin;
if (app.uiPort) {
const protocol = window.location.protocol;
const hostname = window.location.hostname;
diff --git a/client/src/components/apps/AppDetailView.jsx b/client/src/components/apps/AppDetailView.jsx
index 283a80ad5d..324b42da84 100644
--- a/client/src/components/apps/AppDetailView.jsx
+++ b/client/src/components/apps/AppDetailView.jsx
@@ -6,6 +6,7 @@ import toast from '../ui/Toast';
import BrailleSpinner from '../BrailleSpinner';
import StatusBadge from '../StatusBadge';
import * as api from '../../services/api';
+import { PORTOS_APP_ID } from '../../services/apiCore';
import socket from '../../services/socket';
import { APP_DETAIL_TABS, NON_PM2_TYPES, getAppTypeLabel } from './constants';
import OverviewTab from './tabs/OverviewTab';
@@ -202,10 +203,17 @@ export default function AppDetailView() {
)}
</div>
)}
- {/* Launch UI */}
+ {/* Launch UI — self-app uses current origin so the scheme matches the
+ active session (HTTPS on 5555 vs HTTP loopback on 5553); uiPort alone
+ hard-codes the HTTPS-only port and breaks from the HTTP mirror. */}
{app.uiPort && app.overallStatus === 'online' && (
<button
- onClick={() => window.open(`${window.location.protocol}//${window.location.hostname}:${app.uiPort}`, '_blank')}
+ onClick={() => window.open(
+ app.id === PORTOS_APP_ID
+ ? window.location.origin
+ : `${window.location.protocol}//${window.location.hostname}:${app.uiPort}`,
+ '_blank'
+ )}
className="px-2 py-1 bg-port-accent/20 text-port-accent hover:bg-port-accent/30 transition-colors rounded-lg border border-port-border flex items-center gap-1"
>
<ExternalLink size={14} />
diff --git a/ecosystem.config.cjs b/ecosystem.config.cjs
index 5c0e4585e8..f4784675d9 100644
--- a/ecosystem.config.cjs
+++ b/ecosystem.config.cjs
@@ -22,7 +22,9 @@ try {
} catch { /* no .env file — default to docker */ }
const PORTS = {
- API: 5555, // Express API server
+ API: 5555, // Express API server (HTTPS when Tailscale cert is active)
+ API_LOCAL: 5553, // Loopback-only HTTP mirror of API — only binds when HTTPS is active on :API.
+ // Lets http://localhost work without cert warnings. Override w/ PORTOS_HTTP_PORT.
UI: 5554, // Vite dev server (client)
CDP: 5556, // Chrome DevTools Protocol (browser automation)
CDP_HEALTH: 5557, // Browser health check endpoint
@@ -47,6 +49,7 @@ module.exports = {
env: {
...BASE_ENV,
PORT: PORTS.API,
+ PORTOS_HTTP_PORT: PORTS.API_LOCAL, // Loopback HTTP mirror when HTTPS is active
HOST: '0.0.0.0',
PGPORT: PORTS.POSTGRES,
PGPASSWORD: process.env.PGPASSWORD || 'portos',
diff --git a/server/index.js b/server/index.js
index feae6fb5c5..f9fdd500f3 100644
--- a/server/index.js
+++ b/server/index.js
@@ -5,6 +5,7 @@ import { Server } from 'socket.io';
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';
import { PATHS } from './lib/fileUtils.js';
+import { PORTS } from './lib/ports.js';
import { existsSync, readFileSync } from 'fs';
import { readFile, unlink } from 'fs/promises';
@@ -425,7 +426,7 @@ ensureSelf()
// Chrome treats http://localhost as a secure context so getUserMedia
// still works. Same Express app + same Socket.IO instance (via
// io.attach), so routes and websocket events are identical.
- const localHttpPort = Number(process.env.PORTOS_HTTP_PORT) || Number(PORT) - 2;
+ const localHttpPort = Number(process.env.PORTOS_HTTP_PORT) || PORTS.API_LOCAL;
const localServer = createHttpServer(app);
io.attach(localServer);
localServer.listen(localHttpPort, '127.0.0.1', () => {
diff --git a/server/lib/ports.js b/server/lib/ports.js
index 4fdf2e5230..78b6333819 100644
--- a/server/lib/ports.js
+++ b/server/lib/ports.js
@@ -1,4 +1,12 @@
-export const PORTS = { API: 5555, UI: 5554 };
+export const PORTS = {
+ API: 5555, // HTTPS API (or HTTP if cert not configured)
+ API_LOCAL: 5553, // Loopback-only HTTP mirror — only binds when HTTPS is active on API.
+ // Tailscale cert covers <machine>.<tailnet>.ts.net only, so
+ // https://localhost:5555 trips a warning; this sibling port
+ // serves the same app over plain HTTP for local dev.
+ // Overridable via PORTOS_HTTP_PORT.
+ UI: 5554 // Vite dev server
+};
export const DEFAULT_PEER_PORT = PORTS.API;
export const PORTOS_UI_URL = process.env.PORTOS_UI_URL
|| `http://${process.env.PORTOS_HOST || 'localhost'}:${process.env.PORT_UI || PORTS.UI}`;
diff --git a/server/services/apps.js b/server/services/apps.js
index 2fe9de0483..00d5d76f4b 100644
--- a/server/services/apps.js
+++ b/server/services/apps.js
@@ -37,7 +37,9 @@ function buildPortosApp() {
'portos-browser'
],
processes: [
- { name: 'portos-server', port: PORTS.API, ports: { api: PORTS.API } },
+ // portos-server binds a loopback HTTP mirror on API_LOCAL when HTTPS is active on API,
+ // so Overview shows both ports for this process.
+ { name: 'portos-server', port: PORTS.API, ports: { api: PORTS.API, 'api-local': PORTS.API_LOCAL } },
{ name: 'portos-cos', port: 5558, ports: { api: 5558 } },
{ name: 'portos-ui', port: PORTS.UI, ports: { devUi: PORTS.UI } },
{ name: 'portos-autofixer', port: 5559, ports: { api: 5559 } },