diff --git a/apps/server/src/api/v2/chats/services/asset-import-service.ts b/apps/server/src/api/v2/chats/services/asset-import-service.ts index fe154d92d..ab5a463ee 100644 --- a/apps/server/src/api/v2/chats/services/asset-import-service.ts +++ b/apps/server/src/api/v2/chats/services/asset-import-service.ts @@ -6,7 +6,6 @@ import { createMessage, createMessageFileAssociation, db, - getAssetDetailsById, } from '@buster/database'; import type { ChatAssetType, @@ -66,13 +65,12 @@ export async function createAssetImportMessage( }); // Update the chat with most recent file information and title (matching Rust behavior) - const fileType = assetType === 'metric' ? 'metric' : 'dashboard'; await db .update(chats) .set({ title: assetDetails.name, // Set chat title to asset name mostRecentFileId: assetId, - mostRecentFileType: fileType, + mostRecentFileType: assetType, mostRecentVersionNumber: assetDetails.versionNumber, updatedAt: new Date().toISOString(), }) diff --git a/apps/server/src/api/v2/chats/services/chat-helpers.ts b/apps/server/src/api/v2/chats/services/chat-helpers.ts index 4eac00b92..79a650d8c 100644 --- a/apps/server/src/api/v2/chats/services/chat-helpers.ts +++ b/apps/server/src/api/v2/chats/services/chat-helpers.ts @@ -466,7 +466,6 @@ export async function handleAssetChat( } // Update the chat with most recent file information and title (matching Rust behavior) - const fileType = chatAssetType === 'metric' ? 'metric' : 'dashboard'; // Get the asset name from the first message const assetName = assetMessages[0]?.title || ''; @@ -476,7 +475,7 @@ export async function handleAssetChat( .set({ title: assetName, // Set chat title to asset name mostRecentFileId: assetId, - mostRecentFileType: fileType, + mostRecentFileType: chatAssetType, mostRecentVersionNumber: 1, // Asset imports always start at version 1 updatedAt: new Date().toISOString(), }) @@ -617,7 +616,6 @@ export async function handleAssetChatWithPrompt( } // Update the chat with most recent file information and title (matching handleAssetChat) - const fileType = chatAssetType === 'metric' ? 'metric' : 'dashboard'; const assetName = assetMessages[0]?.title || ''; await db @@ -625,7 +623,7 @@ export async function handleAssetChatWithPrompt( .set({ title: assetName, // Set chat title to asset name mostRecentFileId: assetId, - mostRecentFileType: fileType, + mostRecentFileType: chatAssetType, mostRecentVersionNumber: 1, // Asset imports always start at version 1 updatedAt: new Date().toISOString(), }) diff --git a/packages/ai/src/steps/analyst-agent-steps/mark-message-complete-step/mark-message-complete-step.ts b/packages/ai/src/steps/analyst-agent-steps/mark-message-complete-step/mark-message-complete-step.ts index a8ac303c8..489b498f4 100644 --- a/packages/ai/src/steps/analyst-agent-steps/mark-message-complete-step/mark-message-complete-step.ts +++ b/packages/ai/src/steps/analyst-agent-steps/mark-message-complete-step/mark-message-complete-step.ts @@ -55,7 +55,7 @@ export async function markMessageComplete( if (input.selectedFile?.fileId && input.chatId) { await updateChat(input.chatId, { mostRecentFileId: input.selectedFile.fileId, - mostRecentFileType: input.selectedFile.fileType, + mostRecentFileType: input.selectedFile.fileType, //TODO: scope to actually be the enum file type mostRecentVersionNumber: input.selectedFile.versionNumber, }); } diff --git a/packages/ai/src/tools/communication-tools/done-tool/done-tool-start.ts b/packages/ai/src/tools/communication-tools/done-tool/done-tool-start.ts index 032ca1116..f8e3f7e32 100644 --- a/packages/ai/src/tools/communication-tools/done-tool/done-tool-start.ts +++ b/packages/ai/src/tools/communication-tools/done-tool/done-tool-start.ts @@ -94,7 +94,7 @@ export function createDoneToolStart(context: DoneToolContext, doneToolState: Don try { await updateChat(context.chatId, { mostRecentFileId: mostRecentFile.id, - mostRecentFileType: mostRecentFile.fileType as 'metric' | 'dashboard' | 'report', + mostRecentFileType: mostRecentFile.fileType, mostRecentVersionNumber: mostRecentFile.versionNumber || 1, }); } catch (error) { diff --git a/packages/ai/src/tools/communication-tools/done-tool/helpers/done-tool-file-selection.ts b/packages/ai/src/tools/communication-tools/done-tool/helpers/done-tool-file-selection.ts index 66771d826..c6788fe7b 100644 --- a/packages/ai/src/tools/communication-tools/done-tool/helpers/done-tool-file-selection.ts +++ b/packages/ai/src/tools/communication-tools/done-tool/helpers/done-tool-file-selection.ts @@ -49,9 +49,9 @@ interface ToolFileInfo { // File tracking type interface ExtractedFile { id: string; - fileType: 'metric' | 'dashboard' | 'report'; + fileType: 'metric' | 'dashboard' | 'report'; //TODO: scope to actually be the enum file type fileName: string; - status: 'completed' | 'failed' | 'loading'; + status: 'completed' | 'failed' | 'loading'; //TODO: use an enum from server shared operation?: 'created' | 'modified' | undefined; versionNumber?: number | undefined; metricIds?: string[] | undefined; // IDs of metrics that belong to this dashboard