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
This commit is contained in:
1 parent
0f78716903
commit
333d7ef8b7
4 files changed
+178
-17
No files matched your search
@@ -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(
|
||||
|
||||
@@ -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<string, string> = {
|
||||
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__(?<server>.+?)__(?<tool>.+)$/.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 = /^(?<server>t3-code|t3_code|t3code)[.:/](?<tool>.+)$/.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,
|
||||
|
||||
@@ -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(
|
||||
<MessagesTimeline
|
||||
{...buildProps()}
|
||||
timelineEntries={
|
||||
[
|
||||
{
|
||||
id: item.id,
|
||||
kind: "work",
|
||||
createdAt: MESSAGE_CREATED_AT,
|
||||
entry: {
|
||||
id: item.id,
|
||||
createdAt: MESSAGE_CREATED_AT,
|
||||
runId: null,
|
||||
label: item.toolName,
|
||||
tone: "tool",
|
||||
itemType: item.type,
|
||||
toolTitle: item.toolName,
|
||||
toolLifecycleStatus: "completed",
|
||||
toolData: { input: item.input, output: item.output },
|
||||
structuredPayload: item,
|
||||
projectedItem,
|
||||
},
|
||||
},
|
||||
] as never
|
||||
}
|
||||
/>,
|
||||
);
|
||||
|
||||
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(
|
||||
|
||||
@@ -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 (
|
||||
<span
|
||||
className={cn(
|
||||
"flex size-4 shrink-0 items-center justify-center overflow-hidden rounded-[4px] bg-background ring-1 ring-border/65",
|
||||
className,
|
||||
)}
|
||||
title="T3 Code MCP tool"
|
||||
>
|
||||
<img alt="" aria-hidden="true" className="size-4 object-cover" src="/apple-touch-icon.png" />
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
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}
|
||||
>
|
||||
<div className="flex select-none items-center gap-1.5 transition-[opacity,translate] duration-200">
|
||||
<span className={iconWrapperClass}>
|
||||
<WorkEntryIconSvg
|
||||
name={entryIconName}
|
||||
className="block size-3.5 shrink-0 stroke-[1.8] opacity-80"
|
||||
/>
|
||||
{toolPresentation?.logo === "t3-code" ? (
|
||||
<T3CodeToolLogo />
|
||||
) : (
|
||||
<WorkEntryIconSvg
|
||||
name={entryIconName}
|
||||
className="block size-3.5 shrink-0 stroke-[1.8] opacity-80"
|
||||
/>
|
||||
)}
|
||||
</span>
|
||||
<div className="flex min-w-0 flex-1 items-center gap-1.5">
|
||||
<div className="min-w-0 flex-1 overflow-hidden">
|
||||
|
||||
Reference in new issue
Block a user