Skip to content

Commit 2497af2

Browse files
juliusmarmingecodex
andcommitted
Support nested project directories in project keys
- derive logical project keys when expanding bootstrap projects - map Claude Opus 4.7 xhigh effort to the SDK max value - normalize repository root assertions for nested worktrees Co-authored-by: codex <[email protected]>
1 parent 6e107b0 commit 2497af2

5 files changed

Lines changed: 60 additions & 28 deletions

File tree

‎apps/server/src/project/Layers/RepositoryIdentityResolver.test.ts‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { realpathSync } from "node:fs";
2+
13
import * as NodeServices from "@effect/platform-node/NodeServices";
24
import { expect, it } from "@effect/vitest";
35
import { Duration, Effect, FileSystem, Layer } from "effect";
@@ -11,6 +13,8 @@ import {
1113
} from "./RepositoryIdentityResolver.ts";
1214

1315
const normalizePathSeparators = (value: string) => value.replaceAll("\\", "/");
16+
const normalizeResolvedPath = (value: string) =>
17+
normalizePathSeparators(realpathSync.native(value));
1418

1519
const git = (cwd: string, args: ReadonlyArray<string>) =>
1620
Effect.promise(() => runProcess("git", ["-C", cwd, ...args]));
@@ -43,7 +47,7 @@ it.layer(NodeServices.layer)("RepositoryIdentityResolverLive", (it) => {
4347

4448
expect(identity).not.toBeNull();
4549
expect(identity?.canonicalKey).toBe("github.com/t3tools/t3code");
46-
expect(normalizePathSeparators(identity?.rootPath ?? "")).toBe(normalizePathSeparators(cwd));
50+
expect(normalizeResolvedPath(identity?.rootPath ?? "")).toBe(normalizeResolvedPath(cwd));
4751
expect(identity?.displayName).toBe("t3tools/t3code");
4852
expect(identity?.provider).toBe("github");
4953
expect(identity?.owner).toBe("t3tools");
@@ -68,9 +72,7 @@ it.layer(NodeServices.layer)("RepositoryIdentityResolverLive", (it) => {
6872

6973
expect(identity).not.toBeNull();
7074
expect(identity?.canonicalKey).toBe("github.com/t3tools/t3code");
71-
expect(normalizePathSeparators(identity?.rootPath ?? "")).toBe(
72-
normalizePathSeparators(repoRoot),
73-
);
75+
expect(normalizeResolvedPath(identity?.rootPath ?? "")).toBe(normalizeResolvedPath(repoRoot));
7476
}).pipe(Effect.provide(RepositoryIdentityResolverLive)),
7577
);
7678

‎apps/server/src/provider/Layers/ClaudeAdapter.test.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ describe("ClaudeAdapterLive", () => {
351351
);
352352
});
353353

354-
it.effect("defaults Claude Opus 4.7 sessions to xhigh effort", () => {
354+
it.effect("maps the Claude Opus 4.7 default effort to the SDK-supported max value", () => {
355355
const harness = makeHarness();
356356
return Effect.gen(function* () {
357357
const adapter = yield* ClaudeAdapter;
@@ -366,14 +366,14 @@ describe("ClaudeAdapterLive", () => {
366366
});
367367

368368
const createInput = harness.getLastCreateQueryInput();
369-
assert.equal(createInput?.options.effort, "xhigh");
369+
assert.equal(createInput?.options.effort, "max");
370370
}).pipe(
371371
Effect.provideService(Random.Random, makeDeterministicRandomService()),
372372
Effect.provide(harness.layer),
373373
);
374374
});
375375

376-
it.effect("forwards xhigh effort for Claude Opus 4.7", () => {
376+
it.effect("maps xhigh effort for Claude Opus 4.7 to the SDK-supported max value", () => {
377377
const harness = makeHarness();
378378
return Effect.gen(function* () {
379379
const adapter = yield* ClaudeAdapter;
@@ -391,7 +391,7 @@ describe("ClaudeAdapterLive", () => {
391391
});
392392

393393
const createInput = harness.getLastCreateQueryInput();
394-
assert.equal(createInput?.options.effort, "xhigh");
394+
assert.equal(createInput?.options.effort, "max");
395395
}).pipe(
396396
Effect.provideService(Random.Random, makeDeterministicRandomService()),
397397
Effect.provide(harness.layer),

‎apps/server/src/provider/Layers/ClaudeAdapter.ts‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ type ClaudeToolResultStreamKind = Extract<
8484
RuntimeContentStreamKind,
8585
"command_output" | "file_change_output"
8686
>;
87+
type ClaudeSdkEffort = NonNullable<ClaudeQueryOptions["effort"]>;
8788

8889
type PromptQueueItem =
8990
| {
@@ -217,11 +218,17 @@ function normalizeClaudeStreamMessages(cause: Cause.Cause<Error>): ReadonlyArray
217218

218219
function getEffectiveClaudeAgentEffort(
219220
effort: ClaudeAgentEffort | null | undefined,
220-
): Exclude<ClaudeAgentEffort, "ultrathink"> | null {
221+
): ClaudeSdkEffort | null {
221222
if (!effort) {
222223
return null;
223224
}
224-
return effort === "ultrathink" ? null : effort;
225+
if (effort === "ultrathink") {
226+
return null;
227+
}
228+
if (effort === "xhigh") {
229+
return "max";
230+
}
231+
return effort;
225232
}
226233

227234
function isClaudeInterruptedMessage(message: string): boolean {

‎apps/web/src/components/ChatView.browser.tsx‎

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,7 @@ import {
1717
OrchestrationSessionStatus,
1818
DEFAULT_SERVER_SETTINGS,
1919
} from "@t3tools/contracts";
20-
import {
21-
scopedProjectKey,
22-
scopedThreadKey,
23-
scopeProjectRef,
24-
scopeThreadRef,
25-
} from "@t3tools/client-runtime";
20+
import { scopedThreadKey, scopeThreadRef } from "@t3tools/client-runtime";
2621
import { RouterProvider, createMemoryHistory } from "@tanstack/react-router";
2722
import { HttpResponse, http, ws } from "msw";
2823
import { setupWorker } from "msw/browser";
@@ -52,6 +47,7 @@ import { __resetLocalApiForTests } from "../localApi";
5247
import { AppAtomRegistryProvider } from "../rpc/atomRegistry";
5348
import { getServerConfig } from "../rpc/serverState";
5449
import { getRouter } from "../router";
50+
import { deriveLogicalProjectKeyFromSettings } from "../logicalProject";
5551
import { selectBootstrapCompleteForActiveEnvironment, useStore } from "../store";
5652
import { useTerminalStateStore } from "../terminalStateStore";
5753
import { useUiStateStore } from "../uiStateStore";
@@ -78,7 +74,18 @@ const THREAD_REF = scopeThreadRef(LOCAL_ENVIRONMENT_ID, THREAD_ID);
7874
const THREAD_KEY = scopedThreadKey(THREAD_REF);
7975
const UUID_ROUTE_RE = /^\/draft\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
8076
const PROJECT_DRAFT_KEY = `${LOCAL_ENVIRONMENT_ID}:${PROJECT_ID}`;
81-
const PROJECT_KEY = scopedProjectKey(scopeProjectRef(LOCAL_ENVIRONMENT_ID, PROJECT_ID));
77+
const PROJECT_LOGICAL_KEY = deriveLogicalProjectKeyFromSettings(
78+
{
79+
environmentId: LOCAL_ENVIRONMENT_ID,
80+
id: PROJECT_ID,
81+
cwd: "/repo/project",
82+
repositoryIdentity: null,
83+
},
84+
{
85+
sidebarProjectGroupingMode: DEFAULT_CLIENT_SETTINGS.sidebarProjectGroupingMode,
86+
sidebarProjectGroupingOverrides: DEFAULT_CLIENT_SETTINGS.sidebarProjectGroupingOverrides,
87+
},
88+
);
8289
const NOW_ISO = "2026-03-04T12:00:00.000Z";
8390
const BASE_TIME_MS = Date.parse(NOW_ISO);
8491
const ATTACHMENT_SVG = "<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'></svg>";
@@ -1638,12 +1645,12 @@ describe("ChatView timeline estimator parity (full app)", () => {
16381645
customWsRpcResolver = null;
16391646
document.body.innerHTML = "";
16401647
});
1641-
it("re-expands the bootstrap project using its scoped key", async () => {
1648+
it("re-expands the bootstrap project using its logical key", async () => {
16421649
useUiStateStore.setState({
16431650
projectExpandedById: {
1644-
[PROJECT_KEY]: false,
1651+
[PROJECT_LOGICAL_KEY]: false,
16451652
},
1646-
projectOrder: [PROJECT_KEY],
1653+
projectOrder: [PROJECT_LOGICAL_KEY],
16471654
threadLastVisitedAtById: {},
16481655
});
16491656

@@ -1658,7 +1665,7 @@ describe("ChatView timeline estimator parity (full app)", () => {
16581665
try {
16591666
await vi.waitFor(
16601667
() => {
1661-
expect(useUiStateStore.getState().projectExpandedById[PROJECT_KEY]).toBe(true);
1668+
expect(useUiStateStore.getState().projectExpandedById[PROJECT_LOGICAL_KEY]).toBe(true);
16621669
},
16631670
{ timeout: 8_000, interval: 16 },
16641671
);

‎apps/web/src/routes/__root.tsx‎

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ import { Button } from "../components/ui/button";
2222
import { AnchoredToastProvider, ToastProvider, toastManager } from "../components/ui/toast";
2323
import { resolveAndPersistPreferredEditor } from "../editorPreferences";
2424
import { readLocalApi } from "../localApi";
25+
import { useSettings } from "../hooks/useSettings";
26+
import {
27+
deriveLogicalProjectKeyFromSettings,
28+
derivePhysicalProjectKeyFromPath,
29+
} from "../logicalProject";
2530
import {
2631
getServerConfigUpdatedNotification,
2732
ServerConfigUpdatedNotification,
@@ -204,6 +209,10 @@ function EventRouter() {
204209
const setActiveEnvironmentId = useStore((store) => store.setActiveEnvironmentId);
205210
const navigate = useNavigate();
206211
const pathname = useLocation({ select: (loc) => loc.pathname });
212+
const projectGroupingSettings = useSettings((settings) => ({
213+
sidebarProjectGroupingMode: settings.sidebarProjectGroupingMode,
214+
sidebarProjectGroupingOverrides: settings.sidebarProjectGroupingOverrides,
215+
}));
207216
const readPathname = useEffectEvent(() => pathname);
208217
const handledBootstrapThreadIdRef = useRef<string | null>(null);
209218
const seenServerConfigUpdateIdRef = useRef(getServerConfigUpdatedNotification()?.id ?? 0);
@@ -224,14 +233,21 @@ function EventRouter() {
224233
if (!payload.bootstrapProjectId || !payload.bootstrapThreadId) {
225234
return;
226235
}
227-
useUiStateStore
228-
.getState()
229-
.setProjectExpanded(
230-
scopedProjectKey(
231-
scopeProjectRef(payload.environment.environmentId, payload.bootstrapProjectId),
232-
),
233-
true,
236+
const bootstrapEnvironmentState =
237+
useStore.getState().environmentStateById[payload.environment.environmentId];
238+
const bootstrapProject =
239+
bootstrapEnvironmentState?.projectById[payload.bootstrapProjectId] ?? null;
240+
const bootstrapProjectKey =
241+
(bootstrapProject
242+
? deriveLogicalProjectKeyFromSettings(bootstrapProject, projectGroupingSettings)
243+
: null) ??
244+
(serverConfig?.cwd
245+
? derivePhysicalProjectKeyFromPath(payload.environment.environmentId, serverConfig.cwd)
246+
: null) ??
247+
scopedProjectKey(
248+
scopeProjectRef(payload.environment.environmentId, payload.bootstrapProjectId),
234249
);
250+
useUiStateStore.getState().setProjectExpanded(bootstrapProjectKey, true);
235251

236252
if (readPathname() !== "/") {
237253
return;

0 commit comments

Comments
 (0)