Skip to content

Commit

Permalink
[autofix.ci] apply automated fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
autofix-ci[bot] authored Nov 19, 2024
1 parent b40ea3c commit 73fb409
Showing 1 changed file with 64 additions and 48 deletions.
112 changes: 64 additions & 48 deletions ee/tabby-ui/app/search/components/assistant-message-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ import {
IconBlocks,
IconBug,
IconChevronRight,
IconCircleDot,
IconEdit,
IconGitPullRequest,
IconLayers,
IconPlus,
IconRefresh,
IconRemove,
IconSparkles,
IconSpinner,
IconTrash
Expand All @@ -53,6 +54,7 @@ import {
TooltipContent,
TooltipTrigger
} from '@/components/ui/tooltip'
import { ChatContext } from '@/components/chat/chat'
import { CodeReferences } from '@/components/chat/code-references'
import { CopyButton } from '@/components/copy-button'
import {
Expand All @@ -62,7 +64,6 @@ import {
} from '@/components/message-markdown'

import { ConversationMessage, SearchContext, SOURCE_CARD_STYLE } from './search'
import { ChatContext } from '@/components/chat/chat'

export function AssistantMessageSection({
message,
Expand Down Expand Up @@ -92,7 +93,7 @@ export function AssistantMessageSection({
onUpdateMessage
} = useContext(SearchContext)

const {serverCapabilities}= useContext(ChatContext)
const { serverCapabilities } = useContext(ChatContext)

const [isEditing, setIsEditing] = useState(false)
const [showMoreSource, setShowMoreSource] = useState(false)
Expand Down Expand Up @@ -424,9 +425,7 @@ function SourceCard({
conversationId,
source,
showMore,
showDevTooltip,
isDeletable,
onDelete
showDevTooltip
}: {
conversationId: string
source: AttachmentDocItem
Expand All @@ -436,7 +435,6 @@ function SourceCard({
onDelete?: () => void
}) {
const { setDevPanelOpen, setConversationIdForDev } = useContext(SearchContext)
const { hostname } = new URL(source.link)
const [devTooltipOpen, setDevTooltipOpen] = useState(false)

const onOpenChange = (v: boolean) => {
Expand Down Expand Up @@ -467,47 +465,7 @@ function SourceCard({
}}
onClick={() => window.open(source.link)}
>
{isDeletable && (
<div className="absolute -right-1.5 -top-2">
<Button
size="icon"
variant="secondary"
className="h-4 w-4 rounded-full border"
onClick={e => {
e.stopPropagation()
onDelete?.()
}}
>
<IconRemove className="h-3 w-3" />
</Button>
</div>
)}
<div className="flex flex-1 flex-col justify-between gap-y-1">
<div className="flex flex-col gap-y-0.5">
<p className="line-clamp-1 w-full overflow-hidden text-ellipsis break-all text-xs font-semibold">
{source.title}
</p>
<p
className={cn(
' w-full overflow-hidden text-ellipsis break-all text-xs text-muted-foreground',
{
'line-clamp-2': showMore,
'line-clamp-1': !showMore
}
)}
>
{normalizedText(getContent(source))}
</p>
</div>
<div className="flex items-center text-xs text-muted-foreground">
<div className="flex w-full flex-1 items-center">
<SiteFavicon hostname={hostname} />
<p className="ml-1 overflow-hidden text-ellipsis">
{hostname.replace('www.', '').split('/')[0]}
</p>
</div>
</div>
</div>
<SourceCardContent source={source} showMore={showMore} />
</div>
</TooltipTrigger>
<TooltipContent
Expand All @@ -521,6 +479,64 @@ function SourceCard({
)
}

function SourceCardContent({
source,
showMore
}: {
source: AttachmentDocItem
showMore: boolean
}) {
const { hostname } = new URL(source.link)

const isIssue = source.__typename === 'MessageAttachmentIssueDoc'
const isPR = source.__typename === 'MessageAttachmentPullDoc'

return (
<div className="flex flex-1 flex-col justify-between gap-y-1">
<div className="flex flex-col gap-y-0.5">
<p className="line-clamp-1 w-full overflow-hidden text-ellipsis break-all text-xs font-semibold">
{source.title}
</p>
<p
className={cn(
' w-full overflow-hidden text-ellipsis break-all text-xs text-muted-foreground',
{
'line-clamp-2': showMore,
'line-clamp-1': !showMore
}
)}
>
{normalizedText(getContent(source))}
</p>
</div>
<div className="flex items-center text-xs text-muted-foreground">
<div className="flex w-full flex-1 items-center justify-between gap-1">
<div className="flex items-center">
<SiteFavicon hostname={hostname} />
<p className="ml-1 truncate">
{hostname.replace('www.', '').split('/')[0]}
</p>
</div>
<div className="flex shrink-0 items-center gap-1">
{isIssue && (
<>
<IconCircleDot className="h-3.5 w-3.5" />
<span>{source.closed ? 'Closed' : 'Not closed'}</span>
</>
)}
{isPR && (
<>
<IconGitPullRequest className="h-3.5 w-3.5" />
{source.merged ? 'Merged' : 'Not merged'}
</>
)}
</div>
</div>
</div>
</div>
)
}

function MessageContentForm({
message,
onCancel,
Expand Down

0 comments on commit 73fb409

Please sign in to comment.