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([setup-browser-canary-headless]): default the managed browser to headed

[._.]/ Adam Eivy6382e6edfbf3
diff --git a/data.reference/browser-config.json b/data.reference/browser-config.json
index 61cd66d851..2e90a46da8 100644
--- a/data.reference/browser-config.json
+++ b/data.reference/browser-config.json
@@ -3,6 +3,6 @@
"cdpHost": "127.0.0.1",
"healthPort": 5557,
"autoConnect": true,
- "headless": true,
+ "headless": false,
"userDataDir": ""
}
diff --git a/scripts/migrations/061-browser-config-headed-default.js b/scripts/migrations/061-browser-config-headed-default.js
new file mode 100644
index 0000000000..17335aad84
--- /dev/null
+++ b/scripts/migrations/061-browser-config-headed-default.js
@@ -0,0 +1,55 @@
+/**
+ * Flip the managed-browser default from headless to headed for existing
+ * installs.
+ *
+ * The whole point of the custom-Chrome-binary / Canary feature is a *visible*,
+ * differentiated browser — but `data.reference/browser-config.json` historically
+ * shipped `"headless": true`, so every install (and every Canary opt-in) ran the
+ * managed browser invisibly. The seed now ships `"headless": false`; fresh
+ * installs pick that up from data.reference automatically.
+ *
+ * Existing installs keep their old `data/browser-config.json`, so they need this
+ * migration to flip the value. Conservative, matching migration 058's policy:
+ * - Only flip when `headless === true` — the exact old shipped default. A user
+ * who already set `headless: false`, removed the key, or stored some other
+ * value is left untouched.
+ * - Absent file → skip (fresh install seeds from data.reference, already false).
+ *
+ * Other browser-config keys (chromePath, userDataDir, cdpPort, …) are preserved.
+ */
+
+import { readFile, writeFile } from 'fs/promises';
+import { join } from 'path';
+
+const CONFIG_REL_PATH = 'data/browser-config.json';
+
+export default {
+ async up({ rootDir }) {
+ const configPath = join(rootDir, CONFIG_REL_PATH);
+ const raw = await readFile(configPath, 'utf-8').catch((err) => {
+ if (err.code === 'ENOENT') return null;
+ throw err;
+ });
+ if (raw == null) {
+ console.log(`📄 ${CONFIG_REL_PATH} not present — skipping (fresh install seeds headed from data.reference)`);
+ return;
+ }
+
+ let config;
+ try {
+ config = JSON.parse(raw);
+ } catch (err) {
+ console.log(`⚠️ ${CONFIG_REL_PATH}: invalid JSON, skipping (${err.message})`);
+ return;
+ }
+
+ if (config?.headless !== true) {
+ console.log(`✅ ${CONFIG_REL_PATH}: headless already not the legacy default (${JSON.stringify(config?.headless)}) — left untouched`);
+ return;
+ }
+
+ config.headless = false;
+ await writeFile(configPath, `${JSON.stringify(config, null, 2)}\n`);
+ console.log(`📝 ${CONFIG_REL_PATH}: flipped headless true → false (default HEADED)`);
+ },
+};
diff --git a/scripts/migrations/061-browser-config-headed-default.test.js b/scripts/migrations/061-browser-config-headed-default.test.js
new file mode 100644
index 0000000000..0099f2bffb
--- /dev/null
+++ b/scripts/migrations/061-browser-config-headed-default.test.js
@@ -0,0 +1,103 @@
+/**
+ * Test for migration 061 — flip the managed-browser default from headless to
+ * headed for existing installs. Picked up by server/vitest.config.js's
+ * `../scripts/**\/*.test.js` glob.
+ */
+import { describe, it, expect, beforeEach, afterEach } from 'vitest';
+import { mkdtempSync, rmSync, writeFileSync, readFileSync, mkdirSync, existsSync } from 'fs';
+import { tmpdir } from 'os';
+import { join } from 'path';
+
+import migration from './061-browser-config-headed-default.js';
+
+const writeJson = (path, value) => writeFileSync(path, JSON.stringify(value, null, 2) + '\n');
+const readJson = (path) => JSON.parse(readFileSync(path, 'utf-8'));
+
+const legacySeed = (overrides = {}) => ({
+ cdpPort: 5556,
+ cdpHost: '127.0.0.1',
+ healthPort: 5557,
+ autoConnect: true,
+ headless: true,
+ userDataDir: '',
+ ...overrides,
+});
+
+describe('migration 061 — browser-config headed default', () => {
+ let rootDir;
+ let configPath;
+
+ beforeEach(() => {
+ rootDir = mkdtempSync(join(tmpdir(), 'migration-061-'));
+ mkdirSync(join(rootDir, 'data'), { recursive: true });
+ configPath = join(rootDir, 'data/browser-config.json');
+ });
+
+ afterEach(() => {
+ rmSync(rootDir, { recursive: true, force: true });
+ });
+
+ it('flips the legacy headless:true default to false', async () => {
+ writeJson(configPath, legacySeed());
+
+ await migration.up({ rootDir });
+
+ expect(readJson(configPath).headless).toBe(false);
+ });
+
+ it('preserves all other config keys when flipping', async () => {
+ writeJson(configPath, legacySeed({ chromePath: '/Apps/Canary', userDataDir: '/data/p' }));
+
+ await migration.up({ rootDir });
+
+ const after = readJson(configPath);
+ expect(after.headless).toBe(false);
+ expect(after.chromePath).toBe('/Apps/Canary');
+ expect(after.userDataDir).toBe('/data/p');
+ expect(after.cdpPort).toBe(5556);
+ });
+
+ it('leaves a user-customized headless:false untouched (byte-identical)', async () => {
+ writeJson(configPath, legacySeed({ headless: false }));
+ const before = readFileSync(configPath, 'utf-8');
+
+ await migration.up({ rootDir });
+
+ expect(readFileSync(configPath, 'utf-8')).toBe(before);
+ });
+
+ it('leaves a config with no headless key untouched', async () => {
+ const noKey = legacySeed();
+ delete noKey.headless;
+ writeJson(configPath, noKey);
+ const before = readFileSync(configPath, 'utf-8');
+
+ await migration.up({ rootDir });
+
+ expect(readFileSync(configPath, 'utf-8')).toBe(before);
+ });
+
+ it('does not treat a truthy non-boolean as the legacy default', async () => {
+ writeJson(configPath, legacySeed({ headless: 'true' }));
+ const before = readFileSync(configPath, 'utf-8');
+
+ await migration.up({ rootDir });
+
+ expect(readFileSync(configPath, 'utf-8')).toBe(before);
+ });
+
+ it('is a no-op when data/browser-config.json does not exist (fresh install)', async () => {
+ await migration.up({ rootDir });
+
+ expect(existsSync(configPath)).toBe(false);
+ });
+
+ it('does not modify the file on invalid JSON (logs a warning and skips)', async () => {
+ writeFileSync(configPath, '{ not valid json');
+ const before = readFileSync(configPath, 'utf-8');
+
+ await migration.up({ rootDir });
+
+ expect(readFileSync(configPath, 'utf-8')).toBe(before);
+ });
+});
diff --git a/scripts/setup-browser.js b/scripts/setup-browser.js
index 3d2169b158..e514e4c409 100644
--- a/scripts/setup-browser.js
+++ b/scripts/setup-browser.js
@@ -102,6 +102,10 @@ async function applyCanaryToConfig(found) {
}
config.chromePath = found.bin;
if (found.app) config.macAppBundle = found.app;
+ // Canary is a deliberately visible, differentiated browser — opting into it
+ // headless defeats the point. Force headed so the user actually sees the
+ // managed browser they just configured.
+ config.headless = false;
delete config.canaryPromptDeclined;
await saveConfig(config);
console.log(`✅ PortOS browser set to Chrome Canary → ${found.bin}`);
diff --git a/server/services/browserService.js b/server/services/browserService.js
index ac67261d54..a6865cacdb 100644
--- a/server/services/browserService.js
+++ b/server/services/browserService.js
@@ -38,7 +38,10 @@ const DEFAULT_CONFIG = {
cdpHost: process.env.CDP_HOST || '127.0.0.1',
healthPort: 5557,
autoConnect: true,
- headless: true,
+ // Default HEADED — the managed CDP browser is meant to be visible (see
+ // browser/server.js, which already launches headed unless `headless === true`).
+ // Keeping this fallback headed matches that and the shipped seed.
+ headless: false,
userDataDir: DEFAULT_PROFILE_DIR,
downloadDir: DEFAULT_DOWNLOAD_DIR
};