diff --git a/clients/tabby-chat-panel/src/index.ts b/clients/tabby-chat-panel/src/index.ts index a9346b4293a1..857d83a42362 100644 --- a/clients/tabby-chat-panel/src/index.ts +++ b/clients/tabby-chat-panel/src/index.ts @@ -277,7 +277,7 @@ export interface ClientApiMethods { /** * @returns The active selection of active editor. */ - getActiveEditorSelection?: () => Promise + getActiveEditorSelection: () => Promise } export interface ClientApi extends ClientApiMethods { diff --git a/ee/tabby-ui/app/chat/page.tsx b/ee/tabby-ui/app/chat/page.tsx index 54473d0e321e..2a33e1cc6437 100644 --- a/ee/tabby-ui/app/chat/page.tsx +++ b/ee/tabby-ui/app/chat/page.tsx @@ -79,10 +79,6 @@ export default function ChatPage() { supportsReadWorkspaceGitRepoInfo, setSupportsReadWorkspaceGitRepoInfo ] = useState(false) - const [ - supportsGetActiveEditorSelection, - setSupportsGetActiveEditorSelection - ] = useState(false) const executeCommand = (command: ChatCommand) => { if (chatRef.current) { @@ -248,9 +244,6 @@ export default function ChatPage() { server ?.hasCapability('readWorkspaceGitRepositories') .then(setSupportsReadWorkspaceGitRepoInfo) - server - ?.hasCapability('getActiveEditorSelection') - .then(setSupportsGetActiveEditorSelection) } checkCapabilities().then(() => { @@ -309,6 +302,10 @@ export default function ChatPage() { return server?.openExternal(url) } + const getActiveEditorSelection = async () => { + return server?.getActiveEditorSelection() ?? null + } + const refresh = async () => { setIsRefreshLoading(true) await server?.refresh() @@ -431,11 +428,7 @@ export default function ChatPage() { ? server?.readWorkspaceGitRepositories : undefined } - getActiveEditorSelection={ - supportsGetActiveEditorSelection - ? server?.getActiveEditorSelection - : undefined - } + getActiveEditorSelection={getActiveEditorSelection} /> )