@devries-cameron20 / t3code Mirror · read-only / commits / e91595ba0a
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 22, 05:45 UTC

fix(server): browser setup advice names the server's T3 home (#29646)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Alex Southwell committed Nov 3, 2026 at 23:22 UTC e91595ba0a1a52623bd96a3f63a625c9e14c91a6
3 files changed +39 -2
apps/server/src/htmlRender/HtmlRender.test.ts
+29
@@ -22,6 +22,7 @@ import * as ServerConfig from "../config.ts";
22 import * as HtmlRender from "./HtmlRender.ts";
23 import { HtmlRenderBrowserError } from "./headlessChrome.ts";
24 import * as PreviewBrowser from "../preview/PreviewBrowser.ts";
25 +import * as PreviewBrowserHost from "../preview/PreviewBrowserHost.ts";
26
27 const TEST_BROWSER_ENV = "T3CODE_TEST_HEADLESS_SHELL";
28
@@ -365,6 +366,34 @@ fs.createReadStream(null, { fd: 3 }).on("end", quit).on("data", (chunk) => {
366 expect(Option.getOrElse(exitedBy, () => "killed by a signal")).toBe("asked to close");
367 }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
368 );
369 +
370 + it.live("names this server's home in the browser setup command", () =>
371 + Effect.gen(function* () {
372 + const fileSystem = yield* FileSystem.FileSystem;
373 + const path = yield* Path.Path;
374 + const directory = yield* fileSystem.makeTempDirectoryScoped({
375 + prefix: "t3-fake-browser-",
376 + });
377 + const executable = path.join(directory, "chrome-headless-shell");
378 + yield* fileSystem.writeFileString(
379 + executable,
380 + `#!${process.execPath}\nprocess.stderr.write(${JSON.stringify(PreviewBrowserHost.NO_SANDBOX_SIGNATURE)});\nprocess.exit(1);\n`,
381 + { mode: 0o755 },
382 + );
383 +
384 + const { error, baseDir } = yield* Effect.gen(function* () {
385 + const { baseDir } = yield* ServerConfig.ServerConfig;
386 + const htmlRender = yield* HtmlRender.HtmlRender;
387 + const error = yield* htmlRender.preview({ html: "<p>x</p>" }).pipe(Effect.flip);
388 + return { error, baseDir };
389 + }).pipe(
390 + Effect.provide(layerHtmlRender(executable)),
391 + Effect.provideService(HostProcess.UserId, 1000),
392 + );
393 + expect(error).toBeInstanceOf(PreviewBrowserHost.PreviewBrowserSandboxError);
394 + expect(error.message).toContain(`browser setup --base-dir ${baseDir}`);
395 + }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
396 + );
397 },
398 );
399
apps/server/src/htmlRender/HtmlRender.ts
+5 -1
@@ -340,7 +340,11 @@ const make = Effect.gen(function* () {
340 const browsers = yield* Semaphore.make(MAX_CONCURRENT_BROWSERS);
341 // Keep Chrome sandboxed unless explicitly disabled; root must opt out to run.
342 const noSandbox = PreviewBrowserHost.sandboxDisabled(yield* HostProcess.Environment);
343 - const setupCommand = yield* resolveRootCliCommand(PreviewBrowserHost.SETUP_SUBCOMMAND);
343 + // sudo resets the environment, so the command has to name this server's home.
344 + const setupCommand = yield* resolveRootCliCommand(PreviewBrowserHost.SETUP_SUBCOMMAND, [
345 + "--base-dir",
346 + config.baseDir,
347 + ]);
348
349 const launching = <A>(
350 executable: string,
apps/server/src/preview/ServerBrowser.ts
+5 -1
@@ -469,7 +469,11 @@ const make = Effect.gen(function* () {
469 const runFork = Effect.runForkWith(yield* Effect.context<never>());
470 const runPromise = Effect.runPromiseWith(yield* Effect.context<never>());
471 const launchServices = yield* Effect.context<ChildProcessSpawner.ChildProcessSpawner>();
472 - const setupCommand = yield* resolveRootCliCommand(PreviewBrowserHost.SETUP_SUBCOMMAND);
472 + // sudo resets the environment, so the command has to name this server's home.
473 + const setupCommand = yield* resolveRootCliCommand(PreviewBrowserHost.SETUP_SUBCOMMAND, [
474 + "--base-dir",
475 + config.baseDir,
476 + ]);
477 const agentScope = yield* AgentScope;
478 const launchersDir = NodePath.join(config.stateDir, "server-browser", "launchers");
479