From 8b0a2f8964fe506418e6557772dbb44136c1acb0 Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Tue, 23 Jun 2026 15:47:21 +0200 Subject: [PATCH] feat: link artifacts to source chat --- surfsense_backend/app/podcasts/api/schemas.py | 1 + surfsense_backend/app/schemas/reports.py | 1 + .../app/schemas/video_presentations.py | 2 ++ .../contracts/types/podcast.types.ts | 1 + .../contracts/types/reports.types.ts | 1 + .../types/video-presentations.types.ts | 1 + .../hooks/use-library-artifacts.ts | 3 ++ .../artifacts-library/model/artifact.ts | 2 ++ .../artifacts-library/ui/artifact-card.tsx | 32 +++++++++++++++---- .../ui/artifacts-library.tsx | 7 +++- 10 files changed, 44 insertions(+), 7 deletions(-) diff --git a/surfsense_backend/app/podcasts/api/schemas.py b/surfsense_backend/app/podcasts/api/schemas.py index cb8559651..e9d6e6b0c 100644 --- a/surfsense_backend/app/podcasts/api/schemas.py +++ b/surfsense_backend/app/podcasts/api/schemas.py @@ -84,6 +84,7 @@ class PodcastSummary(BaseModel): status: PodcastStatus created_at: datetime search_space_id: int + thread_id: int | None = None class PodcastDetail(BaseModel): diff --git a/surfsense_backend/app/schemas/reports.py b/surfsense_backend/app/schemas/reports.py index 25ca50607..cfd9d89ca 100644 --- a/surfsense_backend/app/schemas/reports.py +++ b/surfsense_backend/app/schemas/reports.py @@ -24,6 +24,7 @@ class ReportRead(BaseModel): report_metadata: dict[str, Any] | None = None report_group_id: int | None = None content_type: str = "markdown" + thread_id: int | None = None created_at: datetime class Config: diff --git a/surfsense_backend/app/schemas/video_presentations.py b/surfsense_backend/app/schemas/video_presentations.py index ec29147ef..68ef3f5ba 100644 --- a/surfsense_backend/app/schemas/video_presentations.py +++ b/surfsense_backend/app/schemas/video_presentations.py @@ -44,6 +44,7 @@ class VideoPresentationRead(VideoPresentationBase): status: VideoPresentationStatusEnum = VideoPresentationStatusEnum.READY created_at: datetime slide_count: int | None = None + thread_id: int | None = None class Config: from_attributes = True @@ -68,6 +69,7 @@ class VideoPresentationRead(VideoPresentationBase): "status": obj.status, "created_at": obj.created_at, "slide_count": len(obj.slides) if obj.slides else None, + "thread_id": obj.thread_id, } return cls(**data) diff --git a/surfsense_web/contracts/types/podcast.types.ts b/surfsense_web/contracts/types/podcast.types.ts index c8247a7fe..365847668 100644 --- a/surfsense_web/contracts/types/podcast.types.ts +++ b/surfsense_web/contracts/types/podcast.types.ts @@ -163,6 +163,7 @@ export const podcastSummary = z.object({ status: podcastStatus, created_at: z.string(), search_space_id: z.number(), + thread_id: z.number().nullish(), }); export type PodcastSummary = z.infer; diff --git a/surfsense_web/contracts/types/reports.types.ts b/surfsense_web/contracts/types/reports.types.ts index 25a682084..8c7b1fe72 100644 --- a/surfsense_web/contracts/types/reports.types.ts +++ b/surfsense_web/contracts/types/reports.types.ts @@ -17,6 +17,7 @@ export const reportListItem = z.object({ title: z.string(), content_type: z.string().default("markdown"), report_metadata: reportMetadata, + thread_id: z.number().nullish(), created_at: z.string(), }); export type ReportListItem = z.infer; diff --git a/surfsense_web/contracts/types/video-presentations.types.ts b/surfsense_web/contracts/types/video-presentations.types.ts index 45b062840..7e0603c75 100644 --- a/surfsense_web/contracts/types/video-presentations.types.ts +++ b/surfsense_web/contracts/types/video-presentations.types.ts @@ -13,6 +13,7 @@ export const videoPresentationListItem = z.object({ status: videoPresentationStatus.default("ready"), created_at: z.string(), search_space_id: z.number(), + thread_id: z.number().nullish(), }); export type VideoPresentationListItem = z.infer; diff --git a/surfsense_web/features/artifacts-library/hooks/use-library-artifacts.ts b/surfsense_web/features/artifacts-library/hooks/use-library-artifacts.ts index 15f65d9b0..e9ed68633 100644 --- a/surfsense_web/features/artifacts-library/hooks/use-library-artifacts.ts +++ b/surfsense_web/features/artifacts-library/hooks/use-library-artifacts.ts @@ -39,6 +39,7 @@ async function fetchLibraryArtifacts(searchSpaceId: number): Promise void; }) { const meta = KIND_META[artifact.kind]; @@ -20,11 +24,16 @@ export function ArtifactCard({ : meta.label; return ( - + @@ -38,6 +47,17 @@ export function ArtifactCard({ {formatRelativeDate(artifact.createdAt)} - + + {artifact.sourceThreadId ? ( + + + Open source chat + + ) : null} + ); } diff --git a/surfsense_web/features/artifacts-library/ui/artifacts-library.tsx b/surfsense_web/features/artifacts-library/ui/artifacts-library.tsx index 0c354c331..3441f626e 100644 --- a/surfsense_web/features/artifacts-library/ui/artifacts-library.tsx +++ b/surfsense_web/features/artifacts-library/ui/artifacts-library.tsx @@ -121,7 +121,12 @@ export function ArtifactsLibrary({ searchSpaceId }: { searchSpaceId: number }) {
{items.map((artifact) => ( - + ))}