-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1826 from stakwork/feature/ui-updates
feat: remove latest on ai chat, fix ui issues
- Loading branch information
Showing
11 changed files
with
136 additions
and
97 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { useEffect, useState } from 'react' | ||
import styled from 'styled-components' | ||
import { Flex } from '~/components/common/Flex' | ||
import { Text } from '~/components/common/Text' | ||
|
||
type Props = { | ||
answer: string | ||
} | ||
|
||
const Wrapper = styled(Flex).attrs({ | ||
direction: 'column', | ||
})` | ||
padding: 1.5rem; | ||
gap: 1rem; | ||
` | ||
|
||
const SummaryText = styled(Text)` | ||
font-size: 14px; | ||
font-weight: 400; | ||
line-height: 19.6px; | ||
` | ||
|
||
export const AiAnswer = ({ answer }: Props) => { | ||
const [displayedText, setDisplayedText] = useState('') | ||
|
||
useEffect(() => { | ||
let timeoutId: NodeJS.Timeout | ||
|
||
if (!answer) { | ||
return | ||
} | ||
|
||
if (displayedText.length < answer.length) { | ||
timeoutId = setTimeout(() => { | ||
setDisplayedText(answer.slice(0, displayedText.length + 1)) | ||
}, 10) | ||
|
||
// eslint-disable-next-line consistent-return | ||
return () => clearTimeout(timeoutId) | ||
} | ||
}, [answer, displayedText]) | ||
|
||
return ( | ||
<Wrapper> | ||
<SummaryText>{displayedText}</SummaryText> | ||
</Wrapper> | ||
) | ||
} |
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
72 changes: 0 additions & 72 deletions
72
src/components/App/SideBar/AiSummary/AiSummaryDetail/index.tsx
This file was deleted.
Oops, something went wrong.
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,35 @@ | ||
import styled from 'styled-components' | ||
import { Flex } from '~/components/common/Flex' | ||
import { Text } from '~/components/common/Text' | ||
import { AIEntity } from '~/types' | ||
import { EpisodeSkeleton } from '../Relevance/EpisodeSkeleton' | ||
import { AiAnswer } from './AiAnswer' | ||
import { AiQuestions } from './AiQuestions' | ||
import { AiSources } from './AiSources' | ||
import { AiSummarySkeleton } from './AiSummarySkeleton' | ||
|
||
type Props = { | ||
question: string | ||
response: AIEntity | ||
} | ||
|
||
const Title = styled(Text)` | ||
font-size: 20px; | ||
font-weight: 600; | ||
padding: 24px 24px 0; | ||
` | ||
|
||
export const AiSummary = ({ question, response }: Props) => ( | ||
<Wrapper> | ||
<Title>{question}</Title> | ||
{response.answerLoading ? <AiSummarySkeleton /> : <AiAnswer answer={response.answer || ''} />} | ||
{response.sourcesLoading ? <EpisodeSkeleton count={1} /> : <AiSources sourceIds={response.sources || []} />} | ||
{response.questionsLoading ? <EpisodeSkeleton count={1} /> : <AiQuestions questions={response.questions || []} />} | ||
</Wrapper> | ||
) | ||
|
||
const Wrapper = styled(Flex).attrs({ | ||
direction: 'column', | ||
})` | ||
border-top: 1px solid #101317; | ||
` |
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