From ea118c238d42d93732e18d05126ceb6e4a7aa027 Mon Sep 17 00:00:00 2001 From: Meng Zhang Date: Wed, 6 Nov 2024 04:40:01 -0800 Subject: [PATCH 1/8] fix(webserver): update health check logic for completion model (#3375) * fix(webserver): update health check logic for completion model * update * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- ee/tabby-schema/src/schema/mod.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/ee/tabby-schema/src/schema/mod.rs b/ee/tabby-schema/src/schema/mod.rs index 4bf839987e57..623973384db5 100644 --- a/ee/tabby-schema/src/schema/mod.rs +++ b/ee/tabby-schema/src/schema/mod.rs @@ -723,7 +723,7 @@ impl Query { ctx: &Context, backend: ModelHealthBackend, ) -> Result { - check_user_allow_auth_token(ctx).await?; + check_admin(ctx).await?; // count request time in milliseconds let start = Instant::now(); @@ -741,16 +741,15 @@ impl Query { .expect("Failed to build completion options"); let (first, _) = completion - .generate("hello Tabby", options) + .generate("def fib(n):\n", options) .await .into_future() .await; - if let Some(first) = first { - if !first.is_empty() { - return Ok(ModelBackendHealthInfo { - latency_ms: start.elapsed().as_millis() as i32, - }); - } + + if first.is_some() { + return Ok(ModelBackendHealthInfo { + latency_ms: start.elapsed().as_millis() as i32, + }); } Err(TestModelConnectionError::FailedToConnect( From daa170c334f2d17b2269dc922456c998a3e142a2 Mon Sep 17 00:00:00 2001 From: Meng Zhang Date: Wed, 6 Nov 2024 07:07:39 -0800 Subject: [PATCH 2/8] ci(docker): update GitHub Actions runner to buildjet-2vcpu-ubuntu-2204 (#3377) Co-authored-by: Wei Zhang --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 54a7bbdfc579..ce1bd89cf605 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -22,7 +22,7 @@ env: jobs: release-docker: - runs-on: ubuntu-latest + runs-on: buildjet-2vcpu-ubuntu-2204 permissions: contents: read packages: write From db5926010cb706a80905e68758fb6285a6c41bca Mon Sep 17 00:00:00 2001 From: aliang <1098486429@qq.com> Date: Thu, 7 Nov 2024 08:18:43 +0700 Subject: [PATCH 3/8] chore(ui): adjust the style of the active selection in chat side panel (#3379) * chore(ui): adjust the style of the active selection in chat side panel * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- ee/tabby-ui/components/chat/chat-panel.tsx | 34 +++++++++++++++------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/ee/tabby-ui/components/chat/chat-panel.tsx b/ee/tabby-ui/components/chat/chat-panel.tsx index 86cdbe59b39f..7b1c7e77ee7e 100644 --- a/ee/tabby-ui/components/chat/chat-panel.tsx +++ b/ee/tabby-ui/components/chat/chat-panel.tsx @@ -2,6 +2,7 @@ import React, { RefObject } from 'react' import type { UseChatHelpers } from 'ai/react' import type { Context } from 'tabby-chat-panel' +import { cn } from '@/lib/utils' import { Badge } from '@/components/ui/badge' import { Button } from '@/components/ui/button' import { @@ -110,10 +111,14 @@ function ChatPanelRenderer( - - {getContextLabel(activeSelection)} + + + Current file ) : null} @@ -122,13 +127,11 @@ function ChatPanelRenderer( - - {getContextLabel(item)} - + @@ -155,12 +158,23 @@ export const ChatPanel = React.forwardRef( ChatPanelRenderer ) -function getContextLabel(context: Context) { +function ContextLabel({ + context, + className +}: { + context: Context + className?: string +}) { const [fileName] = context.filepath.split('/').slice(-1) const line = context.range.start === context.range.end ? `${context.range.start}` : `${context.range.start}-${context.range.end}` - return `${fileName}: ${line}` + return ( + + {fileName} + {`:${line}`} + + ) } From ab8d1871909a040f7f8fc7d18866079f182bc8ef Mon Sep 17 00:00:00 2001 From: Jackson Chen <90215880+Sma1lboy@users.noreply.github.com> Date: Wed, 6 Nov 2024 19:19:08 -0600 Subject: [PATCH 4/8] fix(vscode): fix QuickFix codeaction cannot correct get correct range (#3376) * feat(vscode): add range parameter to "chat.edit.start" command * fix: adjust range calculation in Commands.ts * feat(vscode): improve error handling in QuickFixCodeActionProvider * fix: adjust range calculation in Commands.ts --- clients/vscode/src/Commands.ts | 9 ++++--- clients/vscode/src/code-action/QuickFix.ts | 28 ++++++++++++++++++---- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/clients/vscode/src/Commands.ts b/clients/vscode/src/Commands.ts index 1f9566db8ea2..9368e9b6dff8 100644 --- a/clients/vscode/src/Commands.ts +++ b/clients/vscode/src/Commands.ts @@ -12,6 +12,7 @@ import { ThemeIcon, QuickPickItem, ViewColumn, + Range, } from "vscode"; import os from "os"; import path from "path"; @@ -295,18 +296,20 @@ export class Commands { chatPanelViewProvider.resolveWebviewView(panel); }, - "chat.edit.start": async (userCommand?: string) => { + "chat.edit.start": async (userCommand?: string, range?: Range) => { const editor = window.activeTextEditor; if (!editor) { return; } + const editRange = range || editor.selection; + const editLocation = { uri: editor.document.uri.toString(), range: { - start: { line: editor.selection.start.line, character: 0 }, + start: { line: editRange.start.line, character: 0 }, end: { - line: editor.selection.end.character === 0 ? editor.selection.end.line : editor.selection.end.line + 1, + line: editRange.end.character === 0 ? editRange.end.line : editRange.end.line + 1, character: 0, }, }, diff --git a/clients/vscode/src/code-action/QuickFix.ts b/clients/vscode/src/code-action/QuickFix.ts index 2e9b3dcb546b..2d661a9262a6 100644 --- a/clients/vscode/src/code-action/QuickFix.ts +++ b/clients/vscode/src/code-action/QuickFix.ts @@ -10,7 +10,9 @@ import { } from "vscode"; import { ContextVariables } from "../ContextVariables"; import { getLogger } from "../logger"; + export class QuickFixCodeActionProvider implements CodeActionProviderInterface { + private readonly logger = getLogger("QuickFixCodeActionProvider"); constructor(private readonly contextVariables: ContextVariables) {} provideCodeActions( @@ -22,7 +24,6 @@ export class QuickFixCodeActionProvider implements CodeActionProviderInterface { if (token.isCancellationRequested) { return; } - if (!this.contextVariables.chatEnabled) { return; } @@ -30,25 +31,44 @@ export class QuickFixCodeActionProvider implements CodeActionProviderInterface { return []; } + const getMergedDiagnosticRange = () => { + return context.diagnostics.reduce( + (mergedRange, diagnostic) => { + if (!mergedRange) { + return diagnostic.range; + } + return mergedRange.union(diagnostic.range); + }, + null as Range | null, + ); + }; + + const mergedRange = getMergedDiagnosticRange(); + if (!mergedRange) { + return []; + } + const lspErrors = context.diagnostics .map((diagnostic, idx) => "Error " + idx + ": " + diagnostic.message) .join("\n"); + const quickFixCmd = `Here is some error information that occurred in the selection: ${lspErrors} Please provide the correct command to fix the error.`; - getLogger("QuickFixCodeActionProvider").info("lspErrors", lspErrors); + this.logger.trace("LSP Errors collections: ", lspErrors); + this.logger.debug("QuickFix Range: ", mergedRange); const quickFixEditing = new CodeAction("Fix using Tabby", CodeActionKind.QuickFix); + quickFixEditing.command = { command: "tabby.chat.edit.start", title: "Fix using Tabby", - arguments: [quickFixCmd], + arguments: [quickFixCmd, mergedRange], }; const explainErrorCmd = `\nHere is some error information that occurred in the selection: ${lspErrors} Please provide an explanation for the error.`; - const explainError = new CodeAction("Explain using Tabby", CodeActionKind.QuickFix); explainError.command = { command: "tabby.chat.explainCodeBlock", From 6ddb893b77526fa31c34b4e7012f042d5b661dc9 Mon Sep 17 00:00:00 2001 From: aliang <1098486429@qq.com> Date: Fri, 8 Nov 2024 01:39:13 +0700 Subject: [PATCH 5/8] fix(ui): initialize the persisted model name properly (#3385) --- ee/tabby-ui/app/(home)/page.tsx | 2 +- ee/tabby-ui/lib/hooks/use-models.tsx | 16 ++++++---------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/ee/tabby-ui/app/(home)/page.tsx b/ee/tabby-ui/app/(home)/page.tsx index d735cc7cbcfd..7b7bc3a24353 100644 --- a/ee/tabby-ui/app/(home)/page.tsx +++ b/ee/tabby-ui/app/(home)/page.tsx @@ -5,13 +5,13 @@ import Image from 'next/image' import { useRouter } from 'next/navigation' import tabbyUrl from '@/assets/logo-dark.png' import { useQuery } from 'urql' +import { useStore } from 'zustand' import { SESSION_STORAGE_KEY } from '@/lib/constants' import { useHealth } from '@/lib/hooks/use-health' import { useMe } from '@/lib/hooks/use-me' import { useSelectedModel } from '@/lib/hooks/use-models' import { useIsChatEnabled } from '@/lib/hooks/use-server-info' -import { useStore } from '@/lib/hooks/use-store' import { updateSelectedModel } from '@/lib/stores/chat-actions' import { clearHomeScrollPosition, diff --git a/ee/tabby-ui/lib/hooks/use-models.tsx b/ee/tabby-ui/lib/hooks/use-models.tsx index 47c0ee7593a6..a2a02e5dc5e9 100644 --- a/ee/tabby-ui/lib/hooks/use-models.tsx +++ b/ee/tabby-ui/lib/hooks/use-models.tsx @@ -3,12 +3,12 @@ import { useEffect } from 'react' import { Maybe } from 'graphql/jsutils/Maybe' import useSWR, { SWRResponse } from 'swr' +import { useStore } from 'zustand' import fetcher from '@/lib/tabby/fetcher' import { updateSelectedModel } from '../stores/chat-actions' import { useChatStore } from '../stores/chat-store' -import { useStore } from './use-store' export interface ModelInfo { completion: Maybe> @@ -33,24 +33,20 @@ export function useModels(): SWRResponse { export function useSelectedModel() { const { data: modelData, isLoading: isFetchingModel } = useModels() - const isModelHydrated = useStore(useChatStore, state => state._hasHydrated) const selectedModel = useStore(useChatStore, state => state.selectedModel) - // once model hydrated, try to init model useEffect(() => { - if (isModelHydrated && !isFetchingModel) { - // check if current model is valid + if (!isFetchingModel) { + // init model const validModel = getModelFromModelInfo(selectedModel, modelData?.chat) - if (selectedModel !== validModel) { - updateSelectedModel(validModel) - } + updateSelectedModel(validModel) } - }, [isModelHydrated, isFetchingModel]) + }, [isFetchingModel]) return { // fetching model data or trying to get selected model from localstorage - isModelLoading: isFetchingModel || !isModelHydrated, + isModelLoading: isFetchingModel, selectedModel, models: modelData?.chat } From 99c4e6e4a8f2a97f9e894a991882fcd9d42e6032 Mon Sep 17 00:00:00 2001 From: Meng Zhang Date: Thu, 7 Nov 2024 19:20:40 -0800 Subject: [PATCH 6/8] chore(license): set team license seat limit to 50 (#3386) --- ee/tabby-schema/src/schema/license.rs | 2 +- .../settings/subscription/components/license-table.tsx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ee/tabby-schema/src/schema/license.rs b/ee/tabby-schema/src/schema/license.rs index ebe25c80623b..53855b72a287 100644 --- a/ee/tabby-schema/src/schema/license.rs +++ b/ee/tabby-schema/src/schema/license.rs @@ -39,7 +39,7 @@ impl LicenseInfo { } pub fn seat_limits_for_team_license() -> usize { - 200 + 50 } pub fn guard_seat_limit(mut self) -> Self { diff --git a/ee/tabby-ui/app/(dashboard)/settings/subscription/components/license-table.tsx b/ee/tabby-ui/app/(dashboard)/settings/subscription/components/license-table.tsx index 4dd4d6c3fe37..748fa6df1278 100644 --- a/ee/tabby-ui/app/(dashboard)/settings/subscription/components/license-table.tsx +++ b/ee/tabby-ui/app/(dashboard)/settings/subscription/components/license-table.tsx @@ -88,7 +88,7 @@ const PLANS: Plan[] = [ { name: 'Team', pricing: '$19 per user/month', - limit: 'Up to 200 users' + limit: 'Up to 50 users' }, { name: 'Enterprise', @@ -145,7 +145,7 @@ const FEATURES: FeatureGroup[] = [ { name: 'User count', community: 'Up to 5', - team: 'Up to 200', + team: 'Up to 50', enterprise: 'Unlimited' }, { From 8d2439d8301661e3ebd46a520c1dcab9c54a5e02 Mon Sep 17 00:00:00 2001 From: aliang <1098486429@qq.com> Date: Fri, 8 Nov 2024 10:34:18 +0700 Subject: [PATCH 7/8] fix(ui): remove shortcuts for Answer Engine thread editing (#3387) --- .../app/search/components/assistant-message-section.tsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ee/tabby-ui/app/search/components/assistant-message-section.tsx b/ee/tabby-ui/app/search/components/assistant-message-section.tsx index d49da10157f9..a3b71adeb27c 100644 --- a/ee/tabby-ui/app/search/components/assistant-message-section.tsx +++ b/ee/tabby-ui/app/search/components/assistant-message-section.tsx @@ -13,7 +13,6 @@ import * as z from 'zod' import { MARKDOWN_CITATION_REGEX } from '@/lib/constants/regex' import { MessageAttachmentCode } from '@/lib/gql/generates/graphql' -import { useEnterSubmit } from '@/lib/hooks/use-enter-submit' import { AttachmentDocItem, RelevantCodeContext } from '@/lib/types' import { cn, @@ -532,7 +531,6 @@ function MessageContentForm({ const { content } = form.watch() const isEmptyContent = !content || isEmpty(content.trim()) const [draftMessage] = useState(message) - const { formRef, onKeyDown } = useEnterSubmit() const handleSubmit = async (values: z.infer) => { const errorMessage = await onSubmit({ @@ -546,7 +544,7 @@ function MessageContentForm({ return (
- + From 4338a98b8bfdd16a4268a1084b59f92e378e5125 Mon Sep 17 00:00:00 2001 From: Jackson Chen <90215880+Sma1lboy@users.noreply.github.com> Date: Fri, 8 Nov 2024 03:14:30 -0600 Subject: [PATCH 8/8] fix: add relevant context only chat view is visible (#3388) --- clients/vscode/src/Commands.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/clients/vscode/src/Commands.ts b/clients/vscode/src/Commands.ts index 9368e9b6dff8..64f55c5f8309 100644 --- a/clients/vscode/src/Commands.ts +++ b/clients/vscode/src/Commands.ts @@ -87,8 +87,11 @@ export class Commands { this.chatViewProvider.addRelevantContext(fileContext); } }; + commands.executeCommand("tabby.chatView.focus"); - commands.executeCommand("tabby.chatView.focus").then(addContext); + if (this.chatViewProvider.webview?.visible) { + addContext(); + } } commands: Record void> = {