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 21, 06:00 UTC
fix(web): block invalid project monograms before save (#39131)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Aditya Kumar Puri committed
Nov 19, 2026 at 19:56 UTC
4113f8fee575418d0a2c903f4a95b16c77e595c3
3 files changed
+26
-10
apps/web/src/components/settings/ProjectIconPickerDialog.tsx
+3
-8
@@ -1,16 +1,12 @@
1
-import * as Schema from "effect/Schema";
1
import { deriveProjectIdentity } from "../../projectIdentity";
2
import { ProjectMonogram } from "../ProjectMonogram";
4
-import {
5
- ProjectMonogramText,
6
- type ProjectIconColor,
7
- type ProjectIconOverride,
8
-} from "@t3tools/contracts";
3
+import type { ProjectIconColor, ProjectIconOverride } from "@t3tools/contracts";
4
import { T, useGT, useMessages } from "gt-react";
5
import { createElement, useState } from "react";
6
import {
7
filterProjectIconNames,
8
firstEmoji,
9
+ isValidProjectMonogram,
10
PROJECT_EMOJIS,
11
PROJECT_ICON_COLORS,
12
projectIconColorClassName,
@@ -32,7 +28,6 @@ import { ScrollArea } from "../ui/scroll-area";
28
import { Toggle, ToggleGroup } from "../ui/toggle-group";
29
30
const DEFAULT_ICON = "folder-code";
35
-const isMonogramText = Schema.is(ProjectMonogramText);
31
32
function PickerIcon({ name }: { name: string }) {
33
const icon = lucideIconByName(name);
@@ -105,7 +100,7 @@ function ProjectIconPickerBody({
100
const icons = filterProjectIconNames(query);
101
const selectedColorClassName = projectIconColorClassName(color);
102
const monogram = letters.normalize("NFKC").trim().toUpperCase();
108
- const validMonogram = isMonogramText(monogram);
103
+ const validMonogram = isValidProjectMonogram(monogram);
104
const save = () => {
105
if (mode === "monogram" && !validMonogram) return;
106
onSelect(
apps/web/src/projectIconOptions.test.ts
+12
-1
@@ -1,7 +1,7 @@
1
import { AlarmClockCheck, ArrowDown01, Layers3 } from "lucide-react";
2
import { describe, expect, it } from "vite-plus/test";
3
import { lucideIconByName } from "./lib/lucideIconByName";
4
-import { filterProjectIconNames, firstEmoji } from "./projectIconOptions";
4
+import { filterProjectIconNames, firstEmoji, isValidProjectMonogram } from "./projectIconOptions";
5
6
describe("projectIconOptions", () => {
7
it("resolves every offered icon name, including saved legacy spellings", () => {
@@ -19,4 +19,15 @@ describe("projectIconOptions", () => {
19
expect(firstEmoji("1️⃣ project")).toBe("1️⃣");
20
expect(firstEmoji("plain text")).toBeNull();
21
});
22
+
23
+ it("allows monograms of at most two characters", () => {
24
+ for (const [text, valid] of [
25
+ ["T", true],
26
+ ["T3", true],
27
+ ["E\u0301E\u0301", true],
28
+ ["ABC", false],
29
+ ] as const) {
30
+ expect(isValidProjectMonogram(text), text).toBe(valid);
31
+ }
32
+ });
33
});
apps/web/src/projectIconOptions.ts
+11
-1
@@ -1,8 +1,11 @@
1
+import { ProjectMonogramText } from "@t3tools/contracts";
2
+import * as Schema from "effect/Schema";
3
import { msg } from "gt-react";
2
-
4
import { lucideIconNames } from "./lib/lucideIconByName";
5
export { PROJECT_ICON_COLORS, projectIconColorClassName } from "./projectIconColors";
6
7
+const isProjectMonogramText = Schema.is(ProjectMonogramText);
8
+
9
const POPULAR_PROJECT_ICONS: ReadonlyArray<string> = [
10
"folder-code",
11
"code-2",
@@ -69,6 +72,13 @@ export function filterProjectIconNames(query: string): ReadonlyArray<string> {
72
return lucideIconNames.filter((name) => name.includes(normalized)).slice(0, 60);
73
}
74
75
+// The server also rejects monograms longer than two graphemes (ProjectCommands.ts).
76
+export function isValidProjectMonogram(text: string): boolean {
77
+ if (!isProjectMonogramText(text)) return false;
78
+ const segments = new Intl.Segmenter(undefined, { granularity: "grapheme" }).segment(text);
79
+ return Array.from(segments).length <= 2;
80
+}
81
+
82
export function firstEmoji(value: string): string | null {
83
const trimmed = value.trim();
84
if (!trimmed) return null;