Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

fix(diff-view): auto-scroll streamed content to bottom#10143

Open
village-way wants to merge 1 commit into
RooCodeInc:mainfrom
village-way:fix_diffview_scroll
Open

fix(diff-view): auto-scroll streamed content to bottom#10143
village-way wants to merge 1 commit into
RooCodeInc:mainfrom
village-way:fix_diffview_scroll

Conversation

@village-way

@village-way village-way commented Dec 17, 2025

Copy link
Copy Markdown
Contributor

Ensure the diff editor scrolls to the latest line when streaming long content and simplify diff view editor detection.

Related GitHub Issue

Closes: #10142

Roo Code Task Context (Optional)

Description

This PR fixes an issue where the diff view does not automatically scroll to the bottom when streaming long content. The previous implementation had a condition that checked if the target line was within the visible range before scrolling, which prevented auto-scrolling when content extended beyond the viewport.

Key changes:

  1. Simplified scroll logic: Removed the visibility range check that was preventing auto-scroll. Now the editor always scrolls to the current line being written, ensuring users can see the latest content as it streams.

  2. Improved diff editor opening: Simplified the diff editor opening logic by using onDidChangeActiveTextEditor event listener, following a simpler and more reliable approach similar to Cline's implementation. This ensures the correct editor (right-side of diff view) is captured.

  3. Enhanced scroll method: Improved scrollEditorToLine method with:

    • Added explicit return type annotation (: void)
    • Added early return guard for better code clarity
    • Consistent formatting
  4. Added scroll animation helper: Added a scrollAnimation method (for future use) that provides smooth scrolling between two lines, which can be helpful when tracking large content changes.

Design choices:

  • The removal of the visibility check ensures consistent behavior: always scroll to show the latest content
  • The simplified diff editor opening approach reduces complexity and potential race conditions
  • The changes maintain backward compatibility and don't affect other diff view functionality

Test Procedure

Manual testing steps:

  1. Test with long content streaming:

    • Open Roo Code and start a task that generates a large diff (e.g., create a new file with 500+ lines)
    • Observe that the diff view automatically scrolls to follow the bottom of the content as it streams
    • Verify that you can see the latest changes without manual scrolling
  2. Test with file modifications:

    • Modify an existing file with extensive changes
    • Verify that the diff view correctly scrolls to show the latest modifications
  3. Test diff editor opening:

    • Verify that diff editors open correctly for both new files and modified files
    • Ensure the right-side (editable) editor is correctly captured and focused
  4. Test edge cases:

    • Test with very short content (< 10 lines) to ensure no regression
    • Test with content that fits entirely in the viewport
    • Test with content that extends far beyond the viewport

Expected results:

  • Diff view automatically scrolls to bottom when streaming long content
  • No manual scrolling required to see latest changes
  • Diff editor opens correctly and captures the right editor instance
  • No regressions in existing diff view functionality
  • Issue Linked: This PR will be linked to an approved GitHub Issue (issue to be created)
  • Scope: Changes are focused on fixing the auto-scroll issue in diff view
  • Self-Review: Thorough self-review of code changes completed
  • Testing: Manual testing performed with various content lengths and scenarios
  • Documentation Impact: No documentation updates required (internal implementation fix)
  • Contribution Guidelines: Read and agree to the Contributor Guidelines

Screenshots / Videos

Documentation Updates

Additional Notes

Get in Touch


Important

Improves auto-scroll in diff view and simplifies diff editor detection in DiffViewProvider.ts.

  • Behavior:
    • Removed visibility range check in update() in DiffViewProvider.ts to ensure auto-scroll to the latest line when streaming content.
    • Simplified diff editor opening logic in openDiffEditor() using onDidChangeActiveTextEditor for reliable editor detection.
  • Functions:
    • Added scrollAnimation() in DiffViewProvider.ts for smooth scrolling between lines.
    • Improved scrollEditorToLine() with early return guard and return type annotation.
  • Misc:
    • Removed unnecessary timeout and event listeners in openDiffEditor() for cleaner code.

This description was created by Ellipsis for 0bdfaf3. You can customize this summary. It will automatically update as commits are pushed.

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels Dec 17, 2025
@ghost

ghost commented Dec 17, 2025

Copy link
Copy Markdown

Rooviewer Clock   See task on Roo Cloud

Re-reviewed after new commit (7a42267). Two previously flagged issues are now resolved. One minor issue remains.

  • Unused scrollAnimation method added but never called (dead code)
  • Potential regression: removed pre-opening logic for files with custom editor associations (e.g., markdown)
  • Missing error handling for diff command failures in openDiffEditor (now silently times out instead of showing specific error)
Previous reviews

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

Comment thread src/integrations/editor/DiffViewProvider.ts
},
)
// Timeout for slow machines
setTimeout(() => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In openDiffEditor, the setTimeout timer isn’t cleared when the diff editor becomes active. Consider storing the timer ID and clearing the timeout inside the onDidChangeActiveTextEditor callback to avoid the potential of a late reject being triggered after resolution.

}

// Open new diff editor.
// Open new diff editor (following Cline's simpler approach)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment currently refers to 'Cline's simpler approach'. For consistency with our product naming guidelines, consider updating this reference to 'Roo Code's simpler approach'.

Suggested change
// Open new diff editor (following Cline's simpler approach)
// Open new diff editor (following Roo Code's simpler approach)

This comment was generated because it violated a code review rule: irule_VrRKWqywZ2YV2SOE.

Comment on lines +528 to 539
// Execute the diff command
vscode.commands.executeCommand(
"vscode.diff",
vscode.Uri.from({
scheme: DIFF_VIEW_URI_SCHEME,
path: fileName,
query: Buffer.from(this.originalContent ?? "").toString("base64"),
}),
uri,
`${fileName}: ${fileExists ? DIFF_VIEW_LABEL_CHANGES : "New File"} (Editable)`,
{ preserveFocus: true },
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old code pre-opened the file as a text document before executing the diff command. The removed comment explicitly stated this was needed to "fix issues with files that have custom editor associations (like markdown preview)". With this change, markdown files and other files with custom editor associations may not open correctly in the diff view. Consider testing with markdown files to verify this isn't a regression.

Fix it with Roo Code or mention @roomote and request a fix.

Comment on lines +541 to +545
// Timeout for slow machines
setTimeout(() => {
disposable.dispose()
reject(new Error("Failed to open diff editor, please try again..."))
}, 10_000)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old implementation had explicit error handling for executeCommand failures that provided a meaningful error message (e.g., "Failed to execute diff command for : "). Now if the diff command fails, the promise will silently hang until the 10-second timeout with the generic message "Failed to open diff editor, please try again...", losing the specific error information that could help with debugging.

Fix it with Roo Code or mention @roomote and request a fix.

@village-way
village-way force-pushed the fix_diffview_scroll branch 2 times, most recently from 7639d07 to 1233c6b Compare December 17, 2025 07:02
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Dec 17, 2025
Ensure the diff editor scrolls to the latest line when streaming long content and simplify diff view editor detection.
@hannesrudolph hannesrudolph moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Jan 7, 2026
@hannesrudolph hannesrudolph added PR - Needs Preliminary Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Jan 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug Something isn't working PR - Needs Preliminary Review size:L This PR changes 100-499 lines, ignoring generated files.

Projects

No open projects
Status: PR [Needs Prelim Review]

Development

Successfully merging this pull request may close these issues.

[BUG] Diff view does not auto-scroll to bottom when streaming long content

2 participants