Skip to content

Commit 950268b

Browse files
committed
implement dialog for selected docs
1 parent 52567c0 commit 950268b

File tree

4 files changed

+21
-58
lines changed

4 files changed

+21
-58
lines changed

frontend/app/components/DocumentDialog.tsx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,23 @@ import { TooltipIconButton } from "./ui/assistant-ui/tooltip-icon-button";
1111

1212
interface DocumentDialogProps {
1313
document: Record<string, any>;
14+
trigger?: React.ReactNode;
1415
}
1516

1617
export function DocumentDialog(props: DocumentDialogProps) {
18+
const trigger = props.trigger || (
19+
<TooltipIconButton
20+
tooltip={props.document.metadata.title}
21+
variant="outline"
22+
className="w-6 h-6 z-50 transition-colors ease-in-out bg-transparent hover:bg-gray-500 border-gray-400 text-gray-300"
23+
>
24+
<File />
25+
</TooltipIconButton>
26+
);
27+
1728
return (
1829
<Dialog>
19-
<DialogTrigger asChild>
20-
<TooltipIconButton
21-
tooltip={props.document.metadata.title}
22-
variant="outline"
23-
className="w-6 h-6 z-50 transition-colors ease-in-out bg-transparent hover:bg-gray-500 border-gray-400 text-gray-300"
24-
>
25-
<File />
26-
</TooltipIconButton>
27-
</DialogTrigger>
30+
<DialogTrigger asChild={!props.trigger}>{trigger}</DialogTrigger>
2831
<DialogContent className="max-w-3xl max-h-[80vh] overflow-y-auto bg-gray-700 text-gray-200">
2932
<DialogHeader>
3033
<DialogTitle className="flex items-center justify-start gap-4">

frontend/app/components/SelectedDocumentsToolUI.tsx

Lines changed: 7 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
import { useAssistantToolUI } from "@assistant-ui/react";
22
import { Card, CardContent, CardHeader, CardTitle } from "./ui/card";
3-
import { BookOpenText, Plus, SquareArrowOutUpRight } from "lucide-react";
4-
import {
5-
TooltipProvider,
6-
TooltipTrigger,
7-
TooltipContent,
8-
Tooltip,
9-
} from "./ui/tooltip";
3+
import { BookOpenText, Plus } from "lucide-react";
104
import { Sheet, SheetContent, SheetTrigger } from "./ui/sheet";
5+
import { DocumentDialog } from "./DocumentDialog";
116

127
type Document = {
138
page_content: string;
@@ -36,42 +31,6 @@ const DocumentCard = ({ document }: { document: Document }) => {
3631
);
3732
};
3833

39-
const DocumentCardTooltip = ({ document }: { document: Document }) => {
40-
const description =
41-
document.metadata.description && document.metadata.description !== ""
42-
? document.metadata.description
43-
: document.page_content.slice(0, 250);
44-
45-
return (
46-
<TooltipProvider>
47-
<Tooltip defaultOpen delayDuration={0}>
48-
<TooltipTrigger asChild>
49-
<DocumentCard document={document} />
50-
</TooltipTrigger>
51-
<TooltipContent className="flex flex-col max-w-[600px] whitespace-pre-wrap">
52-
<div className="flex flex-col gap-1">
53-
<p className="font-medium text-gray-300">
54-
{document.metadata.title}
55-
</p>
56-
<div className="flex flex-wrap justify-start">
57-
<a
58-
href={document.metadata.source}
59-
target="_blank"
60-
rel="noopener noreferrer"
61-
className="flex items-center text-blue-400 hover:text-blue-300 transition-colors duration-200 break-all"
62-
>
63-
Source{" "}
64-
<SquareArrowOutUpRight className="ml-1 h-4 w-4 flex-shrink-0" />
65-
</a>
66-
</div>
67-
<p className="text-xs font-light text-gray-400">{description}</p>
68-
</div>
69-
</TooltipContent>
70-
</Tooltip>
71-
</TooltipProvider>
72-
);
73-
};
74-
7534
export const useSelectedDocumentsUI = () =>
7635
useAssistantToolUI({
7736
toolName: "selected_documents",
@@ -92,9 +51,10 @@ export const useSelectedDocumentsUI = () =>
9251
</span>
9352
<div className="flex flex-wrap items-center justify-start gap-2">
9453
{displayedDocuments.map((document, docIndex) => (
95-
<DocumentCardTooltip
96-
key={`final-document-${docIndex}`}
54+
<DocumentDialog
55+
key={`all-documents-${docIndex}`}
9756
document={document}
57+
trigger={<DocumentCard document={document} />}
9858
/>
9959
))}
10060
{remainingDocuments.length > 0 && (
@@ -114,9 +74,10 @@ export const useSelectedDocumentsUI = () =>
11474
</h2>
11575
<div className="flex flex-wrap gap-2">
11676
{documents.map((document, docIndex) => (
117-
<DocumentCardTooltip
77+
<DocumentDialog
11878
key={`all-documents-${docIndex}`}
11979
document={document}
80+
trigger={<DocumentCard document={document} />}
12081
/>
12182
))}
12283
</div>

frontend/app/hooks/useThreads.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ export function useThreads(userId: string | undefined) {
117117
return newThreads;
118118
});
119119
if (id === threadId) {
120-
console.log("Deleted current thread. Creating a new one.");
121120
clearMessages();
122121
// Create a new thread. Use .then to avoid blocking the UI.
123122
// Once completed re-fetch threads to update UI.

frontend/app/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use client";
22

3-
import React, { useEffect, useState } from "react";
3+
import React, { useState } from "react";
44
import {
55
AppendMessage,
66
AssistantRuntimeProvider,
@@ -100,7 +100,7 @@ export default function ContentComposerChatInterface(): React.ReactElement {
100100
isRunning,
101101
onNew,
102102
});
103-
console.log("messages.length", messages.length);
103+
104104
return (
105105
<div className="overflow-hidden w-full flex md:flex-row flex-col relative">
106106
{messages.length > 0 ? (

0 commit comments

Comments
 (0)