diff --git a/.changeset/reset-diff-scroll.md b/.changeset/reset-diff-scroll.md new file mode 100644 index 0000000000..c5efe834f8 --- /dev/null +++ b/.changeset/reset-diff-scroll.md @@ -0,0 +1,5 @@ +--- +"kilo-code": patch +--- + +Fix scroll position not resetting when switching between diff files in the chat and virtual diff viewer diff --git a/packages/kilo-vscode/webview-ui/diff-virtual/DiffVirtualApp.tsx b/packages/kilo-vscode/webview-ui/diff-virtual/DiffVirtualApp.tsx index a9ccfdc103..33661a4f60 100644 --- a/packages/kilo-vscode/webview-ui/diff-virtual/DiffVirtualApp.tsx +++ b/packages/kilo-vscode/webview-ui/diff-virtual/DiffVirtualApp.tsx @@ -1,4 +1,4 @@ -import { createMemo, createSignal, onCleanup, Show } from "solid-js" +import { createMemo, createSignal, onCleanup, Show, createEffect, on } from "solid-js" import type { Component } from "solid-js" import { CodeComponentProvider } from "@kilocode/kilo-ui/context/code" import { DiffComponentProvider } from "@kilocode/kilo-ui/context/diff" @@ -32,6 +32,19 @@ const DiffVirtualContent: Component = () => { const [diff, setDiff] = createSignal(null) const [style, setStyle] = createSignal("unified") const [markdown, setMarkdown] = createSignal(false) + let scrollerRef: HTMLDivElement | undefined + + createEffect( + on( + diff, + () => { + if (scrollerRef) { + scrollerRef.scrollTop = 0 + } + }, + { defer: true }, + ), + ) const handler = (event: MessageEvent) => { const msg = event.data as { @@ -112,7 +125,7 @@ const DiffVirtualContent: Component = () => { -
+
(scrollerRef = el)}> {(v) => (