fix: Add 'Remove from context' button for file read operations to handle token limit issues

- Added delete button to file read messages in ChatRow component
- Button appears only for completed file reads (not during streaming)
- Leverages existing deleteMessage infrastructure for proper cleanup
- Removes messages from both UI (clineMessages) and API conversation history
- Added 'removeFromContext' translation key for button tooltip
- Helps users recover from token limit errors by removing large files

Fixes #7559
This commit is contained in:
Roo Code 2025-08-31 02:52:41 +00:00
parent 63b71d8299
commit afa02637a5
2 changed files with 15 additions and 0 deletions

View file

@ -524,6 +524,20 @@ export const ChatRowContent = ({
: t("chat:fileOperations.wantsToRead")
: t("chat:fileOperations.didRead")}
</span>
{/* Add delete button for completed file reads when not streaming */}
{message.type === "say" && !isStreaming && (
<Button
variant="ghost"
size="icon"
className="ml-auto shrink-0"
title={t("chat:fileOperations.removeFromContext")}
onClick={(e) => {
e.stopPropagation()
vscode.postMessage({ type: "deleteMessage", value: message.ts })
}}>
<span className="codicon codicon-close" />
</Button>
)}
</div>
<ToolUseBlock>
<ToolUseBlockHeader

View file

@ -178,6 +178,7 @@
"wantsToReadAndXMore": "Roo wants to read this file and {{count}} more:",
"wantsToReadOutsideWorkspace": "Roo wants to read this file outside of the workspace:",
"didRead": "Roo read this file:",
"removeFromContext": "Remove from context",
"wantsToEdit": "Roo wants to edit this file:",
"wantsToEditOutsideWorkspace": "Roo wants to edit this file outside of the workspace:",
"wantsToEditProtected": "Roo wants to edit a protected configuration file:",