Open-source SEO, GEO, and marketing skills for AI agents.
feat(notfair-cmo): humanized tool-call rendering + MCP favicons (0.4.3)
Yuting Zhong01ab964fc725
diff --git a/notfair-cmo/CHANGELOG.md b/notfair-cmo/CHANGELOG.mdindex 91e1df0d..b7248ed6 100644--- a/notfair-cmo/CHANGELOG.md+++ b/notfair-cmo/CHANGELOG.md@@ -1,5 +1,19 @@# notfair-cmo+## 0.4.3 — 2026-06-02++**Humanized tool-call rendering in the chat transcript.** The chat used to show every shell call as the raw command — long `/bin/zsh -lc "rg --files ..."` lines splatted right under the assistant's reasoning, with both the tool group's `name` and `label` rendering the same incantation. Visually noisy and didn't tell the user anything they couldn't infer from the prose above it.++The transcript now leads with the *intent*. A new `humanizeTool` helper unwraps `bash -lc`-style shell wrappers, inspects the leading binary, and maps it to a verb phrase: `rg`/`grep` → "Searched files", `git status` → "Ran git status", `cat`/`head`/`tail` → "Read file", `pwd` → "Checked working directory", and so on. Built-in tools (Read/Write/Edit/fetch) and MCP tool names (`mcp__notfair-googleads__listAdAccounts` → "Called list ad accounts") get the same treatment. The raw command stays in the expandable body for power users; the small mono identifier (`shell`, `runScript`, etc.) lives on the row as a debug tag.++Codex `command_execution` items are also re-tagged from `name: "<first line of command>"` to `name: "shell"`, so icon lookup hits Terminal correctly and the working indicator stops reading "Calling /bin/zsh -lc …".++**MCP tool calls now stream into the transcript at all.** Codex 0.132+ surfaces MCP invocations as a distinct `mcp_tool_call` item type (separate from `command_execution` and `tool_call`), and our parser was only handling the older two. Net effect: every MCP call the CMO and Google Ads agents fired was silently dropped from the chat — the conversation jumped straight from "I'll query the account" to the prose summary with nothing visible in between. Parser now consumes `mcp_tool_call` (and `mcp_call` / `function_call` for completeness) and emits a `<server>.<tool>` name so the catalog matcher can resolve the brand.++**MCP brand favicons next to tool calls.** When a tool name resolves to a known MCP server in the project's catalog — matched via Claude Code's `mcp__<key>__<tool>` namespace, Codex's `notfair_<proj>__<server>__<tool>` namespace, or the `mcp_tool_call` `<namespaced-server>.<tool>` shape (the matcher peels the `notfair_<proj>__` prefix to find the bare server key) — the row renders the server's brand favicon (via `t3.gstatic.com/faviconV2`) instead of the generic Wrench icon. Falls back gracefully to Wrench when the favicon misses or the catalog has no match.++The chat page and the per-agent task workspace both forward the project's catalog to `LiveTranscript`; `agent-task-workspace` gained a `mcpCatalog` prop that passes straight through.+## 0.4.2 — 2026-06-01**TTL cache on MCP probe results.** Every server render of `/connections` (and the chat thread page's notfair-googleads banner) used to fan out one `initialize` JSON-RPC call per connector to verify liveness. With six connectors that was six round-trips on every page load — fine for one user dogfooding, rude to upstreams as usage grows.diff --git a/notfair-cmo/package.json b/notfair-cmo/package.jsonindex 56d984c4..332d295c 100644--- a/notfair-cmo/package.json+++ b/notfair-cmo/package.json@@ -1,6 +1,6 @@{"name": "notfair-cmo",- "version": "0.4.2",+ "version": "0.4.3","description": "Open-source AI marketing CMO portal. Run locally; orchestrates marketing agents (Google Ads, SEO, and more) on top of Claude Code, Codex, or other local AI coding agents.","license": "MIT","bin": {diff --git a/notfair-cmo/src/app/(app)/[project]/agents/[agent]/chat/[thread]/page.tsx b/notfair-cmo/src/app/(app)/[project]/agents/[agent]/chat/[thread]/page.tsxindex 716d546c..dfd31f44 100644--- a/notfair-cmo/src/app/(app)/[project]/agents/[agent]/chat/[thread]/page.tsx+++ b/notfair-cmo/src/app/(app)/[project]/agents/[agent]/chat/[thread]/page.tsx@@ -8,6 +8,7 @@ import {} from "@/server/sessions/view";import { classifySessions } from "@/server/sessions/view";import { getMcpStatus } from "@/server/mcp/state";+import { getMcpCatalog } from "@/server/mcp-catalog";import { readTranscriptTail } from "@/server/sessions/transcript-tail";import { LiveTranscript } from "@/components/live-transcript";import { GoogleAdsMcpBanner } from "@/components/google-ads-mcp-banner";@@ -87,6 +88,16 @@ export default async function AgentChatThreadPage({// from the old onboarding audit is gone now that audit IS a task.const autoKickoff = false;+ // MCP catalog — pass through the minimum shape the chat needs to+ // render an MCP server's brand favicon next to its tool calls.+ // Mapping is by server key, so the resource_url is the brand domain+ // we feed faviconV2.+ const mcpCatalog = getMcpCatalog(project.slug).map((m) => ({+ key: m.key,+ display_name: m.display_name,+ resource_url: m.resource_url,+ }));+return (<div className="flex h-full flex-col"><McpFlashBanner connected={mcp_connected} error={mcp_error} />@@ -123,6 +134,7 @@ export default async function AgentChatThreadPage({initialEvents={initialEvents}initialByteOffset={initialByteOffset}autoKickoff={autoKickoff}+ mcpCatalog={mcpCatalog}/></div></div>diff --git a/notfair-cmo/src/app/(app)/[project]/agents/[agent]/tasks/page.tsx b/notfair-cmo/src/app/(app)/[project]/agents/[agent]/tasks/page.tsxindex e3176bda..8186c303 100644--- a/notfair-cmo/src/app/(app)/[project]/agents/[agent]/tasks/page.tsx+++ b/notfair-cmo/src/app/(app)/[project]/agents/[agent]/tasks/page.tsx@@ -2,6 +2,7 @@ import { notFound } from "next/navigation";import { AgentTaskWorkspace } from "@/components/agent-task-workspace";import { getProject } from "@/server/db/projects";+import { getMcpCatalog } from "@/server/mcp-catalog";import { resolveAgentBySlug } from "@/server/agent-meta";import { listApprovalsForTask } from "@/server/db/approvals";import { listQuestionsForTask } from "@/server/db/questions";@@ -80,6 +81,12 @@ export default async function AgentTasksPage({ params, searchParams }: Props) {const tasks = listTasksByAgent(agentFullId);const proposedCount = tasks.filter((t) => t.status === "proposed").length;+ // Brand-favicon lookup table for MCP tool calls in the transcript.+ const mcpCatalog = getMcpCatalog(project.slug).map((m) => ({+ key: m.key,+ display_name: m.display_name,+ resource_url: m.resource_url,+ }));return (<AgentTaskWorkspace@@ -90,6 +97,7 @@ export default async function AgentTasksPage({ params, searchParams }: Props) {tasks={tasks}selected={selected}proposedCount={proposedCount}+ mcpCatalog={mcpCatalog}/>);}diff --git a/notfair-cmo/src/components/agent-task-workspace.tsx b/notfair-cmo/src/components/agent-task-workspace.tsxindex 3d0f17b8..77ef7aa7 100644--- a/notfair-cmo/src/components/agent-task-workspace.tsx+++ b/notfair-cmo/src/components/agent-task-workspace.tsx@@ -16,7 +16,7 @@ import { ApprovalCard } from "@/components/approval-card";import { QuestionCard } from "@/components/question-card";import { Badge } from "@/components/ui/badge";import { Button } from "@/components/ui/button";-import { LiveTranscript } from "@/components/live-transcript";+import { LiveTranscript, type McpCatalogEntryLite } from "@/components/live-transcript";import { Markdown } from "@/components/markdown";import { RunningDot } from "@/components/running-dot";import { StartAllTasksButton } from "@/components/start-all-tasks-button";@@ -96,6 +96,9 @@ type Props = {tasks: Task[];selected: SelectedTaskBundle | null;proposedCount: number;+ /** MCP catalog forwarded to the per-task LiveTranscript so tool calls+ * that resolve to an MCP server render the server's brand favicon. */+ mcpCatalog?: McpCatalogEntryLite[];};export function AgentTaskWorkspace({@@ -106,6 +109,7 @@ export function AgentTaskWorkspace({tasks,selected,proposedCount,+ mcpCatalog,}: Props) {const router = useRouter();const search = useSearchParams();@@ -280,6 +284,7 @@ export function AgentTaskWorkspace({agentSlug={agentSlug}agentDisplayName={agentDisplayName}taskById={taskById}+ mcpCatalog={mcpCatalog}/></div></>@@ -300,12 +305,14 @@ function SelectedTaskPanel({agentSlug,agentDisplayName,taskById,+ mcpCatalog,}: {selected: SelectedTaskBundle;projectSlug: string;agentSlug: string;agentDisplayName: string;taskById: Map<string, Task>;+ mcpCatalog?: McpCatalogEntryLite[];}) {const router = useRouter();const isInFlight = TASK_IN_FLIGHT.includes(selected.task.status);@@ -430,6 +437,7 @@ function SelectedTaskPanel({autoKickoff={selected.kickoff !== null}kickoffMessage={selected.kickoff?.message}taskId={selected.kickoff?.taskId}+ mcpCatalog={mcpCatalog}/></div></div>diff --git a/notfair-cmo/src/components/live-transcript.test.tsx b/notfair-cmo/src/components/live-transcript.test.tsxindex 9491dbdd..ee03ab41 100644--- a/notfair-cmo/src/components/live-transcript.test.tsx+++ b/notfair-cmo/src/components/live-transcript.test.tsx@@ -130,9 +130,12 @@ describe("LiveTranscript rendering events", () => {render(<LiveTranscript {...defaultProps({ initialEvents: events, threadId: "t-render" })} />);expect(screen.getByText("hello there")).toBeInTheDocument();expect(screen.getByTestId("markdown")).toHaveTextContent("hi back");- // Tool name "read" appears both in the group headline and in the per-row.- expect(screen.getAllByText("read").length).toBeGreaterThanOrEqual(1);- expect(screen.getAllByText("/etc/passwd").length).toBeGreaterThanOrEqual(1);+ // Tool group now leads with the humanized intent ("Read file") in+ // both summary and expanded row; raw tool identifier ("read") is+ // tucked into a small mono tag on the row, and the label path+ // surfaces as the target detail.+ expect(screen.getAllByText("Read file").length).toBeGreaterThanOrEqual(1);+ expect(screen.getAllByText(/\/etc\/passwd/).length).toBeGreaterThanOrEqual(1);expect(screen.getByText(/ok output/)).toBeInTheDocument();expect(screen.getByText(/→ result/)).toBeInTheDocument();});@@ -171,6 +174,128 @@ describe("LiveTranscript rendering events", () => {expect(screen.getByText("boom")).toBeInTheDocument();});+ it("humanizes a wrapped shell command into a verb phrase (rg → Searched files)", () => {+ const events: TranscriptEvent[] = [+ {+ kind: "tool_call",+ id: "t1",+ ts: 1,+ tool_call_id: "call-rg",+ name: "shell",+ label: `/bin/zsh -lc "rg --files -g '!*node_modules*' | head -200"`,+ },+ ];+ render(<LiveTranscript {...defaultProps({ initialEvents: events, threadId: "t-shell-rg" })} />);+ expect(screen.getAllByText("Searched files").length).toBeGreaterThanOrEqual(1);+ // Raw command remains accessible in the expanded body.+ expect(screen.getAllByText(/rg --files/).length).toBeGreaterThanOrEqual(1);+ });++ it("humanizes legacy transcript rows where the raw command was stored as the tool name", () => {+ // Pre-0.4.3 codex events landed in SQLite with `name` = first line of+ // the shell command. The new humanizer should sniff the shell wrapper+ // out of the name when the label is missing/duplicated and surface+ // the intent verb instead of "Called md\"".+ const events: TranscriptEvent[] = [+ {+ kind: "tool_call",+ id: "t1",+ ts: 1,+ tool_call_id: "call-legacy",+ name: `/bin/zsh -lc "sed -n '1,220p' notfair-meta.json && sed -n '1,260p' IDENTITY.md"`,+ label: `/bin/zsh -lc "sed -n '1,220p' notfair-meta.json && sed -n '1,260p' IDENTITY.md"`,+ },+ ];+ render(<LiveTranscript {...defaultProps({ initialEvents: events, threadId: "t-legacy-shell" })} />);+ expect(screen.queryByText(/Called md/)).not.toBeInTheDocument();+ expect(screen.getAllByText("Transformed text").length).toBeGreaterThanOrEqual(1);+ });++ it("humanizes a git subcommand from a wrapped shell line", () => {+ const events: TranscriptEvent[] = [+ {+ kind: "tool_call",+ id: "t1",+ ts: 1,+ tool_call_id: "call-git",+ name: "shell",+ label: `/bin/zsh -lc "git status --porcelain"`,+ },+ ];+ render(<LiveTranscript {...defaultProps({ initialEvents: events, threadId: "t-shell-git" })} />);+ expect(screen.getAllByText("Ran git status").length).toBeGreaterThanOrEqual(1);+ });++ it("matches an MCP catalog entry via codex's <namespaced-server>.<tool> name shape", () => {+ // Codex 0.132+ ships MCP invocations as `<configKey>.<tool>` where+ // configKey is the namespaced TOML section name we registered+ // (`notfair_<projectSlug>__<serverNameUnderscored>`). The favicon+ // matcher needs to peel that wrapper off so the bare server key+ // hits the catalog.+ const events: TranscriptEvent[] = [+ {+ kind: "tool_call",+ id: "t1",+ ts: 1,+ tool_call_id: "call-mcp-codex",+ name: "notfair_demo__notfair_googleads.listAdAccounts",+ label: "active campaigns",+ },+ ];+ render(+ <LiveTranscript+ {...defaultProps({+ initialEvents: events,+ threadId: "t-mcp-codex",+ mcpCatalog: [+ {+ key: "notfair-googleads",+ display_name: "NotFair Google Ads",+ resource_url: "https://notfair.co/api/mcp/google_ads",+ },+ ],+ })}+ />,+ );+ const imgs = screen.getAllByRole("img", { name: /NotFair Google Ads/ });+ expect(imgs.length).toBeGreaterThanOrEqual(1);+ expect(imgs[0]!.getAttribute("src")).toMatch(/notfair\.co/);+ });++ it("renders an MCP brand favicon when a tool name matches a catalog entry", () => {+ const events: TranscriptEvent[] = [+ {+ kind: "tool_call",+ id: "t1",+ ts: 1,+ tool_call_id: "call-mcp",+ name: "mcp__notfair-googleads__listAdAccounts",+ label: "active campaigns",+ },+ ];+ render(+ <LiveTranscript+ {...defaultProps({+ initialEvents: events,+ threadId: "t-mcp-icon",+ mcpCatalog: [+ {+ key: "notfair-googleads",+ display_name: "NotFair Google Ads",+ resource_url: "https://notfair.co/api/mcp/google_ads",+ },+ ],+ })}+ />,+ );+ // Favicon img comes from the catalog entry's brand domain (notfair.co).+ const imgs = screen.getAllByRole("img", { name: /NotFair Google Ads/ });+ expect(imgs.length).toBeGreaterThanOrEqual(1);+ expect(imgs[0]!.getAttribute("src")).toMatch(/notfair\.co/);+ // Humanized action verb.+ expect(screen.getAllByText(/list ad accounts/i).length).toBeGreaterThanOrEqual(1);+ });+it("groups multiple consecutive tool calls into a single tool group with step count", () => {const events: TranscriptEvent[] = [{@@ -492,9 +617,12 @@ describe("LiveTranscript /api/chat send path", () => {fireEvent.change(textarea, { target: { value: "ls" } });fireEvent.submit(textarea.closest("form")!);await waitFor(() => {- expect(screen.getAllByText("shell").length).toBeGreaterThanOrEqual(1);- expect(screen.getAllByText("ls").length).toBeGreaterThanOrEqual(1);+ // Streamed tool starts now render with the humanized intent —+ // "ls" is recognized as a `Listed files` invocation.+ expect(screen.getAllByText("Listed files").length).toBeGreaterThanOrEqual(1);});+ // Raw "shell" identifier shows as a small mono tag on the expanded row.+ expect(screen.getAllByText("shell").length).toBeGreaterThanOrEqual(1);// Wrap up the stream so the send promise finishes before unmount.controllerRef!.close();});diff --git a/notfair-cmo/src/components/live-transcript.tsx b/notfair-cmo/src/components/live-transcript.tsxindex e3490567..666fcabe 100644--- a/notfair-cmo/src/components/live-transcript.tsx+++ b/notfair-cmo/src/components/live-transcript.tsx@@ -27,6 +27,7 @@ import { toast } from "sonner";import { Button } from "@/components/ui/button";import { Markdown } from "@/components/markdown";+import { brandDomain } from "@/components/mcp-icon";import { RunningDot } from "@/components/running-dot";import {WorkingIndicator,@@ -72,6 +73,17 @@ function eventSignature(e: TranscriptEvent): string {}}+/**+ * Minimum catalog shape the chat needs to render an MCP server's brand icon+ * next to its tool calls. Mirrors `McpSpec` from `mcp-catalog.ts` — we+ * accept the broader type but only use these fields here.+ */+export type McpCatalogEntryLite = {+ key: string;+ display_name: string;+ resource_url: string;+};+type Props = {projectSlug: string;agentSlug: string;@@ -120,6 +132,14 @@ type Props = {* returns 409 when the claim fails; we treat that as a benign no-op.*/taskId?: string;+ /**+ * MCP servers known to this project. The chat uses this to (a) detect+ * when a tool call belongs to an MCP server (vs. a shell / built-in+ * tool) and (b) render the server's brand favicon next to the call.+ * Optional — when omitted, MCP tool calls fall back to the generic+ * Wrench icon.+ */+ mcpCatalog?: McpCatalogEntryLite[];};/** Module-level guard so React StrictMode dev double-mounts don't double-fire. */@@ -139,6 +159,7 @@ export function LiveTranscript({autoKickoff = false,kickoffMessage,taskId,+ mcpCatalog,}: Props) {const router = useRouter();const [events, setEvents] = useState<TranscriptEvent[]>(initialEvents);@@ -612,7 +633,7 @@ export function LiveTranscript({<ol className="space-y-4">{rendered.map((item) => (<li key={item.key}>- <RenderItem item={item} />+ <RenderItem item={item} mcpCatalog={mcpCatalog} /></li>))}{pendingUserMsg && (@@ -622,7 +643,7 @@ export function LiveTranscript({)}{pendingTools.length > 0 && (<li>- <ToolGroup tools={pendingTools} />+ <ToolGroup tools={pendingTools} mcpCatalog={mcpCatalog} /></li>)}{pendingAssistant && (@@ -981,7 +1002,13 @@ function collapseEvents(events: TranscriptEvent[]): RenderedItem[] {return out;}-function RenderItem({ item }: { item: RenderedItem }) {+function RenderItem({+ item,+ mcpCatalog,+}: {+ item: RenderedItem;+ mcpCatalog?: McpCatalogEntryLite[];+}) {if (item.kind === "user_message") {const isKickoff =item.body.startsWith("(task assignment)") ||@@ -999,7 +1026,7 @@ function RenderItem({ item }: { item: RenderedItem }) {return <AssistantText body={item.body} />;}if (item.kind === "tool_group") {- return <ToolGroup tools={item.tools} />;+ return <ToolGroup tools={item.tools} mcpCatalog={mcpCatalog} />;}return null;}@@ -1025,7 +1052,13 @@ function AssistantText({ body }: { body: string }) {);}-function ToolGroup({ tools }: { tools: ToolEntry[] }) {+function ToolGroup({+ tools,+ mcpCatalog,+}: {+ tools: ToolEntry[];+ mcpCatalog?: McpCatalogEntryLite[];+}) {const inFlightCount = tools.filter((t) => !t.done).length;const isLive = inFlightCount > 0;const headline =@@ -1037,6 +1070,10 @@ function ToolGroup({ tools }: { tools: ToolEntry[] }) {// work" rather than punishing every recoverable hiccup.const lastDone = [...tools].reverse().find((t) => t.done);const hasError = !!(lastDone && !lastDone.ok);+ const intent = headline+ ? humanizeTool(headline.name, headline.label)+ : { verb: "Tool call" };+ const headMcp = headline ? matchMcpServerKey(headline.name, mcpCatalog) : null;const HeadIcon = headline ? iconForTool(headline.name) : Wrench;const StatusIcon = isLive? Loader2@@ -1063,13 +1100,20 @@ function ToolGroup({ tools }: { tools: ToolEntry[] }) {><ChevronRight className="size-3.5 shrink-0 text-muted-foreground transition-transform group-open:rotate-90" /><StatusIcon className={cn("size-3.5 shrink-0", statusClass)} />- <HeadIcon className="size-3.5 shrink-0 text-muted-foreground" />- <span className="font-mono text-[11px] font-medium text-foreground">- {headline ? headline.name : "tool"}+ {headMcp ? (+ <ToolBrandFavicon+ resourceUrl={headMcp.resource_url}+ alt={headMcp.display_name}+ />+ ) : (+ <HeadIcon className="size-3.5 shrink-0 text-muted-foreground" />+ )}+ <span className="text-[12px] font-medium text-foreground">+ {intent.verb}</span>- {headline?.label && (- <span className="min-w-0 flex-1 truncate font-mono text-[11px] text-muted-foreground">- {headline.label}+ {intent.target && (+ <span className="min-w-0 flex-1 truncate text-[11px] text-muted-foreground">+ {intent.target}</span>)}<span className="ml-auto text-[10px] tabular-nums text-muted-foreground">@@ -1080,23 +1124,31 @@ function ToolGroup({ tools }: { tools: ToolEntry[] }) {? "working": `${tools.length} steps · ${inFlightCount} live`}</span>+ ) : tools.length === 1 ? (+ <>1 step</>) : (- <>- {tools.length} step{tools.length === 1 ? "" : "s"}- </>+ <>{tools.length} steps</>)}</span></summary>- <div className="space-y-1 border-t bg-background/40 px-3 py-2">+ <div className="space-y-2 border-t bg-background/40 px-3 py-2">{tools.map((t) => (- <ToolRow key={t.toolCallId} entry={t} />+ <ToolRow key={t.toolCallId} entry={t} mcpCatalog={mcpCatalog} />))}</div></details>);}-function ToolRow({ entry }: { entry: ToolEntry }) {+function ToolRow({+ entry,+ mcpCatalog,+}: {+ entry: ToolEntry;+ mcpCatalog?: McpCatalogEntryLite[];+}) {+ const intent = humanizeTool(entry.name, entry.label);+ const mcp = matchMcpServerKey(entry.name, mcpCatalog);const Icon = iconForTool(entry.name);const StatusIcon = entry.done? entry.ok@@ -1108,22 +1160,45 @@ function ToolRow({ entry }: { entry: ToolEntry }) {? "text-emerald-600": "text-destructive": "text-muted-foreground motion-safe:animate-spin";+ // Show the raw command/label only when it actually adds information —+ // i.e. it's not redundant with the intent target the header already+ // surfaces (path/url/etc.). Keeps simple tool rows tight while still+ // exposing shell command lines and other raw invocations in full.+ const showRawLabel =+ !!entry.label &&+ entry.label.trim() !== "" &&+ entry.label.trim() !== intent.target?.trim();return (- <div className="space-y-0.5">+ <div className="space-y-1"><div className="flex items-center gap-2 text-xs"><StatusIcon className={cn("size-3.5 shrink-0", statusClass)} />- <Icon className="size-3.5 shrink-0 text-muted-foreground" />- <span className="font-mono text-[11px] font-medium text-foreground">- {entry.name}+ {mcp ? (+ <ToolBrandFavicon+ resourceUrl={mcp.resource_url}+ alt={mcp.display_name}+ />+ ) : (+ <Icon className="size-3.5 shrink-0 text-muted-foreground" />+ )}+ <span className="text-[12px] font-medium text-foreground">+ {intent.verb}</span>- {entry.label && (- <span className="min-w-0 flex-1 truncate font-mono text-[11px] text-muted-foreground">- {entry.label}+ {intent.target && (+ <span className="min-w-0 flex-1 truncate text-[11px] text-muted-foreground">+ {intent.target}</span>)}+ <span className="ml-auto shrink-0 font-mono text-[10px] text-muted-foreground/70">+ {formatToolName(entry.name)}+ </span></div>+ {showRawLabel && (+ <pre className="ml-6 max-h-40 overflow-auto rounded bg-muted/60 px-2 py-1 font-mono text-[10.5px] leading-snug text-foreground/80 whitespace-pre-wrap break-all">+ {entry.label}+ </pre>+ )}{entry.done && entry.result && (- <div className="pl-6 font-mono text-[11px] text-muted-foreground/90">+ <div className="ml-6 font-mono text-[11px] text-muted-foreground/90"><span className="text-[10px] uppercase tracking-[0.18em]">{entry.ok ? "→ result" : "→ error"}</span>{" "}@@ -1134,6 +1209,46 @@ function ToolRow({ entry }: { entry: ToolEntry }) {);}+/**+ * Tiny inline favicon for an MCP tool row — sized to fit the same 3.5+ * grid slot as the lucide icons next to it, so MCP and built-in tools+ * align cleanly in the same column. Re-implements the brand-favicon+ * fetch instead of using `<McpIcon>` directly because that component+ * always wraps the image in a 9-unit muted square — too chunky for+ * inline rendering in a dense tool row.+ */+function ToolBrandFavicon({+ resourceUrl,+ alt,+}: {+ resourceUrl: string;+ alt: string;+}) {+ const [errored, setErrored] = useState(false);+ let host: string | null = null;+ try {+ host = new URL(resourceUrl).hostname;+ } catch {+ host = null;+ }+ const brand = host ? brandDomain(host) : null;+ if (!brand || errored) {+ return <Wrench className="size-3.5 shrink-0 text-muted-foreground" />;+ }+ return (+ // eslint-disable-next-line @next/next/no-img-element+ <img+ src={`https://t3.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=http://${brand}&size=16`}+ alt={alt}+ width={14}+ height={14}+ className="size-3.5 shrink-0 rounded-[3px]"+ referrerPolicy="no-referrer"+ onError={() => setErrored(true)}+ />+ );+}+/*** Replaces WorkingStatus when the task is parked in `blocked`. The agent* isn't currently running — it's dormant until the gating condition (most@@ -1318,9 +1433,10 @@ function deriveWorkingView(input: {}if (pendingInFlightTool) {+ const intent = humanizeTool(pendingInFlightTool.name, pendingInFlightTool.label);return {- headline: `Calling ${formatToolName(pendingInFlightTool.name)}`,- subtitle: pendingInFlightTool.label ?? null,+ headline: intent.verb,+ subtitle: intent.target ?? pendingInFlightTool.label ?? null,phases,mood: "tool",};@@ -1344,7 +1460,7 @@ function deriveWorkingView(input: {return {headline: "Thinking",subtitle: lastDone- ? `${formatToolName(lastDone.name)} ${lastDone.ok ? "✓" : "failed"} — picking next step`+ ? `${humanizeTool(lastDone.name, lastDone.label).verb} ${lastDone.ok ? "✓" : "failed"} — picking next step`: null,phases,mood: "waiting",@@ -1367,19 +1483,24 @@ function deriveWorkingView(input: {};}if (inFlightCommittedToolCall) {+ const intent = humanizeTool(+ inFlightCommittedToolCall.name,+ inFlightCommittedToolCall.label,+ );return {- headline: `Calling ${formatToolName(inFlightCommittedToolCall.name)}`,- subtitle: inFlightCommittedToolCall.label ?? null,+ headline: intent.verb,+ subtitle: intent.target ?? inFlightCommittedToolCall.label ?? null,phases,mood: "tool",};}if (lastEvent.kind === "tool_result") {+ const verb = humanizeTool(lastEvent.name, null).verb;return {headline: "Thinking",subtitle: lastEvent.ok- ? `${formatToolName(lastEvent.name)} ✓ — picking next step`- : `${formatToolName(lastEvent.name)} failed — retrying`,+ ? `${verb} ✓ — picking next step`+ : `${verb} failed — retrying`,phases,mood: "waiting",};@@ -1399,7 +1520,8 @@ function subtitleForLastTool(): string | null {const lastDonePending = [...pendingTools].reverse().find((t) => t.done);if (lastDonePending) {- return `${formatToolName(lastDonePending.name)} ${lastDonePending.ok ? "✓" : "failed"}`;+ const verb = humanizeTool(lastDonePending.name, lastDonePending.label).verb;+ return `${verb} ${lastDonePending.ok ? "✓" : "failed"}`;}const lastDoneCommitted = [...events].reverse()@@ -1407,7 +1529,8 @@ function subtitleForLastTool(e.kind === "tool_result",);if (lastDoneCommitted) {- return `${formatToolName(lastDoneCommitted.name)} ${lastDoneCommitted.ok ? "✓" : "failed"}`;+ const verb = humanizeTool(lastDoneCommitted.name, null).verb;+ return `${verb} ${lastDoneCommitted.ok ? "✓" : "failed"}`;}return null;}@@ -1426,21 +1549,34 @@ function buildPhases(const seen = new Set<string>();const phases: WorkingPhase[] = [];- // Walk committed events to build phases in order.+ // Walk committed events to build phases in order. Capture the `label`+ // from the tool_call (where it lives) so the phase chip's intent+ // matches what the inline ToolGroup row shows — without it, shell+ // commands collapse to "Ran shell command" in the trajectory.const committedById = new Map<string,- { name: string; done: boolean; ok: boolean }+ { name: string; label: string | null; done: boolean; ok: boolean }>();for (const e of events) {if (e.kind === "tool_call") {- committedById.set(e.tool_call_id, { name: e.name, done: false, ok: true });+ committedById.set(e.tool_call_id, {+ name: e.name,+ label: e.label,+ done: false,+ ok: true,+ });} else if (e.kind === "tool_result") {const prev = committedById.get(e.tool_call_id);if (prev) {prev.done = true;prev.ok = e.ok;} else {- committedById.set(e.tool_call_id, { name: e.name, done: true, ok: e.ok });+ committedById.set(e.tool_call_id, {+ name: e.name,+ label: null,+ done: true,+ ok: e.ok,+ });}}}@@ -1448,7 +1584,7 @@ function buildPhases(seen.add(id);phases.push({id,- label: formatToolName(t.name),+ label: humanizeTool(t.name, t.label).verb,state: !t.done ? "active" : t.ok ? "done" : "failed",});}@@ -1456,11 +1592,12 @@ function buildPhases(// Then any SSE-pending tools the committed list doesn't have yet.for (const t of pendingTools) {if (seen.has(t.toolCallId)) continue;+ const intent = humanizeTool(t.name, t.label);phases.push({id: t.toolCallId,- label: formatToolName(t.name),+ label: intent.verb,state: !t.done ? "active" : t.ok ? "done" : "failed",- detail: t.label ?? null,+ detail: intent.target ?? t.label ?? null,});}@@ -1516,6 +1653,298 @@ function formatToolName(name: string): string {return name;}+/**+ * Human-readable intent for a tool call, used wherever we'd otherwise+ * surface a raw command line or namespaced tool identifier in the chat.+ *+ * Two layers:+ * 1. Shell-flavored names (`shell`, `bash`, `exec`, Claude's `Bash`):+ * unwrap the standard `bash -lc "..."` wrapper, look at the leading+ * binary, map common ones to verb phrases (`rg` → "Searched files",+ * `git status` → "Ran git status", …). Falls back to `Ran <bin>`.+ * 2. Built-in coding tools (Read, Write, Edit, fetch, …) and MCP tool+ * names (`runScript`, `mcp__notfair__listAdAccounts`, …) get a+ * tailored verb based on the tool name, with the label surfaced as+ * the target detail (file path, URL, or short label string).+ *+ * The returned `verb` is what the collapsed tool group shows; `target`+ * is the optional second-half detail truncated by the row's CSS. The+ * raw command/label still lives in the expanded body so power users can+ * see exactly what ran.+ */+type ToolIntent = { verb: string; target?: string };++function humanizeTool(name: string, label: string | null): ToolIntent {+ const n = (name ?? "").toLowerCase();+ // Shell / exec — Codex (`shell`) and Claude Code (`Bash` / `bash` / `exec`).+ // Also catches the legacy transcript rows the v0.4.2 parser left behind:+ // old codex `command_execution` items stored the raw command's first+ // line as BOTH name and label, so we sniff the name/label for the+ // characteristic shell wrapper (`bash -lc "…"`, leading `/bin/zsh`,+ // etc.) and route them through the shell humanizer too.+ if (n === "shell" || n === "bash" || n === "exec" || looksLikeShellInvocation(name) || looksLikeShellInvocation(label ?? "")) {+ // Prefer the label when present (newer events store the command+ // there); fall back to the name for pre-fix rows where the command+ // was written into the name field.+ const cmdSource =+ label && label.trim().length > 0 ? label : name ?? "";+ return humanizeShellCommand(cmdSource);+ }+ // File reads.+ if (n === "read" || n === "cat" || n === "open") {+ return { verb: "Read file", target: label ? shortenPathish(label) : undefined };+ }+ // File writes / edits.+ if (n === "write") return { verb: "Wrote file", target: label ? shortenPathish(label) : undefined };+ if (n === "edit" || n === "patch")+ return { verb: "Edited file", target: label ? shortenPathish(label) : undefined };+ // Web.+ if (n === "fetch" || n === "webfetch" || n.includes("http"))+ return { verb: "Fetched URL", target: label ?? undefined };+ if (n === "websearch" || n === "search" || n === "google")+ return { verb: "Searched the web", target: label ?? undefined };+ // MCP / generic tool — strip namespace prefixes and pretty-print the action.+ const action = formatToolName(name);+ return {+ verb: `Called ${prettifyToolAction(action)}`,+ target: label ?? undefined,+ };+}++const SHELL_WRAPPER_RE =+ /^(?:[/\w.-]+\/)?(?:zsh|bash|sh|dash|ksh)\s+(?:-[A-Za-z]*c|-c)\s+(['"])([\s\S]*)\1\s*$/;++/**+ * Heuristic for "this string is a shell command, not a tool identifier."+ * Used to rescue transcript rows from before v0.4.3, where the codex+ * parser stored the raw command's first line as the tool `name`. Those+ * rows were rendering with the catch-all "Called …" verb, often+ * truncated to garbage like `Called md"` after `formatToolName` split+ * on the trailing `.md"`. Conservative — only matches recognizable+ * shell prefixes, command separators in non-trivial strings, or+ * leading `/usr/bin`-style binary paths. Returns false on empty / short+ * tokens so real MCP tool names like `runScript` don't get misrouted.+ */+function looksLikeShellInvocation(s: string): boolean {+ if (!s) return false;+ const t = s.trim();+ if (t.length < 3) return false;+ // Standard `bash -lc "..."`-style wrappers.+ if (/^(?:[/\w.-]+\/)?(?:zsh|bash|sh|dash|ksh)\s+(?:-[A-Za-z]*c|-c)\b/.test(t))+ return true;+ // Leading absolute binary path (e.g. `/usr/bin/find`, `/bin/ls`).+ if (/^\/(?:usr\/|bin\/|opt\/|sbin\/)/.test(t)) return true;+ // Contains shell metacharacters in a way that's incompatible with any+ // sane tool identifier — pipes, redirects, quoted args, command+ // chains. Combined with a length guard above this skips short+ // identifiers but catches multi-token command lines.+ if (/\s\|\s|\s&&\s|\s>>?\s|^["']|["']\s|\s["']/.test(t)) return true;+ return false;+}++function unwrapShellWrapper(cmd: string): string {+ const m = cmd.trim().match(SHELL_WRAPPER_RE);+ if (m) return m[2]!.trim();+ return cmd.trim();+}++function humanizeShellCommand(rawCmd: string): ToolIntent {+ const inner = unwrapShellWrapper(rawCmd);+ if (!inner) return { verb: "Ran shell command" };+ // Take the leading effective command (before pipes / && / ;). Stops short+ // of full shell parsing — good enough for the leading-verb mapping.+ const lead = inner.split(/\s*(?:[|&;]|\|\|)\s*/)[0]!.trim();+ const tokens = lead.split(/\s+/);+ const head = (tokens[0] ?? "").toLowerCase();+ const sub = tokens[1] ?? "";+ const firstLine = inner.split("\n")[0]!;+ const targetForExpand = firstLine.length > 80 ? `${firstLine.slice(0, 79)}…` : firstLine;+ switch (head) {+ case "pwd":+ return { verb: "Checked working directory" };+ case "ls":+ return { verb: "Listed files", target: extractPathArg(tokens) };+ case "find":+ return { verb: "Searched the filesystem", target: extractPathArg(tokens) };+ case "rg":+ case "grep":+ case "ag":+ case "ack":+ return {+ verb: "Searched files",+ target: extractQuotedToken(inner) ?? extractPathArg(tokens),+ };+ case "cat":+ case "head":+ case "tail":+ case "less":+ case "more":+ case "bat":+ return { verb: "Read file", target: extractPathArg(tokens) };+ case "git": {+ if (!sub) return { verb: "Ran git", target: targetForExpand };+ return { verb: `Ran git ${sub}` };+ }+ case "npm":+ case "pnpm":+ case "yarn":+ case "bun": {+ if (sub === "test" || sub === "t") return { verb: "Ran tests" };+ if (sub === "install" || sub === "add" || sub === "i")+ return { verb: "Installed packages" };+ if (sub === "run") {+ const script = tokens[2];+ return { verb: script ? `Ran ${head} ${script}` : `Ran ${head}` };+ }+ return { verb: sub ? `Ran ${head} ${sub}` : `Ran ${head}` };+ }+ case "node":+ case "python":+ case "python3":+ case "tsx":+ case "deno":+ case "ts-node":+ return { verb: "Ran script", target: extractPathArg(tokens) };+ case "curl":+ case "wget":+ case "http":+ return { verb: "Fetched URL", target: extractUrl(inner) };+ case "mkdir":+ return { verb: "Created directory", target: extractPathArg(tokens) };+ case "touch":+ return { verb: "Created file", target: extractPathArg(tokens) };+ case "rm":+ return { verb: "Removed file(s)", target: extractPathArg(tokens) };+ case "mv":+ return { verb: "Moved file" };+ case "cp":+ return { verb: "Copied file" };+ case "sed":+ case "awk":+ return { verb: "Transformed text" };+ case "which":+ case "type":+ case "whereis":+ return { verb: "Located binary", target: tokens[1] };+ case "echo":+ case "printf":+ return { verb: "Printed text" };+ case "make":+ return { verb: sub ? `Ran make ${sub}` : "Ran make" };+ case "docker":+ return { verb: sub ? `Ran docker ${sub}` : "Ran docker" };+ case "kubectl":+ return { verb: sub ? `Ran kubectl ${sub}` : "Ran kubectl" };+ case "gh":+ return { verb: sub ? `Ran gh ${sub}` : "Ran gh" };+ case "":+ return { verb: "Ran shell command" };+ default:+ return { verb: `Ran ${head}`, target: targetForExpand };+ }+}++function extractPathArg(tokens: string[]): string | undefined {+ // Last token that isn't a flag and isn't the leading binary.+ for (let i = tokens.length - 1; i >= 1; i--) {+ const t = tokens[i]!;+ if (!t.startsWith("-") && !/^[<>|&]+$/.test(t)) {+ return shortenPathish(t.replace(/^['"]|['"]$/g, ""));+ }+ }+ return undefined;+}++function extractUrl(inner: string): string | undefined {+ const m = inner.match(/https?:\/\/[^\s'"]+/);+ return m?.[0];+}++function extractQuotedToken(inner: string): string | undefined {+ const m = inner.match(/['"]([^'"\n]{1,80})['"]/);+ if (!m) return undefined;+ return `"${m[1]}"`;+}++function shortenPathish(p: string): string {+ if (!p) return p;+ // Don't compress URLs.+ if (p.startsWith("http://") || p.startsWith("https://")) return p;+ const segs = p.split("/").filter(Boolean);+ if (segs.length <= 2) return p;+ return `…/${segs.slice(-2).join("/")}`;+}++/**+ * Map a tool action like `listAdAccounts` to a human-readable phrase+ * (`list ad accounts`). Splits on camelCase and snake_case boundaries+ * and lowercases — leaves single-word actions like `runScript` alone+ * after the split. Returns the action unchanged when there's nothing+ * to split.+ */+function prettifyToolAction(action: string): string {+ if (!action) return action;+ const withSpaces = action+ .replace(/([a-z])([A-Z])/g, "$1 $2")+ .replace(/[_-]+/g, " ")+ .trim();+ if (!withSpaces) return action;+ // Don't lowercase one-token names so single identifiers like "runScript"+ // (already split to "run Script") read naturally as "run Script"; we+ // only lowercase the tail to keep proper capitalization of the leading+ // verb the model chose.+ return withSpaces.charAt(0).toLowerCase() + withSpaces.slice(1).toLowerCase();+}++/**+ * Walk the MCP catalog looking for a server key that matches the tool+ * name's namespace prefix. The two harnesses use different schemes:+ *+ * - **Claude Code**: `mcp__<serverKey>__<tool>` (e.g. `mcp__NotFair-GoogleAds__createCampaign`)+ * - **Codex**: `notfair_<projectSlug>__<serverNameUnderscored>__<tool>`+ *+ * We match by normalizing both sides to lowercase + collapsing `-` and+ * `_` so `NotFair-GoogleAds`, `notfair_googleads`, and `notfair-googleads`+ * all collide on the same catalog entry. Returns null when the tool+ * name doesn't carry a recognizable MCP prefix or the prefix isn't in+ * the catalog (e.g. an unprovisioned server, or a non-MCP built-in).+ */+function matchMcpServerKey(+ toolName: string,+ catalog: McpCatalogEntryLite[] | undefined,+): McpCatalogEntryLite | null {+ if (!toolName || !catalog || catalog.length === 0) return null;+ const candidates: string[] = [];+ // Claude Code: mcp__<serverKey>__<tool>+ const claude = toolName.match(/^mcp__([^_].*?)__/);+ if (claude?.[1]) candidates.push(claude[1]);+ // Codex MCP, namespaced + tool suffix:+ // notfair_<projectSlug>__<serverNameUnderscored>__<tool>+ const codexUnderscored = toolName.match(+ /^notfair_[A-Za-z0-9_]+?__([A-Za-z0-9_]+?)__/,+ );+ if (codexUnderscored?.[1]) candidates.push(codexUnderscored[1]);+ // Codex MCP via the `<server>.<tool>` shape this parser uses for+ // `mcp_tool_call` items. The server is the FULL namespaced config key+ // (e.g. `notfair_demo__notfair_googleads`), so peel the leading+ // `notfair_<projectSlug>__` prefix off too — the catalog stores the+ // bare server key.+ const dot = toolName.match(/^([A-Za-z0-9_-]+)\./);+ if (dot?.[1]) {+ candidates.push(dot[1]);+ const tail = dot[1].match(/^notfair_[A-Za-z0-9_]+?__(.+)$/);+ if (tail?.[1]) candidates.push(tail[1]);+ }+ if (candidates.length === 0) return null;+ const norm = (s: string) => s.toLowerCase().replace(/[-_]/g, "");+ for (const cand of candidates) {+ const target = norm(cand);+ const hit = catalog.find((c) => norm(c.key) === target);+ if (hit) return hit;+ }+ return null;+}+function ErrorRow({agentDisplayName,body,diff --git a/notfair-cmo/src/server/adapters/codex-local/parse.test.ts b/notfair-cmo/src/server/adapters/codex-local/parse.test.tsindex 1be71d62..0adbecef 100644--- a/notfair-cmo/src/server/adapters/codex-local/parse.test.ts+++ b/notfair-cmo/src/server/adapters/codex-local/parse.test.ts@@ -34,17 +34,99 @@ describe("parseCodexLine", () => {}),state,);+ // Shell command items get a stable `"shell"` name so the chat UI can+ // route them to the Terminal icon + humanize the intent from the+ // command line. The raw command stays in `label`.expect(out).toEqual([{kind: "tool",phase: "start",toolCallId: "cmd_1",- name: "ls -la",+ name: "shell",label: "ls -la",},]);});+ it("emits a tool start event for an mcp_tool_call item using <server>.<tool> naming", () => {+ // Codex 0.132+ surfaces MCP invocations as their own item type with+ // distinct `server` + `tool` fields. The UI matches tool calls to+ // catalog entries via a `<server>.<tool>` shape, so the parser+ // normalizes to that.+ const state = makeCodexStreamState();+ const out = parseCodexLine(+ JSON.stringify({+ type: "item.started",+ item: {+ type: "mcp_tool_call",+ id: "mcp_1",+ server: "notfair_demo__notfair_googleads",+ tool: "listAdAccounts",+ arguments: { query: "active campaigns" },+ },+ }),+ state,+ );+ expect(out).toEqual([+ {+ kind: "tool",+ phase: "start",+ toolCallId: "mcp_1",+ name: "notfair_demo__notfair_googleads.listAdAccounts",+ label: "active campaigns",+ },+ ]);+ });++ it("emits a tool result event when an mcp_tool_call completes", () => {+ const state = makeCodexStreamState();+ const out = parseCodexLine(+ JSON.stringify({+ type: "item.completed",+ item: {+ type: "mcp_tool_call",+ id: "mcp_1",+ server: "notfair_demo__notfair_googleads",+ tool: "listAdAccounts",+ },+ }),+ state,+ );+ expect(out).toEqual([+ {+ kind: "tool",+ phase: "result",+ toolCallId: "mcp_1",+ name: "notfair_demo__notfair_googleads.listAdAccounts",+ },+ ]);+ });++ it("keeps the declared name when item.name is provided (real MCP tool call)", () => {+ const state = makeCodexStreamState();+ const out = parseCodexLine(+ JSON.stringify({+ type: "item.started",+ item: {+ type: "tool_call",+ id: "tc_1",+ name: "notfair_demo__notfair_googleads__listAdAccounts",+ arguments: { query: "active campaigns" },+ },+ }),+ state,+ );+ expect(out).toEqual([+ {+ kind: "tool",+ phase: "start",+ toolCallId: "tc_1",+ name: "notfair_demo__notfair_googleads__listAdAccounts",+ label: "active campaigns",+ },+ ]);+ });+it("emits a delta when an agent_message item completes", () => {const state = makeCodexStreamState();const out = parseCodexLine(diff --git a/notfair-cmo/src/server/adapters/codex-local/parse.ts b/notfair-cmo/src/server/adapters/codex-local/parse.tsindex 409afe3b..a2a59a58 100644--- a/notfair-cmo/src/server/adapters/codex-local/parse.ts+++ b/notfair-cmo/src/server/adapters/codex-local/parse.ts@@ -37,10 +37,33 @@ interface CodexEvent {id?: string;command?: string;arguments?: Record<string, unknown>;+ /**+ * Fields specific to `mcp_tool_call` items in codex 0.13x+. The+ * gateway invokes a registered MCP server's tool and emits the+ * server/tool pair separately from the generic `name` slot.+ */+ server?: string;+ tool?: string;+ tool_name?: string;};error?: { message?: string };}+/**+ * Item type ids codex emits for things we want to surface as "tool"+ * events in the UI. Centralized so the started/completed branches stay+ * in sync — historically they drifted, missing newer types like+ * `mcp_tool_call` (added in codex 0.132+) which left MCP invocations+ * silently invisible in the chat.+ */+const TOOLISH_ITEM_TYPES = new Set([+ "command_execution",+ "tool_call",+ "function_call",+ "mcp_tool_call",+ "mcp_call",+]);+export function parseCodexLine(line: string,state: CodexStreamState,@@ -67,10 +90,8 @@ export function parseCodexLine(if (event.type === "item.started" && event.item) {const item = event.item;- if (item.type === "command_execution" || item.type === "tool_call") {- const rawName = item.name ?? item.command ?? "tool";- // Keep name single-line; multi-line commands belong in the label.- const toolName = rawName.split("\n")[0];+ if (item.type && TOOLISH_ITEM_TYPES.has(item.type)) {+ const toolName = nameForToolishItem(item);events.push({kind: "tool",phase: "start",@@ -91,12 +112,12 @@ export function parseCodexLine(state.emittedTextLen = state.assistantText.length;events.push({ kind: "delta", text: delta });}- } else if (item.type === "command_execution" || item.type === "tool_call") {+ } else if (item.type && TOOLISH_ITEM_TYPES.has(item.type)) {events.push({kind: "tool",phase: "result",toolCallId: item.id ?? "",- name: item.name ?? item.command ?? "tool",+ name: nameForToolishItem(item),});}return events;@@ -125,6 +146,50 @@ export function parseCodexLine(return events;}+/**+ * Derive the canonical tool `name` field the UI will see for any codex+ * item type we route through as a tool event. The shape matters: the+ * chat client maps the name to (a) an icon, (b) a humanized verb,+ * (c) an MCP brand favicon. Conventions:+ *+ * - `mcp_tool_call` / `mcp_call` items get `<server>.<tool>` so the+ * UI's `<server>.<tool>` matcher resolves the server brand from+ * the project's MCP catalog. The codex namespace prefix+ * (`notfair_<projectSlug>__<serverName>`) is what `server` carries+ * — the matcher already strips the project prefix.+ * - Shell-style `command_execution` items lose their raw command from+ * the name (it would render as garbage in the UI) — name becomes+ * a stable `"shell"` token, and the command stays in the label.+ * - Generic `tool_call` / `function_call` items keep their declared+ * `name` so unknown function tools surface their real identifier.+ * - Items missing every signal degrade to `"tool"`.+ */+function nameForToolishItem(item: {+ type?: string;+ name?: string;+ command?: string;+ server?: string;+ tool?: string;+ tool_name?: string;+}): string {+ if (item.type === "mcp_tool_call" || item.type === "mcp_call") {+ const server = item.server ?? "";+ const tool = item.tool ?? item.tool_name ?? item.name ?? "tool";+ if (server) return `${server}.${tool}`;+ return tool;+ }+ if (item.type === "command_execution") {+ // Shell items expose only `command`; we want the chat UI to see a+ // stable `"shell"` slug rather than the raw command (which produces+ // garbage verbs like "Called md\"" after the tool-name humanizer+ // splits on dots in the command).+ return "shell";+ }+ // tool_call / function_call / fallthrough.+ const raw = item.name ?? item.tool ?? item.tool_name ?? (item.command ? "shell" : "tool");+ return raw.split("\n")[0]!;+}+function labelForCodexInput(name: string,item: { command?: string; arguments?: Record<string, unknown> },