Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
Add document context and improve conversation title display
Cursor Agent06541c8bd518
diff --git a/ee/features/conversations/components/conversation-document-context.tsx b/ee/features/conversations/components/conversation-document-context.tsxnew file mode 100644index 00000000..089324a4--- /dev/null+++ b/ee/features/conversations/components/conversation-document-context.tsx@@ -0,0 +1,54 @@+import { FileTextIcon, BookOpenIcon } from "lucide-react";++interface ConversationDocumentContextProps {+ dataroomDocument?: {+ document: {+ name: string;+ type?: string;+ };+ };+ documentPageNumber?: number;+ documentVersionNumber?: number;+ className?: string;+}++export function ConversationDocumentContext({+ dataroomDocument,+ documentPageNumber,+ documentVersionNumber,+ className = "",+}: ConversationDocumentContextProps) {+ if (!dataroomDocument) return null;++ const hasPageOrVersion = documentPageNumber || documentVersionNumber;++ return (+ <div+ className={`flex items-center gap-2 rounded-lg border bg-muted/50 px-3 py-2 text-sm ${className}`}+ >+ <div className="flex items-center gap-2 flex-1 min-w-0">+ <FileTextIcon className="h-4 w-4 text-muted-foreground shrink-0" />+ <span className="font-medium truncate">+ {dataroomDocument.document.name}+ </span>+ </div>++ {hasPageOrVersion && (+ <div className="flex items-center gap-2 text-xs text-muted-foreground shrink-0">+ {documentPageNumber && (+ <span className="flex items-center gap-1">+ <BookOpenIcon className="h-3 w-3" />+ Page {documentPageNumber}+ </span>+ )}+ {documentPageNumber && documentVersionNumber && (+ <span>•</span>+ )}+ {documentVersionNumber && (+ <span>v{documentVersionNumber}</span>+ )}+ </div>+ )}+ </div>+ );+}\ No newline at end of filediff --git a/ee/features/conversations/components/conversation-list-item.tsx b/ee/features/conversations/components/conversation-list-item.tsxindex 9aba5f8e..1cceac18 100644--- a/ee/features/conversations/components/conversation-list-item.tsx+++ b/ee/features/conversations/components/conversation-list-item.tsx@@ -13,6 +13,25 @@ export function ConversationListItem({conversation: any;isActive: boolean;}) {+ // Helper function to format document reference+ const formatDocumentReference = () => {+ if (!conversation.dataroomDocument) return "Untitled conversation";++ const documentName = conversation.dataroomDocument.document.name;+ const parts = [];++ if (conversation.documentPageNumber) {+ parts.push(`Page ${conversation.documentPageNumber}`);+ }++ if (conversation.documentVersionNumber) {+ parts.push(`v${conversation.documentVersionNumber}`);+ }++ const reference = parts.length > 0 ? ` (${parts.join(", ")})` : "";+ return `${documentName}${reference}`;+ };+return (<buttonclassName={cn(@@ -40,14 +59,7 @@ export function ConversationListItem({</div></div><div className="text-xs font-medium">- {conversation.title ||- (conversation.dataroomDocument- ? `${conversation.dataroomDocument.document.name}${- conversation.documentPageNumber- ? ` (Page ${conversation.documentPageNumber})`- : ""- }`- : "Untitled conversation")}+ {conversation.title || formatDocumentReference()}</div></div>diff --git a/ee/features/conversations/components/conversation-view-sidebar.tsx b/ee/features/conversations/components/conversation-view-sidebar.tsxindex 29a45964..1058361c 100644--- a/ee/features/conversations/components/conversation-view-sidebar.tsx+++ b/ee/features/conversations/components/conversation-view-sidebar.tsx@@ -3,6 +3,7 @@import { useState } from "react";import { ConversationMessage } from "@/ee/features/conversations/components/conversation-message";+import { ConversationDocumentContext } from "@/ee/features/conversations/components/conversation-document-context";import { format } from "date-fns";import { ArrowLeftIcon, BellIcon, BellOffIcon, Plus } from "lucide-react";import { toast } from "sonner";@@ -223,19 +224,40 @@ export function ConversationViewSidebar({{/* Conversation Header */}<div className="border-b p-4"><div className="flex items-center justify-between">- <div className="flex items-center">+ <div className="flex items-center flex-1 min-w-0"><Buttonvariant="ghost"size="icon"onClick={() => setActiveConversation(null)}- className="-ml-2 mr-2"+ className="-ml-2 mr-2 shrink-0"><ArrowLeftIcon className="h-5 w-5" /></Button>- <h3 className="truncate font-medium">- {activeConversation.title ||- "Untitled conversation"}- </h3>+ <div className="min-w-0">+ <h3 className="truncate font-medium">+ {activeConversation.title ||+ "Conversation"}+ </h3>+ {activeConversation.dataroomDocument && (+ <div className="flex items-center gap-1 text-xs text-muted-foreground mt-1">+ <span className="truncate">+ 📄 {activeConversation.dataroomDocument.document.name}+ </span>+ {(activeConversation.documentPageNumber ||+ activeConversation.documentVersionNumber) && (+ <span className="shrink-0">+ {activeConversation.documentPageNumber &&+ `Page ${activeConversation.documentPageNumber}`}+ {activeConversation.documentPageNumber &&+ activeConversation.documentVersionNumber &&+ " • "}+ {activeConversation.documentVersionNumber &&+ `v${activeConversation.documentVersionNumber}`}+ </span>+ )}+ </div>+ )}+ </div></div><Buttonvariant={@@ -302,6 +324,13 @@ export function ConversationViewSidebar({{/* Messages */}<ScrollArea className="flex-1"><div className="flex flex-col gap-2 p-4">+ {/* Document Context */}+ <ConversationDocumentContext+ dataroomDocument={activeConversation.dataroomDocument}+ documentPageNumber={activeConversation.documentPageNumber}+ documentVersionNumber={activeConversation.documentVersionNumber}+ className="mb-2"+ />{activeConversation.messages?.map((message) => (<ConversationMessagekey={message.id}diff --git a/ee/features/conversations/pages/conversation-detail.tsx b/ee/features/conversations/pages/conversation-detail.tsxindex 6e24fdaf..993656db 100644--- a/ee/features/conversations/pages/conversation-detail.tsx+++ b/ee/features/conversations/pages/conversation-detail.tsx@@ -4,6 +4,7 @@ import { useState } from "react";import { ConversationListItem } from "@/ee/features/conversations/components/conversation-list-item";import { ConversationMessage } from "@/ee/features/conversations/components/conversation-message";+import { ConversationDocumentContext } from "@/ee/features/conversations/components/conversation-document-context";import { Loader2, SearchIcon, Send, Trash2 } from "lucide-react";import { useSession } from "next-auth/react";import { toast } from "sonner";@@ -353,21 +354,33 @@ export default function ConversationDetailPage() {: "?"}</AvatarFallback></Avatar>- <div>+ <div className="flex-1"><h2 className="text-base font-semibold">- {conversation.title ||- (conversation.dataroomDocument- ? `${conversation.dataroomDocument.document.name}${- conversation.documentPageNumber- ? ` (Page ${conversation.documentPageNumber})`- : ""- }`- : "Untitled conversation")}+ {conversation.title || "Conversation"}</h2><p className="text-sm text-muted-foreground">{conversation.participants[0].email ||"Anonymous Viewer"}</p>+ {conversation.dataroomDocument && (+ <div className="mt-1 flex items-center gap-2 text-xs text-muted-foreground">+ <span className="flex items-center gap-1">+ 📄 {conversation.dataroomDocument.document.name}+ </span>+ {(conversation.documentPageNumber ||+ conversation.documentVersionNumber) && (+ <span className="text-xs">+ {conversation.documentPageNumber &&+ `Page ${conversation.documentPageNumber}`}+ {conversation.documentPageNumber &&+ conversation.documentVersionNumber &&+ " • "}+ {conversation.documentVersionNumber &&+ `v${conversation.documentVersionNumber}`}+ </span>+ )}+ </div>+ )}</div></div><Button@@ -383,6 +396,13 @@ export default function ConversationDetailPage() {{/* Messages */}<ScrollArea className="flex-1"><div className="flex flex-col gap-4 p-4">+ {/* Document Context */}+ <ConversationDocumentContext+ dataroomDocument={conversation.dataroomDocument}+ documentPageNumber={conversation.documentPageNumber}+ documentVersionNumber={conversation.documentVersionNumber}+ className="mb-2"+ />{conversation.messages.map((message) => (<ConversationMessagekey={message.id}