Skip to content

Commit ca85162

Browse files
authored
Handle partial messages in the codebase search tool (#3934)
1 parent c357daf commit ca85162

File tree

19 files changed

+77
-66
lines changed

19 files changed

+77
-66
lines changed

src/core/tools/codebaseSearchTool.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,32 @@ export async function codebaseSearchTool(
2929
let query: string | undefined = block.params.query
3030
let directoryPrefix: string | undefined = block.params.path
3131

32-
if (!query) {
33-
cline.consecutiveMistakeCount++
34-
pushToolResult(await cline.sayAndCreateMissingParamError(toolName, "query"))
35-
return
36-
}
3732
query = removeClosingTag("query", query)
3833

3934
if (directoryPrefix) {
4035
directoryPrefix = removeClosingTag("path", directoryPrefix)
4136
directoryPrefix = path.normalize(directoryPrefix)
4237
}
4338

44-
// Extract optional sendResultsToUI parameter
45-
46-
const approvalPayload = {
39+
const sharedMessageProps = {
4740
tool: "codebaseSearch",
4841
query: query,
4942
path: directoryPrefix,
5043
isOutsideWorkspace: false,
5144
}
5245

53-
const didApprove = await askApproval("tool", JSON.stringify(approvalPayload))
46+
if (block.partial) {
47+
await cline.ask("tool", JSON.stringify(sharedMessageProps), block.partial).catch(() => {})
48+
return
49+
}
50+
51+
if (!query) {
52+
cline.consecutiveMistakeCount++
53+
pushToolResult(await cline.sayAndCreateMissingParamError(toolName, "query"))
54+
return
55+
}
56+
57+
const didApprove = await askApproval("tool", JSON.stringify(sharedMessageProps))
5458
if (!didApprove) {
5559
pushToolResult(formatResponse.toolDenied())
5660
return

webview-ui/src/components/chat/ChatRow.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -357,12 +357,19 @@ export const ChatRowContent = ({
357357
<div style={headerStyle}>
358358
{toolIcon("search")}
359359
<span style={{ fontWeight: "bold" }}>
360-
{tool.path
361-
? t("chat:codebaseSearch.wantsToSearchWithPath", {
362-
query: tool.query,
363-
path: tool.path,
364-
})
365-
: t("chat:codebaseSearch.wantsToSearch", { query: tool.query })}
360+
{tool.path ? (
361+
<Trans
362+
i18nKey="chat:codebaseSearch.wantsToSearchWithPath"
363+
components={{ code: <code></code> }}
364+
values={{ query: tool.query, path: tool.path }}
365+
/>
366+
) : (
367+
<Trans
368+
i18nKey="chat:codebaseSearch.wantsToSearch"
369+
components={{ code: <code></code> }}
370+
values={{ query: tool.query }}
371+
/>
372+
)}
366373
</span>
367374
</div>
368375
)

webview-ui/src/i18n/locales/ca/chat.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@
262262
}
263263
},
264264
"codebaseSearch": {
265-
"wantsToSearch": "Roo vol cercar a la base de codi '{{query}}':",
266-
"wantsToSearchWithPath": "Roo vol cercar a la base de codi '{{query}}' a '{{path}}':",
267-
"didSearch": "S'han trobat {{count}} resultat(s) per a '{{query}}':"
265+
"wantsToSearch": "Roo vol cercar a la base de codi <code>{{query}}</code>:",
266+
"wantsToSearchWithPath": "Roo vol cercar a la base de codi <code>{{query}}</code> a <code>{{path}}</code>:",
267+
"didSearch": "S'han trobat {{count}} resultat(s) per a <code>{{query}}</code>:"
268268
}
269269
}

webview-ui/src/i18n/locales/de/chat.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@
262262
}
263263
},
264264
"codebaseSearch": {
265-
"wantsToSearch": "Roo möchte den Codebase nach '{{query}}' durchsuchen:",
266-
"wantsToSearchWithPath": "Roo möchte den Codebase nach '{{query}}' in '{{path}}' durchsuchen:",
267-
"didSearch": "{{count}} Ergebnis(se) für '{{query}}' gefunden:"
265+
"wantsToSearch": "Roo möchte den Codebase nach <code>{{query}}</code> durchsuchen:",
266+
"wantsToSearchWithPath": "Roo möchte den Codebase nach <code>{{query}}</code> in <code>{{path}}</code> durchsuchen:",
267+
"didSearch": "{{count}} Ergebnis(se) für <code>{{query}}</code> gefunden:"
268268
}
269269
}

webview-ui/src/i18n/locales/en/chat.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@
162162
"didSearch": "Roo searched this directory for <code>{{regex}}</code>:"
163163
},
164164
"codebaseSearch": {
165-
"wantsToSearch": "Roo wants to search the codebase for '{{query}}':",
166-
"wantsToSearchWithPath": "Roo wants to search the codebase for '{{query}}' in '{{path}}':",
167-
"didSearch": "Found {{count}} result(s) for '{{query}}':"
165+
"wantsToSearch": "Roo wants to search the codebase for <code>{{query}}</code>:",
166+
"wantsToSearchWithPath": "Roo wants to search the codebase for <code>{{query}}</code> in <code>{{path}}</code>:",
167+
"didSearch": "Found {{count}} result(s) for <code>{{query}}</code>:"
168168
},
169169
"commandOutput": "Command Output",
170170
"response": "Response",

webview-ui/src/i18n/locales/es/chat.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@
262262
}
263263
},
264264
"codebaseSearch": {
265-
"wantsToSearch": "Roo quiere buscar en la base de código '{{query}}':",
266-
"wantsToSearchWithPath": "Roo quiere buscar en la base de código '{{query}}' en '{{path}}':",
267-
"didSearch": "Se encontraron {{count}} resultado(s) para '{{query}}':"
265+
"wantsToSearch": "Roo quiere buscar en la base de código <code>{{query}}</code>:",
266+
"wantsToSearchWithPath": "Roo quiere buscar en la base de código <code>{{query}}</code> en <code>{{path}}</code>:",
267+
"didSearch": "Se encontraron {{count}} resultado(s) para <code>{{query}}</code>:"
268268
}
269269
}

webview-ui/src/i18n/locales/fr/chat.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@
262262
}
263263
},
264264
"codebaseSearch": {
265-
"wantsToSearch": "Roo veut rechercher dans la base de code '{{query}}' :",
266-
"wantsToSearchWithPath": "Roo veut rechercher dans la base de code '{{query}}' dans '{{path}}' :",
267-
"didSearch": "{{count}} résultat(s) trouvé(s) pour '{{query}}' :"
265+
"wantsToSearch": "Roo veut rechercher dans la base de code <code>{{query}}</code> :",
266+
"wantsToSearchWithPath": "Roo veut rechercher dans la base de code <code>{{query}}</code> dans <code>{{path}}</code> :",
267+
"didSearch": "{{count}} résultat(s) trouvé(s) pour <code>{{query}}</code> :"
268268
}
269269
}

webview-ui/src/i18n/locales/hi/chat.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@
262262
}
263263
},
264264
"codebaseSearch": {
265-
"wantsToSearch": "Roo कोडबेस में '{{query}}' खोजना चाहता है:",
266-
"wantsToSearchWithPath": "Roo '{{path}}' में कोडबेस में '{{query}}' खोजना चाहता है:",
267-
"didSearch": "'{{query}}' के लिए {{count}} परिणाम मिले:"
265+
"wantsToSearch": "Roo कोडबेस में <code>{{query}}</code> खोजना चाहता है:",
266+
"wantsToSearchWithPath": "Roo <code>{{path}}</code> में कोडबेस में <code>{{query}}</code> खोजना चाहता है:",
267+
"didSearch": "<code>{{query}}</code> के लिए {{count}} परिणाम मिले:"
268268
}
269269
}

webview-ui/src/i18n/locales/it/chat.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@
262262
}
263263
},
264264
"codebaseSearch": {
265-
"wantsToSearch": "Roo vuole cercare nella base di codice '{{query}}':",
266-
"wantsToSearchWithPath": "Roo vuole cercare nella base di codice '{{query}}' in '{{path}}':",
267-
"didSearch": "Trovato {{count}} risultato/i per '{{query}}':"
265+
"wantsToSearch": "Roo vuole cercare nella base di codice <code>{{query}}</code>:",
266+
"wantsToSearchWithPath": "Roo vuole cercare nella base di codice <code>{{query}}</code> in <code>{{path}}</code>:",
267+
"didSearch": "Trovato {{count}} risultato/i per <code>{{query}}</code>:"
268268
}
269269
}

webview-ui/src/i18n/locales/ja/chat.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@
262262
}
263263
},
264264
"codebaseSearch": {
265-
"wantsToSearch": "Rooはコードベースで '{{query}}' を検索したい:",
266-
"wantsToSearchWithPath": "Rooは '{{path}}' 内のコードベースで '{{query}}' を検索したい:",
267-
"didSearch": "'{{query}}' の検索結果: {{count}} 件"
265+
"wantsToSearch": "Rooはコードベースで <code>{{query}}</code> を検索したい:",
266+
"wantsToSearchWithPath": "Rooは <code>{{path}}</code> 内のコードベースで <code>{{query}}</code> を検索したい:",
267+
"didSearch": "<code>{{query}}</code> の検索結果: {{count}} 件"
268268
}
269269
}

0 commit comments

Comments
 (0)