feat: implement document mention extraction and management in new chat

- Added functionality to extract and manage mentioned documents within the new chat interface.
- Introduced new atoms for storing mentioned documents and their mappings to user messages.
- Enhanced the message persistence logic to include mentioned documents, ensuring they are displayed correctly in the chat.
- Updated the UI components to support document mentions, including a refined document selection interface.
- Improved state management for document mentions to ensure a seamless user experience.
This commit is contained in:
Anish Sarkar 2025-12-23 15:13:03 +05:30
parent ceb01dc544
commit 8e3f4f4ed7
4 changed files with 383 additions and 204 deletions

View file

@ -1,6 +1,7 @@
"use client";
import { atom } from "jotai";
import type { Document } from "@/contracts/types/document.types";
/**
* Atom to store the IDs of documents mentioned in the current chat composer.
@ -8,3 +9,24 @@ import { atom } from "jotai";
*/
export const mentionedDocumentIdsAtom = atom<number[]>([]);
/**
* Atom to store the full document objects mentioned in the current chat composer.
* This persists across component remounts.
*/
export const mentionedDocumentsAtom = atom<Document[]>([]);
/**
* Simplified document info for display purposes
*/
export interface MentionedDocumentInfo {
id: number;
title: string;
document_type: string;
}
/**
* Atom to store mentioned documents per message ID.
* This allows displaying which documents were mentioned with each user message.
*/
export const messageDocumentsMapAtom = atom<Record<string, MentionedDocumentInfo[]>>({});