Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert to BlockNote, Image support, Video Support, tamagui theme, white and black theme #503

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Changing init page
  • Loading branch information
milaiwi committed Jan 31, 2025
commit ee0be94796cea1847167f206cf72ed911ae4f78e
9 changes: 3 additions & 6 deletions src/components/Chat/MessageComponents/ChatSources.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import React from 'react'
import { FileInfoWithContent } from 'electron/main/filesystem/types'
import { DBEntry } from 'electron/main/vector-database/schema'
import posthog from 'posthog-js'
import { Card, CardDescription } from '@/components/ui/card'
import { CardDescription } from '@/components/ui/card'
import { HoverCard, HoverCardTrigger, HoverCardContent } from '@/components/ui/hover-card'
import { useContentContext } from '@/contexts/ContentContext'
import MarkdownRenderer from '@/components/Common/MarkdownRenderer'

import { Card, ScrollView, CardFooter, YStack, CardHeader } from 'tamagui'

interface ChatSourcesProps {
contextItems: FileInfoWithContent[] | DBEntry[]
Expand Down Expand Up @@ -58,12 +58,9 @@ const ChatSources: React.FC<ChatSourcesProps> = ({ contextItems }) => {
<HoverCardTrigger>
<Card
className="flex h-10 w-28 shrink-0 cursor-pointer items-center justify-center bg-secondary"
hoverStyle={{
shadowRadius: "$4",
}}
onClick={() => handleOpenContent(getItemPath(contextItem))}
>
<CardDescription className="overflow-hidden break-all px-1 text-center text-xs">
<CardDescription className="overflow-hidden break-all text-center text-xs">
{truncateName(getItemName(contextItem), 20)}
</CardDescription>
</Card>
Expand Down
15 changes: 8 additions & 7 deletions src/components/Common/IndexingProgress.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useEffect, useState } from 'react'
import { YStack, H2, SizableText } from 'tamagui'

import CircularProgress from '@mui/material/CircularProgress'

Expand Down Expand Up @@ -30,10 +31,10 @@ const IndexingProgress: React.FC<IndexingProgressProps> = ({ indexingProgress })

return (
<ReorModal isOpen onClose={() => {}} hideCloseButton>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: onClose prop is empty function - consider handling modal close during indexing

<div className="mx-3 mb-3 mt-2 h-[100px] w-[500px]">
<h6 className="my-2 text-2xl font-semibold text-white">
<YStack className="mx-3 mb-3 mt-2 h-[100px] w-[500px]">
<H2 marginY={2} fontWeight="semi-bold" fontSize="xl" color="$gray13">
{indexingProgress === 0 ? 'Initializing vector database...' : 'Indexing files...'}
</h6>
</H2>
<div
className={`mb-2 h-4 w-full overflow-hidden rounded-full border-2 border-gray-400 ${
indexingProgress !== 0 ? 'bg-neutral-800' : ''
Expand All @@ -46,14 +47,14 @@ const IndexingProgress: React.FC<IndexingProgressProps> = ({ indexingProgress })
</div>
<div className="flex">
{indexingProgress === 0 && (
<CircularProgress size={20} thickness={7} style={{ color: 'white' }} className="mr-2" />
<CircularProgress size={20} thickness={7} className="mr-2" />
)}

<span className="text-sm font-semibold text-white">
<SizableText fontSize={14} color="$gray13">
{indexingProgress > 0 && <>{Math.round(indexingProgress * 100)}% -</>} {eta}
</span>
</SizableText>
</div>
</div>
</YStack>
</ReorModal>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { EmbeddingModelConfig } from 'electron/main/electron-store/storeConfig'

import NewRemoteEmbeddingModelModal from './modals/NewRemoteEmbeddingModel'
import EmbeddingModelSelect from './EmbeddingModelSelect'
import { XStack, YStack, SizableText } from 'tamagui'

interface InitialEmbeddingModelSettingsProps {
setErrorMsg: (msg: string) => void
Expand Down Expand Up @@ -47,16 +48,16 @@ const InitialEmbeddingModelSettings: React.FC<InitialEmbeddingModelSettingsProps
}

return (
<div className="flex w-full items-center justify-between rounded bg-dark-gray-c-three">
<div className="flex flex-col">
<p className="mb-0 text-gray-100">Embedding Model</p>{' '}
<p className="text-xs text-gray-400">
<XStack className="flex w-full items-center justify-between rounded">
<YStack className="flex flex-col">
<SizableText color="$gray13" fontWeight={600} fontSize={16}>Embedding Model</SizableText>
<SizableText color="$black" fontSize={12} fontWeight={300} marginTop="$2">
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Using $black color for text may not work well with dark theme - consider using a theme-aware color token instead

Choose a recommended model or a{' '}
<a className="underline" onClick={() => setShowNewEmbeddingModelModal(true)}>
custom embedding model
</a>
Comment on lines 59 to 61
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider using Tamagui's Link component instead of HTML anchor for consistency with the UI framework

</p>
</div>
</SizableText>
</YStack>
<div className="w-[150px]">
<EmbeddingModelSelect
selectedModel={selectedModel}
Expand All @@ -74,7 +75,7 @@ const InitialEmbeddingModelSettings: React.FC<InitialEmbeddingModelSettingsProps
updateEmbeddingModels()
}}
/>
</div>
</XStack>
)
}

Expand Down
30 changes: 15 additions & 15 deletions src/components/Settings/InitialSettingsSinglePage.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState } from 'react'

import { Button } from '@material-tailwind/react'

import { YStack, H3, SizableText, XStack } from 'tamagui'
import ReorModal from '../Common/Modal'

import DirectorySelector from './DirectorySelector'
Expand All @@ -27,31 +27,31 @@ const InitialSetupSinglePage: React.FC<OldInitialSettingsProps> = ({ readyForInd

return (
<ReorModal isOpen onClose={() => {}} hideCloseButton>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: onClose prop is set to an empty function - consider handling modal closure properly

<div className="ml-2 mr-4 w-[620px] py-3">
<div className="ml-2 mt-0 h-[450px] ">
<h2 className="mb-0 text-center text-2xl font-semibold text-white">Welcome to the Reor Project</h2>
<p className="mt-2 text-center text-gray-100">
<YStack className="ml-2 mr-4 w-[620px] py-3">
<YStack className="ml-2 mt-0 h-[450px] ">
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syntax: Extra space in className string after h-[450px]

<H3 color="$gray13" fontWeight="semi-bold" className="mb-0 text-center text-2xl">Welcome to the Reor Project</H3>
<SizableText color="$gray11" fontWeight={400} marginTop="$4" textAlign="center">
Reor is a private AI personal knowledge management tool. Each note will be saved as a markdown file to a
vault directory on your machine.
</p>
<div className="mt-10 flex items-center justify-between border-0 border-b-2 border-solid border-neutral-700 pb-4">
<div className="w-80 flex-col">
<p className="m-0 text-gray-100">Vault Directory</p>
<p className="m-0 pt-1 text-xs text-gray-100 opacity-40">
</SizableText>
<XStack className="mt-10 flex items-center justify-between border-0 border-b-2 border-solid border-neutral-700 pb-4">
<YStack className="w-80 flex-col">
<SizableText color="$gray13" fontWeight={600} fontSize={16}>Vault Directory</SizableText>
<SizableText color="$black" fontSize={14} fontWeight={300} className="m-0 pt-1">
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Using $black color token here may cause visibility issues in dark mode since it's a fixed color rather than a theme token

Your vault directory doesn&apos;t need to be empty. Only markdown files will be indexed.
</p>
</div>
</SizableText>
</YStack>
<div className="flex-col">
<DirectorySelector setErrorMsg={setDirectoryErrorMsg} />
{showError && directoryErrorMsg && <p className="text-xs text-red-500">{directoryErrorMsg}</p>}
</div>
</div>
</XStack>
<div className="mt-2 border-0 border-b-2 border-solid border-neutral-700 pb-2">
<InitialEmbeddingModelSettings setErrorMsg={setEmbeddingErrorMsg} />
{showError && embeddingErrorMsg && <p className="text-xs text-red-500">{embeddingErrorMsg}</p>}
</div>
<InitialSetupLLMSettings />
</div>
</YStack>
<div className="flex justify-end">
<Button
className="mb-3 mt-4 h-10 w-[80px] cursor-pointer border-none bg-blue-500 px-2 py-0 text-center hover:bg-blue-600"
Expand All @@ -61,7 +61,7 @@ const InitialSetupSinglePage: React.FC<OldInitialSettingsProps> = ({ readyForInd
Next
</Button>
</div>
</div>
</YStack>
</ReorModal>
)
}
Expand Down
45 changes: 24 additions & 21 deletions src/components/TitleBar/NavigationButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { removeFileExtension } from '@/lib/file'
import '../../styles/history.scss'
import { useFileContext } from '@/contexts/FileContext'
import { useContentContext } from '@/contexts/ContentContext'
import { YStack, XStack, View, Text } from 'tamagui'

const NavigationButtons: React.FC = () => {
const [showMenu, setShowMenu] = useState<string>('')
Expand Down Expand Up @@ -91,27 +92,29 @@ const NavigationButtons: React.FC = () => {
return (
showMenu !== '' &&
menuChild.length > 0 && (
<div
ref={ref}
// eslint-disable-next-line tailwindcss/no-custom-classname
className="history-menu"
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
tabIndex={0}
style={{
left: `${offsetLeft}px`,
top: `${offsetTop + offsetHeight}px`,
}}
>
<ul>
{menuChild.map((pathOrChatID) => (
<li key={pathOrChatID}>
<div key={pathOrChatID} onClick={() => goSelected(pathOrChatID)}>
{removeFileExtension(pathOrChatID.replace(/\\/g, '/').split('/').pop() || '')}
</div>
</li>
))}
</ul>
</div>
<View
ref={ref}
tabIndex={0}
position="absolute"
left={offsetLeft}
top={offsetTop + offsetHeight}
>
<YStack>
{menuChild.map((pathOrChatID) => (
<XStack
key={pathOrChatID}
padding="$3"
cursor="pointer"
hoverStyle={{ backgroundColor: '$backgroundHover' }}
onPress={() => goSelected(pathOrChatID)}
>
<Text>
{removeFileExtension(pathOrChatID.replace(/\\/g, '/').split('/').pop() || '')}
</Text>
</XStack>
))}
</YStack>
</View>
)
)
}
Expand Down
21 changes: 13 additions & 8 deletions src/components/TitleBar/TitleBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { BsChatLeftDots, BsChatLeftDotsFill } from 'react-icons/bs'
import NavigationButtons from './NavigationButtons'
import ExternalLink from '../Common/ExternalLink'
import { useChatContext } from '@/contexts/ChatContext'
import { XStack } from 'tamagui'
import { XStack, SizableText } from 'tamagui'
import { MessageSquareMore, MessageSquareOff } from '@tamagui/lucide-icons'

export const titleBarHeight = '30px'

Expand Down Expand Up @@ -32,19 +33,23 @@ const TitleBar: React.FC = () => {
className="electron-no-drag mt-[0.5px] flex items-center justify-end"
style={platform === 'win32' ? { marginRight: '8.5rem' } : { marginRight: '0.3rem' }}
>
<ExternalLink href="https://forms.gle/8H4GtEcE6MBnNAUa7" className="decoration-gray-200">
<span className="mr-2 cursor-pointer text-sm text-gray-200 hover:text-gray-300">Feedback</span>
<ExternalLink href="https://forms.gle/8H4GtEcE6MBnNAUa7" className="cursor-pointer">
<SizableText
color="$gray13"
fontSize={14}
className="mr-2"
>Feedback</SizableText>
</ExternalLink>
{showChatbot ? (
<BsChatLeftDotsFill
className="electron-no-drag mr-1 mt-[0.2rem] -scale-x-100 cursor-pointer p-[2px] text-gray-100"
size={22}
<MessageSquareOff
className="electron-no-drag mr-1 mt-[0.2rem] ml-1 -scale-x-100 cursor-pointer p-[2px] text-gray-100"
size={19}
Comment on lines +41 to +42
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: size={19} for MessageSquareOff but size={22} for MessageSquareMore creates inconsistent icon sizes

title="Hide Similar Files"
onClick={() => setShowChatbot((show) => !show)}
/>
) : (
<BsChatLeftDots
className="electron-no-drag mr-1 mt-[0.2rem] -scale-x-100 cursor-pointer p-[2px] text-gray-100"
<MessageSquareMore
className="electron-no-drag mr-1 mt-[0.2rem ml-1 -scale-x-100 cursor-pointer p-[2px] text-gray-100"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syntax: typo in className - missing closing quote after [0.2rem

Suggested change
className="electron-no-drag mr-1 mt-[0.2rem ml-1 -scale-x-100 cursor-pointer p-[2px] text-gray-100"
className="electron-no-drag mr-1 mt-[0.2rem] ml-1 -scale-x-100 cursor-pointer p-[2px] text-gray-100"

size={22}
title="Show Chatbot"
onClick={() => setShowChatbot((show) => !show)}
Expand Down