@devries-cameron20 / t3code Mirror · read-only / commits / cd69df4750
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, 18:15 UTC

fix(server): find the resource monitor when the server runs from its build output (#23965)

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com> Co-authored-by: Theo Browne <me@t3.gg> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Victor Vogel <satsdev@only21mil.xyz> Co-authored-by: Julius Marminge <julius0216@outlook.com> Co-authored-by: Yash Singh <saiansh2525@gmail.com> Co-authored-by: Joseph Vidal <135430578+josephv123@users.noreply.github.com> Co-authored-by: Theo Browne <me@theo.li> Co-authored-by: shivam <91240327+shivamhwp@users.noreply.github.com> Co-authored-by: PR Batch Tester <agent@local.test> Co-authored-by: fixfon <12512757+fixfon@users.noreply.github.com> Co-authored-by: Utkarsh Patil <73941998+UtkarshUsername@users.noreply.github.com> Co-authored-by: Yukun Shan <92423096+nateEc@users.noreply.github.com> Co-authored-by: Akshar Patel <123344143+AksharP5@users.noreply.github.com> Co-authored-by: Ben Davis <45952064+bmdavis419@users.noreply.github.com>

Yordis Prieto committed Oct 23, 2026 at 19:11 UTC cd69df47509f0f4926ee40f364891dc496b13dcc
2 files changed +61 -24
apps/server/src/resourceTelemetry/ResourceMonitorBinary.test.ts
+46
@@ -3,6 +3,7 @@ import * as HostProcess from "@t3tools/shared/HostProcess";
3 import { afterEach, assert, describe, it, vi } from "@effect/vitest";
4 import * as Effect from "effect/Effect";
5 import * as FileSystem from "effect/FileSystem";
6 +import * as Path from "effect/Path";
7
8 import * as ServerConfig from "../config.ts";
9 import * as ResourceMonitorBinary from "./ResourceMonitorBinary.ts";
@@ -88,6 +89,51 @@ describe("ResourceMonitorBinary", () => {
89 }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
90 );
91
92 + it.effect.each(["release", "debug"])(
93 + "resolves a cargo %s binary from the built server layout",
94 + (profile) =>
95 + Effect.gen(function* () {
96 + const fileSystem = yield* FileSystem.FileSystem;
97 + const path = yield* Path.Path;
98 + const baseDir = yield* fileSystem.makeTempDirectoryScoped({
99 + prefix: "t3-resource-monitor-binary-",
100 + });
101 + const projectDirectory = path.join(baseDir, "repo");
102 + const distDirectory = path.join(projectDirectory, "apps", "server", "dist");
103 + const binaryDirectory = path.join(
104 + projectDirectory,
105 + "native",
106 + "resource-monitor",
107 + "target",
108 + profile,
109 + );
110 + const binaryPath = path.join(binaryDirectory, "t3-resource-monitor.exe");
111 + yield* fileSystem.makeDirectory(distDirectory, { recursive: true });
112 + yield* fileSystem.makeDirectory(binaryDirectory, { recursive: true });
113 + yield* fileSystem.writeFileString(binaryPath, "binary");
114 + yield* fileSystem.chmod(binaryPath, 0o755);
115 +
116 + const service = yield* ResourceMonitorBinary.make().pipe(
117 + // The bundled module lives in dist rather than src/resourceTelemetry.
118 + Effect.provideService(Path.Path, {
119 + ...path,
120 + resolve: (...segments) =>
121 + path.resolve(
122 + ...segments.map((segment) =>
123 + segment === import.meta.dirname ? distDirectory : segment,
124 + ),
125 + ),
126 + }),
127 + Effect.provide(ServerConfig.layerTest(projectDirectory, baseDir)),
128 + Effect.provideService(HostProcess.Platform, "win32"),
129 + Effect.provideService(HostProcess.Architecture, "arm64"),
130 + Effect.provideService(HostProcess.Environment, {}),
131 + );
132 +
133 + assert.equal(yield* service.resolve, binaryPath);
134 + }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
135 + );
136 +
137 it.effect("rejects bundled glibc binaries on musl Linux hosts", () =>
138 Effect.gen(function* () {
139 const fileSystem = yield* FileSystem.FileSystem;
apps/server/src/resourceTelemetry/ResourceMonitorBinary.ts
+15 -24
@@ -146,6 +146,20 @@ export const make = Effect.fn("resourceTelemetry.resourceMonitorBinary.make")(fu
146 environment.T3CODE_RESOURCE_MONITOR_PATH,
147 config.resourceMonitorPath,
148 ].filter((candidate): candidate is string => Boolean(candidate));
149 + const cargoOutputDirectories =
150 + rustTarget === undefined
151 + ? []
152 + : [
153 + path.join("target", rustTarget, "release"),
154 + path.join("target", "release"),
155 + path.join("target", "debug"),
156 + ];
157 + const sourceCandidates = [
158 + path.resolve(import.meta.dirname, "../../../../native/resource-monitor"),
159 + path.resolve(import.meta.dirname, "../../../native/resource-monitor"),
160 + ].flatMap((crateDirectory) =>
161 + cargoOutputDirectories.map((directory) => path.join(crateDirectory, directory, executableName)),
162 + );
163 const bundledCandidates =
164 platformKey === undefined || rustTarget === undefined
165 ? []
@@ -153,30 +167,7 @@ export const make = Effect.fn("resourceTelemetry.resourceMonitorBinary.make")(fu
167 path.resolve(import.meta.dirname, "resource-monitor", platformKey, executableName),
168 path.resolve(import.meta.dirname, "resource-monitor", executableName),
169 path.resolve(import.meta.dirname, "../resource-monitor", executableName),
156 - path.resolve(
157 - import.meta.dirname,
158 - "../../../../native/resource-monitor/target",
159 - rustTarget,
160 - "release",
161 - executableName,
162 - ),
163 - path.resolve(
164 - import.meta.dirname,
165 - "../../../native/resource-monitor/target",
166 - rustTarget,
167 - "release",
168 - executableName,
169 - ),
170 - path.resolve(
171 - import.meta.dirname,
172 - "../../../../native/resource-monitor/target/release",
173 - executableName,
174 - ),
175 - path.resolve(
176 - import.meta.dirname,
177 - "../../../../native/resource-monitor/target/debug",
178 - executableName,
179 - ),
170 + ...sourceCandidates,
171 ];
172 if (overrideCandidates.length === 0 && bundledCandidates.length === 0) {
173 return ResourceMonitorBinary.of({