Skip to content
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

fix(vscode): chat panel reference opening local code browser #2298

Merged
merged 3 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ee/tabby-ui/app/chat/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export default function ChatPage() {
onLoaded={onChatLoaded}
maxWidth={maxWidth}
onCopyContent={from === 'vscode' ? onCopyContent : undefined}
isReferenceClickable={from !== 'vscode'}
/>
)
}
8 changes: 6 additions & 2 deletions ee/tabby-ui/components/chat/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type ChatContextValue = {
onClearMessages: () => void
container?: HTMLDivElement
onCopyContent?: (value: string) => void
isReferenceClickable: boolean
}

export const ChatContext = React.createContext<ChatContextValue>(
Expand Down Expand Up @@ -118,6 +119,7 @@ interface ChatProps extends React.ComponentProps<'div'> {
welcomeMessage?: string
promptFormClassname?: string
onCopyContent?: (value: string) => void
isReferenceClickable?: boolean
}

function ChatRenderer(
Expand All @@ -137,7 +139,8 @@ function ChatRenderer(
maxWidth,
welcomeMessage,
promptFormClassname,
onCopyContent
onCopyContent,
isReferenceClickable = true
}: ChatProps,
ref: React.ForwardedRef<ChatRef>
) {
Expand Down Expand Up @@ -384,7 +387,8 @@ function ChatRenderer(
handleMessageAction,
onClearMessages,
container,
onCopyContent
onCopyContent,
isReferenceClickable
}}
>
<div className="flex justify-center overflow-x-hidden">
Expand Down
12 changes: 9 additions & 3 deletions ee/tabby-ui/components/chat/question-answer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,8 @@ interface ContextReferencesProps {
contexts: Context[]
}
const CodeReferences = ({ contexts }: ContextReferencesProps) => {
const { onNavigateToContext } = React.useContext(ChatContext)
const { onNavigateToContext, isReferenceClickable } =
React.useContext(ChatContext)
const isMultipleReferences = contexts?.length > 1

if (!contexts?.length) return null
Expand Down Expand Up @@ -421,9 +422,14 @@ const CodeReferences = ({ contexts }: ContextReferencesProps) => {
.join('/')
return (
<div
className="cursor-pointer rounded-md border p-2 hover:bg-accent"
className={cn('rounded-md border p-2 hover:bg-accent', {
'cursor-pointer': isReferenceClickable,
'cursor-default pointer-events-auto': !isReferenceClickable
})}
key={index}
onClick={e => onNavigateToContext?.(item)}
onClick={e =>
isReferenceClickable && onNavigateToContext?.(item)
}
>
<div className="flex items-center gap-1 overflow-x-auto">
<IconFile className="shrink-0" />
Expand Down