Skip to content

Commit

Permalink
fix: move Jan folder (janhq#3160)
Browse files Browse the repository at this point in the history
* chore: upgrade marked-katex-extension (janhq#3049)

* fix: handle long word without space to avoid right panel disappears (janhq#3048)

* add time weighted retrieval (janhq#2908)

* add time weighted retrieval

* add missing configuration for timeWeightedVectorStore

* resolving conflict

* add missing configuration for timeWeightedVectorStore

* resolving conflict

* fix linting issues

* fix build failed due to requirement for useTimeWeightedRetriever in AssistantTool

* update web packages complying the new structure

---------

Co-authored-by: thu <[email protected]>

* fix: model dropdown search by configured model (janhq#3047)

* bump version (janhq#3082) (janhq#3083)

Co-authored-by: Hoang Ha <[email protected]>

* Update cortex cpp nightly to version 0.4.18 (janhq#3072)

* Update cortex cpp nightly to version 0.4.17

* update linux downloadnitro

* c‌ortex 0.4.18

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Van Pham <[email protected]>

* chore: update download.ts (janhq#3088)

infomation -> information

* chore: cortex version update (janhq#3098)

* fix: handle words without space (janhq#3101)

* fix: handle long thread title without space (janhq#3107)

* fix: handle long thread title without space, and make searchbar autofocus inside model dropdown

* feat: enable right click to show setting on thread items (janhq#3108)

* chore: Bump-cortex-0.4.17 (janhq#3111)

* Update cortex cpp nightly to version 0.4.18 (janhq#3114)

* Update cortex cpp nightly to version 0.4.18

* cortex 0.4.19

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Van Pham <[email protected]>

* Chore: Add stop token for Gemma 2b (janhq#3125)

* add stop token

* Bump version

* fix: set specific version for terminate (janhq#3126)

Signed-off-by: James <[email protected]>

* feat: add claude 3.5 sonnet (janhq#3129)

Signed-off-by: James <[email protected]>

* feat: add options config spell check for chat input (janhq#3131)

* fixed grammar nits (janhq#3132)

* Update cortex cpp nightly to version 0.4.20

* fix: toggle button for expand log section on modal troubleshoot (janhq#3130)

* fix: add tooltip messages toolbar (janhq#3138)

* fix: handle error message when apikey is not setup (janhq#3149)

* fix: title thread not updated on input edit title (janhq#3148)

* merge dev

* fix move jan folder

* Update electron/preload.ts

* refactor

* Update electron/preload.ts

* fix wrong param

* use correct method

* chore: fix lint

---------

Signed-off-by: James <[email protected]>
Co-authored-by: Faisal Amir <[email protected]>
Co-authored-by: Nathan <[email protected]>
Co-authored-by: thu <[email protected]>
Co-authored-by: Van Pham <[email protected]>
Co-authored-by: Hoang Ha <[email protected]>
Co-authored-by: jan-service-account <[email protected]>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Ikko Eltociear Ashimine <[email protected]>
Co-authored-by: NamH <[email protected]>
Co-authored-by: Saurabh <[email protected]>
Co-authored-by: Louis <[email protected]>
  • Loading branch information
12 people authored Jul 15, 2024
1 parent 17ecc7c commit a36b3fe
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 46 deletions.
11 changes: 0 additions & 11 deletions core/src/browser/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,6 @@ const unlinkSync = (...args: any[]) => globalThis.core.api?.unlinkSync(...args)
*/
const appendFileSync = (...args: any[]) => globalThis.core.api?.appendFileSync(...args)

/**
* Synchronizes a file from a source path to a destination path.
* @param {string} src - The source path of the file to be synchronized.
* @param {string} dest - The destination path where the file will be synchronized to.
* @returns {Promise<any>} - A promise that resolves when the file has been successfully synchronized.
*/
const syncFile: (src: string, dest: string) => Promise<any> = (src, dest) =>
globalThis.core.api?.syncFile(src, dest)


const copyFile: (src: string, dest: string) => Promise<void> = (src, dest) =>
globalThis.core.api?.copyFile(src, dest)

Expand Down Expand Up @@ -92,7 +82,6 @@ export const fs = {
unlinkSync,
appendFileSync,
copyFile,
syncFile,
fileStat,
writeBlob,
}
14 changes: 0 additions & 14 deletions core/src/node/api/processors/fsExt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,6 @@ export class FSExt implements Processor {
return func(...args)
}

// Handles the 'syncFile' IPC event. This event is triggered to synchronize a file from a source path to a destination path.
syncFile(src: string, dest: string) {
const reflect = require('@alumna/reflect')
validatePath(dest)
return reflect({
src,
dest,
recursive: true,
delete: false,
overwrite: true,
errorOnExist: false,
})
}

// Handles the 'getJanDataFolderPath' IPC event. This event is triggered to get the user space path.
getJanDataFolderPath() {
return Promise.resolve(getPath())
Expand Down
1 change: 0 additions & 1 deletion core/src/types/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ export enum FileSystemRoute {
writeFileSync = 'writeFileSync',
}
export enum FileManagerRoute {
syncFile = 'syncFile',
copyFile = 'copyFile',
getJanDataFolderPath = 'getJanDataFolderPath',
getResourcePath = 'getResourcePath',
Expand Down
32 changes: 31 additions & 1 deletion electron/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@
* @module preload
*/

import { APIEvents, APIRoutes } from '@janhq/core/node'
import { APIEvents, APIRoutes, AppConfiguration, getAppConfigurations, updateAppConfiguration } from '@janhq/core/node'
import { contextBridge, ipcRenderer } from 'electron'
import { readdirSync } from 'fs'

const interfaces: { [key: string]: (...args: any[]) => any } = {}

// Loop over each route in APIRoutes
APIRoutes.forEach((method) => {
// For each method, create a function on the interfaces object
// This function invokes the method on the ipcRenderer with any provided arguments

interfaces[method] = (...args: any[]) => ipcRenderer.invoke(method, ...args)

})

// Loop over each method in APIEvents
Expand All @@ -22,6 +25,33 @@ APIEvents.forEach((method) => {
// The handler for the event is provided as an argument to the function
interfaces[method] = (handler: any) => ipcRenderer.on(method, handler)
})


interfaces['changeDataFolder'] = async path => {
const appConfiguration: AppConfiguration = await ipcRenderer.invoke('getAppConfigurations')
const currentJanDataFolder = appConfiguration.data_folder
appConfiguration.data_folder = path
const reflect = require('@alumna/reflect')
const { err } = await reflect({
src: currentJanDataFolder,
dest: path,
recursive: true,
delete: false,
overwrite: true,
errorOnExist: false,
})
if (err) {
console.error(err)
throw err
}
await ipcRenderer.invoke('updateAppConfiguration', appConfiguration)
}

interfaces['isDirectoryEmpty'] = async path => {
const dirChildren = await readdirSync(path)
return dirChildren.filter((x) => x !== '.DS_Store').length === 0
}

// Expose the 'interfaces' object in the main world under the name 'electronAPI'
// This allows the renderer process to access these methods directly
contextBridge.exposeInMainWorld('electronAPI', {
Expand Down
2 changes: 1 addition & 1 deletion web/containers/Layout/BottomPanel/SystemMonitor/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Fragment, useEffect, useState } from 'react'

import { Button, Progress } from '@janhq/joi'
import { Progress } from '@janhq/joi'
import { useClickOutside } from '@janhq/joi'
import { useAtom, useAtomValue } from 'jotai'
import {
Expand Down
20 changes: 5 additions & 15 deletions web/screens/Settings/Advanced/DataFolder/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Fragment, useCallback, useState } from 'react'

import { fs, AppConfiguration, isSubdirectory } from '@janhq/core'
import { AppConfiguration, isSubdirectory } from '@janhq/core'
import { Button, Input } from '@janhq/joi'
import { useAtomValue, useSetAtom } from 'jotai'
import { PencilIcon, FolderOpenIcon } from 'lucide-react'
Expand Down Expand Up @@ -51,11 +51,10 @@ const DataFolder = () => {
return
}

const newDestChildren: string[] = await fs.readdirSync(destFolder)
const isNotEmpty =
newDestChildren.filter((x) => x !== '.DS_Store').length > 0
const isEmpty: boolean =
await window.core?.api?.isDirectoryEmpty(destFolder)

if (isNotEmpty) {
if (!isEmpty) {
setDestinationPath(destFolder)
showDestNotEmptyConfirm(true)
return
Expand All @@ -74,16 +73,7 @@ const DataFolder = () => {
if (!destinationPath) return
try {
setShowLoader(true)
const appConfiguration: AppConfiguration =
await window.core?.api?.getAppConfigurations()
const currentJanDataFolder = appConfiguration.data_folder
appConfiguration.data_folder = destinationPath
const { err } = await fs.syncFile(currentJanDataFolder, destinationPath)
if (err) throw err
await window.core?.api?.updateAppConfiguration(appConfiguration)
console.debug(
`File sync finished from ${currentJanDataFolder} to ${destinationPath}`
)
await window.core?.api?.changeDataFolder(destinationPath)
localStorage.setItem(SUCCESS_SET_NEW_DESTINATION, 'true')
setTimeout(() => {
setShowLoader(false)
Expand Down
4 changes: 2 additions & 2 deletions web/screens/Settings/CoreExtensions/ExtensionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ const ExtensionItem: React.FC<Props> = ({ item }) => {
)

const progress = isInstalling
? installingExtensions.find((e) => e.extensionId === item.name)
?.percentage ?? -1
? (installingExtensions.find((e) => e.extensionId === item.name)
?.percentage ?? -1)
: -1

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ const SimpleTextMessage: React.FC<ThreadMessage> = (props) => {
>
{isUser
? props.role
: activeThread?.assistants[0].assistant_name ?? props.role}
: (activeThread?.assistants[0].assistant_name ?? props.role)}
</div>
<p className="text-xs font-medium text-gray-400">
{displayDate(props.created)}
Expand Down

0 comments on commit a36b3fe

Please sign in to comment.