Skip to content
TypeScript

feat: add customizable soft-tint project monograms (#11845)

eimexdev438465d6b7dd
diff --git a/apps/server/src/orchestration/Layers/ProjectionPipeline.test.ts b/apps/server/src/orchestration/Layers/ProjectionPipeline.test.ts
index 21c95142929..90f7470a8c5 100644
--- a/apps/server/src/orchestration/Layers/ProjectionPipeline.test.ts
+++ b/apps/server/src/orchestration/Layers/ProjectionPipeline.test.ts
@@ -4353,6 +4353,45 @@ engineLayer("OrchestrationProjectionPipeline via engine dispatch", (it) => {
}),
);
+ it.effect("persists and clears a project monogram", () =>
+ Effect.gen(function* () {
+ const engine = yield* OrchestrationEngineService;
+ const sql = yield* SqlClient.SqlClient;
+ const projectId = ProjectId.make("project-monogram");
+ yield* engine.dispatch({
+ type: "project.create",
+ commandId: CommandId.make("cmd-monogram-create"),
+ projectId,
+ title: "Monogram",
+ workspaceRoot: "/tmp/project-monogram",
+ defaultModelSelection: null,
+ createdAt: "2026-01-01T00:00:00.000Z",
+ });
+ yield* engine.dispatch({
+ type: "project.meta.update",
+ commandId: CommandId.make("cmd-monogram-save"),
+ projectId,
+ projectIcon: { kind: "lucide", name: "folder-code", color: "violet", monogram: "T3" },
+ });
+ const saved = yield* sql<{
+ readonly icon: string | null;
+ }>`SELECT project_icon_json AS icon FROM projection_projects WHERE project_id = ${projectId}`;
+ assert.deepEqual(saved, [
+ { icon: '{"kind":"lucide","name":"folder-code","color":"violet","monogram":"T3"}' },
+ ]);
+ yield* engine.dispatch({
+ type: "project.meta.update",
+ commandId: CommandId.make("cmd-monogram-clear"),
+ projectId,
+ projectIcon: null,
+ });
+ const cleared = yield* sql<{
+ readonly icon: string | null;
+ }>`SELECT project_icon_json AS icon FROM projection_projects WHERE project_id = ${projectId}`;
+ assert.deepEqual(cleared, [{ icon: null }]);
+ }),
+ );
+
it.effect("re-creating a deleted thread id starts from an empty projection", () =>
Effect.gen(function* () {
const engine = yield* OrchestrationEngineService;
diff --git a/apps/web/src/components/ProjectFavicon.tsx b/apps/web/src/components/ProjectFavicon.tsx
index 17006889fb9..edf9f23e23a 100644
--- a/apps/web/src/components/ProjectFavicon.tsx
+++ b/apps/web/src/components/ProjectFavicon.tsx
@@ -11,6 +11,7 @@ import { useAtomValue } from "@effect/atom-react";
import { projectFaviconUrlAtom } from "../state/assets";
import { deriveProjectIdentity } from "../projectIdentity";
import { projectIconColorClassName } from "../projectIconColors";
+import { ProjectMonogram } from "./ProjectMonogram";
import { cn } from "~/lib/utils";
const DynamicIcon = lazy(() =>
@@ -42,6 +43,15 @@ export function ProjectFavicon(input: {
faviconPath: project.faviconPath,
}),
);
+ if (project.projectIcon?.kind === "lucide" && project.projectIcon.monogram) {
+ return (
+ <ProjectMonogram
+ text={project.projectIcon.monogram}
+ color={project.projectIcon.color}
+ className={input.className}
+ />
+ );
+ }
if (project.projectIcon?.kind === "emoji") {
return (
<ProjectFaviconFallback
@@ -112,49 +122,8 @@ function ProjectFaviconFallback({
}) {
if (projectName && projectName.trim().length > 0) {
const identity = deriveProjectIdentity(projectName);
- // Wrapped like the emoji and Lucide branches so the monogram sits where an
- // <img> favicon would. Menu items, buttons and the like pull every bare svg
- // in with [&_svg]:-mx-0.5 to trim the padding stroke icons carry, and this
- // tile has no such padding.
return (
- <span
- aria-hidden="true"
- className={cn("inline-flex size-4 shrink-0 items-center justify-center", className)}
- >
- <svg
- viewBox="0 0 16 16"
- className="size-full overflow-hidden rounded-[25%] font-mono select-none"
- style={{
- backgroundColor: identity.background,
- backgroundImage: `linear-gradient(145deg, ${identity.highlight}, ${identity.background} 72%)`,
- }}
- >
- <text
- x="8"
- y="10.8"
- textAnchor="middle"
- fill="white"
- className="font-mono"
- fontSize="8.25"
- fontWeight="700"
- textLength="12"
- lengthAdjust="spacingAndGlyphs"
- textRendering="geometricPrecision"
- >
- {identity.monogram}
- </text>
- <rect
- x="0.25"
- y="0.25"
- width="15.5"
- height="15.5"
- rx="3.75"
- fill="none"
- strokeWidth="0.5"
- className="stroke-black/10 dark:stroke-white/10"
- />
- </svg>
- </span>
+ <ProjectMonogram text={identity.monogram} color={identity.color} className={className} />
);
}
diff --git a/apps/web/src/components/ProjectMonogram.tsx b/apps/web/src/components/ProjectMonogram.tsx
new file mode 100644
index 00000000000..04a44e166ea
--- /dev/null
+++ b/apps/web/src/components/ProjectMonogram.tsx
@@ -0,0 +1,52 @@
+import type { ProjectIconColor } from "@t3tools/contracts";
+import { projectIconColorClassName } from "../projectIconColors";
+import { cn } from "~/lib/utils";
+
+const monogramSegmenter = new Intl.Segmenter(undefined, { granularity: "grapheme" });
+
+export function ProjectMonogram({
+ text,
+ color,
+ className,
+}: {
+ readonly text: string;
+ readonly color: ProjectIconColor;
+ readonly className?: string | undefined;
+}) {
+ // Wrapped like the emoji and Lucide branches so the monogram sits where an
+ // <img> favicon would. Menu items, buttons and the like pull every bare svg
+ // in with [&_svg]:-mx-0.5 to trim the padding stroke icons carry, and this
+ // tile has no such padding.
+ return (
+ <span
+ aria-hidden="true"
+ className={cn("inline-flex size-4 shrink-0 items-center justify-center", className)}
+ >
+ <svg
+ viewBox="0 0 16 16"
+ className={cn(
+ "size-full overflow-hidden rounded-[25%] font-mono select-none",
+ projectIconColorClassName(color),
+ )}
+ style={{
+ backgroundColor: "color-mix(in srgb, currentColor 14%, transparent)",
+ }}
+ >
+ <text
+ x="8"
+ y="10.8"
+ textAnchor="middle"
+ fill="currentColor"
+ className="font-mono"
+ fontSize="8.25"
+ fontWeight="700"
+ textLength={Array.from(monogramSegmenter.segment(text)).length === 1 ? 6 : 12}
+ lengthAdjust="spacingAndGlyphs"
+ textRendering="geometricPrecision"
+ >
+ {text}
+ </text>
+ </svg>
+ </span>
+ );
+}
diff --git a/apps/web/src/components/settings/ProjectIconPickerDialog.test.tsx b/apps/web/src/components/settings/ProjectIconPickerDialog.test.tsx
index 2280395ecf4..e1c08dfbabb 100644
--- a/apps/web/src/components/settings/ProjectIconPickerDialog.test.tsx
+++ b/apps/web/src/components/settings/ProjectIconPickerDialog.test.tsx
@@ -41,7 +41,13 @@ import { ProjectIconPickerDialog } from "./ProjectIconPickerDialog";
describe("ProjectIconPickerDialog", () => {
it("shows icons first and selects them for an automatic project", () => {
const markup = renderToStaticMarkup(
- <ProjectIconPickerDialog current={null} open onOpenChange={() => {}} onSelect={() => {}} />,
+ <ProjectIconPickerDialog
+ current={null}
+ projectName="Test"
+ open
+ onOpenChange={() => {}}
+ onSelect={() => {}}
+ />,
);
expect(markup).toContain('data-current="lucide"');
diff --git a/apps/web/src/components/settings/ProjectIconPickerDialog.tsx b/apps/web/src/components/settings/ProjectIconPickerDialog.tsx
index 7fce7a4fbb5..8bcdcc617ef 100644
--- a/apps/web/src/components/settings/ProjectIconPickerDialog.tsx
+++ b/apps/web/src/components/settings/ProjectIconPickerDialog.tsx
@@ -1,4 +1,11 @@
-import type { ProjectIconColor, ProjectIconOverride } from "@t3tools/contracts";
+import * as Schema from "effect/Schema";
+import { deriveProjectIdentity } from "../../projectIdentity";
+import { ProjectMonogram } from "../ProjectMonogram";
+import {
+ ProjectMonogramText,
+ type ProjectIconColor,
+ type ProjectIconOverride,
+} from "@t3tools/contracts";
import { DynamicIcon, type IconName } from "lucide-react/dynamic";
import { useEffect, useMemo, useRef, useState } from "react";
import {
@@ -24,7 +31,7 @@ import { ScrollArea } from "../ui/scroll-area";
import { Toggle, ToggleGroup } from "../ui/toggle-group";
const DEFAULT_ICON: IconName = "folder-code";
-const DEFAULT_COLOR: ProjectIconColor = "blue";
+const isMonogramText = Schema.is(ProjectMonogramText);
function iconLabel(name: string): string {
return name
@@ -35,23 +42,29 @@ function iconLabel(name: string): string {
export function ProjectIconPickerDialog({
current,
+ projectName,
open,
onOpenChange,
onSelect,
}: {
readonly current: ProjectIconOverride | null;
+ readonly projectName: string;
readonly open: boolean;
readonly onOpenChange: (open: boolean) => void;
readonly onSelect: (icon: ProjectIconOverride) => void;
}) {
- const [mode, setMode] = useState<"lucide" | "emoji">(
- current?.kind === "emoji" ? "emoji" : "lucide",
+ const automatic = deriveProjectIdentity(projectName);
+ const [mode, setMode] = useState<ProjectIconOverride["kind"] | "monogram">(
+ current?.kind === "lucide" && current.monogram ? "monogram" : (current?.kind ?? "lucide"),
);
const [iconName, setIconName] = useState<IconName>(
current?.kind === "lucide" ? (current.name as IconName) : DEFAULT_ICON,
);
const [color, setColor] = useState<ProjectIconColor>(
- current?.kind === "lucide" ? current.color : DEFAULT_COLOR,
+ current && current.kind !== "emoji" ? current.color : automatic.color,
+ );
+ const [letters, setLetters] = useState(
+ current?.kind === "lucide" && current.monogram ? current.monogram : automatic.monogram,
);
const [emoji, setEmoji] = useState(current?.kind === "emoji" ? current.emoji : "💻");
const [query, setQuery] = useState("");
@@ -60,21 +73,33 @@ export function ProjectIconPickerDialog({
useEffect(() => {
if (open && !previousOpenRef.current) {
- setMode(current?.kind === "emoji" ? "emoji" : "lucide");
+ setMode(
+ current?.kind === "lucide" && current.monogram ? "monogram" : (current?.kind ?? "lucide"),
+ );
setIconName(current?.kind === "lucide" ? (current.name as IconName) : DEFAULT_ICON);
- setColor(current?.kind === "lucide" ? current.color : DEFAULT_COLOR);
+ setColor(current && current.kind !== "emoji" ? current.color : automatic.color);
+ setLetters(
+ current?.kind === "lucide" && current.monogram ? current.monogram : automatic.monogram,
+ );
setEmoji(current?.kind === "emoji" ? current.emoji : "💻");
setQuery("");
setCustomEmoji("");
}
previousOpenRef.current = open;
- }, [current, open]);
+ }, [current, open, automatic.color, automatic.monogram]);
const icons = useMemo(() => filterProjectIconNames(query), [query]);
const selectedColorClassName = projectIconColorClassName(color);
+ const monogram = letters.normalize("NFKC").trim().toUpperCase();
+ const validMonogram = isMonogramText(monogram);
const save = () => {
+ if (mode === "monogram" && !validMonogram) return;
onSelect(
- mode === "lucide" ? { kind: "lucide", name: iconName, color } : { kind: "emoji", emoji },
+ mode === "monogram"
+ ? { kind: "lucide", name: DEFAULT_ICON, monogram, color }
+ : mode === "lucide"
+ ? { kind: "lucide", name: iconName, color }
+ : { kind: "emoji", emoji },
);
onOpenChange(false);
};
@@ -84,7 +109,7 @@ export function ProjectIconPickerDialog({
<DialogPopup className="w-full sm:w-[32rem]">
<DialogHeader>
<DialogTitle>Choose project icon</DialogTitle>
- <DialogDescription>Pick any Lucide icon and color, or use an emoji.</DialogDescription>
+ <DialogDescription>Choose an icon, emoji, or monogram.</DialogDescription>
</DialogHeader>
<DialogPanel className="flex min-h-0 flex-col gap-4">
<ToggleGroup
@@ -93,35 +118,39 @@ export function ProjectIconPickerDialog({
value={[mode]}
onValueChange={(next) => {
const value = next[0];
- if (value === "lucide" || value === "emoji") setMode(value);
+ if (value === "lucide" || value === "emoji" || value === "monogram") setMode(value);
}}
>
<Toggle value="lucide">Icons</Toggle>
<Toggle value="emoji">Emoji</Toggle>
+ <Toggle value="monogram">Monogram</Toggle>
</ToggleGroup>
+ {mode !== "emoji" ? (
+ <div>
+ <div className="mb-2 text-xs font-medium text-muted-foreground">Color</div>
+ <div className="flex flex-wrap gap-1.5" role="group" aria-label="Icon color">
+ {PROJECT_ICON_COLORS.map((option) => (
+ <button
+ key={option.value}
+ type="button"
+ aria-label={option.label}
+ aria-pressed={color === option.value}
+ className={cn(
+ "flex size-6 items-center justify-center rounded-full border border-transparent outline-none focus-visible:ring-2 focus-visible:ring-ring",
+ color === option.value && "border-foreground/64",
+ )}
+ onClick={() => setColor(option.value)}
+ >
+ <span className={cn("size-4 rounded-full", option.swatchClassName)} />
+ </button>
+ ))}
+ </div>
+ </div>
+ ) : null}
+
{mode === "lucide" ? (
<>
- <div>
- <div className="mb-2 text-xs font-medium text-muted-foreground">Color</div>
- <div className="flex flex-wrap gap-1.5" role="group" aria-label="Icon color">
- {PROJECT_ICON_COLORS.map((option) => (
- <button
- key={option.value}
- type="button"
- aria-label={option.label}
- aria-pressed={color === option.value}
- className={cn(
- "flex size-6 items-center justify-center rounded-full border border-transparent outline-none focus-visible:ring-2 focus-visible:ring-ring",
- color === option.value && "border-foreground/64",
- )}
- onClick={() => setColor(option.value)}
- >
- <span className={cn("size-4 rounded-full", option.swatchClassName)} />
- </button>
- ))}
- </div>
- </div>
<Input
type="search"
value={query}
@@ -153,6 +182,30 @@ export function ProjectIconPickerDialog({
<p className="py-8 text-center text-sm text-muted-foreground">No icons found.</p>
) : null}
</>
+ ) : mode === "monogram" ? (
+ <div className="flex items-center gap-4 py-2">
+ <ProjectMonogram
+ text={validMonogram ? monogram : automatic.monogram}
+ color={color}
+ className="size-12"
+ />
+ <div className="flex-1 space-y-2">
+ <label htmlFor="project-monogram" className="text-sm font-medium">
+ Letters
+ </label>
+ <Input
+ id="project-monogram"
+ value={letters}
+ onChange={(event) => setLetters(event.currentTarget.value)}
+ aria-describedby="project-monogram-hint"
+ aria-invalid={!validMonogram}
+ autoComplete="off"
+ />
+ <p id="project-monogram-hint" className="text-xs text-muted-foreground">
+ One or two letters or numbers.
+ </p>
+ </div>
+ </div>
) : (
<>
<ScrollArea scrollFade className="max-h-64">
@@ -197,7 +250,9 @@ export function ProjectIconPickerDialog({
<Button variant="outline" onClick={() => onOpenChange(false)}>
Cancel
</Button>
- <Button onClick={save}>Save icon</Button>
+ <Button onClick={save} disabled={mode === "monogram" && !validMonogram}>
+ Save icon
+ </Button>
</DialogFooter>
</DialogPopup>
</Dialog>
diff --git a/apps/web/src/components/settings/ProjectSettingsPanel.tsx b/apps/web/src/components/settings/ProjectSettingsPanel.tsx
index 1a0f31d7783..3e4cfd22a93 100644
--- a/apps/web/src/components/settings/ProjectSettingsPanel.tsx
+++ b/apps/web/src/components/settings/ProjectSettingsPanel.tsx
@@ -435,7 +435,7 @@ function ProjectDetail({
title="Project icon"
description={
projectIcon?.kind === "lucide"
- ? `${projectIcon.name} · ${projectIcon.color}`
+ ? `${projectIcon.monogram ?? projectIcon.name} · ${projectIcon.color}`
: projectIcon?.kind === "emoji"
? projectIcon.emoji
: (faviconPath ?? "Automatic")
@@ -530,6 +530,7 @@ function ProjectDetail({
<Suspense fallback={null}>
<ProjectIconPickerDialog
current={projectIcon}
+ projectName={representative.title}
open
onOpenChange={setIconPickerOpen}
onSelect={(icon) => void setProjectIcon({ faviconPath: null, projectIcon: icon })}
diff --git a/apps/web/src/projectIdentity.test.ts b/apps/web/src/projectIdentity.test.ts
index 942e76fc91b..250fce32810 100644
--- a/apps/web/src/projectIdentity.test.ts
+++ b/apps/web/src/projectIdentity.test.ts
@@ -1,4 +1,5 @@
import { describe, expect, it } from "vite-plus/test";
+import { PROJECT_ICON_COLORS } from "./projectIconColors";
import { deriveProjectIdentity } from "./projectIdentity";
describe("deriveProjectIdentity", () => {
@@ -18,14 +19,20 @@ describe("deriveProjectIdentity", () => {
const canonical = deriveProjectIdentity("Nebula");
const equivalent = deriveProjectIdentity(" NEBULA ");
- expect(equivalent.background).toBe(canonical.background);
- expect(equivalent.highlight).toBe(canonical.highlight);
+ expect(equivalent.color).toBe(canonical.color);
+ });
+
+ it("uses only colors available in the icon picker", () => {
+ const palette = PROJECT_ICON_COLORS.map(({ value }) => value);
+ for (const name of ["Jobs", "Scripts and Extractors", "T3", "文書", "", "---"]) {
+ expect(palette).toContain(deriveProjectIdentity(name).color);
+ }
});
it("generates different hues for different project names", () => {
const colors = new Set(
["Nebula", "M7 Forge", "Silver Orchard", "Blue Harbor", "Copper Finch", "Juniper Vale"].map(
- (projectName) => deriveProjectIdentity(projectName).background,
+ (projectName) => deriveProjectIdentity(projectName).color,
),
);
diff --git a/apps/web/src/projectIdentity.ts b/apps/web/src/projectIdentity.ts
index 661a07553a6..840856aa403 100644
--- a/apps/web/src/projectIdentity.ts
+++ b/apps/web/src/projectIdentity.ts
@@ -1,8 +1,10 @@
+import { PROJECT_ICON_COLORS } from "./projectIconColors";
+import type { ProjectIconColor } from "@t3tools/contracts";
+
/** Visual identity tokens for a generated project badge. */
export interface ProjectIdentity {
readonly monogram: string;
- readonly background: string;
- readonly highlight: string;
+ readonly color: ProjectIconColor;
}
function normalizeProjectName(projectName: string): string {
@@ -23,21 +25,19 @@ function projectMonogram(projectName: string): string {
return Array.from(`${first}${second}`.toUpperCase()).slice(0, 2).join("");
}
-function projectHue(projectName: string): number {
+function projectColor(projectName: string): ProjectIconColor {
const seed = normalizeProjectName(projectName).toLocaleLowerCase("en-US") || "project";
- let hue = 0;
+ let index = 0;
for (const glyph of seed) {
- hue = (hue * 31 + (glyph.codePointAt(0) ?? 0)) % 360;
+ index = (index * 31 + (glyph.codePointAt(0) ?? 0)) % PROJECT_ICON_COLORS.length;
}
- return hue;
+ return PROJECT_ICON_COLORS[index]?.value ?? "blue";
}
/** Derives the stable monogram and generated colors used when a project has no icon. */
export function deriveProjectIdentity(projectName: string): ProjectIdentity {
- const hue = projectHue(projectName);
return {
monogram: projectMonogram(projectName),
- background: `hsl(${hue} 48% 36%)`,
- highlight: `hsl(${(hue + 24) % 360} 58% 48%)`,
+ color: projectColor(projectName),
};
}
diff --git a/docs/user/project-settings.md b/docs/user/project-settings.md
index 2985c6c011c..372e92b9a10 100644
--- a/docs/user/project-settings.md
+++ b/docs/user/project-settings.md
@@ -43,12 +43,14 @@ Browser access changes apply when an agent session next starts.
## Project icons
-Select the project and open Project to choose an icon, emoji, or image. The choice applies to
+Select the project and open Project to choose an icon, emoji, monogram, or image. The choice applies to
every checkout in the project group and appears on connected clients. Choose **Automatic** to let
T3 Code detect an icon again.
-When no image is found, web and desktop show a two-character monogram with colors
-derived from the saved project name. For example, `Nebula` becomes `NA`,
+Choose **Monogram** in the icon picker to set one or two letters or numbers and a color.
+
+When no image is found, web and desktop show a two-character monogram with a color
+from the icon palette, derived from the saved project name. For example, `Nebula` becomes `NA`,
`Silver Orchard` becomes `SO`, and `M7 Forge` becomes `M7`.
## Keep the default branch current
diff --git a/packages/contracts/src/orchestration.test.ts b/packages/contracts/src/orchestration.test.ts
index b8c8358813d..5228e296d68 100644
--- a/packages/contracts/src/orchestration.test.ts
+++ b/packages/contracts/src/orchestration.test.ts
@@ -17,6 +17,8 @@ import {
OrchestrationGetTurnDiffInput,
OrchestrationLatestTurn,
ProjectCreatedPayload,
+ OrchestrationProjectShell,
+ ProjectIconColor,
ProjectMetaUpdatedPayload,
OrchestrationProposedPlan,
OrchestrationSession,
@@ -40,6 +42,18 @@ import { ProviderInstanceId } from "./providerInstance.ts";
const decodeTurnDiffInput = Schema.decodeUnknownEffect(OrchestrationGetTurnDiffInput);
const decodeFullThreadDiffInput = Schema.decodeUnknownEffect(OrchestrationGetFullThreadDiffInput);
const decodeThreadTurnDiff = Schema.decodeUnknownEffect(ThreadTurnDiff);
+// The icon shape understood by clients released before monograms.
+const legacyProjectIcon = Schema.Union([
+ Schema.Struct({ kind: Schema.Literal("lucide"), name: Schema.String, color: ProjectIconColor }),
+ Schema.Struct({ kind: Schema.Literal("emoji"), emoji: Schema.String }),
+]);
+const decodeLegacyProjectShell = Schema.decodeUnknownEffect(
+ Schema.Struct({
+ ...OrchestrationProjectShell.fields,
+ projectIcon: Schema.optional(Schema.NullOr(legacyProjectIcon)),
+ }),
+);
+const encodeProjectShell = Schema.encodeEffect(OrchestrationProjectShell);
const decodeProjectCreateCommand = Schema.decodeUnknownEffect(ProjectCreateCommand);
const decodeProjectCreatedPayload = Schema.decodeUnknownEffect(ProjectCreatedPayload);
const decodeProjectMetaUpdatedPayload = Schema.decodeUnknownEffect(ProjectMetaUpdatedPayload);
@@ -1494,6 +1508,64 @@ it.effect("project icon overrides accept Lucide icons, colors, and emoji", () =>
}),
);
+it.effect("older clients decode monogram projects as their fallback icon", () =>
+ Effect.gen(function* () {
+ const encoded = yield* encodeProjectShell({
+ id: ProjectId.make("project-monogram"),
+ title: "Monogram",
+ workspaceRoot: "/tmp/monogram",
+ defaultModelSelection: null,
+ scripts: [],
+ createdAt: "2026-01-01T00:00:00.000Z",
+ updatedAt: "2026-01-01T00:00:00.000Z",
+ projectIcon: { kind: "lucide", name: "folder-code", color: "violet", monogram: "T3" },
+ });
+ const decoded = yield* decodeLegacyProjectShell(encoded);
+ assert.deepEqual(decoded.projectIcon, { kind: "lucide", name: "folder-code", color: "violet" });
+ }),
+);
+
+it.effect("project monograms validate text and palette colors", () =>
+ Effect.gen(function* () {
+ for (const text of ["A", "T3", "É", "文書", "कि", "किखि", "e\u0301"]) {
+ const projectIcon = {
+ kind: "lucide",
+ name: "folder-code",
+ color: "violet",
+ monogram: text,
+ } as const;
+ const command = yield* decodeOrchestrationCommand({
+ type: "project.meta.update",
+ commandId: "cmd-monogram",
+ projectId: "project-1",
+ projectIcon,
+ });
+ assert.strictEqual(command.type, "project.meta.update");
+ if (command.type === "project.meta.update")
+ assert.deepEqual(command.projectIcon, projectIcon);
+ }
+ for (const projectIcon of [
+ { kind: "lucide", name: "folder-code", monogram: "", color: "blue" },
+ { kind: "lucide", name: "folder-code", monogram: "ABC", color: "blue" },
+ { kind: "lucide", name: "folder-code", monogram: "किखिगि", color: "blue" },
+ { kind: "lucide", name: "folder-code", monogram: "\u0301", color: "blue" },
+ { kind: "lucide", name: "folder-code", monogram: "A B", color: "blue" },
+ { kind: "lucide", name: "folder-code", monogram: "🚀", color: "blue" },
+ { kind: "lucide", name: "folder-code", monogram: "T3", color: "ultraviolet" },
+ ]) {
+ const result = yield* Effect.exit(
+ decodeOrchestrationCommand({
+ type: "project.meta.update",
+ commandId: "cmd-monogram-invalid",
+ projectId: "project-1",
+ projectIcon,
+ }),
+ );
+ assert.strictEqual(result._tag, "Failure");
+ }
+ }),
+);
+
it.effect("rejects thread history imports without messages", () =>
Effect.gen(function* () {
const result = yield* Effect.exit(
diff --git a/packages/contracts/src/orchestration.ts b/packages/contracts/src/orchestration.ts
index aa2dd54fecb..dc8a0732198 100644
--- a/packages/contracts/src/orchestration.ts
+++ b/packages/contracts/src/orchestration.ts
@@ -459,11 +459,20 @@ const ProjectLucideIconName = TrimmedNonEmptyString.check(
const ProjectEmoji = TrimmedNonEmptyString.check(Schema.isMaxLength(32));
+const monogramSegmenter = new Intl.Segmenter(undefined, { granularity: "grapheme" });
+export const ProjectMonogramText = TrimmedNonEmptyString.check(
+ Schema.isMaxLength(32),
+ Schema.isPattern(/^[\p{L}\p{N}][\p{L}\p{N}\p{M}\u200c\u200d]*$/u),
+ Schema.makeFilter((text) => Array.from(monogramSegmenter.segment(text)).length <= 2),
+);
+
export const ProjectIconOverride = Schema.Union([
Schema.Struct({
kind: Schema.Literal("lucide"),
name: ProjectLucideIconName,
color: ProjectIconColor,
+ // Older clients ignore this field and render the named Lucide icon instead.
+ monogram: Schema.optional(ProjectMonogramText),
}),
Schema.Struct({
kind: Schema.Literal("emoji"),