Display info about partial reads in chat row (#2080)

This commit is contained in:
Matt Rubens 2025-03-29 02:14:18 -04:00 committed by GitHub
parent e15fa227c5
commit 9bb50eaba3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 155 additions and 3 deletions

View file

@ -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 {

View file

@ -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)"
}
}

View file

@ -0,0 +1,9 @@
{
"readFile": {
"linesRange": " (Zeilen {{start}}-{{end}})",
"linesFromToEnd": " (Zeilen {{start}}-Ende)",
"linesFromStartTo": " (Zeilen 1-{{end}})",
"definitionsOnly": " (nur Definitionen)",
"maxLines": " (maximal {{max}} Zeilen)"
}
}

View file

@ -0,0 +1,9 @@
{
"readFile": {
"linesRange": " (lines {{start}}-{{end}})",
"linesFromToEnd": " (lines {{start}}-end)",
"linesFromStartTo": " (lines 1-{{end}})",
"definitionsOnly": " (definitions only)",
"maxLines": " (max {{max}} lines)"
}
}

View file

@ -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)"
}
}

View file

@ -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)"
}
}

View file

@ -0,0 +1,9 @@
{
"readFile": {
"linesRange": " (पंक्तियाँ {{start}}-{{end}})",
"linesFromToEnd": " (पंक्तियाँ {{start}}-अंत)",
"linesFromStartTo": " (पंक्तियाँ 1-{{end}})",
"definitionsOnly": " (केवल परिभाषाएँ)",
"maxLines": " (अधिकतम {{max}} पंक्तियाँ)"
}
}

View file

@ -0,0 +1,9 @@
{
"readFile": {
"linesRange": " (righe {{start}}-{{end}})",
"linesFromToEnd": " (righe {{start}}-fine)",
"linesFromStartTo": " (righe 1-{{end}})",
"definitionsOnly": " (solo definizioni)",
"maxLines": " (max {{max}} righe)"
}
}

View file

@ -0,0 +1,9 @@
{
"readFile": {
"linesRange": " ({{start}}-{{end}}行目)",
"linesFromToEnd": " ({{start}}行目-最後まで)",
"linesFromStartTo": " (1-{{end}}行目)",
"definitionsOnly": " (定義のみ)",
"maxLines": " (最大{{max}}行)"
}
}

View file

@ -0,0 +1,9 @@
{
"readFile": {
"linesRange": " ({{start}}-{{end}}행)",
"linesFromToEnd": " ({{start}}행-끝)",
"linesFromStartTo": " (1-{{end}}행)",
"definitionsOnly": " (정의만)",
"maxLines": " (최대 {{max}}행)"
}
}

View file

@ -0,0 +1,9 @@
{
"readFile": {
"linesRange": " (linie {{start}}-{{end}})",
"linesFromToEnd": " (linie {{start}}-koniec)",
"linesFromStartTo": " (linie 1-{{end}})",
"definitionsOnly": " (tylko definicje)",
"maxLines": " (maks. {{max}} linii)"
}
}

View file

@ -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)"
}
}

View file

@ -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)"
}
}

View file

@ -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)"
}
}

View file

@ -0,0 +1,9 @@
{
"readFile": {
"linesRange": " (第 {{start}}-{{end}} 行)",
"linesFromToEnd": " (第 {{start}} 行至末尾)",
"linesFromStartTo": " (第 1-{{end}} 行)",
"definitionsOnly": " (仅定义)",
"maxLines": " (最多 {{max}} 行)"
}
}

View file

@ -0,0 +1,9 @@
{
"readFile": {
"linesRange": " (第 {{start}}-{{end}} 行)",
"linesFromToEnd": " (第 {{start}} 行至末尾)",
"linesFromStartTo": " (第 1-{{end}} 行)",
"definitionsOnly": " (僅定義)",
"maxLines": " (最多 {{max}} 行)"
}
}

View file

@ -356,6 +356,7 @@ export const ChatRowContent = ({
textAlign: "left",
}}>
{removeLeadingNonAlphanumeric(tool.path ?? "") + "\u200E"}
{tool.reason}
</span>
<div style={{ flexGrow: 1 }}></div>
<span