Skip to content

Conversation

@ShirleyRex
Copy link

@ShirleyRex ShirleyRex commented Dec 1, 2025

Context

Autoscroll in ChatTextArea stopped keeping the caret visible once the conversation got tall, so typing at the end of a long reply would push new lines off-screen. This change ensures the textarea tracks the caret while the user is appending text at the end, but avoids snapping the viewport when they’re editing in the middle of the message.

Implementation

  • Tracked whether the latest input event left the caret at the end of the text and, when it does, scheduled a requestAnimationFrame pass that forces the textarea to scroll to its full scrollHeight.
  • Reused that same pass to refresh the highlight layer so the visual tokens stay in sync with the new scroll position.
  • Added Vitest coverage for both the “append at tail” and “edit mid-buffer” scenarios, stubbing requestAnimationFrame /cancelAnimationFrame to assert when the autoscroll kicks in (and when it shouldn’t).

How to Test

  • pnpm webview dev (or launch the VS Code extension) and open any long-running chat.
  • Paste or type enough lines into the composer to force a scrollbar, then keep typing at the bottom; the viewport should follow the caret automatically.
  • Move the caret to the middle of the text, insert characters, and confirm the scroll position stays put.
  • Run pnpm test webview-ui --filter ChatTextArea to execute the new specs.

Get in Touch

Discord: @shirley

@changeset-bot
Copy link

changeset-bot bot commented Dec 1, 2025

🦋 Changeset detected

Latest commit: 2224b90

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@roo-code/web-roo-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@ShirleyRex ShirleyRex marked this pull request as draft December 1, 2025 14:38
@ShirleyRex ShirleyRex marked this pull request as ready for review December 1, 2025 14:59
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.

1 participant