diff --git a/frontend/src/components/workspace/workspace-header.tsx b/frontend/src/components/workspace/workspace-header.tsx index 932f38eb..2f463586 100644 --- a/frontend/src/components/workspace/workspace-header.tsx +++ b/frontend/src/components/workspace/workspace-header.tsx @@ -3,6 +3,7 @@ import { MessageSquarePlus } from "lucide-react"; import Link from "next/link"; import { usePathname } from "next/navigation"; +import { toast } from "sonner"; import { SidebarMenu, @@ -11,14 +12,34 @@ import { SidebarTrigger, useSidebar, } from "@/components/ui/sidebar"; +import { useThreadChat } from "@/components/workspace/chats"; import { useI18n } from "@/core/i18n/hooks"; +import { POST_MESSAGE_TYPES, sendToParent } from "@/core/iframe-messages"; import { env } from "@/env"; import { cn } from "@/lib/utils"; +import { copyToClipboard } from "@/lib/utils"; export function WorkspaceHeader({ className }: { className?: string }) { const { t } = useI18n(); const { state } = useSidebar(); const pathname = usePathname(); + const { threadId } = useThreadChat(); + const threadUrl = threadId ? `/workspace/chats/${threadId}` : ""; + + const handleCopyThreadId = async () => { + if (!threadId) return; + sendToParent({ + type: POST_MESSAGE_TYPES.COPY_TO_CLIPBOARD, + text: threadId, + }); + try { + await copyToClipboard(threadId); + toast.success(t.clipboard.copiedToClipboard); + } catch { + toast.error(t.clipboard.failedToCopyToClipboard); + } + }; + return ( <>
{/* TODO: 测试标识 */} - XClaw v3.2.9 + XClaw{" "} + v3.2.9 {" "} + { + void handleCopyThreadId(); + }} + title={threadId ? t.clipboard.copyToClipboard : undefined} + > + id:{threadId ? threadId.slice(0, 5) : "-"} + + {" "} + {threadId && ( + + 打开 + + )}
)}