Skip to content

Commit

Permalink
refactor(iframe): streamline message event listener by removing unnec…
Browse files Browse the repository at this point in the history
…essary conditional block

refactor(chat-page): simplify capability checks by consolidating server support evaluations

refactor(chat-webview): remove redundant logging during initialization
  • Loading branch information
Sma1lboy committed Jan 22, 2025
1 parent 986119f commit 524913d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 38 deletions.
4 changes: 1 addition & 3 deletions clients/tabby-threads/source/targets/iframe/nested.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ export async function createThreadFromInsideIframe<
self.addEventListener(
"message",
({ data }) => {
if (data === CHECK_MESSAGE) {
respond();
}
if (data === CHECK_MESSAGE) respond();
},
{ signal: options.signal }
);
Expand Down
2 changes: 0 additions & 2 deletions clients/vscode/src/chat/webview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,9 @@ export class ChatWebview {
};
this.webview = webview;

this.logger.info("Initializing chat panel webview.");
this.createChatPanelApiClient().then((client) => {
this.client = client;
});
this.logger.info("Chat panel webview initialized.");
const statusListener = () => {
this.checkStatusAndLoadContent();
};
Expand Down
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 524913d

Please sign in to comment.