From fe93832bdd4bfe256fb2ec3e4b354d888fee5d8d Mon Sep 17 00:00:00 2001 From: Abhimanyu Saharan Date: Tue, 3 Mar 2026 00:44:34 +0530 Subject: [PATCH] refactor(frontend): centralize agent emoji constants --- .../src/app/agents/[agentId]/edit/page.tsx | 16 ++-------- frontend/src/app/agents/new/page.tsx | 16 ++-------- frontend/src/app/boards/[boardId]/page.tsx | 16 ++-------- frontend/src/lib/agent-emoji.ts | 32 +++++++++++++++++++ 4 files changed, 38 insertions(+), 42 deletions(-) create mode 100644 frontend/src/lib/agent-emoji.ts diff --git a/frontend/src/app/agents/[agentId]/edit/page.tsx b/frontend/src/app/agents/[agentId]/edit/page.tsx index 2c1adfef..9fe11dda 100644 --- a/frontend/src/app/agents/[agentId]/edit/page.tsx +++ b/frontend/src/app/agents/[agentId]/edit/page.tsx @@ -31,6 +31,7 @@ import { SelectTrigger, SelectValue, } from "@/components/ui/select"; +import { AGENT_EMOJI_OPTIONS } from "@/lib/agent-emoji"; import { DEFAULT_IDENTITY_PROFILE } from "@/lib/agent-templates"; type IdentityProfile = { @@ -39,19 +40,6 @@ type IdentityProfile = { emoji: string; }; -const EMOJI_OPTIONS = [ - { value: ":gear:", label: "Gear", glyph: "⚙️" }, - { value: ":sparkles:", label: "Sparkles", glyph: "✨" }, - { value: ":rocket:", label: "Rocket", glyph: "🚀" }, - { value: ":megaphone:", label: "Megaphone", glyph: "📣" }, - { value: ":chart_with_upwards_trend:", label: "Growth", glyph: "📈" }, - { value: ":bulb:", label: "Idea", glyph: "💡" }, - { value: ":wrench:", label: "Builder", glyph: "🔧" }, - { value: ":shield:", label: "Shield", glyph: "🛡️" }, - { value: ":memo:", label: "Notes", glyph: "📝" }, - { value: ":brain:", label: "Brain", glyph: "🧠" }, -]; - const getBoardOptions = (boards: BoardRead[]): SearchableSelectOption[] => boards.map((board) => ({ value: board.id, @@ -379,7 +367,7 @@ export default function EditAgentPage() { - {EMOJI_OPTIONS.map((option) => ( + {AGENT_EMOJI_OPTIONS.map((option) => ( {option.glyph} {option.label} diff --git a/frontend/src/app/agents/new/page.tsx b/frontend/src/app/agents/new/page.tsx index 271a8910..bec1fd4b 100644 --- a/frontend/src/app/agents/new/page.tsx +++ b/frontend/src/app/agents/new/page.tsx @@ -28,6 +28,7 @@ import { SelectTrigger, SelectValue, } from "@/components/ui/select"; +import { AGENT_EMOJI_OPTIONS } from "@/lib/agent-emoji"; import { DEFAULT_IDENTITY_PROFILE } from "@/lib/agent-templates"; type IdentityProfile = { @@ -36,19 +37,6 @@ type IdentityProfile = { emoji: string; }; -const EMOJI_OPTIONS = [ - { value: ":gear:", label: "Gear", glyph: "⚙️" }, - { value: ":sparkles:", label: "Sparkles", glyph: "✨" }, - { value: ":rocket:", label: "Rocket", glyph: "🚀" }, - { value: ":megaphone:", label: "Megaphone", glyph: "📣" }, - { value: ":chart_with_upwards_trend:", label: "Growth", glyph: "📈" }, - { value: ":bulb:", label: "Idea", glyph: "💡" }, - { value: ":wrench:", label: "Builder", glyph: "🔧" }, - { value: ":shield:", label: "Shield", glyph: "🛡️" }, - { value: ":memo:", label: "Notes", glyph: "📝" }, - { value: ":brain:", label: "Brain", glyph: "🧠" }, -]; - const getBoardOptions = (boards: BoardRead[]): SearchableSelectOption[] => boards.map((board) => ({ value: board.id, @@ -232,7 +220,7 @@ export default function NewAgentPage() { - {EMOJI_OPTIONS.map((option) => ( + {AGENT_EMOJI_OPTIONS.map((option) => ( {option.glyph} {option.label} diff --git a/frontend/src/app/boards/[boardId]/page.tsx b/frontend/src/app/boards/[boardId]/page.tsx index 297edb08..7f686bd2 100644 --- a/frontend/src/app/boards/[boardId]/page.tsx +++ b/frontend/src/app/boards/[boardId]/page.tsx @@ -119,6 +119,7 @@ import { resolveHumanActorName, resolveMemberDisplayName, } from "@/lib/display-name"; +import { AGENT_EMOJI_GLYPHS } from "@/lib/agent-emoji"; import { cn } from "@/lib/utils"; import { usePageActive } from "@/hooks/usePageActive"; import { @@ -519,19 +520,6 @@ const statusOptions = [ { value: "done", label: "Done" }, ]; -const EMOJI_GLYPHS: Record = { - ":gear:": "⚙️", - ":sparkles:": "✨", - ":rocket:": "🚀", - ":megaphone:": "📣", - ":chart_with_upwards_trend:": "📈", - ":bulb:": "💡", - ":wrench:": "🔧", - ":shield:": "🛡️", - ":memo:": "📝", - ":brain:": "🧠", -}; - const SSE_RECONNECT_BACKOFF = { baseMs: 1_000, factor: 2, @@ -2782,7 +2770,7 @@ export default function BoardDetailPage() { if (!value) return null; const trimmed = value.trim(); if (!trimmed) return null; - if (EMOJI_GLYPHS[trimmed]) return EMOJI_GLYPHS[trimmed]; + if (AGENT_EMOJI_GLYPHS[trimmed]) return AGENT_EMOJI_GLYPHS[trimmed]; if (trimmed.startsWith(":") && trimmed.endsWith(":")) return null; return trimmed; }; diff --git a/frontend/src/lib/agent-emoji.ts b/frontend/src/lib/agent-emoji.ts new file mode 100644 index 00000000..9c09a54b --- /dev/null +++ b/frontend/src/lib/agent-emoji.ts @@ -0,0 +1,32 @@ +export type AgentEmojiOption = { + value: string; + label: string; + glyph: string; +}; + +export const AGENT_EMOJI_OPTIONS: readonly AgentEmojiOption[] = [ + { value: ":gear:", label: "Gear", glyph: "⚙️" }, + { value: ":alarm_clock:", label: "Alarm Clock", glyph: "⏰" }, + { value: ":art:", label: "Art", glyph: "🎨" }, + { value: ":brain:", label: "Brain", glyph: "🧠" }, + { value: ":wrench:", label: "Builder", glyph: "🔧" }, + { value: ":dart:", label: "Bullseye", glyph: "🎯" }, + { value: ":computer:", label: "Computer", glyph: "💻" }, + { value: ":chart_with_upwards_trend:", label: "Growth", glyph: "📈" }, + { value: ":bulb:", label: "Idea", glyph: "💡" }, + { value: ":zap:", label: "Lightning", glyph: "⚡" }, + { value: ":lock:", label: "Lock", glyph: "🔒" }, + { value: ":mailbox:", label: "Mailbox", glyph: "📬" }, + { value: ":megaphone:", label: "Megaphone", glyph: "📣" }, + { value: ":memo:", label: "Notes", glyph: "📝" }, + { value: ":owl:", label: "Owl", glyph: "🦉" }, + { value: ":robot:", label: "Robot", glyph: "🤖" }, + { value: ":rocket:", label: "Rocket", glyph: "🚀" }, + { value: ":mag:", label: "Search", glyph: "🔍" }, + { value: ":shield:", label: "Shield", glyph: "🛡️" }, + { value: ":sparkles:", label: "Sparkles", glyph: "✨" }, +]; + +export const AGENT_EMOJI_GLYPHS: Record = Object.fromEntries( + AGENT_EMOJI_OPTIONS.map(({ value, glyph }) => [value, glyph]), +);