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.

chore: shortcut for new projects

Faisal Amir341e28ea15f0
diff --git a/web-app/src/components/left-sidebar/NavMain.tsx b/web-app/src/components/left-sidebar/NavMain.tsx
index 1cd0e3bd4..3d7fa5e53 100644
--- a/web-app/src/components/left-sidebar/NavMain.tsx
+++ b/web-app/src/components/left-sidebar/NavMain.tsx
@@ -11,7 +11,7 @@ import { useTranslation } from "@/i18n/react-i18next-compat"
import { Link, useNavigate } from "@tanstack/react-router"
import { PlatformMetaKey } from "@/containers/PlatformMetaKey"
-import React, { useRef, useState } from "react"
+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"
@@ -21,6 +21,7 @@ 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
@@ -42,9 +43,9 @@ const getNavMainItems = (onNewProject: () => void, onSearch: () => void): NavMai
url: route.home,
animatedIcon: MessageCircleIcon,
shortcut: (
- <KbdGroup className="ml-auto scale-90">
- <Kbd><PlatformMetaKey /></Kbd>
- <Kbd>N</Kbd>
+ <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>
</KbdGroup>
),
},
@@ -52,15 +53,21 @@ const getNavMainItems = (onNewProject: () => void, onSearch: () => void): NavMai
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>
+ </KbdGroup>
+ ),
},
{
title: "common:search",
animatedIcon: SearchIcon,
onClick: onSearch,
shortcut: (
- <KbdGroup className="ml-auto scale-90">
- <Kbd><PlatformMetaKey /></Kbd>
- <Kbd>K</Kbd>
+ <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>
</KbdGroup>
),
},
@@ -116,9 +123,9 @@ function NavMainItemWithAnimatedIcon({
export function NavMain() {
const { t } = useTranslation()
const navigate = useNavigate()
- const [projectDialogOpen, setProjectDialogOpen] = useState(false)
const { addFolder } = useThreadManagement()
const { open: searchOpen, setOpen: setSearchOpen } = useSearchDialog()
+ const { open: projectDialogOpen, setOpen: setProjectDialogOpen } = useProjectDialog()
const navMainItems = getNavMainItems(
() => setProjectDialogOpen(true),
diff --git a/web-app/src/containers/Card.tsx b/web-app/src/containers/Card.tsx
index 4c98673e7..83ae89f32 100644
--- a/web-app/src/containers/Card.tsx
+++ b/web-app/src/containers/Card.tsx
@@ -72,7 +72,7 @@ export function CardItem({
export function Card({ title, children, header }: CardProps) {
return (
- <div className="bg-secondary dark:bg-secondary/30 p-4 rounded-lg text-muted-foreground w-full">
+ <div className="bg-card p-4 rounded-lg text-muted-foreground w-full">
{title && (
<h1 className="text-foreground font-studio font-medium text-base mb-4">
{title}
diff --git a/web-app/src/hooks/useInterfaceSettings.ts b/web-app/src/hooks/useInterfaceSettings.ts
index 5927f406e..dcfccc332 100644
--- a/web-app/src/hooks/useInterfaceSettings.ts
+++ b/web-app/src/hooks/useInterfaceSettings.ts
@@ -11,7 +11,7 @@ export const ACCENT_COLORS = [
value: 'gray',
thumb: '#3F3F46',
primary: '#f17455',
- sidebar: { light: '#fafafa', dark: '#171717' },
+ sidebar: { light: '#f1f1f1', dark: '#171717' },
},
{
name: 'Red',
diff --git a/web-app/src/hooks/useProjectDialog.ts b/web-app/src/hooks/useProjectDialog.ts
new file mode 100644
index 000000000..073b57e06
--- /dev/null
+++ b/web-app/src/hooks/useProjectDialog.ts
@@ -0,0 +1,11 @@
+import { create } from 'zustand'
+
+type ProjectDialogState = {
+ open: boolean
+ setOpen: (value: boolean) => void
+}
+
+export const useProjectDialog = create<ProjectDialogState>()((set) => ({
+ open: false,
+ setOpen: (value) => set({ open: value }),
+}))
diff --git a/web-app/src/lib/shortcuts/const.ts b/web-app/src/lib/shortcuts/const.ts
index cce632468..e7534f35a 100644
--- a/web-app/src/lib/shortcuts/const.ts
+++ b/web-app/src/lib/shortcuts/const.ts
@@ -19,6 +19,9 @@ export const PlatformShortcuts: ShortcutMap = {
// New chat - different per platform to avoid browser "new window" conflict
[ShortcutAction.NEW_CHAT]: { key: 'n', usePlatformMetaKey: true },
+ // New project - opens create project dialog
+ [ShortcutAction.NEW_PROJECT]: { key: 'p', usePlatformMetaKey: true },
+
// Go to settings - different per platform to avoid browser "preferences" conflict
[ShortcutAction.GO_TO_SETTINGS]: { key: ',', usePlatformMetaKey: true },
diff --git a/web-app/src/lib/shortcuts/types.ts b/web-app/src/lib/shortcuts/types.ts
index 1bd51fffb..468c78f0c 100644
--- a/web-app/src/lib/shortcuts/types.ts
+++ b/web-app/src/lib/shortcuts/types.ts
@@ -5,6 +5,7 @@
export enum ShortcutAction {
NEW_CHAT = 'newChat',
+ NEW_PROJECT = 'newProject',
TOGGLE_SIDEBAR = 'toggleSidebar',
GO_TO_SETTINGS = 'goSettings',
SEARCH = 'search',
diff --git a/web-app/src/locales/en/settings.json b/web-app/src/locales/en/settings.json
index 7bb0aa568..c2999754a 100644
--- a/web-app/src/locales/en/settings.json
+++ b/web-app/src/locales/en/settings.json
@@ -61,6 +61,8 @@
"application": "Application",
"newChat": "New Chat",
"newChatDesc": "Create a new chat.",
+ "newProject": "New Project",
+ "newProjectDesc": "Open the create project dialog.",
"toggleSidebar": "Toggle Sidebar",
"toggleSidebarDesc": "Show or hide the sidebar.",
"zoomIn": "Zoom In",
diff --git a/web-app/src/providers/KeyboardShortcuts.tsx b/web-app/src/providers/KeyboardShortcuts.tsx
index c165862f1..92fc8c73e 100644
--- a/web-app/src/providers/KeyboardShortcuts.tsx
+++ b/web-app/src/providers/KeyboardShortcuts.tsx
@@ -1,6 +1,7 @@
import { useKeyboardShortcut } from '@/hooks/useHotkeys'
import { useLeftPanel } from '@/hooks/useLeftPanel'
import { useSearchDialog } from '@/hooks/useSearchDialog'
+import { useProjectDialog } from '@/hooks/useProjectDialog'
import { useRouter } from '@tanstack/react-router'
import { route } from '@/constants/routes'
import { PlatformShortcuts, ShortcutAction } from '@/lib/shortcuts'
@@ -8,11 +9,13 @@ import { PlatformShortcuts, ShortcutAction } from '@/lib/shortcuts'
export function KeyboardShortcutsProvider() {
const { open, setLeftPanel } = useLeftPanel()
const { setOpen: setSearchOpen } = useSearchDialog()
+ const { setOpen: setProjectDialogOpen } = useProjectDialog()
const router = useRouter()
// Get shortcut specs from centralized configuration
const sidebarShortcut = PlatformShortcuts[ShortcutAction.TOGGLE_SIDEBAR]
const newChatShortcut = PlatformShortcuts[ShortcutAction.NEW_CHAT]
+ const newProjectShortcut = PlatformShortcuts[ShortcutAction.NEW_PROJECT]
const settingsShortcut = PlatformShortcuts[ShortcutAction.GO_TO_SETTINGS]
const searchShortcut = PlatformShortcuts[ShortcutAction.SEARCH]
@@ -32,6 +35,14 @@ export function KeyboardShortcutsProvider() {
},
})
+ // New Project
+ useKeyboardShortcut({
+ ...newProjectShortcut,
+ callback: () => {
+ setProjectDialogOpen(true)
+ },
+ })
+
// Go to Settings
useKeyboardShortcut({
...settingsShortcut,
diff --git a/web-app/src/routes/settings/shortcuts.tsx b/web-app/src/routes/settings/shortcuts.tsx
index 24ade1f71..3c918ed6d 100644
--- a/web-app/src/routes/settings/shortcuts.tsx
+++ b/web-app/src/routes/settings/shortcuts.tsx
@@ -91,6 +91,11 @@ function Shortcuts() {
description={t('settings:shortcuts.newChatDesc')}
actions={<ShortcutLabel action={ShortcutAction.NEW_CHAT} />}
/>
+ <CardItem
+ title={t('settings:shortcuts.newProject')}
+ description={t('settings:shortcuts.newProjectDesc')}
+ actions={<ShortcutLabel action={ShortcutAction.NEW_PROJECT} />}
+ />
<CardItem
title={t('settings:shortcuts.toggleSidebar')}
description={t('settings:shortcuts.toggleSidebarDesc')}