From 7ce9a59c0e6fafeabe355f693c7c96c8efb7c983 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Sun, 22 Nov 2026 05:37:59 +0000 Subject: [PATCH 1/2] test(server): a provider refresh re-reads the login-shell PATH on macOS and Linux Failing test for #34354: refresh re-reads only the Windows registry PATH, so a CLI installed after startup stays not found until the server restarts. Co-Authored-By: Claude Opus 5.5 --- .../src/provider/ProviderRegistry.test.ts | 45 +++++++++++++++---- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/apps/server/src/provider/ProviderRegistry.test.ts b/apps/server/src/provider/ProviderRegistry.test.ts index e4ec16b77dde0..77e2c4789a678 100644 --- a/apps/server/src/provider/ProviderRegistry.test.ts +++ b/apps/server/src/provider/ProviderRegistry.test.ts @@ -2562,10 +2562,37 @@ it.layer( }), ); - it.effect( - "rebuilds only instances missing their CLI when a refresh finds a new Windows PATH", - () => { - const env: NodeJS.ProcessEnv = { PATH: "C:\\Windows" }; + // A login shell stand-in that prints the capture with one more PATH entry, as a profile edited + // after launch would. + const withLateLoginShell = (effect: (shell: string) => Effect.Effect) => + Effect.gen(function* () { + const fs = yield* FileSystem.FileSystem; + const dir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-login-shell-" }); + const shell = `${dir}/sh`; + yield* fs.writeFileString( + shell, + '#!/bin/sh\nPATH=/opt/late:/usr/bin exec /bin/sh -c "$2"\n', + ); + yield* fs.chmod(shell, 0o755); + return yield* effect(shell); + }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)); + + it.effect.each([ + { + name: "Windows PATH", + platform: "win32" as const, + path: "C:\\Windows", + expectedPath: "C:\\Windows;C:\\Tools", + }, + { + name: "login-shell PATH", + platform: "linux" as const, + path: "/usr/bin", + expectedPath: "/opt/late:/usr/bin", + }, + ])("rebuilds only instances missing their CLI when a refresh finds a new $name", (host) => + withLateLoginShell((shell) => { + const env: NodeJS.ProcessEnv = { PATH: host.path, SHELL: shell }; return Effect.gen(function* () { const driver = ProviderDriverKind.make("codex"); const makeInstance = (id: string, installed: boolean): ProviderInstance => { @@ -2627,7 +2654,9 @@ it.layer( }), ), Layer.provideMerge( - ServerConfig.layerTest(process.cwd(), { prefix: "t3-provider-registry-path-" }), + ServerConfig.layerTest(process.cwd(), { + prefix: "t3-provider-registry-path-", + }), ), Layer.provideMerge(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer)), ), @@ -2636,16 +2665,16 @@ it.layer( yield* registry.refresh(); - assert.strictEqual(env.PATH, "C:\\Windows;C:\\Tools"); + assert.strictEqual(env.PATH, host.expectedPath); assert.deepStrictEqual(rebuilt, [[ProviderInstanceId.make("missing")]]); }).pipe( - Effect.provideService(HostProcess.Platform, "win32"), + Effect.provideService(HostProcess.Platform, host.platform), Effect.provideService(HostProcess.Environment, env), Effect.provideService(WindowsShellEnvironment, () => Effect.succeed({ PATH: "C:\\Windows;C:\\Tools" }), ), ); - }, + }), ); it.effect("rescans a requested cwd whose snapshot is still current", () => From 29f11c3c3a8ec7e57ea2a0303624766f66c76bcd Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Sun, 22 Nov 2026 05:45:50 +0000 Subject: [PATCH 2/2] fix(server): provider refresh finds CLIs installed after launch on macOS and Linux Refreshing provider status re-read PATH only from the Windows registry, so on macOS and Linux a claude or codex added to the shell profile after the server started stayed "not found on PATH" until a restart. The refresh now also re-reads the login shell, and rebuilds instances still missing their CLI whenever PATH differs from what the registry last saw, so a PATH that Source control discovery already refreshed also reaches Claude's driver. Fixes pingdotgg/t3code#34354 Co-Authored-By: Claude Opus 5.5 --- .../src/provider/ProviderRegistry.test.ts | 5 +++++ apps/server/src/provider/ProviderRegistry.ts | 17 ++++++++++++++++- .../src/provider/providerCompatibility.test.ts | 3 +++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/apps/server/src/provider/ProviderRegistry.test.ts b/apps/server/src/provider/ProviderRegistry.test.ts index 77e2c4789a678..69b7bd9eb2c1d 100644 --- a/apps/server/src/provider/ProviderRegistry.test.ts +++ b/apps/server/src/provider/ProviderRegistry.test.ts @@ -565,6 +565,11 @@ const layerTestNodeServices = Layer.mergeAll( Layer.succeed(ServerEnvironment.ServerEnvironmentIdentity, { getEnvironmentId: Effect.succeed(EnvironmentId.make("00000000-0000-4000-8000-000000000001")), }), + // A login shell that prints nothing, so refreshes never take PATH from the developer's profile. + Layer.effect( + HostProcess.Environment, + Effect.sync(() => ({ ...process.env, SHELL: "/usr/bin/true" })), + ), // An empty home, so the developer's own Claude settings never reach provider probes. Layer.effect( HostProcess.HomeDirectory, diff --git a/apps/server/src/provider/ProviderRegistry.ts b/apps/server/src/provider/ProviderRegistry.ts index 43f57bb99a777..43d66cd1ca049 100644 --- a/apps/server/src/provider/ProviderRegistry.ts +++ b/apps/server/src/provider/ProviderRegistry.ts @@ -26,12 +26,14 @@ import * as Ref from "effect/Ref"; import * as Scope from "effect/Scope"; import * as Stream from "effect/Stream"; import * as Semaphore from "effect/Semaphore"; +import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner"; +import * as HostProcess from "@t3tools/shared/HostProcess"; import * as ProviderLatestVersions from "@t3tools/provider-core/server/ProviderLatestVersions"; import * as ModelManifest from "./ModelManifest.ts"; import { applyProviderCompatibility } from "./providerCompatibility.ts"; import * as ServerConfig from "../config.ts"; -import { refreshWindowsPath } from "../os-jank.ts"; +import { refreshPathFromLoginShell, refreshWindowsPath } from "../os-jank.ts"; import * as ProviderInstanceRegistry from "./ProviderInstanceRegistry.ts"; import * as ProviderInstanceRegistryMutator from "./ProviderInstanceRegistryMutator.ts"; import { @@ -747,7 +749,20 @@ export const layer = Layer.effect( // A refresh is how a user asks T3 to see a CLI installed since launch; a burst shares one probe. // Drivers copy the environment when built, so instances still missing their CLI are rebuilt // on the new PATH. They cannot have live sessions, and installed ones keep theirs. + // Compared with the last PATH seen here, since other features re-read the login shell too. + const hostEnvironment = yield* HostProcess.Environment; + const readHostPath = () => hostEnvironment.PATH ?? hostEnvironment.Path ?? hostEnvironment.path; + const lastHostPathRef = yield* Ref.make(readHostPath()); + const spawner = yield* ChildProcessSpawner.ChildProcessSpawner; const refreshHostPath = yield* refreshWindowsPath().pipe( + Effect.andThen(refreshPathFromLoginShell()), + Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner), + Effect.andThen( + Effect.suspend(() => { + const path = readHostPath(); + return Ref.getAndSet(lastHostPathRef, path).pipe(Effect.map((last) => last !== path)); + }), + ), Effect.flatMap((changed) => changed ? Ref.get(providersRef).pipe( diff --git a/apps/server/src/provider/providerCompatibility.test.ts b/apps/server/src/provider/providerCompatibility.test.ts index 83947bedf9213..1629c7e492fb5 100644 --- a/apps/server/src/provider/providerCompatibility.test.ts +++ b/apps/server/src/provider/providerCompatibility.test.ts @@ -1,6 +1,7 @@ import { assert, describe, it } from "@effect/vitest"; import { ProviderDriverKind, ProviderInstanceId, type ServerProvider } from "@t3tools/contracts"; import * as NodeServices from "@effect/platform-node/NodeServices"; +import * as HostProcess from "@t3tools/shared/HostProcess"; import * as Deferred from "effect/Deferred"; import * as Fiber from "effect/Fiber"; import * as Effect from "effect/Effect"; @@ -329,6 +330,8 @@ it.effect("a remote policy refresh preserves a newer health result on the regist ), ), ), + // A login shell that prints nothing, so the refresh never takes PATH from the developer's profile. + Effect.provideService(HostProcess.Environment, { ...process.env, SHELL: "/usr/bin/true" }), ); }), );