diff --git a/apps/chat/src/components/Chatbar/ChatbarSettings.tsx b/apps/chat/src/components/Chatbar/ChatbarSettings.tsx index 118faf3aa..fe43de3ef 100644 --- a/apps/chat/src/components/Chatbar/ChatbarSettings.tsx +++ b/apps/chat/src/components/Chatbar/ChatbarSettings.tsx @@ -11,6 +11,7 @@ import { useTranslation } from 'next-i18next'; import { BucketService } from '@/src/utils/app/data/bucket-service'; import { constructPath } from '@/src/utils/app/file'; +import { getRootId } from '@/src/utils/app/id'; import { ApiKeys } from '@/src/utils/server/api'; import { FeatureType } from '@/src/types/common'; @@ -89,10 +90,7 @@ export const ChatbarSettings = () => { onClick: () => { dispatch( ConversationsActions.createFolder({ - parentId: constructPath( - ApiKeys.Conversations, - BucketService.getBucket(), - ), + parentId: getRootId({ apiKey: ApiKeys.Conversations }), }), ); }, diff --git a/apps/chat/src/components/Chatbar/Conversation.tsx b/apps/chat/src/components/Chatbar/Conversation.tsx index 616bee1bf..8fd5853cd 100644 --- a/apps/chat/src/components/Chatbar/Conversation.tsx +++ b/apps/chat/src/components/Chatbar/Conversation.tsx @@ -15,6 +15,7 @@ import classNames from 'classnames'; import { BucketService } from '@/src/utils/app/data/bucket-service'; import { constructPath, notAllowedSymbolsRegex } from '@/src/utils/app/file'; +import { getRootId } from '@/src/utils/app/id'; import { hasParentWithFloatingOverlay } from '@/src/utils/app/modals'; import { MoveType, getDragImage } from '@/src/utils/app/move'; import { defaultMyItemsFilters } from '@/src/utils/app/search'; @@ -349,10 +350,7 @@ export const ConversationComponent = ({ item: conversation, level }: Props) => { if (isNewFolder) { dispatch( ConversationsActions.createFolder({ - parentId: constructPath( - ApiKeys.Conversations, - BucketService.getBucket(), - ), + parentId: getRootId({ apiKey: ApiKeys.Conversations }), name: newFolderName, }), ); @@ -363,8 +361,7 @@ export const ConversationComponent = ({ item: conversation, level }: Props) => { values: { folderId: isNewFolder ? constructPath( - ApiKeys.Conversations, - BucketService.getBucket(), + getRootId({ apiKey: ApiKeys.Conversations }), folderPath, ) : folderPath, diff --git a/apps/chat/src/components/Files/PreUploadModal.tsx b/apps/chat/src/components/Files/PreUploadModal.tsx index f44c7e622..01f1e7f1d 100644 --- a/apps/chat/src/components/Files/PreUploadModal.tsx +++ b/apps/chat/src/components/Files/PreUploadModal.tsx @@ -23,6 +23,7 @@ import { notAllowedSymbols, } from '@/src/utils/app/file'; import { getParentAndCurrentFoldersById } from '@/src/utils/app/folders'; +import { getRootId } from '@/src/utils/app/id'; import { ApiKeys } from '@/src/utils/server/api'; import { DialFile } from '@/src/types/files'; @@ -147,12 +148,7 @@ export const PreUploadDialog = ({ filteredFiles.map((file) => { return { fileContent: file, - id: constructPath( - ApiKeys.Files, - BucketService.getBucket(), - folderPath, - file.name, - ), + id: constructPath(getRootId(), folderPath, file.name), name: file.name, }; }), @@ -251,8 +247,7 @@ export const PreUploadDialog = ({ ...file, name: e.target.value + formatFile, id: constructPath( - ApiKeys.Files, - BucketService.getBucket(), + getRootId(), folderPath, e.target.value + formatFile, ), @@ -299,8 +294,7 @@ export const PreUploadDialog = ({ return { ...file, id: constructPath( - ApiKeys.Files, - BucketService.getBucket(), + getRootId(), folderPath, file.name, ), diff --git a/apps/chat/src/components/Promptbar/components/Prompt.tsx b/apps/chat/src/components/Promptbar/components/Prompt.tsx index 0bee15f50..ad32689d8 100644 --- a/apps/chat/src/components/Promptbar/components/Prompt.tsx +++ b/apps/chat/src/components/Promptbar/components/Prompt.tsx @@ -223,8 +223,7 @@ export const PromptComponent = ({ item: prompt, level }: Props) => { values: { folderId: isNewFolder ? constructPath( - ApiKeys.Prompts, - BucketService.getBucket(), + getRootId({ apiKey: ApiKeys.Prompts }), folderPath, ) : folderPath, diff --git a/apps/chat/src/components/Promptbar/components/PromptbarSettings.tsx b/apps/chat/src/components/Promptbar/components/PromptbarSettings.tsx index 4fb5546bc..1f30d96f7 100644 --- a/apps/chat/src/components/Promptbar/components/PromptbarSettings.tsx +++ b/apps/chat/src/components/Promptbar/components/PromptbarSettings.tsx @@ -9,6 +9,7 @@ import { useTranslation } from 'next-i18next'; import { BucketService } from '@/src/utils/app/data/bucket-service'; import { constructPath } from '@/src/utils/app/file'; +import { getRootId } from '@/src/utils/app/id'; import { ApiKeys } from '@/src/utils/server/api'; import { FeatureType } from '@/src/types/common'; @@ -46,10 +47,7 @@ export function PromptbarSettings() { onClick: () => { dispatch( PromptsActions.createFolder({ - parentId: constructPath( - ApiKeys.Prompts, - BucketService.getBucket(), - ), + parentId: getRootId({ apiKey: ApiKeys.Prompts }), }), ); }, diff --git a/apps/chat/src/store/conversations/conversations.epics.ts b/apps/chat/src/store/conversations/conversations.epics.ts index 742a178db..d7b77cdce 100644 --- a/apps/chat/src/store/conversations/conversations.epics.ts +++ b/apps/chat/src/store/conversations/conversations.epics.ts @@ -295,10 +295,7 @@ const createNewConversationsEpic: AppEpic = (action$, state$) => lastActivityDate: Date.now(), isMessageStreaming: false, status: UploadStatus.LOADED, - folderId: constructPath( - ApiKeys.Conversations, - BucketService.getBucket(), - ), + folderId: getRootId({ apiKey: ApiKeys.Conversations }), }); }, ); @@ -460,10 +457,7 @@ const duplicateConversationEpic: AppEpic = (action$, state$) => const newConversation: Conversation = regenerateConversationId({ ...conversation, ...resetShareEntity, - folderId: constructPath( - ApiKeys.Conversations, - BucketService.getBucket(), - ), + folderId: getRootId({ apiKey: ApiKeys.Conversations }), name: generateNextName( DEFAULT_CONVERSATION_NAME, conversation.name, diff --git a/apps/chat/src/store/conversations/conversations.reducers.ts b/apps/chat/src/store/conversations/conversations.reducers.ts index 6921342a1..137dca552 100644 --- a/apps/chat/src/store/conversations/conversations.reducers.ts +++ b/apps/chat/src/store/conversations/conversations.reducers.ts @@ -299,10 +299,7 @@ export const conversationsSlice = createSlice({ const newConversation: Conversation = regenerateConversationId({ ...(conversation as Conversation), ...resetShareEntity, - folderId: constructPath( - ApiKeys.Conversations, - BucketService.getBucket(), - ), + folderId: getRootId({ apiKey: ApiKeys.Conversations }), name: generateNextName( DEFAULT_CONVERSATION_NAME, conversation.name, diff --git a/apps/chat/src/store/files/files.reducers.ts b/apps/chat/src/store/files/files.reducers.ts index f24aa3f60..1751b301e 100644 --- a/apps/chat/src/store/files/files.reducers.ts +++ b/apps/chat/src/store/files/files.reducers.ts @@ -7,6 +7,7 @@ import { getAvailableNameOnSameFolderLevel, getParentAndChildFolders, } from '@/src/utils/app/folders'; +import { getRootId } from '@/src/utils/app/id'; import { ApiKeys } from '@/src/utils/server/api'; import { UploadStatus } from '@/src/types/common'; @@ -57,11 +58,7 @@ export const filesSlice = createSlice({ id: payload.id, name: payload.name, relativePath: payload.relativePath, - folderId: constructPath( - ApiKeys.Files, - BucketService.getBucket(), - payload.relativePath, - ), + folderId: constructPath(getRootId(), payload.relativePath), status: UploadStatus.LOADING, percent: 0, @@ -225,8 +222,7 @@ export const filesSlice = createSlice({ ); const newAddedFolderId = constructPath( - ApiKeys.Files, - BucketService.getBucket(), + getRootId(), payload.relativePath, folderName, ); @@ -234,11 +230,7 @@ export const filesSlice = createSlice({ addGeneratedFolderId({ name: folderName, type: FolderType.File, - folderId: constructPath( - ApiKeys.Files, - BucketService.getBucket(), - payload.relativePath, - ), + folderId: constructPath(getRootId(), payload.relativePath), }), ); state.newAddedFolderId = newAddedFolderId; diff --git a/apps/chat/src/utils/app/conversation.ts b/apps/chat/src/utils/app/conversation.ts index d88628564..578b8519c 100644 --- a/apps/chat/src/utils/app/conversation.ts +++ b/apps/chat/src/utils/app/conversation.ts @@ -16,6 +16,7 @@ import { import { BucketService } from './data/bucket-service'; import { constructPath, notAllowedSymbolsRegex } from './file'; import { compareEntitiesByName, splitEntityId } from './folders'; +import { getRootId } from './id'; export const getAssitantModelId = ( modelType: EntityType, @@ -114,8 +115,7 @@ export const getGeneratedConversationId = ( ); } return constructPath( - ApiKeys.Conversations, - BucketService.getBucket(), + getRootId({ apiKey: ApiKeys.Conversations }), getConversationApiKey(conversation), ); }; diff --git a/apps/chat/src/utils/app/import-export.ts b/apps/chat/src/utils/app/import-export.ts index 0be1ca4af..3c8b991d8 100644 --- a/apps/chat/src/utils/app/import-export.ts +++ b/apps/chat/src/utils/app/import-export.ts @@ -76,10 +76,7 @@ export function cleanData(data: SupportedExportFormats): CleanDataResponse { id: chatFolder.id.toString(), name: chatFolder.name, type: FolderType.Chat, - folderId: constructPath( - ApiKeys.Conversations, - BucketService.getBucket(), - ), + folderId: getRootId({ apiKey: ApiKeys.Conversations }), })), prompts: [], isError: false,