Skip to content

Commit

Permalink
fix(ui): navigate to default branch path on clicking code references …
Browse files Browse the repository at this point in the history
…in code browser (#2684)
  • Loading branch information
liangfung authored Jul 18, 2024
1 parent cde18e3 commit 27831f3
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions ee/tabby-ui/app/files/components/chat-side-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,11 @@ export const ChatSideBar: React.FC<ChatSideBarProps> = ({
...props
}) => {
const [{ data }] = useMe()
const {
pendingEvent,
setPendingEvent,
repoMap,
activeRepoRef,
updateActivePath
} = React.useContext(SourceCodeBrowserContext)
const { pendingEvent, setPendingEvent, repoMap, updateActivePath } =
React.useContext(SourceCodeBrowserContext)
const activeChatId = useStore(useChatStore, state => state.activeChatId)
const iframeRef = React.useRef<HTMLIFrameElement>(null)
const repoMapRef = useLatest(repoMap)
const latestRepoRef = useLatest(activeRepoRef)
const onNavigate = async (context: Context) => {
if (context?.filepath && context?.git_url) {
const lineHash = formatLineHashForCodeBrowser(context?.range)
Expand All @@ -46,10 +40,8 @@ export const ChatSideBar: React.FC<ChatSideBarProps> = ({
const targetRepo = repoMap[matchedRepositoryKey]
if (targetRepo) {
const defaultRef = getDefaultRepoRef(targetRepo.refs)
// use curernt rev, and use defaultRev as fallback
const refName =
latestRepoRef?.current?.name ||
resolveRepoRef(defaultRef ?? '')?.name
// navigate to files of the default branch
const refName = resolveRepoRef(defaultRef ?? '')?.name
updateActivePath(
generateEntryPath(
targetRepo,
Expand Down

0 comments on commit 27831f3

Please sign in to comment.