Skip to content

Commit b899f29

Browse files
committed
fix(tools): avoid rendering undefined feedback; omit empty feedback line
refactor(mentions): always process text; remove no-op gate; update docstring
1 parent 7171bff commit b899f29

File tree

3 files changed

+30
-41
lines changed

3 files changed

+30
-41
lines changed

src/core/mentions/processUserContentMentions.ts

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { UrlContentFetcher } from "../../services/browser/UrlContentFetcher"
44
import { FileContextTracker } from "../context-tracking/FileContextTracker"
55

66
/**
7-
* Process mentions in user content, specifically within task and feedback tags
7+
* Process mentions in all user content uniformly (text and tool_result text blocks).
88
*/
99
export async function processUserContentMentions({
1010
userContent,
@@ -35,14 +35,27 @@ export async function processUserContentMentions({
3535
// 3. ToolResultBlockParam's array content where blocks are text type
3636
return Promise.all(
3737
userContent.map(async (block) => {
38-
const shouldProcessMentions = (_text: string) => true
39-
4038
if (block.type === "text") {
41-
if (shouldProcessMentions(block.text)) {
39+
return {
40+
...block,
41+
text: await parseMentions(
42+
block.text,
43+
cwd,
44+
urlContentFetcher,
45+
fileContextTracker,
46+
rooIgnoreController,
47+
showRooIgnoredFiles,
48+
includeDiagnosticMessages,
49+
maxDiagnosticMessages,
50+
maxReadFileLine,
51+
),
52+
}
53+
} else if (block.type === "tool_result") {
54+
if (typeof block.content === "string") {
4255
return {
4356
...block,
44-
text: await parseMentions(
45-
block.text,
57+
content: await parseMentions(
58+
block.content,
4659
cwd,
4760
urlContentFetcher,
4861
fileContextTracker,
@@ -53,33 +66,10 @@ export async function processUserContentMentions({
5366
maxReadFileLine,
5467
),
5568
}
56-
}
57-
58-
return block
59-
} else if (block.type === "tool_result") {
60-
if (typeof block.content === "string") {
61-
if (shouldProcessMentions(block.content)) {
62-
return {
63-
...block,
64-
content: await parseMentions(
65-
block.content,
66-
cwd,
67-
urlContentFetcher,
68-
fileContextTracker,
69-
rooIgnoreController,
70-
showRooIgnoredFiles,
71-
includeDiagnosticMessages,
72-
maxDiagnosticMessages,
73-
maxReadFileLine,
74-
),
75-
}
76-
}
77-
78-
return block
7969
} else if (Array.isArray(block.content)) {
8070
const parsedContent = await Promise.all(
8171
block.content.map(async (contentBlock) => {
82-
if (contentBlock.type === "text" && shouldProcessMentions(contentBlock.text)) {
72+
if (contentBlock.type === "text") {
8373
return {
8474
...contentBlock,
8575
text: await parseMentions(

src/core/tools/attemptCompletionTool.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,10 @@ export async function attemptCompletionTool(
123123
await cline.say("user_feedback", text ?? "", images)
124124
const toolResults: (Anthropic.TextBlockParam | Anthropic.ImageBlockParam)[] = []
125125

126+
const feedbackSuffix = text && text.trim().length > 0 ? `\n${text}` : ""
126127
toolResults.push({
127128
type: "text",
128-
text: `The user has provided feedback on the results. Consider their input to continue the task, and then attempt completion again.\n${text}`,
129+
text: `The user has provided feedback on the results. Consider their input to continue the task, and then attempt completion again.${feedbackSuffix}`,
129130
})
130131

131132
toolResults.push(...formatResponse.imageBlocks(images))

src/core/tools/executeCommandTool.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -311,17 +311,15 @@ export async function executeCommand(
311311
const { text, images } = message
312312
await task.say("user_feedback", text, images)
313313

314-
return [
315-
true,
316-
formatResponse.toolResult(
317-
[
318-
`Command is still running in terminal from '${terminal.getCurrentWorkingDirectory().toPosix()}'.`,
319-
result.length > 0 ? `Here's the output so far:\n${result}\n` : "\n",
320-
`The user provided the following feedback:\n${text}`,
321-
].join("\n"),
322-
images,
323-
),
314+
const parts: string[] = [
315+
`Command is still running in terminal from '${terminal.getCurrentWorkingDirectory().toPosix()}'.`,
316+
result.length > 0 ? `Here's the output so far:\n${result}\n` : "\n",
324317
]
318+
if (text && text.trim().length > 0) {
319+
parts.push(`The user provided the following feedback:\n${text}`)
320+
}
321+
322+
return [true, formatResponse.toolResult(parts.join("\n"), images)]
325323
} else if (completed || exitDetails) {
326324
let exitStatus: string = ""
327325

0 commit comments

Comments
 (0)