fix: user can't view model setting in local api server (#1807)
* fix: cannot change jan data folder Signed-off-by: James <james@jan.ai> * fix: user can't view model setting in local api server Signed-off-by: James <james@jan.ai> --------- Signed-off-by: James <james@jan.ai> Co-authored-by: James <james@jan.ai>
This commit is contained in:
parent
23dfb1c12f
commit
642d7aacc9
@ -11,20 +11,23 @@ export const usePath = () => {
|
|||||||
const selectedModel = useAtomValue(selectedModelAtom)
|
const selectedModel = useAtomValue(selectedModelAtom)
|
||||||
|
|
||||||
const onReviewInFinder = async (type: string) => {
|
const onReviewInFinder = async (type: string) => {
|
||||||
if (!activeThread) return
|
// TODO: this logic should be refactored.
|
||||||
const activeThreadState = threadStates[activeThread.id]
|
if (type !== 'Model') {
|
||||||
if (!activeThreadState.isFinishInit) {
|
if (!activeThread) return
|
||||||
alert('Thread is not started yet')
|
const activeThreadState = threadStates[activeThread.id]
|
||||||
return
|
if (!activeThreadState.isFinishInit) {
|
||||||
|
alert('Thread is not started yet')
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const userSpace = await getJanDataFolderPath()
|
const userSpace = await getJanDataFolderPath()
|
||||||
let filePath = undefined
|
let filePath = undefined
|
||||||
const assistantId = activeThread.assistants[0]?.assistant_id
|
const assistantId = activeThread?.assistants[0]?.assistant_id
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'Engine':
|
case 'Engine':
|
||||||
case 'Thread':
|
case 'Thread':
|
||||||
filePath = await joinPath(['threads', activeThread.id])
|
filePath = await joinPath(['threads', activeThread?.id ?? ''])
|
||||||
break
|
break
|
||||||
case 'Model':
|
case 'Model':
|
||||||
if (!selectedModel) return
|
if (!selectedModel) return
|
||||||
@ -44,20 +47,27 @@ export const usePath = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const onViewJson = async (type: string) => {
|
const onViewJson = async (type: string) => {
|
||||||
if (!activeThread) return
|
// TODO: this logic should be refactored.
|
||||||
const activeThreadState = threadStates[activeThread.id]
|
if (type !== 'Model') {
|
||||||
if (!activeThreadState.isFinishInit) {
|
if (!activeThread) return
|
||||||
alert('Thread is not started yet')
|
const activeThreadState = threadStates[activeThread.id]
|
||||||
return
|
if (!activeThreadState.isFinishInit) {
|
||||||
|
alert('Thread is not started yet')
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const userSpace = await getJanDataFolderPath()
|
const userSpace = await getJanDataFolderPath()
|
||||||
let filePath = undefined
|
let filePath = undefined
|
||||||
const assistantId = activeThread.assistants[0]?.assistant_id
|
const assistantId = activeThread?.assistants[0]?.assistant_id
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'Engine':
|
case 'Engine':
|
||||||
case 'Thread':
|
case 'Thread':
|
||||||
filePath = await joinPath(['threads', activeThread.id, 'thread.json'])
|
filePath = await joinPath([
|
||||||
|
'threads',
|
||||||
|
activeThread?.id ?? '',
|
||||||
|
'thread.json',
|
||||||
|
])
|
||||||
break
|
break
|
||||||
case 'Model':
|
case 'Model':
|
||||||
if (!selectedModel) return
|
if (!selectedModel) return
|
||||||
|
|||||||
@ -44,18 +44,17 @@ const DataFolder = () => {
|
|||||||
}, [janDataFolderPath, setShowSameDirectory, setShowDirectoryConfirm])
|
}, [janDataFolderPath, setShowSameDirectory, setShowDirectoryConfirm])
|
||||||
|
|
||||||
const onUserConfirmed = useCallback(async () => {
|
const onUserConfirmed = useCallback(async () => {
|
||||||
const destination = destinationPath
|
if (!destinationPath) return
|
||||||
if (!destination) return
|
|
||||||
try {
|
try {
|
||||||
const appConfiguration: AppConfiguration =
|
const appConfiguration: AppConfiguration =
|
||||||
await window.core?.api?.getAppConfigurations()
|
await window.core?.api?.getAppConfigurations()
|
||||||
const currentJanDataFolder = appConfiguration.data_folder
|
const currentJanDataFolder = appConfiguration.data_folder
|
||||||
appConfiguration.data_folder = destination
|
appConfiguration.data_folder = destinationPath
|
||||||
await fs.syncFile(currentJanDataFolder, destination)
|
await fs.syncFile(currentJanDataFolder, destinationPath)
|
||||||
await window.core?.api?.updateAppConfiguration(appConfiguration)
|
await window.core?.api?.updateAppConfiguration(appConfiguration)
|
||||||
|
|
||||||
console.debug(
|
console.debug(
|
||||||
`File sync finished from ${currentJanDataFolder} to ${destination}`
|
`File sync finished from ${currentJanDataFolder} to ${destinationPath}`
|
||||||
)
|
)
|
||||||
|
|
||||||
localStorage.setItem(SUCCESS_SET_NEW_DESTINATION, 'true')
|
localStorage.setItem(SUCCESS_SET_NEW_DESTINATION, 'true')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user