mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 12:21:13 -05:00
Revert "Rollback virtualized list changes"
This reverts commit e6f6d754b2.
This commit is contained in:
13
webview-ui/package-lock.json
generated
13
webview-ui/package-lock.json
generated
@@ -24,6 +24,7 @@
|
|||||||
"react-text-truncate": "^0.19.0",
|
"react-text-truncate": "^0.19.0",
|
||||||
"react-textarea-autosize": "^8.5.3",
|
"react-textarea-autosize": "^8.5.3",
|
||||||
"react-use": "^17.5.1",
|
"react-use": "^17.5.1",
|
||||||
|
"react-virtuoso": "^4.7.13",
|
||||||
"rewire": "^7.0.0",
|
"rewire": "^7.0.0",
|
||||||
"typescript": "^4.9.5",
|
"typescript": "^4.9.5",
|
||||||
"web-vitals": "^2.1.4"
|
"web-vitals": "^2.1.4"
|
||||||
@@ -17516,6 +17517,18 @@
|
|||||||
"react-dom": "*"
|
"react-dom": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/react-virtuoso": {
|
||||||
|
"version": "4.7.13",
|
||||||
|
"resolved": "https://registry.npmjs.org/react-virtuoso/-/react-virtuoso-4.7.13.tgz",
|
||||||
|
"integrity": "sha512-rabPhipwJ8rdA6TDk1vdVqVoU6eOkWukqoC1pNQVBCsvjBvIeJMi9nO079s0L7EsRzAxFFQNahX+8vuuY4F1Qg==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": ">=16 || >=17 || >= 18",
|
||||||
|
"react-dom": ">=16 || >=17 || >= 18"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/read-cache": {
|
"node_modules/read-cache": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz",
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
"react-text-truncate": "^0.19.0",
|
"react-text-truncate": "^0.19.0",
|
||||||
"react-textarea-autosize": "^8.5.3",
|
"react-textarea-autosize": "^8.5.3",
|
||||||
"react-use": "^17.5.1",
|
"react-use": "^17.5.1",
|
||||||
|
"react-virtuoso": "^4.7.13",
|
||||||
"rewire": "^7.0.0",
|
"rewire": "^7.0.0",
|
||||||
"typescript": "^4.9.5",
|
"typescript": "^4.9.5",
|
||||||
"web-vitals": "^2.1.4"
|
"web-vitals": "^2.1.4"
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { getSyntaxHighlighterStyleFromTheme } from "../utilities/getSyntaxHighli
|
|||||||
import { vscode } from "../utilities/vscode"
|
import { vscode } from "../utilities/vscode"
|
||||||
import ChatRow from "./ChatRow"
|
import ChatRow from "./ChatRow"
|
||||||
import TaskHeader from "./TaskHeader"
|
import TaskHeader from "./TaskHeader"
|
||||||
|
import { Virtuoso, type VirtuosoHandle } from "react-virtuoso"
|
||||||
import Announcement from "./Announcement"
|
import Announcement from "./Announcement"
|
||||||
|
|
||||||
interface ChatViewProps {
|
interface ChatViewProps {
|
||||||
@@ -42,7 +43,8 @@ const ChatView = ({ messages, isHidden, vscodeThemeName, showAnnouncement, hideA
|
|||||||
|
|
||||||
const [syntaxHighlighterStyle, setSyntaxHighlighterStyle] = useState(vsDarkPlus)
|
const [syntaxHighlighterStyle, setSyntaxHighlighterStyle] = useState(vsDarkPlus)
|
||||||
|
|
||||||
const chatContainerRef = useRef<HTMLDivElement>(null)
|
const virtuosoRef = useRef<VirtuosoHandle>(null)
|
||||||
|
|
||||||
const [expandedRows, setExpandedRows] = useState<Record<number, boolean>>({})
|
const [expandedRows, setExpandedRows] = useState<Record<number, boolean>>({})
|
||||||
|
|
||||||
const toggleRowExpansion = (ts: number) => {
|
const toggleRowExpansion = (ts: number) => {
|
||||||
@@ -312,23 +314,16 @@ const ChatView = ({ messages, isHidden, vscodeThemeName, showAnnouncement, hideA
|
|||||||
}, [modifiedMessages])
|
}, [modifiedMessages])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
// We use a setTimeout to ensure new content is rendered before scrolling to the bottom. virtuoso's followOutput would scroll to the bottom before the new content could render.
|
||||||
const timer = setTimeout(() => {
|
const timer = setTimeout(() => {
|
||||||
scrollToBottom()
|
// TODO: we can use virtuoso's isAtBottom to prevent scrolling if user is scrolled up, and show a 'scroll to bottom' button for better UX
|
||||||
}, 0)
|
// NOTE: scroll to bottom may not work if you use margin, see virtuoso's troubleshooting
|
||||||
|
virtuosoRef.current?.scrollTo({ top: Number.MAX_SAFE_INTEGER, behavior: "smooth" })
|
||||||
|
}, 50)
|
||||||
|
|
||||||
return () => clearTimeout(timer)
|
return () => clearTimeout(timer)
|
||||||
}, [visibleMessages])
|
}, [visibleMessages])
|
||||||
|
|
||||||
const scrollToBottom = (instant: boolean = false) => {
|
|
||||||
if (chatContainerRef.current) {
|
|
||||||
const scrollOptions: ScrollToOptions = {
|
|
||||||
top: chatContainerRef.current.scrollHeight,
|
|
||||||
behavior: instant ? "auto" : "smooth",
|
|
||||||
}
|
|
||||||
chatContainerRef.current.scrollTo(scrollOptions)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const placeholderText = useMemo(() => {
|
const placeholderText = useMemo(() => {
|
||||||
if (messages.at(-1)?.ask === "command_output") {
|
if (messages.at(-1)?.ask === "command_output") {
|
||||||
return "Type input to command stdin..."
|
return "Type input to command stdin..."
|
||||||
@@ -376,14 +371,23 @@ const ChatView = ({ messages, isHidden, vscodeThemeName, showAnnouncement, hideA
|
|||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<div
|
<Virtuoso
|
||||||
ref={chatContainerRef}
|
ref={virtuosoRef}
|
||||||
className="scrollable"
|
className="scrollable"
|
||||||
style={{
|
style={{
|
||||||
flexGrow: 1,
|
flexGrow: 1,
|
||||||
overflowY: "scroll", // always show scrollbar
|
overflowY: "scroll", // always show scrollbar
|
||||||
}}>
|
}}
|
||||||
{visibleMessages.map((message, index) => (
|
// followOutput={(isAtBottom) => {
|
||||||
|
// const lastMessage = modifiedMessages.at(-1)
|
||||||
|
// if (lastMessage && shouldShowChatRow(lastMessage)) {
|
||||||
|
// return "smooth"
|
||||||
|
// }
|
||||||
|
// return false
|
||||||
|
// }}
|
||||||
|
increaseViewportBy={{ top: 0, bottom: Number.MAX_SAFE_INTEGER }} // hack to make sure the last message is always rendered to get truly perfect scroll to bottom animation when new messages are added (Number.MAX_SAFE_INTEGER is safe for arithmetic operations, which is all virtuoso uses this value for in src/sizeRangeSystem.ts)
|
||||||
|
data={visibleMessages} // messages is the raw format returned by extension, modifiedMessages is the manipulated structure that combines certain messages of related type, and visibleMessages is the filtered structure that removes messages that should not be rendered
|
||||||
|
itemContent={(index, message) => (
|
||||||
<ChatRow
|
<ChatRow
|
||||||
key={message.ts}
|
key={message.ts}
|
||||||
message={message}
|
message={message}
|
||||||
@@ -393,8 +397,8 @@ const ChatView = ({ messages, isHidden, vscodeThemeName, showAnnouncement, hideA
|
|||||||
lastModifiedMessage={modifiedMessages.at(-1)}
|
lastModifiedMessage={modifiedMessages.at(-1)}
|
||||||
isLast={index === visibleMessages.length - 1}
|
isLast={index === visibleMessages.length - 1}
|
||||||
/>
|
/>
|
||||||
))}
|
)}
|
||||||
</div>
|
/>
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
opacity: primaryButtonText || secondaryButtonText ? (enableButtons ? 1 : 0.5) : 0,
|
opacity: primaryButtonText || secondaryButtonText ? (enableButtons ? 1 : 0.5) : 0,
|
||||||
@@ -430,7 +434,10 @@ const ChatView = ({ messages, isHidden, vscodeThemeName, showAnnouncement, hideA
|
|||||||
disabled={textAreaDisabled}
|
disabled={textAreaDisabled}
|
||||||
onChange={(e) => setInputValue(e.target.value)}
|
onChange={(e) => setInputValue(e.target.value)}
|
||||||
onKeyDown={handleKeyDown}
|
onKeyDown={handleKeyDown}
|
||||||
onHeightChange={() => scrollToBottom(true)}
|
onHeightChange={() =>
|
||||||
|
//virtuosoRef.current?.scrollToIndex({ index: "LAST", align: "end", behavior: "auto" })
|
||||||
|
virtuosoRef.current?.scrollTo({ top: Number.MAX_SAFE_INTEGER, behavior: "auto" })
|
||||||
|
}
|
||||||
placeholder={placeholderText}
|
placeholder={placeholderText}
|
||||||
maxRows={10}
|
maxRows={10}
|
||||||
autoFocus={true}
|
autoFocus={true}
|
||||||
|
|||||||
Reference in New Issue
Block a user