Skip to content

Commit c80b4a6

Browse files
authored
100% test coverage of parseToolCallDetails 🚀 (#7818)
* WIP * parseToolCallDetails 100% coverage and remove unreachable code
1 parent 071a345 commit c80b4a6

File tree

3 files changed

+340
-13
lines changed

3 files changed

+340
-13
lines changed

‎common/sessionParsing.ts‎

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -192,15 +192,7 @@ export function parseToolCallDetails(
192192
const filePath = args.path;
193193
let fileLabel = filePath ? toFileLabel(filePath) : undefined;
194194

195-
if (fileLabel === undefined) {
196-
fileLabel = filePath;
197-
198-
return {
199-
toolName: fileLabel ? (`Read ${fileLabel}` + (parsedRange ? `, lines ${parsedRange.start} to ${parsedRange.end}` : '')) : 'Read repository',
200-
invocationMessage: fileLabel ? (`Read ${fileLabel}` + (parsedRange ? `, lines ${parsedRange.start} to ${parsedRange.end}` : '')) : 'Read repository',
201-
pastTenseMessage: fileLabel ? (`Read ${fileLabel}` + (parsedRange ? `, lines ${parsedRange.start} to ${parsedRange.end}` : '')) : 'Read repository',
202-
};
203-
} else if (fileLabel === '') {
195+
if (fileLabel === undefined || fileLabel === '') {
204196
return {
205197
toolName: 'Read repository',
206198
invocationMessage: 'Read repository',
@@ -250,7 +242,7 @@ export function parseToolCallDetails(
250242
filePath: filePath,
251243
fileLabel: fileLabel,
252244
} : undefined
253-
}
245+
};
254246
} else if (name === 'create') {
255247
const filePath = args.path;
256248
const fileLabel = filePath && toFileLabel(filePath);
@@ -264,7 +256,7 @@ export function parseToolCallDetails(
264256
filePath: filePath,
265257
fileLabel: fileLabel,
266258
} : undefined
267-
}
259+
};
268260
} else if (name === 'view') {
269261
const filePath = args.path;
270262
const fileLabel = filePath && toFileLabel(filePath);
@@ -319,12 +311,12 @@ export function parseToolCallDetails(
319311
return {
320312
toolName: 'read_bash',
321313
invocationMessage: 'Read logs from Bash session'
322-
}
314+
};
323315
} else if (name === 'stop_bash') {
324316
return {
325317
toolName: 'stop_bash',
326318
invocationMessage: 'Stop Bash session'
327-
}
319+
};
328320
} else {
329321
// Unknown tool type
330322
return {

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4179,6 +4179,7 @@
41794179
"clean": "rm -r dist/",
41804180
"compile": "webpack --mode development --env esbuild",
41814181
"compile:test": "tsc -p tsconfig.test.json",
4182+
"watch:test": "tsc -w -p tsconfig.test.json",
41824183
"compile:node": "webpack --mode development --config-name extension:node --config-name webviews",
41834184
"compile:web": "webpack --mode development --config-name extension:webworker --config-name webviews",
41844185
"lint": "eslint --fix --cache --config .eslintrc.js --ignore-pattern src/env/browser/**/* \"{src,webviews}/**/*.{ts,tsx}\"",

0 commit comments

Comments
 (0)