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 27, 2024
1 parent 8380c9a commit c19c987
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 49 deletions.
2 changes: 1 addition & 1 deletion clients/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -494,4 +494,4 @@
"typescript": "^5.3.2",
"vscode-languageclient": "^9.0.1"
}
}
}
122 changes: 74 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 @@ -37,12 +37,15 @@ import {
import {
IconBlocks,
IconBug,
IconCheckCircled,
IconChevronRight,
IconCircleDot,
IconEdit,
IconGitMerge,
IconGitPullRequest,
IconLayers,
IconPlus,
IconRefresh,
IconRemove,
IconSparkles,
IconSpinner,
IconTrash
Expand All @@ -53,6 +56,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 +66,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 +95,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 +427,7 @@ function SourceCard({
conversationId,
source,
showMore,
showDevTooltip,
isDeletable,
onDelete
showDevTooltip
}: {
conversationId: string
source: AttachmentDocItem
Expand All @@ -436,7 +437,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 +467,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 +481,72 @@ 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 && (
<>
{source.closed ? (
<IconCheckCircled className="h-3.5 w-3.5" />
) : (
<IconCircleDot className="h-3.5 w-3.5" />
)}
<span>{source.closed ? 'Closed' : 'Open'}</span>
</>
)}
{isPR && (
<>
{source.merged ? (
<IconGitMerge className="h-3.5 w-3.5" />
) : (
<IconGitPullRequest className="h-3.5 w-3.5" />
)}
{source.merged ? 'Merged' : 'Open'}
</>
)}
</div>
</div>
</div>
</div>
)
}

function MessageContentForm({
message,
onCancel,
Expand Down

0 comments on commit c19c987

Please sign in to comment.