Skip to content

Commit 9bb50ea

Browse files
authored
Display info about partial reads in chat row (#2080)
1 parent e15fa22 commit 9bb50ea

File tree

17 files changed

+155
-3
lines changed

17 files changed

+155
-3
lines changed

src/core/tools/readFileTool.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Cline } from "../Cline"
33
import { ClineSayTool } from "../../shared/ExtensionMessage"
44
import { ToolUse } from "../assistant-message"
55
import { formatResponse } from "../prompts/responses"
6+
import { t } from "../../i18n"
67
import { AskApproval, HandleError, PushToolResult, RemoveClosingTag } from "./types"
78
import { isPathOutsideWorkspace } from "../../utils/pathUtils"
89
import { getReadablePath } from "../../utils/path"
@@ -97,21 +98,36 @@ export async function readFileTool(
9798
break
9899
}
99100

101+
const { maxReadFileLine = 500 } = (await cline.providerRef.deref()?.getState()) ?? {}
102+
103+
// Create line snippet description for approval message
104+
let lineSnippet = ""
105+
if (startLine !== undefined && endLine !== undefined) {
106+
lineSnippet = t("tools:readFile.linesRange", { start: startLine + 1, end: endLine + 1 })
107+
} else if (startLine !== undefined) {
108+
lineSnippet = t("tools:readFile.linesFromToEnd", { start: startLine + 1 })
109+
} else if (endLine !== undefined) {
110+
lineSnippet = t("tools:readFile.linesFromStartTo", { end: endLine + 1 })
111+
} else if (maxReadFileLine === 0) {
112+
lineSnippet = t("tools:readFile.definitionsOnly")
113+
} else if (maxReadFileLine > 0) {
114+
lineSnippet = t("tools:readFile.maxLines", { max: maxReadFileLine })
115+
}
116+
100117
cline.consecutiveMistakeCount = 0
101118
const absolutePath = path.resolve(cline.cwd, relPath)
119+
102120
const completeMessage = JSON.stringify({
103121
...sharedMessageProps,
104122
content: absolutePath,
123+
reason: lineSnippet,
105124
} satisfies ClineSayTool)
106125

107126
const didApprove = await askApproval("tool", completeMessage)
108127
if (!didApprove) {
109128
break
110129
}
111130

112-
// Get the maxReadFileLine setting
113-
const { maxReadFileLine = 500 } = (await cline.providerRef.deref()?.getState()) ?? {}
114-
115131
// Count total lines in the file
116132
let totalLines = 0
117133
try {

src/i18n/locales/ca/tools.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"readFile": {
3+
"linesRange": " (línies {{start}}-{{end}})",
4+
"linesFromToEnd": " (línies {{start}}-final)",
5+
"linesFromStartTo": " (línies 1-{{end}})",
6+
"definitionsOnly": " (només definicions)",
7+
"maxLines": " (màxim {{max}} línies)"
8+
}
9+
}

src/i18n/locales/de/tools.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"readFile": {
3+
"linesRange": " (Zeilen {{start}}-{{end}})",
4+
"linesFromToEnd": " (Zeilen {{start}}-Ende)",
5+
"linesFromStartTo": " (Zeilen 1-{{end}})",
6+
"definitionsOnly": " (nur Definitionen)",
7+
"maxLines": " (maximal {{max}} Zeilen)"
8+
}
9+
}

src/i18n/locales/en/tools.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"readFile": {
3+
"linesRange": " (lines {{start}}-{{end}})",
4+
"linesFromToEnd": " (lines {{start}}-end)",
5+
"linesFromStartTo": " (lines 1-{{end}})",
6+
"definitionsOnly": " (definitions only)",
7+
"maxLines": " (max {{max}} lines)"
8+
}
9+
}

src/i18n/locales/es/tools.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"readFile": {
3+
"linesRange": " (líneas {{start}}-{{end}})",
4+
"linesFromToEnd": " (líneas {{start}}-final)",
5+
"linesFromStartTo": " (líneas 1-{{end}})",
6+
"definitionsOnly": " (solo definiciones)",
7+
"maxLines": " (máximo {{max}} líneas)"
8+
}
9+
}

src/i18n/locales/fr/tools.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"readFile": {
3+
"linesRange": " (lignes {{start}}-{{end}})",
4+
"linesFromToEnd": " (lignes {{start}}-fin)",
5+
"linesFromStartTo": " (lignes 1-{{end}})",
6+
"definitionsOnly": " (définitions uniquement)",
7+
"maxLines": " (max {{max}} lignes)"
8+
}
9+
}

src/i18n/locales/hi/tools.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"readFile": {
3+
"linesRange": " (पंक्तियाँ {{start}}-{{end}})",
4+
"linesFromToEnd": " (पंक्तियाँ {{start}}-अंत)",
5+
"linesFromStartTo": " (पंक्तियाँ 1-{{end}})",
6+
"definitionsOnly": " (केवल परिभाषाएँ)",
7+
"maxLines": " (अधिकतम {{max}} पंक्तियाँ)"
8+
}
9+
}

src/i18n/locales/it/tools.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"readFile": {
3+
"linesRange": " (righe {{start}}-{{end}})",
4+
"linesFromToEnd": " (righe {{start}}-fine)",
5+
"linesFromStartTo": " (righe 1-{{end}})",
6+
"definitionsOnly": " (solo definizioni)",
7+
"maxLines": " (max {{max}} righe)"
8+
}
9+
}

src/i18n/locales/ja/tools.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"readFile": {
3+
"linesRange": " ({{start}}-{{end}}行目)",
4+
"linesFromToEnd": " ({{start}}行目-最後まで)",
5+
"linesFromStartTo": " (1-{{end}}行目)",
6+
"definitionsOnly": " (定義のみ)",
7+
"maxLines": " (最大{{max}}行)"
8+
}
9+
}

src/i18n/locales/ko/tools.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"readFile": {
3+
"linesRange": " ({{start}}-{{end}}행)",
4+
"linesFromToEnd": " ({{start}}행-끝)",
5+
"linesFromStartTo": " (1-{{end}}행)",
6+
"definitionsOnly": " (정의만)",
7+
"maxLines": " (최대 {{max}}행)"
8+
}
9+
}

0 commit comments

Comments
 (0)