@devries-cameron20 / t3code Mirror · read-only / commits / fd1c3386c4
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 23, 18:00 UTC

fix(release): unblock nightly browser tests and cli builds (#16515)

Co-authored-by: maria-rcks <254055478+maria-rcks@users.noreply.github.com>

maria committed Oct 6, 2026 at 14:12 UTC fd1c3386c4d60f3477ab3f13c87537848de099f5
3 files changed +15 -7
.github/workflows/release.yml
+3
@@ -330,6 +330,9 @@ jobs:
330 # No Electron setup here: `t3` (apps/server) has no Electron dependency
331 # and none of its tests touch the runtime. Only the non-server `test`
332 # job, which covers @t3tools/desktop, needs the download.
333 + - name: Install Chromium for server browser integration tests
334 + run: node apps/server/node_modules/playwright-core/cli.js install --with-deps --only-shell chromium
335 +
336 - name: Test
337 run: vp run --filter t3 test --shard ${{ matrix.shard }}/${{ strategy.job-total }}
338
apps/server/src/preview/ServerBrowserContexts.test.ts
+3 -4
@@ -1,7 +1,7 @@
1 import * as NodeEvents from "node:events";
2
3 import { INCOGNITO_BROWSER_PROFILE_ID } from "@t3tools/contracts";
4 -import type { Browser, BrowserContext, BrowserType } from "playwright-core";
4 +import { chromium, type Browser, type BrowserContext, type BrowserType } from "playwright-core";
5 import { beforeEach, describe, expect, it, vi } from "vite-plus/test";
6
7 import { ServerBrowserContexts } from "./ServerBrowserContexts.ts";
@@ -12,9 +12,8 @@ const launches = vi.hoisted(() => ({
12 mkdir: vi.fn().mockResolvedValue(undefined),
13 rm: vi.fn().mockResolvedValue(undefined),
14 }));
15 -vi.mock("playwright-core", () => ({
16 - chromium: { launch: launches.launch, launchPersistentContext: launches.persistent },
17 -}));
15 +vi.spyOn(chromium, "launch").mockImplementation(launches.launch);
16 +vi.spyOn(chromium, "launchPersistentContext").mockImplementation(launches.persistent);
17 vi.mock("node:fs/promises", () => ({ mkdir: launches.mkdir, rm: launches.rm }));
18
19 const makeContext = () => {
apps/server/src/preview/ServerBrowserContexts.ts
+9 -3
@@ -2,11 +2,17 @@
2 import { INCOGNITO_BROWSER_PROFILE_ID } from "@t3tools/contracts";
3 import { constVoid } from "effect/Function";
4 import * as NodeFSP from "node:fs/promises";
5 +import * as NodeModule from "node:module";
6 import * as NodePath from "node:path";
7 import type { Browser, BrowserContext } from "playwright-core";
8
9 import { sandboxDisabled } from "./PreviewBrowserHost.ts";
10
11 +// Playwright needs its files on disk. createRequire also resolves it from a Node SEA executable.
12 +const requirePlaywright = NodeModule.createRequire(import.meta.url);
13 +const loadPlaywright = () =>
14 + requirePlaywright("playwright-core") as typeof import("playwright-core");
15 +
16 interface Options {
17 readonly profilesDir: string;
18 /** The shared headless browser's executable, installing it on first use. */
@@ -54,7 +60,7 @@ export class ServerBrowserContexts {
60 private sharedBrowser() {
61 if (!this.browser) {
62 const launched = this.launchOptions().then(async (options) => {
57 - const { chromium } = await import("playwright-core");
63 + const { chromium } = loadPlaywright();
64 const browser = await this.launch(options, () => chromium.launch(options));
65 browser.on("disconnected", () => {
66 if (this.browser === launched) this.browser = undefined;
@@ -104,7 +110,7 @@ export class ServerBrowserContexts {
110 }
111 const directory = this.profileDirectory(profileId);
112 const options = await this.launchOptions();
107 - const { chromium } = await import("playwright-core");
113 + const { chromium } = loadPlaywright();
114 await NodeFSP.mkdir(directory, { recursive: true });
115 return this.launch(options, () =>
116 chromium.launchPersistentContext(directory, { ...options, ...contextOptions }),
@@ -133,7 +139,7 @@ export class ServerBrowserContexts {
139 * serves. The page keeps the desktop's storage, size, and window.
140 */
141 async connectDesktopPage(endpoint: string) {
136 - const { chromium } = await import("playwright-core");
142 + const { chromium } = loadPlaywright();
143 const browser = await chromium.connectOverCDP(endpoint, { timeout: 15_000 });
144 const page = browser.contexts().flatMap((context) => context.pages())[0];
145 if (!page) {