mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-09-28 21:05:17 +02:00
Make query history fetch client-side
This commit is contained in:
@@ -216,6 +216,7 @@ def get_chat_session(
|
|||||||
chat_session_id=chat_session_id,
|
chat_session_id=chat_session_id,
|
||||||
user_id=user.id if user else None,
|
user_id=user.id if user else None,
|
||||||
db_session=db_session,
|
db_session=db_session,
|
||||||
|
include_deleted=True,
|
||||||
)
|
)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
@@ -1,11 +1,15 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
import { Bold, Text, Card, Title, Divider } from "@tremor/react";
|
import { Bold, Text, Card, Title, Divider } from "@tremor/react";
|
||||||
import { ChatSessionSnapshot, MessageSnapshot } from "../../analytics/types";
|
import { ChatSessionSnapshot, MessageSnapshot } from "../../analytics/types";
|
||||||
import { FiBook } from "react-icons/fi";
|
import { FiBook } from "react-icons/fi";
|
||||||
import { timestampToReadableDate } from "@/lib/dateUtils";
|
import { timestampToReadableDate } from "@/lib/dateUtils";
|
||||||
import { BackButton } from "@/components/BackButton";
|
import { BackButton } from "@/components/BackButton";
|
||||||
import { SSRAutoRefresh } from "@/components/SSRAutoRefresh";
|
|
||||||
import { FeedbackBadge } from "../FeedbackBadge";
|
import { FeedbackBadge } from "../FeedbackBadge";
|
||||||
import { fetchSS } from "@/lib/utilsSS";
|
import { errorHandlingFetcher } from "@/lib/fetcher";
|
||||||
|
import useSWR from "swr";
|
||||||
|
import { ErrorCallout } from "@/components/ErrorCallout";
|
||||||
|
import { ThreeDotsLoader } from "@/components/Loading";
|
||||||
|
|
||||||
function MessageDisplay({ message }: { message: MessageSnapshot }) {
|
function MessageDisplay({ message }: { message: MessageSnapshot }) {
|
||||||
return (
|
return (
|
||||||
@@ -47,18 +51,32 @@ function MessageDisplay({ message }: { message: MessageSnapshot }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function QueryPage({
|
export default function QueryPage({ params }: { params: { id: string } }) {
|
||||||
params,
|
const {
|
||||||
}: {
|
data: chatSessionSnapshot,
|
||||||
params: { id: string };
|
isLoading,
|
||||||
}) {
|
error,
|
||||||
const response = await fetchSS(`/admin/chat-session-history/${params.id}`);
|
} = useSWR<ChatSessionSnapshot>(
|
||||||
const chatSessionSnapshot = (await response.json()) as ChatSessionSnapshot;
|
`/api/admin/chat-session-history/${params.id}`,
|
||||||
|
errorHandlingFetcher
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isLoading) {
|
||||||
|
return <ThreeDotsLoader />;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!chatSessionSnapshot || error) {
|
||||||
|
return (
|
||||||
|
<ErrorCallout
|
||||||
|
errorTitle="Something went wrong :("
|
||||||
|
errorMsg={`Failed to fetch chat session - ${error}`}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main className="pt-4 mx-auto container">
|
<main className="pt-4 mx-auto container">
|
||||||
<BackButton />
|
<BackButton />
|
||||||
<SSRAutoRefresh />
|
|
||||||
|
|
||||||
<Card className="mt-4">
|
<Card className="mt-4">
|
||||||
<Title>Chat Session Details</Title>
|
<Title>Chat Session Details</Title>
|
||||||
|
Reference in New Issue
Block a user