fix: move Jan folder (#3160)
* chore: upgrade marked-katex-extension (#3049) * fix: handle long word without space to avoid right panel disappears (#3048) * add time weighted retrieval (#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 <thu@treehouse.finance> * fix: model dropdown search by configured model (#3047) * bump version (#3082) (#3083) Co-authored-by: Hoang Ha <64120343+hahuyhoang411@users.noreply.github.com> * Update cortex cpp nightly to version 0.4.18 (#3072) * Update cortex cpp nightly to version 0.4.17 * update linux downloadnitro * cortex 0.4.18 --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Van Pham <64197333+Van-QA@users.noreply.github.com> * chore: update download.ts (#3088) infomation -> information * chore: cortex version update (#3098) * fix: handle words without space (#3101) * fix: handle long thread title without space (#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 (#3108) * chore: Bump-cortex-0.4.17 (#3111) * Update cortex cpp nightly to version 0.4.18 (#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 <64197333+Van-QA@users.noreply.github.com> * Chore: Add stop token for Gemma 2b (#3125) * add stop token * Bump version * fix: set specific version for terminate (#3126) Signed-off-by: James <namnh0122@gmail.com> * feat: add claude 3.5 sonnet (#3129) Signed-off-by: James <namnh0122@gmail.com> * feat: add options config spell check for chat input (#3131) * fixed grammar nits (#3132) * Update cortex cpp nightly to version 0.4.20 * fix: toggle button for expand log section on modal troubleshoot (#3130) * fix: add tooltip messages toolbar (#3138) * fix: handle error message when apikey is not setup (#3149) * fix: title thread not updated on input edit title (#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 <namnh0122@gmail.com> Co-authored-by: Faisal Amir <urmauur@gmail.com> Co-authored-by: Nathan <thu.nhuanh99@gmail.com> Co-authored-by: thu <thu@treehouse.finance> Co-authored-by: Van Pham <64197333+Van-QA@users.noreply.github.com> Co-authored-by: Hoang Ha <64120343+hahuyhoang411@users.noreply.github.com> Co-authored-by: jan-service-account <136811300+jan-service-account@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Ikko Eltociear Ashimine <eltociear@gmail.com> Co-authored-by: NamH <NamNh0122@gmail.com> Co-authored-by: Saurabh <saurabhrai1717@gmail.com> Co-authored-by: Louis <louis@jan.ai>
This commit is contained in:
parent
17ecc7c9c8
commit
a36b3fee24
@ -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)
|
||||
|
||||
@ -92,7 +82,6 @@ export const fs = {
|
||||
unlinkSync,
|
||||
appendFileSync,
|
||||
copyFile,
|
||||
syncFile,
|
||||
fileStat,
|
||||
writeBlob,
|
||||
}
|
||||
|
||||
@ -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())
|
||||
|
||||
@ -99,7 +99,6 @@ export enum FileSystemRoute {
|
||||
writeFileSync = 'writeFileSync',
|
||||
}
|
||||
export enum FileManagerRoute {
|
||||
syncFile = 'syncFile',
|
||||
copyFile = 'copyFile',
|
||||
getJanDataFolderPath = 'getJanDataFolderPath',
|
||||
getResourcePath = 'getResourcePath',
|
||||
|
||||
@ -3,8 +3,9 @@
|
||||
* @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 } = {}
|
||||
|
||||
@ -12,7 +13,9 @@ const interfaces: { [key: string]: (...args: any[]) => any } = {}
|
||||
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
|
||||
@ -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', {
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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'
|
||||
@ -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
|
||||
@ -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)
|
||||
|
||||
@ -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(() => {
|
||||
|
||||
@ -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)}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user