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
import { describe, it, expect } from 'vitest';
import { getLaunchUrls, getPrimaryLaunchUrl } from './appUrls';
import { PORTOS_APP_ID } from './apiCore';
// The "Open UI" affordance in AppDetailView renders a button per non-null launch
// URL and hides entirely when there are none. A portless desktop app (a game
// window, #2991) must therefore surface NO launch URL — never a link to
// `undefined` — while a port-bearing app still does.
describe('getLaunchUrls — portless vs port-bearing (#2991)', () => {
it('returns all-null for a portless desktop app', () => {
const urls = getLaunchUrls({ id: 'the-game', type: 'desktop', uiPort: null, apiPort: null, devUiPort: null, tlsPort: null });
expect(urls).toEqual({ https: null, http: null, dev: null });
// The single-click launcher likewise has nothing to open.
expect(getPrimaryLaunchUrl({ id: 'the-game', type: 'desktop' })).toBeNull();
});
it('returns an http launch URL when the app has a uiPort', () => {
const urls = getLaunchUrls({ id: 'web-app', type: 'express', uiPort: 3000 });
expect(urls.http).toBe(`http://${window.location.hostname}:3000`);
expect(getPrimaryLaunchUrl({ id: 'web-app', type: 'express', uiPort: 3000 }))
.toBe(`http://${window.location.hostname}:3000`);
});
it('prefers https when a tlsPort is present', () => {
const urls = getLaunchUrls({ id: 'web-app', type: 'express', uiPort: 3000, tlsPort: 8443 });
expect(urls.https).toBe(`https://${window.location.hostname}:8443`);
expect(getPrimaryLaunchUrl({ id: 'web-app', type: 'express', uiPort: 3000, tlsPort: 8443 }))
.toBe(`https://${window.location.hostname}:8443`);
});
it('keeps the http launch URL when uiPort is a distinct plain-HTTP listener', () => {
const urls = getLaunchUrls({ id: 'web-app', type: 'express', uiPort: 3000, tlsPort: 8443 });
expect(urls.http).toBe(`http://${window.location.hostname}:3000`);
});
it('does not advertise a Dev UI for the PortOS management entry', () => {
const urls = getLaunchUrls({ id: PORTOS_APP_ID, type: 'express', uiPort: 5555, devUiPort: 5554 });
expect(urls).toEqual({ https: null, http: window.location.origin, dev: null });
});
});
// A single-listener dev server that terminates TLS itself (a Vite app reading the
// shared Tailscale cert) reports the SAME port as uiPort/devUiPort and tlsPort.
// That port speaks TLS only, so emitting an http:// URL for it renders a launch
// button that can never connect.
describe('getLaunchUrls — TLS and plain-HTTP on the same port', () => {
it('suppresses the http URL when uiPort is the TLS port', () => {
const urls = getLaunchUrls({ id: 'vite-app', type: 'vite', uiPort: 3117, tlsPort: 3117 });
expect(urls.https).toBe(`https://${window.location.hostname}:3117`);
expect(urls.http).toBeNull();
});
it('suppresses the dev URL when devUiPort is the TLS port', () => {
const urls = getLaunchUrls({ id: 'vite-app', type: 'vite', uiPort: 3117, devUiPort: 3117, tlsPort: 3117 });
expect(urls.dev).toBeNull();
// The one surviving URL is the working one, so the single-click launcher still opens it.
expect(getPrimaryLaunchUrl({ id: 'vite-app', type: 'vite', uiPort: 3117, devUiPort: 3117, tlsPort: 3117 }))
.toBe(`https://${window.location.hostname}:3117`);
});
it('keeps a dev URL that runs on its own plain-HTTP port', () => {
const urls = getLaunchUrls({ id: 'vite-app', type: 'vite', uiPort: 5173, devUiPort: 5174, tlsPort: 5173 });
expect(urls.dev).toBe(`http://${window.location.hostname}:5174`);
expect(urls.http).toBeNull();
});
});