Unify T3 MCP tool presentation across clients

- Extract shared T3 MCP tool label resolution
- Show T3 Code branding for matched tool activity rows
- Add tests for shared resolution and mobile feed output
This commit is contained in:
Julius Marminge committed 2026-08-14 11:23:26 +02:00
1 parent 606b9086a7
commit c8a8c421b2
10 files changed
+198 -85

No files matched your search

+2 -7
View File
@@ -3,14 +3,9 @@ import { Image } from "expo-image";
import { View } from "react-native";
import { AppText as Text } from "./AppText";
import { T3_CODE_BRAND_MARK_SOURCE } from "./brandAssets";
const appVariant = Constants.expoConfig?.extra?.appVariant;
const BRAND_MARK_SOURCE =
appVariant === "development"
? require("../../../../assets/dev/blueprint-ios-1024.png")
: appVariant === "preview"
? require("../../../../assets/nightly/nightly-ios-1024.png")
: require("../../../../assets/prod/black-ios-1024.png");
const DEFAULT_STAGE_LABEL =
appVariant === "development" ? "Dev" : appVariant === "preview" ? "Preview" : "Alpha";
@@ -22,7 +17,7 @@ export function BrandMark(props: { readonly compact?: boolean; readonly stageLab
return (
<View className="flex-row items-center gap-3">
<Image
source={BRAND_MARK_SOURCE}
source={T3_CODE_BRAND_MARK_SOURCE}
accessibilityIgnoresInvertColors
style={{
width: iconSize,
+10
View File
@@ -0,0 +1,10 @@
import Constants from "expo-constants";
const appVariant = Constants.expoConfig?.extra?.appVariant;
export const T3_CODE_BRAND_MARK_SOURCE =
appVariant === "development"
? require("../../../../assets/dev/blueprint-ios-1024.png")
: appVariant === "preview"
? require("../../../../assets/nightly/nightly-ios-1024.png")
: require("../../../../assets/prod/black-ios-1024.png");
@@ -1,11 +1,12 @@
import * as Haptics from "expo-haptics";
import { SymbolView, type SFSymbol } from "expo-symbols";
import { Image } from "expo-image";
import { type AppSymbolName, SymbolView } from "../../components/AppSymbol";
import type { EnvironmentId, ThreadId } from "@t3tools/contracts";
import { useRouter } from "expo-router";
import { LayoutAnimation, Pressable, useColorScheme, View } from "react-native";
import { AppText as Text } from "../../components/AppText";
import { scaledTypographyLineHeight } from "../../lib/appearancePreferences";
import { T3_CODE_BRAND_MARK_SOURCE } from "../../components/brandAssets";
import { cn } from "../../lib/cn";
import { buildThreadRoutePath } from "../../lib/routes";
import type { ThreadFeedActivity } from "../../lib/threadActivity";
@@ -74,6 +75,36 @@ function workRowSymbolName(icon: ThreadFeedActivity["icon"]): AppSymbolName {
}
}
function WorkRowIcon(props: {
readonly row: ThreadFeedActivity;
readonly iconSubtleColor: import("react-native").ColorValue;
}) {
const iconIsDestructive = props.row.icon === "alert" || props.row.icon === "warning";
if (props.row.logo === "t3-code") {
return (
<Image
source={T3_CODE_BRAND_MARK_SOURCE}
accessibilityIgnoresInvertColors
style={{
width: 16,
height: 16,
borderRadius: 4,
}}
/>
);
}
return (
<SymbolView
name={workRowSymbolName(props.row.icon)}
size={14}
weight="medium"
tintColor={iconIsDestructive ? "#e11d48" : props.iconSubtleColor}
type="monochrome"
/>
);
}
function ThreadActivityThreadLink(props: {
readonly activity: ThreadFeedActivity;
readonly environmentId: EnvironmentId;
@@ -163,7 +194,7 @@ export function ThreadWorkLog(props: {
const canExpand = row.fullDetail !== null;
const detail = compactActivityDetail(row.detail);
const displayText = detail ? `${row.summary} ${detail}` : row.summary;
const iconIsDestructive = row.icon === "alert" || row.icon === "warning";
const textIsDestructive = row.icon === "alert" || row.icon === "warning";
return (
<View
@@ -195,22 +226,16 @@ export function ThreadWorkLog(props: {
})}
className="rounded-md px-0.5 py-0"
>
<View className="min-h-8 flex-row items-center gap-1.5">
<View className="h-[18px] w-5 shrink-0 items-center justify-center">
<SymbolView
name={workRowSymbolName(row.icon)}
size={13}
weight="medium"
tintColor={iconIsDestructive ? "#e11d48" : props.iconSubtleColor}
type="monochrome"
/>
<View className="min-h-9 flex-row items-center gap-1.5">
<View className="h-5 w-5 shrink-0 items-center justify-center">
<WorkRowIcon row={row} iconSubtleColor={props.iconSubtleColor} />
</View>
<Text className="min-w-0 flex-1 text-xs text-foreground" numberOfLines={1}>
<Text
className={cn(
"font-t3-medium text-foreground",
iconIsDestructive && "text-rose-600 dark:text-rose-400",
textIsDestructive && "text-rose-600 dark:text-rose-400",
)}
>
{row.summary}
@@ -260,6 +260,7 @@ describe("buildThreadFeed", () => {
getFullDetail: () => null,
getCopyText: () => id,
icon: "command",
logo: null,
toolLike: true,
status,
});
@@ -299,6 +300,23 @@ describe("buildThreadFeed", () => {
expanded: true,
});
});
it("pretty prints T3 MCP dynamic tool activities and attaches the product logo", () => {
const toolItem: OrchestrationV2TurnItem = {
...base("item-t3-tool", "2026-06-20T00:00:04.000Z", 3),
type: "dynamic_tool",
toolName: "mcp__t3-code__t3_thread_read",
input: { threadId: "thread-child" },
output: { messages: [] },
};
const feed = buildThreadFeed([projected(toolItem, 0)]);
const activity = feed[0]?.type === "activity-group" ? feed[0].activities[0] : null;
expect(activity?.summary).toBe("Read a T3 thread");
expect(activity?.logo).toBe("t3-code");
expect(activity?.copyText.split("\n")[0]).toBe("Read a T3 thread");
});
});
describe("quiet timeline: nested agents", () => {
+22 -4
View File
@@ -3,6 +3,11 @@ import type {
ThreadPendingUserInput,
ThreadUserInputQuestion,
} from "@t3tools/client-runtime/state/thread-requests";
import {
resolveT3McpToolPresentation,
type T3McpToolLogo,
type T3McpToolPresentation,
} from "@t3tools/shared/t3McpToolPresentation";
import type {
ChatAttachment,
MessageId,
@@ -48,6 +53,7 @@ export interface ThreadFeedActivity {
| "warning"
| "wrench"
| "zap";
readonly logo: T3McpToolLogo | null;
readonly toolLike: boolean;
readonly prominent: boolean;
readonly status: "success" | "failure" | "neutral" | null;
@@ -563,9 +569,19 @@ function itemIcon(item: OrchestrationV2TurnItem): ThreadFeedActivity["icon"] {
}
}
function itemSummary(item: OrchestrationV2TurnItem): string {
function itemToolPresentation(item: OrchestrationV2TurnItem): T3McpToolPresentation | null {
if (item.type !== "dynamic_tool") {
return null;
}
return resolveT3McpToolPresentation(item.toolName) ?? resolveT3McpToolPresentation(item.title);
}
function itemSummary(
item: OrchestrationV2TurnItem,
toolPresentation: T3McpToolPresentation | null = null,
): string {
const title = item.title?.trim();
if (title) return capitalizePhrase(title);
if (title) return toolPresentation?.displayName ?? capitalizePhrase(title);
switch (item.type) {
case "reasoning":
return "Thinking";
@@ -600,7 +616,7 @@ function itemSummary(item: OrchestrationV2TurnItem): string {
case "subagent":
return "Subagent";
case "dynamic_tool":
return item.toolName ?? "Tool call";
return toolPresentation?.displayName ?? item.toolName ?? "Tool call";
case "proposed_plan":
return "Proposed plan";
case "todo_list":
@@ -659,7 +675,8 @@ function itemPreview(item: OrchestrationV2TurnItem): string | null {
function toFeedActivity(row: OrchestrationV2ProjectedTurnItem): ThreadFeedActivity {
const item = row.item;
const summary = itemSummary(item);
const toolPresentation = itemToolPresentation(item);
const summary = itemSummary(item, toolPresentation);
const detail = itemPreview(item);
const fullDetail = JSON.stringify(
{
@@ -679,6 +696,7 @@ function toFeedActivity(row: OrchestrationV2ProjectedTurnItem): ThreadFeedActivi
detail,
fullDetail,
icon: itemIcon(item),
logo: toolPresentation?.logo ?? null,
copyText: [summary, detail, fullDetail]
.filter(
(value, index, values): value is string =>
@@ -14,6 +14,10 @@ import {
type RunId,
} from "@t3tools/contracts";
import type { ThreadRunSummary } from "@t3tools/client-runtime/state/shell";
import {
resolveT3McpToolPresentation,
type T3McpToolPresentation,
} from "@t3tools/shared/t3McpToolPresentation";
export const MAX_VISIBLE_WORK_LOG_ENTRIES = 1;
export const TIMELINE_MINIMAP_ITEM_SPACING = 8;
@@ -259,66 +263,8 @@ 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 type TimelineToolPresentation = T3McpToolPresentation;
export const resolveTimelineToolPresentation = resolveT3McpToolPresentation;
export function resolveAssistantMessageCopyState({
text,
@@ -2255,6 +2255,7 @@ function WorkEntryIconSvg({ name, className }: { name: WorkEntryIconName; classN
}
function T3CodeToolLogo({ className }: { className?: string }) {
const logoUrl = `${import.meta.env.BASE_URL}apple-touch-icon.png`;
return (
<span
className={cn(
@@ -2263,7 +2264,7 @@ function T3CodeToolLogo({ className }: { className?: string }) {
)}
title="T3 Code MCP tool"
>
<img alt="" aria-hidden="true" className="size-4 object-cover" src="/apple-touch-icon.png" />
<img alt="" aria-hidden="true" className="size-4 object-cover" src={logoUrl} />
</span>
);
}
+4
View File
@@ -75,6 +75,10 @@
"types": "./src/toolActivity.ts",
"import": "./src/toolActivity.ts"
},
"./t3McpToolPresentation": {
"types": "./src/t3McpToolPresentation.ts",
"import": "./src/t3McpToolPresentation.ts"
},
"./Struct": {
"types": "./src/Struct.ts",
"import": "./src/Struct.ts"
@@ -0,0 +1,30 @@
import { describe, expect, it } from "vite-plus/test";
import { resolveT3McpToolPresentation } from "./t3McpToolPresentation.ts";
describe("resolveT3McpToolPresentation", () => {
it("pretty prints Claude and Cursor T3 MCP tool names", () => {
expect(resolveT3McpToolPresentation("mcp__t3-code__t3_thread_read")).toEqual({
displayName: "Read a T3 thread",
logo: "t3-code",
});
});
it("pretty prints Codex T3 MCP tool names", () => {
expect(resolveT3McpToolPresentation("t3-code.create_threads")).toEqual({
displayName: "Create T3 threads",
logo: "t3-code",
});
});
it("pretty prints bare T3 MCP toolkit names", () => {
expect(resolveT3McpToolPresentation("list_scheduled_tasks")).toEqual({
displayName: "List scheduled tasks",
logo: "t3-code",
});
});
it("keeps unknown MCP tools on the generic renderer path", () => {
expect(resolveT3McpToolPresentation("mcp__github__search_issues")).toBeNull();
});
});
@@ -0,0 +1,66 @@
export type T3McpToolLogo = "t3-code";
export interface T3McpToolPresentation {
readonly displayName: string;
readonly logo: T3McpToolLogo;
}
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 normalizeT3McpToolLabel(value: string): string {
return value.replace(/\s+(?:complete|completed)\s*$/i, "").trim();
}
function resolveT3McpToolName(value: string): string | null {
const label = normalizeT3McpToolLabel(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 resolveT3McpToolPresentation(
toolName: string | null | undefined,
): T3McpToolPresentation | 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",
};
}