diff --git a/uikit/src/command/index.tsx b/uikit/src/command/index.tsx index 0d87d72c92..57d8e1441a 100644 --- a/uikit/src/command/index.tsx +++ b/uikit/src/command/index.tsx @@ -27,7 +27,13 @@ const CommandModal = ({ children, ...props }: CommandModalProps) => { return ( - + { + if (value.includes(search)) return 1 + return 0 + }} + className="[&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5" + > {children} diff --git a/web/containers/Layout/BottomBar/index.tsx b/web/containers/Layout/BottomBar/index.tsx index 1ff0b64143..1a264da020 100644 --- a/web/containers/Layout/BottomBar/index.tsx +++ b/web/containers/Layout/BottomBar/index.tsx @@ -8,6 +8,8 @@ import ProgressBar from '@/containers/ProgressBar' import { appDownloadProgress } from '@/containers/Providers/Jotai' +import ShortCut from '@/containers/Shortcut' + import { MainViewState } from '@/constants/screens' import { useActiveModel } from '@/hooks/useActiveModel' @@ -47,7 +49,10 @@ const BottomBar = () => { name="Active model:" value={ activeModel?.id || ( - ⌘e to show your model + + +   to show your model + ) } /> diff --git a/web/containers/Layout/TopBar/CommandListDownloadedModel/index.tsx b/web/containers/Layout/TopBar/CommandListDownloadedModel/index.tsx index fee918f3a2..0fb278080c 100644 --- a/web/containers/Layout/TopBar/CommandListDownloadedModel/index.tsx +++ b/web/containers/Layout/TopBar/CommandListDownloadedModel/index.tsx @@ -61,6 +61,7 @@ export default function CommandListDownloadedModel() { return ( { onModelActionClick(model.id) setOpen(false) @@ -71,7 +72,7 @@ export default function CommandListDownloadedModel() { className="mr-3 text-muted-foreground" />
- {model.name} + {model.id} {activeModel && activeModel.id === model.id && ( Active )} diff --git a/web/containers/Layout/TopBar/CommandSearch/index.tsx b/web/containers/Layout/TopBar/CommandSearch/index.tsx index 568c0dae49..cd7b815d60 100644 --- a/web/containers/Layout/TopBar/CommandSearch/index.tsx +++ b/web/containers/Layout/TopBar/CommandSearch/index.tsx @@ -19,6 +19,8 @@ import { BookOpenIcon, } from 'lucide-react' +import ShortCut from '@/containers/Shortcut' + import { FeatureToggleContext } from '@/context/FeatureToggle' import { MainViewState } from '@/constants/screens' @@ -27,10 +29,8 @@ import { useMainViewState } from '@/hooks/useMainViewState' export default function CommandSearch() { const { experimentalFeatureEnabed } = useContext(FeatureToggleContext) - const { setMainViewState } = useMainViewState() - const [open, setOpen] = useState(false) const menus = [ { name: 'Getting Started', @@ -60,13 +60,15 @@ export default function CommandSearch() { name: 'Settings', icon: , state: MainViewState.Setting, - shortcut: '⌘,', + shortcut: , }, ] + const [open, setOpen] = useState(false) + useEffect(() => { const down = (e: KeyboardEvent) => { - if (e.key === 'j' && (e.metaKey || e.ctrlKey)) { + if (e.key === 'k' && (e.metaKey || e.ctrlKey)) { e.preventDefault() setOpen((open) => !open) } @@ -90,10 +92,11 @@ export default function CommandSearch() { > Search menus... -
- ⌘ j +
+
+ @@ -103,6 +106,7 @@ export default function CommandSearch() { return ( { setMainViewState(menu.state) setOpen(false) diff --git a/web/containers/Shortcut/index.tsx b/web/containers/Shortcut/index.tsx new file mode 100644 index 0000000000..67a5f8d0c1 --- /dev/null +++ b/web/containers/Shortcut/index.tsx @@ -0,0 +1,21 @@ +import { useOs, type OS } from '@/hooks/useOs' + +export default function ShortCut(props: { menu: string }) { + const os = useOs() + const { menu } = props + const getSymbol = (os: OS) => { + switch (os) { + case 'macos': + return '⌘' + + default: + return 'Ctrl' + } + } + + return ( +
+

{getSymbol(os) + ' + ' + menu}

+
+ ) +} diff --git a/web/hooks/useOs.ts b/web/hooks/useOs.ts new file mode 100644 index 0000000000..c4472d54f8 --- /dev/null +++ b/web/hooks/useOs.ts @@ -0,0 +1,57 @@ +import { useEffect, useState } from 'react' + +export type OS = + | 'undetermined' + | 'macos' + | 'ios' + | 'windows' + | 'android' + | 'linux' + +function getOS(): OS { + if (typeof window === 'undefined') { + return 'undetermined' + } + + const { userAgent } = window.navigator + const macosPlatforms = /(Macintosh)|(MacIntel)|(MacPPC)|(Mac68K)/i + const windowsPlatforms = /(Win32)|(Win64)|(Windows)|(WinCE)/i + const iosPlatforms = /(iPhone)|(iPad)|(iPod)/i + + if (iosPlatforms.test(userAgent)) { + return 'ios' + } + if (/Android/i.test(userAgent)) { + return 'android' + } + + if (macosPlatforms.test(userAgent)) { + return 'macos' + } + if (windowsPlatforms.test(userAgent)) { + return 'windows' + } + if (/Linux/i.test(userAgent)) { + return 'linux' + } + + return 'undetermined' +} + +interface UseOsOptions { + getValueInEffect: boolean +} + +export function useOs(options: UseOsOptions = { getValueInEffect: true }): OS { + const [value, setValue] = useState( + options.getValueInEffect ? 'undetermined' : getOS() + ) + + useEffect(() => { + if (options.getValueInEffect) { + setValue(getOS) + } + }, []) + + return value +} diff --git a/web/screens/Chat/index.tsx b/web/screens/Chat/index.tsx index 4123c20d4f..9efee34e12 100644 --- a/web/screens/Chat/index.tsx +++ b/web/screens/Chat/index.tsx @@ -10,6 +10,8 @@ import { twMerge } from 'tailwind-merge' import { currentPromptAtom } from '@/containers/Providers/Jotai' +import ShortCut from '@/containers/Shortcut' + import { MainViewState } from '@/constants/screens' import { useActiveModel } from '@/hooks/useActiveModel' @@ -181,8 +183,9 @@ const ChatScreen = () => {

{`You don’t have any actively running models`}

{`Please start a downloaded model in My Models page to use this feature.`}

- - ⌘e to show your model + + +   to show your model
)} diff --git a/web/screens/Welcome/index.tsx b/web/screens/Welcome/index.tsx index 72030cb919..30ca9a0f65 100644 --- a/web/screens/Welcome/index.tsx +++ b/web/screens/Welcome/index.tsx @@ -4,6 +4,8 @@ import { Badge, Button } from '@janhq/uikit' import LogoMark from '@/containers/Brand/Logo/Mark' +import ShortCut from '@/containers/Shortcut' + import { MainViewState } from '@/constants/screens' import { useActiveModel } from '@/hooks/useActiveModel' @@ -46,8 +48,9 @@ const WelcomeScreen = () => {

{`You don’t have any actively running models`}

{`Please start a downloaded model in My Models page to use this feature.`}

- - ⌘e to show your model + + +   to show your model
)}