@devries-cameron20 / t3code Mirror · read-only / commits / 1cfd23e7cb
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, 10:45 UTC

fix(web): keep palette project lookups in their environment (#25236)

Co-authored-by: Alex Southwell <4596216+saphid@users.noreply.github.com>

maria committed Oct 30, 2026 at 21:12 UTC 1cfd23e7cb35e02892935bc618ad61cd1d77793a
4 files changed +40 -13
apps/web/src/components/CommandPalette.logic.test.ts
+20
@@ -4,6 +4,7 @@ import type { Thread } from "../types";
4 import { makeThreadFixture } from "../test-fixtures";
5 import {
6 buildNestedSearchItems,
7 + resolveCommandPaletteProject,
8 buildThreadActionItems,
9 buildLinkedThreadActionItems,
10 filterPinnedBrowseEntries,
@@ -918,3 +919,22 @@ describe("returning from file and content search", () => {
919 expect(reduceCommandPaletteUiState(closed, { _tag: "SetOpen", open: true })).toEqual(root);
920 });
921 });
922 +
923 +it("resolves project metadata and browse roots within the active environment", () => {
924 + const local = { title: "Local project", workspaceRoot: "/local/repo" };
925 + const remote = { title: "Remote project", workspaceRoot: "/remote/repo" };
926 + const projects = new Map([
927 + ["local:shared-project", local],
928 + ["remote:shared-project", remote],
929 + ]);
930 + expect(
931 + resolveCommandPaletteProject(projects, EnvironmentId.make("local"), PROJECT_ID),
932 + ).toBeUndefined();
933 + const sharedId = ProjectId.make("shared-project");
934 + expect(resolveCommandPaletteProject(projects, EnvironmentId.make("local"), sharedId)).toBe(local);
935 + expect(resolveCommandPaletteProject(projects, EnvironmentId.make("remote"), sharedId)).toBe(
936 + remote,
937 + );
938 + expect(resolveCommandPaletteProject(projects, null, sharedId)).toBeUndefined();
939 + expect(resolveCommandPaletteProject(projects, EnvironmentId.make("local"), null)).toBeUndefined();
940 +});
apps/web/src/components/CommandPalette.logic.ts
+9
@@ -20,6 +20,7 @@ import {
20 } from "@t3tools/client-runtime/operations/projects";
21 import {
22 type EnvironmentId,
23 + type ProjectId,
24 type EnvironmentMachineKind,
25 type FilesystemBrowseEntry,
26 type KeybindingCommand,
@@ -860,3 +861,11 @@ export function overlayModeForCommand(command: string | null): SearchOverlayMode
861 ? OVERLAY_MODE_BY_COMMAND[command as keyof typeof OVERLAY_MODE_BY_COMMAND]
862 : null;
863 }
864 +
865 +export function resolveCommandPaletteProject<TProject>(
866 + projects: ReadonlyMap<string, TProject>,
867 + environmentId: EnvironmentId | null,
868 + projectId: ProjectId | null,
869 +) {
870 + return environmentId && projectId ? projects.get(`${environmentId}:${projectId}`) : undefined;
871 +}
apps/web/src/components/CommandPalette.tsx
+10 -5
@@ -159,6 +159,7 @@ import {
159 resolveWslProjectSelection,
160 } from "../wslPaths";
161 import {
162 + resolveCommandPaletteProject,
163 ADDON_ICON_CLASS,
164 browseInputEndPaddingClass,
165 buildBrowseGroups,
@@ -611,7 +612,7 @@ function OpenCommandPaletteDialog(props: {
612 return ensureBrowseDirectoryPath(baseDirectory);
613 };
614
614 - const { projectCwdById, projectByKey, projectTitleById } = useProjectLookups();
615 + const { projectByKey } = useProjectLookups();
616
617 const activeThreadKey = activeThread
618 ? scopedThreadKey(scopeThreadRef(activeThread.environmentId, activeThread.id))
@@ -637,9 +638,12 @@ function OpenCommandPaletteDialog(props: {
638 const canTriage =
639 useAtomValue(serverEnvironment.prepareTriage.permissionAtom(triageEnvironmentId)) &&
640 supportsTriage(triageEnvironmentId);
640 - const currentProjectCwd = currentProjectId
641 - ? (projectCwdById.get(currentProjectId) ?? null)
642 - : null;
641 + const currentProject = resolveCommandPaletteProject(
642 + projectByKey,
643 + currentProjectEnvironmentId,
644 + currentProjectId,
645 + );
646 + const currentProjectCwd = currentProject?.workspaceRoot ?? null;
647 const currentProjectCwdForBrowse =
648 browseEnvironmentId && currentProjectEnvironmentId === browseEnvironmentId
649 ? currentProjectCwd
@@ -1155,7 +1159,8 @@ function OpenCommandPaletteDialog(props: {
1159 if (projects.length > 0) {
1160 const activeProjectTitle =
1161 projectPickerEntries.find((entry) => entry.isPreferred)?.group.displayName ??
1158 - (currentProjectId ? (projectTitleById.get(currentProjectId) ?? null) : null);
1162 + currentProject?.title ??
1163 + null;
1164
1165 if (activeProjectTitle) {
1166 actionItems.push({
apps/web/src/components/CommandPaletteLookups.ts
+1 -8
@@ -1,7 +1,6 @@
1 import {
2 type ClientSettings,
3 type EnvironmentId,
4 - type ProjectId,
4 resolveEnvironmentMachineKind,
5 } from "@t3tools/contracts";
6
@@ -41,16 +40,10 @@ export function useEnvironmentLookups() {
40
41 export function useProjectLookups() {
42 const projects = useProjects();
44 - const projectCwdById = new Map<ProjectId, string>(
45 - projects.map((project) => [project.id, project.workspaceRoot]),
46 - );
43 const projectByKey = new Map(
44 projects.map((project) => [`${project.environmentId}:${project.id}`, project]),
45 );
50 - const projectTitleById = new Map<ProjectId, string>(
51 - projects.map((project) => [project.id, project.title]),
52 - );
53 - return { projectCwdById, projectByKey, projectTitleById };
46 + return { projectByKey };
47 }
48
49 export const selectCommandPaletteClientSettings = (settings: ClientSettings) => ({