Skip to content

Commit d278a7a

Browse files
authored
fix(ui): resolve missing code source in answer engine (#4034)
* fix(ui): resolve missing code source in answer engine * update: threadRelevantQuestions
1 parent 53d151b commit d278a7a

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

ee/tabby-ui/app/(home)/page.tsx

+11-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useEffect, useLayoutEffect, useRef, useState } from 'react'
44
import Image from 'next/image'
55
import { useRouter } from 'next/navigation'
66
import tabbyUrl from '@/assets/logo-dark.png'
7+
import { compact } from 'lodash-es'
78
import { useQuery } from 'urql'
89
import { useStore } from 'zustand'
910

@@ -95,7 +96,14 @@ function MainPanel() {
9596
setIsLoading(true)
9697
updatePendingUserMessage({
9798
content: question,
98-
context
99+
context: {
100+
...context,
101+
codeSourceId: selectedRepository?.id,
102+
docSourceIds: compact([
103+
selectedRepository?.id,
104+
...(context?.docSourceIds ?? [])
105+
])
106+
}
99107
})
100108
router.push('/search')
101109
}
@@ -105,8 +113,8 @@ function MainPanel() {
105113
updatePendingUserMessage({
106114
content: question,
107115
context: {
108-
docSourceIds: [sourceId as string],
109-
codeSourceIds: [sourceId as string],
116+
docSourceIds: [sourceId],
117+
codeSourceId: sourceId,
110118
modelName: selectedModel
111119
}
112120
})

ee/tabby-ui/app/search/components/search.tsx

+4-8
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,6 @@ export function Search() {
360360
initializing.current = true
361361

362362
if (pendingUserMessage?.content) {
363-
// setIsReady(true)
364363
onSubmitSearch(pendingUserMessage.content, pendingUserMessage.context)
365364
updatePendingUserMessage(undefined)
366365
return
@@ -1031,20 +1030,17 @@ function getSourceInputs(
10311030
repositorySourceId: string | undefined,
10321031
ctx: ThreadRunContexts | undefined
10331032
) {
1034-
let sourceIdsForDocQuery: string[] = []
1035-
let sourceIdForCodeQuery: string | undefined
1033+
let sourceIdsForDocQuery: string[] = compact([repositorySourceId])
1034+
let sourceIdForCodeQuery: string | undefined = repositorySourceId
10361035
let searchPublic = false
10371036

10381037
if (ctx) {
10391038
sourceIdsForDocQuery = uniq(
10401039
// Compatible with existing user messages
1041-
compact(
1042-
[repositorySourceId, ctx?.codeSourceIds?.[0]].concat(ctx.docSourceIds)
1043-
)
1040+
compact([repositorySourceId, ctx?.codeSourceId].concat(ctx.docSourceIds))
10441041
)
10451042
searchPublic = ctx.searchPublic ?? false
1046-
sourceIdForCodeQuery =
1047-
repositorySourceId || ctx.codeSourceIds?.[0] || undefined
1043+
sourceIdForCodeQuery = repositorySourceId || ctx.codeSourceId || undefined
10481044
}
10491045
return {
10501046
sourceIdsForDocQuery,

ee/tabby-ui/lib/types/chat.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,11 @@ type MergeUnionType<T> = {
116116
[k in Keys<T>]?: Pick<T, k>
117117
}
118118

119-
export type ThreadRunContexts = {
119+
export interface ThreadRunContexts {
120120
modelName?: string
121121
searchPublic?: boolean
122122
docSourceIds?: string[]
123-
codeSourceIds?: string[]
123+
codeSourceId?: string
124124
}
125125

126126
export interface RelevantCodeContext extends Context {

0 commit comments

Comments
 (0)