Skip to content

Commit

Permalink
feat: put timestamp under thread name in left panel
Browse files Browse the repository at this point in the history
  • Loading branch information
urmauur committed Jan 28, 2024
1 parent 36a8809 commit 5fe68c1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
15 changes: 12 additions & 3 deletions web/hooks/useSendChatMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export default function useSendChatMessage() {
const instructions = activeThread.assistants[0].instructions ?? ''
const tools = activeThread.assistants[0].tools ?? []

const updatedThread: Thread = {
const initThread: Thread = {
...activeThread,
assistants: [
{
Expand All @@ -189,12 +189,13 @@ export default function useSendChatMessage() {
},
],
}

updateThreadInitSuccess(activeThread.id)
updateThread(updatedThread)
updateThread(initThread)

await extensionManager
.get<ConversationalExtension>(ExtensionTypeEnum.Conversational)
?.saveThread(updatedThread)
?.saveThread(initThread)
}

updateThreadWaiting(activeThread.id, true)
Expand Down Expand Up @@ -326,6 +327,14 @@ export default function useSendChatMessage() {
setFileUpload([])
}

const updatedThread: Thread = {
...activeThread,
updated: timestamp,
}

// cheange last update thread when send message
updateThread(updatedThread)

await extensionManager
.get<ConversationalExtension>(ExtensionTypeEnum.Conversational)
?.addNewMessage(threadMessage)
Expand Down
16 changes: 6 additions & 10 deletions web/screens/Chat/ThreadList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ export default function ThreadList() {
threads.map((thread, i) => {
const lastMessage =
threadStates[thread.id]?.lastMessage ?? 'No new message'

return (
<div
key={i}
Expand All @@ -96,13 +95,10 @@ export default function ThreadList() {
}}
>
<div className="relative z-10 p-4 py-4">
<div className="flex justify-between">
<h2 className="line-clamp-1 font-bold">{thread.title}</h2>
<p className="mb-1 line-clamp-1 text-xs leading-5 text-muted-foreground">
{thread.updated &&
displayDate(new Date(thread.updated).getTime())}
</p>
</div>
<p className="line-clamp-1 text-xs leading-5 text-muted-foreground">
{thread.updated && displayDate(thread.updated)}
</p>
<h2 className="line-clamp-1 font-bold">{thread.title}</h2>
<p className="mt-1 line-clamp-1 text-xs text-gray-700 group-hover/message:max-w-[160px] dark:text-gray-300">
{lastMessage || 'No new message'}
</p>
Expand Down Expand Up @@ -161,9 +157,9 @@ export default function ThreadList() {
<div className="flex cursor-pointer items-center space-x-2 px-4 py-2 hover:bg-secondary">
<Trash2Icon
size={16}
className="text-muted-foreground"
className="text-red-600 dark:text-red-300"
/>
<span className="text-bold text-black dark:text-muted-foreground">
<span className="text-bold text-red-600 dark:text-red-300">
Delete thread
</span>
</div>
Expand Down

0 comments on commit 5fe68c1

Please sign in to comment.