mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-09 05:39:12 +00:00
Improve command bar slash experience
This commit is contained in:
@@ -71,7 +71,6 @@ function ChatInputArea(props: ChatInputProps) {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (message.startsWith('/')) {
|
if (message.startsWith('/')) {
|
||||||
const command = message.split(' ')[0].substring(1);
|
const command = message.split(' ')[0].substring(1);
|
||||||
console.log('Command is:', command);
|
|
||||||
}
|
}
|
||||||
}, [message]);
|
}, [message]);
|
||||||
|
|
||||||
@@ -120,41 +119,41 @@ function ChatInputArea(props: ChatInputProps) {
|
|||||||
|
|
||||||
function getIconForSlashCommand(command: string) {
|
function getIconForSlashCommand(command: string) {
|
||||||
if (command.includes('summarize')) {
|
if (command.includes('summarize')) {
|
||||||
return <Gps className='h-4 w-4 mx-2' />
|
return <Gps className='h-4 w-4 mr-2' />
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command.includes('help')) {
|
if (command.includes('help')) {
|
||||||
return <Question className='h-4 w-4 mx-2' />
|
return <Question className='h-4 w-4 mr-2' />
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command.includes('automation')) {
|
if (command.includes('automation')) {
|
||||||
return <Robot className='h-4 w-4 mx-2' />
|
return <Robot className='h-4 w-4 mr-2' />
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command.includes('webpage')) {
|
if (command.includes('webpage')) {
|
||||||
return <Browser className='h-4 w-4 mx-2' />
|
return <Browser className='h-4 w-4 mr-2' />
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command.includes('notes')) {
|
if (command.includes('notes')) {
|
||||||
return <Notebook className='h-4 w-4 mx-2' />
|
return <Notebook className='h-4 w-4 mr-2' />
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command.includes('image')) {
|
if (command.includes('image')) {
|
||||||
return <Image className='h-4 w-4 mx-2' />
|
return <Image className='h-4 w-4 mr-2' />
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command.includes('default')) {
|
if (command.includes('default')) {
|
||||||
return <Shapes className='h-4 w-4 mx-2' />
|
return <Shapes className='h-4 w-4 mr-2' />
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command.includes('general')) {
|
if (command.includes('general')) {
|
||||||
return <ChatsTeardrop className='h-4 w-4 mx-2' />
|
return <ChatsTeardrop className='h-4 w-4 mr-2' />
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command.includes('online')) {
|
if (command.includes('online')) {
|
||||||
return <GlobeSimple className='h-4 w-4 mx-2' />
|
return <GlobeSimple className='h-4 w-4 mr-2' />
|
||||||
}
|
}
|
||||||
return <ArrowRight className='h-4 w-4 mx-2' />
|
return <ArrowRight className='h-4 w-4 mr-2' />
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -216,7 +215,7 @@ function ChatInputArea(props: ChatInputProps) {
|
|||||||
</PopoverTrigger>
|
</PopoverTrigger>
|
||||||
<PopoverContent
|
<PopoverContent
|
||||||
onOpenAutoFocus={(e) => e.preventDefault()}
|
onOpenAutoFocus={(e) => e.preventDefault()}
|
||||||
className={`${props.isMobileWidth} ? 'w-[100vw] : w-full`}>
|
className={`${props.isMobileWidth ? 'w-[100vw]' : 'w-full'} rounded-md`}>
|
||||||
<Command className='max-w-full'>
|
<Command className='max-w-full'>
|
||||||
<CommandInput placeholder="Type a command or search..." value={message} className='hidden' />
|
<CommandInput placeholder="Type a command or search..." value={message} className='hidden' />
|
||||||
<CommandList>
|
<CommandList>
|
||||||
@@ -225,11 +224,19 @@ function ChatInputArea(props: ChatInputProps) {
|
|||||||
{props.chatOptionsData && Object.entries(props.chatOptionsData).map(([key, value]) => (
|
{props.chatOptionsData && Object.entries(props.chatOptionsData).map(([key, value]) => (
|
||||||
<CommandItem
|
<CommandItem
|
||||||
key={key}
|
key={key}
|
||||||
|
className={`text-md`}
|
||||||
onSelect={() => handleSlashCommandClick(key)}>
|
onSelect={() => handleSlashCommandClick(key)}>
|
||||||
{getIconForSlashCommand(key)}
|
<div
|
||||||
<span>
|
className='grid grid-cols-1 gap-1'>
|
||||||
/{key}: {value}
|
<div
|
||||||
</span>
|
className='font-bold flex items-center'>
|
||||||
|
{getIconForSlashCommand(key)}
|
||||||
|
/{key}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
{value}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</CommandItem>
|
</CommandItem>
|
||||||
))}
|
))}
|
||||||
</CommandGroup>
|
</CommandGroup>
|
||||||
@@ -382,6 +389,7 @@ export default function Chat() {
|
|||||||
const [queryToProcess, setQueryToProcess] = useState<string>('');
|
const [queryToProcess, setQueryToProcess] = useState<string>('');
|
||||||
const [processQuerySignal, setProcessQuerySignal] = useState(false);
|
const [processQuerySignal, setProcessQuerySignal] = useState(false);
|
||||||
const [uploadedFiles, setUploadedFiles] = useState<string[]>([]);
|
const [uploadedFiles, setUploadedFiles] = useState<string[]>([]);
|
||||||
|
const [isMobileWidth, setIsMobileWidth] = useState(false);
|
||||||
|
|
||||||
|
|
||||||
const handleWebSocketMessage = (event: MessageEvent) => {
|
const handleWebSocketMessage = (event: MessageEvent) => {
|
||||||
@@ -465,6 +473,12 @@ export default function Chat() {
|
|||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setIsMobileWidth(window.innerWidth < 786);
|
||||||
|
|
||||||
|
window.addEventListener('resize', () => {
|
||||||
|
setIsMobileWidth(window.innerWidth < 786);
|
||||||
|
});
|
||||||
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -537,6 +551,7 @@ export default function Chat() {
|
|||||||
setTitle={setTitle}
|
setTitle={setTitle}
|
||||||
setQueryToProcess={setQueryToProcess}
|
setQueryToProcess={setQueryToProcess}
|
||||||
setUploadedFiles={setUploadedFiles}
|
setUploadedFiles={setUploadedFiles}
|
||||||
|
isMobileWidth={isMobileWidth}
|
||||||
onConversationIdChange={handleConversationIdChange} />
|
onConversationIdChange={handleConversationIdChange} />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user