Browse Source

Improve the display of codebase search results (#5571)

Matt Rubens 6 months ago
parent
commit
6fa918c275

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

@@ -1166,9 +1166,9 @@ export const ChatRowContent = ({
 						return <div>Error displaying search results.</div>
 					}
 
-					const { query = "", results = [] } = parsed?.content || {}
+					const { results = [] } = parsed?.content || {}
 
-					return <CodebaseSearchResultsDisplay query={query} results={results} />
+					return <CodebaseSearchResultsDisplay results={results} />
 				case "user_edit_todos":
 					return <UpdateTodoListToolBlock userEdited onChange={() => {}} />
 				default:

+ 3 - 3
webview-ui/src/components/chat/CodebaseSearchResult.tsx

@@ -30,15 +30,15 @@ const CodebaseSearchResult: React.FC<CodebaseSearchResultProps> = ({ filePath, s
 		<StandardTooltip content={t("codebaseSearch.resultTooltip", { score: score.toFixed(3) })}>
 			<div
 				onClick={handleClick}
-				className="mb-1 p-2 border border-primary rounded cursor-pointer hover:bg-secondary hover:text-white">
+				className="p-2 border border-[var(--vscode-editorGroup-border)] cursor-pointer hover:bg-secondary hover:text-white">
 				<div className="flex gap-2 items-center overflow-hidden">
 					<span className="text-primary-300 whitespace-nowrap flex-shrink-0">
-						{filePath.split("/").at(-1)}:{startLine}-{endLine}
+						{filePath.split("/").at(-1)}:{startLine === endLine ? startLine : `${startLine}-${endLine}`}
 					</span>
 					<span className="text-gray-500 truncate min-w-0 flex-1">
 						{filePath.split("/").slice(0, -1).join("/")}
 					</span>
-					<span className="text-xs text-vscode-descriptionForeground bg-vscode-badge-background px-2 py-1 rounded whitespace-nowrap ml-auto">
+					<span className="text-xs text-vscode-descriptionForeground whitespace-nowrap ml-auto opacity-60">
 						{score.toFixed(3)}
 					</span>
 				</div>

+ 6 - 7
webview-ui/src/components/chat/CodebaseSearchResultsDisplay.tsx

@@ -3,7 +3,6 @@ import CodebaseSearchResult from "./CodebaseSearchResult"
 import { Trans } from "react-i18next"
 
 interface CodebaseSearchResultsDisplayProps {
-	query: string
 	results: Array<{
 		filePath: string
 		score: number
@@ -13,26 +12,26 @@ interface CodebaseSearchResultsDisplayProps {
 	}>
 }
 
-const CodebaseSearchResultsDisplay: React.FC<CodebaseSearchResultsDisplayProps> = ({ query, results }) => {
+const CodebaseSearchResultsDisplay: React.FC<CodebaseSearchResultsDisplayProps> = ({ results }) => {
 	const [codebaseSearchResultsExpanded, setCodebaseSearchResultsExpanded] = useState(false)
 
 	return (
-		<div className="flex flex-col gap-2">
+		<div className="flex flex-col -mt-4 gap-1">
 			<div
 				onClick={() => setCodebaseSearchResultsExpanded(!codebaseSearchResultsExpanded)}
-				className="font-bold cursor-pointer flex items-center justify-between px-2 py-2 rounded border bg-[var(--vscode-editor-background)] border-[var(--vscode-editorGroup-border)]">
+				className="cursor-pointer flex items-center justify-between px-2 py-2 border bg-[var(--vscode-editor-background)] border-[var(--vscode-editorGroup-border)]">
 				<span>
 					<Trans
 						i18nKey="chat:codebaseSearch.didSearch"
-						components={{ code: <code></code> }}
-						values={{ query, count: results.length }}
+						count={results.length}
+						values={{ count: results.length }}
 					/>
 				</span>
 				<span className={`codicon codicon-chevron-${codebaseSearchResultsExpanded ? "up" : "down"}`}></span>
 			</div>
 
 			{codebaseSearchResultsExpanded && (
-				<div className="flex flex-col gap-2">
+				<div className="flex flex-col gap-1">
 					{results.map((result, idx) => (
 						<CodebaseSearchResult
 							key={idx}

+ 2 - 1
webview-ui/src/i18n/locales/ca/chat.json

@@ -297,7 +297,8 @@
 	"codebaseSearch": {
 		"wantsToSearch": "Roo vol cercar a la base de codi <code>{{query}}</code>:",
 		"wantsToSearchWithPath": "Roo vol cercar a la base de codi <code>{{query}}</code> a <code>{{path}}</code>:",
-		"didSearch": "S'han trobat {{count}} resultat(s) per a <code>{{query}}</code>:",
+		"didSearch_one": "S'ha trobat 1 resultat",
+		"didSearch_other": "S'han trobat {{count}} resultats",
 		"resultTooltip": "Puntuació de similitud: {{score}} (fes clic per obrir el fitxer)"
 	},
 	"read-batch": {

+ 2 - 1
webview-ui/src/i18n/locales/de/chat.json

@@ -297,7 +297,8 @@
 	"codebaseSearch": {
 		"wantsToSearch": "Roo möchte den Codebase nach <code>{{query}}</code> durchsuchen:",
 		"wantsToSearchWithPath": "Roo möchte den Codebase nach <code>{{query}}</code> in <code>{{path}}</code> durchsuchen:",
-		"didSearch": "{{count}} Ergebnis(se) für <code>{{query}}</code> gefunden:",
+		"didSearch_one": "1 Ergebnis gefunden",
+		"didSearch_other": "{{count}} Ergebnisse gefunden",
 		"resultTooltip": "Ähnlichkeitswert: {{score}} (klicken zum Öffnen der Datei)"
 	},
 	"read-batch": {

+ 2 - 1
webview-ui/src/i18n/locales/en/chat.json

@@ -202,7 +202,8 @@
 	"codebaseSearch": {
 		"wantsToSearch": "Roo wants to search the codebase for <code>{{query}}</code>:",
 		"wantsToSearchWithPath": "Roo wants to search the codebase for <code>{{query}}</code> in <code>{{path}}</code>:",
-		"didSearch": "Found {{count}} result(s) for <code>{{query}}</code>:",
+		"didSearch_one": "Found 1 result",
+		"didSearch_other": "Found {{count}} results",
 		"resultTooltip": "Similarity score: {{score}} (click to open file)"
 	},
 	"commandOutput": "Command Output",

+ 2 - 1
webview-ui/src/i18n/locales/es/chat.json

@@ -297,7 +297,8 @@
 	"codebaseSearch": {
 		"wantsToSearch": "Roo quiere buscar en la base de código <code>{{query}}</code>:",
 		"wantsToSearchWithPath": "Roo quiere buscar en la base de código <code>{{query}}</code> en <code>{{path}}</code>:",
-		"didSearch": "Se encontraron {{count}} resultado(s) para <code>{{query}}</code>:",
+		"didSearch_one": "Se encontró 1 resultado",
+		"didSearch_other": "Se encontraron {{count}} resultados",
 		"resultTooltip": "Puntuación de similitud: {{score}} (haz clic para abrir el archivo)"
 	},
 	"read-batch": {

+ 2 - 1
webview-ui/src/i18n/locales/fr/chat.json

@@ -297,7 +297,8 @@
 	"codebaseSearch": {
 		"wantsToSearch": "Roo veut rechercher dans la base de code <code>{{query}}</code> :",
 		"wantsToSearchWithPath": "Roo veut rechercher dans la base de code <code>{{query}}</code> dans <code>{{path}}</code> :",
-		"didSearch": "{{count}} résultat(s) trouvé(s) pour <code>{{query}}</code> :",
+		"didSearch_one": "1 résultat trouvé",
+		"didSearch_other": "{{count}} résultats trouvés",
 		"resultTooltip": "Score de similarité : {{score}} (cliquer pour ouvrir le fichier)"
 	},
 	"read-batch": {

+ 2 - 1
webview-ui/src/i18n/locales/hi/chat.json

@@ -297,7 +297,8 @@
 	"codebaseSearch": {
 		"wantsToSearch": "Roo कोडबेस में <code>{{query}}</code> खोजना चाहता है:",
 		"wantsToSearchWithPath": "Roo <code>{{path}}</code> में कोडबेस में <code>{{query}}</code> खोजना चाहता है:",
-		"didSearch": "<code>{{query}}</code> के लिए {{count}} परिणाम मिले:",
+		"didSearch_one": "1 परिणाम मिला",
+		"didSearch_other": "{{count}} परिणाम मिले",
 		"resultTooltip": "समानता स्कोर: {{score}} (फ़ाइल खोलने के लिए क्लिक करें)"
 	},
 	"read-batch": {

+ 2 - 1
webview-ui/src/i18n/locales/id/chat.json

@@ -208,7 +208,8 @@
 	"codebaseSearch": {
 		"wantsToSearch": "Roo ingin mencari codebase untuk <code>{{query}}</code>:",
 		"wantsToSearchWithPath": "Roo ingin mencari codebase untuk <code>{{query}}</code> di <code>{{path}}</code>:",
-		"didSearch": "Ditemukan {{count}} hasil untuk <code>{{query}}</code>:",
+		"didSearch_one": "Ditemukan 1 hasil",
+		"didSearch_other": "Ditemukan {{count}} hasil",
 		"resultTooltip": "Skor kemiripan: {{score}} (klik untuk membuka file)"
 	},
 	"commandOutput": "Output Perintah",

+ 2 - 1
webview-ui/src/i18n/locales/it/chat.json

@@ -297,7 +297,8 @@
 	"codebaseSearch": {
 		"wantsToSearch": "Roo vuole cercare nella base di codice <code>{{query}}</code>:",
 		"wantsToSearchWithPath": "Roo vuole cercare nella base di codice <code>{{query}}</code> in <code>{{path}}</code>:",
-		"didSearch": "Trovato {{count}} risultato/i per <code>{{query}}</code>:",
+		"didSearch_one": "Trovato 1 risultato",
+		"didSearch_other": "Trovati {{count}} risultati",
 		"resultTooltip": "Punteggio di somiglianza: {{score}} (clicca per aprire il file)"
 	},
 	"read-batch": {

+ 2 - 1
webview-ui/src/i18n/locales/ja/chat.json

@@ -297,7 +297,8 @@
 	"codebaseSearch": {
 		"wantsToSearch": "Rooはコードベースで <code>{{query}}</code> を検索したい:",
 		"wantsToSearchWithPath": "Rooは <code>{{path}}</code> 内のコードベースで <code>{{query}}</code> を検索したい:",
-		"didSearch": "<code>{{query}}</code> の検索結果: {{count}} 件",
+		"didSearch_one": "1件の結果が見つかりました",
+		"didSearch_other": "{{count}}件の結果が見つかりました",
 		"resultTooltip": "類似度スコア: {{score}} (クリックしてファイルを開く)"
 	},
 	"read-batch": {

+ 2 - 1
webview-ui/src/i18n/locales/ko/chat.json

@@ -297,7 +297,8 @@
 	"codebaseSearch": {
 		"wantsToSearch": "Roo가 코드베이스에서 <code>{{query}}</code>을(를) 검색하고 싶어합니다:",
 		"wantsToSearchWithPath": "Roo가 <code>{{path}}</code>에서 <code>{{query}}</code>을(를) 검색하고 싶어합니다:",
-		"didSearch": "<code>{{query}}</code>에 대한 검색 결과 {{count}}개 찾음:",
+		"didSearch_one": "1개의 결과를 찾았습니다",
+		"didSearch_other": "{{count}}개의 결과를 찾았습니다",
 		"resultTooltip": "유사도 점수: {{score}} (클릭하여 파일 열기)"
 	},
 	"read-batch": {

+ 2 - 1
webview-ui/src/i18n/locales/nl/chat.json

@@ -297,7 +297,8 @@
 	"codebaseSearch": {
 		"wantsToSearch": "Roo wil de codebase doorzoeken op <code>{{query}}</code>:",
 		"wantsToSearchWithPath": "Roo wil de codebase doorzoeken op <code>{{query}}</code> in <code>{{path}}</code>:",
-		"didSearch": "{{count}} resultaat/resultaten gevonden voor <code>{{query}}</code>:",
+		"didSearch_one": "1 resultaat gevonden",
+		"didSearch_other": "{{count}} resultaten gevonden",
 		"resultTooltip": "Gelijkenisscore: {{score}} (klik om bestand te openen)"
 	},
 	"read-batch": {

+ 2 - 1
webview-ui/src/i18n/locales/pl/chat.json

@@ -297,7 +297,8 @@
 	"codebaseSearch": {
 		"wantsToSearch": "Roo chce przeszukać bazę kodu w poszukiwaniu <code>{{query}}</code>:",
 		"wantsToSearchWithPath": "Roo chce przeszukać bazę kodu w poszukiwaniu <code>{{query}}</code> w <code>{{path}}</code>:",
-		"didSearch": "Znaleziono {{count}} wynik(ów) dla <code>{{query}}</code>:",
+		"didSearch_one": "Znaleziono 1 wynik",
+		"didSearch_other": "Znaleziono {{count}} wyników",
 		"resultTooltip": "Wynik podobieństwa: {{score}} (kliknij, aby otworzyć plik)"
 	},
 	"read-batch": {

+ 2 - 1
webview-ui/src/i18n/locales/pt-BR/chat.json

@@ -297,7 +297,8 @@
 	"codebaseSearch": {
 		"wantsToSearch": "Roo quer pesquisar na base de código por <code>{{query}}</code>:",
 		"wantsToSearchWithPath": "Roo quer pesquisar na base de código por <code>{{query}}</code> em <code>{{path}}</code>:",
-		"didSearch": "Encontrado {{count}} resultado(s) para <code>{{query}}</code>:",
+		"didSearch_one": "Encontrado 1 resultado",
+		"didSearch_other": "Encontrados {{count}} resultados",
 		"resultTooltip": "Pontuação de similaridade: {{score}} (clique para abrir o arquivo)"
 	},
 	"read-batch": {

+ 2 - 1
webview-ui/src/i18n/locales/ru/chat.json

@@ -297,7 +297,8 @@
 	"codebaseSearch": {
 		"wantsToSearch": "Roo хочет выполнить поиск в кодовой базе по <code>{{query}}</code>:",
 		"wantsToSearchWithPath": "Roo хочет выполнить поиск в кодовой базе по <code>{{query}}</code> в <code>{{path}}</code>:",
-		"didSearch": "Найдено {{count}} результат(ов) для <code>{{query}}</code>:",
+		"didSearch_one": "Найден 1 результат",
+		"didSearch_other": "Найдено {{count}} результатов",
 		"resultTooltip": "Оценка схожести: {{score}} (нажмите, чтобы открыть файл)"
 	},
 	"read-batch": {

+ 2 - 1
webview-ui/src/i18n/locales/tr/chat.json

@@ -297,7 +297,8 @@
 	"codebaseSearch": {
 		"wantsToSearch": "Roo kod tabanında <code>{{query}}</code> aramak istiyor:",
 		"wantsToSearchWithPath": "Roo <code>{{path}}</code> içinde kod tabanında <code>{{query}}</code> aramak istiyor:",
-		"didSearch": "<code>{{query}}</code> için {{count}} sonuç bulundu:",
+		"didSearch_one": "1 sonuç bulundu",
+		"didSearch_other": "{{count}} sonuç bulundu",
 		"resultTooltip": "Benzerlik puanı: {{score}} (dosyayı açmak için tıklayın)"
 	},
 	"read-batch": {

+ 2 - 1
webview-ui/src/i18n/locales/vi/chat.json

@@ -297,7 +297,8 @@
 	"codebaseSearch": {
 		"wantsToSearch": "Roo muốn tìm kiếm trong cơ sở mã cho <code>{{query}}</code>:",
 		"wantsToSearchWithPath": "Roo muốn tìm kiếm trong cơ sở mã cho <code>{{query}}</code> trong <code>{{path}}</code>:",
-		"didSearch": "Đã tìm thấy {{count}} kết quả cho <code>{{query}}</code>:",
+		"didSearch_one": "Đã tìm thấy 1 kết quả",
+		"didSearch_other": "Đã tìm thấy {{count}} kết quả",
 		"resultTooltip": "Điểm tương tự: {{score}} (nhấp để mở tệp)"
 	},
 	"read-batch": {

+ 2 - 1
webview-ui/src/i18n/locales/zh-CN/chat.json

@@ -297,7 +297,8 @@
 	"codebaseSearch": {
 		"wantsToSearch": "Roo 需要搜索代码库: <code>{{query}}</code>",
 		"wantsToSearchWithPath": "Roo 需要在 <code>{{path}}</code> 中搜索: <code>{{query}}</code>",
-		"didSearch": "找到 {{count}} 个结果: <code>{{query}}</code>",
+		"didSearch_one": "找到 1 个结果",
+		"didSearch_other": "找到 {{count}} 个结果",
 		"resultTooltip": "相似度评分: {{score}} (点击打开文件)"
 	},
 	"read-batch": {

+ 2 - 1
webview-ui/src/i18n/locales/zh-TW/chat.json

@@ -297,7 +297,8 @@
 	"codebaseSearch": {
 		"wantsToSearch": "Roo 想要搜尋程式碼庫:<code>{{query}}</code>",
 		"wantsToSearchWithPath": "Roo 想要在 <code>{{path}}</code> 中搜尋:<code>{{query}}</code>",
-		"didSearch": "找到 {{count}} 個結果:<code>{{query}}</code>",
+		"didSearch_one": "找到 1 個結果",
+		"didSearch_other": "找到 {{count}} 個結果",
 		"resultTooltip": "相似度評分:{{score}} (點擊開啟檔案)"
 	},
 	"read-batch": {