Skip to content

Commit

Permalink
refactor(client): simplify createClient function by returning thread …
Browse files Browse the repository at this point in the history
…directly
  • Loading branch information
Sma1lboy committed Jan 22, 2025
1 parent 1024b74 commit 986119f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
4 changes: 1 addition & 3 deletions clients/tabby-chat-panel/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,8 @@ export interface ClientApi extends ClientApiMethods {
supports: SupportProxy
}

// TODO: change this to async
export async function createClient(target: HTMLIFrameElement, api: ClientApiMethods): Promise<ServerApi> {
const thread = await createThreadFromIframe(target, {
return await createThreadFromIframe(target, {
expose: {
refresh: api.refresh,
onApplyInEditor: api.onApplyInEditor,
Expand All @@ -395,7 +394,6 @@ export async function createClient(target: HTMLIFrameElement, api: ClientApiMeth
readFileContent: api.readFileContent,
},
})
return thread as unknown as Promise<ServerApi>
}

export async function createServer(api: ServerApi): Promise<ClientApi> {
Expand Down
3 changes: 1 addition & 2 deletions clients/vscode/src/chat/createClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async function createThreadFromWebview<Self = Record<string, never>, Target = Re
}

export async function createClient(webview: Webview, api: ClientApiMethods): Promise<ServerApi> {
const thread = await createThreadFromWebview(webview, {
return await createThreadFromWebview(webview, {
expose: {
refresh: api.refresh,
onApplyInEditor: api.onApplyInEditor,
Expand All @@ -45,5 +45,4 @@ export async function createClient(webview: Webview, api: ClientApiMethods): Pro
readFileContent: api.readFileContent,
},
});
return thread as unknown as ServerApi;
}

0 comments on commit 986119f

Please sign in to comment.