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

feat([codex5-network-exposure-ui]): add Network Exposure dashboard widget

[._.]/ Adam Eivybc7167431e90
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index ee0640b9f7..7a7a6e79c3 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -2,6 +2,8 @@
## Added
+- **Network Exposure dashboard widget.** New widget surfaces how PortOS is actually exposed on the network: HTTPS vs HTTP, bind address + audience (loopback-only / all-interfaces / specific-interface), cert mode (Tailscale-trusted hostname vs self-signed), the loopback HTTP mirror port when HTTPS is on, and a mic-availability hint computed from the browser origin (HTTPS or loopback ⇒ available; HTTP on a Tailscale IP ⇒ blocked by the browser's secure-context rule). Renders a warning banner when bound on all interfaces over plain HTTP. Seeded into the `default` (Everything) and `ops` built-in dashboard layouts so the security posture is visible product UX, not a docs-only invariant. Backed by `GET /api/network-exposure/status`.
+
- **CoS task form: pick the reviewer for the Review Loop (`--review-with`).** A new compact dropdown appears next to the Review Loop checkbox in `TaskAddForm.jsx` (copilot / claude / gemini / codex; default copilot). The choice is persisted on the task as `metadata.reviewer` and flows through the agent prompt, the follow-up agent's prompt (`/do:rpr --review-with <reviewer>`), and the worktree cleanup hook — for non-copilot reviewers, PortOS skips the GitHub Copilot reviewer-API pre-request and instructs the follow-up to invoke the chosen CLI against the PR diff instead. AgentCard chips show the selected reviewer when it isn't the default.
- **Deep-linkable image preview modals via `?preview=<filename>`.** Every page hosting `<MediaPreview>` (Media History, Media Collections, Image Gen, Video Gen, Universe Builder variations + cast, Comic Script Stage, Nouns Stage) now drives the lightbox through a `?preview=<filename>` query param, so `/media/history?preview=foo.png` or `/universe-builder/:id?tab=cast&preview=foo.png` re-opens the same image on reload and is shareable. New `usePreviewRoute(items)` hook (`client/src/hooks/usePreviewRoute.js`) owns the URL round-trip — first open pushes a history entry so the browser back button closes the modal; prev/next nav and close replace so the history stack stays clean.
diff --git a/client/src/components/NetworkExposureWidget.jsx b/client/src/components/NetworkExposureWidget.jsx
new file mode 100644
index 0000000000..6cfe1741f2
--- /dev/null
+++ b/client/src/components/NetworkExposureWidget.jsx
@@ -0,0 +1,221 @@
+import { useState, useEffect, memo, useMemo } from 'react';
+import {
+ Shield,
+ ShieldAlert,
+ ShieldCheck,
+ Globe,
+ Lock,
+ Unlock,
+ Mic,
+ MicOff,
+ ExternalLink,
+ AlertTriangle,
+ CheckCircle
+} from 'lucide-react';
+import * as api from '../services/api';
+
+// Browser secure-context rule mirrored client-side: getUserMedia (and other
+// powerful APIs) are gated on the page origin being HTTPS, localhost, or
+// 127.0.0.1/::1 — anything else (Tailscale IP, LAN IP, plain hostname over
+// HTTP) silently fails. Server-side we know the scheme + bind, but only the
+// browser knows which of those origins it actually loaded from.
+const LOOPBACK_HOSTS = new Set(['localhost', '127.0.0.1', '::1']);
+
+function describeMicAvailability() {
+ if (typeof window === 'undefined' || !window.location) {
+ return { available: true, reason: 'unknown' };
+ }
+ const { protocol, hostname } = window.location;
+ if (protocol === 'https:') {
+ return { available: true, reason: 'https' };
+ }
+ if (LOOPBACK_HOSTS.has(hostname)) {
+ return { available: true, reason: 'loopback' };
+ }
+ return { available: false, reason: 'insecure-context' };
+}
+
+function CertModeBadge({ mode, host }) {
+ if (mode === 'tailscale') {
+ return (
+ <div className="flex items-center gap-2 text-sm">
+ <ShieldCheck size={14} className="text-port-success" />
+ <span className="text-port-success">Trusted via Tailscale</span>
+ {host && (
+ <span className="text-gray-500 truncate" title={host}>· {host}</span>
+ )}
+ </div>
+ );
+ }
+ if (mode === 'self-signed') {
+ return (
+ <div className="flex items-center gap-2 text-sm">
+ <Shield size={14} className="text-port-warning" />
+ <span className="text-port-warning">Self-signed cert</span>
+ </div>
+ );
+ }
+ if (mode === 'unknown') {
+ return (
+ <div className="flex items-center gap-2 text-sm">
+ <Shield size={14} className="text-gray-400" />
+ <span className="text-gray-400">HTTPS · cert metadata missing</span>
+ </div>
+ );
+ }
+ return (
+ <div className="flex items-center gap-2 text-sm">
+ <ShieldAlert size={14} className="text-port-warning" />
+ <span className="text-port-warning">No TLS — plain HTTP</span>
+ </div>
+ );
+}
+
+const NetworkExposureWidget = memo(function NetworkExposureWidget() {
+ const [status, setStatus] = useState(null);
+ const [loading, setLoading] = useState(true);
+
+ useEffect(() => {
+ let cancelled = false;
+ api.getNetworkExposure({ silent: true })
+ .then((data) => {
+ if (!cancelled) setStatus(data);
+ })
+ .catch(() => {
+ if (!cancelled) setStatus(null);
+ })
+ .finally(() => {
+ if (!cancelled) setLoading(false);
+ });
+ return () => { cancelled = true; };
+ }, []);
+
+ const mic = useMemo(() => describeMicAvailability(), []);
+
+ if (loading || !status) return null;
+
+ const { scheme, httpsEnabled, bind, loopbackMirror, cert, docsUrl } = status;
+ const SchemeIcon = httpsEnabled ? Lock : Unlock;
+ const schemeColor = httpsEnabled ? 'text-port-success' : 'text-port-warning';
+
+ // "Surface area" warning — server bound on all interfaces with no TLS means
+ // any device on the LAN/Tailnet can speak plain HTTP to it. PortOS expects
+ // to live behind Tailscale, so we flag this rather than silently allow it.
+ const exposedOverInsecureWan =
+ !httpsEnabled && bind?.audience === 'all-interfaces';
+
+ return (
+ <div className="bg-port-card border border-port-border rounded-xl p-4 sm:p-6">
+ <div className="flex items-center justify-between mb-4">
+ <div className="flex items-center gap-3">
+ <div className={`p-2 rounded-lg ${httpsEnabled ? 'bg-port-success/10' : 'bg-port-warning/10'}`}>
+ <Globe className={`w-5 h-5 ${schemeColor}`} />
+ </div>
+ <div>
+ <h3 className="text-lg font-semibold text-white">Network Exposure</h3>
+ <div className="flex items-center gap-2 text-sm">
+ <SchemeIcon size={14} className={schemeColor} />
+ <span className={schemeColor}>{scheme.toUpperCase()}</span>
+ <span className="text-gray-500">·</span>
+ <span className="text-gray-400 font-mono text-xs">
+ {bind.host}:{bind.port}
+ </span>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ {exposedOverInsecureWan && (
+ <div className="mb-4 flex items-start gap-2 px-3 py-2 rounded-lg bg-port-warning/10 text-port-warning text-sm">
+ <AlertTriangle size={14} className="mt-0.5 flex-shrink-0" />
+ <span>
+ Bound on all interfaces over plain HTTP — anyone on this LAN/Tailnet
+ can reach PortOS unencrypted. Run <code className="font-mono">npm run setup:cert</code> to enable HTTPS.
+ </span>
+ </div>
+ )}
+
+ <dl className="space-y-3 text-sm">
+ <div className="flex items-start justify-between gap-3">
+ <dt className="text-gray-500 flex items-center gap-2">
+ <Shield size={14} />
+ Cert mode
+ </dt>
+ <dd className="text-right min-w-0">
+ <CertModeBadge mode={cert.mode} host={cert.tailscaleHost} />
+ </dd>
+ </div>
+
+ <div className="flex items-start justify-between gap-3">
+ <dt className="text-gray-500 flex items-center gap-2">
+ <Globe size={14} />
+ Bind audience
+ </dt>
+ <dd className="text-right text-gray-300">
+ {bind.audience === 'loopback-only' && 'Loopback only'}
+ {bind.audience === 'all-interfaces' && 'All interfaces'}
+ {bind.audience === 'specific-interface' && (
+ <span className="font-mono text-xs">{bind.host}</span>
+ )}
+ </dd>
+ </div>
+
+ {loopbackMirror.enabled && (
+ <div className="flex items-start justify-between gap-3">
+ <dt className="text-gray-500 flex items-center gap-2">
+ <Unlock size={14} />
+ Loopback HTTP mirror
+ </dt>
+ <dd className="text-right text-gray-300">
+ <a
+ href={`http://localhost:${loopbackMirror.port}`}
+ target="_blank"
+ rel="noreferrer"
+ className="font-mono text-xs text-port-accent hover:underline"
+ >
+ :{loopbackMirror.port}
+ </a>
+ </dd>
+ </div>
+ )}
+
+ <div className="flex items-start justify-between gap-3">
+ <dt className="text-gray-500 flex items-center gap-2">
+ {mic.available ? <Mic size={14} /> : <MicOff size={14} />}
+ Voice / mic
+ </dt>
+ <dd className="text-right">
+ {mic.available ? (
+ <div className="flex items-center gap-1 text-port-success">
+ <CheckCircle size={14} />
+ <span>Available</span>
+ <span className="text-gray-500 text-xs">
+ ({mic.reason === 'https' ? 'HTTPS' : 'loopback'})
+ </span>
+ </div>
+ ) : (
+ <div className="flex items-center gap-1 text-port-warning">
+ <AlertTriangle size={14} />
+ <span>Blocked — HTTP on non-loopback origin</span>
+ </div>
+ )}
+ </dd>
+ </div>
+ </dl>
+
+ <div className="mt-4 pt-3 border-t border-port-border">
+ <a
+ href={docsUrl}
+ target="_blank"
+ rel="noreferrer"
+ className="inline-flex items-center gap-1 text-sm text-port-accent hover:text-port-accent/80"
+ >
+ <span>Port + scheme guide</span>
+ <ExternalLink size={12} />
+ </a>
+ </div>
+ </div>
+ );
+});
+
+export default NetworkExposureWidget;
diff --git a/client/src/components/dashboard/widgetRegistry.jsx b/client/src/components/dashboard/widgetRegistry.jsx
index 0eb23070ff..279848893d 100644
--- a/client/src/components/dashboard/widgetRegistry.jsx
+++ b/client/src/components/dashboard/widgetRegistry.jsx
@@ -1,4 +1,5 @@
import BackupWidget from '../BackupWidget';
+import NetworkExposureWidget from '../NetworkExposureWidget';
import SystemHealthWidget from '../SystemHealthWidget';
import CosDashboardWidget from '../CosDashboardWidget';
import GoalProgressWidget from '../GoalProgressWidget';
@@ -39,6 +40,7 @@ export const WIDGETS = [
{ id: 'proactive-alerts', label: 'Proactive Alerts', Component: ProactiveAlertsWidget, width: 'quarter', defaultH: 4, module: { id: '04', status: 'ALERTS', glyph: 'warning-tri' } },
{ id: 'review-hub', label: 'Review Hub', Component: ReviewHubCard, width: 'quarter', defaultH: 4, module: { id: '05', status: 'REVIEW', glyph: 'reticle' } },
{ id: 'system-health', label: 'System Health', Component: SystemHealthWidget, width: 'quarter', defaultH: 8, module: { id: '01', status: 'HEALTH', glyph: 'matrix' } },
+ { id: 'network-exposure', label: 'Network Exposure', Component: NetworkExposureWidget, width: 'quarter', defaultH: 5, module: { id: '07', status: 'EXPOSURE', glyph: 'reticle' } },
{ id: 'backup', label: 'Backup', Component: BackupWidget, width: 'quarter', defaultH: 5 },
{ id: 'death-clock', label: 'Death Clock', Component: DeathClockWidget, width: 'quarter', defaultH: 4 },
{ id: 'quick-stats', label: 'Quick Stats', Component: QuickStatsWidget, width: 'quarter', defaultH: 3, gate: (s) => s.apps.length > 0 },
diff --git a/client/src/services/apiSystem.js b/client/src/services/apiSystem.js
index a22f34c59c..11936de973 100644
--- a/client/src/services/apiSystem.js
+++ b/client/src/services/apiSystem.js
@@ -6,6 +6,7 @@ export const getAlertsSummary = (options) => request('/alerts/summary', options)
// Health
export const checkHealth = () => request('/system/health');
export const getSystemHealth = (options) => request('/system/health/details', options);
+export const getNetworkExposure = (options) => request('/network-exposure/status', options);
export const updateHealthThresholds = (thresholds) => request('/system/health/thresholds', {
method: 'PUT',
body: JSON.stringify(thresholds)
diff --git a/server/index.js b/server/index.js
index caab719259..6db61b72e5 100644
--- a/server/index.js
+++ b/server/index.js
@@ -17,6 +17,7 @@ import systemHealthRoutes from './routes/systemHealth.js';
import appsRoutes from './routes/apps.js';
import referenceReposRoutes from './routes/referenceRepos.js';
import portsRoutes from './routes/ports.js';
+import networkExposureRoutes from './routes/networkExposure.js';
import logsRoutes from './routes/logs.js';
import detectRoutes from './routes/detect.js';
import scaffoldRoutes from './routes/scaffold.js';
@@ -327,6 +328,7 @@ app.use('/api/system', systemHealthRoutes);
app.use('/api/apps', appsRoutes);
app.use('/api/apps/:appId/reference-repos', referenceReposRoutes);
app.use('/api/ports', portsRoutes);
+app.use('/api/network-exposure', networkExposureRoutes);
app.use('/api/logs', logsRoutes);
app.use('/api/detect', detectRoutes);
app.use('/api/scaffold', scaffoldRoutes);
diff --git a/server/lib/README.md b/server/lib/README.md
index bd338958d8..1e70675a04 100644
--- a/server/lib/README.md
+++ b/server/lib/README.md
@@ -106,6 +106,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub
| `sharingOrigin.js` | Origin metadata for records imported from share buckets. |
| `tailscale.js` | Common paths where the Tailscale CLI binary is found. |
| `httpsState.js` | Captures whether PortOS booted with HTTPS active. |
+| `networkExposure.js` | Snapshot of scheme + bind + cert mode for the dashboard's Network Exposure widget. |
## Search & indexing
diff --git a/server/lib/index.js b/server/lib/index.js
index 2d13074a2e..719a21abd9 100644
--- a/server/lib/index.js
+++ b/server/lib/index.js
@@ -83,6 +83,7 @@ export * from './pythonSetup.js';
export * from './fetchWithTimeout.js';
export * from './httpClient.js';
export * from './httpsState.js';
+export * from './networkExposure.js';
export * from './peerHttpClient.js';
export * from './peerSelfHost.js';
export * from './peerUrl.js';
diff --git a/server/lib/networkExposure.js b/server/lib/networkExposure.js
new file mode 100644
index 0000000000..87e647719a
--- /dev/null
+++ b/server/lib/networkExposure.js
@@ -0,0 +1,83 @@
+/**
+ * Snapshot of how PortOS is exposed on the network — scheme, bind address,
+ * loopback HTTP mirror, Tailscale-vs-self-signed cert mode. Drives the
+ * dashboard's Network Exposure widget so the security posture is visible
+ * product UX, not a docs-only invariant.
+ *
+ * The HTTPS decision and the bind host/port are frozen at boot (see
+ * lib/tailscale-https.js + httpsState.js). After running `npm run setup:cert`
+ * the user must restart for the scheme to flip — this snapshot reflects what
+ * the running process is actually serving, which is exactly what the widget
+ * should show.
+ */
+import { readFileSync, statSync } from 'node:fs';
+import { join } from 'node:path';
+import { PATHS, safeJSONParse } from './fileUtils.js';
+import { PORTS } from './ports.js';
+import { getHttpsEnabledAtBoot } from './httpsState.js';
+import { getSelfHost } from './peerSelfHost.js';
+
+const META_PATH = join(PATHS.data, 'certs', 'meta.json');
+// docs/PORTS.md is checked into the repo but the server doesn't serve the
+// docs/ directory, so link out to GitHub for the canonical guide rather than
+// to a 404. The widget shows this as "Learn more →".
+const PORTS_DOCS_URL = 'https://github.com/atomantic/PortOS/blob/main/docs/PORTS.md';
+
+function readCertMeta() {
+ const stat = statSync(META_PATH, { throwIfNoEntry: false });
+ if (!stat) return null;
+ return safeJSONParse(readFileSync(META_PATH, 'utf-8'), null);
+}
+
+// Loopback-only bind hosts — for these, the browser treats the page as
+// "potentially trustworthy" (Secure Contexts spec), so getUserMedia and other
+// powerful APIs work over plain HTTP. Any other host (Tailscale IP, LAN IP,
+// 0.0.0.0 → resolves to the actual interface) requires HTTPS.
+const LOOPBACK_HOSTS = new Set(['localhost', '127.0.0.1', '::1', '[::1]']);
+export function isLoopbackHost(host) {
+ if (typeof host !== 'string' || !host) return false;
+ return LOOPBACK_HOSTS.has(host.toLowerCase());
+}
+
+export function getNetworkExposureStatus() {
+ const { value: httpsEnabled, initialized } = getHttpsEnabledAtBoot();
+ const scheme = httpsEnabled ? 'https' : 'http';
+ const bindHost = process.env.HOST || '0.0.0.0';
+ const bindPort = Number(process.env.PORT) || PORTS.API;
+ const loopbackPort = Number(process.env.PORTOS_HTTP_PORT) || PORTS.API_LOCAL;
+
+ const meta = readCertMeta();
+ const certMode = httpsEnabled ? (meta?.mode || 'unknown') : null;
+ const tailscaleHost = getSelfHost();
+ const tailscaleIps = Array.isArray(meta?.ips) ? meta.ips : [];
+
+ // Bind audience — informational summary shown to the user so they know
+ // *who* can reach the listener. 0.0.0.0 means every interface (Tailscale,
+ // LAN, loopback); 127.0.0.1 / localhost is loopback-only.
+ const bindAudience = isLoopbackHost(bindHost)
+ ? 'loopback-only'
+ : bindHost === '0.0.0.0' || bindHost === '::'
+ ? 'all-interfaces'
+ : 'specific-interface';
+
+ return {
+ scheme,
+ httpsEnabled,
+ httpsStateInitialized: initialized,
+ bind: {
+ host: bindHost,
+ port: bindPort,
+ audience: bindAudience,
+ },
+ loopbackMirror: {
+ enabled: httpsEnabled,
+ port: loopbackPort,
+ },
+ cert: {
+ mode: certMode,
+ tailscaleHost,
+ ips: tailscaleIps,
+ },
+ docsUrl: PORTS_DOCS_URL,
+ };
+}
diff --git a/server/lib/networkExposure.test.js b/server/lib/networkExposure.test.js
new file mode 100644
index 0000000000..55010a8a01
--- /dev/null
+++ b/server/lib/networkExposure.test.js
@@ -0,0 +1,138 @@
+import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
+
+vi.mock('./fileUtils.js', () => ({
+ PATHS: { data: '/mock/data' },
+ safeJSONParse: (s, fallback) => { try { return JSON.parse(s); } catch { return fallback; } },
+ tryReadFile: vi.fn().mockResolvedValue(null),
+}));
+
+vi.mock('./httpsState.js', () => ({
+ getHttpsEnabledAtBoot: vi.fn(),
+}));
+
+vi.mock('./peerSelfHost.js', () => ({
+ getSelfHost: vi.fn(),
+}));
+
+vi.mock('node:fs', () => ({
+ readFileSync: vi.fn(),
+ statSync: vi.fn(),
+}));
+
+import { readFileSync, statSync } from 'node:fs';
+import { getHttpsEnabledAtBoot } from './httpsState.js';
+import { getSelfHost } from './peerSelfHost.js';
+import { getNetworkExposureStatus, isLoopbackHost } from './networkExposure.js';
+
+describe('networkExposure.isLoopbackHost', () => {
+ it.each([
+ ['localhost', true],
+ ['LOCALHOST', true],
+ ['127.0.0.1', true],
+ ['::1', true],
+ ['0.0.0.0', false],
+ ['100.111.11.146', false],
+ ['void.taile8179.ts.net', false],
+ ['', false],
+ [null, false],
+ [undefined, false],
+ ])('isLoopbackHost(%p) === %p', (input, expected) => {
+ expect(isLoopbackHost(input)).toBe(expected);
+ });
+});
+
+describe('networkExposure.getNetworkExposureStatus', () => {
+ const ORIGINAL_ENV = { ...process.env };
+
+ beforeEach(() => {
+ vi.clearAllMocks();
+ delete process.env.HOST;
+ delete process.env.PORT;
+ delete process.env.PORTOS_HTTP_PORT;
+ statSync.mockReturnValue(undefined);
+ });
+
+ afterEach(() => {
+ process.env = { ...ORIGINAL_ENV };
+ });
+
+ it('reports HTTP-only when HTTPS is not enabled at boot', () => {
+ getHttpsEnabledAtBoot.mockReturnValue({ value: false, initialized: true });
+ getSelfHost.mockReturnValue(null);
+
+ const status = getNetworkExposureStatus();
+ expect(status.scheme).toBe('http');
+ expect(status.httpsEnabled).toBe(false);
+ expect(status.loopbackMirror.enabled).toBe(false);
+ expect(status.cert.mode).toBeNull();
+ expect(status.cert.tailscaleHost).toBeNull();
+ });
+
+ it('reports HTTPS + tailscale mode when cert meta.json indicates tailscale', () => {
+ getHttpsEnabledAtBoot.mockReturnValue({ value: true, initialized: true });
+ getSelfHost.mockReturnValue('void.taile8179.ts.net');
+ statSync.mockReturnValue({ mtimeMs: 1 });
+ readFileSync.mockReturnValue(JSON.stringify({
+ mode: 'tailscale',
+ hostname: 'void.taile8179.ts.net',
+ ips: ['100.111.11.146']
+ }));
+
+ const status = getNetworkExposureStatus();
+ expect(status.scheme).toBe('https');
+ expect(status.httpsEnabled).toBe(true);
+ expect(status.loopbackMirror.enabled).toBe(true);
+ expect(status.cert.mode).toBe('tailscale');
+ expect(status.cert.tailscaleHost).toBe('void.taile8179.ts.net');
+ expect(status.cert.ips).toEqual(['100.111.11.146']);
+ });
+
+ it('reports HTTPS + self-signed mode when meta.json mode is self-signed', () => {
+ getHttpsEnabledAtBoot.mockReturnValue({ value: true, initialized: true });
+ getSelfHost.mockReturnValue(null);
+ statSync.mockReturnValue({ mtimeMs: 1 });
+ readFileSync.mockReturnValue(JSON.stringify({
+ mode: 'self-signed',
+ ips: ['127.0.0.1', '100.111.11.146']
+ }));
+
+ const status = getNetworkExposureStatus();
+ expect(status.cert.mode).toBe('self-signed');
+ expect(status.cert.tailscaleHost).toBeNull();
+ expect(status.cert.ips).toEqual(['127.0.0.1', '100.111.11.146']);
+ });
+
+ it('returns "unknown" cert mode when HTTPS is on but meta.json is missing', () => {
+ getHttpsEnabledAtBoot.mockReturnValue({ value: true, initialized: true });
+ getSelfHost.mockReturnValue(null);
+ statSync.mockReturnValue(undefined);
+
+ const status = getNetworkExposureStatus();
+ expect(status.cert.mode).toBe('unknown');
+ });
+
+ it('classifies bind audience by host', () => {
+ getHttpsEnabledAtBoot.mockReturnValue({ value: false, initialized: true });
+ getSelfHost.mockReturnValue(null);
+
+ process.env.HOST = '0.0.0.0';
+ expect(getNetworkExposureStatus().bind.audience).toBe('all-interfaces');
+
+ process.env.HOST = '127.0.0.1';
+ expect(getNetworkExposureStatus().bind.audience).toBe('loopback-only');
+
+ process.env.HOST = '100.111.11.146';
+ expect(getNetworkExposureStatus().bind.audience).toBe('specific-interface');
+ });
+
+ it('honors PORT and PORTOS_HTTP_PORT env overrides', () => {
+ getHttpsEnabledAtBoot.mockReturnValue({ value: true, initialized: true });
+ getSelfHost.mockReturnValue(null);
+ process.env.PORT = '6000';
+ process.env.PORTOS_HTTP_PORT = '6001';
+
+ const status = getNetworkExposureStatus();
+ expect(status.bind.port).toBe(6000);
+ expect(status.loopbackMirror.port).toBe(6001);
+ });
+});
diff --git a/server/routes/networkExposure.js b/server/routes/networkExposure.js
new file mode 100644
index 0000000000..68be625275
--- /dev/null
+++ b/server/routes/networkExposure.js
@@ -0,0 +1,11 @@
+import { Router } from 'express';
+import { asyncHandler } from '../lib/errorHandler.js';
+import { getNetworkExposureStatus } from '../lib/networkExposure.js';
+
+const router = Router();
+
+router.get('/status', asyncHandler(async (_req, res) => {
+ res.json(getNetworkExposureStatus());
+}));
+
+export default router;
diff --git a/server/routes/networkExposure.test.js b/server/routes/networkExposure.test.js
new file mode 100644
index 0000000000..7ad2356e69
--- /dev/null
+++ b/server/routes/networkExposure.test.js
@@ -0,0 +1,32 @@
+import { describe, it, expect, vi } from 'vitest';
+import express from 'express';
+import { request } from '../lib/testHelper.js';
+import networkExposureRoutes from './networkExposure.js';
+
+vi.mock('../lib/networkExposure.js', () => ({
+ getNetworkExposureStatus: vi.fn().mockReturnValue({
+ scheme: 'https',
+ httpsEnabled: true,
+ httpsStateInitialized: true,
+ bind: { host: '0.0.0.0', port: 5555, audience: 'all-interfaces' },
+ loopbackMirror: { enabled: true, port: 5553 },
+ cert: { mode: 'tailscale', tailscaleHost: 'void.taile8179.ts.net', ips: [] },
+ docsUrl: 'https://github.com/atomantic/PortOS/blob/main/docs/PORTS.md',
+ }),
+}));
+
+describe('Network Exposure Routes', () => {
+ const app = express();
+ app.use(express.json());
+ app.use('/api/network-exposure', networkExposureRoutes);
+
+ it('returns the network exposure status snapshot', async () => {
+ const res = await request(app).get('/api/network-exposure/status');
+ expect(res.status).toBe(200);
+ expect(res.body.scheme).toBe('https');
+ expect(res.body.bind.port).toBe(5555);
+ expect(res.body.loopbackMirror.port).toBe(5553);
+ expect(res.body.cert.tailscaleHost).toBe('void.taile8179.ts.net');
+ expect(res.body.docsUrl).toMatch(/PORTS\.md$/);
+ });
+});
diff --git a/server/services/dashboardLayouts.js b/server/services/dashboardLayouts.js
index eda22f4fc8..45fe802c01 100644
--- a/server/services/dashboardLayouts.js
+++ b/server/services/dashboardLayouts.js
@@ -38,7 +38,7 @@ const DEFAULT_LAYOUTS = [
'quick-brain', 'quick-task',
'apps',
'cos', 'goal-progress', 'upcoming-tasks',
- 'proactive-alerts', 'review-hub', 'system-health', 'backup', 'death-clock', 'quick-stats', 'decision-log',
+ 'proactive-alerts', 'review-hub', 'system-health', 'network-exposure', 'backup', 'death-clock', 'quick-stats', 'decision-log',
'activity-streak', 'hourly-activity',
],
// Above-the-fold capture row stretches to h=5 so the Quick Task card
@@ -60,6 +60,7 @@ const DEFAULT_LAYOUTS = [
{ id: 'backup', x: 0, y: 10, w: 3, h: 4 },
{ id: 'quick-stats', x: 3, y: 10, w: 3, h: 3 },
{ id: 'goal-progress', x: 6, y: 10, w: 3, h: 4 },
+ { id: 'network-exposure', x: 9, y: 10, w: 3, h: 4 },
// Row 14–17: lower-priority + cos
{ id: 'decision-log', x: 0, y: 14, w: 4, h: 2 },
{ id: 'cos', x: 4, y: 14, w: 5, h: 4 },
@@ -104,17 +105,18 @@ const DEFAULT_LAYOUTS = [
id: 'ops',
name: 'Ops',
builtIn: true,
- widgets: ['system-health', 'cos', 'backup', 'apps', 'quick-stats'],
+ widgets: ['system-health', 'network-exposure', 'cos', 'backup', 'apps', 'quick-stats'],
// System monitoring focus — system-health takes the tall left column
// (the primary alarm surface), cos in the center for ChiefOfStaff
// status, backup + quick-stats stacked on the right, apps grid fills
// the empty cell below cos so all 5 widgets fit above the fold.
grid: [
- { id: 'system-health', x: 0, y: 0, w: 6, h: 5 },
- { id: 'quick-stats', x: 6, y: 0, w: 6, h: 3 },
- { id: 'cos', x: 6, y: 3, w: 6, h: 4 },
- { id: 'backup', x: 0, y: 5, w: 6, h: 3 },
- { id: 'apps', x: 0, y: 8, w: 12, h: 11 },
+ { id: 'system-health', x: 0, y: 0, w: 6, h: 5 },
+ { id: 'quick-stats', x: 6, y: 0, w: 6, h: 3 },
+ { id: 'cos', x: 6, y: 3, w: 6, h: 4 },
+ { id: 'backup', x: 0, y: 5, w: 3, h: 3 },
+ { id: 'network-exposure', x: 3, y: 5, w: 3, h: 3 },
+ { id: 'apps', x: 0, y: 8, w: 12, h: 11 },
],
},
];