-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: right side quick filters will be applied based on the main filters
- Loading branch information
1 parent
d85316a
commit bc720ec
Showing
47 changed files
with
709 additions
and
294 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 12 additions & 4 deletions
16
apps/webapp/src/hooks/conversations/use-conversation-history.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,22 @@ | ||
import { sort } from 'fast-sort'; | ||
import React from 'react'; | ||
|
||
import type { ConversationHistoryType } from 'common/types'; | ||
|
||
import { useContextStore } from 'store/global-context-provider'; | ||
|
||
export const useConversationHistory = (conversationId: string) => { | ||
const { conversationHistoryStore } = useContextStore(); | ||
|
||
return React.useMemo(() => { | ||
return conversationHistoryStore.getConversationHistoryForConversation( | ||
conversationId, | ||
); | ||
const conversationHistory = | ||
conversationHistoryStore.getConversationHistoryForConversation( | ||
conversationId, | ||
); | ||
return sort(conversationHistory).asc( | ||
(co: ConversationHistoryType) => new Date(co.createdAt), | ||
) as ConversationHistoryType[]; | ||
|
||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [conversationId]); | ||
}, [conversationId, conversationHistoryStore.conversationHistory.length]); | ||
}; |
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { UserTypeEnum } from '@tegonhq/types'; | ||
import { defaultExtensions } from '@tegonhq/ui/components/ui/editor/editor-extensions'; | ||
import { AI } from '@tegonhq/ui/icons'; | ||
import { Editor } from '@tiptap/core'; | ||
import { observer } from 'mobx-react-lite'; | ||
import React, { useEffect, useRef } from 'react'; | ||
|
||
import type { ConversationHistoryType } from 'common/types'; | ||
import { UserAvatar } from 'common/user-avatar'; | ||
|
||
import { useUserData } from 'hooks/users'; | ||
|
||
interface AIConversationItemProps { | ||
conversationHistory: ConversationHistoryType; | ||
} | ||
|
||
export const ConversationItem = observer( | ||
({ conversationHistory }: AIConversationItemProps) => { | ||
const { user } = useUserData(conversationHistory.userId); | ||
const id = `a${conversationHistory.id.replace(/-/g, '')}`; | ||
const editorRef = useRef<Editor | null>(null); | ||
|
||
useEffect(() => { | ||
const element = document.getElementById(id); | ||
let editor: Editor; | ||
|
||
if (element) { | ||
editor = new Editor({ | ||
element, | ||
extensions: defaultExtensions, | ||
editable: false, | ||
}); | ||
editorRef.current = editor; | ||
|
||
editor.commands.setContent(conversationHistory.message, false, { | ||
preserveWhitespace: true, | ||
}); | ||
} | ||
// Clean up on unmount | ||
return () => { | ||
editor && editor.destroy(); | ||
}; | ||
}, [id, conversationHistory.message]); | ||
|
||
const getIcon = () => { | ||
if (conversationHistory.userType === UserTypeEnum.User) { | ||
return <UserAvatar user={user} />; | ||
} | ||
|
||
return <AI size={16} />; | ||
}; | ||
|
||
return ( | ||
<div className="flex px-3 gap-2 border-b border-border py-4"> | ||
<div className="shrink-0">{getIcon()}</div> | ||
|
||
<div id={id}></div> | ||
</div> | ||
); | ||
}, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Button } from '@tegonhq/ui/components/ui/button'; | ||
import { Textarea } from '@tegonhq/ui/components/ui/textarea'; | ||
import { SendLine } from '@tegonhq/ui/icons'; | ||
import { useState } from 'react'; | ||
|
||
interface ConversationTextareaProps { | ||
onSend: (value: string) => void; | ||
} | ||
|
||
export function ConversationTextarea({ onSend }: ConversationTextareaProps) { | ||
const [text, setText] = useState(''); | ||
|
||
return ( | ||
<div className="p-3 px-5 relative"> | ||
<Textarea | ||
className="bg-transparent border border-border max-h-[500px]" | ||
rows={1} | ||
value={text} | ||
autoFocus | ||
onChange={(e) => setText(e.currentTarget.value)} | ||
placeholder="Ask AI anything..." | ||
/> | ||
<Button | ||
variant="ghost" | ||
className="transition-all duration-500 ease-in-out my-2 absolute bottom-2 right-6" | ||
type="submit" | ||
onClick={() => { | ||
onSend(text); | ||
setText(''); | ||
}} | ||
> | ||
<SendLine size={20} /> | ||
</Button> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.