Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.
feat: simplify Jan Browser extension instruction
Vanalite08eba6133a59
diff --git a/web-app/src/containers/ChatInput.tsx b/web-app/src/containers/ChatInput.tsxindex 616e4cf3f..4647419db 100644--- a/web-app/src/containers/ChatInput.tsx+++ b/web-app/src/containers/ChatInput.tsx@@ -142,8 +142,6 @@ const ChatInput = ({dialogOpen: extensionDialogOpen,dialogState: extensionDialogState,toggleBrowser: handleBrowseClick,- handleRetryConnection: handleExtensionDialogRetry,- handleContinueAnyway: handleExtensionDialogContinue,handleCancel: handleExtensionDialogCancel,setDialogOpen: setExtensionDialogOpen,} = useJanBrowserExtension()@@ -514,6 +512,8 @@ const ChatInput = ({}},[+ ATTACHMENT_AUTO_INLINE_FALLBACK_BYTES,+ attachmentsKey,autoInlineContextRatio,activeModels,currentThreadId,@@ -524,6 +524,7 @@ const ChatInput = ({selectedProvider,serviceHub,setActiveModels,+ setAttachmentsForThread,updateAttachmentProcessing,updateLoadingModel,]@@ -1612,8 +1613,6 @@ const ChatInput = ({open={extensionDialogOpen}onOpenChange={setExtensionDialogOpen}state={extensionDialogState}- onRetryConnection={handleExtensionDialogRetry}- onContinueAnyway={handleExtensionDialogContinue}onCancel={handleExtensionDialogCancel}/></div>diff --git a/web-app/src/containers/dialogs/JanBrowserExtensionDialog.tsx b/web-app/src/containers/dialogs/JanBrowserExtensionDialog.tsxindex 6b6756902..9472eb8ab 100644--- a/web-app/src/containers/dialogs/JanBrowserExtensionDialog.tsx+++ b/web-app/src/containers/dialogs/JanBrowserExtensionDialog.tsx@@ -7,7 +7,7 @@ import {DialogTitle,} from '@/components/ui/dialog'import { Button } from '@/components/ui/button'-import { IconWorld, IconExternalLink, IconLoader2, IconCheck, IconRefresh } from '@tabler/icons-react'+import { IconExternalLink, IconLoader2 } from '@tabler/icons-react'import { useTranslation } from '@/i18n/react-i18next-compat'import { useCallback } from 'react'import { openUrl } from '@tauri-apps/plugin-opener'@@ -19,15 +19,11 @@ export type JanBrowserExtensionDialogState =| 'closed'| 'checking'| 'not_installed'- | 'waiting_connection'- | 'connected'interface JanBrowserExtensionDialogProps {open: booleanonOpenChange: (open: boolean) => voidstate: JanBrowserExtensionDialogState- onRetryConnection: () => void- onContinueAnyway?: () => voidonCancel?: () => void}@@ -35,8 +31,6 @@ export default function JanBrowserExtensionDialog({open,onOpenChange,state,- onRetryConnection,- onContinueAnyway,onCancel,}: JanBrowserExtensionDialogProps) {const { t } = useTranslation()@@ -63,185 +57,41 @@ export default function JanBrowserExtensionDialog({}}, [onCancel, onOpenChange])- // Just close the dialog without deactivating (for success state)- const handleClose = useCallback(() => {- onOpenChange(false)- }, [onOpenChange])-const renderContent = () => {switch (state) {case 'checking':return (- <>- <DialogHeader>- <div className="flex items-start gap-3">- <div className="shrink-0 size-5 flex items-center justify-center">- <IconLoader2 className="size-5 text-accent animate-spin origin-center" />- </div>- <div>- <DialogTitle>{t('mcp-servers:browserExtension.connecting.title')}</DialogTitle>- <DialogDescription className="mt-1 text-main-view-fg/70">- {t('mcp-servers:browserExtension.connecting.description')}- </DialogDescription>- </div>- </div>- </DialogHeader>- <div className="flex items-center justify-center py-8">- <div className="flex flex-col items-center justify-center gap-3">- <IconLoader2 className="size-8 text-accent animate-spin origin-center" />- <p className="text-sm text-main-view-fg/60">{t('mcp-servers:browserExtension.connecting.checking')}</p>- </div>+ <div className="flex items-center justify-center py-8">+ <div className="flex flex-col items-center justify-center gap-3">+ <IconLoader2 className="size-8 text-accent animate-spin origin-center" />+ <p className="text-sm text-main-view-fg/60">{t('mcp-servers:browserExtension.connecting.checking')}</p></div>- </>+ </div>)case 'not_installed':return (<><DialogHeader>- <div className="flex items-start gap-3">- <div className="shrink-0">- <IconWorld className="size-5 text-accent" />- </div>- <div>- <DialogTitle>{t('mcp-servers:browserExtension.notInstalled.title')}</DialogTitle>- <DialogDescription className="mt-1 text-main-view-fg/70">- {t('mcp-servers:browserExtension.notInstalled.description')}- </DialogDescription>- </div>- </div>+ <DialogTitle>{t('mcp-servers:browserExtension.notInstalled.title')}</DialogTitle>+ <DialogDescription className="mt-1 text-main-view-fg/70">+ {t('mcp-servers:browserExtension.notInstalled.description')}+ </DialogDescription></DialogHeader>- <div className="bg-main-view-fg/2 p-4 border border-main-view-fg/5 rounded-lg space-y-3">- <h4 className="font-medium text-sm">{t('mcp-servers:browserExtension.notInstalled.whatCanDo')}</h4>- <ul className="text-sm text-main-view-fg/70 space-y-2">- <li className="flex items-start gap-2">- <span className="text-accent">•</span>- <span>{t('mcp-servers:browserExtension.notInstalled.feature1')}</span>- </li>- <li className="flex items-start gap-2">- <span className="text-accent">•</span>- <span>{t('mcp-servers:browserExtension.notInstalled.feature2')}</span>- </li>- <li className="flex items-start gap-2">- <span className="text-accent">•</span>- <span>{t('mcp-servers:browserExtension.notInstalled.feature3')}</span>- </li>- </ul>- </div>-- <DialogFooter className="flex flex-col gap-2 sm:flex-row sm:justify-between">+ <DialogFooter className="flex gap-2 sm:justify-end"><Button- variant="link"+ variant="outline"onClick={handleCancel}- className="sm:order-1">{t('common:cancel')}</Button>- <div className="flex gap-2 sm:order-2">- <Button- onClick={onRetryConnection}- className="gap-2 bg-transparent border border-main-view-fg/20 text-main-view-fg hover:bg-main-view-fg/10"- >- <IconRefresh className="size-4" />- {t('mcp-servers:browserExtension.notInstalled.installed')}- </Button>- <Button- onClick={handleOpenChromeStore}- className="gap-2"- >- <IconExternalLink className="size-4" />- {t('mcp-servers:browserExtension.notInstalled.getExtension')}- </Button>- </div>- </DialogFooter>- </>- )-- case 'waiting_connection':- return (- <>- <DialogHeader>- <div className="flex items-start gap-3">- <div className="shrink-0 size-5 flex items-center justify-center">- <IconLoader2 className="size-5 text-accent animate-spin origin-center" />- </div>- <div>- <DialogTitle>{t('mcp-servers:browserExtension.waitingConnection.title')}</DialogTitle>- <DialogDescription className="mt-1 text-main-view-fg/70">- {t('mcp-servers:browserExtension.waitingConnection.description')}- </DialogDescription>- </div>- </div>- </DialogHeader>-- <div className="bg-main-view-fg/2 p-4 border border-main-view-fg/5 rounded-lg space-y-3">- <h4 className="font-medium text-sm">{t('mcp-servers:browserExtension.waitingConnection.howToConnect')}</h4>- <ol className="text-sm text-main-view-fg/70 space-y-2 list-decimal list-inside">- <li>{t('mcp-servers:browserExtension.waitingConnection.step1')}</li>- <li>{t('mcp-servers:browserExtension.waitingConnection.step2')}</li>- <li>{t('mcp-servers:browserExtension.waitingConnection.step3')}</li>- </ol>- </div>-- <DialogFooter className="flex flex-col gap-2 sm:flex-row sm:justify-between"><Button- variant="link"- onClick={handleCancel}- className="sm:order-1"+ onClick={handleOpenChromeStore}+ className="gap-2">- {t('common:cancel')}- </Button>- <div className="flex gap-2 sm:order-2">- {onContinueAnyway && (- <Button- onClick={onContinueAnyway}- className="bg-transparent border border-main-view-fg/20 text-main-view-fg hover:bg-main-view-fg/10"- >- {t('mcp-servers:browserExtension.waitingConnection.continueAnyway')}- </Button>- )}- <Button- onClick={onRetryConnection}- className="gap-2"- >- <IconRefresh className="size-4" />- {t('mcp-servers:browserExtension.waitingConnection.checkAgain')}- </Button>- </div>- </DialogFooter>- </>- )-- case 'connected':- return (- <>- <DialogHeader>- <div className="flex items-start gap-3">- <div className="shrink-0">- <IconCheck className="size-5 text-green-500" />- </div>- <div>- <DialogTitle>{t('mcp-servers:browserExtension.connected.title')}</DialogTitle>- <DialogDescription className="mt-1 text-main-view-fg/70">- {t('mcp-servers:browserExtension.connected.description')}- </DialogDescription>- </div>- </div>- </DialogHeader>-- <div className="flex items-center justify-center py-6">- <div className="flex flex-col items-center gap-3">- <div className="bg-green-500/10 rounded-full p-4">- <IconCheck className="size-8 text-green-500" />- </div>- <p className="text-sm text-main-view-fg/60">{t('mcp-servers:browserExtension.connected.toolsAvailable')}</p>- </div>- </div>-- <DialogFooter>- <Button onClick={handleClose} className="w-full sm:w-auto">- {t('mcp-servers:browserExtension.connected.done')}+ <IconExternalLink className="size-4" />+ {t('mcp-servers:browserExtension.notInstalled.getExtension')}</Button></DialogFooter></>@@ -252,21 +102,13 @@ export default function JanBrowserExtensionDialog({}}- // Handle dialog open change - route close actions through cancel handler- // except for 'connected' state where we just close without deactivatingconst handleOpenChange = useCallback((newOpen: boolean) => {if (!newOpen) {- if (state === 'connected') {- // Successfully connected - just close without deactivating- handleClose()- } else {- // User is trying to close/cancel - deactivate server- handleCancel()- }+ handleCancel()} else {onOpenChange(newOpen)}- }, [state, handleCancel, handleClose, onOpenChange])+ }, [handleCancel, onOpenChange])return (<Dialog open={open && state !== 'closed'} onOpenChange={handleOpenChange}>diff --git a/web-app/src/hooks/useJanBrowserExtension.ts b/web-app/src/hooks/useJanBrowserExtension.tsindex 83d07c474..1adb6fdef 100644--- a/web-app/src/hooks/useJanBrowserExtension.ts+++ b/web-app/src/hooks/useJanBrowserExtension.ts@@ -10,7 +10,6 @@ const JAN_BROWSER_MCP_NAME = 'Jan Browser MCP'const PING_TIMEOUT_MS = 6000 // Backend ping takes up to 3sconst POLL_INTERVAL_MS = 500const SERVER_START_DELAY_MS = 1000-const SUCCESS_CLOSE_DELAY_MS = 1500export function useJanBrowserExtension() {const serviceHub = useServiceHub()@@ -63,42 +62,12 @@ export function useJanBrowserExtension() {}, [checkExtensionConnection])/**- * Handle successful connection - show success state and auto-close+ * Handle successful connection - close dialog and show toast*/const handleConnectionSuccess = useCallback(() => {- setDialogState('connected')- toast.success('Jan Browser MCP enabled')- setTimeout(() => {- setDialogOpen(false)- setDialogState('closed')- }, SUCCESS_CLOSE_DELAY_MS)- }, [])-- /**- * Handle retry connection (called from dialog's "I've Installed It" or "Check Again" button)- */- const handleRetryConnection = useCallback(async () => {- setDialogState('checking')-- const connected = await waitForExtensionConnection(PING_TIMEOUT_MS, POLL_INTERVAL_MS)-- if (connected) {- handleConnectionSuccess()- } else {- // Still not connected, show waiting state- setDialogState('waiting_connection')- }- }, [waitForExtensionConnection, handleConnectionSuccess])-- /**- * Handle continue anyway (user wants to proceed without extension)- */- const handleContinueAnyway = useCallback(() => {setDialogOpen(false)setDialogState('closed')- toast.info('Jan Browser MCP is active', {- description: 'Connect the browser extension to use browser tools',- })+ toast.success('Jan Browser MCP enabled')}, [])/**@@ -241,8 +210,6 @@ export function useJanBrowserExtension() {// ActionstoggleBrowser,- handleRetryConnection,- handleContinueAnyway,handleCancel,setDialogOpen,}diff --git a/web-app/src/locales/en/mcp-servers.json b/web-app/src/locales/en/mcp-servers.jsonindex 5fe075889..7825bd651 100644--- a/web-app/src/locales/en/mcp-servers.json+++ b/web-app/src/locales/en/mcp-servers.json@@ -3,35 +3,12 @@"addServer": "Add MCP Server","browserExtension": {"connecting": {- "title": "Connecting to Jan Browser Extension",- "description": "Please wait while we check for the browser extension...","checking": "Checking extension status..."},"notInstalled": {- "title": "Install Jan Browser Extension",- "description": "To use browser automation features, you need to install the Jan Browser Extension.",- "whatCanDo": "What can Jan Browser do?",- "feature1": "Search the web and extract information from pages",- "feature2": "Navigate websites and take screenshots",- "feature3": "Click, type, and interact with web elements",- "installed": "I've Installed It",+ "title": "Jan completes tasks in your browser",+ "description": "Install the extension to give Jan browser access","getExtension": "Get Extension"- },- "waitingConnection": {- "title": "Waiting for Extension Connection",- "description": "The MCP server is running. Please open the Jan Browser Extension in your browser to connect.",- "howToConnect": "How to connect:",- "step1": "Click the Jan Browser Extension icon in your browser toolbar",- "step2": "Click \"Connect\" in the extension popup",- "step3": "The extension will automatically connect to Jan",- "continueAnyway": "Continue Anyway",- "checkAgain": "Check Again"- },- "connected": {- "title": "Extension Connected!",- "description": "The Jan Browser Extension is connected and ready to use.",- "toolsAvailable": "Browser tools are now available",- "done": "Done"}},"serverName": "Server Name",