Skip to content

Conversation

@roblourens
Copy link
Member

@roblourens roblourens commented Dec 21, 2025

Hopefully fix #274428

Do you think this makes sense in the ListView @joaomoreno @rebornix? It doesn't have to be, I just thought it's maybe easier and I wouldn't mind having a way for the copilot debug tree to auto-scroll down too at some point.

Copilot AI review requested due to automatic review settings December 21, 2025 06:00
@roblourens roblourens self-assigned this Dec 21, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements autoscroll functionality directly in the ListView component to address issue #274428, eliminating the need for custom scroll management logic in consumers like ChatWidget.

Key changes:

  • Added a new autoscroll option to ListView that automatically keeps the list scrolled to the bottom when content changes (height updates or splices), if the list was already at the bottom
  • Removed ChatWidget's custom scroll tracking logic including previousTreeScrollHeight, scrollAnimationFrameDisposable, and the manual scroll-to-bottom logic in onDidChangeTreeContentHeight()
  • Added comprehensive test coverage for the autoscroll feature including edge cases

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/vs/base/browser/ui/list/listView.ts Implements core autoscroll logic with isScrolledToBottom() method and autoscroll checks in updateElementHeight() and _splice() methods; adds autoscroll option to interfaces
src/vs/base/browser/ui/tree/abstractTree.ts Adds autoscroll option to tree options interface to enable propagation through the tree abstraction layer
src/vs/workbench/contrib/chat/browser/chatWidget.ts Removes custom scroll logic and enables the new autoscroll option; cleans up scrollAnimationFrameDisposable and previousTreeScrollHeight state
src/vs/base/test/browser/ui/list/listView.test.ts Adds three comprehensive tests covering autoscroll behavior on element height changes, splices, and non-interference when not at bottom

}

private isScrolledToBottom(): boolean {
return this.scrollTop + this.renderHeight >= this.scrollHeight;
Copy link

Copilot AI Dec 21, 2025

Choose a reason for hiding this comment

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

The isScrolledToBottom() method doesn't account for rounding errors. Due to rounding, the scrollTop + renderHeight will not exactly match the scrollHeight. This issue was documented in the old ChatWidget implementation that was removed (which used a 2px tolerance), and the same tolerance is still used elsewhere in the codebase.

For reference:

  • The old ChatWidget code (removed in this PR) had: this.tree.scrollTop + this.tree.renderHeight >= this.previousTreeScrollHeight - 2
  • The debug REPL still uses: tree.scrollTop + tree.renderHeight >= this.previousTreeScrollHeight - 2 (see src/vs/workbench/contrib/debug/browser/repl.ts:691)
  • The ChatWidget still uses 2px tolerance for scroll-down button visibility: this.tree.scrollTop >= this.tree.scrollHeight - this.tree.renderHeight - 2 (line 1578)

Consider changing this to: return this.scrollTop + this.renderHeight >= this.scrollHeight - 2; to maintain consistency with existing scroll detection logic in the codebase.

Suggested change
return this.scrollTop + this.renderHeight >= this.scrollHeight;
return this.scrollTop + this.renderHeight >= this.scrollHeight - 2;

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Chat response: revealing the last output sometimes stuck

2 participants