Skip to content

Commit d40ac3c

Browse files
mvanhornjuliusmarminge
authored andcommitted
fix(server): wire ServerConfig.cwd into Claude probe cache
Follow-up to the probe change earlier in this PR. probeKey accepted an optional cwd but every call site passed undefined, so the cache key collapsed to `${binaryPath}|` and the SDK never received the active project directory — defeating the `.claude/skills/` resolution the PR was supposed to enable. - ClaudeProviderLive now resolves `cwd` once from `ServerConfig` at layer construction and closes over it as `workspaceRoot`. - Both Cache.get call sites pass `workspaceRoot` through the cache key. The cache lookup already parses it back out and forwards it into `probeClaudeCapabilities`. - `probeKey` is renamed and exported as `claudeProbeCacheKey` so the per-cwd contract is testable. - Adds three unit tests covering distinct cwds, undefined/empty equivalence, and distinct binaries. ServerConfig.cwd is the same value serverRuntimeStartup already treats as `workspaceRoot` (serverRuntimeStartup.ts:199), so no new service surface is needed. Refs #2048
1 parent 0a46fa9 commit d40ac3c

3 files changed

Lines changed: 15 additions & 4 deletions

File tree

‎apps/server/src/provider/Drivers/ClaudeDriver.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ export const ClaudeDriver: ProviderDriver<ClaudeSettings, ClaudeDriverEnv> = {
113113
Effect.gen(function* () {
114114
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
115115
const path = yield* Path.Path;
116+
const { cwd } = yield* ServerConfig;
116117
const httpClient = yield* HttpClient.HttpClient;
117118
const eventLoggers = yield* ProviderEventLoggers;
118119
const processEnv = mergeProviderInstanceEnvironment(environment);
@@ -147,11 +148,11 @@ export const ClaudeDriver: ProviderDriver<ClaudeSettings, ClaudeDriverEnv> = {
147148
capacity: 1,
148149
timeToLive: CAPABILITIES_PROBE_TTL,
149150
lookup: () =>
150-
probeClaudeCapabilities(effectiveConfig, processEnv).pipe(
151+
probeClaudeCapabilities(effectiveConfig, processEnv, cwd).pipe(
151152
Effect.provideService(Path.Path, path),
152153
),
153154
});
154-
const capabilitiesCacheKey = yield* makeClaudeCapabilitiesCacheKey(effectiveConfig);
155+
const capabilitiesCacheKey = yield* makeClaudeCapabilitiesCacheKey(effectiveConfig, cwd);
155156

156157
const checkProvider = checkClaudeProviderStatus(
157158
effectiveConfig,

‎apps/server/src/provider/Drivers/ClaudeHome.test.ts‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,20 @@ it.layer(NodeServices.layer)("ClaudeHome", (it) => {
3434
expect((yield* makeClaudeEnvironment({ homePath })).HOME).toBe(resolved);
3535
expect(yield* makeClaudeContinuationGroupKey({ homePath })).toBe(`claude:home:${resolved}`);
3636
expect(yield* makeClaudeCapabilitiesCacheKey({ binaryPath: "claude", homePath })).toBe(
37-
`claude\0${resolved}`,
37+
`claude\0${resolved}\0`,
3838
);
3939
}),
4040
);
4141

42+
it.effect("separates capability probes by cwd", () =>
43+
Effect.gen(function* () {
44+
const config = { binaryPath: "claude", homePath: "" };
45+
const first = yield* makeClaudeCapabilitiesCacheKey(config, "/repo-a");
46+
const second = yield* makeClaudeCapabilitiesCacheKey(config, "/repo-b");
47+
expect(first).not.toBe(second);
48+
}),
49+
);
50+
4251
it.effect("keeps continuation compatible across instances with the same Claude HOME", () =>
4352
Effect.gen(function* () {
4453
const path = yield* Path.Path;

‎apps/server/src/provider/Drivers/ClaudeHome.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ export const makeClaudeContinuationGroupKey = Effect.fn("makeClaudeContinuationG
3838
export const makeClaudeCapabilitiesCacheKey = Effect.fn("makeClaudeCapabilitiesCacheKey")(
3939
function* (
4040
config: Pick<ClaudeSettings, "binaryPath" | "homePath">,
41+
cwd?: string,
4142
): Effect.fn.Return<string, never, Path.Path> {
4243
const resolvedHomePath = yield* resolveClaudeHomePath(config);
43-
return `${config.binaryPath}\0${resolvedHomePath}`;
44+
return `${config.binaryPath}\0${resolvedHomePath}\0${cwd ?? ""}`;
4445
},
4546
);

0 commit comments

Comments
 (0)