Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.
chore: update base layout windows
Faisal Amir9a765c729cd6
diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.jsonindex 5b1c23390..b6a4eba7f 100644--- a/src-tauri/capabilities/default.json+++ b/src-tauri/capabilities/default.json@@ -11,6 +11,9 @@"core:webview:allow-set-webview-zoom","core:window:allow-start-dragging","core:window:allow-set-theme",+ "core:window:allow-minimize",+ "core:window:allow-toggle-maximize",+ "core:window:allow-close","shell:allow-spawn","shell:allow-open","core:app:allow-set-app-theme",diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.jsonindex ffb5e62d1..40392e546 100644--- a/src-tauri/tauri.conf.json+++ b/src-tauri/tauri.conf.json@@ -29,7 +29,7 @@"x": 20,"y": 32},- "decorations": true,+ "decorations": false,"titleBarStyle": "Overlay","windowEffects": {"effects": ["fullScreenUI", "mica", "tabbed", "blur", "acrylic"],diff --git a/web-app/src/components/WindowControls.tsx b/web-app/src/components/WindowControls.tsxnew file mode 100644index 000000000..a7c9edb7b--- /dev/null+++ b/web-app/src/components/WindowControls.tsx@@ -0,0 +1,51 @@+import { Minus, Square, X } from 'lucide-react'+import { getCurrentWebviewWindow } from '@tauri-apps/api/webviewWindow'+import { Button } from '@/components/ui/button'++export const WindowControls = () => {+ const appWindow = getCurrentWebviewWindow()++ const handleMinimize = async () => {+ console.log('Minimizing window')+ await appWindow.minimize()+ }++ const handleMaximize = async () => {+ await appWindow.toggleMaximize()+ }++ const handleClose = async () => {+ await appWindow.close()+ }++ return (+ <div className="absolute top-0 z-50 right-4 h-15">+ <div className="flex items-center h-full">+ <Button+ onClick={handleMinimize}+ aria-label="Minimize"+ variant="ghost"+ size="icon-sm"+ >+ <Minus className="size-4" />+ </Button>+ <Button+ onClick={handleMaximize}+ variant="ghost"+ size="icon-sm"+ aria-label="Maximize"+ >+ <Square className="size-3" />+ </Button>+ <Button+ onClick={handleClose}+ variant="ghost"+ size="icon-sm"+ aria-label="Close"+ >+ <X className="size-4" />+ </Button>+ </div>+ </div>+ )+}diff --git a/web-app/src/components/left-sidebar/NavMain.tsx b/web-app/src/components/left-sidebar/NavMain.tsxindex a90aed253..366d5b994 100644--- a/web-app/src/components/left-sidebar/NavMain.tsx+++ b/web-app/src/components/left-sidebar/NavMain.tsx@@ -1,91 +1,120 @@-import { LucideIcon } from "lucide-react"+import { LucideIcon } from 'lucide-react'import { route } from '@/constants/routes'import {SidebarMenu,SidebarMenuButton,SidebarMenuItem,-} from "@/components/ui/sidebar"-import { Kbd, KbdGroup } from "@/components/ui/kbd"-import { useTranslation } from "@/i18n/react-i18next-compat"+} from '@/components/ui/sidebar'+import { Kbd, KbdGroup } from '@/components/ui/kbd'+import { useTranslation } from '@/i18n/react-i18next-compat'-import { Link, useNavigate } from "@tanstack/react-router"-import { PlatformMetaKey } from "@/containers/PlatformMetaKey"-import React, { useRef } from "react"-import { SearchIcon, type SearchIconHandle } from "@/components/animated-icon/search"-import { FolderPlusIcon, type FolderPlusIconHandle } from "@/components/animated-icon/folder-plus"-import { MessageCircleIcon, type MessageCircleIconHandle } from "@/components/animated-icon/message-circle"-import { SettingsIcon, type SettingsIconHandle } from "@/components/animated-icon/settings"-import { BlocksIcon, type BlocksIconHandle } from "../animated-icon/blocks"-import AddProjectDialog from "@/containers/dialogs/AddProjectDialog"-import { SearchDialog } from "@/containers/dialogs/SearchDialog"-import { useThreadManagement } from "@/hooks/useThreadManagement"-import { useSearchDialog } from "@/hooks/useSearchDialog"-import { useProjectDialog } from "@/hooks/useProjectDialog"+import { Link, useNavigate } from '@tanstack/react-router'+import { PlatformMetaKey } from '@/containers/PlatformMetaKey'+import React, { useRef } from 'react'+import {+ SearchIcon,+ type SearchIconHandle,+} from '@/components/animated-icon/search'+import {+ FolderPlusIcon,+ type FolderPlusIconHandle,+} from '@/components/animated-icon/folder-plus'+import {+ MessageCircleIcon,+ type MessageCircleIconHandle,+} from '@/components/animated-icon/message-circle'+import {+ SettingsIcon,+ type SettingsIconHandle,+} from '@/components/animated-icon/settings'+import { BlocksIcon, type BlocksIconHandle } from '../animated-icon/blocks'+import AddProjectDialog from '@/containers/dialogs/AddProjectDialog'+import { SearchDialog } from '@/containers/dialogs/SearchDialog'+import { useThreadManagement } from '@/hooks/useThreadManagement'+import { useSearchDialog } from '@/hooks/useSearchDialog'+import { useProjectDialog } from '@/hooks/useProjectDialog'-type AnimatedIconHandle = SearchIconHandle | FolderPlusIconHandle | MessageCircleIconHandle | SettingsIconHandle | BlocksIconHandle+type AnimatedIconHandle =+ | SearchIconHandle+ | FolderPlusIconHandle+ | MessageCircleIconHandle+ | SettingsIconHandle+ | BlocksIconHandletype NavMainItem = {title: stringurl?: stringicon?: LucideIcon | React.ComponentType<{ className?: string }>animatedIcon?: React.ForwardRefExoticComponent<- { className?: string; size?: number } & React.RefAttributes<AnimatedIconHandle>+ {+ className?: string+ size?: number+ } & React.RefAttributes<AnimatedIconHandle>>isActive?: booleanshortcut?: React.ReactNodeonClick?: () => void}-const getNavMainItems = (onNewProject: () => void, onSearch: () => void): NavMainItem[] => [+const getNavMainItems = (+ onNewProject: () => void,+ onSearch: () => void+): NavMainItem[] => [{title: 'common:newChat',url: route.home,animatedIcon: MessageCircleIcon,shortcut: (<KbdGroup className="ml-auto scale-90 gap-0">- <Kbd className="bg-transparent size-3 min-w-3"><PlatformMetaKey /></Kbd>- <Kbd className="bg-transparent size-3 min-w-3">N</Kbd>+ <Kbd className="bg-transparent size-3">+ <PlatformMetaKey />+ </Kbd>+ <Kbd className="bg-transparent size-3">N</Kbd></KbdGroup>),},{- title: "common:projects.new",+ title: 'common:projects.new',animatedIcon: FolderPlusIcon,onClick: onNewProject,shortcut: (<KbdGroup className="ml-auto scale-90 gap-0">- <Kbd className="bg-transparent size-3 min-w-3"><PlatformMetaKey /></Kbd>- <Kbd className="bg-transparent size-3 min-w-3">P</Kbd>+ <Kbd className="bg-transparent size-3">+ <PlatformMetaKey />+ </Kbd>+ <Kbd className="bg-transparent size-3">P</Kbd></KbdGroup>),},{- title: "common:search",+ title: 'common:search',animatedIcon: SearchIcon,onClick: onSearch,shortcut: (<KbdGroup className="ml-auto scale-90 gap-0">- <Kbd className="bg-transparent size-3 min-w-3"><PlatformMetaKey /></Kbd>- <Kbd className="bg-transparent size-3 min-w-3">K</Kbd>+ <Kbd className="bg-transparent size-3">+ <PlatformMetaKey />+ </Kbd>+ <Kbd className="bg-transparent size-3">K</Kbd></KbdGroup>),},{- title: "common:hub",+ title: 'common:hub',url: route.hub.index,animatedIcon: BlocksIcon,},{- title: "common:settings",+ title: 'common:settings',url: route.settings.general,animatedIcon: SettingsIcon,- }+ },]function NavMainItemWithAnimatedIcon({item,- label+ label,}: {item: NavMainItemlabel: string@@ -110,11 +139,7 @@ function NavMainItemWithAnimatedIcon({onMouseLeave={() => iconRef.current?.stopAnimation()}onClick={item.onClick}>- {item.url ? (- <Link to={item.url}>{content}</Link>- ) : (- content- )}+ {item.url ? <Link to={item.url}>{content}</Link> : content}</SidebarMenuButton></SidebarMenuItem>)@@ -125,7 +150,8 @@ export function NavMain() {const navigate = useNavigate()const { addFolder } = useThreadManagement()const { open: searchOpen, setOpen: setSearchOpen } = useSearchDialog()- const { open: projectDialogOpen, setOpen: setProjectDialogOpen } = useProjectDialog()+ const { open: projectDialogOpen, setOpen: setProjectDialogOpen } =+ useProjectDialog()const navMainItems = getNavMainItems(() => setProjectDialogOpen(true),@@ -135,7 +161,10 @@ export function NavMain() {const handleCreateProject = async (name: string, assistantId?: string) => {const newProject = await addFolder(name, assistantId)setProjectDialogOpen(false)- navigate({ to: '/project/$projectId', params: { projectId: newProject.id } })+ navigate({+ to: '/project/$projectId',+ params: { projectId: newProject.id },+ })}return (@@ -155,7 +184,11 @@ export function NavMain() {const Icon = item.iconreturn (<SidebarMenuItem key={item.title}>- <SidebarMenuButton asChild={!!item.url} isActive={item.isActive} onClick={item.onClick}>+ <SidebarMenuButton+ asChild={!!item.url}+ isActive={item.isActive}+ onClick={item.onClick}+ >{item.url ? (<Link to={item.url}>{Icon && <Icon className="text-foreground/70" />}@@ -182,10 +215,7 @@ export function NavMain() {onSave={handleCreateProject}/>- <SearchDialog- open={searchOpen}- onOpenChange={setSearchOpen}- />+ <SearchDialog open={searchOpen} onOpenChange={setSearchOpen} /></>)}diff --git a/web-app/src/components/left-sidebar/index.tsx b/web-app/src/components/left-sidebar/index.tsxindex 9cec9ec11..491537a67 100644--- a/web-app/src/components/left-sidebar/index.tsx+++ b/web-app/src/components/left-sidebar/index.tsx@@ -1,7 +1,7 @@-import { DownloadManagement } from "@/containers/DownloadManegement"-import { NavChats } from "./NavChats"-import { NavMain } from "./NavMain"-import { NavProjects } from "./NavProjects"+import { DownloadManagement } from '@/containers/DownloadManegement'+import { NavChats } from './NavChats'+import { NavMain } from './NavMain'+import { NavProjects } from './NavProjects'import {Sidebar,@@ -10,23 +10,26 @@ import {SidebarTrigger,SidebarHeader,SidebarRail,-} from "@/components/ui/sidebar"+} from '@/components/ui/sidebar'export function LeftSidebar() {return (<Sidebar variant="floating" collapsible="offcanvas">- <SidebarHeader className="flex items-end px-1">- <SidebarTrigger className="text-muted-foreground rounded-full hover:bg-sidebar-foreground/8! -mt-0.5" />+ <SidebarHeader className="flex px-1">+ <div className="flex items-center w-full justify-between">+ <span className="ml-2 font-medium font-studio">Jan</span>+ <SidebarTrigger className="text-muted-foreground rounded-full hover:bg-sidebar-foreground/8! -mt-0.5" />+ </div><NavMain /></SidebarHeader><SidebarContent className="mask-b-from-95% mask-t-from-98%"><NavProjects /><NavChats /></SidebarContent>- <SidebarFooter >+ <SidebarFooter><DownloadManagement />- </SidebarFooter >+ </SidebarFooter><SidebarRail /></Sidebar>)-}\ No newline at end of file+}diff --git a/web-app/src/routes/__root.tsx b/web-app/src/routes/__root.tsxindex 286caf25a..030a09e3d 100644--- a/web-app/src/routes/__root.tsx+++ b/web-app/src/routes/__root.tsx@@ -25,9 +25,9 @@ import { useEffect } from 'react'import GlobalError from '@/containers/GlobalError'import { GlobalEventHandler } from '@/providers/GlobalEventHandler'import { ServiceHubProvider } from '@/providers/ServiceHubProvider'-import { SidebarInset, SidebarProvider } from "@/components/ui/sidebar"+import { SidebarInset, SidebarProvider } from '@/components/ui/sidebar'import { LeftSidebar } from '@/components/left-sidebar'-+import { WindowControls } from '@/components/WindowControls'export const Route = createRootRoute({component: RootLayout,@@ -45,7 +45,7 @@ const AppLayout = () => {} = useLeftPanel()return (- <div className='bg-neutral-50 dark:bg-background size-full'>+ <div className="bg-neutral-50 dark:bg-background size-full relative"><SidebarProvideropen={isLeftPanelOpen}onOpenChange={setLeftPanel}@@ -55,21 +55,19 @@ const AppLayout = () => {<AnalyticProvider /><KeyboardShortcutsProvider />{/* Fake absolute panel top to enable window drag */}- {IS_MACOS &&- <div className="fixed w-full h-3 z-20 top-0" data-tauri-drag-region />- }+ {!IS_MACOS && <WindowControls />}+ <div className="fixed w-full h-3 z-20 top-0" data-tauri-drag-region /><DialogAppUpdater /><BackendUpdater /><LeftSidebar />- <SidebarInset >- <div className='bg-neutral-50 dark:bg-background size-full'>+ <SidebarInset>+ <div className="bg-neutral-50 dark:bg-background size-full"><Outlet /></div></SidebarInset>{productAnalyticPrompt && <PromptAnalytic />}{showJanModelPrompt && <PromptJanModel />}-</SidebarProvider></div>)diff --git a/web-app/src/routes/settings/assistant.tsx b/web-app/src/routes/settings/assistant.tsxindex 7dc03db61..f8715a3af 100644--- a/web-app/src/routes/settings/assistant.tsx+++ b/web-app/src/routes/settings/assistant.tsx@@ -53,8 +53,10 @@ function AssistantContent() {return (<div className="flex flex-col h-svh w-full"><HeaderPage>- <div className="flex items-center justify-between w-full mr-2 pr-4">- <span className='font-medium text-base font-studio'>{t('common:settings')}</span>+ <div className="flex items-center justify-between w-full mr-2 pr-30">+ <span className="font-medium text-base font-studio">+ {t('common:settings')}+ </span><ButtononClick={() => {setEditingKey(null)@@ -129,7 +131,9 @@ function AssistantContent() {onOpenChange={setOpen}editingKey={editingKey}initialData={- editingKey ? assistants.find((a) => a.id === editingKey) : undefined+ editingKey+ ? assistants.find((a) => a.id === editingKey)+ : undefined}onSave={handleSave}/>