Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/core/tools/applyDiffTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export async function applyDiffTool(
const sharedMessageProps: ClineSayTool = {
tool: "appliedDiff",
path: getReadablePath(cline.cwd, removeClosingTag("path", relPath)),
diff: diffContent,
}

try {
Expand All @@ -46,8 +47,10 @@ export async function applyDiffTool(
return
}

const partialMessage = JSON.stringify(sharedMessageProps)
await cline.ask("tool", partialMessage, block.partial, toolProgressStatus).catch(() => {})
await cline
.ask("tool", JSON.stringify(sharedMessageProps), block.partial, toolProgressStatus)
.catch(() => {})

return
} else {
if (!relPath) {
Expand Down
21 changes: 11 additions & 10 deletions src/core/tools/insertContentTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ export async function insertContentTool(
const sharedMessageProps: ClineSayTool = {
tool: "insertContent",
path: getReadablePath(cline.cwd, removeClosingTag("path", relPath)),
diff: content,
lineNumber: line ? parseInt(line, 10) : undefined,
}

try {
if (block.partial) {
const partialMessage = JSON.stringify(sharedMessageProps)
await cline.ask("tool", partialMessage, block.partial).catch(() => {})
await cline.ask("tool", JSON.stringify(sharedMessageProps), block.partial).catch(() => {})
return
}

Expand Down Expand Up @@ -145,14 +145,15 @@ export async function insertContentTool(
return
}

const userFeedbackDiff = JSON.stringify({
tool: "insertContent",
path: getReadablePath(cline.cwd, relPath),
lineNumber: lineNumber,
diff: userEdits,
} satisfies ClineSayTool)

await cline.say("user_feedback_diff", userFeedbackDiff)
await cline.say(
"user_feedback_diff",
JSON.stringify({
tool: "insertContent",
path: getReadablePath(cline.cwd, relPath),
diff: userEdits,
lineNumber: lineNumber,
} satisfies ClineSayTool),
)

pushToolResult(
`The user made the following updates to your content:\n\n${userEdits}\n\n` +
Expand Down
15 changes: 8 additions & 7 deletions src/core/tools/searchAndReplaceTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,14 @@ export async function searchAndReplaceTool(
return
}

const userFeedbackDiff = JSON.stringify({
tool: "appliedDiff",
path: getReadablePath(cline.cwd, relPath),
diff: userEdits,
} satisfies ClineSayTool)

await cline.say("user_feedback_diff", userFeedbackDiff)
await cline.say(
"user_feedback_diff",
JSON.stringify({
tool: "appliedDiff",
path: getReadablePath(cline.cwd, relPath),
diff: userEdits,
} satisfies ClineSayTool),
)

// Format and send response with user's updates
const resultMessage = [
Expand Down
1 change: 1 addition & 0 deletions src/core/tools/writeToFileTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export async function writeToFileTool(
const sharedMessageProps: ClineSayTool = {
tool: fileExists ? "editedExistingFile" : "newFileCreated",
path: getReadablePath(cline.cwd, removeClosingTag("path", relPath)),
content: newContent,
isOutsideWorkspace,
}

Expand Down
91 changes: 33 additions & 58 deletions webview-ui/src/components/chat/ChatRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ import { useCopyToClipboard } from "@src/utils/clipboard"
import { useExtensionState } from "@src/context/ExtensionStateContext"
import { findMatchingResourceOrTemplate } from "@src/utils/mcp"
import { vscode } from "@src/utils/vscode"
import { removeLeadingNonAlphanumeric } from "@src/utils/removeLeadingNonAlphanumeric"
import { Button } from "@src/components/ui"

import CodeAccordian, { removeLeadingNonAlphanumeric } from "../common/CodeAccordian"
import CodeBlock, { CODE_BLOCK_BG_COLOR } from "../common/CodeBlock"
import { ToolUseBlock, ToolUseBlockHeader } from "../common/ToolUseBlock"
import CodeAccordian from "../common/CodeAccordian"
import CodeBlock from "../common/CodeBlock"
import MarkdownBlock from "../common/MarkdownBlock"
import { ReasoningBlock } from "./ReasoningBlock"
import Thumbnails from "../common/Thumbnails"
Expand Down Expand Up @@ -287,10 +289,11 @@ export const ChatRowContent = ({
</span>
</div>
<CodeAccordian
path={tool.path}
code={tool.content ?? tool.diff}
language={tool.tool === "appliedDiff" ? "diff" : undefined}
progressStatus={message.progressStatus}
isLoading={message.partial}
diff={tool.diff!}
path={tool.path!}
isExpanded={isExpanded}
onToggleExpand={onToggleExpand}
/>
Expand All @@ -312,10 +315,11 @@ export const ChatRowContent = ({
</span>
</div>
<CodeAccordian
path={tool.path}
code={tool.diff}
language="diff"
progressStatus={message.progressStatus}
isLoading={message.partial}
diff={tool.diff!}
path={tool.path!}
isExpanded={isExpanded}
onToggleExpand={onToggleExpand}
/>
Expand All @@ -333,10 +337,10 @@ export const ChatRowContent = ({
</span>
</div>
<CodeAccordian
path={tool.path}
code={tool.diff}
progressStatus={message.progressStatus}
isLoading={message.partial}
diff={tool.diff!}
path={tool.path!}
isExpanded={isExpanded}
onToggleExpand={onToggleExpand}
/>
Expand All @@ -350,9 +354,9 @@ export const ChatRowContent = ({
<span style={{ fontWeight: "bold" }}>{t("chat:fileOperations.wantsToCreate")}</span>
</div>
<CodeAccordian
path={tool.path}
code={tool.content}
isLoading={message.partial}
code={tool.content!}
path={tool.path!}
isExpanded={isExpanded}
onToggleExpand={onToggleExpand}
/>
Expand All @@ -371,47 +375,21 @@ export const ChatRowContent = ({
: t("chat:fileOperations.didRead")}
</span>
</div>
<div
style={{
borderRadius: 3,
backgroundColor: CODE_BLOCK_BG_COLOR,
overflow: "hidden",
border: "1px solid var(--vscode-editorGroup-border)",
}}>
<div
style={{
color: "var(--vscode-descriptionForeground)",
display: "flex",
alignItems: "center",
padding: "9px 10px",
cursor: "pointer",
userSelect: "none",
WebkitUserSelect: "none",
MozUserSelect: "none",
msUserSelect: "none",
}}
onClick={() => {
vscode.postMessage({ type: "openFile", text: tool.content })
}}>
<ToolUseBlock>
<ToolUseBlockHeader
onClick={() => vscode.postMessage({ type: "openFile", text: tool.content })}>
{tool.path?.startsWith(".") && <span>.</span>}
<span
style={{
whiteSpace: "nowrap",
overflow: "hidden",
textOverflow: "ellipsis",
marginRight: "8px",
direction: "rtl",
textAlign: "left",
}}>
<span className="whitespace-nowrap overflow-hidden text-ellipsis text-left mr-2 rtl">
{removeLeadingNonAlphanumeric(tool.path ?? "") + "\u200E"}
{tool.reason}
</span>
<div style={{ flexGrow: 1 }}></div>
<span
className={`codicon codicon-link-external`}
style={{ fontSize: 13.5, margin: "1px 0" }}></span>
</div>
</div>
style={{ fontSize: 13.5, margin: "1px 0" }}
/>
</ToolUseBlockHeader>
</ToolUseBlock>
</>
)
case "fetchInstructions":
Expand All @@ -422,8 +400,8 @@ export const ChatRowContent = ({
<span style={{ fontWeight: "bold" }}>{t("chat:instructions.wantsToFetch")}</span>
</div>
<CodeAccordian
code={tool.content}
isLoading={message.partial}
code={tool.content!}
isExpanded={isExpanded}
onToggleExpand={onToggleExpand}
/>
Expand All @@ -441,8 +419,8 @@ export const ChatRowContent = ({
</span>
</div>
<CodeAccordian
code={tool.content!}
path={tool.path!}
path={tool.path}
code={tool.content}
language="shell-session"
isExpanded={isExpanded}
onToggleExpand={onToggleExpand}
Expand All @@ -461,8 +439,8 @@ export const ChatRowContent = ({
</span>
</div>
<CodeAccordian
code={tool.content!}
path={tool.path!}
path={tool.path}
code={tool.content}
language="shell-session"
isExpanded={isExpanded}
onToggleExpand={onToggleExpand}
Expand All @@ -481,8 +459,8 @@ export const ChatRowContent = ({
</span>
</div>
<CodeAccordian
code={tool.content!}
path={tool.path!}
path={tool.path}
code={tool.content}
isExpanded={isExpanded}
onToggleExpand={onToggleExpand}
/>
Expand Down Expand Up @@ -510,8 +488,8 @@ export const ChatRowContent = ({
</span>
</div>
<CodeAccordian
code={tool.content!}
path={tool.path! + (tool.filePattern ? `/(${tool.filePattern})` : "")}
code={tool.content}
language="log"
isExpanded={isExpanded}
onToggleExpand={onToggleExpand}
Expand Down Expand Up @@ -881,13 +859,10 @@ export const ChatRowContent = ({
case "user_feedback_diff":
const tool = safeJsonParse<ClineSayTool>(message.text)
return (
<div
style={{
marginTop: -10,
width: "100%",
}}>
<div style={{ marginTop: -10, width: "100%" }}>
<CodeAccordian
diff={tool?.diff!}
code={tool?.diff}
language="diff"
isFeedback={true}
isExpanded={isExpanded}
onToggleExpand={onToggleExpand}
Expand Down
6 changes: 4 additions & 2 deletions webview-ui/src/components/chat/ContextMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import React, { useEffect, useMemo, useRef, useState } from "react"
import { getIconForFilePath, getIconUrlByName, getIconForDirectoryPath } from "vscode-material-icons"

import { ModeConfig } from "@roo/shared/modes"

import {
ContextMenuOptionType,
ContextMenuQueryItem,
getContextMenuOptions,
SearchResult,
} from "@src/utils/context-mentions"
import { removeLeadingNonAlphanumeric } from "../common/CodeAccordian"
import { ModeConfig } from "@roo/shared/modes"
import { removeLeadingNonAlphanumeric } from "@src/utils/removeLeadingNonAlphanumeric"

interface ContextMenuProps {
onSelect: (type: ContextMenuOptionType, value?: string) => void
Expand Down
Loading