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

refactor(thread): refactor hasCapability call with a better readable way #3732

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
65467d8
to: adding a draft approach
Sma1lboy Jan 20, 2025
f7fa804
refactor(api): improve type definitions for ClientApiMethods and Supp…
Sma1lboy Jan 20, 2025
4b83730
refactor(chat): convert client creation to async and enhance logging
Sma1lboy Jan 21, 2025
9d8fbbe
refactor(iframe): enhance method exchange and logging in thread creation
Sma1lboy Jan 21, 2025
02e80a6
refactor(api): update SupportProxy type to use boolean and enhance cr…
Sma1lboy Jan 21, 2025
9e2fc10
refactor(api): update exchangeMethods to return a Promise and enhance…
Sma1lboy Jan 22, 2025
1024b74
refactor(chat-panel): remove unused eslint-disable for console statem…
Sma1lboy Jan 22, 2025
986119f
refactor(client): simplify createClient function by returning thread …
Sma1lboy Jan 22, 2025
524913d
refactor(iframe): streamline message event listener by removing unnec…
Sma1lboy Jan 22, 2025
77f14b6
[autofix.ci] apply automated fixes
autofix-ci[bot] Jan 22, 2025
2daa34d
refactor(target): remove exchangeMethods function and related references
Sma1lboy Jan 22, 2025
5312275
refactor(client): simplify createClient and related functions by remo…
Sma1lboy Jan 24, 2025
ea16035
refactor(iframe): streamline thread creation and message handling in …
Sma1lboy Jan 24, 2025
d03eeb5
refactor(iframe): remove unnecessary line break in createThreadFromIf…
Sma1lboy Jan 24, 2025
f7412bc
refactor(chat): remove unnecessary console log for session state support
Sma1lboy Jan 24, 2025
03f11bf
refactor(client): remove unused support proxy type and simplify metho…
Sma1lboy Jan 24, 2025
2d177e7
refactor(target): simplify listener and property handler logic by rem…
Sma1lboy Jan 24, 2025
17859e1
refactor(client): remove unnecessary async keyword from createServer …
Sma1lboy Jan 24, 2025
911f783
refactor(target): enhance property handler logic by adding undefined …
Sma1lboy Jan 24, 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
refactor(iframe): streamline message event listener by removing unnec…
…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
commit 524913d40557242257b30d47a5f8943227e9c3db
4 changes: 1 addition & 3 deletions clients/tabby-threads/source/targets/iframe/nested.ts
Original file line number Diff line number Diff line change
@@ -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 }
);
2 changes: 0 additions & 2 deletions clients/vscode/src/chat/webview.ts
Original file line number Diff line number Diff line change
@@ -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();
};
48 changes: 15 additions & 33 deletions ee/tabby-ui/app/chat/page.tsx
Original file line number Diff line number Diff line change
@@ -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'

@@ -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])

Loading