From dfd799f0464874c2e9dd40719fc2b23fc0b69a83 Mon Sep 17 00:00:00 2001 From: mawkone Date: Sat, 16 May 2026 11:32:40 -0700 Subject: [PATCH] feat(ui): add JSON export functionality to session viewer for AI fine-tuning --- .../(home)/sessions/[sessionId]/page.tsx | 93 +++++++++++++++---- 1 file changed, 76 insertions(+), 17 deletions(-) diff --git a/vibn-frontend/app/[workspace]/project/[projectId]/(home)/sessions/[sessionId]/page.tsx b/vibn-frontend/app/[workspace]/project/[projectId]/(home)/sessions/[sessionId]/page.tsx index 79b8de8b..19c196e4 100644 --- a/vibn-frontend/app/[workspace]/project/[projectId]/(home)/sessions/[sessionId]/page.tsx +++ b/vibn-frontend/app/[workspace]/project/[projectId]/(home)/sessions/[sessionId]/page.tsx @@ -2,7 +2,15 @@ import { useEffect, useState } from "react"; import { useParams, useRouter } from "next/navigation"; -import { Loader2, ArrowLeft, Bot, User, Code2, Wrench } from "lucide-react"; +import { + Loader2, + ArrowLeft, + Bot, + User, + Code2, + Wrench, + Download, +} from "lucide-react"; import ReactMarkdown from "react-markdown"; interface ToolCall { @@ -33,8 +41,8 @@ export default function SessionViewer() { useEffect(() => { fetch(`/api/chat/threads/${sessionId}`) - .then(r => r.json()) - .then(d => { + .then((r) => r.json()) + .then((d) => { setThread(d.thread); setMessages(d.messages || []); }) @@ -54,7 +62,7 @@ export default function SessionViewer() { return (

Session not found.

- -
-

{thread.title}

-

{new Date(thread.createdAt).toLocaleString()}

+
+

+ {thread.title} +

+

+ {new Date(thread.createdAt).toLocaleString()} +

+
@@ -94,7 +144,7 @@ export default function SessionViewer() {
)}
- +
{m.role === "user" && m.content && (
@@ -107,7 +157,10 @@ export default function SessionViewer() { {m.toolCalls && m.toolCalls.length > 0 && (
{m.toolCalls.map((tc, idx) => ( -
+
{tc.name} @@ -125,20 +178,26 @@ export default function SessionViewer() { {m.content}
)} - + {/* Fallback for when textSegments exists but content is empty */} - {!m.content && m.textSegments && m.textSegments.length > 0 && ( -
- {m.textSegments.join("\n\n")} -
- )} + {!m.content && + m.textSegments && + m.textSegments.length > 0 && ( +
+ + {m.textSegments.join("\n\n")} + +
+ )} )}
))} {messages.length === 0 && ( -

Empty session.

+

+ Empty session. +

)}