fix(native-chat): give the projected Diff row the file-change glyph

Every Codex fileChange item projects to a tool call named `Diff`, which the
edit set does not name — it names the tools that carry the edit in their own
input. So a run whose body renders an edited-file card was headed by the
generic wrench.
This commit is contained in:
Merge Sim
2026-09-05 01:46:17 -07:00
parent 7115f08397
commit 9b684266bb
3 changed files with 33 additions and 0 deletions
@@ -456,6 +456,29 @@ describe('NativeChatToolRun', () => {
).toEqual(['lucide-chevron-right'])
})
it('heads a projected diff run with the file-change glyph, not the generic one', () => {
const projected = projectStructuredItemToNativeChat({
itemId: 'file-change',
revision: 1,
sequence: 1,
observedAt: 1,
body: {
kind: 'diff',
path: 'src/a.ts',
patch: { head: '@@ -1 +1 @@\n-was\n+now', truncated: false, byteLength: 24 }
}
})
const { container } = render(
<NativeChatToolRun blocks={projected?.blocks ?? []} expandSignal={false} expandOverride />
)
// The run renders an edited-file card, so a wrench above it reads as a tool
// this vocabulary does not model.
expect(container.querySelector('.lucide-pencil')).toBeInTheDocument()
expect(container.querySelector('.lucide-wrench')).toBeNull()
})
it('labels a bare list row by the command it ran rather than an invented path', () => {
const blocks: NativeChatBlock[] = [
{
+7
View File
@@ -67,6 +67,13 @@ describe('native chat tool icons', () => {
}
})
it('reads the projected `Diff` row as a file change, which is what it renders', () => {
// Every Codex fileChange item projects to a call named `Diff`, so a wrench
// here headed a run whose body is an edited-file card.
expect(nativeChatToolCategory('Diff')).toBe('fileChange')
expect(nativeChatToolIconName('Diff')).toBe('pencil')
})
it('reads an MCP tool by its prefix, since the row is named after the tool', () => {
expect(nativeChatToolCategory('mcp__linear__create_issue')).toBe('mcpToolCall')
expect(nativeChatToolIconName('mcp__playwright__browser_click')).toBe('plug')
+3
View File
@@ -65,6 +65,9 @@ const CATEGORY_BY_ROW_WORD = new Map<string, NativeChatToolCategory>([
['read', 'read'],
['search', 'search'],
['list', 'listFiles'],
// Every Codex file change projects as a `Diff` call, and the edit set below
// names the tools that carry the edit in their input, not that projection.
['diff', 'fileChange'],
// Claude's tool names, which its lane renders verbatim.
['grep', 'search'],
['glob', 'search'],