diff --git a/apps/web/src/components/CommandPalette.logic.test.ts b/apps/web/src/components/CommandPalette.logic.test.ts index c034c7f4131c1..cc23a79ddddad 100644 --- a/apps/web/src/components/CommandPalette.logic.test.ts +++ b/apps/web/src/components/CommandPalette.logic.test.ts @@ -948,7 +948,7 @@ describe("newThreadNoProjectIndex", () => { }); it("goes after the pinned projects and the first unpinned one", () => { - expect(newThreadNoProjectIndex([entry(true), entry(true), entry(false, true), entry()])).toBe( + expect(newThreadNoProjectIndex([entry(false, true), entry(true), entry(true), entry()])).toBe( 3, ); expect(newThreadNoProjectIndex([entry(false, true), entry(), entry(false, false, true)])).toBe( diff --git a/apps/web/src/components/CommandPalette.tsx b/apps/web/src/components/CommandPalette.tsx index 7c0821678e512..5d08f4c7f6e8d 100644 --- a/apps/web/src/components/CommandPalette.tsx +++ b/apps/web/src/components/CommandPalette.tsx @@ -826,8 +826,15 @@ function OpenCommandPaletteDialog(props: { (() => { const isScratch = (project: CommandPaletteProject) => isScratchProject(project, scratchWorkspaceRootFor(project.environmentId)); + const currentEntry = + currentProjectId === null + ? undefined + : projectPickerEntries.find((entry) => entry.isPreferred); const projectItems = buildNewThreadInProjectItems({ projects: pickerProjects.filter((project) => !isScratch(project)), + currentProjectKey: currentEntry + ? `${currentEntry.targetProject.environmentId}:${currentEntry.targetProject.id}` + : null, projectGroupByTargetKey, locationByEnvironmentId: projectEnvironmentLocationById, pin: projectPin, diff --git a/apps/web/src/components/CommandPaletteProjectItems.tsx b/apps/web/src/components/CommandPaletteProjectItems.tsx index 2a3d466474d2e..3039ac9e6f261 100644 --- a/apps/web/src/components/CommandPaletteProjectItems.tsx +++ b/apps/web/src/components/CommandPaletteProjectItems.tsx @@ -73,7 +73,9 @@ export function buildProjectSearchItems(input: ProjectItemsInput) { } /** Projects as targets of the "New thread in..." submenu. */ -export function buildNewThreadInProjectItems(input: ProjectItemsInput) { +export function buildNewThreadInProjectItems( + input: ProjectItemsInput & { readonly currentProjectKey: string | null }, +) { return buildProjectActionItems({ projects: input.projects, valuePrefix: "new-thread-in", @@ -89,6 +91,7 @@ export function buildNewThreadInProjectItems(input: ProjectItemsInput) { ), icon: projectFaviconIcon, @@ -100,10 +103,17 @@ export function buildNewThreadInProjectItems(input: ProjectItemsInput) { function ProjectLocationDescription(props: { readonly location: CommandPaletteProjectLocation | undefined; readonly workspaceRoot: string; + readonly current?: boolean; }) { const location = props.location ?? UNKNOWN_PROJECT_LOCATION; return ( + {props.current ? ( + <> + Current + + + ) : null} {location.kind === "remote" ? ( {location.label} - {props.workspaceRoot} + {props.workspaceRoot} ); } diff --git a/apps/web/src/environmentGrouping.test.ts b/apps/web/src/environmentGrouping.test.ts index 81e7c37b470e3..b2081b4b8fe9a 100644 --- a/apps/web/src/environmentGrouping.test.ts +++ b/apps/web/src/environmentGrouping.test.ts @@ -279,7 +279,7 @@ describe("environment grouping", () => { }); }); - it("puts the preferred project after pinned projects", () => { + it("puts the preferred project before pinned projects", () => { const project = (title: string, pinnedAt: string | null = null) => makeProject({ id: ProjectId.make(title), @@ -299,6 +299,6 @@ describe("environment grouping", () => { groups: pickableProjectGroups(groups), preferredProjectRef: { environmentId: current.environmentId, projectId: current.id }, }); - expect(entries.map((entry) => entry.group.displayName)).toEqual(["pinned", "current", "other"]); + expect(entries.map((entry) => entry.group.displayName)).toEqual(["current", "pinned", "other"]); }); }); diff --git a/apps/web/src/sidebarProjectGrouping.ts b/apps/web/src/sidebarProjectGrouping.ts index 5f9f7d981da7d..8fb8c4a5a1c6c 100644 --- a/apps/web/src/sidebarProjectGrouping.ts +++ b/apps/web/src/sidebarProjectGrouping.ts @@ -239,10 +239,8 @@ export function buildSidebarProjectPickerEntries(input: { return [{ group, targetProject, isPreferred }]; }); - // The preferred project leads the unpinned ones; pinned projects stay first. + // The current project leads, even ahead of pinned projects. const preferred = entries.find((entry) => entry.isPreferred); - if (!preferred || preferred.group.pinned) return entries; - const rest = entries.filter((entry) => entry !== preferred); - const pinnedCount = rest.filter((entry) => entry.group.pinned).length; - return [...rest.slice(0, pinnedCount), preferred, ...rest.slice(pinnedCount)]; + if (!preferred) return entries; + return [preferred, ...entries.filter((entry) => entry !== preferred)]; }