From 9bb50eaba37475b679634c51c973b6098f78be3e Mon Sep 17 00:00:00 2001 From: Matt Rubens Date: Sat, 29 Mar 2025 02:14:18 -0400 Subject: [PATCH] Display info about partial reads in chat row (#2080) --- src/core/tools/readFileTool.ts | 22 +++++++++++++++++++--- src/i18n/locales/ca/tools.json | 9 +++++++++ src/i18n/locales/de/tools.json | 9 +++++++++ src/i18n/locales/en/tools.json | 9 +++++++++ src/i18n/locales/es/tools.json | 9 +++++++++ src/i18n/locales/fr/tools.json | 9 +++++++++ src/i18n/locales/hi/tools.json | 9 +++++++++ src/i18n/locales/it/tools.json | 9 +++++++++ src/i18n/locales/ja/tools.json | 9 +++++++++ src/i18n/locales/ko/tools.json | 9 +++++++++ src/i18n/locales/pl/tools.json | 9 +++++++++ src/i18n/locales/pt-BR/tools.json | 9 +++++++++ src/i18n/locales/tr/tools.json | 9 +++++++++ src/i18n/locales/vi/tools.json | 9 +++++++++ src/i18n/locales/zh-CN/tools.json | 9 +++++++++ src/i18n/locales/zh-TW/tools.json | 9 +++++++++ webview-ui/src/components/chat/ChatRow.tsx | 1 + 17 files changed, 155 insertions(+), 3 deletions(-) create mode 100644 src/i18n/locales/ca/tools.json create mode 100644 src/i18n/locales/de/tools.json create mode 100644 src/i18n/locales/en/tools.json create mode 100644 src/i18n/locales/es/tools.json create mode 100644 src/i18n/locales/fr/tools.json create mode 100644 src/i18n/locales/hi/tools.json create mode 100644 src/i18n/locales/it/tools.json create mode 100644 src/i18n/locales/ja/tools.json create mode 100644 src/i18n/locales/ko/tools.json create mode 100644 src/i18n/locales/pl/tools.json create mode 100644 src/i18n/locales/pt-BR/tools.json create mode 100644 src/i18n/locales/tr/tools.json create mode 100644 src/i18n/locales/vi/tools.json create mode 100644 src/i18n/locales/zh-CN/tools.json create mode 100644 src/i18n/locales/zh-TW/tools.json diff --git a/src/core/tools/readFileTool.ts b/src/core/tools/readFileTool.ts index 6616a5fcd1..315f178e32 100644 --- a/src/core/tools/readFileTool.ts +++ b/src/core/tools/readFileTool.ts @@ -3,6 +3,7 @@ import { Cline } from "../Cline" import { ClineSayTool } from "../../shared/ExtensionMessage" import { ToolUse } from "../assistant-message" import { formatResponse } from "../prompts/responses" +import { t } from "../../i18n" import { AskApproval, HandleError, PushToolResult, RemoveClosingTag } from "./types" import { isPathOutsideWorkspace } from "../../utils/pathUtils" import { getReadablePath } from "../../utils/path" @@ -97,11 +98,29 @@ export async function readFileTool( break } + const { maxReadFileLine = 500 } = (await cline.providerRef.deref()?.getState()) ?? {} + + // Create line snippet description for approval message + let lineSnippet = "" + if (startLine !== undefined && endLine !== undefined) { + lineSnippet = t("tools:readFile.linesRange", { start: startLine + 1, end: endLine + 1 }) + } else if (startLine !== undefined) { + lineSnippet = t("tools:readFile.linesFromToEnd", { start: startLine + 1 }) + } else if (endLine !== undefined) { + lineSnippet = t("tools:readFile.linesFromStartTo", { end: endLine + 1 }) + } else if (maxReadFileLine === 0) { + lineSnippet = t("tools:readFile.definitionsOnly") + } else if (maxReadFileLine > 0) { + lineSnippet = t("tools:readFile.maxLines", { max: maxReadFileLine }) + } + cline.consecutiveMistakeCount = 0 const absolutePath = path.resolve(cline.cwd, relPath) + const completeMessage = JSON.stringify({ ...sharedMessageProps, content: absolutePath, + reason: lineSnippet, } satisfies ClineSayTool) const didApprove = await askApproval("tool", completeMessage) @@ -109,9 +128,6 @@ export async function readFileTool( break } - // Get the maxReadFileLine setting - const { maxReadFileLine = 500 } = (await cline.providerRef.deref()?.getState()) ?? {} - // Count total lines in the file let totalLines = 0 try { diff --git a/src/i18n/locales/ca/tools.json b/src/i18n/locales/ca/tools.json new file mode 100644 index 0000000000..14e7e43880 --- /dev/null +++ b/src/i18n/locales/ca/tools.json @@ -0,0 +1,9 @@ +{ + "readFile": { + "linesRange": " (línies {{start}}-{{end}})", + "linesFromToEnd": " (línies {{start}}-final)", + "linesFromStartTo": " (línies 1-{{end}})", + "definitionsOnly": " (només definicions)", + "maxLines": " (màxim {{max}} línies)" + } +} diff --git a/src/i18n/locales/de/tools.json b/src/i18n/locales/de/tools.json new file mode 100644 index 0000000000..f1b7d85032 --- /dev/null +++ b/src/i18n/locales/de/tools.json @@ -0,0 +1,9 @@ +{ + "readFile": { + "linesRange": " (Zeilen {{start}}-{{end}})", + "linesFromToEnd": " (Zeilen {{start}}-Ende)", + "linesFromStartTo": " (Zeilen 1-{{end}})", + "definitionsOnly": " (nur Definitionen)", + "maxLines": " (maximal {{max}} Zeilen)" + } +} diff --git a/src/i18n/locales/en/tools.json b/src/i18n/locales/en/tools.json new file mode 100644 index 0000000000..bb258961ba --- /dev/null +++ b/src/i18n/locales/en/tools.json @@ -0,0 +1,9 @@ +{ + "readFile": { + "linesRange": " (lines {{start}}-{{end}})", + "linesFromToEnd": " (lines {{start}}-end)", + "linesFromStartTo": " (lines 1-{{end}})", + "definitionsOnly": " (definitions only)", + "maxLines": " (max {{max}} lines)" + } +} diff --git a/src/i18n/locales/es/tools.json b/src/i18n/locales/es/tools.json new file mode 100644 index 0000000000..f6e4389206 --- /dev/null +++ b/src/i18n/locales/es/tools.json @@ -0,0 +1,9 @@ +{ + "readFile": { + "linesRange": " (líneas {{start}}-{{end}})", + "linesFromToEnd": " (líneas {{start}}-final)", + "linesFromStartTo": " (líneas 1-{{end}})", + "definitionsOnly": " (solo definiciones)", + "maxLines": " (máximo {{max}} líneas)" + } +} diff --git a/src/i18n/locales/fr/tools.json b/src/i18n/locales/fr/tools.json new file mode 100644 index 0000000000..97a640a18f --- /dev/null +++ b/src/i18n/locales/fr/tools.json @@ -0,0 +1,9 @@ +{ + "readFile": { + "linesRange": " (lignes {{start}}-{{end}})", + "linesFromToEnd": " (lignes {{start}}-fin)", + "linesFromStartTo": " (lignes 1-{{end}})", + "definitionsOnly": " (définitions uniquement)", + "maxLines": " (max {{max}} lignes)" + } +} diff --git a/src/i18n/locales/hi/tools.json b/src/i18n/locales/hi/tools.json new file mode 100644 index 0000000000..7f682391f4 --- /dev/null +++ b/src/i18n/locales/hi/tools.json @@ -0,0 +1,9 @@ +{ + "readFile": { + "linesRange": " (पंक्तियाँ {{start}}-{{end}})", + "linesFromToEnd": " (पंक्तियाँ {{start}}-अंत)", + "linesFromStartTo": " (पंक्तियाँ 1-{{end}})", + "definitionsOnly": " (केवल परिभाषाएँ)", + "maxLines": " (अधिकतम {{max}} पंक्तियाँ)" + } +} diff --git a/src/i18n/locales/it/tools.json b/src/i18n/locales/it/tools.json new file mode 100644 index 0000000000..a9ad538e9d --- /dev/null +++ b/src/i18n/locales/it/tools.json @@ -0,0 +1,9 @@ +{ + "readFile": { + "linesRange": " (righe {{start}}-{{end}})", + "linesFromToEnd": " (righe {{start}}-fine)", + "linesFromStartTo": " (righe 1-{{end}})", + "definitionsOnly": " (solo definizioni)", + "maxLines": " (max {{max}} righe)" + } +} diff --git a/src/i18n/locales/ja/tools.json b/src/i18n/locales/ja/tools.json new file mode 100644 index 0000000000..6daed74793 --- /dev/null +++ b/src/i18n/locales/ja/tools.json @@ -0,0 +1,9 @@ +{ + "readFile": { + "linesRange": " ({{start}}-{{end}}行目)", + "linesFromToEnd": " ({{start}}行目-最後まで)", + "linesFromStartTo": " (1-{{end}}行目)", + "definitionsOnly": " (定義のみ)", + "maxLines": " (最大{{max}}行)" + } +} diff --git a/src/i18n/locales/ko/tools.json b/src/i18n/locales/ko/tools.json new file mode 100644 index 0000000000..f4583d2d06 --- /dev/null +++ b/src/i18n/locales/ko/tools.json @@ -0,0 +1,9 @@ +{ + "readFile": { + "linesRange": " ({{start}}-{{end}}행)", + "linesFromToEnd": " ({{start}}행-끝)", + "linesFromStartTo": " (1-{{end}}행)", + "definitionsOnly": " (정의만)", + "maxLines": " (최대 {{max}}행)" + } +} diff --git a/src/i18n/locales/pl/tools.json b/src/i18n/locales/pl/tools.json new file mode 100644 index 0000000000..33edb77cfa --- /dev/null +++ b/src/i18n/locales/pl/tools.json @@ -0,0 +1,9 @@ +{ + "readFile": { + "linesRange": " (linie {{start}}-{{end}})", + "linesFromToEnd": " (linie {{start}}-koniec)", + "linesFromStartTo": " (linie 1-{{end}})", + "definitionsOnly": " (tylko definicje)", + "maxLines": " (maks. {{max}} linii)" + } +} diff --git a/src/i18n/locales/pt-BR/tools.json b/src/i18n/locales/pt-BR/tools.json new file mode 100644 index 0000000000..0992809bdd --- /dev/null +++ b/src/i18n/locales/pt-BR/tools.json @@ -0,0 +1,9 @@ +{ + "readFile": { + "linesRange": " (linhas {{start}}-{{end}})", + "linesFromToEnd": " (linhas {{start}}-fim)", + "linesFromStartTo": " (linhas 1-{{end}})", + "definitionsOnly": " (apenas definições)", + "maxLines": " (máx. {{max}} linhas)" + } +} diff --git a/src/i18n/locales/tr/tools.json b/src/i18n/locales/tr/tools.json new file mode 100644 index 0000000000..19b0158d13 --- /dev/null +++ b/src/i18n/locales/tr/tools.json @@ -0,0 +1,9 @@ +{ + "readFile": { + "linesRange": " (satır {{start}}-{{end}})", + "linesFromToEnd": " (satır {{start}}-son)", + "linesFromStartTo": " (satır 1-{{end}})", + "definitionsOnly": " (sadece tanımlar)", + "maxLines": " (maks. {{max}} satır)" + } +} diff --git a/src/i18n/locales/vi/tools.json b/src/i18n/locales/vi/tools.json new file mode 100644 index 0000000000..76af39abe1 --- /dev/null +++ b/src/i18n/locales/vi/tools.json @@ -0,0 +1,9 @@ +{ + "readFile": { + "linesRange": " (dòng {{start}}-{{end}})", + "linesFromToEnd": " (dòng {{start}}-cuối)", + "linesFromStartTo": " (dòng 1-{{end}})", + "definitionsOnly": " (chỉ định nghĩa)", + "maxLines": " (tối đa {{max}} dòng)" + } +} diff --git a/src/i18n/locales/zh-CN/tools.json b/src/i18n/locales/zh-CN/tools.json new file mode 100644 index 0000000000..5f9b2ddaf7 --- /dev/null +++ b/src/i18n/locales/zh-CN/tools.json @@ -0,0 +1,9 @@ +{ + "readFile": { + "linesRange": " (第 {{start}}-{{end}} 行)", + "linesFromToEnd": " (第 {{start}} 行至末尾)", + "linesFromStartTo": " (第 1-{{end}} 行)", + "definitionsOnly": " (仅定义)", + "maxLines": " (最多 {{max}} 行)" + } +} diff --git a/src/i18n/locales/zh-TW/tools.json b/src/i18n/locales/zh-TW/tools.json new file mode 100644 index 0000000000..a9297e876b --- /dev/null +++ b/src/i18n/locales/zh-TW/tools.json @@ -0,0 +1,9 @@ +{ + "readFile": { + "linesRange": " (第 {{start}}-{{end}} 行)", + "linesFromToEnd": " (第 {{start}} 行至末尾)", + "linesFromStartTo": " (第 1-{{end}} 行)", + "definitionsOnly": " (僅定義)", + "maxLines": " (最多 {{max}} 行)" + } +} diff --git a/webview-ui/src/components/chat/ChatRow.tsx b/webview-ui/src/components/chat/ChatRow.tsx index f1a7ed994b..7fe200c3e9 100644 --- a/webview-ui/src/components/chat/ChatRow.tsx +++ b/webview-ui/src/components/chat/ChatRow.tsx @@ -356,6 +356,7 @@ export const ChatRowContent = ({ textAlign: "left", }}> {removeLeadingNonAlphanumeric(tool.path ?? "") + "\u200E"} + {tool.reason}