window.open(source.link)}
+
-
-
- {source.title}
-
-
+
window.open(source.link)}
>
- {normalizedText(source.snippet)}
-
-
-
-
-
-
- {hostname.replace('www.', '').split('/')[0]}
-
+
+
+
+ {source.title}
+
+
+ {normalizedText(source.snippet)}
+
+
+
+
+
+
+ {hostname.replace('www.', '').split('/')[0]}
+
+
+
+
-
-
+
+
+ Source info
+ Score: xxxx
+ Ranking: xxxx
+
+
)
}
diff --git a/ee/tabby-ui/components/chat/question-answer.tsx b/ee/tabby-ui/components/chat/question-answer.tsx
index 776452f1a3b1..f4ffc88f9e9b 100644
--- a/ee/tabby-ui/components/chat/question-answer.tsx
+++ b/ee/tabby-ui/components/chat/question-answer.tsx
@@ -1,7 +1,7 @@
// Inspired by Chatbot-UI and modified to fit the needs of this project
// @see https://github.com/mckaywrigley/chatbot-ui/blob/main/components/Chat/ChatMessage.tsx
-import React from 'react'
+import React, { ReactNode, useState } from 'react'
import Image from 'next/image'
import tabbyLogo from '@/assets/tabby.png'
import { isNil } from 'lodash-es'
@@ -18,6 +18,11 @@ import {
} from '@/lib/types/chat'
import { cn } from '@/lib/utils'
import { CodeBlock } from '@/components/ui/codeblock'
+import {
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger
+} from '@/components/ui/tooltip'
import { MemoizedReactMarkdown } from '@/components/markdown'
import { CopyButton } from '../copy-button'
@@ -441,13 +446,17 @@ interface ContextReferencesProps {
className?: string
onContextClick?: (context: Context) => void
defaultOpen?: boolean
+ enableTooltip?: boolean
+ onTooltipClick?: () => void
}
export const CodeReferences = ({
contexts,
userContexts,
className,
onContextClick,
- defaultOpen
+ defaultOpen,
+ enableTooltip,
+ onTooltipClick
}: ContextReferencesProps) => {
const totalContextLength = (userContexts?.length || 0) + contexts.length
const isMultipleReferences = totalContextLength > 1
@@ -483,6 +492,17 @@ export const CodeReferences = ({
key={`assistant-${index}`}
context={item}
onContextClick={onContextClick}
+ enableTooltip={enableTooltip}
+ tooltipContent={
+ enableTooltip ? (
+
+
Code info
+
Score: xxxx
+
Ranking: xxxx
+
+ ) : null
+ }
+ onTooltipClick={onTooltipClick}
/>
)
})}
@@ -495,12 +515,19 @@ export const CodeReferences = ({
function ContextItem({
context,
clickable = true,
- onContextClick
+ onContextClick,
+ enableTooltip,
+ tooltipContent,
+ onTooltipClick
}: {
context: Context
clickable?: boolean
onContextClick?: (context: Context) => void
+ enableTooltip?: boolean
+ tooltipContent?: ReactNode
+ onTooltipClick?: () => void
}) {
+ const [tooltipOpen, setTooltipOpen] = useState(false)
const isMultiLine =
!isNil(context.range?.start) &&
!isNil(context.range?.end) &&
@@ -508,30 +535,50 @@ function ContextItem({
const pathSegments = context.filepath.split('/')
const fileName = pathSegments[pathSegments.length - 1]
const path = pathSegments.slice(0, pathSegments.length - 1).join('/')
+
+ const onTooltipOpenChange = (v: boolean) => {
+ if (!enableTooltip || !tooltipContent) return
+
+ setTooltipOpen(v)
+ }
+
return (
-
clickable && onContextClick?.(context)}
+
-
-
-
-
{fileName}
- {context.range?.start && (
-
- :{context.range.start}
-
- )}
- {isMultiLine && (
-
-{context.range.end}
- )}
-
{path}
+
+ clickable && onContextClick?.(context)}
+ >
+
+
+
+ {fileName}
+ {context.range?.start && (
+
+ :{context.range.start}
+
+ )}
+ {isMultiLine && (
+
+ -{context.range.end}
+
+ )}
+ {path}
+
+
-
-
+
+
+ {tooltipContent}
+
+
)
}
diff --git a/ee/tabby-ui/components/ui/icons.tsx b/ee/tabby-ui/components/ui/icons.tsx
index 87a9e116b1d2..3a26a7e10055 100644
--- a/ee/tabby-ui/components/ui/icons.tsx
+++ b/ee/tabby-ui/components/ui/icons.tsx
@@ -6,6 +6,7 @@ import {
Blocks,
BookOpenText,
Box,
+ Bug,
ChevronsDownUp,
CirclePlay,
FileText,
@@ -1522,6 +1523,10 @@ function IconApplyInEditor({
return
}
+function IconBug({ className, ...props }: React.ComponentProps
) {
+ return
+}
+
export {
IconEdit,
IconNextChat,
@@ -1606,5 +1611,6 @@ export {
IconBox,
IconTag,
IconFileText,
- IconApplyInEditor
+ IconApplyInEditor,
+ IconBug
}
diff --git a/ee/tabby-ui/lib/experiment-flags.ts b/ee/tabby-ui/lib/experiment-flags.ts
index c197a991117b..73bd26bbaf3d 100644
--- a/ee/tabby-ui/lib/experiment-flags.ts
+++ b/ee/tabby-ui/lib/experiment-flags.ts
@@ -114,3 +114,14 @@ const enableSearchFactory = new ExperimentFlagFactory(
)
export const EXP_enable_search = enableSearchFactory.defineGlobalVar()
export const useEnableSearch = enableSearchFactory.defineHook()
+
+const enableDeveloperModeFactory = new ExperimentFlagFactory(
+ 'enable_developer_mode',
+ 'Developer Mode',
+ 'Enable the developer mode. The features involved include the Answer Engine.',
+ false
+)
+
+export const EXP_enable_developer_mode =
+ enableDeveloperModeFactory.defineGlobalVar()
+export const useEnableDeveloperMode = enableDeveloperModeFactory.defineHook()
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index be683a40adbd..06ba8371fc6f 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -323,10 +323,10 @@ importers:
version: 2.2.3
esbuild-plugin-copy:
specifier: ^2.1.1
- version: 2.1.1(esbuild@0.19.12)
+ version: 2.1.1(esbuild@0.20.2)
esbuild-plugin-polyfill-node:
specifier: ^0.3.0
- version: 0.3.0(esbuild@0.19.12)
+ version: 0.3.0(esbuild@0.20.2)
eslint:
specifier: ^8.55.0
version: 8.57.0
@@ -10512,7 +10512,7 @@ snapshots:
'@babel/traverse': 7.23.5
'@babel/types': 7.23.5
convert-source-map: 2.0.0
- debug: 4.3.4(supports-color@9.4.0)
+ debug: 4.3.4
gensync: 1.0.0-beta.2
json5: 2.2.3
semver: 6.3.1
@@ -10901,7 +10901,7 @@ snapshots:
'@babel/helper-split-export-declaration': 7.22.6
'@babel/parser': 7.23.5
'@babel/types': 7.23.5
- debug: 4.3.4(supports-color@9.4.0)
+ debug: 4.3.4
globals: 11.12.0
transitivePeerDependencies:
- supports-color
@@ -11433,7 +11433,7 @@ snapshots:
'@eslint/eslintrc@2.1.2':
dependencies:
ajv: 6.12.6
- debug: 4.3.4(supports-color@9.4.0)
+ debug: 4.3.4
espree: 9.6.1
globals: 13.22.0
ignore: 5.3.1
@@ -11843,7 +11843,7 @@ snapshots:
'@types/json-stable-stringify': 1.0.36
'@whatwg-node/fetch': 0.9.14
chalk: 4.1.2
- debug: 4.3.4(supports-color@9.4.0)
+ debug: 4.3.4
dotenv: 16.3.1
graphql: 16.8.1
graphql-request: 6.1.0(encoding@0.1.13)(graphql@16.8.1)
@@ -11931,7 +11931,7 @@ snapshots:
'@humanwhocodes/config-array@0.11.11':
dependencies:
'@humanwhocodes/object-schema': 1.2.1
- debug: 4.3.4(supports-color@9.4.0)
+ debug: 4.3.4
minimatch: 3.1.2
transitivePeerDependencies:
- supports-color
@@ -13883,7 +13883,7 @@ snapshots:
'@typescript-eslint/type-utils': 7.4.0(eslint@8.50.0)(typescript@5.2.2)
'@typescript-eslint/utils': 7.4.0(eslint@8.50.0)(typescript@5.2.2)
'@typescript-eslint/visitor-keys': 7.4.0
- debug: 4.3.4(supports-color@9.4.0)
+ debug: 4.3.4
eslint: 8.50.0
graphemer: 1.4.0
ignore: 5.3.1
@@ -13900,7 +13900,7 @@ snapshots:
'@typescript-eslint/scope-manager': 5.62.0
'@typescript-eslint/types': 5.62.0
'@typescript-eslint/typescript-estree': 5.62.0(typescript@5.2.2)
- debug: 4.3.4(supports-color@9.4.0)
+ debug: 4.3.4
eslint: 8.50.0
optionalDependencies:
typescript: 5.2.2
@@ -14006,7 +14006,7 @@ snapshots:
dependencies:
'@typescript-eslint/typescript-estree': 7.4.0(typescript@5.2.2)
'@typescript-eslint/utils': 7.4.0(eslint@8.50.0)(typescript@5.2.2)
- debug: 4.3.4(supports-color@9.4.0)
+ debug: 4.3.4
eslint: 8.50.0
ts-api-utils: 1.3.0(typescript@5.2.2)
optionalDependencies:
@@ -14026,7 +14026,7 @@ snapshots:
dependencies:
'@typescript-eslint/types': 5.62.0
'@typescript-eslint/visitor-keys': 5.62.0
- debug: 4.3.4(supports-color@9.4.0)
+ debug: 4.3.4
globby: 11.1.0
is-glob: 4.0.3
semver: 7.6.2
@@ -14085,7 +14085,7 @@ snapshots:
dependencies:
'@typescript-eslint/types': 7.4.0
'@typescript-eslint/visitor-keys': 7.4.0
- debug: 4.3.4(supports-color@9.4.0)
+ debug: 4.3.4
globby: 11.1.0
is-glob: 4.0.3
minimatch: 9.0.3
@@ -14569,7 +14569,7 @@ snapshots:
agent-base@7.1.0:
dependencies:
- debug: 4.3.4(supports-color@9.4.0)
+ debug: 4.3.4
transitivePeerDependencies:
- supports-color
@@ -15591,6 +15591,10 @@ snapshots:
dependencies:
ms: 2.1.3
+ debug@4.3.4:
+ dependencies:
+ ms: 2.1.2
+
debug@4.3.4(supports-color@8.1.1):
dependencies:
ms: 2.1.2
@@ -15992,11 +15996,11 @@ snapshots:
is-date-object: 1.0.5
is-symbol: 1.0.4
- esbuild-plugin-copy@2.1.1(esbuild@0.19.12):
+ esbuild-plugin-copy@2.1.1(esbuild@0.20.2):
dependencies:
chalk: 4.1.2
chokidar: 3.6.0
- esbuild: 0.19.12
+ esbuild: 0.20.2
fs-extra: 10.1.0
globby: 11.1.0
@@ -16006,6 +16010,12 @@ snapshots:
esbuild: 0.19.12
import-meta-resolve: 3.1.1
+ esbuild-plugin-polyfill-node@0.3.0(esbuild@0.20.2):
+ dependencies:
+ '@jspm/core': 2.0.1
+ esbuild: 0.20.2
+ import-meta-resolve: 3.1.1
+
esbuild@0.19.11:
optionalDependencies:
'@esbuild/aix-ppc64': 0.19.11
@@ -16115,7 +16125,7 @@ snapshots:
'@typescript-eslint/parser': 5.62.0(eslint@8.50.0)(typescript@5.2.2)
eslint: 8.50.0
eslint-import-resolver-node: 0.3.9
- eslint-import-resolver-typescript: 3.6.1(@typescript-eslint/parser@5.62.0(eslint@8.50.0)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.28.1)(eslint@8.50.0)
+ eslint-import-resolver-typescript: 3.6.1(@typescript-eslint/parser@5.62.0(eslint@8.50.0)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.28.1(@typescript-eslint/parser@5.62.0(eslint@8.50.0)(typescript@5.2.2))(eslint@8.50.0))(eslint@8.50.0)
eslint-plugin-import: 2.28.1(@typescript-eslint/parser@5.62.0(eslint@8.50.0)(typescript@5.2.2))(eslint-import-resolver-typescript@3.6.1)(eslint@8.50.0)
eslint-plugin-jsx-a11y: 6.7.1(eslint@8.50.0)
eslint-plugin-react: 7.33.2(eslint@8.50.0)
@@ -16164,12 +16174,12 @@ snapshots:
transitivePeerDependencies:
- supports-color
- eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@5.62.0(eslint@8.50.0)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.28.1)(eslint@8.50.0):
+ eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@5.62.0(eslint@8.50.0)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.28.1(@typescript-eslint/parser@5.62.0(eslint@8.50.0)(typescript@5.2.2))(eslint@8.50.0))(eslint@8.50.0):
dependencies:
- debug: 4.3.4(supports-color@9.4.0)
+ debug: 4.3.4
enhanced-resolve: 5.15.0
eslint: 8.50.0
- eslint-module-utils: 2.8.0(@typescript-eslint/parser@5.62.0(eslint@8.50.0)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@5.62.0(eslint@8.50.0)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.28.1)(eslint@8.50.0))(eslint@8.50.0)
+ eslint-module-utils: 2.8.0(@typescript-eslint/parser@5.62.0(eslint@8.50.0)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@5.62.0(eslint@8.50.0)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.28.1(@typescript-eslint/parser@5.62.0(eslint@8.50.0)(typescript@5.2.2))(eslint@8.50.0))(eslint@8.50.0))(eslint@8.50.0)
eslint-plugin-import: 2.28.1(@typescript-eslint/parser@5.62.0(eslint@8.50.0)(typescript@5.2.2))(eslint-import-resolver-typescript@3.6.1)(eslint@8.50.0)
fast-glob: 3.3.1
get-tsconfig: 4.7.2
@@ -16185,14 +16195,14 @@ snapshots:
dependencies:
eslint: 9.3.0
- eslint-module-utils@2.8.0(@typescript-eslint/parser@5.62.0(eslint@8.50.0)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@5.62.0(eslint@8.50.0)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.28.1)(eslint@8.50.0))(eslint@8.50.0):
+ eslint-module-utils@2.8.0(@typescript-eslint/parser@5.62.0(eslint@8.50.0)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@5.62.0(eslint@8.50.0)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.28.1(@typescript-eslint/parser@5.62.0(eslint@8.50.0)(typescript@5.2.2))(eslint@8.50.0))(eslint@8.50.0))(eslint@8.50.0):
dependencies:
debug: 3.2.7
optionalDependencies:
'@typescript-eslint/parser': 5.62.0(eslint@8.50.0)(typescript@5.2.2)
eslint: 8.50.0
eslint-import-resolver-node: 0.3.9
- eslint-import-resolver-typescript: 3.6.1(@typescript-eslint/parser@5.62.0(eslint@8.50.0)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.28.1)(eslint@8.50.0)
+ eslint-import-resolver-typescript: 3.6.1(@typescript-eslint/parser@5.62.0(eslint@8.50.0)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.28.1(@typescript-eslint/parser@5.62.0(eslint@8.50.0)(typescript@5.2.2))(eslint@8.50.0))(eslint@8.50.0)
transitivePeerDependencies:
- supports-color
@@ -16244,7 +16254,7 @@ snapshots:
doctrine: 2.1.0
eslint: 8.50.0
eslint-import-resolver-node: 0.3.9
- eslint-module-utils: 2.8.0(@typescript-eslint/parser@5.62.0(eslint@8.50.0)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@5.62.0(eslint@8.50.0)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.28.1)(eslint@8.50.0))(eslint@8.50.0)
+ eslint-module-utils: 2.8.0(@typescript-eslint/parser@5.62.0(eslint@8.50.0)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@5.62.0(eslint@8.50.0)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.28.1(@typescript-eslint/parser@5.62.0(eslint@8.50.0)(typescript@5.2.2))(eslint@8.50.0))(eslint@8.50.0))(eslint@8.50.0)
has: 1.0.3
is-core-module: 2.13.0
is-glob: 4.0.3
@@ -16512,7 +16522,7 @@ snapshots:
ajv: 6.12.6
chalk: 4.1.2
cross-spawn: 7.0.3
- debug: 4.3.4(supports-color@9.4.0)
+ debug: 4.3.4
doctrine: 3.0.0
escape-string-regexp: 4.0.0
eslint-scope: 7.2.2
@@ -17376,7 +17386,7 @@ snapshots:
http-proxy-agent@7.0.0:
dependencies:
agent-base: 7.1.0
- debug: 4.3.4(supports-color@9.4.0)
+ debug: 4.3.4
transitivePeerDependencies:
- supports-color
@@ -17397,7 +17407,7 @@ snapshots:
https-proxy-agent@7.0.2:
dependencies:
agent-base: 7.1.0
- debug: 4.3.4(supports-color@9.4.0)
+ debug: 4.3.4
transitivePeerDependencies:
- supports-color
@@ -18577,7 +18587,7 @@ snapshots:
micromark@3.2.0:
dependencies:
'@types/debug': 4.1.9
- debug: 4.3.4(supports-color@9.4.0)
+ debug: 4.3.4
decode-named-character-reference: 1.0.2
micromark-core-commonmark: 1.1.0
micromark-factory-space: 1.1.0