Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.
✨enhancement: dialog model error trigger from provider screen and improve copy button (#5858)
Faisal Amir5553096bc4b1
diff --git a/web-app/src/containers/dialogs/LoadModelErrorDialog.tsx b/web-app/src/containers/dialogs/LoadModelErrorDialog.tsxindex 7d1c98699..2b7a1e703 100644--- a/web-app/src/containers/dialogs/LoadModelErrorDialog.tsx+++ b/web-app/src/containers/dialogs/LoadModelErrorDialog.tsx@@ -8,20 +8,33 @@ import {} from '@/components/ui/dialog'import { Button } from '@/components/ui/button'import { AlertTriangle } from 'lucide-react'+import { IconCopy, IconCopyCheck } from '@tabler/icons-react'import { useTranslation } from '@/i18n/react-i18next-compat'import { useModelLoad } from '@/hooks/useModelLoad'import { toast } from 'sonner'+import { useState } from 'react'export default function LoadModelErrorDialog() {const { t } = useTranslation()const { modelLoadError, setModelLoadError } = useModelLoad()+ const [isCopying, setIsCopying] = useState(false)- const handleCopy = () => {- navigator.clipboard.writeText(modelLoadError ?? '')- toast.success('Copy successful', {- id: 'copy-model',- description: 'Model load error information copied to clipboard',- })+ const handleCopy = async () => {+ setIsCopying(true)+ try {+ await navigator.clipboard.writeText(modelLoadError ?? '')+ toast.success('Copy successful', {+ id: 'copy-model',+ description: 'Model load error information copied to clipboard',+ })+ } catch {+ toast.error('Failed to copy', {+ id: 'copy-model-error',+ description: 'Failed to copy error information to clipboard',+ })+ } finally {+ setTimeout(() => setIsCopying(false), 2000)+ }}const handleDialogOpen = (open: boolean) => {@@ -34,7 +47,7 @@ export default function LoadModelErrorDialog() {<DialogHeader><div className="flex items-start gap-3"><div className="shrink-0">- <AlertTriangle className="size-4" />+ <AlertTriangle className="size-4 text-destructive" /></div><div><DialogTitle>{t('common:error')}</DialogTitle>@@ -47,7 +60,7 @@ export default function LoadModelErrorDialog() {<div className="bg-main-view-fg/8 p-2 border border-main-view-fg/5 rounded-lg"><p- className="text-sm text-main-view-fg/70 leading-relaxed max-h-[200px] overflow-y-auto"+ className="text-sm text-main-view-fg/70 leading-relaxed max-h-[200px] overflow-y-auto break-all"ref={(el) => {if (el) {el.scrollTop = el.scrollHeight@@ -61,17 +74,29 @@ export default function LoadModelErrorDialog() {<DialogFooter className="flex flex-col gap-2 sm:flex-row sm:justify-right"><Buttonvariant="link"- onClick={() => handleCopy()}+ onClick={() => handleDialogOpen(false)}className="flex-1 text-right sm:flex-none">- {t('common:copy')}+ {t('common:cancel')}</Button><Buttonvariant="link"- onClick={() => handleDialogOpen(false)}- className="flex-1 text-right sm:flex-none"+ onClick={() => handleCopy()}+ disabled={isCopying}+ autoFocus+ className="flex-1 text-right sm:flex-none border border-main-view-fg/20 !px-2">- {t('common:cancel')}+ {isCopying ? (+ <>+ <IconCopyCheck className="text-accent" />+ {t('common:copied')}+ </>+ ) : (+ <>+ <IconCopy />+ {t('common:copy')}+ </>+ )}</Button></DialogFooter></DialogContent>diff --git a/web-app/src/routes/settings/providers/$providerName.tsx b/web-app/src/routes/settings/providers/$providerName.tsxindex 2a6f98712..9b1066aa6 100644--- a/web-app/src/routes/settings/providers/$providerName.tsx+++ b/web-app/src/routes/settings/providers/$providerName.tsx@@ -38,6 +38,7 @@ import { getProviders } from '@/services/providers'import { toast } from 'sonner'import { useEffect, useState } from 'react'import { predefinedProviders } from '@/mock/data'+import { useModelLoad } from '@/hooks/useModelLoad'// as route.threadsDetailexport const Route = createFileRoute('/settings/providers/$providerName')({@@ -52,6 +53,7 @@ export const Route = createFileRoute('/settings/providers/$providerName')({function ProviderDetail() {const { t } = useTranslation()+ const { setModelLoadError } = useModelLoad()const steps = [{target: '.first-step-setup-remote-provider',@@ -176,6 +178,7 @@ function ProviderDetail() {}).catch((error) => {console.error('Error starting model:', error)+ setModelLoadError(`${error.message}`)}).finally(() => {// Remove model from loading state