Skip to content

Commit

Permalink
fix: adjust autocomplete menu's position
Browse files Browse the repository at this point in the history
  • Loading branch information
weilirs committed Nov 14, 2024
1 parent 5f60dee commit 8ea3d57
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 17 deletions.
8 changes: 7 additions & 1 deletion electron/main/filesystem/ipcHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ import WindowsManager from '../common/windowManager'
import { StoreSchema } from '../electron-store/storeConfig'
import { handleFileRename, updateFileInTable } from '../vector-database/tableHelperFunctions'

import { GetFilesInfoTree, createFileRecursive, isHidden, GetFilesInfoListForListOfPaths } from './filesystem'
import {
GetFilesInfoTree,
createFileRecursive,
isHidden,
GetFilesInfoListForListOfPaths,
searchFiles,
} from './filesystem'
import { FileInfoTree, WriteFileProps, RenameFileProps, FileInfoWithContent } from './types'

const registerFileHandlers = (store: Store<StoreSchema>, _windowsManager: WindowsManager) => {
Expand Down
14 changes: 10 additions & 4 deletions src/components/Chat/ChatInput.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useRef } from 'react'
import React, { useRef, useState } from 'react'
import { PiPaperPlaneRight } from 'react-icons/pi'
import FileAutocomplete from './FileAutocomplete'
import { AgentConfig, LoadingState } from '../../lib/llm/types'
Expand Down Expand Up @@ -131,7 +131,7 @@ const ChatInput: React.FC<ChatInputProps> = ({

return (
<div className="flex w-full">
<div className="z-50 flex w-full flex-col overflow-hidden rounded border-2 border-solid border-border bg-background focus-within:ring-1 focus-within:ring-ring">
<div className="relative z-50 flex w-full flex-col overflow-visible rounded border-2 border-solid border-border bg-background focus-within:ring-1 focus-within:ring-ring">
{/* <Select value={selectedLLM}>
<SelectTrigger className="h-7 w-32 border-0 text-[10px] text-gray-300 focus:ring-0 focus:ring-offset-0">
<SelectValue placeholder="Tools" />
Expand All @@ -149,19 +149,25 @@ const ChatInput: React.FC<ChatInputProps> = ({
</SelectContent>
</Select> */}
<textarea
ref={textareaRef}
value={userTextFieldInput}
onKeyDown={(e) => {
handleKeyDown(e)
if (!e.shiftKey && e.key === 'Enter') {
e.preventDefault()
handleSubmitNewMessage()
}
}}
className="h-[100px] w-full resize-none border-0 bg-transparent p-4 text-foreground caret-current focus:outline-none"
onChange={(e) => {
handleInput(e)
setUserTextFieldInput(e.target.value)
}}
className="min-h-[100px] w-full resize-none border-0 bg-transparent p-4 text-foreground caret-current focus:outline-none"
wrap="soft"
placeholder="What can Reor help you with today?"
onChange={(e) => setUserTextFieldInput(e.target.value)}
// eslint-disable-next-line jsx-a11y/no-autofocus
autoFocus
// rows={1}
/>
<div className="mx-auto h-px w-[96%] bg-background/20" />
<div className="flex h-10 flex-col items-center justify-between gap-2 py-2 md:flex-row md:gap-4">
Expand Down
1 change: 1 addition & 0 deletions src/components/Chat/ChatSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const ChatItem: React.FC<ChatItemProps> = ({ chatMetadata }) => {
`

const handleDeleteChat = () => {
// eslint-disable-next-line no-alert
const isConfirmed = window.confirm(`Are you sure you want to delete the chat "${chatMetadata.displayName}"?`)
if (isConfirmed) {
deleteChat(chatMetadata.id)
Expand Down
6 changes: 5 additions & 1 deletion src/components/Chat/FileAutocomplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ const FileAutocomplete: React.FC<FileAutocompleteProps> = ({ searchTerm, positio
return (
<div
className="absolute z-50 max-h-48 w-64 overflow-y-auto rounded-md border border-neutral-700 bg-background shadow-lg"
style={{ top: position.top, left: position.left }}
style={{
top: 'auto',
bottom: `calc(100% + 10px)`,
left: position.left,
}}
>
{files.map((file) => (
<div key={file} className="cursor-pointer px-4 py-2 hover:bg-neutral-700" onClick={() => onSelect(file)}>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Chat/MessageComponents/ChatSources.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const ChatSources: React.FC<ChatSourcesProps> = ({ contextItems }) => {
<div>
<div className="mb-1 text-sm text-muted-foreground">Sources:</div>

<div className="scrollbar-thumb-rounded-full flex space-x-2 overflow-x-auto p-0 pb-1 scrollbar-thin scrollbar-track-transparent scrollbar-thumb-gray-800">
<div className="flex space-x-2 overflow-x-auto p-0 pb-1 scrollbar-thin scrollbar-track-transparent scrollbar-thumb-gray-800">
{contextItems.map((contextItem) => (
<HoverCard key={getItemPath(contextItem)} openDelay={600}>
<HoverCardTrigger>
Expand Down
21 changes: 11 additions & 10 deletions src/components/Chat/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,21 @@ const ChatComponent: React.FC = () => {

// Extract file references from the message
const fileRefs = extractFileReferences(userTextFieldInput || '')
// console.log('fileRefs', fileRefs)
console.log('fileRefs', fileRefs)

Check warning on line 51 in src/components/Chat/index.tsx

View workflow job for this annotation

GitHub Actions / build_and_package (macos-13)

Unexpected console statement

Check warning on line 51 in src/components/Chat/index.tsx

View workflow job for this annotation

GitHub Actions / build_and_package (macos-latest)

Unexpected console statement

Check warning on line 51 in src/components/Chat/index.tsx

View workflow job for this annotation

GitHub Actions / build_and_package (windows-latest)

Unexpected console statement

Check warning on line 51 in src/components/Chat/index.tsx

View workflow job for this annotation

GitHub Actions / build_and_package (ubuntu-latest, x64)

Unexpected console statement

// Create or update chat with file context
// outputChat = userTextFieldInput?.trim()
// ? await updateOrCreateChat(chat, userTextFieldInput, {
// name: agentConfig?.name || 'default',
// ...agentConfig,
// toolDefinitions: agentConfig?.toolDefinitions || [],
// promptTemplate: agentConfig?.promptTemplate || [],
// files: fileRefs,
// })
outputChat = userTextFieldInput?.trim()
? await appendToOrCreateChat(chat, userTextFieldInput, agentConfig)
? await appendToOrCreateChat(chat, userTextFieldInput, {
name: agentConfig?.name || 'default',
...agentConfig,
toolDefinitions: agentConfig?.toolDefinitions || [],
promptTemplate: agentConfig?.promptTemplate || [],
files: fileRefs,
})
: chat
// outputChat = userTextFieldInput?.trim()
// ? await appendToOrCreateChat(chat, userTextFieldInput, agentConfig)
// : chat

if (!outputChat) {
return
Expand Down
1 change: 1 addition & 0 deletions src/components/Settings/LLMSettings/DefaultLLMSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const DefaultLLMSelector: React.FC<DefaultLLMSelectorProps> = ({ llmConfigs, def
}

const handleDeleteLLM = async (modelName: string) => {
// eslint-disable-next-line no-alert
const confirmDelete = window.confirm(`Are you sure you want to delete the model ${modelName}?`)
if (!confirmDelete) return

Expand Down

0 comments on commit 8ea3d57

Please sign in to comment.