kilocode
kilocode copied to clipboard
fix: enforce autoscroll in chattextarea
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
requestAnimationFramepass that forces the textarea to scroll to its fullscrollHeight. - 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/cancelAnimationFrameto 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 --filterChatTextAreato execute the new specs.
Get in Touch
Discord: @shirley
🦋 Changeset detected
Latest commit: 05f1072c673c1f7a42c37959a3fb7f33f733e8b3
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 1 package
| Name | Type |
|---|---|
| kilo-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