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

Skip the documentRender browser suite on a Chrome without H.264 (#11593)

[._.]/ Adam Eivyce5becbced17
diff --git a/server/lib/README.md b/server/lib/README.md
index 3503249a48..4c9ff27b1d 100644
--- a/server/lib/README.md
+++ b/server/lib/README.md
@@ -768,7 +768,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub
| Module | Purpose |
|---|---|
-| `browserSuiteGate.js` | `browserSuiteCanRun(label, prerequisites)` is the `canRun` guard for the cross-workspace `*.browser.test.js` suites (Chrome + ffmpeg + the client bundler). Pass `{ name: discoveredValue }`; a falsy value is missing. Returns `false` with a visible skip log locally, but throws naming the missing prerequisites when `PORTOS_REQUIRE_BROWSER_SUITES` is set — the flag the CI `database` job sets for the browser suites the planner selected (#10312). |
+| `browserSuiteGate.js` | `chromeWithH264(path)` returns the path only when that Chrome decodes H.264 (null on codec-less Chromium); `browserSuiteCanRun(label, prerequisites)` is the `canRun` guard for the cross-workspace `*.browser.test.js` suites (Chrome + ffmpeg + the client bundler). Pass `{ name: discoveredValue }`; a falsy value is missing. Returns `false` with a visible skip log locally, but throws naming the missing prerequisites when `PORTOS_REQUIRE_BROWSER_SUITES` is set — the flag the CI `database` job sets for the browser suites the planner selected (#10312). |
| `dbTestGate.js` | `requireDbOrSkip(label, dbReady, reason)` keeps a missing local test database as a visible skipped suite, but throws when `PORTOS_REQUIRE_DB` is set so CI cannot pass after DB-backed suites disappear. |
| `gitTestRepo.js` | Shared real-git sandbox for integration tests (#4394): one initialized template (working tree + bare origin) per worker, then `fs.cp` into a fresh temp dir. `makeGitSandbox({ origin })`, `attachBareOrigin(scratch, repo)`, `materializeGitRepo(dest)`, `destroyGitSandbox`, plus `SKIP_HEAVY_INTEGRATION` (`VITEST_FAST=1`). `resetGitSandbox({ scratch, repo, initialHead })` / `resetGitWorktreeSandbox(repo, initialHead)` restore a sandbox in place (branches, worktrees, remote) so a `describe` can build one sandbox in `beforeAll` and reset between tests instead of paying the fs.cp/rm cycle per test (#5902). Every entry point runs `assertTempPath` first, so a path outside `os.tmpdir()` throws instead of `git init`-ing or `rm -rf`-ing a real checkout (#4554). Fixture-local maintenance/GC detachment is disabled so awaited Git operations retain their writers through teardown. Still real git — just not rebuilt from `init`+`commit`+`push` in every `beforeEach`. |
| `mirrorParity.js` | Source-extraction and comparison primitives for declaration-level contract tests: the vendored `aiToolkit/` copy of `TOOL_USE_RE` (`localModelHeuristics.mirror.test.js`), and the bootstrap sequence's body assertions (`bootstrap*.test.js`). A pure module the browser needs is imported by the client rather than mirrored, so no client↔server copy test should need these: `stripCommentsAndNormalize` (so per-side commentary may diverge but logic may not), `extractDeclaration(src, name)` (balanced `{}`/`()`/`[]` walk over `function` / `async function` / `const`), and `compareDeclaration(serverSrc, clientSrc, name)`. Use these instead of hand-rolling a brace-walker per mirror. Pure — no `vitest` import — so callers own the assertions. |
diff --git a/server/lib/browserSuiteGate.js b/server/lib/browserSuiteGate.js
index ea656ea904..176495811c 100644
--- a/server/lib/browserSuiteGate.js
+++ b/server/lib/browserSuiteGate.js
@@ -1,3 +1,8 @@
+import { execFileSync } from 'node:child_process';
+import { mkdtempSync, rmSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+
/**
* Keep cross-workspace browser suites as visible skips on machines without
* Chrome, ffmpeg or the client workspace, while letting the one CI job that
@@ -21,3 +26,26 @@ export function browserSuiteCanRun(label, prerequisites, { onUnavailable } = {})
console.log(`⏭️ ${label}: skipping suite — ${reason}`);
return false;
}
+
+const H264_PROBE_PAGE = `data:text/html,<body><script>document.body.textContent='H264:'+document.createElement('video').canPlayType('video/mp4; codecs="avc1.640028"')</script></body>`;
+
+/**
+ * Whether a Chrome binary can decode H.264 (Playwright's bundled Chromium has
+ * no proprietary codecs). Returns the binary path when it can, else null, so it
+ * drops straight into a `browserSuiteCanRun` prerequisite map. A binary that
+ * fails to launch or answer counts as unable.
+ */
+export function chromeWithH264(chromePath) {
+ if (!chromePath) return null;
+ const profile = mkdtempSync(join(tmpdir(), 'portos-h264-probe-'));
+ try {
+ const dom = execFileSync(chromePath, ['--headless=new', '--disable-gpu', '--no-sandbox',
+ `--user-data-dir=${profile}`, '--virtual-time-budget=2000', '--dump-dom', H264_PROBE_PAGE],
+ { encoding: 'utf8', timeout: 20000, stdio: ['ignore', 'pipe', 'ignore'] });
+ return /H264:\w+/.test(dom) ? chromePath : null;
+ } catch {
+ return null;
+ } finally {
+ rmSync(profile, { recursive: true, force: true });
+ }
+}
diff --git a/server/services/musicVideo/documentRender.browser.test.js b/server/services/musicVideo/documentRender.browser.test.js
index 08849e44a6..d5c687ad8b 100644
--- a/server/services/musicVideo/documentRender.browser.test.js
+++ b/server/services/musicVideo/documentRender.browser.test.js
@@ -16,7 +16,7 @@ import { execFileSync, spawn } from 'node:child_process';
import { chromium } from 'playwright-core';
import sharp from 'sharp';
import { cleanupTempDataRoots, lazyTempDataRoot, makePathsProxy, ownTestBodies } from '../../lib/mockPathsDataRoot.js';
-import { browserSuiteCanRun } from '../../lib/browserSuiteGate.js';
+import { browserSuiteCanRun, chromeWithH264 } from '../../lib/browserSuiteGate.js';
const { it, drain } = ownTestBodies(vitestIt);
const lifecycle = vi.hoisted(() => ({ diagnostics: null }));
@@ -78,7 +78,7 @@ const chrome = [process.env.CHROME_PATH, chromium.executablePath(),
].find((path) => path && existsSync(path));
const ffmpeg = await findFfmpeg();
// Imported discovery helpers can initialize mocked paths even on a skip.
-const canRun = browserSuiteCanRun('documentRender browser suite', { Chrome: chrome, ffmpeg }, { onUnavailable: cleanupTempDataRoots });
+const canRun = browserSuiteCanRun('documentRender browser suite', { 'Chrome with H.264': chromeWithH264(chrome), ffmpeg }, { onUnavailable: cleanupTempDataRoots });
describe.skipIf(!canRun)('layered template with real Chrome and ffmpeg', () => {
let proc;