From b3d2453e7fbc9a6bdc13a2611fb5be75db9f654d Mon Sep 17 00:00:00 2001 From: Mathew Pareles Date: Sun, 12 Jan 2025 19:02:26 -0800 Subject: [PATCH] history style --- .../react/src/sidebar-tsx/SidebarChat.tsx | 1 - .../src/sidebar-tsx/SidebarThreadSelector.tsx | 109 ++++++++++-------- 2 files changed, 64 insertions(+), 46 deletions(-) diff --git a/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx b/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx index f1c6f391..db450b95 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx @@ -51,7 +51,6 @@ export const IconX = ({ size, className = '', ...props }: { size: number, classN ); }; - const IconArrowUp = ({ size, className = '' }: { size: number, className?: string }) => { return ( { @@ -31,61 +32,79 @@ export const SidebarThreadSelector = () => { const sortedThreadIds = Object.keys(allThreads ?? {}).sort((threadId1, threadId2) => allThreads![threadId1].lastModified > allThreads![threadId2].lastModified ? -1 : 1) return ( -
+
- {/* X button at top right */} -
-
{/* a list of all the past threads */} -
- {sortedThreadIds.map((threadId) => { - if (!allThreads) - return <>Error: Threads not found. - const pastThread = allThreads[threadId] - let firstMsg: string | null = null - let secondMsg: string | null = null +
+
    + {sortedThreadIds.map((threadId) => { + if (!allThreads) { + return
  • {`No history found.`}
  • ; + } - const firstMsgIdx = allThreads[threadId].messages.findIndex(msg => msg.role !== 'system' && !!msg.displayContent) ?? '' - if (firstMsgIdx !== -1) - firstMsg = truncate(allThreads[threadId].messages[firstMsgIdx].displayContent ?? '') - else - firstMsg = '""' + const pastThread = allThreads[threadId]; + let firstMsg = null; + let secondMsg = null; - const secondMsgIdx = allThreads[threadId].messages.findIndex((msg, i) => msg.role !== 'system' && !!msg.displayContent && i > firstMsgIdx) ?? '' - if (secondMsgIdx !== -1) - secondMsg = truncate(allThreads[threadId].messages[secondMsgIdx].displayContent ?? '') + const firstMsgIdx = pastThread.messages.findIndex( + (msg) => msg.role !== 'system' && !!msg.displayContent + ); - const numMessages = allThreads[threadId].messages.filter((msg, i) => msg.role !== 'system').length + if (firstMsgIdx !== -1) { + firstMsg = truncate(pastThread.messages[firstMsgIdx].displayContent ?? ''); + } else { + firstMsg = '""'; + } - return ( - - ) - })} -
+ const secondMsgIdx = pastThread.messages.findIndex( + (msg, i) => msg.role !== 'system' && !!msg.displayContent && i > firstMsgIdx + ); + + if (secondMsgIdx !== -1) { + secondMsg = truncate(pastThread.messages[secondMsgIdx].displayContent ?? ''); + } + + const numMessages = pastThread.messages.filter( + (msg) => msg.role !== 'system' + ).length; + + return ( +
  • + +
  • + ); + })} + +
    )