Skip to content

Commit 78909c1

Browse files
committed
Fix comments
1 parent c853166 commit 78909c1

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

packages/server/api/src/app/ai/chat/ai-chat.service.ts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ export type MCPChatContext = {
5858
model?: string;
5959
};
6060

61+
type ChatSummary = { chatId: string; chatName: string };
62+
6163
export const generateChatId = (
6264
params: MCPChatContext & {
6365
userId: string;
@@ -193,21 +195,18 @@ export const getAllChats = async (
193195
chatIds.map((chatId) => getChatContext(chatId, userId, projectId)),
194196
);
195197

196-
const chats: { chatId: string; chatName: string }[] = [];
197-
198-
for (let i = 0; i < chatIds.length; i++) {
199-
const context = contexts[i];
200-
const chatId = chatIds[i];
201-
202-
if (context?.chatName) {
203-
chats.push({
204-
chatId,
205-
chatName: context.chatName,
206-
});
198+
const chatsOrNull = chatIds.map((chatId, index): ChatSummary | null => {
199+
const context = contexts[index];
200+
if (!context?.chatName) {
201+
return null;
207202
}
208-
}
203+
return {
204+
chatId,
205+
chatName: context.chatName,
206+
};
207+
});
209208

210-
return chats;
209+
return chatsOrNull.filter((chat): chat is ChatSummary => chat !== null);
211210
};
212211

213212
export const saveChatHistory = async (

0 commit comments

Comments
 (0)