1- import { Link , useNavigate , useParams } from "@tanstack/react-router" ;
1+ import { useNavigate , useParams } from "@tanstack/react-router" ;
22import { AnimatePresence , motion } from "framer-motion" ;
3- import {
4- ChevronDown ,
5- Eye ,
6- EyeOff ,
7- MessageCircle ,
8- Save ,
9- Search ,
10- User ,
11- Users ,
12- X ,
13- } from "lucide-react" ;
3+ import { Eye , EyeOff , MessageCircle , Save , Search , User , Users , X } from "lucide-react" ;
144import { useState } from "react" ;
155import {
166 usePeer ,
@@ -20,6 +10,7 @@ import {
2010 useSearchPeer ,
2111 useSetPeerCard ,
2212} from "@/api/queries" ;
13+ import { Breadcrumb } from "@/components/layout/Breadcrumb" ;
2314import { Badge } from "@/components/shared/Badge" ;
2415import { ErrorAlert } from "@/components/shared/ErrorAlert" ;
2516import { JsonViewer } from "@/components/shared/JsonViewer" ;
@@ -38,10 +29,12 @@ import {
3829 SectionHeading ,
3930} from "@/components/ui/typography" ;
4031import { useDemo } from "@/hooks/useDemo" ;
32+ import { useMetadata } from "@/hooks/useMetadata" ;
4133import { COLOR } from "@/lib/constants" ;
4234
4335export function PeerDetail ( ) {
4436 const { mask } = useDemo ( ) ;
37+ const { showMetadata } = useMetadata ( ) ;
4538 const { workspaceId, peerId } = useParams ( { strict : false } ) as {
4639 workspaceId : string ;
4740 peerId : string ;
@@ -65,7 +58,6 @@ export function PeerDetail() {
6558
6659 const [ cardDraft , setCardDraft ] = useState < string | null > ( null ) ;
6760 const [ searchQuery , setSearchQuery ] = useState ( "" ) ;
68- const [ metaExpanded , setMetaExpanded ] = useState ( false ) ;
6961
7062 const observeMe = ( peer as { configuration ?: { observe_me ?: boolean } } | undefined )
7163 ?. configuration ?. observe_me ;
@@ -79,27 +71,7 @@ export function PeerDetail() {
7971 return (
8072 < div className = "page-container page-container--xl" >
8173 < motion . div initial = { { opacity : 0 , y : - 8 } } animate = { { opacity : 1 , y : 0 } } >
82- < div className = "flex items-center gap-2 text-xs mb-4" style = { { color : "var(--text-3)" } } >
83- < Link to = "/workspaces" className = "hover:underline" >
84- Workspaces
85- </ Link >
86- < span > /</ span >
87- < Link
88- to = "/workspaces/$workspaceId"
89- params = { { workspaceId } as never }
90- className = "hover:underline font-mono"
91- >
92- { mask ( workspaceId ) }
93- </ Link >
94- < span > /</ span >
95- < Link
96- to = "/workspaces/$workspaceId/peers"
97- params = { { workspaceId } as never }
98- className = "hover:underline"
99- >
100- Peers
101- </ Link >
102- </ div >
74+ < Breadcrumb />
10375
10476 < div className = "flex items-start justify-between gap-4" >
10577 < div >
@@ -377,47 +349,29 @@ export function PeerDetail() {
377349 ) }
378350 </ motion . div >
379351
380- { /* Metadata — collapsible */ }
381- < motion . div
382- initial = { { opacity : 0 , y : 8 } }
383- animate = { { opacity : 1 , y : 0 } }
384- transition = { { delay : 0.25 } }
385- className = "rounded-xl theme-card overflow-hidden"
386- >
387- < button
388- type = "button"
389- onClick = { ( ) => setMetaExpanded ( ( v ) => ! v ) }
390- className = "w-full flex items-center justify-between px-5 py-4"
391- style = { { color : "var(--text-3)" } }
392- >
393- < SectionHeading className = "mb-0" > Metadata</ SectionHeading >
352+ { /* Metadata — global toggle */ }
353+ < AnimatePresence >
354+ { showMetadata && (
394355 < motion . div
395- animate = { { rotate : metaExpanded ? 0 : - 90 } }
396- transition = { { duration : 0.15 } }
356+ initial = { { opacity : 0 , height : 0 } }
357+ animate = { { opacity : 1 , height : "auto" } }
358+ exit = { { opacity : 0 , height : 0 } }
359+ transition = { { duration : 0.2 } }
360+ className = "overflow-hidden"
397361 >
398- < ChevronDown
399- className = "w-4 h-4"
400- strokeWidth = { 2 }
401- style = { { color : COLOR . dimText } }
402- />
403- </ motion . div >
404- </ button >
405- < AnimatePresence initial = { false } >
406- { metaExpanded && (
407- < motion . div
408- initial = { { height : 0 , opacity : 0 } }
409- animate = { { height : "auto" , opacity : 1 } }
410- exit = { { height : 0 , opacity : 0 } }
411- transition = { { duration : 0.2 } }
412- className = "overflow-hidden"
362+ < div
363+ className = "rounded-xl p-5"
364+ style = { {
365+ background : "rgba(245,158,11,0.04)" ,
366+ border : "1px solid rgba(245,158,11,0.2)" ,
367+ } }
413368 >
414- < div className = "px-5 pb-5" >
415- < JsonViewer data = { peer . metadata } maxHeight = "300px" />
416- </ div >
417- </ motion . div >
418- ) }
419- </ AnimatePresence >
420- </ motion . div >
369+ < SectionHeading style = { { color : COLOR . warning } } > Metadata</ SectionHeading >
370+ < JsonViewer data = { peer . metadata } maxHeight = "300px" />
371+ </ div >
372+ </ motion . div >
373+ ) }
374+ </ AnimatePresence >
421375 </ >
422376 ) }
423377 </ div >
0 commit comments