-
Notifications
You must be signed in to change notification settings - Fork 19
Auto select frontend #112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Auto select frontend #112
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
27d87ef
Add auto-select feature for conversation items in ConversationAccordion
ussaama 52e184b
Implement auto-select functionality across conversation components
ussaama 6723ff6
Enhance ProjectChatRoute with source search and citation display
ussaama be9100f
Refine auto-select logic in ProjectChatRoute
ussaama 53e8772
Add SourcesSearched component to ChatHistoryMessage
ussaama 9605c35
Refactor ChatMessage component and comment out Citations in ProjectCh…
ussaama 55c14d3
Update ChatHistoryMessage and ChatMessage components for improved layout
ussaama 046cda7
Enhance ConversationAccordion with chat mode detection
ussaama 7371b8d
Refactor chat message submission and progress handling in ProjectChat…
ussaama a6b6aa3
Refactor NavigationButton and ConversationAccordion for improved styl…
ussaama 0781361
Update localization files for improved translations and context handling
ussaama 2728473
Update localization files for improved translations and context handling
ussaama 2fba20b
Refactor AutoSelectConversations component to remove projectId prop
ussaama File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,49 @@ | ||
| import { Trans } from "@lingui/react/macro"; | ||
| import { Box, Group, Text } from "@mantine/core"; | ||
| import { IconCheck } from "@tabler/icons-react"; | ||
|
|
||
| type CitationsProps = { | ||
| sources: string[]; | ||
| }; | ||
|
|
||
| const Citations = ({ sources }: CitationsProps) => { | ||
| const maxToShow = 3; | ||
| const visibleSources = sources.slice(0, maxToShow); | ||
| const remainingCount = sources.length - visibleSources.length; | ||
|
|
||
| return ( | ||
| <> | ||
| <Box className="rounded-bl-0 w-fit rounded-br-[0.75rem] rounded-tl-[0.75rem] rounded-tr-[0.75rem] border border-green-500 px-4 py-3"> | ||
| <Group> | ||
| <Box className="rounded-full bg-green-500 p-1"> | ||
| <IconCheck size={16} color="white" /> | ||
| </Box> | ||
| <Text size="sm"> | ||
| <Trans>Searched through the most relevant sources</Trans> | ||
| </Text> | ||
| </Group> | ||
| </Box> | ||
|
|
||
| <Box className="mt-2"> | ||
| <Text size="sm" fw={500}> | ||
| <Trans>Citing the following sources</Trans> | ||
| </Text> | ||
|
|
||
| <Group gap="xs" mt="sm"> | ||
| {visibleSources.map((source, idx) => ( | ||
| <Box key={idx} className="mr-2 rounded bg-gray-100 p-2"> | ||
| <Text size="xs">{source}</Text> | ||
| </Box> | ||
| ))} | ||
| {remainingCount > 0 && ( | ||
| <Box className="rounded bg-gray-100 p-2"> | ||
| <Text size="xs">+{remainingCount} more</Text> | ||
| </Box> | ||
| )} | ||
| </Group> | ||
| </Box> | ||
| </> | ||
| ); | ||
| }; | ||
|
|
||
| export default Citations; |
This file contains hidden or 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,20 @@ | ||
| import { Trans } from "@lingui/react/macro"; | ||
| import { Box, Progress, Text } from "@mantine/core"; | ||
|
|
||
|
|
||
| type SourcesSearchProps = { | ||
| progressValue: number; | ||
| }; | ||
|
|
||
| const SourcesSearch = ({ progressValue }: SourcesSearchProps) => { | ||
| return ( | ||
| <Box className="rounded-bl-0 w-fit rounded-br-[0.75rem] rounded-tl-[0.75rem] rounded-tr-[0.75rem] border border-green-500 px-4 py-3"> | ||
| <Text size="sm" className="mb-2 text-center"> | ||
| <Trans>Searching through the most relevant sources</Trans> | ||
| </Text> | ||
| <Progress value={progressValue} color="green" size="sm" /> | ||
| </Box> | ||
| ); | ||
| }; | ||
|
|
||
| export default SourcesSearch; |
This file contains hidden or 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,20 @@ | ||
| import { Trans } from "@lingui/react/macro"; | ||
| import { Box, Group, Text } from "@mantine/core"; | ||
| import { IconCheck } from "@tabler/icons-react"; | ||
|
|
||
| const SourcesSearched = () => { | ||
| return ( | ||
| <Box className="rounded-bl-0 w-fit rounded-br-[0.75rem] rounded-tl-[0.75rem] rounded-tr-[0.75rem] border border-green-500 px-4 py-3"> | ||
| <Group> | ||
| <Box className="rounded-full bg-green-500 p-1"> | ||
| <IconCheck size={16} color="white" /> | ||
| </Box> | ||
| <Text size="sm"> | ||
| <Trans>Searched through the most relevant sources</Trans> | ||
| </Text> | ||
| </Group> | ||
| </Box> | ||
| ); | ||
| }; | ||
|
|
||
| export default SourcesSearched; |
This file contains hidden or 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
49 changes: 49 additions & 0 deletions
49
echo/frontend/src/components/conversation/AutoSelectConversations.tsx
This file contains hidden or 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,49 @@ | ||
| import { useAddChatContextMutation, useDeleteChatContextMutation, useProjectChatContext } from "@/lib/query"; | ||
| import { Trans } from "@lingui/react/macro"; | ||
| import { Box, Checkbox, Group, Stack, Text } from "@mantine/core"; | ||
| import { useParams } from "react-router-dom"; | ||
|
|
||
| export const AutoSelectConversations = () => { | ||
| const { chatId } = useParams(); | ||
| const projectChatContextQuery = useProjectChatContext(chatId ?? ""); | ||
| const addChatContextMutation = useAddChatContextMutation(); | ||
| const deleteChatContextMutation = useDeleteChatContextMutation(); | ||
| // Get the auto_select_bool value from the chat context | ||
| const autoSelect = projectChatContextQuery.data?.auto_select_bool ?? false; | ||
| const handleCheckboxChange = (checked: boolean) => { | ||
| if (checked) { | ||
| addChatContextMutation.mutate({ | ||
| chatId: chatId ?? "", | ||
| auto_select_bool: true | ||
| }); | ||
| } else { | ||
| deleteChatContextMutation.mutate({ | ||
| chatId: chatId ?? "", | ||
| auto_select_bool: false | ||
| }); | ||
| } | ||
| }; | ||
| return ( | ||
| <Box | ||
| className="cursor-pointer border border-gray-200 hover:bg-gray-50" | ||
| > | ||
| <Group justify="space-between" p="md" wrap="nowrap"> | ||
| <Stack gap="xs"> | ||
| <Text className="font-medium"> | ||
| <Trans>Auto-select</Trans> | ||
| </Text> | ||
| <Text size="xs" c="gray.6"> | ||
| <Trans>Auto-select sources to add to the chat</Trans> | ||
| </Text> | ||
| </Stack> | ||
| <Checkbox | ||
| size="md" | ||
| checked={autoSelect} | ||
| color="green" | ||
| onClick={(e) => e.stopPropagation()} | ||
| onChange={(e) => handleCheckboxChange(e.currentTarget.checked)} | ||
| /> | ||
| </Group> | ||
| </Box> | ||
| ); | ||
| }; |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.