Skip to content

Commit f799cc8

Browse files
authored
fix: Include read file path in tool title (#158)
1 parent 71d7889 commit f799cc8

3 files changed

Lines changed: 57 additions & 1 deletion

File tree

src/CodexToolCallMapper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ function createCommandActionEvent(
202202
toolCallId: id,
203203
status: acpStatus,
204204
kind: "read",
205-
title: "Read file",
205+
title: `Read file '${commandAction.path}'`,
206206
locations: [{ path: commandAction.path }],
207207
};
208208
} else if (commandAction.type === "search") {

src/__tests__/CodexACPAgent/command-action-events.test.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,42 @@ describe('CodexEventHandler - command action events', () => {
8989
);
9090
});
9191

92+
it('should include the path in read file command titles', async () => {
93+
const readFileNotification: ServerNotification = {
94+
method: 'item/started',
95+
params: {
96+
threadId: sessionId,
97+
turnId: 'turn-1',
98+
item: {
99+
type: 'commandExecution',
100+
id: 'command-read-file',
101+
command: 'sed -n "1,80p" /test/project/src/index.ts',
102+
cwd: '/test/project',
103+
processId: null,
104+
source: 'agent',
105+
status: 'inProgress',
106+
commandActions: [
107+
{
108+
type: 'read',
109+
command: 'sed -n "1,80p" /test/project/src/index.ts',
110+
name: 'sed',
111+
path: '/test/project/src/index.ts',
112+
},
113+
],
114+
aggregatedOutput: null,
115+
exitCode: null,
116+
durationMs: null,
117+
},
118+
},
119+
};
120+
121+
await setupPromptAndSendNotifications(mockFixture, sessionId, sessionState, [readFileNotification]);
122+
123+
await expect(mockFixture.getAcpConnectionDump([])).toMatchFileSnapshot(
124+
'data/command-read-file-with-path.json'
125+
);
126+
});
127+
92128
it('should handle search command with query and path', async () => {
93129
const searchNotification: ServerNotification = {
94130
method: 'item/started',
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"method": "sessionUpdate",
3+
"args": [
4+
{
5+
"sessionId": "test-session-id",
6+
"update": {
7+
"sessionUpdate": "tool_call",
8+
"toolCallId": "command-read-file",
9+
"status": "in_progress",
10+
"kind": "read",
11+
"title": "Read file '/test/project/src/index.ts'",
12+
"locations": [
13+
{
14+
"path": "/test/project/src/index.ts"
15+
}
16+
]
17+
}
18+
}
19+
]
20+
}

0 commit comments

Comments
 (0)