Fix row collapse logic

This commit is contained in:
Saoud Rizwan
2024-09-24 13:17:09 -04:00
parent c2aff91973
commit 8b69e2a8b5

View File

@@ -384,7 +384,8 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
const isCollapsing = expandedRows[ts] ?? false const isCollapsing = expandedRows[ts] ?? false
const isLast = visibleMessages.at(-1)?.ts === ts const isLast = visibleMessages.at(-1)?.ts === ts
const isSecondToLast = visibleMessages.at(-2)?.ts === ts const isSecondToLast = visibleMessages.at(-2)?.ts === ts
const isLastCollapsed = !expandedRows[visibleMessages.at(-1)?.ts ?? 0] const isLastCollapsedApiReq =
visibleMessages.at(-1)?.say === "api_req_started" && !expandedRows[visibleMessages.at(-1)?.ts ?? 0]
setExpandedRows((prev) => ({ setExpandedRows((prev) => ({
...prev, ...prev,
[ts]: !prev[ts], [ts]: !prev[ts],
@@ -400,7 +401,7 @@ const ChatView = ({ isHidden, showAnnouncement, hideAnnouncement, showHistoryVie
return () => clearTimeout(timer) return () => clearTimeout(timer)
} else if (isLast || isSecondToLast) { } else if (isLast || isSecondToLast) {
if (isCollapsing) { if (isCollapsing) {
if (isSecondToLast && !isLastCollapsed) { if (isSecondToLast && !isLastCollapsedApiReq) {
return return
} }
const timer = setTimeout(() => { const timer = setTimeout(() => {