Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
wwayne committed May 30, 2024
1 parent 583c163 commit 74e8f8a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
7 changes: 6 additions & 1 deletion clients/vscode/src/chat/ChatViewProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ export class ChatViewProvider implements WebviewViewProvider {
}

this.client = createClient(webviewView, {
navigate: async () => {},
navigate: async (context: Context) => {
if (context?.filepath && context?.git_url) {
const url = `${context.git_url}/blob/main/${context.filepath}#L${context.range.start}-L${context.range.end}`;
await env.openExternal(Uri.parse(url));
}
},
});

this.agent.on("didChangeStatus", async (status) => {
Expand Down
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

0 comments on commit 74e8f8a

Please sign in to comment.