Skip to content

Commit

Permalink
refactor(chat-page): simplify capability checks by consolidating serv…
Browse files Browse the repository at this point in the history
…er support evaluations
  • Loading branch information
Sma1lboy committed Jan 22, 2025
1 parent afce109 commit ec3200d
Showing 1 changed file with 15 additions and 33 deletions.
48 changes: 15 additions & 33 deletions ee/tabby-ui/app/chat/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import { MemoizedReactMarkdown } from '@/components/markdown'

import './page.css'

import { set } from 'date-fns'

import { saveFetcherOptions } from '@/lib/tabby/token-management'
import { PromptFormRef } from '@/components/chat/form-editor/types'

Expand Down Expand Up @@ -244,40 +246,20 @@ export default function ChatPage() {
apiVersion: TABBY_CHAT_PANEL_API_VERSION
})

if ('refresh' in server) {
// eslint-disable-next-line no-console
console.log('refresh in server')
}
// eslint-disable-next-line no-console
console.log('support v2?:', server?.supports['onApplyInEditorV2'])

const checkCapabilities = async () => {
server
?.hasCapability('onApplyInEditorV2')
.then(setSupportsOnApplyInEditorV2)
server?.hasCapability('lookupSymbol').then(setSupportsOnLookupSymbol)
server
?.hasCapability('readWorkspaceGitRepositories')
.then(setSupportsReadWorkspaceGitRepoInfo)
server
?.hasCapability('listFileInWorkspace')
.then(setSupportProvideFileAtInfo)
server
?.hasCapability('readFileContent')
.then(setSupportsReadFileContent)

Promise.all([
server?.hasCapability('fetchSessionState'),
server?.hasCapability('storeSessionState')
]).then(results => {
setSupportsStoreAndFetchSessionState(
results.every(result => !!result)
)
})
setSupportProvideFileAtInfo(!!server?.supports['listFileInWorkspace'])
setSupportsReadFileContent(!!server?.supports['readFileContent'])
setSupportsOnApplyInEditorV2(!!server?.supports['onApplyInEditorV2'])
setSupportsOnLookupSymbol(!!server?.supports['lookupSymbol'])
setSupportsReadWorkspaceGitRepoInfo(
!!server?.supports['readWorkspaceGitRepositories']
)
if (
!!server?.supports['fetchSessionState'] &&
!!server?.supports['storeSessionState']
) {
setSupportsStoreAndFetchSessionState(true)
}
checkCapabilities().then(() => {
setIsServerLoaded(true)
})
setIsServerLoaded(true)
}
}, [server])

Expand Down

0 comments on commit ec3200d

Please sign in to comment.