feat(mentions): add sidebar mention event atom and enhance document mention handling in the editor

This commit is contained in:
Anish Sarkar 2026-04-28 17:50:21 +05:30
parent f607636ba6
commit 960f761c6c
4 changed files with 227 additions and 27 deletions

View file

@ -11,12 +11,24 @@ export const mentionedDocumentsAtom = atom<Pick<Document, "id" | "title" | "docu
/**
* Atom to store documents selected via the sidebar checkboxes / row clicks.
* These are NOT inserted as chips the composer shows a count badge instead.
* These power the selected-sources badge and backend doc filters.
*/
export const sidebarSelectedDocumentsAtom = atom<
Pick<Document, "id" | "title" | "document_type">[]
>([]);
export interface SidebarMentionEvent {
kind: "add" | "remove";
docs: Pick<Document, "id" | "title" | "document_type">[];
nonce: number;
}
/**
* Event atom used to tell the composer that documents were selected/unselected
* from sidebar checkboxes, so chips can be inserted/removed in-editor.
*/
export const sidebarMentionEventAtom = atom<SidebarMentionEvent | null>(null);
/**
* Derived read-only atom that merges @-mention chips and sidebar selections
* into a single deduplicated set of document IDs for the backend.