TypeScript
fix(web): show the same project icon in the command palette as everywhere else (#10712)
Theo Browne82451eeb7277
diff --git a/apps/web/src/components/CommandPalette.logic.test.ts b/apps/web/src/components/CommandPalette.logic.test.tsindex b11d88b764b..5ec9872597e 100644--- a/apps/web/src/components/CommandPalette.logic.test.ts+++ b/apps/web/src/components/CommandPalette.logic.test.ts@@ -1,8 +1,9 @@import { describe, expect, it, vi } from "vite-plus/test";import { EnvironmentId, ProjectId, ProviderInstanceId, ThreadId } from "@t3tools/contracts";-import type { Thread } from "../types";+import type { Project, Thread } from "../types";import {buildBrowseGroups,+ buildProjectActionItems,buildThreadActionItems,enumerateCommandPaletteItems,filterPinnedBrowseEntries,@@ -112,6 +113,20 @@ describe("enumerateCommandPaletteItems", () => {const LOCAL_ENVIRONMENT_ID = EnvironmentId.make("environment-local");const PROJECT_ID = ProjectId.make("project-1");+function makeProject(overrides: Partial<Project> = {}): Project {+ return {+ id: PROJECT_ID,+ environmentId: LOCAL_ENVIRONMENT_ID,+ title: "Project",+ workspaceRoot: "/workspace/project",+ defaultModelSelection: null,+ scripts: [],+ createdAt: "2026-03-01T00:00:00.000Z",+ updatedAt: "2026-03-01T00:00:00.000Z",+ ...overrides,+ };+}+function makeThread(overrides: Partial<Thread> = {}): Thread {return {id: ThreadId.make("thread-1"),@@ -139,6 +154,28 @@ function makeThread(overrides: Partial<Thread> = {}): Thread {};}+describe("buildProjectActionItems", () => {+ it("shows the grouped display name but keeps the real title for icons", () => {+ const project = makeProject({ title: "fleet", workspaceRoot: "/Users/theo/Code/p/fleet" });+ const iconTitles: string[] = [];+ const [item] = buildProjectActionItems({+ projects: [{ ...project, displayName: "t3dotgg/fleet" }],+ valuePrefix: "project",+ icon: (candidate) => {+ iconTitles.push(candidate.title);+ return null;+ },+ runProject: async () => undefined,+ });++ expect(item?.title).toBe("t3dotgg/fleet");+ expect(item?.searchTerms).toEqual(+ expect.arrayContaining(["t3dotgg/fleet", "fleet", "/Users/theo/Code/p/fleet"]),+ );+ expect(iconTitles).toEqual(["fleet"]);+ });+});+describe("buildThreadActionItems", () => {it("orders threads by most recent activity and formats timestamps from updatedAt", () => {vi.useFakeTimers();diff --git a/apps/web/src/components/CommandPalette.logic.ts b/apps/web/src/components/CommandPalette.logic.tsindex 2492ca0cf98..e91de65d5ca 100644--- a/apps/web/src/components/CommandPalette.logic.ts+++ b/apps/web/src/components/CommandPalette.logic.ts@@ -139,20 +139,31 @@ export function enumerateCommandPaletteItems(export type CommandPaletteMode = "root" | "root-browse" | "submenu" | "submenu-browse";+// A project as the palette shows it. `displayName` is the grouped label (for+// example "owner/repo" when projects are merged across machines). Keep `title`+// as the real project title: the automatic project icon is derived from it, and+// every other surface uses the real title, so overriding it desyncs the icon.+export type CommandPaletteProject = Project & { readonly displayName: string };+export function buildProjectActionItems(input: {- projects: ReadonlyArray<Project>;+ projects: ReadonlyArray<CommandPaletteProject>;valuePrefix: string;- icon: (project: Project) => ReactNode;- runProject: (project: Project) => Promise<void>;- searchTerms?: (project: Project) => ReadonlyArray<string>;- renderDescription?: (project: Project) => ReactNode;+ icon: (project: CommandPaletteProject) => ReactNode;+ runProject: (project: CommandPaletteProject) => Promise<void>;+ searchTerms?: (project: CommandPaletteProject) => ReadonlyArray<string>;+ renderDescription?: (project: CommandPaletteProject) => ReactNode;shortcutCommand?: KeybindingCommand;}): CommandPaletteActionItem[] {return input.projects.map((project) => ({kind: "action",value: `${input.valuePrefix}:${project.environmentId}:${project.id}`,- searchTerms: [project.title, project.workspaceRoot, ...(input.searchTerms?.(project) ?? [])],- title: project.title,+ searchTerms: [+ project.displayName,+ project.title,+ project.workspaceRoot,+ ...(input.searchTerms?.(project) ?? []),+ ],+ title: project.displayName,description: input.renderDescription?.(project) ?? project.workspaceRoot,icon: input.icon(project),...(input.shortcutCommand !== undefined ? { shortcutCommand: input.shortcutCommand } : {}),diff --git a/apps/web/src/components/CommandPalette.tsx b/apps/web/src/components/CommandPalette.tsxindex fcf86362707..dedc84832e0 100644--- a/apps/web/src/components/CommandPalette.tsx+++ b/apps/web/src/components/CommandPalette.tsx@@ -794,7 +794,7 @@ function OpenCommandPaletteDialog(props: {() =>projectPickerEntries.map(({ group, targetProject }) => ({...targetProject,- title: group.displayName,+ displayName: group.displayName,})),[projectPickerEntries],);