SurfSense/surfsense_web/lib/chat/mention-doc-key.ts
DESKTOP-RTLN3BA\$punk c8374e6c5b
Some checks are pending
Build and Push Docker Images / tag_release (push) Waiting to run
Build and Push Docker Images / build (./surfsense_backend, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-24.04-arm, linux/arm64, arm64) (push) Blocked by required conditions
Build and Push Docker Images / build (./surfsense_backend, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-latest, linux/amd64, amd64) (push) Blocked by required conditions
Build and Push Docker Images / build (./surfsense_web, ./surfsense_web/Dockerfile, web, surfsense-web, ubuntu-24.04-arm, linux/arm64, arm64) (push) Blocked by required conditions
Build and Push Docker Images / build (./surfsense_web, ./surfsense_web/Dockerfile, web, surfsense-web, ubuntu-latest, linux/amd64, amd64) (push) Blocked by required conditions
Build and Push Docker Images / create_manifest (backend, surfsense-backend) (push) Blocked by required conditions
Build and Push Docker Images / create_manifest (web, surfsense-web) (push) Blocked by required conditions
feat: improved document, folder mentions rendering
2026-05-09 22:15:51 -07:00

18 lines
568 B
TypeScript

type MentionKeyInput = {
id: number;
document_type?: string | null;
kind?: "doc" | "folder";
};
/**
* Build a stable dedup key for a mention chip.
*
* The ``kind:document_type:id`` shape prevents a document and a folder
* with the same integer id from colliding in the chip array (folders
* use the ``FOLDER`` sentinel ``document_type``; the ``kind`` prefix
* is the belt-and-braces guard).
*/
export function getMentionDocKey(doc: MentionKeyInput): string {
const kind = doc.kind ?? "doc";
return `${kind}:${doc.document_type ?? "UNKNOWN"}:${doc.id}`;
}