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.

Merge remote-tracking branch 'origin/dev' into mobile/dev

Vanalitec53d8c09c40e
diff --cc web-app/src/containers/HeaderPage.tsx
index 2cfa8b50d,ffa9b0aa2..91dbe4c7a
--- a/web-app/src/containers/HeaderPage.tsx
+++ b/web-app/src/containers/HeaderPage.tsx
@@@ -1,16 -1,40 +1,43 @@@
import { useLeftPanel } from '@/hooks/useLeftPanel'
import { cn } from '@/lib/utils'
- import { IconLayoutSidebar } from '@tabler/icons-react'
- import { ReactNode } from 'react'
+import { useMobileScreen, useSmallScreen } from '@/hooks/useMediaQuery'
+ import { IconLayoutSidebar, IconMessage, IconMessageFilled } from '@tabler/icons-react'
-import { ReactNode } from '@tanstack/react-router'
++import { ReactNode } from 'react'
+ import { useRouter } from '@tanstack/react-router'
+ import { route } from '@/constants/routes'
+ import { PlatformFeatures } from '@/lib/platform/const'
+ import { PlatformFeature } from '@/lib/platform/types'
+ import { TEMPORARY_CHAT_QUERY_ID } from '@/constants/chat'
type HeaderPageProps = {
children?: ReactNode
}
const HeaderPage = ({ children }: HeaderPageProps) => {
const { open, setLeftPanel } = useLeftPanel()
+ const isMobile = useMobileScreen()
+ const isSmallScreen = useSmallScreen()
+ const router = useRouter()
+ const currentPath = router.state.location.pathname
+
+ const isHomePage = currentPath === route.home
+
+ // Parse temporary chat flag from URL search params directly to avoid invariant errors
+ const searchString = window.location.search
+ const urlSearchParams = new URLSearchParams(searchString)
+ const isTemporaryChat = isHomePage && urlSearchParams.get(TEMPORARY_CHAT_QUERY_ID) === 'true'
+
+ const handleChatToggle = () => {
+ console.log('Chat toggle clicked!', { isTemporaryChat, isHomePage, currentPath })
+ if (isHomePage) {
+ if (isTemporaryChat) {
+ console.log('Switching to regular chat')
+ router.navigate({ to: route.home, search: {} })
+ } else {
+ console.log('Switching to temporary chat')
+ router.navigate({ to: route.home, search: { [TEMPORARY_CHAT_QUERY_ID]: true } })
+ }
+ }
+ }
return (
<div
@@@ -44,12 -56,30 +71,35 @@@
/>
</button>
)}
- {children}
+ <div className={cn(
+ 'flex-1 min-w-0', // Allow content to shrink on small screens
+ isMobile && 'overflow-hidden'
+ )}>
+ {children}
+ </div>
+
+ {/* Temporary Chat Toggle - Only show on home page if feature is enabled */}
+ {PlatformFeatures[PlatformFeature.TEMPORARY_CHAT] && isHomePage && (
+ <div className="ml-auto">
+ <button
+ className="size-8 cursor-pointer flex items-center justify-center rounded hover:bg-main-view-fg/10 transition-all duration-200 ease-in-out relative z-20"
+ onClick={handleChatToggle}
+ title={isTemporaryChat ? 'Switch to Regular Chat' : 'Start Temporary Chat'}
+ >
+ {isTemporaryChat ? (
+ <IconMessageFilled
+ size={18}
+ className="text-main-view-fg"
+ />
+ ) : (
+ <IconMessage
+ size={18}
+ className="text-main-view-fg"
+ />
+ )}
+ </button>
+ </div>
+ )}
</div>
</div>
)
diff --cc web-app/src/lib/platform/const.ts
index 5e7561fa9,5621602b5..d38455a49
--- a/web-app/src/lib/platform/const.ts
+++ b/web-app/src/lib/platform/const.ts
@@@ -69,12 -60,11 +69,15 @@@ export const PlatformFeatures: Record<P
[PlatformFeature.GOOGLE_ANALYTICS]: !isPlatformTauri(),
// Alternate shortcut bindings - enabled for web only (to avoid browser conflicts)
- [PlatformFeature.ALTERNATE_SHORTCUT_BINDINGS]: !isPlatformTauri(),
+ [PlatformFeature.ALTERNATE_SHORTCUT_BINDINGS]:
+ !isPlatformTauri() && !isPlatformIOS() && !isPlatformAndroid(),
+ // Shortcut
+ [PlatformFeature.SHORTCUT]: !isPlatformIOS() && !isPlatformAndroid(),
+
// First message persisted thread - enabled for web only
[PlatformFeature.FIRST_MESSAGE_PERSISTED_THREAD]: !isPlatformTauri(),
+
- // Temporary chat mode - enabled for web only
++ // Temporary chat mode - enabled for web only
+ [PlatformFeature.TEMPORARY_CHAT]: !isPlatformTauri(),
-}
+}
diff --cc web-app/src/routes/index.tsx
index 61669a503,cd501db3d..d5477f56d
--- a/web-app/src/routes/index.tsx
+++ b/web-app/src/routes/index.tsx
@@@ -19,9 -18,9 +20,10 @@@ type SearchParams =
import DropdownAssistant from '@/containers/DropdownAssistant'
import { useEffect } from 'react'
import { useThreads } from '@/hooks/useThreads'
+import { useMobileScreen } from '@/hooks/useMediaQuery'
import { PlatformFeatures } from '@/lib/platform/const'
import { PlatformFeature } from '@/lib/platform/types'
+ import { TEMPORARY_CHAT_QUERY_ID } from '@/constants/chat'
export const Route = createFileRoute(route.home as any)({
component: Index,
@@@ -35,9 -43,8 +46,10 @@@ function Index()
const { providers } = useModelProvider()
const search = useSearch({ from: route.home as any })
const selectedModel = search.model
+ const isTemporaryChat = search['temporary-chat']
const { setCurrentThreadId } = useThreads()
+ const isMobile = useMobileScreen()
+ useTools()
// Conditional to check if there are any valid providers
// required min 1 api_key or 1 model in llama.cpp or jan provider
@@@ -61,42 -68,14 +73,42 @@@
<HeaderPage>
{PlatformFeatures[PlatformFeature.ASSISTANTS] && <DropdownAssistant />}
</HeaderPage>
- <div className="h-full px-4 md:px-8 overflow-y-auto flex flex-col gap-2 justify-center">
- <div className="w-full md:w-4/6 mx-auto">
- <div className="mb-8 text-center">
- <h1 className="font-editorialnew text-main-view-fg text-4xl">
+ <div
+ className={cn(
+ 'h-full overflow-y-auto flex flex-col gap-2 justify-center px-3 sm:px-4 md:px-8 py-4 md:py-0'
+ )}
+ >
+ <div
+ className={cn(
+ 'mx-auto',
+ // Full width on mobile, constrained on desktop
+ isMobile ? 'w-full max-w-full' : 'w-full md:w-4/6'
+ )}
+ >
+ <div
+ className={cn(
+ 'text-center',
+ // Adjust spacing for mobile
+ isMobile ? 'mb-6' : 'mb-8'
+ )}
+ >
+ <h1
+ className={cn(
+ 'font-editorialnew text-main-view-fg',
+ // Responsive title size
+ isMobile ? 'text-2xl sm:text-3xl' : 'text-4xl'
+ )}
+ >
- {t('chat:welcome')}
+ {isTemporaryChat ? t('chat:temporaryChat') : t('chat:welcome')}
</h1>
- <p className="text-main-view-fg/70 text-lg mt-2">
+ <p
+ className={cn(
+ 'text-main-view-fg/70 mt-2',
+ // Responsive description size
+ isMobile ? 'text-base' : 'text-lg'
+ )}
+ >
- {t('chat:description')}
+ {isTemporaryChat ? t('chat:temporaryChatDescription') : t('chat:description')}
</p>
</div>
<div className="flex-1 shrink-0">
diff --cc web-app/src/routes/threads/$threadId.tsx
index 93e27d640,a8bd03d29..1d0fc4932
--- a/web-app/src/routes/threads/$threadId.tsx
+++ b/web-app/src/routes/threads/$threadId.tsx
@@@ -137,12 -207,18 +210,18 @@@ function ThreadDetail()
if (!messages || !threadModel) return null
return (
- <div className="flex flex-col h-full">
+ <div className="flex flex-col h-[calc(100dvh-(env(safe-area-inset-bottom)+env(safe-area-inset-top)))]">
<HeaderPage>
<div className="flex items-center justify-between w-full pr-2">
- {PlatformFeatures[PlatformFeature.ASSISTANTS] && (
- <DropdownAssistant />
- )}
+ <div>
+ {PlatformFeatures[PlatformFeature.ASSISTANTS] && (
+ <DropdownAssistant />
+ )}
+ </div>
+ <div className="flex-1 flex justify-center">
+ {threadId === TEMPORARY_CHAT_ID && <TemporaryChatIndicator t={t} />}
+ </div>
+ <div></div>
</div>
</HeaderPage>
<div className="flex flex-col h-[calc(100%-40px)]">