diff --git a/clients/tabby-chat-panel/package.json b/clients/tabby-chat-panel/package.json index d07e9ea118dc..27775eac49c7 100644 --- a/clients/tabby-chat-panel/package.json +++ b/clients/tabby-chat-panel/package.json @@ -1,7 +1,7 @@ { "name": "tabby-chat-panel", "type": "module", - "version": "0.2.2", + "version": "0.3.0", "keywords": [], "sideEffects": false, "exports": { @@ -44,8 +44,8 @@ "typecheck": "tsc --noEmit" }, "dependencies": { - "@quilted/threads": "^2.2.0", - "react": "18.2.0" + "react": "18.2.0", + "tabby-threads": "workspace:*" }, "devDependencies": { "@antfu/eslint-config": "^2.16.0", diff --git a/clients/tabby-chat-panel/src/index.ts b/clients/tabby-chat-panel/src/index.ts index 95dec07c4f2f..ceabd054dc12 100644 --- a/clients/tabby-chat-panel/src/index.ts +++ b/clients/tabby-chat-panel/src/index.ts @@ -1,4 +1,4 @@ -import { createThreadFromIframe, createThreadFromInsideIframe } from '@quilted/threads' +import { createThreadFromIframe, createThreadFromInsideIframe } from 'tabby-threads' import { version } from '../package.json' export const TABBY_CHAT_PANEL_API_VERSION: string = version @@ -54,7 +54,7 @@ export interface ServerApi { updateActiveSelection: (context: Context | null) => void } -export interface ClientApi { +export interface ClientApiMethods { navigate: (context: Context, opts?: NavigateOpts) => void refresh: () => Promise @@ -69,6 +69,13 @@ export interface ClientApi { onCopy: (content: string) => void onKeyboardEvent: (type: 'keydown' | 'keyup' | 'keypress', event: KeyboardEventInit) => void + +} + +export interface ClientApi extends ClientApiMethods { + // this is inner function cover by tabby-threads + // the function doesn't need to expose to client but can call by client + hasCapability: (method: keyof ClientApiMethods) => Promise } export interface ChatMessage { @@ -84,7 +91,7 @@ export interface ChatMessage { activeContext?: Context } -export function createClient(target: HTMLIFrameElement, api: ClientApi): ServerApi { +export function createClient(target: HTMLIFrameElement, api: ClientApiMethods): ServerApi { return createThreadFromIframe(target, { expose: { navigate: api.navigate, diff --git a/clients/tabby-chat-panel/src/react.ts b/clients/tabby-chat-panel/src/react.ts index b2d25b22b216..e6a57edeb295 100644 --- a/clients/tabby-chat-panel/src/react.ts +++ b/clients/tabby-chat-panel/src/react.ts @@ -1,10 +1,10 @@ import type { RefObject } from 'react' import { useEffect, useState } from 'react' -import type { ClientApi, ServerApi } from './index' +import type { ClientApi, ClientApiMethods, ServerApi } from './index' import { createClient, createServer } from './index' -function useClient(iframeRef: RefObject, api: ClientApi) { +function useClient(iframeRef: RefObject, api: ClientApiMethods) { const [client, setClient] = useState(null) let isCreated = false diff --git a/clients/vscode/package.json b/clients/vscode/package.json index c4e52a43b8bf..8df27a9507a7 100644 --- a/clients/vscode/package.json +++ b/clients/vscode/package.json @@ -459,7 +459,7 @@ "publish-prerelease": "pnpm run vscode:publish-prerelease && pnpm run ovsx:publish-prerelease" }, "devDependencies": { - "@quilted/threads": "^2.2.0", + "tabby-threads": "workspace:*", "@types/deep-equal": "^1.0.4", "@types/diff": "^5.2.1", "@types/fs-extra": "^11.0.1", diff --git a/clients/vscode/src/chat/chatPanel.ts b/clients/vscode/src/chat/chatPanel.ts index 0c97df8fa499..0214f654e42b 100644 --- a/clients/vscode/src/chat/chatPanel.ts +++ b/clients/vscode/src/chat/chatPanel.ts @@ -1,5 +1,5 @@ -import { createThread, type ThreadOptions } from "@quilted/threads"; -import type { ServerApi, ClientApi } from "tabby-chat-panel"; +import { createThread, type ThreadOptions } from "tabby-threads"; +import type { ServerApi, ClientApiMethods } from "tabby-chat-panel"; import { Webview } from "vscode"; export function createThreadFromWebview, Target = Record>( @@ -22,7 +22,7 @@ export function createThreadFromWebview, Target = R ); } -export function createClient(webview: Webview, api: ClientApi): ServerApi { +export function createClient(webview: Webview, api: ClientApiMethods): ServerApi { return createThreadFromWebview(webview, { expose: { navigate: api.navigate, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 10dfdf3b98aa..17ab9a1f87c3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -218,12 +218,12 @@ importers: clients/tabby-chat-panel: dependencies: - '@quilted/threads': - specifier: ^2.2.0 - version: 2.4.0(@preact/signals-core@1.8.0) react: specifier: 18.2.0 version: 18.2.0 + tabby-threads: + specifier: workspace:* + version: link:../tabby-threads devDependencies: '@antfu/eslint-config': specifier: ^2.16.0 @@ -298,9 +298,6 @@ importers: clients/vscode: devDependencies: - '@quilted/threads': - specifier: ^2.2.0 - version: 2.4.0(@preact/signals-core@1.8.0) '@types/deep-equal': specifier: ^1.0.4 version: 1.0.4 @@ -388,6 +385,9 @@ importers: tabby-chat-panel: specifier: workspace:* version: link:../tabby-chat-panel + tabby-threads: + specifier: workspace:* + version: link:../tabby-threads tsc-watch: specifier: ^6.2.0 version: 6.2.0(typescript@5.4.5) @@ -2547,15 +2547,6 @@ packages: resolution: {integrity: sha512-uA3fFqJ/uSvk7h/zdPG0RkO/JO7R5smAkb5vdL1LQJa0oH9udLIVGw8T913dhy0KGxQx4W4NVyPnNVdlHaYe9g==} engines: {node: '>=14.0.0'} - '@quilted/threads@2.4.0': - resolution: {integrity: sha512-YIjgV+kLsssruF9+ymzTS3HKmzt6YS1k3LSxhl24+KAyTEFQdzHjPO6PKhlrp1LR8dEtPGn9plqhK4A7eKWqSw==} - engines: {node: '>=14.0.0'} - peerDependencies: - '@preact/signals-core': ^1.6.0 - peerDependenciesMeta: - '@preact/signals-core': - optional: true - '@radix-ui/colors@1.0.1': resolution: {integrity: sha512-xySw8f0ZVsAEP+e7iLl3EvcBXX7gsIlC1Zso/sPBW9gIWerBTgz6axrjU+MZ39wD+WFi5h5zdWpsg3+hwt2Qsg==} @@ -12759,12 +12750,6 @@ snapshots: '@preact/signals-core': 1.8.0 '@quilted/events': 2.0.0 - '@quilted/threads@2.4.0(@preact/signals-core@1.8.0)': - dependencies: - '@quilted/events': 2.0.0 - optionalDependencies: - '@preact/signals-core': 1.8.0 - '@radix-ui/colors@1.0.1': {} '@radix-ui/number@1.0.1':