Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tabby-ui): add mention functionality in tabby chat ui #3607

Merged
merged 24 commits into from
Jan 17, 2025
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0d0c81a
feat(chat): add mention functionality with category selection and sty…
Sma1lboy Dec 21, 2024
3eea537
feat(chat): implement mention functionality with category support and…
Sma1lboy Dec 24, 2024
d491b37
feat(chat): add input management methods to PromptFormRef interface
Sma1lboy Dec 24, 2024
a5f01c6
refactor(chat): remove unused FileList, CategoryMenu, mention compone…
Sma1lboy Dec 24, 2024
f9b5bc4
refactor(chat): Revert Webviewhelper to a previous version
Sma1lboy Dec 24, 2024
0468316
Merge branch 'main' into feat-at-function-in-tabby-ui
Sma1lboy Jan 9, 2025
96e6ecb
refactor(chat): remove unused mention components and styles
Sma1lboy Jan 10, 2025
7d10eed
refactor(chat): remove PopoverMentionList component and its associate…
Sma1lboy Jan 10, 2025
c6b2413
[autofix.ci] apply automated fixes
autofix-ci[bot] Jan 10, 2025
b0eac5f
refactor(chat): enhance at-mention handling and improve file item pro…
Sma1lboy Jan 13, 2025
5f0a8d2
refactor(chat): implement file mention functionality and enhance ment…
Sma1lboy Jan 13, 2025
088a9aa
chore: fix some potential normalize issue
Sma1lboy Jan 13, 2025
52de94d
refactor(chat): update chatInputRef type to use PromptFormRef for imp…
Sma1lboy Jan 13, 2025
08f3175
Merge branch 'main' into feat-at-function-in-tabby-ui
Sma1lboy Jan 14, 2025
f2aaba0
update
liangfung Jan 15, 2025
39daf96
[autofix.ci] apply automated fixes
autofix-ci[bot] Jan 15, 2025
6bedc1e
update
liangfung Jan 15, 2025
41685d8
fix(chat): update fileItemToSourceItem to handle filepath extraction …
Sma1lboy Jan 16, 2025
e7a0c11
update
liangfung Jan 17, 2025
db1fab5
Merge branch 'main' into feat-at-function-in-tabby-ui
liangfung Jan 17, 2025
2a00236
[autofix.ci] apply automated fixes
autofix-ci[bot] Jan 17, 2025
6187bff
update
liangfung Jan 17, 2025
2dd4430
updae
liangfung Jan 17, 2025
5087067
[autofix.ci] apply automated fixes
autofix-ci[bot] Jan 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'main' into feat-at-function-in-tabby-ui
liangfung authored Jan 17, 2025
commit db1fab51a765a35b6c7833db6aea028676326c67
19 changes: 19 additions & 0 deletions ee/tabby-ui/app/chat/page.tsx
Original file line number Diff line number Diff line change
@@ -80,6 +80,10 @@ export default function ChatPage() {
supportsReadWorkspaceGitRepoInfo,
setSupportsReadWorkspaceGitRepoInfo
] = useState(false)
const [
supportsStoreAndFetchSessionState,
setSupportsStoreAndFetchSessionState
] = useState(false)
const [supportsListFileInWorkspace, setSupportProvideFileAtInfo] =
useState(false)
const [supportsReadFileContent, setSupportsReadFileContent] = useState(false)
@@ -254,6 +258,15 @@ export default function ChatPage() {
server
?.hasCapability('readFileContent')
.then(setSupportsReadFileContent)

Promise.all([
server?.hasCapability('fetchSessionState'),
server?.hasCapability('storeSessionState')
]).then(results => {
setSupportsStoreAndFetchSessionState(
results.every(result => !!result)
)
})
}

checkCapabilities().then(() => {
@@ -445,6 +458,12 @@ export default function ChatPage() {
: undefined
}
getActiveEditorSelection={getActiveEditorSelection}
fetchSessionState={
supportsStoreAndFetchSessionState ? fetchSessionState : undefined
}
storeSessionState={
supportsStoreAndFetchSessionState ? storeSessionState : undefined
}
listFileInWorkspace={
isInEditor && supportsListFileInWorkspace
? server?.listFileInWorkspace
33 changes: 32 additions & 1 deletion ee/tabby-ui/components/chat/chat.tsx
Original file line number Diff line number Diff line change
@@ -138,12 +138,26 @@ interface ChatProps extends React.ComponentProps<'div'> {
supportsOnApplyInEditorV2: boolean
readWorkspaceGitRepositories?: () => Promise<GitRepository[]>
getActiveEditorSelection?: () => Promise<EditorFileContext | null>
fetchSessionState?: () => Promise<SessionState | null>
storeSessionState?: (state: Partial<SessionState>) => Promise<void>
listFileInWorkspace?: (
params: ListFilesInWorkspaceParams
) => Promise<ListFileItem[]>
readFileContent?: (info: FileRange) => Promise<string | null>
}

/**
* The state used to restore the chat panel, should be json serializable.
* Save this state to client so that the chat panel can be restored across webview reloading.
*/
export interface SessionState {
threadId?: string | undefined
qaPairs?: QuestionAnswerPair[] | undefined
input?: string | undefined
relevantContext?: Context[] | undefined
selectedRepoId?: string | undefined
}

function ChatRenderer(
{
className,
@@ -166,8 +180,10 @@ function ChatRenderer(
supportsOnApplyInEditorV2,
readWorkspaceGitRepositories,
getActiveEditorSelection,
fetchSessionState,
storeSessionState,
listFileInWorkspace,
readFileContent
readFileConten
}: ChatProps,
ref: React.ForwardedRef<ChatRef>
) {
@@ -270,6 +286,7 @@ function ChatRenderer(
}
]
setQaPairs(nextQaPairs)

const [createMessageInput, threadRunOptions] =
await generateRequestPayload(qaPair.user)

@@ -304,11 +321,20 @@ function ChatRenderer(
const nextQaPairs = qaPairs.filter(o => o.user.id !== userMessageId)
setQaPairs(nextQaPairs)


storeSessionState?.({
qaPairs: nextQaPairs,
relevantContext: updatedRelevantContext
})

setInput(userMessage.message)

const inputContent = convertTextToTiptapContent(userMessage.message)
setInput({
type: 'doc',
content: inputContent
})

if (userMessage.activeContext) {
openInEditor(getFileLocationFromContext(userMessage.activeContext))
}
@@ -536,6 +562,11 @@ function ChatRenderer(
}
]
setQaPairs(nextQaPairs)

storeSessionState?.({
qaPairs: nextQaPairs
})

const payload = await generateRequestPayload(newUserMessage)
sendUserMessage(...payload)
}
You are viewing a condensed version of this merge commit. You can view the full changes here.