handoff fixes

This commit is contained in:
debu-2 2026-10-06 02:21:27 +05:30
parent 3f4bcc26d9
commit 6c52cd19cb
8 changed files with 561 additions and 59 deletions

View file

@ -2,6 +2,29 @@ import { ArrowLeft } from "lucide-react";
import { useCallback, useEffect, useState } from "react";
import { getHandoffConversation } from "../api";
function HandoffMessageBody({ message }) {
const [showQuoted, setShowQuoted] = useState(false);
const displayText = message.new_reply_content || message.body_text || message.snippet;
return (
<>
<div className="handoff-message-body">{displayText}</div>
{message.has_quoted_text && message.raw_body && (
<button
type="button"
className="handoff-show-quoted"
onClick={() => setShowQuoted((current) => !current)}
>
{showQuoted ? "Hide quoted text" : "Show quoted text"}
</button>
)}
{showQuoted && message.raw_body && (
<pre className="handoff-quoted-body">{message.raw_body}</pre>
)}
</>
);
}
function formatTime(dateValue) {
if (!dateValue) return "";
return new Date(dateValue).toLocaleString(undefined, {
@ -63,9 +86,7 @@ export default function HandoffConversation({ handoffId, onBack }) {
<strong>{message.role === "human" ? "HUMAN OWNER" : "AGENT"}</strong>
<time>{formatTime(message.event_at)}</time>
</header>
<div className="handoff-message-body">
{message.body_text || message.snippet}
</div>
<HandoffMessageBody message={message} />
</article>
))}
</div>