Skip to content

Commit

Permalink
update: simpify
Browse files Browse the repository at this point in the history
  • Loading branch information
liangfung committed Dec 23, 2024
1 parent dd8608d commit be2faf1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
4 changes: 1 addition & 3 deletions ee/tabby-ui/app/files/components/chat-side-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ export const ChatSideBar: React.FC<ChatSideBarProps> = ({
const repoMapRef = useLatest(repoMap)
const onNavigate = async (context: Context) => {
if (context?.filepath && context?.git_url) {
const lineHash = context.range
? undefined
: formatLineHashForCodeBrowser(context?.range)
const lineHash = formatLineHashForCodeBrowser(context?.range)
const repoMap = repoMapRef.current
const matchedRepositoryKey = find(
Object.keys(repoMap),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,7 @@ export function AssistantMessageSection({
searchParams.append('redirect_git_url', ctx.git_url)
url.search = searchParams.toString()

const lineHash = ctx.range
? formatLineHashForCodeBrowser({
start: ctx.range.start,
end: ctx.range.end
})
: undefined
const lineHash = formatLineHashForCodeBrowser(ctx.range)
if (lineHash) {
url.hash = lineHash
}
Expand Down Expand Up @@ -240,7 +235,7 @@ export function AssistantMessageSection({
searchParams.append('redirect_git_url', code.gitUrl)
url.search = searchParams.toString()

const lineHash = range ? formatLineHashForCodeBrowser(range) : undefined
const lineHash = formatLineHashForCodeBrowser(range)
if (lineHash) {
url.hash = lineHash
}
Expand Down
4 changes: 2 additions & 2 deletions ee/tabby-ui/lib/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export function getRangeFromAttachmentCode(code: {
startLine?: Maybe<number>
content: string
}): LineRange | undefined {
if (!code?.startLine || typeof code.startLine !== 'number') return undefined
if (!code?.startLine) return undefined

const start = code.startLine
const lineCount = code.content.split('\n').length
Expand All @@ -126,7 +126,7 @@ export function getRangeFromAttachmentCode(code: {

export function getRangeTextFromAttachmentCode(code: AttachmentCodeItem) {
const range = getRangeFromAttachmentCode(code)
return range ? formatLineHashForCodeBrowser(range) : ''
return formatLineHashForCodeBrowser(range)
}

export function getContent(item: AttachmentDocItem) {
Expand Down

0 comments on commit be2faf1

Please sign in to comment.