Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/observe-chat-resize.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@kilocode/kilo-ui": patch
"kilo-code": patch
---

Keep chat pinned to the latest output when the visible message area resizes without overriding an intentional scroll position.
16 changes: 16 additions & 0 deletions packages/kilo-ui/src/hooks/create-auto-scroll.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export function createAutoScroll(options: AutoScrollOptions) {

const [store, setStore] = createStore({
contentRef: undefined as HTMLElement | undefined,
scrollRef: undefined as HTMLElement | undefined,
userScrolled: false,
})

Expand Down Expand Up @@ -187,6 +188,20 @@ export function createAutoScroll(options: AutoScrollOptions) {
},
)

createResizeObserver(
() => store.scrollRef,
() => {
const el = scroll
if (!el) return
if (!canScroll(el)) {
if (store.userScrolled) setStore("userScrolled", false)
return
}
if (store.userScrolled || recentlyInteracted()) return
scrollToBottomNow("auto")
},
)

createEffect(
on(options.working, (working: boolean) => {
settling = false
Expand Down Expand Up @@ -219,6 +234,7 @@ export function createAutoScroll(options: AutoScrollOptions) {
}

scroll = el
setStore("scrollRef", el)

if (!el) return

Expand Down
13 changes: 1 addition & 12 deletions packages/kilo-vscode/webview-ui/src/components/chat/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Main chat container that combines all chat components
*/

import { type Component, Show, createEffect, createMemo, createSignal, on, onCleanup, onMount } from "solid-js"
import { type Component, Show, createEffect, createMemo, createSignal, onCleanup, onMount } from "solid-js"
import { Button } from "@kilocode/kilo-ui/button"
import { Icon } from "@kilocode/kilo-ui/icon"
import { Spinner } from "@kilocode/kilo-ui/spinner"
Expand Down Expand Up @@ -78,17 +78,6 @@ export const ChatView: Component<ChatViewProps> = (props) => {
const questioning = () => isQuestioning(blocked(), familyQuestions().length)
const dock = () => !props.readonly || !!permissionRequest()

// When a bottom-dock permission disappears while the session is busy,
// the scroll container grows taller. Dispatch a custom event so MessageList can
// resume auto-scroll.
createEffect(
on(blocked, (isBlocked, wasBlocked) => {
if (wasBlocked && !isBlocked && !idle()) {
window.dispatchEvent(new CustomEvent("resumeAutoScroll"))
}
}),
)

onMount(() => {
if (props.readonly) return
const handler = (e: KeyboardEvent) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const MessageList: Component<MessageListProps> = (props) => {
working: () => session.status() !== "idle",
})

// Resume auto-scroll when a bottom-dock permission/question is dismissed
// Explicit output-producing actions resume auto-scroll before appending.
const onResumeAutoScroll = () => autoScroll.resume()
window.addEventListener("resumeAutoScroll", onResumeAutoScroll)
onCleanup(() => window.removeEventListener("resumeAutoScroll", onResumeAutoScroll))
Expand Down
Loading