From 0e5ce83ee55b8621419e05cb1b91623eb64ec08e Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Tue, 23 Jun 2026 17:04:43 +0200 Subject: [PATCH] feat(chat): persist referenced-chat mention chips on user turns Recognise the "thread" chip kind when building stored user content so referenced-chat mentions survive reloads and regeneration. --- surfsense_backend/app/tasks/chat/persistence.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/surfsense_backend/app/tasks/chat/persistence.py b/surfsense_backend/app/tasks/chat/persistence.py index 9d100c13c..8840ec995 100644 --- a/surfsense_backend/app/tasks/chat/persistence.py +++ b/surfsense_backend/app/tasks/chat/persistence.py @@ -109,7 +109,8 @@ def _build_user_content( [{"type": "text", "text": "..."}, {"type": "image", "image": "data:..."}, {"type": "mentioned-documents", "documents": [{"id": int, - "title": str, "kind": "doc" | "folder" | "connector", ...}, + "title": str, "kind": "doc" | "folder" | "connector" | "thread", + ...}, ...]}] The companion reader is @@ -135,7 +136,11 @@ def _build_user_content( title = doc.get("title") document_type = doc.get("document_type") kind_raw = doc.get("kind", "doc") - kind = kind_raw if kind_raw in ("doc", "folder", "connector") else "doc" + kind = ( + kind_raw + if kind_raw in ("doc", "folder", "connector", "thread") + else "doc" + ) if doc_id is None or title is None: continue if kind == "doc" and document_type is None: