mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-26 21:39:43 +02:00
Add the "thread" mention kind (makeThreadMention + stable dedup key) so a chat can be referenced like a document. Also introduce submittedMentionsAtom and a pure deriveMentionedPayload() helper, the building blocks for capturing chips at submit time and mapping them to backend payload buckets.
21 lines
746 B
TypeScript
21 lines
746 B
TypeScript
type MentionKeyInput = {
|
|
id: number;
|
|
document_type?: string | null;
|
|
connector_type?: string | null;
|
|
kind?: "doc" | "folder" | "connector" | "thread";
|
|
};
|
|
|
|
/**
|
|
* Build a stable dedup key for a mention chip.
|
|
*
|
|
* Each mention kind keys off its real identity fields:
|
|
* docs by document type, folders by folder id, connectors by
|
|
* connector type + account id, and threads by thread id.
|
|
*/
|
|
export function getMentionDocKey(doc: MentionKeyInput): string {
|
|
const kind = doc.kind ?? "doc";
|
|
if (kind === "folder") return `folder:${doc.id}`;
|
|
if (kind === "thread") return `thread:${doc.id}`;
|
|
if (kind === "connector") return `connector:${doc.connector_type ?? "UNKNOWN"}:${doc.id}`;
|
|
return `doc:${doc.document_type ?? "UNKNOWN"}:${doc.id}`;
|
|
}
|