From 333d7ef8b7dbdb495ac41f863a63597723ea3d80 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Tue, 21 Jul 2026 03:19:40 -0700 Subject: [PATCH] Render T3 MCP tools with branded timeline labels - Pretty-print known T3 MCP tool names in work rows - Show the T3 Code logo for recognized MCP tool entries - Add logic and UI tests for the new tool presentation --- .../chat/MessagesTimeline.logic.test.ts | 40 ++++++++---- .../components/chat/MessagesTimeline.logic.ts | 61 ++++++++++++++++++ .../components/chat/MessagesTimeline.test.tsx | 63 +++++++++++++++++++ .../src/components/chat/MessagesTimeline.tsx | 31 +++++++-- 4 files changed, 178 insertions(+), 17 deletions(-) diff --git a/apps/web/src/components/chat/MessagesTimeline.logic.test.ts b/apps/web/src/components/chat/MessagesTimeline.logic.test.ts index 45fe344d04..ac41f566ac 100644 --- a/apps/web/src/components/chat/MessagesTimeline.logic.test.ts +++ b/apps/web/src/components/chat/MessagesTimeline.logic.test.ts @@ -5,20 +5,9 @@ import { deriveMessagesTimelineRows, normalizeCompactToolLabel, resolveAssistantMessageCopyState, - shouldPreserveAssistantLineBreaks, + resolveTimelineToolPresentation, } from "./MessagesTimeline.logic"; -describe("shouldPreserveAssistantLineBreaks", () => { - it("preserves Claude insight formatting without changing regular markdown", () => { - expect( - shouldPreserveAssistantLineBreaks( - "★ Insight ─────────────────\\nFirst observation\\nSecond observation\\n─────────────────", - ), - ).toBe(true); - expect(shouldPreserveAssistantLineBreaks("A normal\\nmarkdown paragraph")).toBe(false); - }); -}); - describe("computeMessageDurationStart", () => { it("returns message createdAt when there is no preceding user message", () => { const result = computeMessageDurationStart([ @@ -218,6 +207,33 @@ describe("normalizeCompactToolLabel", () => { }); }); +describe("resolveTimelineToolPresentation", () => { + it("pretty prints Claude and Cursor T3 MCP tool names", () => { + expect(resolveTimelineToolPresentation("mcp__t3-code__t3_thread_read")).toEqual({ + displayName: "Read a T3 thread", + logo: "t3-code", + }); + }); + + it("pretty prints Codex T3 MCP tool names", () => { + expect(resolveTimelineToolPresentation("t3-code.create_threads")).toEqual({ + displayName: "Create T3 threads", + logo: "t3-code", + }); + }); + + it("pretty prints bare T3 MCP toolkit names", () => { + expect(resolveTimelineToolPresentation("list_scheduled_tasks")).toEqual({ + displayName: "List scheduled tasks", + logo: "t3-code", + }); + }); + + it("keeps unknown MCP tools on the generic renderer path", () => { + expect(resolveTimelineToolPresentation("mcp__github__search_issues")).toBeNull(); + }); +}); + describe("resolveAssistantMessageCopyState", () => { it("returns enabled copy state for completed assistant messages", () => { expect( diff --git a/apps/web/src/components/chat/MessagesTimeline.logic.ts b/apps/web/src/components/chat/MessagesTimeline.logic.ts index cf03a217a3..83fa37d3d9 100644 --- a/apps/web/src/components/chat/MessagesTimeline.logic.ts +++ b/apps/web/src/components/chat/MessagesTimeline.logic.ts @@ -263,6 +263,67 @@ export function normalizeCompactToolLabel(value: string): string { return value.replace(/\s+(?:complete|completed)\s*$/i, "").trim(); } +export interface TimelineToolPresentation { + readonly displayName: string; + readonly logo: "t3-code"; +} + +const T3_MCP_SERVER_ALIASES = new Set(["t3-code", "t3_code", "t3code"]); + +const T3_MCP_TOOL_DISPLAY_NAMES: Record = { + orchestrator_capabilities: "Get orchestration capabilities", + delegate_task: "Delegate a child task", + task_status: "Get delegated task status", + task_cancel: "Cancel delegated task", + schedule_task: "Schedule a recurring task", + list_scheduled_tasks: "List scheduled tasks", + update_scheduled_task: "Update a scheduled task", + delete_scheduled_task: "Delete a scheduled task", + create_threads: "Create T3 threads", + t3_thread_start: "Start a T3 thread", + t3_thread_list: "List T3 threads", + t3_thread_read: "Read a T3 thread", + t3_thread_send: "Send to a T3 thread", + t3_thread_wait: "Wait for a T3 thread", + t3_thread_interrupt: "Interrupt a T3 thread", +}; + +function resolveT3McpToolName(value: string): string | null { + const label = normalizeCompactToolLabel(value); + const mcpMatch = /^mcp__(?.+?)__(?.+)$/.exec(label); + if (mcpMatch?.groups) { + const { server, tool } = mcpMatch.groups; + return server !== undefined && tool !== undefined && T3_MCP_SERVER_ALIASES.has(server) + ? tool + : null; + } + + const namespaceMatch = /^(?t3-code|t3_code|t3code)[.:/](?.+)$/.exec(label); + if (namespaceMatch?.groups) { + return namespaceMatch.groups.tool ?? null; + } + + return Object.hasOwn(T3_MCP_TOOL_DISPLAY_NAMES, label) ? label : null; +} + +export function resolveTimelineToolPresentation( + toolName: string | null | undefined, +): TimelineToolPresentation | null { + const resolvedToolName = + toolName === undefined || toolName === null ? null : resolveT3McpToolName(toolName); + if (resolvedToolName === null) { + return null; + } + const displayName = T3_MCP_TOOL_DISPLAY_NAMES[resolvedToolName]; + if (displayName === undefined) { + return null; + } + return { + displayName, + logo: "t3-code", + }; +} + export function resolveAssistantMessageCopyState({ text, showCopyButton, diff --git a/apps/web/src/components/chat/MessagesTimeline.test.tsx b/apps/web/src/components/chat/MessagesTimeline.test.tsx index 2fcec1233c..8960525979 100644 --- a/apps/web/src/components/chat/MessagesTimeline.test.tsx +++ b/apps/web/src/components/chat/MessagesTimeline.test.tsx @@ -995,6 +995,69 @@ describe("MessagesTimeline", () => { expect(markup).toContain("Inherited"); }); + it("renders T3 MCP dynamic tools with the product logo and pretty name", async () => { + const { MessagesTimeline } = await import("./MessagesTimeline"); + const item = { + id: "tool-t3-thread-read", + threadId: "thread-source", + runId: null, + nodeId: null, + providerThreadId: null, + providerTurnId: null, + nativeItemRef: null, + parentItemId: null, + ordinal: 0, + status: "completed", + title: null, + startedAt: null, + completedAt: null, + updatedAt: {}, + type: "dynamic_tool", + toolName: "mcp__t3-code__t3_thread_read", + input: { threadId: "thread-child" }, + output: { messages: [] }, + } as const; + const projectedItem = { + position: 0, + visibility: "local", + sourceThreadId: "thread-source", + sourceItemId: item.id, + item, + } as const; + const markup = renderToStaticMarkup( + , + ); + + expect(markup).toContain('data-tool-logo="t3-code"'); + expect(markup).toContain('src="/apple-touch-icon.png"'); + expect(markup).toContain("Read a T3 thread"); + expect(markup).not.toContain("mcp__t3-code__t3_thread_read"); + }); + it("formats changed file paths from the workspace root", async () => { const { MessagesTimeline } = await import("./MessagesTimeline"); const markup = renderToStaticMarkup( diff --git a/apps/web/src/components/chat/MessagesTimeline.tsx b/apps/web/src/components/chat/MessagesTimeline.tsx index 241693b8a2..a477386712 100644 --- a/apps/web/src/components/chat/MessagesTimeline.tsx +++ b/apps/web/src/components/chat/MessagesTimeline.tsx @@ -72,6 +72,7 @@ import { computeStableMessagesTimelineRows, deriveMessagesTimelineRows, normalizeCompactToolLabel, + resolveTimelineToolPresentation, resolveAssistantMessageCopyState, resolveTimelineIsAtEnd, resolveTimelineMinimapHasPersistentGutter, @@ -2253,6 +2254,20 @@ function WorkEntryIconSvg({ name, className }: { name: WorkEntryIconName; classN } } +function T3CodeToolLogo({ className }: { className?: string }) { + return ( + + + + ); +} + function workToneIcon(tone: TimelineWorkEntry["tone"]): { iconName: WorkEntryIconName; className: string; @@ -2520,7 +2535,8 @@ const PlainWorkEntryRow = memo(function PlainWorkEntryRow(props: { const iconConfig = workToneIcon(workEntry.tone); const showWarningIndicator = false; const entryIconName = showWarningIndicator ? "x" : workEntryIconName(workEntry); - const heading = toolWorkEntryHeading(workEntry); + const toolPresentation = resolveTimelineToolPresentation(workEntry.toolTitle ?? workEntry.label); + const heading = toolPresentation?.displayName ?? toolWorkEntryHeading(workEntry); const rawPreview = workEntryPreview(workEntry, workspaceRoot); const preview = rawPreview && @@ -2575,16 +2591,21 @@ const PlainWorkEntryRow = memo(function PlainWorkEntryRow(props: { canExpand && "cursor-pointer hover:bg-accent/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/70", )} + data-tool-logo={toolPresentation?.logo} data-v2-item-type={workEntry.projectedItem?.item.type} data-v2-item-visibility={workEntry.projectedItem?.visibility} {...rowToggleProps} >
- + {toolPresentation?.logo === "t3-code" ? ( + + ) : ( + + )}