Skip to content

Commit 9759978

Browse files
committed
fix(chat): allow editing historical messages while streaming and prevent auto-jump to bottom; ensure edit area scrolls into view
1 parent e0c5248 commit 9759978

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

webview-ui/src/components/chat/ChatRow.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,17 +1164,19 @@ export const ChatRowContent = ({
11641164
className="flex-grow px-2 py-1 wrap-anywhere rounded-lg transition-colors"
11651165
onClick={(e) => {
11661166
e.stopPropagation()
1167-
if (!isStreaming) {
1168-
handleEditClick()
1167+
// Allow editing historical messages even while streaming; only block when this is the last message and streaming
1168+
if (isStreaming && isLast) {
1169+
return
11691170
}
1171+
handleEditClick()
11701172
}}
11711173
title={t("chat:queuedMessages.clickToEdit")}>
11721174
<Mention text={message.text} withShadow />
11731175
</div>
11741176
<div className="flex gap-2 pr-1">
11751177
<div
11761178
className="cursor-pointer shrink-0 opacity-0 group-hover:opacity-100 transition-opacity"
1177-
style={{ visibility: isStreaming ? "hidden" : "visible" }}
1179+
style={{ visibility: isStreaming && isLast ? "hidden" : "visible" }}
11781180
onClick={(e) => {
11791181
e.stopPropagation()
11801182
handleEditClick()

webview-ui/src/components/chat/ChatView.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,15 +1384,17 @@ const ChatViewComponent: React.ForwardRefRenderFunction<ChatViewRef, ChatViewPro
13841384

13851385
const handleRowHeightChange = useCallback(
13861386
(isTaller: boolean) => {
1387-
if (!disableAutoScrollRef.current) {
1387+
// Only auto-scroll when user is already at the bottom.
1388+
// This prevents editing a historical message from forcing the list to jump to the bottom.
1389+
if (!disableAutoScrollRef.current && isAtBottom) {
13881390
if (isTaller) {
13891391
scrollToBottomSmooth()
13901392
} else {
13911393
setTimeout(() => scrollToBottomAuto(), 0)
13921394
}
13931395
}
13941396
},
1395-
[scrollToBottomSmooth, scrollToBottomAuto],
1397+
[scrollToBottomSmooth, scrollToBottomAuto, isAtBottom],
13961398
)
13971399

13981400
useEffect(() => {

0 commit comments

Comments
 (0)