From 27831f30aedfbe1d88900cadeb4c5aecb4d1db8b Mon Sep 17 00:00:00 2001 From: aliang <1098486429@qq.com> Date: Thu, 18 Jul 2024 16:17:13 +0800 Subject: [PATCH] fix(ui): navigate to default branch path on clicking code references in code browser (#2684) --- .../app/files/components/chat-side-bar.tsx | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/ee/tabby-ui/app/files/components/chat-side-bar.tsx b/ee/tabby-ui/app/files/components/chat-side-bar.tsx index 745cf92c095..bd70f9074fa 100644 --- a/ee/tabby-ui/app/files/components/chat-side-bar.tsx +++ b/ee/tabby-ui/app/files/components/chat-side-bar.tsx @@ -23,17 +23,11 @@ export const ChatSideBar: React.FC = ({ ...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(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) @@ -46,10 +40,8 @@ export const ChatSideBar: React.FC = ({ 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,