mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
feat: auto-scroll to edit location after user edits in diff view
- Added ref to user_feedback_diff element - Implemented smooth scroll behavior when user edits appear - Scrolls to center of viewport for better visibility Fixes #7996
This commit is contained in:
parent
9d33c109c9
commit
28cf54b5cc
1 changed files with 18 additions and 1 deletions
|
|
@ -125,6 +125,7 @@ export const ChatRowContent = ({
|
|||
const [editMode, setEditMode] = useState<Mode>(mode || "code")
|
||||
const [editImages, setEditImages] = useState<string[]>([])
|
||||
const { copyWithFeedback } = useCopyToClipboard()
|
||||
const userEditRef = useRef<HTMLDivElement>(null)
|
||||
|
||||
// Handle message events for image selection during edit mode
|
||||
useEffect(() => {
|
||||
|
|
@ -351,6 +352,22 @@ export const ChatRowContent = ({
|
|||
return null
|
||||
}, [message.type, message.ask, message.partial, message.text])
|
||||
|
||||
// Scroll to user edits when they appear
|
||||
useEffect(() => {
|
||||
if (message.say === "user_feedback_diff" && userEditRef.current) {
|
||||
const tool = safeJsonParse<ClineSayTool>(message.text)
|
||||
if (tool?.diff) {
|
||||
// Use a small delay to ensure the element is rendered
|
||||
setTimeout(() => {
|
||||
userEditRef.current?.scrollIntoView({
|
||||
behavior: "smooth",
|
||||
block: "center",
|
||||
})
|
||||
}, 100)
|
||||
}
|
||||
}
|
||||
}, [message.say, message.text])
|
||||
|
||||
if (tool) {
|
||||
const toolIcon = (name: string) => (
|
||||
<span
|
||||
|
|
@ -1241,7 +1258,7 @@ export const ChatRowContent = ({
|
|||
case "user_feedback_diff":
|
||||
const tool = safeJsonParse<ClineSayTool>(message.text)
|
||||
return (
|
||||
<div style={{ marginTop: -10, width: "100%" }}>
|
||||
<div ref={userEditRef} style={{ marginTop: -10, width: "100%" }}>
|
||||
<CodeAccordian
|
||||
code={tool?.diff}
|
||||
language="diff"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue