fix(web): make project icons the default (#9457)

Co-authored-by: maria-rcks <[email protected]>
This commit is contained in:
mariaandmaria-rcks authored and GitHub committed 2026-09-03 13:53:16 -04:00
1 parent 645d58547d
commit 4e89d74436
6 files changed
+31 -49

No files matched your search

@@ -115,28 +115,40 @@ describe("ProjectFavicon", () => {
testState.faviconUrl = "https://environment.test/api/assets/token-a/v1-20-favicon.svg";
});
it("shows a project-name emoji when no favicon exists", () => {
it("shows a project-name icon when no favicon exists", () => {
testState.faviconUrl = `https://environment.test/api/assets/token/${PROJECT_FAVICON_FALLBACK_MARKER}`;
const element = ProjectFavicon({
environmentId: "environment-test" as EnvironmentId,
cwd: "/workspace/analytics-db",
projectName: "analytics-db",
}) as ReactElement<{ readonly emoji?: string }>;
}) as ReactElement<{
readonly colorClassName?: string;
readonly emoji?: string;
readonly icon?: ComponentType<{ className?: string }>;
}>;
expect(element.props.emoji).toBe("🗄️");
expect(element.props.icon).toBeDefined();
expect(element.props.emoji).toBeUndefined();
expect(element.props.colorClassName).toContain("text-cyan-600");
});
it("chooses a deterministic semantic emoji", () => {
it("chooses a deterministic semantic icon", () => {
testState.faviconUrl = `https://environment.test/api/assets/token/${PROJECT_FAVICON_FALLBACK_MARKER}`;
const element = ProjectFavicon({
environmentId: "environment-test" as EnvironmentId,
cwd: "/workspace/agent-runtime",
projectName: "agent-runtime",
}) as ReactElement<{ readonly emoji?: string }>;
}) as ReactElement<{
readonly colorClassName?: string;
readonly emoji?: string;
readonly icon?: ComponentType<{ className?: string }>;
}>;
expect(element.props.emoji).toBe("🤖");
expect(element.props.icon).toBeDefined();
expect(element.props.emoji).toBeUndefined();
expect(element.props.colorClassName).toContain("text-violet-600");
});
it("renders a saved Lucide icon and color ahead of an uploaded favicon", () => {
@@ -39,13 +39,13 @@ vi.mock("../ui/toggle-group", () => ({
import { ProjectIconPickerDialog } from "./ProjectIconPickerDialog";
describe("ProjectIconPickerDialog", () => {
it("shows emoji first and selects it for an automatic project", () => {
it("shows icons first and selects them for an automatic project", () => {
const markup = renderToStaticMarkup(
<ProjectIconPickerDialog current={null} open onOpenChange={() => {}} onSelect={() => {}} />,
);
expect(markup).toContain('data-current="emoji"');
expect(markup.indexOf(">Emoji<")).toBeLessThan(markup.indexOf(">Icons<"));
expect(markup).toContain("Or paste any emoji");
expect(markup).toContain('data-current="lucide"');
expect(markup.indexOf(">Icons<")).toBeLessThan(markup.indexOf(">Emoji<"));
expect(markup).toContain('aria-label="Icon color"');
});
});
@@ -45,7 +45,7 @@ export function ProjectIconPickerDialog({
readonly onSelect: (icon: ProjectIconOverride) => void;
}) {
const [mode, setMode] = useState<"lucide" | "emoji">(
current?.kind === "lucide" ? "lucide" : "emoji",
current?.kind === "emoji" ? "emoji" : "lucide",
);
const [iconName, setIconName] = useState<IconName>(
current?.kind === "lucide" ? (current.name as IconName) : DEFAULT_ICON,
@@ -60,7 +60,7 @@ export function ProjectIconPickerDialog({
useEffect(() => {
if (open && !previousOpenRef.current) {
setMode(current?.kind === "lucide" ? "lucide" : "emoji");
setMode(current?.kind === "emoji" ? "emoji" : "lucide");
setIconName(current?.kind === "lucide" ? (current.name as IconName) : DEFAULT_ICON);
setColor(current?.kind === "lucide" ? current.color : DEFAULT_COLOR);
setEmoji(current?.kind === "emoji" ? current.emoji : "💻");
@@ -84,7 +84,7 @@ export function ProjectIconPickerDialog({
<DialogPopup className="w-full sm:w-[32rem]">
<DialogHeader>
<DialogTitle>Choose project icon</DialogTitle>
<DialogDescription>Pick an emoji, or choose any Lucide icon and color.</DialogDescription>
<DialogDescription>Pick any Lucide icon and color, or use an emoji.</DialogDescription>
</DialogHeader>
<DialogPanel className="flex min-h-0 flex-col gap-4">
<ToggleGroup
@@ -96,8 +96,8 @@ export function ProjectIconPickerDialog({
if (value === "lucide" || value === "emoji") setMode(value);
}}
>
<Toggle value="emoji">Emoji</Toggle>
<Toggle value="lucide">Icons</Toggle>
<Toggle value="emoji">Emoji</Toggle>
</ToggleGroup>
{mode === "lucide" ? (
+3 -4
View File
@@ -19,18 +19,17 @@ describe("selectProjectIcon", () => {
expect(selectProjectIcon("", "C:\\work\\mobile-app").icon).toBe("mobile");
});
it("uses emoji for automatic project icons", () => {
it("uses Lucide icons for automatic project icons", () => {
expect(selectProjectIcon("agent-runtime", "/workspace/agent-runtime")).toEqual({
kind: "emoji",
kind: "lucide",
icon: "ai",
emoji: "🤖",
});
});
it("gives unknown names a stable generic icon", () => {
const icon = selectProjectIcon("mercury", "/workspace/mercury");
expect(icon.kind).toBe("emoji");
expect(icon.kind).toBe("lucide");
expect(PROJECT_ICON_NAMES).toContain(icon.icon);
expect(selectProjectIcon("mercury", "/elsewhere/mercury")).toEqual(icon);
});
+1 -30
View File
@@ -131,31 +131,6 @@ const GENERIC_PROJECT_ICONS: ReadonlyArray<ProjectIconName> = [
"layers",
];
const PROJECT_ICON_EMOJIS: Record<ProjectIconName, string> = {
ai: "🤖",
book: "📚",
braces: "🧩",
circuit: "⚡",
cloud: "☁️",
code: "💻",
database: "🗄️",
desktop: "🖥️",
"folder-code": "🛠️",
game: "🎮",
image: "🖼️",
layers: "✨",
mobile: "📱",
music: "🎵",
package: "📦",
security: "🔒",
server: "⚙️",
shopping: "🛍️",
terminal: "⌨️",
test: "🧪",
video: "🎬",
web: "🌐",
};
const projectIconCache = new Map<string, ProjectIconSelection>();
function projectNameTokens(value: string): ReadonlyArray<string> {
@@ -211,11 +186,7 @@ export function selectProjectIcon(
const iconName =
bestIcon ?? GENERIC_PROJECT_ICONS[stableIndex(cacheKey, GENERIC_PROJECT_ICONS.length)]!;
const icon: ProjectIconSelection = {
kind: "emoji",
icon: iconName,
emoji: PROJECT_ICON_EMOJIS[iconName],
};
const icon: ProjectIconSelection = { kind: "lucide", icon: iconName };
projectIconCache.set(cacheKey, icon);
return icon;
}
+1 -1
View File
@@ -2,7 +2,7 @@
T3 Code selects a project icon automatically. It checks `t3.json`, common favicon and app icon
paths, and icon links in project HTML files. If it does not find an image, it chooses a built-in
emoji from the project name.
icon from the project name.
To choose a different icon or emoji: