Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

fix: browser capability should be disabled when there is no vision capability

Louis269e41244c82
diff --git a/web-app/src/consts/providers.ts b/web-app/src/constants/providers.ts
similarity index 100%
rename from web-app/src/consts/providers.ts
rename to web-app/src/constants/providers.ts
diff --git a/web-app/src/containers/ChatInput.tsx b/web-app/src/containers/ChatInput.tsx
index 65b77bcec..e776ffc07 100644
--- a/web-app/src/containers/ChatInput.tsx
+++ b/web-app/src/containers/ChatInput.tsx
@@ -173,6 +173,19 @@ const ChatInput = ({
setDialogOpen: setExtensionDialogOpen,
} = useJanBrowserExtension()
+ // Check if model supports browser feature (requires both vision and tools)
+ const modelSupportsBrowser = useMemo(() => {
+ const capabilities = selectedModel?.capabilities || []
+ return capabilities.includes('vision') && capabilities.includes('tools')
+ }, [selectedModel?.capabilities])
+
+ // Auto-disable browser feature when model doesn't support it
+ useEffect(() => {
+ if (janBrowserMCPActive && !modelSupportsBrowser) {
+ handleBrowseClick()
+ }
+ }, [janBrowserMCPActive, modelSupportsBrowser, handleBrowseClick])
+
const attachmentsEnabled = useAttachments((s) => s.enabled)
const parsePreference = useAttachments((s) => s.parseMode)
const maxFileSizeMB = useAttachments((s) => s.maxFileSizeMB)
@@ -1530,15 +1543,14 @@ const ChatInput = ({
</Tooltip>
</TooltipProvider>
)}
- {selectedModel?.capabilities?.includes('tools') &&
- hasJanBrowserMCPConfig && (
+ {hasJanBrowserMCPConfig && modelSupportsBrowser && (
<TooltipProvider>
<Tooltip>
<TooltipTrigger asChild>
<div
className={cn(
'h-7 p-1 flex items-center justify-center rounded-sm hover:bg-main-view-fg/10 transition-all duration-200 ease-in-out gap-1 cursor-pointer',
- janBrowserMCPActive && 'bg-accent/10',
+ janBrowserMCPActive && 'bg-primary/10',
isJanBrowserMCPLoading &&
'opacity-70 cursor-not-allowed'
)}
@@ -1551,14 +1563,14 @@ const ChatInput = ({
{isJanBrowserMCPLoading ? (
<IconLoader2
size={18}
- className="text-accent animate-spin"
+ className="text-primary animate-spin"
/>
) : (
<IconWorld
size={18}
className={cn(
'text-main-view-fg/50',
- janBrowserMCPActive && 'text-accent'
+ janBrowserMCPActive && 'text-primary'
)}
/>
)}
@@ -1621,14 +1633,14 @@ const ChatInput = ({
className={cn(
'h-7 p-1 flex items-center justify-center rounded-sm hover:bg-main-view-fg/10 transition-all duration-200 ease-in-out gap-1 cursor-pointer',
isOpen && 'bg-main-view-fg/10',
- toolsCount > 0 && 'bg-accent/10'
+ toolsCount > 0 && 'bg-primary/10'
)}
>
<IconTool
size={18}
className={cn(
'text-main-view-fg/50',
- toolsCount > 0 && 'text-accent'
+ toolsCount > 0 && 'text-primary'
)}
/>
</div>
diff --git a/web-app/src/containers/DropdownModelProvider.tsx b/web-app/src/containers/DropdownModelProvider.tsx
index 27092da18..735039412 100644
--- a/web-app/src/containers/DropdownModelProvider.tsx
+++ b/web-app/src/containers/DropdownModelProvider.tsx
@@ -20,7 +20,7 @@ import { Fzf } from 'fzf'
import { localStorageKey } from '@/constants/localStorage'
import { useTranslation } from '@/i18n/react-i18next-compat'
import { useFavoriteModel } from '@/hooks/useFavoriteModel'
-import { predefinedProviders } from '@/consts/providers'
+import { predefinedProviders } from '@/constants/providers'
import { useServiceHub } from '@/hooks/useServiceHub'
import { PlatformFeatures } from '@/lib/platform/const'
import { PlatformFeature } from '@/lib/platform/types'
diff --git a/web-app/src/containers/dialogs/DeleteProvider.tsx b/web-app/src/containers/dialogs/DeleteProvider.tsx
index 1c3a7c651..e95b15e1f 100644
--- a/web-app/src/containers/dialogs/DeleteProvider.tsx
+++ b/web-app/src/containers/dialogs/DeleteProvider.tsx
@@ -17,7 +17,7 @@ import { useModelProvider } from '@/hooks/useModelProvider'
import { useRouter } from '@tanstack/react-router'
import { route } from '@/constants/routes'
import { useTranslation } from '@/i18n/react-i18next-compat'
-import { predefinedProviders } from '@/consts/providers'
+import { predefinedProviders } from '@/constants/providers'
import { useFavoriteModel } from '@/hooks/useFavoriteModel'
type Props = {
@@ -43,7 +43,7 @@ const DeleteProvider = ({ provider }: Props) => {
removeFavorite(favoriteModel.id)
}
})
-
+
deleteProvider(provider.provider)
toast.success(t('providers:deleteProvider.title'), {
id: `delete-provider-${provider.provider}`,
diff --git a/web-app/src/routes/index.tsx b/web-app/src/routes/index.tsx
index d4c9fc348..72c86d1de 100644
--- a/web-app/src/routes/index.tsx
+++ b/web-app/src/routes/index.tsx
@@ -9,7 +9,7 @@ import { cn } from '@/lib/utils'
import { useModelProvider } from '@/hooks/useModelProvider'
import SetupScreen from '@/containers/SetupScreen'
import { route } from '@/constants/routes'
-import { predefinedProviders } from '@/consts/providers'
+import { predefinedProviders } from '@/constants/providers'
type SearchParams = {
'model'?: {
diff --git a/web-app/src/routes/settings/providers/$providerName.tsx b/web-app/src/routes/settings/providers/$providerName.tsx
index fe990877d..0ddfa9c98 100644
--- a/web-app/src/routes/settings/providers/$providerName.tsx
+++ b/web-app/src/routes/settings/providers/$providerName.tsx
@@ -31,7 +31,7 @@ import {
} from '@tabler/icons-react'
import { toast } from 'sonner'
import { useCallback, useEffect, useState } from 'react'
-import { predefinedProviders } from '@/consts/providers'
+import { predefinedProviders } from '@/constants/providers'
import { useModelLoad } from '@/hooks/useModelLoad'
import { useLlamacppDevices } from '@/hooks/useLlamacppDevices'
import { PlatformFeatures } from '@/lib/platform/const'
@@ -567,7 +567,7 @@ function ProviderDetail() {
size="sm"
className={cn(
'p-0',
- isCheckingBackendUpdate &&
+ isCheckingBackendUpdate &&
'pointer-events-none'
)}
onClick={handleCheckForBackendUpdate}
diff --git a/web-app/src/routes/settings/providers/index.tsx b/web-app/src/routes/settings/providers/index.tsx
index 7b9afd905..9876c2efe 100644
--- a/web-app/src/routes/settings/providers/index.tsx
+++ b/web-app/src/routes/settings/providers/index.tsx
@@ -13,7 +13,7 @@ import ProvidersAvatar from '@/containers/ProvidersAvatar'
import { AddProviderDialog } from '@/containers/dialogs'
import { Switch } from '@/components/ui/switch'
import { useCallback } from 'react'
-import { openAIProviderSettings } from '@/consts/providers'
+import { openAIProviderSettings } from '@/constants/providers'
import cloneDeep from 'lodash/cloneDeep'
import { toast } from 'sonner'
import { useServiceHub } from '@/hooks/useServiceHub'
diff --git a/web-app/src/services/providers/tauri.ts b/web-app/src/services/providers/tauri.ts
index 8782d07d3..6074e63a8 100644
--- a/web-app/src/services/providers/tauri.ts
+++ b/web-app/src/services/providers/tauri.ts
@@ -3,7 +3,7 @@
*/
import { models as providerModels } from 'token.js'
-import { predefinedProviders } from '@/consts/providers'
+import { predefinedProviders } from '@/constants/providers'
import { EngineManager, SettingComponentProps } from '@janhq/core'
import { ModelCapabilities } from '@/types/models'
import { modelSettings } from '@/lib/predefined'