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
feat: headed mode and persistent browser profile for manual auth
Adam Eivy791d8dafe252
diff --git a/.changelog/v0.11.17.md b/.changelog/v0.11.17.mdindex f5ca74d7fa..82c6bfc625 100644--- a/.changelog/v0.11.17.md+++ b/.changelog/v0.11.17.md@@ -212,11 +212,15 @@ This release focuses on security improvements, bug fixes for the AI runner syste- **Learning tab shows both**: The Duration Estimates table now displays both average and estimated (P80) columns so users can see the range- **Backward compatible**: Existing learning data without max/P80 fields gracefully falls back to using the average-### Browser URL Navigation+### Browser URL Navigation & Headed Mode- **Open URL in CDP browser**: Added a URL input bar to the Browser page that opens any URL in a new tab of the managed CDP browser- **Auto-prefix**: URLs without a protocol are automatically prefixed with `https://`- **Server endpoint**: New `POST /api/browser/navigate` route with Zod URL validation, using CDP's `/json/new` endpoint to open tabs- **Conditional visibility**: The URL bar only appears when the browser is connected, keeping the UI clean when the browser is stopped+- **Headed mode support**: Browser now reads the `headless` config setting from `data/browser-config.json` — disable headless to see the browser window and manually authenticate to sites like GitHub+- **Persistent browser profile**: Auth cookies, localStorage, and sessions now persist across restarts via `--user-data-dir` pointing to `data/browser-profile`+- **Config-driven launch**: The browser process reads its configuration from the shared config file on startup instead of hardcoding `headless: true`+- **Live mode display**: Sidebar shows whether the running browser is in headed or headless mode, with a restart hint after config changes### Architecture Documentation Update- **Updated system diagram**: Expanded the architecture diagram to include portos-browser and portos-autofixer as PM2-managed satellite services alongside Chief of Staffdiff --git a/browser/server.js b/browser/server.jsindex 895bc6d2d3..b49c0c7436 100644--- a/browser/server.js+++ b/browser/server.js@@ -1,5 +1,13 @@import { chromium } from 'playwright';import { createServer } from 'http';+import { readFile, mkdir } from 'fs/promises';+import { resolve, dirname } from 'path';+import { fileURLToPath } from 'url';++const __dirname = dirname(fileURLToPath(import.meta.url));+const PROJECT_ROOT = resolve(__dirname, '..');+const CONFIG_FILE = resolve(PROJECT_ROOT, 'data', 'browser-config.json');+const DEFAULT_PROFILE_DIR = resolve(PROJECT_ROOT, 'data', 'browser-profile');const CDP_PORT = parseInt(process.env.CDP_PORT || '5556', 10);const HEALTH_PORT = parseInt(process.env.PORT || '5557', 10);@@ -8,15 +16,28 @@ const HEALTH_PORT = parseInt(process.env.PORT || '5557', 10);const CDP_HOST = process.env.CDP_HOST || '127.0.0.1';let browser = null;+let headlessMode = true;++async function loadConfig() {+ const raw = await readFile(CONFIG_FILE, 'utf-8').catch(() => null);+ return raw ? JSON.parse(raw) : {};+}async function launchBrowser() {- console.log(`🌐 Launching persistent Chromium browser with CDP on ${CDP_HOST}:${CDP_PORT}`);+ const config = await loadConfig();+ headlessMode = config.headless !== false;+ const profileDir = config.userDataDir || DEFAULT_PROFILE_DIR;++ await mkdir(profileDir, { recursive: true });++ console.log(`🌐 Launching browser (headless=${headlessMode}, profile=${profileDir}) CDP on ${CDP_HOST}:${CDP_PORT}`);browser = await chromium.launch({- headless: true,+ headless: headlessMode,args: [`--remote-debugging-port=${CDP_PORT}`,`--remote-debugging-address=${CDP_HOST}`,+ `--user-data-dir=${profileDir}`,'--no-first-run','--no-default-browser-check','--disable-background-networking',@@ -46,7 +67,8 @@ const healthServer = createServer((req, res) => {status,cdpPort: CDP_PORT,cdpHost: CDP_HOST,- cdpEndpoint: `ws://${CDP_HOST}:${CDP_PORT}`+ cdpEndpoint: `ws://${CDP_HOST}:${CDP_PORT}`,+ headless: headlessMode}));} else if (req.url === '/') {res.writeHead(200, { 'Content-Type': 'application/json' });diff --git a/client/src/pages/Browser.jsx b/client/src/pages/Browser.jsxindex b6534fba76..970128b141 100644--- a/client/src/pages/Browser.jsx+++ b/client/src/pages/Browser.jsx@@ -115,7 +115,7 @@ export default function BrowserPage() {if (saved) {setConfig(saved);setConfigDraft(saved);- toast.success('Browser config saved');+ toast.success('Browser config saved — restart browser to apply changes');}}, [configDraft]);@@ -494,9 +494,9 @@ export default function BrowserPage() {<span className="text-sm font-mono text-white">{status?.config?.healthPort || '-'}</span></div><div className="flex items-center justify-between">- <span className="text-gray-400 text-sm">Headless</span>- <span className={`text-sm font-medium ${status?.config?.headless ? 'text-port-success' : 'text-port-warning'}`}>- {status?.config?.headless ? 'Yes' : 'No'}+ <span className="text-gray-400 text-sm">Mode</span>+ <span className={`text-sm font-medium ${status?.headless === false ? 'text-port-warning' : 'text-port-success'}`}>+ {status?.headless === false ? 'Headed (visible)' : 'Headless'}</span></div><div className="flex items-center justify-between">@@ -524,9 +524,9 @@ export default function BrowserPage() {<h3 className="font-semibold text-white mb-3">Usage</h3><ul className="space-y-2 text-sm text-gray-400"><li>1. Launch the browser using the controls</li>- <li>2. Browser runs as a PM2 process (portos-browser)</li>- <li>3. Connect via CDP endpoint for automation</li>- <li>4. Sessions persist across restarts</li>+ <li>2. To sign in to sites, disable headless in Config, restart, then navigate to the login page</li>+ <li>3. Auth cookies persist across restarts in the browser profile</li>+ <li>4. Switch back to headless after authenticating</li></ul></div></div>diff --git a/server/services/browserService.js b/server/services/browserService.jsindex 442a7daa66..24f70c74e1 100644--- a/server/services/browserService.js+++ b/server/services/browserService.js@@ -16,13 +16,15 @@ const CONFIG_FILE = join(DATA_DIR, 'browser-config.json');export const browserEvents = new EventEmitter();+const DEFAULT_PROFILE_DIR = join(DATA_DIR, 'browser-profile');+const DEFAULT_CONFIG = {cdpPort: 5556,cdpHost: '127.0.0.1',healthPort: 5557,autoConnect: true,headless: true,- userDataDir: ''+ userDataDir: DEFAULT_PROFILE_DIR};let cachedConfig = null;@@ -85,6 +87,7 @@ export async function getHealthStatus() {cdpHost: data.cdpHost || config.cdpHost,healthPort: config.healthPort,cdpEndpoint: data.cdpEndpoint || `ws://${config.cdpHost}:${config.cdpPort}`,+ headless: data.headless ?? config.headless,status: data.status};}