@wrongstack/webui 0.291.2 → 0.292.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AnalyticsDashboard-BBbdycai.js → AnalyticsDashboard-DausPJOP.js} +1 -1
- package/dist/assets/AudienceMemoryPanel-di7dxMBb.js +3 -0
- package/dist/assets/{ChangesView-Bwb4Qh4n.js → ChangesView-DPfs8VeV.js} +1 -1
- package/dist/assets/{ChronicleDashboard-oOlGTsm5.js → ChronicleDashboard-CMkQ7EBt.js} +1 -1
- package/dist/assets/CodeEditor-iYG6Q0ag.js +1 -0
- package/dist/assets/CodeMap-T1dsXVRH.js +1 -0
- package/dist/assets/{ConfirmModal-B9lFAAUO.js → ConfirmModal-Bm9f2Pg9.js} +1 -1
- package/dist/assets/CronJobsPanel-CKQw0vat.js +1 -0
- package/dist/assets/{DebugDashboard-CCe1PP60.js → DebugDashboard-BeDOPYmE.js} +1 -1
- package/dist/assets/DesignGalleryView-DY3atfBB.js +1 -0
- package/dist/assets/{GoalView-Ck6Oa8nh.js → GoalView-Dh27cG1z.js} +1 -1
- package/dist/assets/KanbanView-DYa0iSlV.js +2 -0
- package/dist/assets/{LazyMarkdown-CGMv69IJ.js → LazyMarkdown-C1a0wbAZ.js} +3 -3
- package/dist/assets/{MailboxDetailView-Dr3B9nM0.js → MailboxDetailView-DQpxIh_A.js} +1 -1
- package/dist/assets/MemoryManager-D1_0SW_m.js +1 -0
- package/dist/assets/{ModelPicker-DwoHlu_Q.js → ModelPicker-Cwa4UKNc.js} +1 -1
- package/dist/assets/OfficeMapPanel-DTQPdV7a.js +4 -0
- package/dist/assets/ProcessMonitor-DjO7eNsN.js +1 -0
- package/dist/assets/QueuePanel-lUChp6xi.js +1 -0
- package/dist/assets/RefreshDebugView-BNa6ehdH.js +1 -0
- package/dist/assets/SddHub-BW7ExYNe.js +2 -0
- package/dist/assets/{SessionsDashboard-yrSEaUdc.js → SessionsDashboard-Cf_67b9g.js} +1 -1
- package/dist/assets/SetupScreen-fu9Qr5Qj.js +1 -0
- package/dist/assets/SkillDetailView-DHcDX_1A.js +3 -0
- package/dist/assets/SpecsView-CNqNOKqo.js +1 -0
- package/dist/assets/{TechStackView-DPxBWfsU.js → TechStackView-CXE80hAc.js} +1 -1
- package/dist/assets/{TerminalPanel-B-BSGITg.js → TerminalPanel-KysALyRz.js} +1 -1
- package/dist/assets/{Toaster-CPO2WS96.js → Toaster-B1idXZ-O.js} +1 -1
- package/dist/assets/{activity-DX6l7wqU.js → activity-AfUMXtSI.js} +1 -1
- package/dist/assets/{activity-CCA6JsEh.js → activity-Bd_pRifE.js} +1 -1
- package/dist/assets/{activity-C8JKxa7u.js → activity-Ct_QOdtL.js} +1 -1
- package/dist/assets/{activity-B8Lz00d-.js → activity-Cyx4UukM.js} +1 -1
- package/dist/assets/{activity-BcdEzklN.js → activity-Dyikq8Zm.js} +1 -1
- package/dist/assets/{activity-CqPvl4kb.js → activity-Ukyu3lON.js} +1 -1
- package/dist/assets/{activity-5G605qiF.js → activity-gaWDc806.js} +1 -1
- package/dist/assets/{button-FFFZxxoZ.js → button-99L74zdE.js} +1 -1
- package/dist/assets/chat-store-Cunk1nDr.js +13 -0
- package/dist/assets/{codemap-activity-store-CfY_WBuV.js → codemap-activity-store-BIW6YPvC.js} +1 -1
- package/dist/assets/{dialog-DWvX4WNX.js → dialog-CNwwBFw3.js} +1 -1
- package/dist/assets/{i18n-VQ8IAWEk.js → i18n-DaR2GB_4.js} +2 -2
- package/dist/assets/index-BLAy5CKD.js +119 -0
- package/dist/assets/index-BlCmdyyZ.css +1 -0
- package/dist/assets/{input-BpQGvMAi.js → input-DXjUO_X9.js} +1 -1
- package/dist/assets/{mailbox-store-CibW8-D6.js → mailbox-store-Dq1wxCRt.js} +1 -1
- package/dist/assets/{pagination-D2oCHj95.js → pagination-Ktuov5iD.js} +1 -1
- package/dist/assets/{session-store-BZ4TsTBa.js → session-store-B8icONBU.js} +1 -1
- package/dist/assets/{shared-DykO0hB0.js → shared-aSCYBzAV.js} +1 -1
- package/dist/assets/stores-JSLvWOQY.js +6 -0
- package/dist/assets/ui-store-BepZz9CZ.js +1 -0
- package/dist/assets/useWebSocket-CRYUFxmO.js +27 -0
- package/dist/assets/{utils-Ca0_D_-X.js → utils-C4qVQ63O.js} +1 -1
- package/dist/assets/{vendor-BsMARlcy.js → vendor-Di1mdAi5.js} +27 -27
- package/dist/assets/{view-navigation-Dx54K1uS.js → view-navigation-BbHlzAQz.js} +1 -1
- package/dist/assets/{ws-client-BOKgdABR.js → ws-client-BWO_PH_X.js} +1 -1
- package/dist/components/AgentsMonitor.d.ts.map +1 -1
- package/dist/components/ChatInput.d.ts.map +1 -1
- package/dist/components/ContextBar.d.ts +14 -4
- package/dist/components/ContextBar.d.ts.map +1 -1
- package/dist/components/ContextDashboard.d.ts.map +1 -1
- package/dist/components/ContextMemoryMonitor.d.ts +2 -0
- package/dist/components/ContextMemoryMonitor.d.ts.map +1 -0
- package/dist/components/CronJobsPanel.d.ts.map +1 -1
- package/dist/components/DesignGalleryView.d.ts.map +1 -1
- package/dist/components/FleetMonitor.d.ts +0 -6
- package/dist/components/FleetMonitor.d.ts.map +1 -1
- package/dist/components/FleetPanel.d.ts.map +1 -1
- package/dist/components/GoalPanel.d.ts.map +1 -1
- package/dist/components/InspectorPanel.d.ts.map +1 -1
- package/dist/components/MemoryManager/MemoryDetail.d.ts +5 -2
- package/dist/components/MemoryManager/MemoryDetail.d.ts.map +1 -1
- package/dist/components/MemoryManager/MemoryGraph.d.ts +5 -2
- package/dist/components/MemoryManager/MemoryGraph.d.ts.map +1 -1
- package/dist/components/MemoryManager/MemoryInjectorTrace.d.ts +3 -0
- package/dist/components/MemoryManager/MemoryInjectorTrace.d.ts.map +1 -0
- package/dist/components/MemoryManager/MemoryLifecycleTrace.d.ts +2 -0
- package/dist/components/MemoryManager/MemoryLifecycleTrace.d.ts.map +1 -0
- package/dist/components/MemoryManager/index.d.ts.map +1 -1
- package/dist/components/MessageBubble/ToolLedgerCard.d.ts +13 -0
- package/dist/components/MessageBubble/ToolLedgerCard.d.ts.map +1 -0
- package/dist/components/MessageBubble/index.d.ts.map +1 -1
- package/dist/components/MessageBubble/utils.d.ts +8 -0
- package/dist/components/MessageBubble/utils.d.ts.map +1 -1
- package/dist/components/PlanPanel.d.ts.map +1 -1
- package/dist/components/ProcessMonitor.d.ts.map +1 -1
- package/dist/components/PromptLibraryModal.d.ts.map +1 -1
- package/dist/components/ProviderWaitingRoom.d.ts.map +1 -1
- package/dist/components/QueuePanel.d.ts.map +1 -1
- package/dist/components/RefreshDebugView.d.ts.map +1 -1
- package/dist/components/SddBoardView.d.ts.map +1 -1
- package/dist/components/SddTaskDrawer.d.ts.map +1 -1
- package/dist/components/SettingsPanel/ProviderSection.d.ts.map +1 -1
- package/dist/components/SettingsPanel/ToolsSection.d.ts.map +1 -1
- package/dist/components/SidePanel/AgentsPanel.d.ts.map +1 -1
- package/dist/components/SidePanel/ChangesPanel.d.ts.map +1 -1
- package/dist/components/SidePanel/index.d.ts.map +1 -1
- package/dist/components/SpecsView.d.ts.map +1 -1
- package/dist/components/TasksPanel.d.ts.map +1 -1
- package/dist/components/TechStackView/index.d.ts.map +1 -1
- package/dist/components/TodosPanel.d.ts.map +1 -1
- package/dist/components/WorktreeLanes.d.ts.map +1 -1
- package/dist/components/WorktreeOrphans.d.ts.map +1 -1
- package/dist/components/activity-bar/index.d.ts.map +1 -1
- package/dist/components/agents/AgentDetailSection.d.ts +17 -0
- package/dist/components/agents/AgentDetailSection.d.ts.map +1 -0
- package/dist/components/agents/AgentRosterCard.d.ts +28 -0
- package/dist/components/agents/AgentRosterCard.d.ts.map +1 -0
- package/dist/components/agents/FleetSummaryBar.d.ts +19 -0
- package/dist/components/agents/FleetSummaryBar.d.ts.map +1 -0
- package/dist/components/ui/fleet-agent-row.d.ts +24 -0
- package/dist/components/ui/fleet-agent-row.d.ts.map +1 -0
- package/dist/hooks/useFleetPolling.d.ts +35 -0
- package/dist/hooks/useFleetPolling.d.ts.map +1 -0
- package/dist/hooks/useWebSocket.d.ts +4 -0
- package/dist/hooks/useWebSocket.d.ts.map +1 -1
- package/dist/hooks/ws-handlers/chat-handlers.d.ts.map +1 -1
- package/dist/hooks/ws-handlers/misc-handlers.d.ts.map +1 -1
- package/dist/hooks/ws-handlers/session-handlers.d.ts.map +1 -1
- package/dist/index.css +99 -0
- package/dist/index.css.map +3 -3
- package/dist/index.html +23 -23
- package/dist/index.js +11129 -9610
- package/dist/index.js.map +4 -4
- package/dist/lib/agent-status.d.ts +61 -0
- package/dist/lib/agent-status.d.ts.map +1 -1
- package/dist/lib/ws-client.d.ts +4 -0
- package/dist/lib/ws-client.d.ts.map +1 -1
- package/dist/stores/chat-store.d.ts +21 -0
- package/dist/stores/chat-store.d.ts.map +1 -1
- package/dist/stores/fleet-store.d.ts +32 -0
- package/dist/stores/fleet-store.d.ts.map +1 -1
- package/dist/stores/index.d.ts +2 -1
- package/dist/stores/index.d.ts.map +1 -1
- package/dist/stores/memory-injector-store.d.ts +79 -0
- package/dist/stores/memory-injector-store.d.ts.map +1 -0
- package/dist/stores/memory-lifecycle-store.d.ts +23 -0
- package/dist/stores/memory-lifecycle-store.d.ts.map +1 -0
- package/dist/stores/ui-store.d.ts +3 -0
- package/dist/stores/ui-store.d.ts.map +1 -1
- package/dist/types.d.ts +27 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +6 -6
- package/dist/assets/AudienceMemoryPanel-BWcCpuCv.js +0 -3
- package/dist/assets/CodeEditor-Bt9fqzjU.js +0 -1
- package/dist/assets/CodeMap-BhJyDUAh.js +0 -1
- package/dist/assets/CronJobsPanel-i2-zcKIC.js +0 -1
- package/dist/assets/DesignGalleryView-BDxyVUoW.js +0 -1
- package/dist/assets/KanbanView-BSoNz6a-.js +0 -2
- package/dist/assets/MemoryManager-BQZeiYDi.js +0 -1
- package/dist/assets/OfficeMapPanel-CA-BmADR.js +0 -4
- package/dist/assets/ProcessMonitor-7mzC-JTl.js +0 -1
- package/dist/assets/QueuePanel-DNccWIKx.js +0 -1
- package/dist/assets/RefreshDebugView-2Ockf4po.js +0 -1
- package/dist/assets/SddHub-Cg63TJIL.js +0 -2
- package/dist/assets/SetupScreen-BFfYTt1L.js +0 -1
- package/dist/assets/SkillDetailView-Sqe-T3-x.js +0 -3
- package/dist/assets/SpecsView-DFj6_8G5.js +0 -1
- package/dist/assets/chat-store-BvxTrNjV.js +0 -13
- package/dist/assets/index-CuByAUEC.css +0 -1
- package/dist/assets/index-D_QeLLAg.js +0 -119
- package/dist/assets/stores-BazbaxhT.js +0 -6
- package/dist/assets/ui-store-D_s-_3Y6.js +0 -1
- package/dist/assets/useWebSocket-BEkBQAAR.js +0 -27
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{An as t,Bn as n,Ji as r,Ti as i,Tt as a,Xr as o,Zi as s,bt as c,na as l,pt as u,qr as d,tt as f,xt as p}from"./vendor-BsMARlcy.js";import"./i18n-VQ8IAWEk.js";import{t as m}from"./ws-client-BOKgdABR.js";import{C as h}from"./stores-BazbaxhT.js";import{t as g}from"./pagination-D2oCHj95.js";import{S as _,g as v}from"./index-D_QeLLAg.js";var y=e(l(),1),b=f();function x(e){let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m ${t%60}s`;let r=Math.floor(n/60);return r<24?`${r}h ${n%60}m`:`${Math.floor(r/24)}d`}function S(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function C(e){return e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function w(e){return new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function T(e){return e.includes(`error`)||e.includes(`fail`)?`text-destructive`:e.includes(`warn`)?`text-warning`:e.includes(`success`)||e.includes(`complete`)?`text-success`:`text-muted-foreground`}function E({icon:e,label:t,value:n,sub:r,color:i=`text-muted-foreground`}){return(0,b.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsx)(`div`,{className:`mt-0.5 ${i}`,children:e}),(0,b.jsxs)(`div`,{className:`min-w-0`,children:[(0,b.jsx)(`div`,{className:`text-2xl font-semibold tabular-nums text-foreground`,children:n}),(0,b.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:t}),r?(0,b.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground/70`,children:r}):null]})]})}function D(){let{t:e}=s(),[l,f]=(0,y.useState)(null),[D,O]=(0,y.useState)([]),[k,A]=(0,y.useState)([]),[j,M]=(0,y.useState)(null),[N,P]=(0,y.useState)(!0),[F,I]=(0,y.useState)(!1),L=(0,y.useRef)(null),R=(0,y.useCallback)(async()=>{try{let e=await fetch(`/api/analytics/summary`);if(e.ok){let t=await e.json();f(t)}}catch{}},[]),z=(0,y.useCallback)(async()=>{try{let e=await fetch(`/api/analytics?limit=50`);if(e.ok){let t=await e.json();O(t.events)}}catch{}},[]),B=(0,y.useCallback)(async()=>{try{let e=await fetch(`/api/sessions`);if(e.ok){let t=await e.json();A(t)}}catch{}},[]),V=(0,y.useCallback)(async()=>{if(!F){I(!0);try{let e=m(h.getState().wsUrl);L.current=e;let t=e.on(`stats.get`,e=>{let n=e.payload;M(n),I(!1),t()});e.getStats({echoToChat:!1}),setTimeout(()=>{I(!1),t()},8e3)}catch{I(!1)}}},[F]);(0,y.useEffect)(()=>{let e=()=>{Promise.all([R(),z(),B(),V()]).finally(()=>P(!1))};e();let t=setInterval(e,1e4);return()=>clearInterval(t)},[R,z,B,V]);let{totalAgents:H,activeAgents:U,totalToolCalls:W,totalIterations:G}=(0,y.useMemo)(()=>{let e=0,t=0,n=0,r=0;for(let i of k)for(let a of i.agents)e++,a.status===`running`&&t++,n+=a.toolCalls,r+=a.iterations;return{totalAgents:e,activeAgents:t,totalToolCalls:n,totalIterations:r}},[k]),K=(0,y.useMemo)(()=>l?Object.entries(l.categoryBreakdown).sort((e,t)=>t[1]-e[1]).slice(0,8):[],[l]),q=(0,y.useMemo)(()=>l?Object.entries(l.eventBreakdown).sort((e,t)=>t[1]-e[1]).slice(0,10):[],[l]),J=(0,y.useMemo)(()=>{if(!l)return 0;let e=0;for(let[t,n]of Object.entries(l.eventBreakdown))t.toLowerCase().includes(`error`)&&(e+=n);return e},[l]),Y=(0,y.useMemo)(()=>{if(!l)return 0;let e=0;for(let[t,n]of Object.entries(l.eventBreakdown))t.toLowerCase().includes(`warn`)&&(e+=n);return e},[l]),X=_((0,y.useMemo)(()=>[...D].reverse(),[D]),20);return N?(0,b.jsx)(`div`,{className:`flex h-full min-h-0 items-center justify-center bg-[hsl(var(--surface-2)/0.45)] p-4`,children:(0,b.jsxs)(`div`,{className:`ws-surface flex items-center gap-2 rounded-xl px-4 py-3 text-sm text-muted-foreground`,children:[(0,b.jsx)(n,{className:`h-4 w-4 animate-spin text-primary`}),e(`activity:analytics.loading`)]})}):(0,b.jsx)(`div`,{ref:v(`analytics`),className:`h-full min-h-0 min-w-0 overflow-y-auto overscroll-contain bg-[hsl(var(--surface-2)/0.45)] p-4 sm:p-6`,children:(0,b.jsxs)(`div`,{className:`mx-auto flex w-full max-w-7xl flex-col gap-5`,children:[(0,b.jsx)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:(0,b.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,b.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,b.jsx)(i,{className:`h-4 w-4 text-primary`}),(0,b.jsx)(`h1`,{className:`truncate text-base font-semibold`,children:e(`activity:analytics.heading`)})]}),(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`activity:analytics.autoRefresh`)})]})}),(0,b.jsxs)(`div`,{className:`min-w-0 space-y-5`,children:[(0,b.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3`,children:[(0,b.jsx)(E,{icon:(0,b.jsx)(r,{className:`h-4 w-4`}),label:e(`activity:analytics.liveSessions`),value:k.length,color:`text-primary`}),(0,b.jsx)(E,{icon:(0,b.jsx)(u,{className:`h-4 w-4`}),label:e(`activity:analytics.agents`),value:`${U}/${H}`,sub:U>0?e(`activity:analytics.agentsActive`,{count:U}):void 0,color:`text-success`}),(0,b.jsx)(E,{icon:(0,b.jsx)(t,{className:`h-4 w-4`}),label:e(`activity:analytics.totalEvents`),value:l?.totalEvents??0,sub:e(`activity:analytics.categoriesSub`,{count:l?.uniqueCategories??0}),color:`text-warning`}),(0,b.jsx)(E,{icon:(0,b.jsx)(a,{className:`h-4 w-4`}),label:e(`activity:analytics.toolCalls`),value:W,sub:e(`activity:analytics.iterationsSub`,{count:G}),color:`text-success`}),(0,b.jsx)(E,{icon:(0,b.jsx)(d,{className:`h-4 w-4`}),label:e(`activity:analytics.sessionCost`),value:j?C(j.cost):`—`,sub:j?e(`activity:analytics.tokensSub`,{input:S(j.usage.input),output:S(j.usage.output)}):void 0,color:`text-primary`}),(0,b.jsx)(E,{icon:(0,b.jsx)(o,{className:`h-4 w-4`}),label:e(`activity:analytics.sessionDuration`),value:j?x(j.elapsedMs):`—`,sub:j?e(`activity:analytics.messagesSub`,{count:j.messages}):void 0,color:`text-muted-foreground`})]}),(0,b.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,b.jsx)(p,{className:`h-3.5 w-3.5 text-primary`}),e(`activity:analytics.eventsByCategory`)]}),K.length===0?(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`activity:analytics.noEvents`)}):(0,b.jsx)(`div`,{className:`space-y-1.5`,children:K.map(([e,t])=>{let n=K[0]?.[1]??1,r=Math.round(t/n*100);return(0,b.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,7rem)_minmax(0,1fr)_2.5rem] items-center gap-2 text-xs`,children:[(0,b.jsx)(`span`,{className:`min-w-0 truncate text-foreground`,children:e}),(0,b.jsx)(`div`,{className:`h-4 overflow-hidden rounded-full bg-muted`,children:(0,b.jsx)(`div`,{className:`h-full rounded-full bg-primary/70 transition-all`,style:{width:`${Math.max(r,4)}%`}})}),(0,b.jsx)(`span`,{className:`text-right tabular-nums text-muted-foreground`,children:t})]},e)})})]}),(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,b.jsx)(i,{className:`h-3.5 w-3.5 text-warning`}),e(`activity:analytics.topEvents`)]}),q.length===0?(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`activity:analytics.noEvents`)}):(0,b.jsx)(`div`,{className:`space-y-1.5`,children:q.map(([e,t])=>{let n=q[0]?.[1]??1,r=Math.round(t/n*100);return(0,b.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,9rem)_minmax(0,1fr)_2.5rem] items-center gap-2 text-xs`,children:[(0,b.jsx)(`span`,{className:`min-w-0 truncate ${T(e)}`,children:e}),(0,b.jsx)(`div`,{className:`h-4 overflow-hidden rounded-full bg-muted`,children:(0,b.jsx)(`div`,{className:`h-full rounded-full bg-warning/70 transition-all`,style:{width:`${Math.max(r,4)}%`}})}),(0,b.jsx)(`span`,{className:`text-right tabular-nums text-muted-foreground`,children:t})]},e)})})]})]}),(0,b.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,b.jsx)(d,{className:`h-3.5 w-3.5 text-primary`}),e(`activity:analytics.activeSessionUsage`)]}),j?(0,b.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 text-xs`,children:[(0,b.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.provider`)}),(0,b.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-foreground`,children:j.provider})]}),(0,b.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.model`)}),(0,b.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-foreground`,children:j.model})]}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.inputTokens`)}),(0,b.jsx)(`p`,{className:`mt-0.5 tabular-nums text-foreground`,children:S(j.usage.input)})]}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.outputTokens`)}),(0,b.jsx)(`p`,{className:`mt-0.5 tabular-nums text-foreground`,children:S(j.usage.output)})]}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.cacheRatio`)}),(0,b.jsxs)(`p`,{className:`mt-0.5 tabular-nums text-foreground`,children:[(j.cache.ratio*100).toFixed(1),`%`]})]}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.filesRead`)}),(0,b.jsx)(`p`,{className:`mt-0.5 tabular-nums text-foreground`,children:j.readFiles})]})]}):(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`activity:analytics.noSession`)})]}),(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,b.jsx)(c,{className:`h-3.5 w-3.5 text-warning`}),e(`activity:analytics.healthErrors`)]}),(0,b.jsx)(`div`,{className:`space-y-2 text-xs`,children:l?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`flex justify-between`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.errorEvents`)}),(0,b.jsx)(`span`,{className:`tabular-nums text-destructive`,children:J})]}),(0,b.jsxs)(`div`,{className:`flex justify-between`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.warningEvents`)}),(0,b.jsx)(`span`,{className:`tabular-nums text-warning`,children:Y})]}),(0,b.jsxs)(`div`,{className:`flex justify-between`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.cacheHitRate`)}),(0,b.jsx)(`span`,{className:`tabular-nums text-success`,children:j?`${(j.cache.ratio*100).toFixed(1)}%`:`—`})]}),(0,b.jsxs)(`div`,{className:`flex justify-between`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.totalCategories`)}),(0,b.jsx)(`span`,{className:`tabular-nums text-foreground`,children:l.uniqueCategories})]})]}):(0,b.jsx)(`p`,{className:`text-muted-foreground`,children:e(`activity:analytics.waitingData`)})})]})]}),(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,b.jsx)(r,{className:`h-3.5 w-3.5 text-primary`}),e(`activity:analytics.recentEvents`)]}),D.length===0?(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`activity:analytics.noRecentEvents`)}):(0,b.jsx)(`div`,{className:`max-h-64 space-y-1 overflow-y-auto`,children:X.pageItems.map((e,t)=>(0,b.jsxs)(`div`,{className:`grid grid-cols-[4rem_minmax(0,7rem)_minmax(0,6rem)_minmax(0,1fr)] items-start gap-2 rounded px-2 py-1 text-xs hover:bg-muted/60`,children:[(0,b.jsx)(`span`,{className:`tabular-nums text-muted-foreground/70`,children:w(e.timestamp)}),(0,b.jsx)(`span`,{className:`min-w-0 truncate ${T(e.event)}`,children:e.event}),(0,b.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground`,children:e.category}),(0,b.jsx)(`span`,{className:`min-w-0 truncate text-foreground/80`,children:e.label??e.sessionId??``})]},`${e.timestamp}-${t}`))}),(0,b.jsx)(g,{page:X.page,pageSize:X.pageSize,totalItems:X.totalItems,onPageChange:X.setPage,compact:!0,itemLabel:`events`,className:`mt-3 rounded-lg border`})]})]})]})})}export{D as AnalyticsDashboard};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{An as t,Bn as n,Ei as r,Jr as i,Tt as a,Zi as o,Zr as s,aa as c,bt as l,ea as u,pt as d,tt as f,xt as p}from"./vendor-Di1mdAi5.js";import"./i18n-DaR2GB_4.js";import{t as m}from"./ws-client-BWO_PH_X.js";import{j as h}from"./stores-JSLvWOQY.js";import{t as g}from"./pagination-Ktuov5iD.js";import{S as _,g as v}from"./index-BLAy5CKD.js";var y=e(c(),1),b=f();function x(e){let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m ${t%60}s`;let r=Math.floor(n/60);return r<24?`${r}h ${n%60}m`:`${Math.floor(r/24)}d`}function S(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function C(e){return e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function w(e){return new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function T(e){return e.includes(`error`)||e.includes(`fail`)?`text-destructive`:e.includes(`warn`)?`text-warning`:e.includes(`success`)||e.includes(`complete`)?`text-success`:`text-muted-foreground`}function E({icon:e,label:t,value:n,sub:r,color:i=`text-muted-foreground`}){return(0,b.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsx)(`div`,{className:`mt-0.5 ${i}`,children:e}),(0,b.jsxs)(`div`,{className:`min-w-0`,children:[(0,b.jsx)(`div`,{className:`text-2xl font-semibold tabular-nums text-foreground`,children:n}),(0,b.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:t}),r?(0,b.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground/70`,children:r}):null]})]})}function D(){let{t:e}=u(),[c,f]=(0,y.useState)(null),[D,O]=(0,y.useState)([]),[k,A]=(0,y.useState)([]),[j,M]=(0,y.useState)(null),[N,P]=(0,y.useState)(!0),[F,I]=(0,y.useState)(!1),L=(0,y.useRef)(null),R=(0,y.useCallback)(async()=>{try{let e=await fetch(`/api/analytics/summary`);if(e.ok){let t=await e.json();f(t)}}catch{}},[]),z=(0,y.useCallback)(async()=>{try{let e=await fetch(`/api/analytics?limit=50`);if(e.ok){let t=await e.json();O(t.events)}}catch{}},[]),B=(0,y.useCallback)(async()=>{try{let e=await fetch(`/api/sessions`);if(e.ok){let t=await e.json();A(t)}}catch{}},[]),V=(0,y.useCallback)(async()=>{if(!F){I(!0);try{let e=m(h.getState().wsUrl);L.current=e;let t=e.on(`stats.get`,e=>{let n=e.payload;M(n),I(!1),t()});e.getStats({echoToChat:!1}),setTimeout(()=>{I(!1),t()},8e3)}catch{I(!1)}}},[F]);(0,y.useEffect)(()=>{let e=()=>{Promise.all([R(),z(),B(),V()]).finally(()=>P(!1))};e();let t=setInterval(e,1e4);return()=>clearInterval(t)},[R,z,B,V]);let{totalAgents:H,activeAgents:U,totalToolCalls:W,totalIterations:G}=(0,y.useMemo)(()=>{let e=0,t=0,n=0,r=0;for(let i of k)for(let a of i.agents)e++,a.status===`running`&&t++,n+=a.toolCalls,r+=a.iterations;return{totalAgents:e,activeAgents:t,totalToolCalls:n,totalIterations:r}},[k]),K=(0,y.useMemo)(()=>c?Object.entries(c.categoryBreakdown).sort((e,t)=>t[1]-e[1]).slice(0,8):[],[c]),q=(0,y.useMemo)(()=>c?Object.entries(c.eventBreakdown).sort((e,t)=>t[1]-e[1]).slice(0,10):[],[c]),J=(0,y.useMemo)(()=>{if(!c)return 0;let e=0;for(let[t,n]of Object.entries(c.eventBreakdown))t.toLowerCase().includes(`error`)&&(e+=n);return e},[c]),Y=(0,y.useMemo)(()=>{if(!c)return 0;let e=0;for(let[t,n]of Object.entries(c.eventBreakdown))t.toLowerCase().includes(`warn`)&&(e+=n);return e},[c]),X=_((0,y.useMemo)(()=>[...D].reverse(),[D]),20);return N?(0,b.jsx)(`div`,{className:`flex h-full min-h-0 items-center justify-center bg-[hsl(var(--surface-2)/0.45)] p-4`,children:(0,b.jsxs)(`div`,{className:`ws-surface flex items-center gap-2 rounded-xl px-4 py-3 text-sm text-muted-foreground`,children:[(0,b.jsx)(n,{className:`h-4 w-4 animate-spin text-primary`}),e(`activity:analytics.loading`)]})}):(0,b.jsx)(`div`,{ref:v(`analytics`),className:`h-full min-h-0 min-w-0 overflow-y-auto overscroll-contain bg-[hsl(var(--surface-2)/0.45)] p-4 sm:p-6`,children:(0,b.jsxs)(`div`,{className:`mx-auto flex w-full max-w-7xl flex-col gap-5`,children:[(0,b.jsx)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:(0,b.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,b.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,b.jsx)(r,{className:`h-4 w-4 text-primary`}),(0,b.jsx)(`h1`,{className:`truncate text-base font-semibold`,children:e(`activity:analytics.heading`)})]}),(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`activity:analytics.autoRefresh`)})]})}),(0,b.jsxs)(`div`,{className:`min-w-0 space-y-5`,children:[(0,b.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3`,children:[(0,b.jsx)(E,{icon:(0,b.jsx)(o,{className:`h-4 w-4`}),label:e(`activity:analytics.liveSessions`),value:k.length,color:`text-primary`}),(0,b.jsx)(E,{icon:(0,b.jsx)(d,{className:`h-4 w-4`}),label:e(`activity:analytics.agents`),value:`${U}/${H}`,sub:U>0?e(`activity:analytics.agentsActive`,{count:U}):void 0,color:`text-success`}),(0,b.jsx)(E,{icon:(0,b.jsx)(t,{className:`h-4 w-4`}),label:e(`activity:analytics.totalEvents`),value:c?.totalEvents??0,sub:e(`activity:analytics.categoriesSub`,{count:c?.uniqueCategories??0}),color:`text-warning`}),(0,b.jsx)(E,{icon:(0,b.jsx)(a,{className:`h-4 w-4`}),label:e(`activity:analytics.toolCalls`),value:W,sub:e(`activity:analytics.iterationsSub`,{count:G}),color:`text-success`}),(0,b.jsx)(E,{icon:(0,b.jsx)(i,{className:`h-4 w-4`}),label:e(`activity:analytics.sessionCost`),value:j?C(j.cost):`—`,sub:j?e(`activity:analytics.tokensSub`,{input:S(j.usage.input),output:S(j.usage.output)}):void 0,color:`text-primary`}),(0,b.jsx)(E,{icon:(0,b.jsx)(s,{className:`h-4 w-4`}),label:e(`activity:analytics.sessionDuration`),value:j?x(j.elapsedMs):`—`,sub:j?e(`activity:analytics.messagesSub`,{count:j.messages}):void 0,color:`text-muted-foreground`})]}),(0,b.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,b.jsx)(p,{className:`h-3.5 w-3.5 text-primary`}),e(`activity:analytics.eventsByCategory`)]}),K.length===0?(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`activity:analytics.noEvents`)}):(0,b.jsx)(`div`,{className:`space-y-1.5`,children:K.map(([e,t])=>{let n=K[0]?.[1]??1,r=Math.round(t/n*100);return(0,b.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,7rem)_minmax(0,1fr)_2.5rem] items-center gap-2 text-xs`,children:[(0,b.jsx)(`span`,{className:`min-w-0 truncate text-foreground`,children:e}),(0,b.jsx)(`div`,{className:`h-4 overflow-hidden rounded-full bg-muted`,children:(0,b.jsx)(`div`,{className:`h-full rounded-full bg-primary/70 transition-all`,style:{width:`${Math.max(r,4)}%`}})}),(0,b.jsx)(`span`,{className:`text-right tabular-nums text-muted-foreground`,children:t})]},e)})})]}),(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,b.jsx)(r,{className:`h-3.5 w-3.5 text-warning`}),e(`activity:analytics.topEvents`)]}),q.length===0?(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`activity:analytics.noEvents`)}):(0,b.jsx)(`div`,{className:`space-y-1.5`,children:q.map(([e,t])=>{let n=q[0]?.[1]??1,r=Math.round(t/n*100);return(0,b.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,9rem)_minmax(0,1fr)_2.5rem] items-center gap-2 text-xs`,children:[(0,b.jsx)(`span`,{className:`min-w-0 truncate ${T(e)}`,children:e}),(0,b.jsx)(`div`,{className:`h-4 overflow-hidden rounded-full bg-muted`,children:(0,b.jsx)(`div`,{className:`h-full rounded-full bg-warning/70 transition-all`,style:{width:`${Math.max(r,4)}%`}})}),(0,b.jsx)(`span`,{className:`text-right tabular-nums text-muted-foreground`,children:t})]},e)})})]})]}),(0,b.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,b.jsx)(i,{className:`h-3.5 w-3.5 text-primary`}),e(`activity:analytics.activeSessionUsage`)]}),j?(0,b.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 text-xs`,children:[(0,b.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.provider`)}),(0,b.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-foreground`,children:j.provider})]}),(0,b.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.model`)}),(0,b.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-foreground`,children:j.model})]}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.inputTokens`)}),(0,b.jsx)(`p`,{className:`mt-0.5 tabular-nums text-foreground`,children:S(j.usage.input)})]}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.outputTokens`)}),(0,b.jsx)(`p`,{className:`mt-0.5 tabular-nums text-foreground`,children:S(j.usage.output)})]}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.cacheRatio`)}),(0,b.jsxs)(`p`,{className:`mt-0.5 tabular-nums text-foreground`,children:[(j.cache.ratio*100).toFixed(1),`%`]})]}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.filesRead`)}),(0,b.jsx)(`p`,{className:`mt-0.5 tabular-nums text-foreground`,children:j.readFiles})]})]}):(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`activity:analytics.noSession`)})]}),(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,b.jsx)(l,{className:`h-3.5 w-3.5 text-warning`}),e(`activity:analytics.healthErrors`)]}),(0,b.jsx)(`div`,{className:`space-y-2 text-xs`,children:c?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`flex justify-between`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.errorEvents`)}),(0,b.jsx)(`span`,{className:`tabular-nums text-destructive`,children:J})]}),(0,b.jsxs)(`div`,{className:`flex justify-between`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.warningEvents`)}),(0,b.jsx)(`span`,{className:`tabular-nums text-warning`,children:Y})]}),(0,b.jsxs)(`div`,{className:`flex justify-between`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.cacheHitRate`)}),(0,b.jsx)(`span`,{className:`tabular-nums text-success`,children:j?`${(j.cache.ratio*100).toFixed(1)}%`:`—`})]}),(0,b.jsxs)(`div`,{className:`flex justify-between`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.totalCategories`)}),(0,b.jsx)(`span`,{className:`tabular-nums text-foreground`,children:c.uniqueCategories})]})]}):(0,b.jsx)(`p`,{className:`text-muted-foreground`,children:e(`activity:analytics.waitingData`)})})]})]}),(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,b.jsx)(o,{className:`h-3.5 w-3.5 text-primary`}),e(`activity:analytics.recentEvents`)]}),D.length===0?(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`activity:analytics.noRecentEvents`)}):(0,b.jsx)(`div`,{className:`max-h-64 space-y-1 overflow-y-auto`,children:X.pageItems.map((e,t)=>(0,b.jsxs)(`div`,{className:`grid grid-cols-[4rem_minmax(0,7rem)_minmax(0,6rem)_minmax(0,1fr)] items-start gap-2 rounded px-2 py-1 text-xs hover:bg-muted/60`,children:[(0,b.jsx)(`span`,{className:`tabular-nums text-muted-foreground/70`,children:w(e.timestamp)}),(0,b.jsx)(`span`,{className:`min-w-0 truncate ${T(e.event)}`,children:e.event}),(0,b.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground`,children:e.category}),(0,b.jsx)(`span`,{className:`min-w-0 truncate text-foreground/80`,children:e.label??e.sessionId??``})]},`${e.timestamp}-${t}`))}),(0,b.jsx)(g,{page:X.page,pageSize:X.pageSize,totalItems:X.totalItems,onPageChange:X.setPage,compact:!0,itemLabel:`events`,className:`mt-3 rounded-lg border`})]})]})]})})}export{D as AnalyticsDashboard};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ct as t,Dt as n,aa as r,cn as i,gr as a,ot as o,qr as s,qt as c,rn as l,tt as u,vt as d,zt as f}from"./vendor-Di1mdAi5.js";import{t as p}from"./useWebSocket-CRYUFxmO.js";import{t as m}from"./utils-C4qVQ63O.js";import{a as h,i as g,n as _,o as v,r as y,t as b}from"./dialog-CNwwBFw3.js";import{t as x}from"./button-99L74zdE.js";import{t as S}from"./pagination-Ktuov5iD.js";import{t as C}from"./input-DXjUO_X9.js";import{S as w}from"./index-BLAy5CKD.js";import{g as T,i as E,r as D,y as O}from"./shared-aSCYBzAV.js";var k=e(r(),1),A=u();function j(e){if(!Array.isArray(e))return;let t=[...new Set(e.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(Boolean))];return t.length>0?t:void 0}function M(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e,n={roles:j(t.roles),taskTypes:j(t.taskTypes),modes:j(t.modes)};return n.roles||n.taskTypes||n.modes?n:void 0}function ee(e){let t=e.trim().replace(/^```(?:json)?\s*/i,``).replace(/\s*```$/,``),n=JSON.parse(t);if(!Array.isArray(n))throw Error(`Input must be a JSON array.`);let r=[],i=0;for(let e of n){if(!e||typeof e!=`object`||Array.isArray(e)){i++;continue}let t=e,n=typeof t.text==`string`?t.text.trim():``,a=M(t.audience);if(!n||!a){i++;continue}let o=typeof t.kind==`string`&&E.some(e=>e===t.kind)?t.kind:void 0,s=j(t.tags);r.push({text:n,audience:a,kind:o,tags:s,importance:typeof t.importance==`number`?t.importance:void 0,confidence:typeof t.confidence==`number`?t.confidence:void 0})}return{entries:r,skipped:i}}function N(e,t){if(!t)return!0;let n=e.audience;return[e.text,e.kind,e.status,...n?.roles??[],...n?.taskTypes??[],...n?.modes??[]].join(` `).toLocaleLowerCase().includes(t.toLocaleLowerCase())}function P(e,t){return[...new Set(e.flatMap(e=>e.audience?.[t]??[]).filter(e=>e.length>0))].sort((e,t)=>e.localeCompare(t))}function F(){let e=p(),[r,u]=(0,k.useState)([]),[f,E]=(0,k.useState)(!0),[D,O]=(0,k.useState)(null),[j,M]=(0,k.useState)(``),[F,R]=(0,k.useState)(!1),[B,V]=(0,k.useState)(!1),[H,U]=(0,k.useState)(null),[W,G]=(0,k.useState)(!1),[K,q]=(0,k.useState)(!1),J=(0,k.useRef)(null),Y=(0,k.useCallback)(()=>{E(!0),O(null),e.listSuperMemories({echoToChat:!1})},[e.listSuperMemories]);(0,k.useEffect)(()=>{let t=e.client,n=t.on(`memory.super.list`,e=>{let t=e.payload;t.error?O({tone:`error`,text:t.error}):u(t.memories??[]),E(!1)}),r=t.on(`memory.super.remember`,e=>{let t=e.payload;if(G(!1),t.error){O({tone:`error`,text:t.error});return}t.memory&&(u(e=>[t.memory,...e.filter(e=>e.id!==t.memory.id)]),R(!1))}),i=t.on(`memory.super.update`,e=>{let t=e.payload;t.error?O({tone:`error`,text:t.error}):t.memory&&(u(e=>e.map(e=>e.id===t.memory.id?t.memory:e)),t.memory.audience||O({tone:`success`,text:`Audience scope removed. The memory is now general.`}))}),a=t.on(`memory.super.delete`,e=>{let t=e.payload,n=J.current;t.success&&n?(u(e=>e.filter(e=>e.id!==n)),O({tone:`success`,text:`Audience memory deleted.`}),U(null),q(!1),J.current=null):t.success?Y():(O({tone:`error`,text:t.message??`Could not delete the memory.`}),q(!1),J.current=null)});return Y(),()=>{n(),r(),i(),a()}},[Y,e.client]);let X=(0,k.useMemo)(()=>r.filter(e=>{let t=e.audience;return!!(t&&(t.roles?.length||t.taskTypes?.length||t.modes?.length))}),[r]),Z=j.trim(),Q=(0,k.useMemo)(()=>X.filter(e=>N(e,Z)),[Z,X]),$=w(Q,16,Z),ie=(0,k.useMemo)(()=>P(X,`roles`),[X]),ae=(0,k.useMemo)(()=>P(X,`taskTypes`),[X]),oe=(0,k.useMemo)(()=>P(X,`modes`),[X]),se=t=>{O(null),e.updateSuperMemory(t,{audience:void 0},{echoToChat:!1})},ce=()=>{H&&(J.current=H,q(!0),O(null),e.deleteSuperMemory(H,`Removed from the audience memory panel.`))},le=async()=>{let e=X.map(e=>({id:e.id,text:e.text,kind:e.kind,status:e.status,audience:e.audience,tags:e.tags,importance:e.importance,confidence:e.confidence}));try{if(!navigator.clipboard)throw Error(`Clipboard access is unavailable.`);await navigator.clipboard.writeText(JSON.stringify(e,null,2)),O({tone:`success`,text:`${e.length} audience memor${e.length===1?`y`:`ies`} copied as JSON.`})}catch(e){O({tone:`error`,text:e instanceof Error?e.message:`Failed to copy JSON to the clipboard.`})}};return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col bg-card/20`,"aria-labelledby":`audience-memory-title`,children:[(0,A.jsxs)(`div`,{className:`shrink-0 border-b border-border/60 p-3`,children:[(0,A.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,A.jsx)(`div`,{className:`min-w-0`,children:(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-md border border-primary/20 bg-primary/10 text-primary`,children:(0,A.jsx)(n,{className:`size-3.5`})}),(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`h2`,{id:`audience-memory-title`,className:`truncate text-sm font-semibold`,children:`Audience Memory`}),(0,A.jsx)(`p`,{className:`truncate text-[10px] text-muted-foreground`,children:`Guidance routed to matching agents`})]})]})}),(0,A.jsxs)(x,{variant:`default`,size:`sm`,className:`h-7 shrink-0 gap-1 px-2 text-xs`,onClick:()=>R(!0),children:[(0,A.jsx)(i,{className:`size-3`}),`Add`]})]}),(0,A.jsxs)(`div`,{className:`mt-3 grid grid-cols-4 gap-px overflow-hidden rounded-md border border-border/60 bg-border/60`,children:[(0,A.jsx)(I,{value:X.length,label:`Memories`}),(0,A.jsx)(I,{value:ie.length,label:`Roles`}),(0,A.jsx)(I,{value:ae.length,label:`Tasks`}),(0,A.jsx)(I,{value:oe.length,label:`Modes`})]}),(0,A.jsxs)(`div`,{className:`mt-3 flex items-center gap-1.5`,children:[(0,A.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,A.jsx)(c,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,A.jsx)(C,{value:j,onChange:e=>M(e.target.value),placeholder:`Search text, role, task or mode…`,"aria-label":`Search audience memories`,className:`h-8 pl-8 pr-8 text-xs`}),j&&(0,A.jsx)(`button`,{type:`button`,className:`absolute right-2 top-1/2 -translate-y-1/2 rounded-sm p-0.5 text-muted-foreground hover:text-foreground`,onClick:()=>M(``),"aria-label":`Clear audience memory search`,children:(0,A.jsx)(o,{className:`size-3`})})]}),(0,A.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-8 shrink-0`,onClick:Y,"aria-label":`Refresh audience memories`,title:`Refresh`,children:(0,A.jsx)(l,{className:m(`size-3.5`,f&&`animate-spin`)})}),(0,A.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-8 shrink-0`,onClick:()=>V(!0),"aria-label":`Import audience memories`,title:`Import JSON`,children:(0,A.jsx)(d,{className:`size-3.5`})}),(0,A.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-8 shrink-0`,onClick:()=>void le(),"aria-label":`Copy audience memories as JSON`,title:`Copy JSON`,disabled:X.length===0,children:(0,A.jsx)(s,{className:`size-3.5`})})]})]}),D&&(0,A.jsxs)(`div`,{role:D.tone===`error`?`alert`:`status`,className:m(`mx-3 mt-3 flex shrink-0 items-start justify-between gap-2 rounded-md border px-2.5 py-2 text-[11px]`,D.tone===`error`?`border-destructive/30 bg-destructive/5 text-destructive`:`border-success/30 bg-success/5 text-success`),children:[(0,A.jsx)(`span`,{children:D.text}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>O(null),className:`shrink-0 rounded-sm opacity-70 hover:opacity-100`,"aria-label":`Dismiss message`,children:(0,A.jsx)(o,{className:`size-3`})})]}),(0,A.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[!f&&X.length>0&&(0,A.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between px-3 pb-1.5 pt-3 text-[10px] text-muted-foreground`,children:[(0,A.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,A.jsx)(a,{className:`size-3`}),Z?`${Q.length} of ${X.length}`:`${X.length} scoped`]}),Z&&(0,A.jsx)(`button`,{type:`button`,className:`hover:text-foreground`,onClick:()=>M(``),children:`Clear filter`})]}),(0,A.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3`,children:[f?(0,A.jsx)(z,{}):X.length===0?(0,A.jsx)(te,{onAdd:()=>R(!0)}):Q.length===0?(0,A.jsxs)(`div`,{className:`flex h-full min-h-32 flex-col items-center justify-center px-4 text-center`,children:[(0,A.jsx)(c,{className:`mb-2 size-5 text-muted-foreground/60`}),(0,A.jsx)(`p`,{className:`text-xs font-medium`,children:`No matching memories`}),(0,A.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:`Try another role, task, mode, or phrase.`}),(0,A.jsx)(x,{variant:`ghost`,size:`sm`,className:`mt-2 h-7 text-xs`,onClick:()=>M(``),children:`Clear search`})]}):(0,A.jsx)(`ul`,{className:`space-y-2`,children:$.pageItems.map(e=>(0,A.jsx)(L,{memory:e,onFilter:M,onClearScope:()=>se(e.id),onDelete:()=>U(e.id)},e.id))}),(0,A.jsx)(S,{page:$.page,pageSize:$.pageSize,totalItems:$.totalItems,onPageChange:$.setPage,compact:!0,itemLabel:`memories`})]})]})]}),(0,A.jsx)(ne,{open:F,busy:W,onOpenChange:e=>{W||R(e)},onCreate:t=>{O(null),G(!0),e.rememberSuperMemory({text:t.text,kind:t.kind,audience:{roles:t.roles.length>0?t.roles:void 0,taskTypes:t.taskTypes.length>0?t.taskTypes:void 0,modes:t.modes.length>0?t.modes:void 0}},{echoToChat:!1})}}),(0,A.jsx)(re,{open:B,onOpenChange:V,onImport:t=>{try{let{entries:n,skipped:r}=ee(t);if(n.length===0)return O({tone:`error`,text:`No valid audience-scoped memories were found in the JSON.`}),!1;for(let t of n)e.rememberSuperMemory(t,{echoToChat:!1});return O({tone:`success`,text:`${n.length} memor${n.length===1?`y`:`ies`} queued for import${r?`; ${r} invalid ${r===1?`entry was`:`entries were`} skipped`:``}.`}),V(!1),!0}catch(e){return O({tone:`error`,text:e instanceof Error?e.message:`Invalid JSON.`}),!1}}}),(0,A.jsx)(b,{open:!!H,onOpenChange:e=>{!e&&!K&&U(null)},children:(0,A.jsxs)(_,{className:`max-w-md`,children:[(0,A.jsxs)(h,{children:[(0,A.jsx)(v,{children:`Delete this audience memory?`}),(0,A.jsx)(y,{children:`This removes the memory from active use. To keep it as general project guidance, cancel and use the un-scope action instead.`})]}),(0,A.jsx)(`div`,{className:`rounded-md border border-border/70 bg-background/45 p-3 text-xs text-muted-foreground`,children:T(r.find(e=>e.id===H)?.text??``,180)}),(0,A.jsxs)(g,{children:[(0,A.jsx)(x,{variant:`outline`,onClick:()=>U(null),disabled:K,children:`Cancel`}),(0,A.jsxs)(x,{variant:`destructive`,onClick:ce,disabled:K,children:[(0,A.jsx)(t,{className:`size-4`}),K?`Deleting…`:`Delete memory`]})]})]})})]})}function I({value:e,label:t}){return(0,A.jsxs)(`div`,{className:`bg-card/95 px-1.5 py-2 text-center`,children:[(0,A.jsx)(`p`,{className:`text-sm font-semibold tabular-nums`,children:e}),(0,A.jsx)(`p`,{className:`truncate text-[9px] uppercase tracking-wide text-muted-foreground`,children:t})]})}function L({memory:e,onFilter:n,onClearScope:r,onDelete:i}){return(0,A.jsxs)(`li`,{className:`group rounded-md border border-border/65 bg-card/55 p-2.5 transition-colors hover:border-border hover:bg-card/85`,children:[(0,A.jsx)(`p`,{className:`break-words text-xs leading-5`,children:e.text}),e.audience&&(0,A.jsx)(R,{audience:e.audience,onFilter:n}),(0,A.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2 border-t border-border/45 pt-2`,children:[(0,A.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-[9px] uppercase tracking-wide text-muted-foreground`,children:[(0,A.jsx)(`span`,{className:`truncate`,children:D[e.kind]??e.kind}),(0,A.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,A.jsx)(`span`,{children:e.status})]}),(0,A.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[(0,A.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-6`,onClick:r,"aria-label":`Remove audience scope from ${T(e.text,42)}`,title:`Make general memory`,children:(0,A.jsx)(f,{className:`size-3`})}),(0,A.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-6 text-destructive hover:text-destructive`,onClick:i,"aria-label":`Delete ${T(e.text,42)}`,title:`Delete`,children:(0,A.jsx)(t,{className:`size-3`})})]})]})]})}function R({audience:e,onFilter:t}){return(0,A.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[...(e.roles??[]).map(e=>({label:`role`,value:e})),...(e.taskTypes??[]).map(e=>({label:`task`,value:e})),...(e.modes??[]).map(e=>({label:`mode`,value:e}))].map(({label:e,value:n})=>(0,A.jsxs)(`button`,{type:`button`,className:`max-w-full truncate rounded border border-primary/15 bg-primary/7 px-1.5 py-0.5 font-mono text-[9px] text-primary/90 transition-colors hover:border-primary/35 hover:bg-primary/12`,onClick:()=>t(n),title:`Filter by ${e}: ${n}`,children:[e,`:`,n]},`${e}:${n}`))})}function z(){return(0,A.jsx)(`div`,{className:`space-y-2 pt-3`,role:`status`,"aria-label":`Loading audience memories`,children:[0,1,2].map(e=>(0,A.jsxs)(`div`,{className:`animate-pulse rounded-md border border-border/50 p-3`,children:[(0,A.jsx)(`div`,{className:`h-2.5 w-full rounded bg-muted`}),(0,A.jsx)(`div`,{className:`mt-2 h-2.5 w-2/3 rounded bg-muted`}),(0,A.jsx)(`div`,{className:`mt-3 h-4 w-24 rounded bg-muted`})]},e))})}function te({onAdd:e}){return(0,A.jsxs)(`div`,{className:`flex h-full min-h-44 flex-col items-center justify-center px-5 text-center`,children:[(0,A.jsx)(`span`,{className:`mb-3 flex size-10 items-center justify-center rounded-full border border-dashed border-primary/35 bg-primary/5 text-primary`,children:(0,A.jsx)(n,{className:`size-4`})}),(0,A.jsx)(`p`,{className:`text-xs font-medium`,children:`Route guidance to the right agents`}),(0,A.jsx)(`p`,{className:`mt-1 max-w-52 text-[10px] leading-4 text-muted-foreground`,children:`Scope a memory by role, task type, or operating mode. Matching agents receive it automatically.`}),(0,A.jsxs)(x,{variant:`outline`,size:`sm`,className:`mt-3 h-7 gap-1 text-xs`,onClick:e,children:[(0,A.jsx)(i,{className:`size-3`}),`Add scoped memory`]})]})}function ne({open:e,busy:t,onOpenChange:n,onCreate:r}){let[i,a]=(0,k.useState)(``),[o,s]=(0,k.useState)(`workflow`),[c,l]=(0,k.useState)(``),[u,d]=(0,k.useState)(``),[f,p]=(0,k.useState)(``);(0,k.useEffect)(()=>{e||(a(``),s(`workflow`),l(``),d(``),p(``))},[e]);let m=O(c),S=O(u),C=O(f),w=i.trim().length>0&&(m.length>0||S.length>0||C.length>0);return(0,A.jsx)(b,{open:e,onOpenChange:n,children:(0,A.jsxs)(_,{className:`max-w-xl`,children:[(0,A.jsxs)(h,{children:[(0,A.jsx)(v,{children:`Add audience-scoped memory`}),(0,A.jsx)(y,{children:`This guidance is injected only when an agent matches at least one supplied selector.`})]}),(0,A.jsxs)(`div`,{className:`space-y-4`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{htmlFor:`audience-memory-text`,className:`mb-1.5 block text-xs font-medium`,children:`Memory`}),(0,A.jsx)(`textarea`,{id:`audience-memory-text`,value:i,onChange:e=>a(e.target.value),placeholder:`What should matching agents remember?`,rows:4,autoFocus:!0,className:`w-full resize-y rounded-md border border-input bg-background px-3 py-2 text-sm outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring`})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{htmlFor:`audience-memory-kind`,className:`mb-1.5 block text-xs font-medium`,children:`Kind`}),(0,A.jsx)(`select`,{id:`audience-memory-kind`,value:o,onChange:e=>s(e.target.value),className:`h-9 w-full rounded-md border border-input bg-background px-3 text-xs outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:E.map(e=>(0,A.jsx)(`option`,{value:e,children:D[e]??e},e))})]}),(0,A.jsxs)(`fieldset`,{className:`space-y-3 rounded-md border border-border/70 bg-background/35 p-3`,children:[(0,A.jsx)(`legend`,{className:`px-1 text-xs font-medium`,children:`Audience selectors`}),(0,A.jsx)(B,{id:`audience-memory-roles`,label:`Roles`,value:c,onChange:l,placeholder:`reviewer, refactor-planner`}),(0,A.jsx)(B,{id:`audience-memory-task-types`,label:`Task types`,value:u,onChange:d,placeholder:`review, refactor, bugfix`}),(0,A.jsx)(B,{id:`audience-memory-modes`,label:`Modes`,value:f,onChange:p,placeholder:`teach, code-review`}),(0,A.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Comma-separate multiple values. At least one selector is required.`})]})]}),(0,A.jsxs)(g,{children:[(0,A.jsx)(x,{variant:`outline`,onClick:()=>n(!1),disabled:t,children:`Cancel`}),(0,A.jsx)(x,{onClick:()=>r({text:i.trim(),kind:o,roles:m,taskTypes:S,modes:C}),disabled:!w||t,children:t?`Remembering…`:`Remember`})]})]})})}function B({id:e,label:t,value:n,placeholder:r,onChange:i}){return(0,A.jsxs)(`div`,{className:`grid gap-1.5 sm:grid-cols-[6rem_1fr] sm:items-center`,children:[(0,A.jsx)(`label`,{htmlFor:e,className:`text-[11px] font-medium text-muted-foreground`,children:t}),(0,A.jsx)(C,{id:e,value:n,onChange:e=>i(e.target.value),placeholder:r,className:`h-8 font-mono text-xs`})]})}function re({open:e,onOpenChange:t,onImport:n}){let[r,i]=(0,k.useState)(``);return(0,k.useEffect)(()=>{e||i(``)},[e]),(0,A.jsx)(b,{open:e,onOpenChange:t,children:(0,A.jsxs)(_,{className:`max-w-xl`,children:[(0,A.jsxs)(h,{children:[(0,A.jsx)(v,{children:`Import audience memories`}),(0,A.jsxs)(y,{children:[`Paste the JSON produced here or by `,(0,A.jsx)(`code`,{children:`/memory audience export`}),`. Entries without a valid audience selector are skipped.`]})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{htmlFor:`audience-memory-import`,className:`mb-1.5 block text-xs font-medium`,children:`JSON array`}),(0,A.jsx)(`textarea`,{id:`audience-memory-import`,value:r,onChange:e=>i(e.target.value),placeholder:`[
|
|
2
|
+
{ "text": "…", "audience": { "roles": ["reviewer"] } }
|
|
3
|
+
]`,rows:10,autoFocus:!0,spellCheck:!1,className:`w-full resize-y rounded-md border border-input bg-background p-3 font-mono text-xs outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring`})]}),(0,A.jsxs)(g,{children:[(0,A.jsx)(x,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,A.jsxs)(x,{onClick:()=>n(r),disabled:!r.trim(),children:[(0,A.jsx)(d,{className:`size-4`}),`Import memories`]})]})]})})}export{F as AudienceMemoryPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Bn as t,
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Bn as t,Fr as n,Xt as r,Yt as i,aa as a,b as o,ea as s,ni as c,rn as l,tt as u,wi as d}from"./vendor-Di1mdAi5.js";import"./i18n-DaR2GB_4.js";import{a as f,n as p,t as m}from"./monaco-C7izDJhg.js";import{t as h}from"./ws-client-BWO_PH_X.js";import{t as g}from"./utils-C4qVQ63O.js";import{h as _,j as v}from"./stores-JSLvWOQY.js";import{v as y}from"./index-BLAy5CKD.js";import{t as b}from"./monaco-theme-BoNOJHQB.js";var x=e(a(),1),S=u();p.config({monaco:m});var C={ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,mjs:`javascript`,json:`json`,css:`css`,scss:`scss`,html:`html`,md:`markdown`,py:`python`,go:`go`,rs:`rust`,java:`java`,c:`c`,cpp:`cpp`,cs:`csharp`,rb:`ruby`,php:`php`,sh:`shell`,bash:`shell`,yml:`yaml`,yaml:`yaml`,toml:`toml`,sql:`sql`};function w(e){return C[e.split(`.`).pop()?.toLowerCase()??``]??`plaintext`}function T({path:e,oldText:n,newText:r}){let{t:a}=s(),c=(0,x.useRef)(null),[l,u]=(0,x.useState)(!1),[p,m]=(0,x.useState)(!1),[g,_]=(0,x.useState)(null);(0,x.useEffect)(()=>{u(!1),m(!1),_(null)},[]);let y=(0,x.useCallback)(e=>{c.current=e,f.setTheme(b()),e.getModifiedEditor().onDidChangeModelContent(()=>u(!0))},[]),C=(0,x.useCallback)(()=>{let t=c.current?.getModifiedEditor().getValue();if(t==null)return;m(!0);let n=h(v.getState().wsUrl),r=n.on(`files.written`,t=>{t.type===`files.written`&&t.payload.filePath===e&&(r(),clearTimeout(i),m(!1),t.payload.success&&(u(!1),_(Date.now())))}),i=setTimeout(()=>{r(),m(!1)},5e3);n.send({type:`files.write`,payload:{filePath:e,content:t}})},[e]),T=w(e);return(0,S.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,S.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2 px-2 py-1.5 border-b border-border/40`,children:[(0,S.jsx)(`span`,{className:`text-xs font-mono text-muted-foreground truncate`,children:e}),(0,S.jsxs)(`button`,{type:`button`,onClick:C,disabled:!l||p,className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-md border border-border text-xs font-medium disabled:opacity-40 enabled:hover:bg-muted transition-colors`,title:a(`activity:monacoDiff.applyTitle`),children:[p?(0,S.jsx)(t,{className:`h-3.5 w-3.5 animate-spin`}):g&&!l?(0,S.jsx)(d,{className:`h-3.5 w-3.5 text-success`}):(0,S.jsx)(i,{className:`h-3.5 w-3.5`}),a(p?`activity:monacoDiff.applying`:g&&!l?`activity:monacoDiff.applied`:`activity:monacoDiff.apply`)]})]}),(0,S.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-hidden`,children:(0,S.jsx)(o,{original:n,modified:r,language:T,theme:b(),onMount:y,options:{renderSideBySide:!0,readOnly:!1,originalEditable:!1,minimap:{enabled:!1},fontSize:13,scrollBeyondLastLine:!1,automaticLayout:!0}})})]})}var E=1e4;function D({className:e}){let{t:i}=s(),a=_(e=>e.selectedPath),o=_(e=>e.diff),u=_(e=>e.loadingDiff),[d,f]=(0,x.useState)(`unified`),[p,m]=(0,x.useState)(!1),b=!!a&&(u||!o);(0,x.useEffect)(()=>{if(m(!1),!b)return;let e=setTimeout(()=>m(!0),E);return()=>clearTimeout(e)},[b,a]);let C=()=>{a&&(m(!1),_.getState().setDiffLoading(!0),h(v.getState().wsUrl).getGitDiff?.(a))};if(!a)return(0,S.jsx)(`div`,{className:g(`flex min-h-0 min-w-0 flex-1 items-center justify-center bg-[hsl(var(--surface-2)/0.45)] p-4`,e),children:(0,S.jsxs)(`div`,{className:`ws-surface flex max-w-md flex-col items-center gap-3 rounded-xl p-6 text-center text-muted-foreground`,children:[(0,S.jsx)(`span`,{className:`flex h-12 w-12 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,S.jsx)(n,{className:`h-6 w-6`})}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h2`,{className:`text-base font-semibold text-foreground`,children:`Source changes`}),(0,S.jsx)(`p`,{className:`mt-1 text-sm`,children:i(`activity:changes.selectPrompt`)})]})]})});let w=o&&!o.error&&!o.binary&&!o.tooLarge;return(0,S.jsx)(`div`,{className:g(`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-[hsl(var(--surface-2)/0.45)] p-3`,e),children:(0,S.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-border/70 bg-card/75 shadow-sm`,children:[(0,S.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2 border-b border-border/70 px-3 py-2`,children:[(0,S.jsxs)(`div`,{className:`min-w-0`,children:[(0,S.jsx)(`div`,{className:`text-[10px] font-semibold uppercase text-muted-foreground`,children:`Source control`}),(0,S.jsx)(`div`,{className:`truncate font-mono text-xs text-foreground`,title:a,children:a})]}),w&&(0,S.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,S.jsxs)(`button`,{type:`button`,onClick:()=>f(`unified`),title:i(`activity:changes.unifiedTitle`),className:g(`inline-flex h-8 items-center gap-1 rounded-md border px-2 text-xs transition-colors`,d===`unified`?`border-primary/40 bg-primary/10 text-primary`:`border-border text-muted-foreground hover:bg-muted`),children:[(0,S.jsx)(r,{className:`h-3.5 w-3.5`}),` `,i(`activity:changes.unified`)]}),(0,S.jsxs)(`button`,{type:`button`,onClick:()=>f(`edit`),title:i(`activity:changes.editTitle`),className:g(`inline-flex h-8 items-center gap-1 rounded-md border px-2 text-xs transition-colors`,d===`edit`?`border-primary/40 bg-primary/10 text-primary`:`border-border text-muted-foreground hover:bg-muted`),children:[(0,S.jsx)(c,{className:`h-3.5 w-3.5`}),` `,i(`activity:changes.edit`)]})]})]}),(0,S.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:u||!o?p?(0,S.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center gap-3 p-4 text-center`,children:[(0,S.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i(`activity:changes.diffTimeout`)}),(0,S.jsxs)(`button`,{type:`button`,onClick:C,className:`inline-flex h-8 items-center gap-1.5 rounded-md border border-border px-3 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:[(0,S.jsx)(l,{className:`h-3.5 w-3.5`}),` `,i(`common:action.retry`)]})]}):(0,S.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,S.jsx)(t,{className:`h-4 w-4 animate-spin`}),` `,i(`activity:changes.loadingDiff`)]}):o.error?(0,S.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-sm text-destructive`,children:o.error}):o.binary?(0,S.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-sm text-muted-foreground`,children:i(`activity:changes.binary`)}):o.tooLarge?(0,S.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-sm text-muted-foreground`,children:i(`activity:changes.tooLarge`)}):d===`edit`?(0,S.jsx)(T,{path:o.path,oldText:o.oldText??``,newText:o.newText??``},o.path):(0,S.jsx)(y,{oldText:o.oldText,newText:o.newText,caption:o.path,fill:!0})})]})})}export{D as ChangesView};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{$t as t,Bt as n,Ji as r,Jr as i,Lr as a,Mi as o,Nt as s,bi as c,bt as l,fr as u,hr as d,ii as f,ki as p,na as m,ot as h,qt as ee,rn as g,tt as _}from"./vendor-BsMARlcy.js";import{t as v}from"./ws-client-BOKgdABR.js";import{t as y}from"./utils-Ca0_D_-X.js";import{t as b}from"./pagination-D2oCHj95.js";import{S as x}from"./index-D_QeLLAg.js";var S=e(m(),1),C=_(),w=[`eventType`,`providerId`,`modelId`,`outcome`,`resourceKind`],te=[{id:`all`,label:`All signals`,icon:(0,C.jsx)(r,{})},{id:`llm`,label:`LLM`,icon:(0,C.jsx)(p,{})},{id:`agents`,label:`Agents`,icon:(0,C.jsx)(o,{})},{id:`tools`,label:`Tools`,icon:(0,C.jsx)(s,{})},{id:`files`,label:`Files`,icon:(0,C.jsx)(a,{})},{id:`failures`,label:`Failures`,icon:(0,C.jsx)(l,{})}];function T(){let e=v(),[n,r]=(0,S.useState)([]),[i,c]=(0,S.useState)(null),[l,u]=(0,S.useState)({}),[m,_]=(0,S.useState)({limit:300,order:`desc`}),[T,E]=(0,S.useState)({text:``,path:``,providerId:``,modelId:``,sessionId:``}),[j,R]=(0,S.useState)(`all`),[B,V]=(0,S.useState)({total:0,scannedEvents:0,sourceFiles:0,invalidLines:0}),[H,U]=(0,S.useState)(D),[W,G]=(0,S.useState)(!0),[K,q]=(0,S.useState)(null),[ne,J]=(0,S.useState)(null),Y=(0,S.useCallback)(t=>{if(!e.supportsCapability(`chronicle.query`)){G(!1),q(`Restart the backend once to activate Chronicle protocol support.`);return}G(!0),q(null),_(t),e.send({type:`chronicle.query`,payload:{query:t}});for(let n of w)e.send({type:`chronicle.facet`,payload:{field:n,query:t,limit:12}})},[e]);(0,S.useEffect)(()=>{let t=e.on(`chronicle.query_result`,e=>{e.type===`chronicle.query_result`&&(r(e.payload.events),V(e.payload),U(e.payload.summary??D),G(!1))}),n=e.on(`chronicle.facet_result`,e=>{e.type===`chronicle.facet_result`&&u(t=>({...t,[e.payload.field]:e.payload.values}))}),i=e.on(`chronicle.error`,e=>{e.type===`chronicle.error`&&(q(e.payload.message),G(!1))}),a=e.on(`chronicle.graph_result`,e=>{e.type===`chronicle.graph_result`&&J(e.payload)});return Y({limit:300,order:`desc`}),()=>{t(),n(),i(),a()}},[e,Y]);let X=(0,S.useMemo)(()=>n.filter(e=>A(e,j)),[n,j]),Z=x(X,25,j),Q=(0,S.useMemo)(()=>n.find(e=>e.eventType===`runtime.health.sampled`)?.attributes,[n]),$=()=>Y({limit:300,order:`desc`,...T.text?{text:T.text}:{},...T.path?{path:T.path}:{},...T.providerId?{providerId:T.providerId}:{},...T.modelId?{modelId:T.modelId}:{},...T.sessionId?{sessionId:T.sessionId}:{}}),re=()=>{E({text:``,path:``,providerId:``,modelId:``,sessionId:``}),R(`all`),Y({limit:300,order:`desc`})},ie=t=>{c(t),J(null),e.supportsCapability(`chronicle.graph`)&&e.send({type:`chronicle.graph`,payload:{seed:{eventId:t.eventId},hops:2,maxNodes:250}})};return(0,C.jsxs)(`div`,{className:`flex h-full min-h-0 bg-background`,"data-testid":`chronicle-dashboard`,children:[(0,C.jsxs)(`main`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,C.jsx)(`header`,{className:`border-b border-border/70 bg-gradient-to-r from-primary/[0.045] via-background to-background px-5 py-4`,children:(0,C.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(p,{className:`h-5 w-5 text-primary`}),(0,C.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight`,children:`Coding Intelligence`}),(0,C.jsx)(`span`,{className:`rounded-full border border-primary/20 bg-primary/10 px-2 py-0.5 text-[9px] font-semibold tracking-wider text-primary`,children:`CHRONICLE`})]}),(0,C.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`LLM, agent, tool and file evidence — connected from decision to code change.`})]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(`span`,{className:y(`h-2 w-2 rounded-full`,K?`bg-destructive`:W?`animate-pulse bg-warning`:`bg-success`)}),(0,C.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:W?`Reading journal`:K?`Unavailable`:`Live evidence`}),(0,C.jsx)(`button`,{onClick:()=>Y(m),className:`ml-2 rounded-md border border-border bg-card p-2 hover:bg-muted`,title:`Refresh evidence`,children:(0,C.jsx)(g,{className:y(`h-4 w-4`,W&&`animate-spin`)})})]})]})}),(0,C.jsxs)(`section`,{className:`grid grid-cols-2 border-b border-border/70 xl:grid-cols-6`,children:[(0,C.jsx)(P,{icon:(0,C.jsx)(p,{}),label:`LLM requests`,value:H.logicalRequests,detail:`${H.modelAttempts} attempts · ${H.providers} providers · ${H.models} models`}),(0,C.jsx)(P,{icon:(0,C.jsx)(o,{}),label:`Agent work`,value:H.agentEvents,detail:`${H.uniqueAgents} correlated agents · ${H.decisions} decisions`}),(0,C.jsx)(P,{icon:(0,C.jsx)(s,{}),label:`Tool calls`,value:H.toolCalls,detail:`${H.failedTools} failed · ${H.processes} processes`}),(0,C.jsx)(P,{icon:(0,C.jsx)(a,{}),label:`File evidence`,value:H.fileEvents,detail:`${H.uniqueFiles} unique paths`}),(0,C.jsx)(P,{icon:(0,C.jsx)(t,{}),label:`Retries`,value:H.scheduledRetries,detail:`${H.failures} failures · ${H.fallbacks} fallbacks`,tone:H.failures?`danger`:`normal`}),(0,C.jsx)(P,{icon:(0,C.jsx)(f,{}),label:`Provider p95`,value:M(H.providerP95DurationMs),detail:`${M(H.providerAvgDurationMs)} average · all matches`})]}),(0,C.jsxs)(`section`,{className:`flex flex-wrap gap-x-6 gap-y-1 border-b border-border/60 bg-primary/[0.018] px-4 py-1.5 font-mono text-[9px] text-muted-foreground`,children:[(0,C.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-primary`,children:`Token economics`}),(0,C.jsxs)(`span`,{children:[`fresh input `,(0,C.jsx)(`b`,{className:`text-foreground`,children:H.inputTokens.toLocaleString()})]}),(0,C.jsxs)(`span`,{children:[`output `,(0,C.jsx)(`b`,{className:`text-foreground`,children:H.outputTokens.toLocaleString()})]}),(0,C.jsxs)(`span`,{children:[`cache read `,(0,C.jsx)(`b`,{className:`text-foreground`,children:H.cacheReadTokens.toLocaleString()})]}),(0,C.jsxs)(`span`,{children:[`cache write `,(0,C.jsx)(`b`,{className:`text-foreground`,children:H.cacheWriteTokens.toLocaleString()})]}),(0,C.jsxs)(`span`,{children:[`cache hit `,(0,C.jsxs)(`b`,{className:`text-foreground`,children:[k(H).toFixed(1),`%`]})]}),(0,C.jsxs)(`span`,{children:[`estimated cost `,(0,C.jsxs)(`b`,{className:`text-foreground`,children:[`$`,H.estimatedCostUsd.toFixed(4)]})]})]}),(0,C.jsx)(`section`,{className:`border-b border-border/70 px-4 py-3`,children:(0,C.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 xl:grid-cols-[1.35fr_1fr_1fr_1fr_1fr_auto]`,children:[(0,C.jsx)(N,{icon:(0,C.jsx)(ee,{}),placeholder:`Search event evidence`,value:T.text,onChange:e=>E(t=>({...t,text:e})),onEnter:$}),(0,C.jsx)(N,{placeholder:`File or directory`,value:T.path,onChange:e=>E(t=>({...t,path:e})),onEnter:$}),(0,C.jsx)(N,{placeholder:`Provider`,value:T.providerId,onChange:e=>E(t=>({...t,providerId:e})),onEnter:$}),(0,C.jsx)(N,{placeholder:`Model`,value:T.modelId,onChange:e=>E(t=>({...t,modelId:e})),onEnter:$}),(0,C.jsx)(N,{placeholder:`Session`,value:T.sessionId,onChange:e=>E(t=>({...t,sessionId:e})),onEnter:$}),(0,C.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,C.jsxs)(`button`,{onClick:$,className:`rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground`,children:[(0,C.jsx)(d,{className:`mr-1 inline h-3 w-3`}),`Apply`]}),(0,C.jsx)(`button`,{onClick:re,className:`rounded-md border border-border px-2.5 text-xs hover:bg-muted`,children:`Clear`})]})]})}),(0,C.jsxs)(`section`,{className:`flex items-center gap-1 overflow-x-auto border-b border-border/70 px-4 py-2`,children:[te.map(e=>(0,C.jsxs)(`button`,{onClick:()=>R(e.id),className:y(`flex shrink-0 items-center gap-1.5 rounded-md px-2.5 py-1.5 text-[11px] transition-colors [&>svg]:h-3.5 [&>svg]:w-3.5`,j===e.id?`bg-primary/10 font-medium text-primary`:`text-muted-foreground hover:bg-muted hover:text-foreground`),children:[e.icon,e.label,(0,C.jsx)(`span`,{className:`ml-1 rounded bg-background/70 px-1 font-mono text-[9px]`,children:O(H,e.id,B.total)})]},e.id)),(0,C.jsxs)(`div`,{className:`ml-auto hidden items-center gap-3 pl-4 text-[9px] text-muted-foreground lg:flex`,children:[(0,C.jsxs)(`span`,{children:[B.total.toLocaleString(),` matched`]}),(0,C.jsxs)(`span`,{children:[B.sourceFiles,` journal files`]}),B.invalidLines>0&&(0,C.jsxs)(`span`,{className:`text-warning`,children:[B.invalidLines,` invalid lines`]})]})]}),Q&&(0,C.jsx)(F,{health:Q}),(0,C.jsx)(`section`,{className:`flex gap-4 overflow-x-auto border-b border-border/60 bg-muted/[0.18] px-4 py-2`,children:[`providerId`,`modelId`,`outcome`].map(e=>(0,C.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,C.jsx)(`span`,{className:`mr-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e.replace(`Id`,``)}),(l[e]??[]).slice(0,4).map(t=>(0,C.jsxs)(`button`,{onClick:()=>Y({...m,[e]:t.value}),className:`rounded-full border border-border bg-card px-2 py-0.5 text-[9px] hover:border-primary/50`,children:[t.value,` `,(0,C.jsx)(`b`,{children:t.count})]},t.value))]},e))}),(0,C.jsxs)(`div`,{className:`grid grid-cols-[92px_minmax(190px,1.25fr)_110px_minmax(180px,1fr)_minmax(140px,.8fr)_24px] gap-3 border-b border-border/60 bg-muted/20 px-4 py-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,C.jsx)(`span`,{children:`Time`}),(0,C.jsx)(`span`,{children:`Signal`}),(0,C.jsx)(`span`,{children:`Outcome`}),(0,C.jsx)(`span`,{children:`Model / agent`}),(0,C.jsx)(`span`,{children:`Resource`}),(0,C.jsx)(`span`,{})]}),(0,C.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:K?(0,C.jsx)(z,{text:K}):!W&&X.length===0?(0,C.jsx)(z,{text:`No coding evidence matches these filters.`}):(0,C.jsx)(`div`,{className:`divide-y divide-border/40`,children:Z.pageItems.map(e=>(0,C.jsx)(I,{event:e,active:i?.eventId===e.eventId,onClick:()=>ie(e)},e.eventId))})}),(0,C.jsx)(b,{page:Z.page,pageSize:Z.pageSize,totalItems:Z.totalItems,onPageChange:Z.setPage,itemLabel:`events`})]}),i&&(0,C.jsxs)(`aside`,{className:`w-[440px] max-w-[48vw] shrink-0 overflow-auto border-l border-border bg-card/60 shadow-[-12px_0_32px_hsl(var(--background)/.35)]`,children:[(0,C.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center justify-between border-b border-border bg-card/95 px-4 py-3 backdrop-blur`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-xs font-semibold`,children:`Evidence & lineage`}),(0,C.jsxs)(`div`,{className:`mt-0.5 font-mono text-[9px] text-muted-foreground`,children:[`#`,i.sequence,` · `,i.eventId]})]}),(0,C.jsx)(`button`,{onClick:()=>c(null),className:`rounded p-1 hover:bg-muted`,children:(0,C.jsx)(h,{className:`h-4 w-4`})})]}),(0,C.jsx)(L,{event:i,graph:ne})]})]})}var E={llm:0,agent:0,tool:0,file:0,memory:0,task:0,decision:0,runtime:0},D={logicalRequests:0,modelAttempts:0,completedAttempts:0,failedAttempts:0,scheduledRetries:0,fallbacks:0,providers:0,models:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheWriteTokens:0,estimatedCostUsd:0,providerAvgDurationMs:0,providerP95DurationMs:0,toolCalls:0,completedTools:0,failedTools:0,toolAvgDurationMs:0,processes:0,failedProcesses:0,fileEvents:0,uniqueFiles:0,agentEvents:0,uniqueAgents:0,decisions:0,escalations:0,failures:0,cancellations:0,families:{...E},failuresByFamily:{...E}};function O(e,t,n){return t===`all`?n:t===`llm`?e.families.llm:t===`agents`?e.families.agent:t===`tools`?e.families.tool:t===`files`?e.families.file:e.failures}function k(e){let t=e.inputTokens+e.cacheReadTokens;return t?e.cacheReadTokens/t*100:0}function A(e,t){return t===`all`?!0:t===`llm`?/^(provider|token|context|compaction)\./.test(e.eventType):t===`agents`?/^(agent|subagent|delegate|fleet|sdd)\./.test(e.eventType):t===`tools`?/^(tool|process|mcp|network)\./.test(e.eventType):t===`files`?e.resource?.kind===`file`||/^(file|worktree|storage)\./.test(e.eventType):e.outcome===`failure`||/(?:failed|error|retry|fallback|blocked|conflict)/i.test(e.eventType)}function j(e){if(!e)return`—`;let t=e/1e6;return t<1?`${(e/1e3).toFixed(0)}µs`:t<1e3?`${t.toFixed(1)}ms`:`${(t/1e3).toFixed(1)}s`}function M(e){return e?e<1?`${(e*1e3).toFixed(0)}µs`:e<1e3?`${e.toFixed(1)}ms`:`${(e/1e3).toFixed(1)}s`:`—`}function N({placeholder:e,value:t,onChange:n,onEnter:r,icon:i}){return(0,C.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md border border-border bg-card px-2.5 py-2 focus-within:border-primary/60`,children:[i&&(0,C.jsx)(`span`,{className:`text-muted-foreground [&>svg]:h-3.5 [&>svg]:w-3.5`,children:i}),(0,C.jsx)(`input`,{className:`w-full bg-transparent text-xs outline-none placeholder:text-muted-foreground/70`,placeholder:e,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Enter`&&r()}})]})}function P({icon:e,label:t,value:n,detail:r,tone:i=`normal`}){return(0,C.jsxs)(`div`,{className:`min-w-0 border-r border-border/60 px-4 py-3`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,C.jsx)(`span`,{className:`text-primary [&>svg]:h-3.5 [&>svg]:w-3.5`,children:e}),t]}),(0,C.jsx)(`div`,{className:y(`mt-1 text-xl font-semibold tabular-nums`,i===`danger`&&`text-destructive`),children:typeof n==`number`?n.toLocaleString():n}),(0,C.jsx)(`div`,{className:`mt-0.5 truncate text-[9px] text-muted-foreground`,children:r})]})}function F({health:e}){return(0,C.jsxs)(`section`,{className:`flex flex-wrap gap-x-5 gap-y-1 border-b border-border/60 bg-success/[0.025] px-4 py-1.5 font-mono text-[9px] text-muted-foreground`,children:[(0,C.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-success`,children:`Collector healthy`}),(0,C.jsxs)(`span`,{children:[`ELU `,(0,C.jsxs)(`b`,{className:`text-foreground`,children:[((e.eventLoop?.utilization??0)*100).toFixed(1),`%`]})]}),(0,C.jsxs)(`span`,{children:[`p95 `,(0,C.jsxs)(`b`,{className:`text-foreground`,children:[(e.eventLoop?.delayP95Ms??0).toFixed(1),`ms`]})]}),(0,C.jsxs)(`span`,{children:[`heap `,(0,C.jsxs)(`b`,{className:`text-foreground`,children:[((e.memory?.heapUsedBytes??0)/1048576).toFixed(0),`MB`]})]}),(0,C.jsxs)(`span`,{children:[`queue `,(0,C.jsx)(`b`,{className:`text-foreground`,children:e.chronicle?.pendingEvents??0})]}),(0,C.jsxs)(`span`,{children:[`dropped `,(0,C.jsx)(`b`,{className:y((e.chronicle?.rejectedEvents??0)>0&&`text-destructive`),children:e.chronicle?.rejectedEvents??0})]})]})}function I({event:e,active:t,onClick:n}){let r=e.occurredAt??e.observedAt,i=e.runtime?.modelId??e.scope.agentId??e.runtime?.providerId??`—`,a=e.resource?.path??e.resource?.id??e.correlation.toolCallId??`—`;return(0,C.jsxs)(`button`,{onClick:n,className:y(`grid w-full grid-cols-[92px_minmax(190px,1.25fr)_110px_minmax(180px,1fr)_minmax(140px,.8fr)_24px] items-center gap-3 px-4 py-2.5 text-left hover:bg-muted/45`,t&&`bg-primary/[0.07]`),children:[(0,C.jsx)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:new Date(r).toLocaleTimeString()}),(0,C.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,C.jsx)(`span`,{className:y(`h-1.5 w-1.5 shrink-0 rounded-full`,e.outcome===`failure`?`bg-destructive`:e.outcome===`success`?`bg-success`:`bg-primary`)}),(0,C.jsx)(`span`,{className:`truncate font-mono text-[11px] font-medium`,children:e.eventType})]}),(0,C.jsx)(`span`,{className:y(`w-fit rounded px-1.5 py-0.5 text-[9px]`,B(e.outcome)),children:e.outcome??`unknown`}),(0,C.jsx)(`span`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:i}),(0,C.jsx)(`span`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:a}),(0,C.jsx)(c,{className:`h-3.5 w-3.5 text-muted-foreground`})]})}function L({event:e,graph:t}){let r=(0,S.useMemo)(()=>[[`Scope`,e.scope],[`Correlation`,e.correlation],[`Runtime`,e.runtime],[`Resource`,e.resource],[`Attributes`,e.attributes],[`Tags`,e.tags]],[e]);return(0,C.jsxs)(`div`,{className:`p-4`,children:[(0,C.jsxs)(`div`,{className:`mb-4 rounded-lg border border-border bg-background/60 p-3`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(`span`,{className:y(`h-2 w-2 rounded-full`,e.outcome===`failure`?`bg-destructive`:e.outcome===`success`?`bg-success`:`bg-primary`)}),(0,C.jsx)(`span`,{className:`font-mono text-xs font-semibold`,children:e.eventType})]}),(0,C.jsxs)(`div`,{className:`mt-2 flex gap-4 text-[9px] text-muted-foreground`,children:[(0,C.jsx)(`span`,{children:new Date(e.occurredAt??e.observedAt).toLocaleString()}),(0,C.jsx)(`span`,{children:j(Number(e.durationNs??0))})]})]}),(0,C.jsxs)(`div`,{className:`mb-4 grid grid-cols-2 gap-2`,children:[(0,C.jsx)(R,{icon:(0,C.jsx)(n,{}),label:`Evidence hash`,value:e.hash.slice(0,16)}),(0,C.jsx)(R,{icon:(0,C.jsx)(i,{}),label:`Sequence`,value:String(e.sequence)})]}),t&&(0,C.jsxs)(`section`,{className:`mb-4`,children:[(0,C.jsxs)(`h3`,{className:`mb-1.5 flex items-center gap-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,C.jsx)(u,{className:`h-3 w-3`}),`Lineage · `,t.nodes.length,` nodes · `,t.edges.length,` edges`]}),(0,C.jsx)(`div`,{className:`space-y-1 rounded-md border border-border bg-background/70 p-2`,children:t.edges.slice(0,40).map((e,n)=>(0,C.jsxs)(`div`,{className:`flex items-center gap-2 font-mono text-[9px]`,children:[(0,C.jsx)(`span`,{className:y(`rounded px-1`,e.confidence===`explicit`?`bg-success/10 text-success`:e.confidence===`inferred`?`bg-warning/10 text-warning`:`bg-primary/10 text-primary`),children:e.confidence}),(0,C.jsx)(`span`,{className:`text-muted-foreground`,children:e.kind}),(0,C.jsxs)(`span`,{className:`truncate`,children:[t.nodes.find(t=>t.eventId===e.from)?.eventType,` → `,t.nodes.find(t=>t.eventId===e.to)?.eventType]})]},`${e.from}-${e.to}-${e.kind}-${n}`))}),t.truncated&&(0,C.jsx)(`p`,{className:`mt-1 text-[9px] text-warning`,children:`Lineage truncated at safety limit.`})]}),r.map(([e,t])=>t&&(0,C.jsxs)(`section`,{className:`mb-4`,children:[(0,C.jsx)(`h3`,{className:`mb-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e}),(0,C.jsx)(`pre`,{className:`overflow-auto rounded-md border border-border bg-background/70 p-3 font-mono text-[9px] leading-relaxed`,children:JSON.stringify(t,null,2)})]},e))]})}function R({icon:e,label:t,value:n}){return(0,C.jsxs)(`div`,{className:`rounded-md border border-border p-2`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-1 text-[8px] uppercase text-muted-foreground`,children:[(0,C.jsx)(`span`,{className:`[&>svg]:h-3 [&>svg]:w-3`,children:e}),t]}),(0,C.jsx)(`div`,{className:`mt-1 truncate font-mono text-[9px]`,children:n})]})}function z({text:e}){return(0,C.jsx)(`div`,{className:`flex h-48 items-center justify-center text-sm text-muted-foreground`,children:e})}function B(e){return e===`failure`?`bg-destructive/10 text-destructive`:e===`success`?`bg-success/10 text-success`:e===`started`?`bg-primary/10 text-primary`:`bg-muted text-muted-foreground`}export{T as ChronicleDashboard};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{$t as t,Ai as n,Bt as r,Ni as i,Nt as a,Rr as o,Yr as s,Zi as c,aa as l,ai as u,bt as d,gr as f,ot as p,pr as m,qt as ee,rn as h,tt as g,xi as _}from"./vendor-Di1mdAi5.js";import{t as v}from"./ws-client-BWO_PH_X.js";import{t as y}from"./utils-C4qVQ63O.js";import{t as b}from"./pagination-Ktuov5iD.js";import{S as x}from"./index-BLAy5CKD.js";var S=e(l(),1),C=g(),w=[`eventType`,`providerId`,`modelId`,`outcome`,`resourceKind`],te=[{id:`all`,label:`All signals`,icon:(0,C.jsx)(c,{})},{id:`llm`,label:`LLM`,icon:(0,C.jsx)(n,{})},{id:`agents`,label:`Agents`,icon:(0,C.jsx)(i,{})},{id:`tools`,label:`Tools`,icon:(0,C.jsx)(a,{})},{id:`files`,label:`Files`,icon:(0,C.jsx)(o,{})},{id:`failures`,label:`Failures`,icon:(0,C.jsx)(d,{})}];function T(){let e=v(),[r,s]=(0,S.useState)([]),[c,l]=(0,S.useState)(null),[d,m]=(0,S.useState)({}),[g,_]=(0,S.useState)({limit:300,order:`desc`}),[T,E]=(0,S.useState)({text:``,path:``,providerId:``,modelId:``,sessionId:``}),[j,R]=(0,S.useState)(`all`),[B,V]=(0,S.useState)({total:0,scannedEvents:0,sourceFiles:0,invalidLines:0}),[H,U]=(0,S.useState)(D),[W,G]=(0,S.useState)(!0),[K,q]=(0,S.useState)(null),[ne,J]=(0,S.useState)(null),Y=(0,S.useCallback)(t=>{if(!e.supportsCapability(`chronicle.query`)){G(!1),q(`Restart the backend once to activate Chronicle protocol support.`);return}G(!0),q(null),_(t),e.send({type:`chronicle.query`,payload:{query:t}});for(let n of w)e.send({type:`chronicle.facet`,payload:{field:n,query:t,limit:12}})},[e]);(0,S.useEffect)(()=>{let t=e.on(`chronicle.query_result`,e=>{e.type===`chronicle.query_result`&&(s(e.payload.events),V(e.payload),U(e.payload.summary??D),G(!1))}),n=e.on(`chronicle.facet_result`,e=>{e.type===`chronicle.facet_result`&&m(t=>({...t,[e.payload.field]:e.payload.values}))}),r=e.on(`chronicle.error`,e=>{e.type===`chronicle.error`&&(q(e.payload.message),G(!1))}),i=e.on(`chronicle.graph_result`,e=>{e.type===`chronicle.graph_result`&&J(e.payload)});return Y({limit:300,order:`desc`}),()=>{t(),n(),r(),i()}},[e,Y]);let X=(0,S.useMemo)(()=>r.filter(e=>A(e,j)),[r,j]),Z=x(X,25,j),Q=(0,S.useMemo)(()=>r.find(e=>e.eventType===`runtime.health.sampled`)?.attributes,[r]),$=()=>Y({limit:300,order:`desc`,...T.text?{text:T.text}:{},...T.path?{path:T.path}:{},...T.providerId?{providerId:T.providerId}:{},...T.modelId?{modelId:T.modelId}:{},...T.sessionId?{sessionId:T.sessionId}:{}}),re=()=>{E({text:``,path:``,providerId:``,modelId:``,sessionId:``}),R(`all`),Y({limit:300,order:`desc`})},ie=t=>{l(t),J(null),e.supportsCapability(`chronicle.graph`)&&e.send({type:`chronicle.graph`,payload:{seed:{eventId:t.eventId},hops:2,maxNodes:250}})};return(0,C.jsxs)(`div`,{className:`flex h-full min-h-0 bg-background`,"data-testid":`chronicle-dashboard`,children:[(0,C.jsxs)(`main`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,C.jsx)(`header`,{className:`border-b border-border/70 bg-gradient-to-r from-primary/[0.045] via-background to-background px-5 py-4`,children:(0,C.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(n,{className:`h-5 w-5 text-primary`}),(0,C.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight`,children:`Coding Intelligence`}),(0,C.jsx)(`span`,{className:`rounded-full border border-primary/20 bg-primary/10 px-2 py-0.5 text-[9px] font-semibold tracking-wider text-primary`,children:`CHRONICLE`})]}),(0,C.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`LLM, agent, tool and file evidence — connected from decision to code change.`})]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(`span`,{className:y(`h-2 w-2 rounded-full`,K?`bg-destructive`:W?`animate-pulse bg-warning`:`bg-success`)}),(0,C.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:W?`Reading journal`:K?`Unavailable`:`Live evidence`}),(0,C.jsx)(`button`,{onClick:()=>Y(g),className:`ml-2 rounded-md border border-border bg-card p-2 hover:bg-muted`,title:`Refresh evidence`,children:(0,C.jsx)(h,{className:y(`h-4 w-4`,W&&`animate-spin`)})})]})]})}),(0,C.jsxs)(`section`,{className:`grid grid-cols-2 border-b border-border/70 xl:grid-cols-6`,children:[(0,C.jsx)(P,{icon:(0,C.jsx)(n,{}),label:`LLM requests`,value:H.logicalRequests,detail:`${H.modelAttempts} attempts · ${H.providers} providers · ${H.models} models`}),(0,C.jsx)(P,{icon:(0,C.jsx)(i,{}),label:`Agent work`,value:H.agentEvents,detail:`${H.uniqueAgents} correlated agents · ${H.decisions} decisions`}),(0,C.jsx)(P,{icon:(0,C.jsx)(a,{}),label:`Tool calls`,value:H.toolCalls,detail:`${H.failedTools} failed · ${H.processes} processes`}),(0,C.jsx)(P,{icon:(0,C.jsx)(o,{}),label:`File evidence`,value:H.fileEvents,detail:`${H.uniqueFiles} unique paths`}),(0,C.jsx)(P,{icon:(0,C.jsx)(t,{}),label:`Retries`,value:H.scheduledRetries,detail:`${H.failures} failures · ${H.fallbacks} fallbacks`,tone:H.failures?`danger`:`normal`}),(0,C.jsx)(P,{icon:(0,C.jsx)(u,{}),label:`Provider p95`,value:M(H.providerP95DurationMs),detail:`${M(H.providerAvgDurationMs)} average · all matches`})]}),(0,C.jsxs)(`section`,{className:`flex flex-wrap gap-x-6 gap-y-1 border-b border-border/60 bg-primary/[0.018] px-4 py-1.5 font-mono text-[9px] text-muted-foreground`,children:[(0,C.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-primary`,children:`Token economics`}),(0,C.jsxs)(`span`,{children:[`fresh input `,(0,C.jsx)(`b`,{className:`text-foreground`,children:H.inputTokens.toLocaleString()})]}),(0,C.jsxs)(`span`,{children:[`output `,(0,C.jsx)(`b`,{className:`text-foreground`,children:H.outputTokens.toLocaleString()})]}),(0,C.jsxs)(`span`,{children:[`cache read `,(0,C.jsx)(`b`,{className:`text-foreground`,children:H.cacheReadTokens.toLocaleString()})]}),(0,C.jsxs)(`span`,{children:[`cache write `,(0,C.jsx)(`b`,{className:`text-foreground`,children:H.cacheWriteTokens.toLocaleString()})]}),(0,C.jsxs)(`span`,{children:[`cache hit `,(0,C.jsxs)(`b`,{className:`text-foreground`,children:[k(H).toFixed(1),`%`]})]}),(0,C.jsxs)(`span`,{children:[`estimated cost `,(0,C.jsxs)(`b`,{className:`text-foreground`,children:[`$`,H.estimatedCostUsd.toFixed(4)]})]})]}),(0,C.jsx)(`section`,{className:`border-b border-border/70 px-4 py-3`,children:(0,C.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 xl:grid-cols-[1.35fr_1fr_1fr_1fr_1fr_auto]`,children:[(0,C.jsx)(N,{icon:(0,C.jsx)(ee,{}),placeholder:`Search event evidence`,value:T.text,onChange:e=>E(t=>({...t,text:e})),onEnter:$}),(0,C.jsx)(N,{placeholder:`File or directory`,value:T.path,onChange:e=>E(t=>({...t,path:e})),onEnter:$}),(0,C.jsx)(N,{placeholder:`Provider`,value:T.providerId,onChange:e=>E(t=>({...t,providerId:e})),onEnter:$}),(0,C.jsx)(N,{placeholder:`Model`,value:T.modelId,onChange:e=>E(t=>({...t,modelId:e})),onEnter:$}),(0,C.jsx)(N,{placeholder:`Session`,value:T.sessionId,onChange:e=>E(t=>({...t,sessionId:e})),onEnter:$}),(0,C.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,C.jsxs)(`button`,{onClick:$,className:`rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground`,children:[(0,C.jsx)(f,{className:`mr-1 inline h-3 w-3`}),`Apply`]}),(0,C.jsx)(`button`,{onClick:re,className:`rounded-md border border-border px-2.5 text-xs hover:bg-muted`,children:`Clear`})]})]})}),(0,C.jsxs)(`section`,{className:`flex items-center gap-1 overflow-x-auto border-b border-border/70 px-4 py-2`,children:[te.map(e=>(0,C.jsxs)(`button`,{onClick:()=>R(e.id),className:y(`flex shrink-0 items-center gap-1.5 rounded-md px-2.5 py-1.5 text-[11px] transition-colors [&>svg]:h-3.5 [&>svg]:w-3.5`,j===e.id?`bg-primary/10 font-medium text-primary`:`text-muted-foreground hover:bg-muted hover:text-foreground`),children:[e.icon,e.label,(0,C.jsx)(`span`,{className:`ml-1 rounded bg-background/70 px-1 font-mono text-[9px]`,children:O(H,e.id,B.total)})]},e.id)),(0,C.jsxs)(`div`,{className:`ml-auto hidden items-center gap-3 pl-4 text-[9px] text-muted-foreground lg:flex`,children:[(0,C.jsxs)(`span`,{children:[B.total.toLocaleString(),` matched`]}),(0,C.jsxs)(`span`,{children:[B.sourceFiles,` journal files`]}),B.invalidLines>0&&(0,C.jsxs)(`span`,{className:`text-warning`,children:[B.invalidLines,` invalid lines`]})]})]}),Q&&(0,C.jsx)(F,{health:Q}),(0,C.jsx)(`section`,{className:`flex gap-4 overflow-x-auto border-b border-border/60 bg-muted/[0.18] px-4 py-2`,children:[`providerId`,`modelId`,`outcome`].map(e=>(0,C.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,C.jsx)(`span`,{className:`mr-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e.replace(`Id`,``)}),(d[e]??[]).slice(0,4).map(t=>(0,C.jsxs)(`button`,{onClick:()=>Y({...g,[e]:t.value}),className:`rounded-full border border-border bg-card px-2 py-0.5 text-[9px] hover:border-primary/50`,children:[t.value,` `,(0,C.jsx)(`b`,{children:t.count})]},t.value))]},e))}),(0,C.jsxs)(`div`,{className:`grid grid-cols-[92px_minmax(190px,1.25fr)_110px_minmax(180px,1fr)_minmax(140px,.8fr)_24px] gap-3 border-b border-border/60 bg-muted/20 px-4 py-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,C.jsx)(`span`,{children:`Time`}),(0,C.jsx)(`span`,{children:`Signal`}),(0,C.jsx)(`span`,{children:`Outcome`}),(0,C.jsx)(`span`,{children:`Model / agent`}),(0,C.jsx)(`span`,{children:`Resource`}),(0,C.jsx)(`span`,{})]}),(0,C.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:K?(0,C.jsx)(z,{text:K}):!W&&X.length===0?(0,C.jsx)(z,{text:`No coding evidence matches these filters.`}):(0,C.jsx)(`div`,{className:`divide-y divide-border/40`,children:Z.pageItems.map(e=>(0,C.jsx)(I,{event:e,active:c?.eventId===e.eventId,onClick:()=>ie(e)},e.eventId))})}),(0,C.jsx)(b,{page:Z.page,pageSize:Z.pageSize,totalItems:Z.totalItems,onPageChange:Z.setPage,itemLabel:`events`})]}),c&&(0,C.jsxs)(`aside`,{className:`w-[440px] max-w-[48vw] shrink-0 overflow-auto border-l border-border bg-card/60 shadow-[-12px_0_32px_hsl(var(--background)/.35)]`,children:[(0,C.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center justify-between border-b border-border bg-card/95 px-4 py-3 backdrop-blur`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-xs font-semibold`,children:`Evidence & lineage`}),(0,C.jsxs)(`div`,{className:`mt-0.5 font-mono text-[9px] text-muted-foreground`,children:[`#`,c.sequence,` · `,c.eventId]})]}),(0,C.jsx)(`button`,{onClick:()=>l(null),className:`rounded p-1 hover:bg-muted`,children:(0,C.jsx)(p,{className:`h-4 w-4`})})]}),(0,C.jsx)(L,{event:c,graph:ne})]})]})}var E={llm:0,agent:0,tool:0,file:0,memory:0,task:0,decision:0,runtime:0},D={logicalRequests:0,modelAttempts:0,completedAttempts:0,failedAttempts:0,scheduledRetries:0,fallbacks:0,providers:0,models:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheWriteTokens:0,estimatedCostUsd:0,providerAvgDurationMs:0,providerP95DurationMs:0,toolCalls:0,completedTools:0,failedTools:0,toolAvgDurationMs:0,processes:0,failedProcesses:0,fileEvents:0,uniqueFiles:0,agentEvents:0,uniqueAgents:0,decisions:0,escalations:0,failures:0,cancellations:0,families:{...E},failuresByFamily:{...E}};function O(e,t,n){return t===`all`?n:t===`llm`?e.families.llm:t===`agents`?e.families.agent:t===`tools`?e.families.tool:t===`files`?e.families.file:e.failures}function k(e){let t=e.inputTokens+e.cacheReadTokens;return t?e.cacheReadTokens/t*100:0}function A(e,t){return t===`all`?!0:t===`llm`?/^(provider|token|context|compaction)\./.test(e.eventType):t===`agents`?/^(agent|subagent|delegate|fleet|sdd)\./.test(e.eventType):t===`tools`?/^(tool|process|mcp|network)\./.test(e.eventType):t===`files`?e.resource?.kind===`file`||/^(file|worktree|storage)\./.test(e.eventType):e.outcome===`failure`||/(?:failed|error|retry|fallback|blocked|conflict)/i.test(e.eventType)}function j(e){if(!e)return`—`;let t=e/1e6;return t<1?`${(e/1e3).toFixed(0)}µs`:t<1e3?`${t.toFixed(1)}ms`:`${(t/1e3).toFixed(1)}s`}function M(e){return e?e<1?`${(e*1e3).toFixed(0)}µs`:e<1e3?`${e.toFixed(1)}ms`:`${(e/1e3).toFixed(1)}s`:`—`}function N({placeholder:e,value:t,onChange:n,onEnter:r,icon:i}){return(0,C.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md border border-border bg-card px-2.5 py-2 focus-within:border-primary/60`,children:[i&&(0,C.jsx)(`span`,{className:`text-muted-foreground [&>svg]:h-3.5 [&>svg]:w-3.5`,children:i}),(0,C.jsx)(`input`,{className:`w-full bg-transparent text-xs outline-none placeholder:text-muted-foreground/70`,placeholder:e,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Enter`&&r()}})]})}function P({icon:e,label:t,value:n,detail:r,tone:i=`normal`}){return(0,C.jsxs)(`div`,{className:`min-w-0 border-r border-border/60 px-4 py-3`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,C.jsx)(`span`,{className:`text-primary [&>svg]:h-3.5 [&>svg]:w-3.5`,children:e}),t]}),(0,C.jsx)(`div`,{className:y(`mt-1 text-xl font-semibold tabular-nums`,i===`danger`&&`text-destructive`),children:typeof n==`number`?n.toLocaleString():n}),(0,C.jsx)(`div`,{className:`mt-0.5 truncate text-[9px] text-muted-foreground`,children:r})]})}function F({health:e}){return(0,C.jsxs)(`section`,{className:`flex flex-wrap gap-x-5 gap-y-1 border-b border-border/60 bg-success/[0.025] px-4 py-1.5 font-mono text-[9px] text-muted-foreground`,children:[(0,C.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-success`,children:`Collector healthy`}),(0,C.jsxs)(`span`,{children:[`ELU `,(0,C.jsxs)(`b`,{className:`text-foreground`,children:[((e.eventLoop?.utilization??0)*100).toFixed(1),`%`]})]}),(0,C.jsxs)(`span`,{children:[`p95 `,(0,C.jsxs)(`b`,{className:`text-foreground`,children:[(e.eventLoop?.delayP95Ms??0).toFixed(1),`ms`]})]}),(0,C.jsxs)(`span`,{children:[`heap `,(0,C.jsxs)(`b`,{className:`text-foreground`,children:[((e.memory?.heapUsedBytes??0)/1048576).toFixed(0),`MB`]})]}),(0,C.jsxs)(`span`,{children:[`queue `,(0,C.jsx)(`b`,{className:`text-foreground`,children:e.chronicle?.pendingEvents??0})]}),(0,C.jsxs)(`span`,{children:[`dropped `,(0,C.jsx)(`b`,{className:y((e.chronicle?.rejectedEvents??0)>0&&`text-destructive`),children:e.chronicle?.rejectedEvents??0})]})]})}function I({event:e,active:t,onClick:n}){let r=e.occurredAt??e.observedAt,i=e.runtime?.modelId??e.scope.agentId??e.runtime?.providerId??`—`,a=e.resource?.path??e.resource?.id??e.correlation.toolCallId??`—`;return(0,C.jsxs)(`button`,{onClick:n,className:y(`grid w-full grid-cols-[92px_minmax(190px,1.25fr)_110px_minmax(180px,1fr)_minmax(140px,.8fr)_24px] items-center gap-3 px-4 py-2.5 text-left hover:bg-muted/45`,t&&`bg-primary/[0.07]`),children:[(0,C.jsx)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:new Date(r).toLocaleTimeString()}),(0,C.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,C.jsx)(`span`,{className:y(`h-1.5 w-1.5 shrink-0 rounded-full`,e.outcome===`failure`?`bg-destructive`:e.outcome===`success`?`bg-success`:`bg-primary`)}),(0,C.jsx)(`span`,{className:`truncate font-mono text-[11px] font-medium`,children:e.eventType})]}),(0,C.jsx)(`span`,{className:y(`w-fit rounded px-1.5 py-0.5 text-[9px]`,B(e.outcome)),children:e.outcome??`unknown`}),(0,C.jsx)(`span`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:i}),(0,C.jsx)(`span`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:a}),(0,C.jsx)(_,{className:`h-3.5 w-3.5 text-muted-foreground`})]})}function L({event:e,graph:t}){let n=(0,S.useMemo)(()=>[[`Scope`,e.scope],[`Correlation`,e.correlation],[`Runtime`,e.runtime],[`Resource`,e.resource],[`Attributes`,e.attributes],[`Tags`,e.tags]],[e]);return(0,C.jsxs)(`div`,{className:`p-4`,children:[(0,C.jsxs)(`div`,{className:`mb-4 rounded-lg border border-border bg-background/60 p-3`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(`span`,{className:y(`h-2 w-2 rounded-full`,e.outcome===`failure`?`bg-destructive`:e.outcome===`success`?`bg-success`:`bg-primary`)}),(0,C.jsx)(`span`,{className:`font-mono text-xs font-semibold`,children:e.eventType})]}),(0,C.jsxs)(`div`,{className:`mt-2 flex gap-4 text-[9px] text-muted-foreground`,children:[(0,C.jsx)(`span`,{children:new Date(e.occurredAt??e.observedAt).toLocaleString()}),(0,C.jsx)(`span`,{children:j(Number(e.durationNs??0))})]})]}),(0,C.jsxs)(`div`,{className:`mb-4 grid grid-cols-2 gap-2`,children:[(0,C.jsx)(R,{icon:(0,C.jsx)(r,{}),label:`Evidence hash`,value:e.hash.slice(0,16)}),(0,C.jsx)(R,{icon:(0,C.jsx)(s,{}),label:`Sequence`,value:String(e.sequence)})]}),t&&(0,C.jsxs)(`section`,{className:`mb-4`,children:[(0,C.jsxs)(`h3`,{className:`mb-1.5 flex items-center gap-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,C.jsx)(m,{className:`h-3 w-3`}),`Lineage · `,t.nodes.length,` nodes · `,t.edges.length,` edges`]}),(0,C.jsx)(`div`,{className:`space-y-1 rounded-md border border-border bg-background/70 p-2`,children:t.edges.slice(0,40).map((e,n)=>(0,C.jsxs)(`div`,{className:`flex items-center gap-2 font-mono text-[9px]`,children:[(0,C.jsx)(`span`,{className:y(`rounded px-1`,e.confidence===`explicit`?`bg-success/10 text-success`:e.confidence===`inferred`?`bg-warning/10 text-warning`:`bg-primary/10 text-primary`),children:e.confidence}),(0,C.jsx)(`span`,{className:`text-muted-foreground`,children:e.kind}),(0,C.jsxs)(`span`,{className:`truncate`,children:[t.nodes.find(t=>t.eventId===e.from)?.eventType,` → `,t.nodes.find(t=>t.eventId===e.to)?.eventType]})]},`${e.from}-${e.to}-${e.kind}-${n}`))}),t.truncated&&(0,C.jsx)(`p`,{className:`mt-1 text-[9px] text-warning`,children:`Lineage truncated at safety limit.`})]}),n.map(([e,t])=>t&&(0,C.jsxs)(`section`,{className:`mb-4`,children:[(0,C.jsx)(`h3`,{className:`mb-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e}),(0,C.jsx)(`pre`,{className:`overflow-auto rounded-md border border-border bg-background/70 p-3 font-mono text-[9px] leading-relaxed`,children:JSON.stringify(t,null,2)})]},e))]})}function R({icon:e,label:t,value:n}){return(0,C.jsxs)(`div`,{className:`rounded-md border border-border p-2`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-1 text-[8px] uppercase text-muted-foreground`,children:[(0,C.jsx)(`span`,{className:`[&>svg]:h-3 [&>svg]:w-3`,children:e}),t]}),(0,C.jsx)(`div`,{className:`mt-1 truncate font-mono text-[9px]`,children:n})]})}function z({text:e}){return(0,C.jsx)(`div`,{className:`flex h-48 items-center justify-center text-sm text-muted-foreground`,children:e})}function B(e){return e===`failure`?`bg-destructive/10 text-destructive`:e===`success`?`bg-success/10 text-success`:e===`started`?`bg-primary/10 text-primary`:`bg-muted text-muted-foreground`}export{T as ChronicleDashboard};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Bn as t,Ci as n,Fr as r,Kt as i,Ni as a,Nt as o,Or as s,Vn as c,Vt as l,Zi as u,aa as d,bi as f,ci as p,ea as m,hi as h,ot as g,pr as _,pt as v,rn as y,tt as b,y as x,zr as ee}from"./vendor-Di1mdAi5.js";import"./i18n-DaR2GB_4.js";import{a as S,i as C,n as w,o as T,r as E,t as D}from"./monaco-C7izDJhg.js";import{t as te}from"./ws-client-BWO_PH_X.js";import{t as O}from"./utils-C4qVQ63O.js";import{i as k}from"./codemap-activity-store-BIW6YPvC.js";import{E as A,O as j,j as ne,o as re,u as ie}from"./stores-JSLvWOQY.js";import{s as M}from"./view-navigation-BbHlzAQz.js";import{C as N,v as ae,y as P}from"./index-BLAy5CKD.js";import{t as F}from"./monaco-theme-BoNOJHQB.js";var I={ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,json:`json`,css:`css`,html:`html`,svg:`xml`,md:`markdown`,yml:`yaml`,yaml:`yaml`,toml:`toml`,sh:`shell`,bash:`shell`,ps1:`powershell`,py:`python`,rs:`rust`,go:`go`,rb:`ruby`,java:`java`,c:`c`,cpp:`cpp`,h:`c`,hpp:`cpp`,sql:`sql`,xml:`xml`},L=Array.from(new Set(Object.values(I))).filter(e=>e!==`plaintext`),R=12e3,z=4e3,B=5e3,V=1e4;function H(e){return I[e.split(`.`).pop()?.toLowerCase()??``]??`plaintext`}function U(e){return e.match(/([A-Za-z_$][\w$]*)$/)?.[1]??``}function W(e,t){return e.triggerCharacter?!0:t.length>=3}function G(e,t){return e.triggerCharacter===`.`||!e.triggerCharacter&&/^(findBy|findAllBy|create|update|delete|remove|get[A-Z_]|set[A-Z_]|use[A-Z_])/.test(t)}function oe(e){return[e.filePath,e.language,e.lineNumber,e.column,e.versionId??``,e.triggerCharacter??``,e.linePrefix.slice(-160),e.suffix.slice(0,160)].join(`\0`)}var K=e(d(),1),q=b(),J=150,se=224,ce=38,le=/(write|edit|update|create|delete|rename|modified|changed)/i;function ue(e){return e.replace(/\\/g,`/`).replace(/^\.\//,``).replace(/\/{2,}/g,`/`).toLowerCase()}function Y(e,t){let n=ue(e),r=ue(t);return n===r||n.endsWith(`/${r}`)||r.endsWith(`/${n}`)}function de(e,t=Date.now()){let n=e.filter(e=>t-e.at<=30*6e4),r=n.filter(e=>le.test(e.action)),i=new Set(n.map(e=>e.sessionId).filter(Boolean)).size,a=new Set(n.map(e=>e.actor).filter(Boolean)).size,o=new Set(n.map(e=>e.taskId).filter(Boolean)).size;return{level:r.length>=8||r.length>=4&&a>=3?`churn`:r.length>0?`active`:`quiet`,mutationCount:r.length,sessionCount:i,actorCount:a,taskCount:o}}function X(e){return typeof e==`string`&&e.length>0?e:void 0}function fe(e){let t=Date.parse(e.occurredAt??e.observedAt);return Number.isFinite(t)?t:Date.now()}function pe(e){let t=e.attributes??{},n=X(t.operation)??e.eventType,r=e.scope.agentId,i=e.runtime?.providerId,a=e.runtime?.modelId;return{id:e.eventId,at:fe(e),action:n,actor:r??i??X(t.actor)??`external`,source:X(t.source)??e.tags?.collector??`chronicle`,summary:[e.eventType,i&&a?`${i}/${a}`:i,e.outcome].filter(Boolean).join(` · `),sessionId:e.scope.sessionId,agentId:r,taskId:e.scope.taskId??X(t.taskId),boardId:X(t.boardId)??e.scope.boardId,tool:X(t.toolName),status:e.outcome,raw:e}}function me(e){return{id:e.id??`${e.filePath}:${e.timestamp}:${e.type}`,at:e.timestamp,action:e.type,actor:e.agentName??e.agent??e.agentId??`external`,source:e.source??`live`,summary:e.summary,sessionId:e.sessionId,agentId:e.agentId,tool:e.toolName,status:e.status,raw:e}}function he(e){let t=new Set;return e.sort((e,t)=>t.at-e.at).filter(e=>{let n=`${e.id}:${e.at}`;return t.has(n)?!1:(t.add(n),!0)})}function ge(e){return e?e.split(/\r?\n/).length:0}function _e(e){return new TextEncoder().encode(e).length}function ve(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function ye(e){return e.length>18?`${e.slice(0,8)}…${e.slice(-6)}`:e}function be(e,t){let n=P(e,t);return n?{added:n.filter(e=>e.kind===`add`).length,removed:n.filter(e=>e.kind===`del`).length,large:!1}:{added:0,removed:0,large:!0}}function xe({file:e}){let{t}=m(),[i,a]=(0,K.useState)(!0),[s,l]=(0,K.useState)(se),[d,p]=(0,K.useState)(`overview`),[g,v]=(0,K.useState)([]),[b,x]=(0,K.useState)(!1),[S,C]=(0,K.useState)(null),[w,T]=(0,K.useState)(null),E=(0,K.useRef)(null),D=ne(e=>e.wsUrl),A=k(e=>e.history),j=k(e=>e.activeOperations),M=ie(e=>e.activeBoard),N=re(e=>e.snapshot),P=(0,K.useMemo)(()=>te(D),[D]),F=(0,K.useCallback)(()=>{C(null),x(!0),typeof P.getGitDiff==`function`&&P.getGitDiff(e.path),typeof P.supportsCapability==`function`&&P.supportsCapability(`chronicle.query`)?P.send({type:`chronicle.query`,payload:{query:{path:e.path,resourceKind:`file`,order:`desc`,limit:150}}}):x(!1)},[P,e.path]);(0,K.useEffect)(()=>{v([]),T(null);let t=P.on(`chronicle.query_result`,t=>{if(t.type!==`chronicle.query_result`)return;let n=t.payload.events.filter(t=>t.resource?.path&&Y(t.resource.path,e.path));t.payload.events.length>0&&n.length===0||(v(n),x(!1))}),n=P.on(`chronicle.error`,e=>{e.type===`chronicle.error`&&(C(e.payload.message),x(!1))}),r=P.on(`git.diff`,t=>{if(t.type!==`git.diff`||!Y(t.payload.path,e.path))return;let n=t.payload;if(n.error||n.binary||n.tooLarge){T({text:e.savedContent,available:!1,error:n.error});return}T({text:n.oldText??``,available:!0})});return F(),()=>{t(),n(),r()}},[P,e.path,e.savedContent,F]),(0,K.useEffect)(()=>{let e=e=>{if(!E.current)return;let t=E.current.startY-e.clientY,n=Math.max(J,Math.floor(window.innerHeight*.62));l(Math.min(n,Math.max(J,E.current.startHeight+t)))},t=()=>{E.current=null,document.body.style.cursor=``,document.body.style.userSelect=``};return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t)}},[]);let I=(0,K.useMemo)(()=>{let t=[];for(let[n,r]of A)Y(n,e.path)&&t.push(...r);for(let n of j.values())t.push(...n.filter(t=>Y(t.filePath,e.path)));return t},[j,e.path,A]),L=(0,K.useMemo)(()=>he([...I.map(me),...g.map(pe)]),[g,I]),R=(0,K.useMemo)(()=>de(L),[L]),z=w?.text??e.savedContent,B=(0,K.useMemo)(()=>be(z,e.content),[z,e.content]),V=(0,K.useMemo)(()=>[...new Set(L.map(e=>e.sessionId).filter(e=>!!e))],[L]),H=(0,K.useMemo)(()=>[...new Set(L.map(e=>e.actor).filter(Boolean))],[L]),U=(0,K.useMemo)(()=>[...new Set(L.map(e=>e.taskId).filter(e=>!!e))],[L]),W=(0,K.useCallback)(e=>{let t=M?.tasks.find(t=>t.id===e),n=N?.tasks.find(t=>t.id===e||t.shortId===e);return t?.title??n?.title??e},[M,N]),G=e=>{i||a(!0),E.current={startY:e.clientY,startHeight:i?s:J},document.body.style.cursor=`ns-resize`,document.body.style.userSelect=`none`},oe=[{id:`overview`,label:t(`activity:fileActivity.overview`),icon:(0,q.jsx)(u,{})},{id:`changes`,label:t(`activity:fileActivity.changes`),icon:(0,q.jsx)(r,{})},{id:`context`,label:t(`activity:fileActivity.context`),icon:(0,q.jsx)(c,{})},{id:`logs`,label:t(`activity:fileActivity.logs`),icon:(0,q.jsx)(o,{})}];return(0,q.jsxs)(`section`,{className:`flex shrink-0 flex-col overflow-hidden border-t border-border bg-card/95 shadow-[0_-10px_30px_hsl(var(--background)/0.24)] backdrop-blur`,style:{height:i?s:ce},"data-testid":`file-activity-drawer`,children:[(0,q.jsx)(`button`,{type:`button`,"aria-label":t(`activity:fileActivity.resizeHint`),className:`group relative block h-2 w-full cursor-ns-resize touch-none`,onPointerDown:G,onDoubleClick:()=>{a(!0),l(se)},title:t(`activity:fileActivity.resizeHint`),children:(0,q.jsx)(`span`,{className:`absolute left-1/2 top-0.5 h-1 w-10 -translate-x-1/2 rounded-full bg-border transition-colors group-hover:bg-primary/60`})}),(0,q.jsxs)(`header`,{className:`flex h-[30px] min-w-0 items-center gap-2 border-b border-border/70 px-2.5`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`inline-flex min-w-0 items-center gap-1.5 rounded px-1.5 py-1 text-[11px] font-semibold hover:bg-muted`,"aria-expanded":i,children:[(0,q.jsx)(ee,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,q.jsx)(`span`,{className:`truncate`,children:t(`activity:fileActivity.title`)}),i?(0,q.jsx)(n,{className:`h-3 w-3`}):(0,q.jsx)(f,{className:`h-3 w-3`})]}),(0,q.jsx)(`span`,{className:`hidden h-3 w-px bg-border sm:block`}),(0,q.jsx)(Se,{label:`${ge(e.content)} ${t(`activity:fileActivity.lines`)}`}),(0,q.jsx)(Se,{label:ve(_e(e.content))}),!B.large&&(B.added>0||B.removed>0)&&(0,q.jsxs)(`span`,{className:`hidden items-center gap-1 font-mono text-[10px] md:flex`,children:[(0,q.jsxs)(`span`,{className:`text-success`,children:[`+`,B.added]}),(0,q.jsxs)(`span`,{className:`text-destructive`,children:[`−`,B.removed]})]}),(0,q.jsxs)(`span`,{className:O(`ml-auto inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[9px] font-semibold uppercase tracking-wide`,R.level===`churn`&&`bg-destructive/10 text-destructive`,R.level===`active`&&`bg-warning/10 text-warning`,R.level===`quiet`&&`bg-success/10 text-success`),children:[(0,q.jsx)(h,{className:`h-2.5 w-2.5`}),t(`activity:fileActivity.level.${R.level}`)]}),(0,q.jsx)(`span`,{className:`hidden text-[9px] text-muted-foreground lg:inline`,children:t(`activity:fileActivity.evidenceCount`,{count:L.length})}),i&&(0,q.jsx)(`button`,{type:`button`,onClick:F,className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,title:t(`activity:fileActivity.refresh`),children:(0,q.jsx)(y,{className:O(`h-3.5 w-3.5`,b&&`animate-spin`)})})]}),i&&(0,q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,q.jsxs)(`nav`,{className:`flex shrink-0 items-center gap-0.5 border-b border-border/60 bg-muted/20 px-2`,children:[oe.map(e=>(0,q.jsxs)(`button`,{type:`button`,onClick:()=>p(e.id),className:O(`inline-flex h-7 items-center gap-1.5 border-b-2 px-2 text-[10px] transition-colors [&>svg]:h-3 [&>svg]:w-3`,d===e.id?`border-primary font-medium text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`),children:[e.icon,e.label]},e.id)),S&&(0,q.jsx)(`span`,{className:`ml-auto truncate px-2 text-[9px] text-warning`,children:S})]}),(0,q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[d===`overview`&&(0,q.jsx)(Ce,{analysis:R,records:L,sessions:V,agents:H,tasks:U,taskLabel:W}),d===`changes`&&(0,q.jsxs)(`div`,{className:`h-full min-h-[120px] p-2`,children:[(0,q.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2 text-[9px] text-muted-foreground`,children:[(0,q.jsx)(_,{className:`h-3 w-3`}),(0,q.jsx)(`span`,{children:w?.available?t(`activity:fileActivity.gitToBuffer`):t(`activity:fileActivity.savedToBuffer`)}),e.dirty&&(0,q.jsx)(`span`,{className:`rounded bg-warning/10 px-1.5 py-0.5 text-warning`,children:t(`activity:fileActivity.unsaved`)}),w?.error&&(0,q.jsx)(`span`,{className:`truncate text-warning`,children:w.error})]}),(0,q.jsx)(`div`,{className:`h-[calc(100%-24px)] min-h-[90px]`,children:(0,q.jsx)(ae,{oldText:z,newText:e.content,caption:e.path,fill:!0})})]}),d===`context`&&(0,q.jsx)(we,{sessions:V,agents:H,tasks:U,records:L,taskLabel:W,boardTitle:M?.title??N?.title}),d===`logs`&&(0,q.jsx)(Te,{records:L,loading:b})]})]})]})}function Se({label:e}){return(0,q.jsx)(`span`,{className:`hidden whitespace-nowrap font-mono text-[9px] text-muted-foreground sm:inline`,children:e})}function Ce({analysis:e,records:t,sessions:n,agents:i,tasks:o,taskLabel:s}){let{t:u}=m();return(0,q.jsxs)(`div`,{className:`grid min-h-full grid-cols-1 gap-2 p-2 lg:grid-cols-[minmax(360px,.9fr)_minmax(420px,1.35fr)]`,children:[(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsx)(`div`,{className:`grid grid-cols-4 gap-1.5`,children:[{label:u(`activity:fileActivity.mutations30m`),value:e.mutationCount,icon:(0,q.jsx)(r,{})},{label:u(`activity:fileActivity.sessions`),value:n.length,icon:(0,q.jsx)(v,{})},{label:u(`activity:fileActivity.actors`),value:i.length,icon:(0,q.jsx)(a,{})},{label:u(`activity:fileActivity.linkedWork`),value:o.length,icon:(0,q.jsx)(c,{})}].map(e=>(0,q.jsxs)(`div`,{className:`rounded-md border border-border/70 bg-background/45 px-2 py-1.5`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1 text-[9px] text-muted-foreground [&>svg]:h-3 [&>svg]:w-3`,children:[e.icon,(0,q.jsx)(`span`,{className:`truncate`,children:e.label})]}),(0,q.jsx)(`div`,{className:`mt-0.5 font-mono text-sm font-semibold`,children:e.value})]},e.label))}),(0,q.jsxs)(`div`,{className:O(`flex items-start gap-2 rounded-md border px-2.5 py-2 text-[10px]`,e.level===`churn`?`border-destructive/25 bg-destructive/[0.055]`:`border-border/70 bg-background/45`),children:[(0,q.jsx)(l,{className:O(`mt-0.5 h-3.5 w-3.5 shrink-0`,e.level===`churn`?`text-destructive`:`text-primary`)}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`font-semibold`,children:u(`activity:fileActivity.analysisTitle.${e.level}`)}),(0,q.jsx)(`p`,{className:`mt-0.5 text-muted-foreground`,children:u(`activity:fileActivity.analysisBody.${e.level}`,{mutations:e.mutationCount,actors:e.actorCount,sessions:e.sessionCount})})]})]}),o.length>0&&(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 text-[9px]`,children:[(0,q.jsxs)(`span`,{className:`text-muted-foreground`,children:[u(`activity:fileActivity.workLinks`),`:`]}),o.slice(0,4).map(e=>(0,q.jsx)(`span`,{className:`max-w-[180px] truncate rounded border border-primary/20 bg-primary/5 px-1.5 py-0.5 text-primary`,title:e,children:s(e)},e))]})]}),(0,q.jsxs)(`div`,{className:`min-w-0 rounded-md border border-border/70 bg-background/35`,children:[(0,q.jsx)(`div`,{className:`border-b border-border/60 px-2.5 py-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:u(`activity:fileActivity.recentActivity`)}),(0,q.jsx)(`div`,{className:`divide-y divide-border/40`,children:t.length===0?(0,q.jsx)($,{text:u(`activity:fileActivity.noEvidence`)}):t.slice(0,5).map(e=>(0,q.jsx)(Ee,{record:e},`${e.id}:${e.at}`))})]})]})}function we({sessions:e,agents:t,tasks:n,records:r,taskLabel:i,boardTitle:o}){let{t:s}=m();return(0,q.jsxs)(`div`,{className:`grid min-h-full grid-cols-1 divide-y divide-border/50 md:grid-cols-3 md:divide-x md:divide-y-0`,children:[(0,q.jsx)(Z,{icon:(0,q.jsx)(v,{}),title:s(`activity:fileActivity.sessions`),empty:s(`activity:fileActivity.noSessions`),children:e.map(e=>(0,q.jsx)(Q,{title:ye(e),subtitle:`${r.filter(t=>t.sessionId===e).length} ${s(`activity:fileActivity.events`)}`,raw:e},e))}),(0,q.jsx)(Z,{icon:(0,q.jsx)(a,{}),title:s(`activity:fileActivity.actors`),empty:s(`activity:fileActivity.noActors`),children:t.map(e=>(0,q.jsx)(Q,{title:e,subtitle:`${r.filter(t=>t.actor===e).length} ${s(`activity:fileActivity.events`)}`},e))}),(0,q.jsx)(Z,{icon:(0,q.jsx)(c,{}),title:s(`activity:fileActivity.workLinks`),empty:s(`activity:fileActivity.noWorkLinks`),children:n.map(e=>(0,q.jsx)(Q,{title:i(e),subtitle:o??s(`activity:fileActivity.taskOrTodo`),raw:e},e))})]})}function Z({icon:e,title:t,empty:n,children:r}){let i=Array.isArray(r)?r.length>0:!!r;return(0,q.jsxs)(`section`,{className:`min-w-0 p-2`,children:[(0,q.jsxs)(`h3`,{className:`mb-1.5 flex items-center gap-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground [&>svg]:h-3 [&>svg]:w-3`,children:[e,t]}),(0,q.jsx)(`div`,{className:`space-y-1`,children:i?r:(0,q.jsx)($,{text:n})})]})}function Q({title:e,subtitle:t,raw:n}){return(0,q.jsxs)(`div`,{className:`rounded-md border border-border/60 bg-background/45 px-2 py-1.5`,title:n,children:[(0,q.jsx)(`div`,{className:`truncate text-[10px] font-medium`,children:e}),(0,q.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[8px] text-muted-foreground`,children:t})]})}function Te({records:e,loading:n}){let{t:r}=m();return n&&e.length===0?(0,q.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-[10px] text-muted-foreground`,children:[(0,q.jsx)(t,{className:`h-3.5 w-3.5 animate-spin`}),r(`activity:fileActivity.loadingEvidence`)]}):e.length===0?(0,q.jsx)($,{text:r(`activity:fileActivity.noEvidence`)}):(0,q.jsx)(`div`,{className:`divide-y divide-border/40`,children:e.map(e=>(0,q.jsx)(Ee,{record:e,raw:!0},`${e.id}:${e.at}`))})}function Ee({record:e,raw:t=!1}){let n=(0,q.jsxs)(`div`,{className:`grid grid-cols-[62px_74px_minmax(90px,.7fr)_minmax(160px,1.5fr)] items-center gap-2 text-[9px]`,children:[(0,q.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:new Date(e.at).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}),(0,q.jsx)(`span`,{className:O(`w-fit rounded px-1.5 py-0.5 font-mono`,le.test(e.action)?`bg-warning/10 text-warning`:`bg-primary/10 text-primary`),children:e.action}),(0,q.jsx)(`span`,{className:`truncate`,title:e.agentId,children:e.actor}),(0,q.jsx)(`span`,{className:`truncate text-muted-foreground`,title:e.summary,children:e.summary})]});return t?(0,q.jsxs)(`details`,{className:`group cursor-pointer px-2.5 py-1.5`,children:[(0,q.jsx)(`summary`,{className:`list-none [&::-webkit-details-marker]:hidden`,children:n}),(0,q.jsx)(`pre`,{className:`mt-1.5 max-h-48 overflow-auto rounded border border-border/60 bg-background/60 p-2 font-mono text-[8px] leading-relaxed text-muted-foreground`,children:JSON.stringify(e.raw,null,2)})]}):(0,q.jsx)(`div`,{className:`px-2.5 py-1.5`,children:n})}function $({text:e}){return(0,q.jsx)(`div`,{className:`px-3 py-3 text-center text-[10px] text-muted-foreground`,children:e})}w.config({monaco:D});function De(e){switch(e){case`method`:return T.CompletionItemKind.Method;case`function`:return T.CompletionItemKind.Function;case`constructor`:return T.CompletionItemKind.Constructor;case`field`:return T.CompletionItemKind.Field;case`variable`:return T.CompletionItemKind.Variable;case`class`:return T.CompletionItemKind.Class;case`interface`:return T.CompletionItemKind.Interface;case`module`:return T.CompletionItemKind.Module;case`property`:return T.CompletionItemKind.Property;case`unit`:return T.CompletionItemKind.Unit;case`value`:return T.CompletionItemKind.Value;case`enum`:return T.CompletionItemKind.Enum;case`keyword`:return T.CompletionItemKind.Keyword;case`snippet`:return T.CompletionItemKind.Snippet;case`file`:return T.CompletionItemKind.File;case`reference`:return T.CompletionItemKind.Reference;default:return T.CompletionItemKind.Text}}function Oe(){let e=A(e=>e.openFiles),t=A(e=>e.activeFilePath),n=A(e=>e.setActiveFile),r=A(e=>e.closeFile);return e.length===0?null:(0,q.jsx)(`div`,{className:`flex items-center border-b bg-muted/40 overflow-x-auto shrink-0`,children:e.map(e=>{let i=e.path===t,a=e.path.split(`/`).pop()??e.path;return(0,q.jsxs)(`button`,{type:`button`,onClick:()=>n(e.path),onMouseDown:t=>{t.button===1&&(t.preventDefault(),r(e.path))},className:O(`group flex items-center gap-1.5 px-3 py-1.5 text-[11px] border-r whitespace-nowrap min-w-0 max-w-[180px] transition-colors`,i?`bg-background border-t-2 border-t-primary text-foreground -mb-px`:`text-muted-foreground hover:bg-muted/60 hover:text-foreground`),title:e.path,children:[e.dirty&&(0,q.jsx)(p,{className:`h-2 w-2 fill-current text-primary shrink-0`}),(0,q.jsx)(`span`,{className:`truncate`,children:a}),(0,q.jsx)(g,{className:O(`h-3 w-3 shrink-0 rounded-sm hover:bg-muted-foreground/20 opacity-0 group-hover:opacity-100 transition-opacity`,i&&`opacity-100`),onClick:t=>{t.stopPropagation(),r(e.path)}})]},e.path)})})}function ke(){let{t:e}=m(),t=A(e=>e.openFiles),n=A(e=>e.activeFilePath),r=A(e=>e.updateContent),{theme:a}=N(),o=(0,K.useRef)(null),c=(0,K.useRef)(n),l=(0,K.useRef)(new Map),u=(0,K.useMemo)(()=>t.find(e=>e.path===n)??null,[t,n]),d=n?H(n):`plaintext`,f=F(),[p,h]=(0,K.useState)(!1);(0,K.useEffect)(()=>{c.current=n},[n]),(0,K.useEffect)(()=>{let e=F();S.setTheme(e)},[a]),(0,K.useEffect)(()=>{let e=L.map(e=>T.registerCompletionItemProvider(e,{triggerCharacters:[`.`,`_`],provideCompletionItems:async(e,t,n,r)=>{let i=c.current;if(!i)return{suggestions:[]};let a=e.getOffsetAt(t),o=e.getValue(),s=o.slice(Math.max(0,a-R),a),u=o.slice(a,a+z),d=e.getLineContent(t.lineNumber).slice(0,Math.max(0,t.column-1)),f=U(d),p={triggerCharacter:n.triggerCharacter,triggerKind:n.triggerKind};if(!W(p,f))return{suggestions:[]};let m=`cmp_${Date.now()}_${Math.random().toString(36).slice(2)}`,h=e.getWordUntilPosition(t),g={startLineNumber:t.lineNumber,endLineNumber:t.lineNumber,startColumn:h.startColumn,endColumn:t.column},_=te(ne.getState().wsUrl),v=e=>e.map((e,t)=>({label:e.label,kind:De(e.kind),insertText:e.insertText,detail:e.detail??(e.source?`WrongStack ${e.source}`:void 0),documentation:e.documentation,sortText:e.sortText??`${String(t).padStart(3,`0`)}-${e.label}`,range:g,insertTextRules:e.kind===`snippet`?T.CompletionItemInsertTextRule.InsertAsSnippet:void 0})),y=oe({filePath:i,language:e.getLanguageId(),lineNumber:t.lineNumber,column:t.column,versionId:e.getVersionId(),triggerCharacter:n.triggerCharacter,linePrefix:d,suffix:u}),b=l.current.get(y);return b&&b.expiresAt>Date.now()?{suggestions:v(b.items)}:await new Promise(a=>{let c=!1,d=()=>{},h=null,g,b=e=>{c||(c=!0,d(),g!==void 0&&window.clearTimeout(g),h?.dispose(),a({suggestions:e}))};d=_.on(`completion.result`,e=>{let t=e;t.payload.requestId===m&&(l.current.set(y,{expiresAt:Date.now()+V,items:t.payload.items}),b(v(t.payload.items)))}),g=window.setTimeout(()=>b([]),B),h=r.onCancellationRequested(()=>b([])),_.requestCompletion({requestId:m,filePath:i,language:e.getLanguageId(),lineNumber:t.lineNumber,column:t.column,content:o.length<=5e5?o:void 0,prefix:s,suffix:u,triggerCharacter:n.triggerCharacter,triggerKind:n.triggerKind,allowLlm:G(p,f)})})}}));return()=>{e.forEach(e=>{e.dispose()})}},[]);let g=(0,K.useCallback)(()=>{let e=o.current;if(!e)return null;let t=e.getSelection();if(!t||t.isEmpty())return null;let n=e.getModel();if(!n)return null;let r=n.getValueInRange(t);return r.trim()?{content:r,startLine:t.startLineNumber,endLine:t.endLineNumber}:null},[]),_=(0,K.useCallback)(()=>{M(`chat`),requestAnimationFrame(()=>{document.querySelector(`[data-chat-textarea]`)?.focus()})},[]),v=(0,K.useCallback)(()=>{let e=c.current;if(!e)return;let t=g();t&&(j.getState().addRef({kind:`snippet`,path:e,startLine:t.startLine,endLine:t.endLine,content:t.content}),_())},[g,_]),y=(0,K.useCallback)(()=>{let e=c.current;e&&(j.getState().addRef({kind:`file`,path:e}),_())},[_]),b=(0,K.useCallback)(t=>{o.current=t,S.setTheme(F()),t.onDidChangeCursorSelection(()=>{let e=t.getSelection();h(!!e&&!e.isEmpty())}),t.addAction({id:`wrongstack-send-to-chat`,label:e(`activity:codeEditor.sendSelectionAction`),contextMenuGroupId:`wrongstack`,contextMenuOrder:0,precondition:void 0,keybindings:[C.CtrlCmd|C.Shift|E.KeyL],run:e=>{let t=e.getSelection();t&&!t.isEmpty()?v():y()}})},[v,y]),ee=(0,K.useCallback)(e=>{n&&e!==void 0&&r(n,e)},[n,r]);return(0,K.useEffect)(()=>{let e=e=>{let t=e.ctrlKey||e.metaKey,r=e.target?.tagName?.toLowerCase()===`textarea`||e.target?.closest(`.monaco-editor`)!==null;!t||!r||(e.key.toLowerCase()===`s`&&(e.preventDefault(),window.dispatchEvent(new CustomEvent(`wrongstack:save-file`,{detail:{filePath:n}}))),e.key.toLowerCase()===`w`&&(e.preventDefault(),n&&A.getState().closeFile(n)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),t.length===0?(0,q.jsx)(`div`,{className:`flex h-full min-w-0 items-center justify-center`,children:(0,q.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`activity:codeEditor.noFilesOpen`)}),(0,q.jsx)(`p`,{className:`text-[11px] text-muted-foreground/75`,children:e(`activity:codeEditor.selectToEdit`)})]})}):(0,q.jsxs)(`div`,{className:`flex h-full min-w-0 flex-col overflow-hidden`,children:[(0,q.jsx)(Oe,{}),(0,q.jsxs)(`div`,{className:`relative min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(p||u)&&(0,q.jsx)(`div`,{className:`absolute top-2 right-2 z-10 flex items-center gap-1 rounded-lg border border-border bg-popover/95 backdrop-blur shadow-md p-1`,children:(0,q.jsxs)(`button`,{type:`button`,onClick:p?v:y,className:`inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-[11px] text-foreground hover:bg-accent transition-colors`,title:e(p?`activity:codeEditor.sendSelectedTitle`:`activity:codeEditor.mentionFileTitle`),children:[p?(0,q.jsx)(i,{className:`h-3 w-3`}):(0,q.jsx)(s,{className:`h-3 w-3`}),(0,q.jsx)(`span`,{children:e(p?`activity:codeEditor.sendToChat`:`activity:codeEditor.mentionFile`)})]})}),u?(0,q.jsx)(x,{language:d,value:u.content,onChange:ee,theme:f,onMount:b,loading:(0,q.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,q.jsx)(`span`,{className:`text-[11px] text-muted-foreground animate-pulse`,children:e(`activity:codeEditor.loadingEditor`)})}),options:{minimap:{enabled:!1},fontSize:13,fontFamily:`'IBM Plex Mono', 'Cascadia Code', 'Fira Code', 'JetBrains Mono', monospace`,lineNumbers:`on`,renderWhitespace:`selection`,scrollBeyondLastLine:!1,wordWrap:`off`,tabSize:2,smoothScrolling:!0,cursorBlinking:`smooth`,cursorSmoothCaretAnimation:`on`,bracketPairColorization:{enabled:!0},"semanticHighlighting.enabled":!0,automaticLayout:!0,padding:{top:8}}},u.path):(0,q.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,q.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e(`activity:codeEditor.selectTab`)})})]}),u&&(0,q.jsx)(xe,{file:u})]})}export{ke as CodeEditor};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Bn as t,Bt as n,Ci as r,Cn as i,Et as a,Lr as o,Mi as s,Sn as c,Sr as l,Ur as u,Wi as ee,Zi as d,Zn as f,_ as p,a as te,aa as m,ar as ne,c as re,f as ie,g as h,h as ae,i as oe,in as g,ln as se,m as ce,mn as _,ot as le,p as ue,pr as de,qt as fe,r as pe,s as v,tt as y,u as me,xi as b,xn as he,yr as x}from"./vendor-Di1mdAi5.js";import{t as S}from"./utils-C4qVQ63O.js";import{i as ge,r as _e,t as C}from"./codemap-activity-store-BIW6YPvC.js";var w=e(m(),1);function T(e){return e.level===`packages`?`packages`:e.level===`files`?`files:${e.package}`:`symbols:${e.file}`}function ve(e){return e.level===`packages`?`/api/codemap/packages`:e.level===`files`?`/api/codemap/files?package=${encodeURIComponent(e.package)}`:`/api/codemap/symbols?file=${encodeURIComponent(e.file)}`}function ye(e,t,n){let r=new Map(e.nodes.map(e=>[e.id,e])),i=[];for(let a of e.edges){let e=n===`incoming`?a.target===t?a.source:void 0:a.source===t?a.target:void 0;if(!e)continue;let o=r.get(e);o&&i.push({node:o,edge:a})}return i.sort((e,t)=>t.edge.weight-e.edge.weight||e.node.label.localeCompare(t.node.label))}function be(e,t){let n=new Set([t]);for(let r of e.edges)r.source===t&&n.add(r.target),r.target===t&&n.add(r.source);return n}function xe(e,t){let n=new Map(e.nodes.map(e=>[e.id,0]));for(let r of e.edges)!t.has(r.source)||!t.has(r.target)||(n.set(r.source,(n.get(r.source)??0)+r.weight),r.target!==r.source&&n.set(r.target,(n.get(r.target)??0)+r.weight));return n}function E(e){let t=new Set(e.nodes.map(e=>e.id)),n=xe(e,t),r=new Map(e.nodes.map(e=>[e.id,0])),i=new Map;for(let n of e.edges){if(!t.has(n.source)||!t.has(n.target)||n.source===n.target)continue;r.set(n.target,(r.get(n.target)??0)+1);let e=i.get(n.source)??[];e.push(n.target),i.set(n.source,e)}let a=new Map,o=e.nodes.filter(e=>(r.get(e.id)??0)===0).sort((e,t)=>(n.get(t.id)??0)-(n.get(e.id)??0)).map(e=>e.id);o.length===0&&e.nodes[0]&&o.push(e.nodes[0].id);for(let e of o)a.set(e,0);let s=new Set,c=0;for(;c<o.length;){let e=o[c++];if(!s.has(e)){s.add(e);for(let t of i.get(e)??[])a.set(t,Math.max(a.get(t)??0,Math.min((a.get(e)??0)+1,7))),r.set(t,(r.get(t)??1)-1),(r.get(t)??0)<=0&&o.push(t)}}let l=e.nodes.filter(e=>!a.has(e.id)).sort((e,t)=>(n.get(t.id)??0)-(n.get(e.id)??0));l.forEach((e,t)=>{a.set(e.id,t%Math.min(4,Math.max(1,l.length)))});let u=new Map;for(let t of e.nodes){let e=a.get(t.id)??0,n=u.get(e)??[];n.push(t),u.set(e,n)}for(let e of u.values())e.sort((e,t)=>Number(e.external)-Number(t.external)||(n.get(t.id)??0)-(n.get(e.id)??0)||e.label.localeCompare(t.label));let ee=Math.max(1,...[...u.values()].map(e=>e.length))*160,d=[];for(let[e,t]of[...u.entries()].sort(([e],[t])=>e-t)){let n=(ee-t.length*160)/2;t.forEach((t,r)=>{d.push({node:t,position:{x:e*386,y:n+r*160}})})}return d}function Se(e,t){if(e.nodes.length===0)return[];let n=xe(e,new Set(e.nodes.map(e=>e.id))),r=e.nodes.find(e=>e.id===t)??[...e.nodes].sort((e,t)=>(n.get(t.id)??0)-(n.get(e.id)??0))[0],i=be(e,r.id);i.delete(r.id);let a=e.nodes.filter(e=>i.has(e.id)),o=e.nodes.filter(e=>e.id!==r.id&&!i.has(e.id)),s=[{node:r,position:{x:0,y:0}}],c=(e,t,n)=>{e.forEach((r,i)=>{let a=n+Math.PI*2*i/Math.max(1,e.length);s.push({node:r,position:{x:Math.cos(a)*t,y:Math.sin(a)*t}})})};c(a,Math.max(330,a.length*34),-Math.PI/2);for(let e=0;e<o.length;e+=18)c(o.slice(e,e+18),620+Math.floor(e/18)*280,-Math.PI/2+.12);return s}function Ce(e,t,n){return t===`orbit`?Se(e,n):E(e)}function D(e){let t=(e.file??e.label).replace(/\\/g,`/`),n=e.package??``,r=n.startsWith(`@wrongstack/`)?`/packages/${n.slice(12)}/`:n.startsWith(`app:`)?`/apps/${n.slice(4)}/`:void 0;if(r){let e=t.indexOf(r);if(e>=0)return t.slice(e+r.length)}let i=t.lastIndexOf(`/src/`);return i>=0?t.slice(i+1):t.split(`/`).slice(-3).join(`/`)}var O=new WeakMap;function we(e){let t=O.get(e);if(t)return t;let n={name:``,path:``,directories:[],files:[]};for(let t of e.filter(e=>e.kind===`file`&&!e.external)){let e=D(t).split(`/`).filter(Boolean),r=e.pop()??t.label,i=n;for(let t of e){let e=i.path?`${i.path}/${t}`:t,n=i.directories.find(e=>e.name===t);n||(n={name:t,path:e,directories:[],files:[]},i.directories.push(n)),i=n}i.files.push({...t,label:r})}let r=e=>{e.directories.sort((e,t)=>e.name.localeCompare(t.name)),e.files.sort((e,t)=>e.label.localeCompare(t.label)),e.directories.forEach(r)};return r(n),O.set(e,n),n}var k=y(),Te={nodes:[],edges:[]},A={package:{icon:he,accent:`border-l-primary`,iconStyle:`bg-primary/12 text-primary`},file:{icon:o,accent:`border-l-info`,iconStyle:`bg-info/12 text-info`},symbol:{icon:s,accent:`border-l-success`,iconStyle:`bg-success/12 text-success`}},Ee={call:`hsl(var(--primary))`,import:`hsl(var(--info))`,type_ref:`hsl(var(--success))`,inherit:`hsl(var(--warning))`,implement:`hsl(var(--destructive))`},De={read:`ring-2 ring-info/60 shadow-info/20`,write:`ring-2 ring-warning/70 shadow-warning/30`,edit:`ring-2 ring-warning/80 shadow-warning/40`,delete:`ring-2 ring-destructive/70 shadow-destructive/30`,search:`ring-2 ring-primary/55 shadow-primary/20`,memory:`ring-2 ring-success/60 shadow-success/30`,index:`ring-2 ring-info/50 shadow-info/20`,execute:`ring-2 ring-primary/55 shadow-primary/25`},j=[`bg-primary text-primary-foreground`,`bg-info text-info-foreground`,`bg-success text-success-foreground`,`bg-warning text-warning-foreground`,`bg-destructive text-destructive-foreground`];function M(e){return e.replace(/\\/g,`/`).replace(/^\.\//,``).toLocaleLowerCase()}function Oe(e,t){if(!e||!t)return!1;let n=M(e),r=M(t);return n===r||n.endsWith(`/${r}`)||r.endsWith(`/${n}`)}function ke(e){let t=M(e),n=t.match(/\/packages\/([^/]+)\//);if(n?.[1])return`@wrongstack/${n[1]}`;let r=t.match(/\/apps\/([^/]+)\//);return r?.[1]?`app:${r[1]}`:`(root)`}function N(e,t){return t.kind===`package`?ke(e.filePath)===(t.package??t.label):Oe(e.filePath,t.file)?t.kind!==`symbol`||e.symbol?.id===t.id:!1}function Ae(e){let t=e.trim().split(/[\s:_-]+/).filter(Boolean);return(t.length>1?`${t[0]?.[0]??``}${t[1]?.[0]??``}`:e.slice(0,2)).toLocaleUpperCase()}function je(e){let t=0;for(let n of e)t=t*31+n.charCodeAt(0)|0;return j[Math.abs(t)%j.length]??j[0]}function Me(e){let t=0;for(let n of e)t=t*31+n.charCodeAt(0)|0;return`hsl(${Math.abs(t)%360} 82% 58%)`}function Ne(e){let t=e.replace(/\\/g,`/`),n=t.lastIndexOf(`/packages/`),r=t.lastIndexOf(`/apps/`),i=Math.max(n,r);return i>=0?t.slice(i+1):t.split(`/`).slice(-3).join(`/`)}function Pe(e){return[e.symbol?.name,e.line?`L${e.line}`:void 0].filter(Boolean).join(` · `)}function Fe(e,t){let n=t.filter(t=>t.kind===`symbol`&&!t.external&&Oe(t.file,e.filePath));if(n.length===0)return;if(e.line)return[...n].sort((e,t)=>(t.line??0)-(e.line??0)).find(t=>(t.line??0)<=e.line)??n[0];let r=e.summary.toLocaleLowerCase();return n.find(e=>e.label.length>2&&(r.includes(e.label.toLocaleLowerCase())||!!(e.signature&&r.includes(e.signature.toLocaleLowerCase()))))}var Ie=160;function Le(e,t,n){if(n===`all`||e.nodes.length<=Ie)return e;let r=new Map(e.nodes.map(e=>[e.id,e])),i=new Map;for(let t of e.edges)i.set(t.source,(i.get(t.source)??0)+t.weight),i.set(t.target,(i.get(t.target)??0)+t.weight);let a=[...e.nodes].sort((e,t)=>(i.get(t.id)??0)-(i.get(e.id)??0)||e.label.localeCompare(t.label)),o=new Set,s=e=>{r.has(e)&&o.size<Ie&&o.add(e)};if(t&&r.has(t)){s(t);let n=e.edges.filter(e=>e.source===t||e.target===t).sort((e,t)=>t.weight-e.weight);for(let e of n)s(e.source),s(e.target);let r=new Set(o),i=e.edges.filter(e=>r.has(e.source)||r.has(e.target)).sort((e,t)=>t.weight-e.weight);for(let e of i)s(e.source),s(e.target)}else{let e=a.filter(e=>!e.external).slice(0,124),t=a.filter(e=>e.external).slice(0,36);for(let n of[...e,...t])s(n.id)}for(let e of a)s(e.id);return{nodes:e.nodes.filter(e=>o.has(e.id)),edges:e.edges.filter(e=>o.has(e.source)&&o.has(e.target))}}function Re({data:e}){let{graphNode:t,selected:n,dimmed:r,incoming:i,outgoing:a,isActive:o,activityType:s,activeOperations:c}=e,l=A[t.kind],ee=l.icon,d=t.kind!==`symbol`,f=t.kind===`symbol`?`${t.symbolKind??`symbol`}${t.line?` · L${t.line}`:``}`:t.kind===`file`?D(t):`${t.fileCount??0} files · ${t.symbolCount??0} symbols`;return(0,k.jsxs)(`div`,{className:S(`group relative w-[236px] border border-l-[3px] bg-card text-card-foreground shadow-[0_8px_24px_hsl(var(--shadow-color)/0.08)] transition-[opacity,filter,box-shadow,border-color,background-color]`,l.accent,n&&`border-primary bg-primary/5 shadow-[0_0_0_2px_hsl(var(--primary)/0.18),0_16px_36px_hsl(var(--shadow-color)/0.18)]`,t.external&&`border-dashed bg-muted/75`,r&&`opacity-25 grayscale`,o&&s&&De[s]),children:[c.length>0&&(0,k.jsxs)(`div`,{className:`absolute -top-5 left-2 z-20 flex max-w-[210px] items-center gap-1`,children:[c.slice(0,4).map(e=>{let t=e.agentName??e.agent??`External`,n=`${e.sessionId??`none`}:${e.agentId??t}`;return(0,k.jsxs)(`span`,{className:S(`flex h-6 items-center gap-1 border-2 border-background px-1.5 font-mono text-[8px] font-bold shadow-md`,je(n)),title:`${t} · ${e.type} ${Pe(e)}`,children:[(0,k.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse bg-current`}),Ae(t),e.symbol&&(0,k.jsx)(`span`,{className:`max-w-[80px] truncate`,children:e.symbol.name})]},e.id??`${n}:${e.filePath}`)}),c.length>4&&(0,k.jsxs)(`span`,{className:`border bg-card px-1 font-mono text-[8px] shadow`,children:[`+`,c.length-4]})]}),(0,k.jsx)(v,{type:`target`,position:p.Left,className:`!h-2.5 !w-2.5 !border-2 !border-card !bg-muted-foreground`}),(0,k.jsxs)(`button`,{type:`button`,className:`block w-full text-left`,onClick:n=>{if(n.shiftKey&&t.file){e.onShowHistory(t.file);return}e.onSelect(t)},onDoubleClick:()=>d&&e.onOpen(t),"aria-label":`${t.kind} ${t.label}`,children:[(0,k.jsxs)(`div`,{className:`flex items-start gap-3 p-3 pr-10`,children:[(0,k.jsx)(`span`,{className:S(`flex h-8 w-8 shrink-0 items-center justify-center border`,l.iconStyle),children:(0,k.jsx)(ee,{className:`h-4 w-4`})}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[9px] font-bold uppercase tracking-[0.18em] text-muted-foreground`,children:[(0,k.jsx)(`span`,{children:t.kind}),t.external&&(0,k.jsx)(`span`,{className:`border border-border px-1 py-0.5 text-[8px] text-warning`,children:`external`}),t.lang&&(0,k.jsx)(`span`,{className:`ml-auto font-mono normal-case tracking-normal`,children:t.lang})]}),(0,k.jsx)(`div`,{className:`truncate font-mono text-[13px] font-semibold`,title:t.label,children:t.label}),(0,k.jsx)(`div`,{className:`mt-1 truncate text-[10px] text-muted-foreground`,title:f,children:f})]})]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-3 border-t bg-muted/30 px-3 py-1.5 font-mono text-[9px] text-muted-foreground`,children:[(0,k.jsxs)(`span`,{title:`Incoming relationships`,children:[`← `,i]}),(0,k.jsxs)(`span`,{title:`Outgoing relationships`,children:[`→ `,a]}),t.symbolCount!==void 0&&t.kind===`file`&&(0,k.jsxs)(`span`,{className:`ml-auto`,children:[t.symbolCount,` sym`]}),o&&(0,k.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 font-bold text-warning`,children:[(0,k.jsx)(g,{className:`h-2.5 w-2.5 animate-pulse`}),` LIVE`]})]})]}),d&&(0,k.jsx)(`button`,{type:`button`,className:`absolute right-2 top-2 z-10 flex h-7 w-7 items-center justify-center border border-transparent text-muted-foreground opacity-0 transition hover:border-border hover:bg-muted hover:text-foreground group-hover:opacity-100 focus:opacity-100`,onClick:()=>e.onOpen(t),title:t.kind===`package`?`Open file map`:`Open symbol map`,"aria-label":`Open ${t.label} map`,children:(0,k.jsx)(u,{className:`h-3.5 w-3.5`})}),(0,k.jsx)(v,{type:`source`,position:p.Right,className:`!h-2.5 !w-2.5 !border-2 !border-card !bg-muted-foreground`})]})}function ze(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function P(e,t){return e.graphNode===t.graphNode&&e.selected===t.selected&&e.dimmed===t.dimmed&&e.incoming===t.incoming&&e.outgoing===t.outgoing&&e.isActive===t.isActive&&e.activityType===t.activityType&&e.onSelect===t.onSelect&&e.onOpen===t.onOpen&&e.onShowHistory===t.onShowHistory&&ze(e.activeOperations,t.activeOperations)}var Be={codemap:(0,w.memo)(Re,(e,t)=>P(e.data,t.data))};function Ve(e,t){let n=new Map(e.map(e=>[e.id,e])),r=e.length!==t.length,i=t.map((t,i)=>{let a=n.get(t.id);return a?a.type===t.type&&a.position.x===t.position.x&&a.position.y===t.position.y&&P(a.data,t.data)?(e[i]!==a&&(r=!0),a):(r=!0,{...a,...t,measured:a.measured}):(r=!0,t)});return r?i:e}function He(e){return e.data?.renderKey}function Ue(e,t){let n=new Map(e.map(e=>[e.id,e])),r=e.length!==t.length,i=t.map((t,i)=>{let a=n.get(t.id);return a&&He(a)===He(t)?(e[i]!==a&&(r=!0),a):(r=!0,t)});return r?i:e}function We(e){let{directory:n,packageName:i,depth:a,expandedDirectories:c,expandedFiles:ee,loadingBranches:d,graphForFile:f,onToggleDirectory:p,onToggleFile:te,onSelectFile:m,onOpenFile:ne,onSelectSymbol:re,selectedId:ie,activeOperations:h}=e;return(0,k.jsxs)(k.Fragment,{children:[n.directories.map(t=>{let n=`${i}:${t.path}`,o=c.has(n);return(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`button`,{type:`button`,className:`flex h-7 w-full items-center gap-1.5 pr-2 text-left text-[11px] text-muted-foreground hover:bg-muted hover:text-foreground`,style:{paddingLeft:8+a*12},onClick:()=>p(n),children:[o?(0,k.jsx)(r,{className:`h-3 w-3`}):(0,k.jsx)(b,{className:`h-3 w-3`}),o?(0,k.jsx)(l,{className:`h-3.5 w-3.5 text-warning`}):(0,k.jsx)(x,{className:`h-3.5 w-3.5 text-warning`}),(0,k.jsx)(`span`,{className:`truncate`,children:t.name})]}),o&&(0,k.jsx)(We,{...e,directory:t,depth:a+1})]},n)}),n.files.map(e=>{let n=ee.has(e.file??e.id),i=T({level:`symbols`,file:e.file??e.label}),c=(e.file?f(e.file):void 0)?.nodes.filter(t=>t.kind===`symbol`&&t.file===e.file&&!t.external)??[],l=h.filter(t=>Oe(t.filePath,e.file));return(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`div`,{className:S(`group flex h-7 items-center pr-1 text-[11px] hover:bg-muted`,ie===e.id&&`bg-primary/10 text-primary`),style:{paddingLeft:8+a*12},children:[(0,k.jsx)(`button`,{type:`button`,className:`flex h-6 w-4 shrink-0 items-center justify-center text-muted-foreground`,onClick:()=>te(e),"aria-label":`${n?`Collapse`:`Expand`} ${e.label}`,children:d.has(i)?(0,k.jsx)(t,{className:`h-3 w-3 animate-spin`}):n?(0,k.jsx)(r,{className:`h-3 w-3`}):(0,k.jsx)(b,{className:`h-3 w-3`})}),(0,k.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left`,onClick:()=>m(e),onDoubleClick:()=>ne(e),children:[(0,k.jsx)(o,{className:`h-3.5 w-3.5 shrink-0 text-info`}),l.length>0&&(0,k.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 animate-pulse bg-success`,title:`${l.length} live operation(s)`}),(0,k.jsx)(`span`,{className:`truncate font-mono`,title:e.file,children:e.label}),(0,k.jsx)(`span`,{className:`ml-auto text-[9px] text-muted-foreground`,children:e.symbolCount??0})]}),(0,k.jsx)(`button`,{type:`button`,className:`ml-1 hidden h-5 w-5 items-center justify-center text-muted-foreground hover:text-foreground group-hover:flex`,onClick:()=>ne(e),title:`Open symbol map`,"aria-label":`Open ${e.label} map`,children:(0,k.jsx)(u,{className:`h-3 w-3`})})]}),n&&c.map(e=>(0,k.jsxs)(`button`,{type:`button`,className:S(`flex h-7 w-full items-center gap-1.5 pr-2 text-left text-[10px] hover:bg-muted`,ie===e.id?`bg-primary/10 text-primary`:`text-muted-foreground`),style:{paddingLeft:38+a*12},onClick:()=>re(e),children:[(0,k.jsx)(s,{className:`h-3 w-3 shrink-0 text-success`}),h.some(t=>t.symbol?.id===e.id)&&(0,k.jsx)(g,{className:`h-3 w-3 shrink-0 animate-pulse text-success`}),(0,k.jsx)(`span`,{className:`truncate font-mono`,children:e.label}),e.line&&(0,k.jsxs)(`span`,{className:`ml-auto font-mono text-[8px] opacity-60`,children:[`:`,e.line]})]},e.id))]},e.id)})]})}function Ge(e){let{title:t,subtitle:n,items:i,graph:a,selectedId:o,expanded:s,onToggle:c,onSelect:l}=e;return(0,k.jsxs)(`section`,{className:`border-b py-3`,children:[(0,k.jsxs)(`div`,{className:`mb-2 flex items-end justify-between px-3`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`h3`,{className:`text-[10px] font-bold uppercase tracking-[0.16em]`,children:t}),(0,k.jsx)(`p`,{className:`mt-0.5 text-[9px] text-muted-foreground`,children:n})]}),(0,k.jsx)(`span`,{className:`border bg-muted px-1.5 py-0.5 font-mono text-[9px]`,children:i.length})]}),i.length===0?(0,k.jsx)(`p`,{className:`px-3 py-2 text-[10px] text-muted-foreground`,children:`No relationships in this view.`}):i.map(e=>{let n=`${t}:${e.node.id}`,i=s.has(n),u=[...ye(a,e.node.id,`incoming`),...ye(a,e.node.id,`outgoing`)].filter((e,t,n)=>e.node.id!==o&&n.findIndex(t=>t.node.id===e.node.id)===t).slice(0,8);return(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`div`,{className:`group flex min-h-9 items-center gap-1 px-2 hover:bg-muted/70`,children:[(0,k.jsx)(`button`,{type:`button`,className:`flex h-6 w-5 shrink-0 items-center justify-center text-muted-foreground`,onClick:()=>u.length>0&&c(n),"aria-label":`${i?`Collapse`:`Expand`} relation ${e.node.label}`,children:u.length>0?i?(0,k.jsx)(r,{className:`h-3 w-3`}):(0,k.jsx)(b,{className:`h-3 w-3`}):(0,k.jsx)(`span`,{className:`h-px w-2 bg-border`})}),(0,k.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 py-1 text-left`,onClick:()=>l(e.node),children:[(0,k.jsx)(`span`,{className:`block truncate font-mono text-[10px] font-semibold`,title:e.node.label,children:e.node.label}),(0,k.jsx)(`span`,{className:`block truncate text-[9px] text-muted-foreground`,children:e.node.package??e.node.symbolKind??e.node.kind})]}),(0,k.jsx)(`span`,{className:`border px-1 py-0.5 font-mono text-[8px] text-muted-foreground`,children:e.edge.refType}),(0,k.jsxs)(`span`,{className:`w-5 text-right font-mono text-[9px] text-muted-foreground`,children:[`×`,e.edge.weight]})]}),i&&u.map(e=>(0,k.jsxs)(`button`,{type:`button`,className:`relative flex h-7 w-full items-center gap-2 border-l border-border pl-11 pr-3 text-left text-[9px] text-muted-foreground hover:bg-muted hover:text-foreground`,onClick:()=>l(e.node),children:[(0,k.jsx)(`span`,{className:`absolute left-7 top-1/2 h-px w-3 bg-border`}),(0,k.jsx)(de,{className:`h-3 w-3 shrink-0`}),(0,k.jsx)(`span`,{className:`truncate font-mono`,children:e.node.label}),(0,k.jsx)(`span`,{className:`ml-auto font-mono opacity-70`,children:e.edge.refType})]},`${n}:${e.node.id}`))]},n)})]})}function F({activity:e}){return(0,k.jsx)(`span`,{className:S(`shrink-0 border px-1.5 py-0.5 font-mono text-[8px] font-bold uppercase`,e.type===`delete`?`border-destructive/50 bg-destructive/10 text-destructive`:e.type===`read`?`border-info/50 bg-info/10 text-info`:e.type===`search`||e.type===`index`?`border-primary/50 bg-primary/10 text-primary`:`border-warning/50 bg-warning/10 text-warning`),children:e.filePath.startsWith(`(tool:`)?e.toolName:e.type})}function I({activity:e,onLocate:t,showAgent:r=!1}){let i=e.agentName??e.agent??`External process`,o=`${e.sessionId??`none`}:${e.agentId??i}`;return(0,k.jsxs)(`button`,{type:`button`,className:`group flex w-full items-start gap-2 border-b px-3 py-2 text-left last:border-b-0 hover:bg-muted/70`,onClick:()=>!e.filePath.startsWith(`(`)&&t(e),title:`Locate ${e.filePath}`,children:[r&&(0,k.jsx)(`span`,{className:S(`mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center font-mono text-[8px] font-black`,je(o)),children:Ae(i)}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,k.jsx)(F,{activity:e}),r&&(0,k.jsx)(`span`,{className:`truncate text-[9px] font-semibold`,children:i}),e.status===`active`&&(0,k.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 font-mono text-[8px] font-bold text-success`,children:[(0,k.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse bg-success`}),` LIVE`]}),e.watcherConfirmed&&(0,k.jsx)(n,{className:`ml-auto h-3 w-3 text-success`,"aria-label":`Filesystem confirmed`}),e.attribution===`correlated`&&!e.watcherConfirmed&&(0,k.jsx)(`span`,{className:`ml-auto font-mono text-[7px] uppercase text-warning`,title:`Correlated from the only active tool`,children:`~ correlated`}),e.attribution===`external`&&(0,k.jsx)(`span`,{className:`ml-auto font-mono text-[7px] uppercase text-destructive`,children:`external`})]}),(0,k.jsx)(`div`,{className:`mt-1 truncate font-mono text-[9px] font-semibold`,title:e.filePath,children:Ne(e.filePath)}),(e.symbol||e.line)&&(0,k.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-1 truncate font-mono text-[8px] text-success`,children:[(0,k.jsx)(a,{className:`h-2.5 w-2.5 shrink-0`}),e.symbol?.name??`line ${e.line}`,e.symbol?.kind&&(0,k.jsxs)(`span`,{className:`text-muted-foreground`,children:[`· `,e.symbol.kind]})]}),e.change&&(0,k.jsxs)(`div`,{className:`mt-1 flex items-center gap-1 font-mono text-[8px]`,children:[(0,k.jsxs)(`span`,{className:`border border-success/40 bg-success/10 px-1 text-success`,children:[`+`,e.change.added]}),(0,k.jsxs)(`span`,{className:`border border-destructive/40 bg-destructive/10 px-1 text-destructive`,children:[`−`,e.change.removed]}),e.durationMs!==void 0&&(0,k.jsxs)(`span`,{className:`ml-auto text-muted-foreground`,children:[e.durationMs,`ms`]})]}),e.summary&&e.summary!==e.toolName&&(0,k.jsx)(`div`,{className:`mt-1 line-clamp-2 text-[8px] leading-3 text-muted-foreground`,children:e.summary})]}),!e.filePath.startsWith(`(`)&&(0,k.jsx)(u,{className:`mt-1 h-3 w-3 shrink-0 text-muted-foreground opacity-0 group-hover:opacity-100`})]})}function Ke({presences:e,onLocate:t}){return e.length===0?null:(0,k.jsxs)(`section`,{className:`pointer-events-auto absolute left-3 top-14 z-20 w-[304px] border bg-card/95 shadow-xl backdrop-blur`,children:[(0,k.jsxs)(`div`,{className:`flex h-9 items-center gap-2 border-b px-3`,children:[(0,k.jsx)(g,{className:`h-3.5 w-3.5 animate-pulse text-success`}),(0,k.jsx)(`h2`,{className:`text-[9px] font-black uppercase tracking-[0.18em]`,children:`Live agent operations`}),(0,k.jsxs)(`span`,{className:`ml-auto bg-success px-1.5 py-0.5 font-mono text-[8px] font-bold text-success-foreground`,children:[e.length,` ONLINE`]})]}),(0,k.jsx)(`div`,{className:`max-h-[330px] overflow-y-auto`,children:e.map(e=>(0,k.jsxs)(`div`,{className:`border-b last:border-b-0`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2 bg-muted/35 px-3 py-1.5`,children:[(0,k.jsx)(`span`,{className:S(`flex h-6 w-6 items-center justify-center font-mono text-[8px] font-black`,je(e.key)),children:Ae(e.agentName)}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsx)(`div`,{className:`truncate text-[9px] font-bold`,children:e.agentName}),(0,k.jsxs)(`div`,{className:`truncate font-mono text-[7px] text-muted-foreground`,children:[`session `,e.sessionId.slice(0,12),` · agent `,e.agentId.slice(0,12)]})]}),(0,k.jsxs)(`span`,{className:`font-mono text-[8px] text-success`,children:[e.operations.length,` op`]})]}),e.operations.map(e=>(0,k.jsx)(I,{activity:e,onLocate:t},e.id??`${e.toolUseId}:${e.filePath}`))]},e.key))})]})}function qe({paused:e,followLive:t,agentFilter:n,agents:r,onTogglePaused:i,onToggleFollow:o,onAgentFilter:s}){return(0,k.jsxs)(`div`,{className:`pointer-events-auto absolute right-3 top-14 z-20 flex h-9 items-center border bg-card/95 shadow-lg backdrop-blur`,children:[(0,k.jsxs)(`button`,{type:`button`,className:S(`flex h-full items-center gap-1.5 border-r px-2.5 text-[8px] font-bold uppercase tracking-wider`,t?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-muted`),onClick:o,title:`Automatically enter the file/function used by the newest visible agent`,children:[(0,k.jsx)(a,{className:`h-3 w-3`}),` Follow`]}),(0,k.jsxs)(`button`,{type:`button`,className:S(`flex h-full items-center gap-1.5 border-r px-2.5 text-[8px] font-bold uppercase tracking-wider`,e?`bg-warning text-warning-foreground`:`text-success hover:bg-success/10`),onClick:i,title:e?`Resume the live telemetry stream`:`Freeze the current telemetry frame`,children:[e?(0,k.jsx)(se,{className:`h-3 w-3`}):(0,k.jsx)(_,{className:`h-3 w-3`}),e?`Resume`:`Live`]}),(0,k.jsxs)(`label`,{className:`flex h-full items-center gap-1.5 px-2 text-[8px] uppercase text-muted-foreground`,children:[`Agent`,(0,k.jsxs)(`select`,{"aria-label":`Filter CodeMap by agent and session`,className:`h-6 max-w-[170px] border bg-background px-1.5 font-mono text-[8px] text-foreground outline-none focus:border-primary`,value:n,onChange:e=>s(e.target.value),children:[(0,k.jsx)(`option`,{value:`all`,children:`ALL AGENTS`}),r.map(e=>(0,k.jsxs)(`option`,{value:e.key,children:[e.agentName,` · `,e.sessionId.slice(0,10)]},e.key))]})]})]})}function Je(){let[e,n]=(0,w.useState)({level:`packages`}),a=T(e),[o,s]=(0,w.useState)(Te),[l,p]=(0,w.useState)(!0),[m,se]=(0,w.useState)(null),[_,v]=(0,w.useState)(null),[y,me]=(0,w.useState)(`layers`),[x,xe]=(0,w.useState)(`smart`),[E,Se]=(0,w.useState)(`all`),[O,De]=(0,w.useState)(``),[j,M]=(0,w.useState)(new Set),[je,Ne]=(0,w.useState)(new Set),[Pe,Ie]=(0,w.useState)(new Set),[Re,ze]=(0,w.useState)(new Set),[P,He]=(0,w.useState)(new Set),[F,Je]=(0,w.useState)(0),[L,Ye]=(0,w.useState)(null),[Xe,Ze]=(0,w.useState)(!1),[R,Qe]=(0,w.useState)(`all`),[z,$e]=(0,w.useState)(null),[et,tt]=(0,w.useState)(null),[nt,rt]=(0,w.useState)(0),B=(0,w.useRef)(new Map),V=(0,w.useRef)(null),H=(0,w.useRef)(null),it=(0,w.useRef)(``),U=ge(),W=(0,w.useMemo)(()=>[...U.activeOperations.values()].flat(),[U.activeOperations]),at=(0,w.useMemo)(()=>[...U.pulses.keys()].map(e=>U.history.get(e)?.[0]).filter(e=>!!e),[U.history,U.pulses]),G=(0,w.useMemo)(()=>{let e=[];for(let t of U.history.values())e.push(...t.slice(0,16));return e.sort((e,t)=>t.timestamp-e.timestamp).slice(0,16)},[U.history]),ot=(0,w.useMemo)(()=>_e([...W,...G]),[W,G]),K=(0,w.useMemo)(()=>{let e=z??W;return R===`all`?e:e.filter(e=>C(e)===R)},[W,R,z]),st=(0,w.useMemo)(()=>{let e=et??G;return R===`all`?e:e.filter(e=>C(e)===R)},[R,et,G]),ct=(0,w.useMemo)(()=>_e(K),[K]),[lt,ut,dt]=ce([]),[ft,pt,mt]=ue([]),{fitView:ht}=ae(),q=(0,w.useCallback)(async(e,t=!1)=>{let n=T(e),r=B.current.get(n);if(r&&!t)return r;let i=await fetch(ve(e));if(!i.ok){let e=await i.json().catch(()=>({error:i.statusText}));throw Error(e.error??`HTTP ${i.status}`)}let a=await i.json();return B.current.set(n,a),Je(e=>e+1),a},[]);(0,w.useEffect)(()=>{let t=!1;return p(!0),se(null),q(e).then(e=>{if(t)return;s(e);let n=V.current;V.current=null,v(n&&e.nodes.some(e=>e.id===n)?n:null),p(!1)}).catch(e=>{t||(se(e instanceof Error?e.message:String(e)),s(Te),p(!1))}),()=>{t=!0}},[a,q]);let J=(0,w.useCallback)((e,t)=>{if(V.current=t??null,T(e)===a){v(t??null),V.current=null;return}n(e)},[a]),Y=(0,w.useCallback)(async e=>{let t=T(e);if(!(B.current.has(t)||P.has(t))){He(e=>new Set(e).add(t));try{await q(e)}finally{He(e=>{let n=new Set(e);return n.delete(t),n})}}},[q,P]);(0,w.useEffect)(()=>{let e=!1;for(let t of W)t.symbol||!t.toolUseId||t.filePath.startsWith(`(`)||q({level:`symbols`,file:t.filePath}).then(n=>{if(e)return;let r=Fe(t,n.nodes);r&&U.resolveActivitySymbol(t.toolUseId,t.filePath,{id:r.id,name:r.label,...r.symbolKind?{kind:r.symbolKind}:{},...r.line?{line:r.line}:{}})}).catch(()=>void 0);return()=>{e=!0}},[W,U.resolveActivitySymbol,q]);let X=(0,w.useMemo)(()=>({nodes:o.nodes,edges:E===`all`?o.edges:o.edges.filter(e=>e.refType===E)}),[o,E]),Z=o.nodes.find(e=>e.id===_),Q=(0,w.useMemo)(()=>Le(X,_,x),[x,X,_]),gt=(0,w.useMemo)(()=>_?be(X,_):new Set,[X,_]),{incomingCounts:_t,outgoingCounts:vt}=(0,w.useMemo)(()=>{let e=new Map,t=new Map;for(let n of X.edges)t.set(n.source,(t.get(n.source)??0)+1),e.set(n.target,(e.get(n.target)??0)+1);return{incomingCounts:e,outgoingCounts:t}},[X]),yt=y===`orbit`?_??void 0:void 0,bt=(0,w.useMemo)(()=>Ce(Q,y,yt),[Q,y,yt]),xt=(0,w.useMemo)(()=>[a,y,y===`orbit`?_??``:``,Q.nodes.map(e=>e.id).join(``),Q.edges.map(e=>`${e.source}>${e.target}:${e.refType}`).join(``)].join(``),[Q,a,y,_]),St=(0,w.useCallback)(e=>{v(e.id),ze(new Set)},[]),Ct=(0,w.useCallback)(e=>{e.kind===`package`&&J({level:`files`,package:e.package??e.label}),e.kind===`file`&&e.file&&J({level:`symbols`,file:e.file,package:e.package})},[J]);(0,w.useEffect)(()=>{let e=new Set(bt.filter(({node:e})=>K.some(t=>N(t,e))).map(({node:e})=>e.id)),t=bt.map(({node:e,position:t})=>{let n=K.filter(t=>N(t,e)),r=n[0]??at.find(t=>N(t,e));return{id:e.id,type:`codemap`,position:t,data:{graphNode:e,selected:e.id===_,dimmed:!!_&&!gt.has(e.id),incoming:_t.get(e.id)??0,outgoing:vt.get(e.id)??0,isActive:!!r,...r?{activityType:r.type}:{},activeOperations:n,onSelect:St,onOpen:Ct,onShowHistory:Ye}}});ut(e=>Ve(e,t));let n=Q.edges.map((t,n)=>{let r=!!_&&(t.source===_||t.target===_),i=e.has(t.source)||e.has(t.target),a=Ee[t.refType]??`hsl(var(--muted-foreground))`;return{id:`edge:${t.source}:${t.target}:${n}`,source:t.source,target:t.target,type:`smoothstep`,animated:i,label:r?`${t.refType}${t.weight>1?` ×${t.weight}`:``}`:void 0,markerEnd:{type:h.ArrowClosed,color:a,width:14,height:14},style:{stroke:a,strokeWidth:i?Math.min(2.5+Math.log2(t.weight+1)*.65,5):r?Math.min(1.25+Math.log2(t.weight+1)*.65,4):1,opacity:i?1:_?r?.88:.08:.52},labelStyle:{fontSize:9,fontFamily:`var(--font-mono)`,fill:`hsl(var(--muted-foreground))`},labelBgStyle:{fill:`hsl(var(--card))`,fillOpacity:.92},labelBgPadding:[4,2],zIndex:i?4:r?2:0,data:{renderKey:`${t.refType}:${t.weight}:${_?r?`focused`:`dimmed`:`idle`}:${i?`live`:`still`}`}}}),r=new Map,i=new Set(K.map(C));for(let e of[...st].sort((e,t)=>e.timestamp-t.timestamp)){let t=C(e);r.set(t,[...r.get(t)??[],e])}let a=[];for(let[e,t]of r){let n=i.has(e),r=t.map(e=>({activity:e,node:Q.nodes.find(t=>N(e,t))})).filter(e=>!!e.node).filter((e,t,n)=>t===0||e.node.id!==n[t-1]?.node.id),o=Me(e);for(let t=1;t<r.length;t++){let i=r[t-1],s=r[t];a.push({id:`trail:${e}:${i.activity.timestamp}:${s.activity.timestamp}`,source:i.node.id,target:s.node.id,type:`smoothstep`,animated:n,label:t===r.length-1?`${Ae(s.activity.agentName??s.activity.agent??`agent`)} TRAIL`:void 0,markerEnd:{type:h.ArrowClosed,color:o,width:13,height:13},style:{stroke:o,strokeWidth:2.5,strokeDasharray:`7 5`,opacity:.9},labelStyle:{fontSize:8,fontWeight:700,fill:o},labelBgStyle:{fill:`hsl(var(--card))`,fillOpacity:.94},labelBgPadding:[4,2],zIndex:6,data:{renderKey:`${o}:${t===r.length-1?`label`:`plain`}:${n?`live`:`still`}`}})}}if(rt(a.length),pt(e=>Ue(e,[...n,...a])),it.current===xt)return;let o=window.setTimeout(()=>{it.current=xt,ht({padding:.2,duration:240,maxZoom:1.25})},20);return()=>window.clearTimeout(o)},[Q,_,K,st,xt,gt,ht,Ct,St,_t,vt,bt,at,pt,ut]),(0,w.useEffect)(()=>{let e=window.setInterval(()=>{U._sweep()},2e3);return()=>window.clearInterval(e)},[U._sweep]);let wt=B.current.get(`packages`)??(e.level===`packages`?o:Te),Tt=(0,w.useCallback)(e=>B.current.get(T({level:`files`,package:e})),[F]),Et=(0,w.useCallback)(e=>B.current.get(T({level:`symbols`,file:e})),[F]),$=(0,w.useCallback)(e=>{let t=e.filePath,n=ke(e.filePath),r=`file:${e.filePath}`;for(let i of B.current.values()){let a=i.nodes.find(t=>t.kind===`file`&&!t.external&&Oe(t.file,e.filePath));if(a){t=a.file??t,n=a.package??n,r=a.id;break}}if(e.symbol){J({level:`symbols`,file:t,package:n},e.symbol.id);return}J({level:`files`,package:n},r)},[J]);(0,w.useEffect)(()=>{if(!Xe||z)return;let e=[...K].filter(e=>!e.filePath.startsWith(`(`)).sort((e,t)=>t.timestamp-e.timestamp)[0];if(!e)return;let t=`${e.id??e.toolUseId}:${e.filePath}:${e.symbol?.id??`file`}`;H.current!==t&&(H.current=t,$(e))},[K,Xe,$,z]);let Dt=(0,w.useCallback)(()=>{if(z){$e(null),tt(null);return}$e([...W]),tt([...G])},[W,z,G]),Ot=(0,w.useCallback)(e=>{let t=e.package??e.label,n=!j.has(t);M(e=>{let r=new Set(e);return n?r.add(t):r.delete(t),r}),n&&Y({level:`files`,package:t}).then(()=>{let e=B.current.get(T({level:`files`,package:t})),n=e?we(e.nodes):void 0;n?.directories.length===1&&n.directories[0]&&Ne(e=>new Set(e).add(`${t}:${n.directories[0].path}`))}).catch(()=>void 0)},[Y,j]),kt=(0,w.useCallback)(e=>{if(!e.file)return;let t=!Pe.has(e.file);Ie(n=>{let r=new Set(n);return t?r.add(e.file):r.delete(e.file),r}),t&&Y({level:`symbols`,file:e.file,package:e.package}).catch(()=>void 0)},[Y,Pe]),At=(0,w.useCallback)(e=>{Ne(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),jt=(0,w.useCallback)(e=>{J({level:`files`,package:e.package??`(root)`},e.id)},[J]),Mt=(0,w.useCallback)(e=>{e.file&&J({level:`symbols`,file:e.file,package:e.package},e.id)},[J]),Nt=(0,w.useMemo)(()=>{let e=O.trim().toLocaleLowerCase();if(!e)return[];let t=new Map;for(let n of B.current.values())for(let r of n.nodes)`${r.label} ${r.file??``} ${r.signature??``} ${r.package??``}`.toLocaleLowerCase().includes(e)&&t.set(r.id,r);return[...t.values()].sort((e,t)=>e.kind.localeCompare(t.kind)||e.label.localeCompare(t.label)).slice(0,80)},[O,F]),Pt=(0,w.useCallback)(e=>{e.kind===`package`?J({level:`packages`},e.id):e.kind===`file`?J({level:`files`,package:e.package??`(root)`},e.id):e.file&&J({level:`symbols`,file:e.file,package:e.package},e.id)},[J]),{incoming:Ft,outgoing:It}=(0,w.useMemo)(()=>({incoming:Z?ye(X,Z.id,`incoming`):[],outgoing:Z?ye(X,Z.id,`outgoing`):[]}),[X,Z]),{edgeWeight:Lt,connectedNodeCount:Rt}=(0,w.useMemo)(()=>{let e=0,t=new Set;for(let n of X.edges)e+=n.weight,t.add(n.source),t.add(n.target);return{edgeWeight:e,connectedNodeCount:t.size}},[X]),zt=Z?K.filter(e=>N(e,Z)):[],Bt=L?U.getActivityForFile(L):[];return(0,k.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-background`,children:[(0,k.jsxs)(`header`,{className:`flex h-[62px] shrink-0 items-center gap-4 border-b bg-card px-4`,children:[(0,k.jsxs)(`div`,{className:`flex min-w-[220px] items-center gap-3`,children:[(0,k.jsx)(`span`,{className:`flex h-9 w-9 items-center justify-center border border-primary bg-primary/10 text-primary`,children:(0,k.jsx)(i,{className:`h-4 w-4`})}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`h1`,{className:`font-display text-sm font-semibold tracking-tight`,children:`Code Atlas`}),(0,k.jsx)(`p`,{className:`text-[9px] uppercase tracking-[0.18em] text-muted-foreground`,children:`Architecture intelligence`})]})]}),(0,k.jsxs)(`nav`,{className:`flex min-w-0 flex-1 items-center gap-1 font-mono text-[10px]`,"aria-label":`Code map breadcrumb`,children:[e.level!==`packages`&&(0,k.jsx)(`button`,{type:`button`,className:`mr-1 flex h-7 w-7 items-center justify-center border text-muted-foreground hover:bg-muted`,onClick:()=>{e.level===`symbols`?J({level:`files`,package:e.package??`(root)`}):J({level:`packages`})},"aria-label":`Back`,children:(0,k.jsx)(ee,{className:`h-3.5 w-3.5`})}),(0,k.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1.5 px-1.5 py-1 text-muted-foreground hover:text-foreground`,onClick:()=>J({level:`packages`}),children:[(0,k.jsx)(ne,{className:`h-3 w-3`}),` workspace`]}),e.level!==`packages`&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(b,{className:`h-3 w-3 text-muted-foreground`}),(0,k.jsx)(`button`,{type:`button`,className:`max-w-[220px] truncate px-1.5 py-1 hover:text-primary`,onClick:()=>J({level:`files`,package:e.package??`(root)`}),children:e.package??`(root)`})]}),e.level===`symbols`&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(b,{className:`h-3 w-3 text-muted-foreground`}),(0,k.jsx)(`span`,{className:`truncate px-1.5 py-1 text-primary`,children:D({id:``,label:e.file,kind:`file`,file:e.file,package:e.package})})]})]}),(0,k.jsxs)(`div`,{className:`hidden items-center gap-5 xl:flex`,children:[(0,k.jsxs)(`div`,{className:S(`flex h-8 items-center gap-2 border px-2.5`,ct.length>0?`border-success/50 bg-success/10 text-success`:`text-muted-foreground`),children:[(0,k.jsx)(g,{className:S(`h-3 w-3`,ct.length>0&&`animate-pulse`)}),(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`div`,{className:`font-mono text-[10px] font-bold`,children:[ct.length,` LIVE`]}),(0,k.jsx)(`div`,{className:`text-[7px] uppercase tracking-wider`,children:`agents`})]})]}),(0,k.jsxs)(`div`,{className:`text-right`,children:[(0,k.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:o.nodes.length}),(0,k.jsx)(`div`,{className:`text-[8px] uppercase tracking-wider text-muted-foreground`,children:`nodes`})]}),(0,k.jsxs)(`div`,{className:`text-right`,children:[(0,k.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:o.edges.length}),(0,k.jsx)(`div`,{className:`text-[8px] uppercase tracking-wider text-muted-foreground`,children:`links`})]}),(0,k.jsxs)(`div`,{className:`text-right`,children:[(0,k.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:Lt}),(0,k.jsx)(`div`,{className:`text-[8px] uppercase tracking-wider text-muted-foreground`,children:`references`})]}),(0,k.jsxs)(`div`,{className:`text-right`,children:[(0,k.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:Rt}),(0,k.jsx)(`div`,{className:`text-[8px] uppercase tracking-wider text-muted-foreground`,children:`connected`})]})]})]}),(0,k.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,k.jsxs)(`aside`,{className:`flex w-[286px] shrink-0 flex-col border-r bg-card/70`,children:[(0,k.jsxs)(`div`,{className:`border-b p-3`,children:[(0,k.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,k.jsx)(`h2`,{className:`text-[10px] font-bold uppercase tracking-[0.18em]`,children:`Code tree`}),(0,k.jsxs)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:[wt.nodes.length,` roots`]})]}),(0,k.jsxs)(`label`,{className:`flex h-8 items-center gap-2 border bg-background px-2 focus-within:border-primary`,children:[(0,k.jsx)(fe,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,k.jsx)(`input`,{className:`min-w-0 flex-1 bg-transparent font-mono text-[10px] outline-none placeholder:text-muted-foreground`,value:O,onChange:e=>De(e.target.value),placeholder:`Find package, file, symbol…`}),O&&(0,k.jsx)(`button`,{type:`button`,onClick:()=>De(``),"aria-label":`Clear search`,children:(0,k.jsx)(le,{className:`h-3 w-3 text-muted-foreground`})})]})]}),(0,k.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-2`,children:O.trim()?(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`div`,{className:`px-3 pb-2 text-[9px] text-muted-foreground`,children:[Nt.length,` loaded-map results`]}),Nt.map(e=>{let t=A[e.kind].icon;return(0,k.jsxs)(`button`,{type:`button`,className:`flex min-h-8 w-full items-center gap-2 px-3 py-1 text-left hover:bg-muted`,onClick:()=>Pt(e),children:[(0,k.jsx)(t,{className:S(`h-3.5 w-3.5 shrink-0`,e.kind===`package`?`text-primary`:e.kind===`file`?`text-info`:`text-success`)}),(0,k.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,k.jsx)(`span`,{className:`block truncate font-mono text-[10px]`,children:e.label}),(0,k.jsx)(`span`,{className:`block truncate text-[8px] text-muted-foreground`,children:e.file??e.package??e.symbolKind})]}),(0,k.jsx)(`span`,{className:`text-[8px] uppercase text-muted-foreground`,children:e.kind.slice(0,3)})]},e.id)}),Nt.length===0&&(0,k.jsxs)(`p`,{className:`px-3 py-8 text-center text-[10px] text-muted-foreground`,children:[`No match in loaded branches.`,(0,k.jsx)(`br`,{}),`Expand a package to search its files.`]})]}):wt.nodes.map(e=>{let n=e.package??e.label,i=j.has(n),a=T({level:`files`,package:n}),o=Tt(n),s=o?we(o.nodes):void 0;return(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`div`,{className:S(`group flex h-8 items-center px-2 hover:bg-muted`,_===e.id&&`bg-primary/10 text-primary`),children:[(0,k.jsx)(`button`,{type:`button`,className:`flex h-6 w-5 items-center justify-center text-muted-foreground`,onClick:()=>Ot(e),"aria-label":`${i?`Collapse`:`Expand`} ${n}`,children:P.has(a)?(0,k.jsx)(t,{className:`h-3 w-3 animate-spin`}):i?(0,k.jsx)(r,{className:`h-3 w-3`}):(0,k.jsx)(b,{className:`h-3 w-3`})}),(0,k.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-2 text-left`,onClick:()=>J({level:`packages`},e.id),onDoubleClick:()=>J({level:`files`,package:n}),children:[(0,k.jsx)(he,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,k.jsx)(`span`,{className:`truncate font-mono text-[10px] font-semibold`,children:e.label}),(0,k.jsx)(`span`,{className:`ml-auto text-[9px] text-muted-foreground`,children:e.fileCount??0})]}),(0,k.jsx)(`button`,{type:`button`,className:`ml-1 hidden h-5 w-5 items-center justify-center text-muted-foreground hover:text-foreground group-hover:flex`,onClick:()=>J({level:`files`,package:n}),title:`Open file map`,"aria-label":`Open ${n} map`,children:(0,k.jsx)(u,{className:`h-3 w-3`})})]}),i&&s&&(0,k.jsx)(We,{directory:s,packageName:n,depth:1,expandedDirectories:je,expandedFiles:Pe,loadingBranches:P,graphForFile:Et,onToggleDirectory:At,onToggleFile:kt,onSelectFile:jt,onOpenFile:Ct,onSelectSymbol:Mt,selectedId:_,activeOperations:K})]},e.id)})}),(0,k.jsxs)(`div`,{className:`border-t px-3 py-2 text-[9px] leading-relaxed text-muted-foreground`,children:[`Click to focus · double-click to enter`,(0,k.jsx)(`br`,{}),`Branches stay open while the map changes`]})]}),(0,k.jsxs)(`main`,{className:`relative min-w-0 flex-1 bg-[radial-gradient(circle_at_50%_0%,hsl(var(--primary)/0.055),transparent_38%)]`,children:[(0,k.jsxs)(`div`,{className:`absolute left-3 right-3 top-3 z-10 flex items-center gap-2 pointer-events-none`,children:[(0,k.jsxs)(`div`,{className:`pointer-events-auto flex border bg-card/95 shadow-md backdrop-blur`,children:[(0,k.jsxs)(`button`,{type:`button`,className:S(`flex h-8 items-center gap-1.5 border-r px-2.5 text-[9px] font-semibold uppercase tracking-wider`,y===`layers`?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-muted`),onClick:()=>me(`layers`),children:[(0,k.jsx)(f,{className:`h-3 w-3`}),` Layers`]}),(0,k.jsxs)(`button`,{type:`button`,className:S(`flex h-8 items-center gap-1.5 px-2.5 text-[9px] font-semibold uppercase tracking-wider`,y===`orbit`?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-muted`),onClick:()=>me(`orbit`),children:[(0,k.jsx)(c,{className:`h-3 w-3`}),` Relations`]})]}),(0,k.jsxs)(`div`,{className:`pointer-events-auto flex border bg-card/95 shadow-md backdrop-blur`,children:[(0,k.jsxs)(`button`,{type:`button`,className:S(`h-8 border-r px-2.5 font-mono text-[9px] font-bold`,x===`smart`?`bg-success text-success-foreground`:`text-muted-foreground hover:bg-muted`),onClick:()=>xe(`smart`),title:`Keep the full tree, show the strongest relations and selected neighbourhood`,children:[`SMART `,Q.nodes.length,`/`,o.nodes.length]}),(0,k.jsx)(`button`,{type:`button`,className:S(`h-8 px-2.5 font-mono text-[9px] font-bold`,x===`all`?`bg-foreground text-background`:`text-muted-foreground hover:bg-muted`),onClick:()=>xe(`all`),title:`Render every node and relation in this scope`,children:`ALL`})]}),(0,k.jsx)(`div`,{className:`pointer-events-auto ml-auto flex max-w-[60%] overflow-x-auto border bg-card/95 shadow-md backdrop-blur`,children:[`all`,`import`,`call`,`type_ref`,`inherit`,`implement`].map(e=>(0,k.jsx)(`button`,{type:`button`,className:S(`h-8 whitespace-nowrap border-r px-2.5 font-mono text-[9px] last:border-r-0`,E===e?`bg-foreground text-background`:`text-muted-foreground hover:bg-muted`),onClick:()=>Se(e),children:e===`all`?`ALL LINKS`:e.replace(`_`,` `).toUpperCase()},e))})]}),(0,k.jsx)(Ke,{presences:ct,onLocate:$}),(0,k.jsx)(qe,{paused:z!==null,followLive:Xe,agentFilter:R,agents:ot,onTogglePaused:Dt,onToggleFollow:()=>{H.current=null,Ze(e=>!e)},onAgentFilter:e=>{H.current=null,Qe(e)}}),l&&(0,k.jsxs)(`div`,{className:`absolute inset-0 z-20 flex flex-col items-center justify-center gap-3 bg-background/75 backdrop-blur-sm`,children:[(0,k.jsx)(t,{className:`h-7 w-7 animate-spin text-primary`}),(0,k.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-widest text-muted-foreground`,children:`Mapping relationships`})]}),m&&!l&&(0,k.jsxs)(`div`,{className:`absolute inset-0 z-20 flex flex-col items-center justify-center gap-3 p-8 text-center`,children:[(0,k.jsx)(i,{className:`h-10 w-10 text-destructive`}),(0,k.jsx)(`p`,{className:`font-mono text-sm text-destructive`,children:m}),(0,k.jsxs)(`p`,{className:`max-w-md text-xs text-muted-foreground`,children:[`The map needs a codebase index. Run`,` `,(0,k.jsx)(`code`,{className:`border bg-muted px-1.5 py-0.5`,children:`codebase-index`}),` once, then reopen this view.`]})]}),!l&&!m&&o.nodes.length===0&&(0,k.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-2 text-muted-foreground`,children:[(0,k.jsx)(i,{className:`h-8 w-8 opacity-40`}),(0,k.jsx)(`p`,{className:`text-xs`,children:`No indexed nodes at this level.`})]}),!l&&!m&&o.nodes.length>1&&o.edges.length===0&&(0,k.jsxs)(`div`,{className:`pointer-events-none absolute left-1/2 top-14 z-10 -translate-x-1/2 border border-warning/40 bg-warning/10 px-3 py-2 text-center shadow backdrop-blur`,children:[(0,k.jsx)(`div`,{className:`font-mono text-[9px] font-bold uppercase tracking-wider text-warning`,children:`No resolved relations in this scope`}),(0,k.jsx)(`div`,{className:`mt-0.5 text-[8px] text-muted-foreground`,children:`The upgraded index will rebuild and resolve call/import/type links automatically.`})]}),!m&&o.nodes.length>0&&(0,k.jsxs)(ie,{nodes:lt,edges:ft,onNodesChange:dt,onEdgesChange:mt,nodeTypes:Be,nodesConnectable:!1,nodesDraggable:!1,edgesFocusable:!1,elementsSelectable:!1,onlyRenderVisibleElements:Q.nodes.length>80,minZoom:.08,maxZoom:2.2,proOptions:{hideAttribution:!0},children:[(0,k.jsx)(pe,{variant:oe.Dots,gap:22,size:1,color:`hsl(var(--muted-foreground))`,className:`!opacity-25`}),(0,k.jsx)(te,{position:`bottom-left`,showInteractive:!1,className:`!border !border-border !bg-card !shadow-md [&>button]:!border-border [&>button]:!bg-card [&>button]:!fill-foreground`}),(0,k.jsx)(re,{position:`bottom-right`,pannable:!0,zoomable:!0,className:`!h-[112px] !w-[180px] !border !border-border !bg-card !shadow-md`,maskColor:`hsl(var(--background) / 0.72)`,nodeColor:e=>{let t=e.data?.graphNode.kind;return t===`package`?`hsl(var(--primary))`:t===`file`?`hsl(var(--info))`:`hsl(var(--success))`}})]}),(0,k.jsxs)(`div`,{className:`pointer-events-none absolute bottom-3 left-1/2 z-10 flex -translate-x-1/2 items-center gap-3 border bg-card/90 px-3 py-1.5 font-mono text-[8px] text-muted-foreground shadow backdrop-blur`,children:[Object.entries(Ee).map(([e,t])=>(0,k.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,k.jsx)(`span`,{className:`h-0.5 w-3`,style:{backgroundColor:t}}),e.replace(`_`,` `)]},e)),(0,k.jsxs)(`span`,{className:`flex items-center gap-1 text-primary`,"data-testid":`agent-trail-count`,children:[(0,k.jsx)(`span`,{className:`w-4 border-t-2 border-dashed border-primary`}),`agent trail`,nt>0?` ×${nt}`:``]})]})]}),(0,k.jsxs)(`aside`,{className:`flex w-[326px] shrink-0 flex-col border-l bg-card/80`,children:[(0,k.jsxs)(`div`,{className:`flex h-10 items-center justify-between border-b px-3`,children:[(0,k.jsx)(`h2`,{className:`text-[10px] font-bold uppercase tracking-[0.18em]`,children:`Relation inspector`}),Z&&(0,k.jsx)(`button`,{type:`button`,className:`text-muted-foreground hover:text-foreground`,onClick:()=>v(null),"aria-label":`Clear selection`,children:(0,k.jsx)(le,{className:`h-3.5 w-3.5`})})]}),Z?(0,k.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[(0,k.jsxs)(`div`,{className:`border-b bg-muted/25 p-3`,children:[(0,k.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,k.jsx)(`span`,{className:S(`flex h-8 w-8 items-center justify-center border`,A[Z.kind].iconStyle),children:(()=>{let e=A[Z.kind].icon;return(0,k.jsx)(e,{className:`h-4 w-4`})})()}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsxs)(`div`,{className:`text-[8px] font-bold uppercase tracking-[0.18em] text-muted-foreground`,children:[Z.external?`external `:``,Z.kind]}),(0,k.jsx)(`div`,{className:`truncate font-mono text-xs font-semibold`,title:Z.label,children:Z.label})]})]}),(0,k.jsx)(`div`,{className:`break-all font-mono text-[9px] leading-relaxed text-muted-foreground`,children:Z.file?D(Z):Z.package}),Z.signature&&(0,k.jsx)(`pre`,{className:`mt-3 overflow-x-auto border bg-background p-2 font-mono text-[9px] leading-relaxed text-foreground`,children:Z.signature}),(0,k.jsxs)(`div`,{className:`mt-3 grid grid-cols-3 border`,children:[(0,k.jsxs)(`div`,{className:`border-r p-2 text-center`,children:[(0,k.jsx)(`div`,{className:`font-mono text-sm font-semibold text-info`,children:Ft.length}),(0,k.jsx)(`div`,{className:`text-[8px] uppercase text-muted-foreground`,children:`incoming`})]}),(0,k.jsxs)(`div`,{className:`border-r p-2 text-center`,children:[(0,k.jsx)(`div`,{className:`font-mono text-sm font-semibold text-primary`,children:It.length}),(0,k.jsx)(`div`,{className:`text-[8px] uppercase text-muted-foreground`,children:`outgoing`})]}),(0,k.jsxs)(`div`,{className:`p-2 text-center`,children:[(0,k.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:Z.symbolCount??Z.fileCount??Z.line??`—`}),(0,k.jsx)(`div`,{className:`text-[8px] uppercase text-muted-foreground`,children:Z.kind===`package`?`files`:Z.kind===`file`?`symbols`:`line`})]})]}),(0,k.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[Z.kind!==`symbol`&&(0,k.jsxs)(`button`,{type:`button`,className:`flex h-7 flex-1 items-center justify-center gap-1.5 border bg-foreground text-[9px] font-semibold uppercase tracking-wider text-background hover:opacity-90`,onClick:()=>Ct(Z),children:[(0,k.jsx)(u,{className:`h-3 w-3`}),` Open`,` `,Z.kind===`package`?`files`:`symbols`]}),Z.file&&(0,k.jsxs)(`button`,{type:`button`,className:`flex h-7 items-center justify-center gap-1.5 border px-2 text-[9px] uppercase text-muted-foreground hover:bg-muted`,onClick:()=>Ye(Z.file),children:[(0,k.jsx)(d,{className:`h-3 w-3`}),` Activity`]})]})]}),zt.length>0&&(0,k.jsxs)(`section`,{className:`border-b bg-success/5 py-2`,children:[(0,k.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 px-3`,children:[(0,k.jsx)(g,{className:`h-3 w-3 animate-pulse text-success`}),(0,k.jsx)(`h3`,{className:`text-[9px] font-bold uppercase tracking-[0.16em]`,children:`Agents on this node`}),(0,k.jsx)(`span`,{className:`ml-auto font-mono text-[9px] text-success`,children:zt.length})]}),zt.map(e=>(0,k.jsx)(I,{activity:e,onLocate:$,showAgent:!0},e.id??`${e.toolUseId}:${e.filePath}`))]}),(0,k.jsx)(Ge,{title:`Incoming`,subtitle:`Who depends on this`,items:Ft,graph:X,selectedId:Z.id,expanded:Re,onToggle:e=>ze(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),onSelect:St}),(0,k.jsx)(Ge,{title:`Outgoing`,subtitle:`What this depends on`,items:It,graph:X,selectedId:Z.id,expanded:Re,onToggle:e=>ze(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),onSelect:St})]}):(0,k.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[K.length>0&&(0,k.jsxs)(`section`,{className:`border-b`,children:[(0,k.jsxs)(`div`,{className:`flex h-9 items-center gap-2 border-b bg-success/5 px-3`,children:[(0,k.jsx)(g,{className:`h-3 w-3 animate-pulse text-success`}),(0,k.jsx)(`h3`,{className:`text-[9px] font-bold uppercase tracking-[0.16em]`,children:`Active now`}),(0,k.jsx)(`span`,{className:`ml-auto font-mono text-[9px] text-success`,children:K.length})]}),K.map(e=>(0,k.jsx)(I,{activity:e,onLocate:$,showAgent:!0},e.id??`${e.toolUseId}:${e.filePath}`))]}),(0,k.jsxs)(`section`,{children:[(0,k.jsxs)(`div`,{className:`flex h-9 items-center gap-2 border-b px-3`,children:[(0,k.jsx)(d,{className:`h-3 w-3 text-muted-foreground`}),(0,k.jsx)(`h3`,{className:`text-[9px] font-bold uppercase tracking-[0.16em]`,children:`Event stream`}),(0,k.jsxs)(`span`,{className:`ml-auto font-mono text-[8px] text-muted-foreground`,children:[U.totalCount,` total`]})]}),st.length>0?st.map((e,t)=>(0,k.jsx)(I,{activity:e,onLocate:$,showAgent:!0},e.id??`${e.timestamp}:${t}`)):(0,k.jsxs)(`div`,{className:`flex flex-col items-center justify-center px-7 py-16 text-center`,children:[(0,k.jsx)(`span`,{className:`mb-4 flex h-12 w-12 items-center justify-center border bg-muted text-muted-foreground`,children:(0,k.jsx)(de,{className:`h-5 w-5`})}),(0,k.jsx)(`h3`,{className:`text-xs font-semibold`,children:`Select a node or wait for an agent`}),(0,k.jsx)(`p`,{className:`mt-2 text-[10px] leading-relaxed text-muted-foreground`,children:`Relations appear on selection. Tool calls and external filesystem touches stream here live.`})]})]})]})]})]}),L&&(0,k.jsxs)(`div`,{className:`absolute right-0 top-0 z-50 flex h-full w-[390px] max-w-[90%] flex-col border-l bg-card shadow-2xl`,children:[(0,k.jsxs)(`div`,{className:`flex h-12 items-center justify-between border-b px-4`,children:[(0,k.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,k.jsx)(d,{className:`h-4 w-4 shrink-0 text-warning`}),(0,k.jsx)(`span`,{className:`truncate font-mono text-[11px] font-semibold`,title:L,children:L})]}),(0,k.jsx)(`button`,{type:`button`,onClick:()=>Ye(null),className:`flex h-7 w-7 items-center justify-center border text-muted-foreground hover:bg-muted`,"aria-label":`Close activity`,children:(0,k.jsx)(le,{className:`h-3.5 w-3.5`})})]}),(0,k.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-3`,children:Bt.length===0?(0,k.jsx)(`p`,{className:`py-12 text-center text-[10px] text-muted-foreground`,children:`No activity recorded for this file yet.`}):Bt.map((e,t)=>(0,k.jsxs)(`div`,{className:`mb-1 flex items-start gap-2 border p-2 text-[10px]`,children:[(0,k.jsx)(`span`,{className:S(`border px-1.5 py-0.5 font-mono text-[8px] font-bold uppercase`,e.type===`delete`?`border-destructive/40 text-destructive`:e.type===`read`?`border-info/40 text-info`:`border-warning/40 text-warning`),children:e.type}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsx)(`div`,{className:`font-mono text-[9px] text-muted-foreground`,children:new Date(e.timestamp).toLocaleTimeString()}),e.toolName&&(0,k.jsxs)(`div`,{className:`mt-1`,children:[`via `,e.toolName]}),e.agent&&(0,k.jsx)(`div`,{className:`text-muted-foreground`,children:e.agent}),e.summary&&(0,k.jsx)(`div`,{className:`mt-1 text-muted-foreground`,children:e.summary}),e.change&&(0,k.jsxs)(`div`,{className:`mt-1 flex items-center gap-1 font-mono text-[8px]`,children:[(0,k.jsxs)(`span`,{className:`border border-success/40 bg-success/10 px-1 text-success`,children:[`+`,e.change.added]}),(0,k.jsxs)(`span`,{className:`border border-destructive/40 bg-destructive/10 px-1 text-destructive`,children:[`−`,e.change.removed]}),e.change.before&&(0,k.jsx)(`span`,{className:`ml-1 truncate text-destructive/80`,title:e.change.before,children:e.change.before}),e.change.after&&(0,k.jsxs)(`span`,{className:`truncate text-success/80`,title:e.change.after,children:[`→ `,e.change.after]})]}),(0,k.jsxs)(`div`,{className:`mt-1 flex gap-2 font-mono text-[8px] uppercase text-muted-foreground`,children:[(0,k.jsx)(`span`,{children:e.status??`observed`}),(0,k.jsx)(`span`,{children:e.source??`legacy`}),e.durationMs!==void 0&&(0,k.jsxs)(`span`,{children:[e.durationMs,`ms`]}),e.watcherConfirmed&&(0,k.jsx)(`span`,{className:`text-success`,children:`fs verified`})]})]})]},`${e.timestamp}-${t}`))}),(0,k.jsxs)(`div`,{className:`border-t px-4 py-2 font-mono text-[9px] text-muted-foreground`,children:[Bt.length,` events · newest first`]})]})]})}function L(){return(0,k.jsx)(me,{children:(0,k.jsx)(Je,{})})}export{L as CodeMap};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{$i as t,aa as n,ea as r,tt as i}from"./vendor-Di1mdAi5.js";import"./i18n-DaR2GB_4.js";import{a,i as o,n as s,o as c,r as l,t as u}from"./dialog-CNwwBFw3.js";import{t as d}from"./button-99L74zdE.js";import{t as f}from"./input-DXjUO_X9.js";var p=e(n(),1),m=i(),h=t()((e,t)=>({request:null,open:n=>{t().request?.resolve(!1),e({request:n})},settle:n=>{t().request?.resolve(n),e({request:null})}}));function g(e){return new Promise(t=>{h.getState().open({...e,resolve:t})})}function _(){let{t:e}=r(),t=h(e=>e.request),n=h(e=>e.settle);return(0,p.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Enter`&&(e.preventDefault(),h.getState().settle(!0))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]),(0,m.jsx)(u,{open:t!==null,onOpenChange:e=>{e||n(!1)},children:(0,m.jsxs)(s,{className:`max-w-md`,children:[(0,m.jsxs)(a,{children:[(0,m.jsx)(c,{children:t?.title}),t?.message&&(0,m.jsx)(l,{children:t.message})]}),(0,m.jsxs)(o,{className:`gap-2`,children:[(0,m.jsx)(d,{variant:`outline`,size:`sm`,onClick:()=>n(!1),children:t?.cancelLabel??e(`common:action.cancel`)}),(0,m.jsx)(d,{variant:t?.danger?`destructive`:`default`,size:`sm`,autoFocus:!0,onClick:()=>n(!0),children:t?.confirmLabel??e(`common:action.confirm`)})]})]})})}var v=t()((e,t)=>({request:null,open:n=>{t().request?.resolve(null),e({request:n})},settle:n=>{t().request?.resolve(n),e({request:null})}}));function y(e){return new Promise(t=>{v.getState().open({...e,resolve:t})})}function b(){let{t:e}=r(),t=v(e=>e.request),n=v(e=>e.settle),[i,h]=(0,p.useState)(``);(0,p.useEffect)(()=>{h(t?.defaultValue??``)},[t]);let g=()=>{let e=i.trim();n(e.length>0?e:null)};return(0,m.jsx)(u,{open:t!==null,onOpenChange:e=>{e||n(null)},children:(0,m.jsxs)(s,{className:`max-w-md`,children:[(0,m.jsxs)(a,{children:[(0,m.jsx)(c,{children:t?.title}),t?.message&&(0,m.jsx)(l,{children:t.message})]}),(0,m.jsx)(f,{autoFocus:!0,value:i,placeholder:t?.placeholder,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),g())}}),(0,m.jsxs)(o,{className:`gap-2`,children:[(0,m.jsx)(d,{variant:`outline`,size:`sm`,onClick:()=>n(null),children:t?.cancelLabel??e(`common:action.cancel`)}),(0,m.jsx)(d,{size:`sm`,disabled:i.trim().length===0,onClick:g,children:t?.confirmLabel??e(`common:action.ok`)})]})]})})}export{y as i,b as n,g as r,_ as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Qt as t,aa as n,ii as r,mi as i,pi as a,tt as o}from"./vendor-Di1mdAi5.js";import{k as s}from"./stores-JSLvWOQY.js";import{a as c,n as l,o as u,r as d,t as f}from"./dialog-CNwwBFw3.js";import{c as p,h as m}from"./index-BLAy5CKD.js";var h=e(n(),1),g=o();function _(e){return e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:e<36e5?`${(e/6e4).toFixed(1)}m`:`${(e/36e5).toFixed(1)}h`}function v(e){if(!e)return`—`;let t=new Date(e),n=Date.now(),r=t.getTime()-n,i=Math.abs(r);if(i<6e4)return r>=0?`<1m`:`<1m ago`;if(i<36e5){let e=Math.round(i/6e4);return r>=0?`${e}m`:`${e}m ago`}if(i<864e5){let e=Math.round(i/36e5);return r>=0?`${e}h`:`${e}h ago`}return t.toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function y({enabled:e,overdue:t}){return e?t?(0,g.jsxs)(p,{variant:`destructive`,className:`gap-1`,children:[(0,g.jsx)(r,{className:`h-3 w-3`}),`Overdue`]}):(0,g.jsxs)(p,{variant:`default`,className:`gap-1 bg-emerald-600 hover:bg-emerald-600`,children:[(0,g.jsx)(a,{className:`h-3 w-3`}),`Active`]}):(0,g.jsxs)(p,{variant:`secondary`,className:`gap-1`,children:[(0,g.jsx)(i,{className:`h-3 w-3`}),`Disabled`]})}function b({open:e,onClose:n}){let i=s(e=>e.snapshot),a=s(e=>e.lastFiredAt);s(e=>e.revision);let o=i?.jobs??[],p=i?.count??0,b=i?.maxConcurrent??0,x=o.filter(e=>e.overdue).length,S=o.filter(e=>e.enabled).length,C=o.reduce((e,t)=>e+t.runCount,0);return(0,g.jsx)(f,{open:e,onOpenChange:(0,h.useCallback)(e=>{e||n()},[n]),children:(0,g.jsxs)(l,{className:`max-w-3xl max-h-[80vh] flex flex-col`,children:[(0,g.jsxs)(c,{children:[(0,g.jsxs)(u,{className:`flex items-center gap-2`,children:[(0,g.jsx)(t,{className:`h-5 w-5`}),`Cron Jobs`]}),(0,g.jsx)(d,{children:`Scheduled recurring tasks managed by the cron plugin.`})]}),p>0&&(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 text-sm text-muted-foreground border-b border-border/70 pb-3`,children:[(0,g.jsxs)(`span`,{className:`font-medium text-foreground`,children:[p,` job`,p===1?``:`s`]}),(0,g.jsxs)(`span`,{className:`text-emerald-500`,children:[S,` enabled`]}),x>0&&(0,g.jsxs)(`span`,{className:`text-destructive`,children:[x,` overdue`]}),(0,g.jsxs)(`span`,{children:[C,` total runs`]}),(0,g.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[`max `,b,` concurrent`]})]}),p===0&&(0,g.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-12 text-muted-foreground`,children:[(0,g.jsx)(r,{className:`h-8 w-8 opacity-40`}),(0,g.jsx)(`p`,{className:`text-sm`,children:`No cron jobs scheduled.`}),(0,g.jsxs)(`p`,{className:`text-xs`,children:[`Use `,(0,g.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5`,children:`cron_schedule`}),` to add one.`]})]}),p>0&&(0,g.jsx)(m,{className:`flex-1 -mx-6 px-6`,children:(0,g.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,g.jsx)(`thead`,{children:(0,g.jsxs)(`tr`,{className:`border-b border-border/50 text-left text-xs text-muted-foreground`,children:[(0,g.jsx)(`th`,{className:`pb-2 pr-3 font-medium`,children:`Status`}),(0,g.jsx)(`th`,{className:`pb-2 pr-3 font-medium`,children:`Name`}),(0,g.jsx)(`th`,{className:`pb-2 pr-3 font-medium`,children:`Interval`}),(0,g.jsx)(`th`,{className:`pb-2 pr-3 font-medium text-right`,children:`Runs`}),(0,g.jsx)(`th`,{className:`pb-2 pr-3 font-medium`,children:`Next Run`}),(0,g.jsx)(`th`,{className:`pb-2 pr-3 font-medium`,children:`Last Run`}),(0,g.jsx)(`th`,{className:`pb-2 font-medium`,children:`Action`})]})}),(0,g.jsx)(`tbody`,{children:o.map(e=>(0,g.jsxs)(`tr`,{className:`border-b border-border/30 last:border-0`,children:[(0,g.jsx)(`td`,{className:`py-2.5 pr-3`,children:(0,g.jsx)(y,{enabled:e.enabled,overdue:e.overdue})}),(0,g.jsx)(`td`,{className:`py-2.5 pr-3 font-mono text-xs font-medium max-w-[160px] truncate`,title:e.name,children:e.name}),(0,g.jsx)(`td`,{className:`py-2.5 pr-3 font-mono text-xs tabular-nums`,children:_(e.intervalMs)}),(0,g.jsxs)(`td`,{className:`py-2.5 pr-3 text-right font-mono text-xs tabular-nums`,children:[e.runCount,a[e.name]&&(0,g.jsx)(`span`,{className:`ml-1 text-emerald-500`,title:`Last fired at ${a[e.name]}`,children:`●`})]}),(0,g.jsx)(`td`,{className:`py-2.5 pr-3 font-mono text-xs tabular-nums`,children:v(e.nextRun)}),(0,g.jsx)(`td`,{className:`py-2.5 pr-3 font-mono text-xs tabular-nums`,children:v(e.lastRun)}),(0,g.jsx)(`td`,{className:`py-2.5 font-mono text-xs max-w-[200px] truncate text-muted-foreground`,title:e.action,children:e.action})]},e.name))})]})}),p>0&&(0,g.jsxs)(`p`,{className:`text-xs text-muted-foreground pt-3 border-t border-border/70`,children:[`Use `,(0,g.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 text-[11px]`,children:`cron_schedule`}),` to add,`,(0,g.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 text-[11px] ml-1`,children:`cron_cancel`}),` to remove.`]})]})})}export{b as CronJobsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ei as t,Gt as n,Pr as r,Vr as i,Zi as a,_i as o,aa as s,ea as c,hr as l,ii as u,ra as d,rn as f,tt as p,xt as m}from"./vendor-Di1mdAi5.js";import"./i18n-DaR2GB_4.js";import{g as h}from"./index-BLAy5CKD.js";var g=e(s(),1),_=p();function v({title:e,value:t,subtitle:n,icon:r,color:i=`text-primary`,trend:a}){let{t:o}=c();return(0,_.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,_.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,_.jsxs)(`div`,{className:`min-w-0`,children:[(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground font-medium`,children:e}),(0,_.jsx)(`p`,{className:`mt-1 truncate text-xl font-semibold tabular-nums sm:text-2xl ${i}`,children:t}),n&&(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:n})]}),(0,_.jsx)(`div`,{className:`shrink-0 rounded-lg bg-muted/70 p-2 ${i}`,children:(0,_.jsx)(r,{className:`w-5 h-5`})})]}),a&&(0,_.jsxs)(`div`,{className:`mt-2 flex items-center gap-1`,children:[a===`up`&&(0,_.jsx)(m,{className:`w-3 h-3 text-success`}),a===`down`&&(0,_.jsx)(m,{className:`w-3 h-3 rotate-180 text-destructive`}),(0,_.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:o(a===`up`?`activity:debug.trendUp`:a===`down`?`activity:debug.trendDown`:`activity:debug.trendStable`)})]})]})}function y(){let{t:e}=c(),[s,p]=(0,g.useState)({fileWatcher:null,system:null,lastUpdated:null,error:null}),[y,S]=(0,g.useState)(!0),[C,w]=(0,g.useState)(2e3),T=(0,g.useCallback)(async()=>{try{let[e,t]=await Promise.all([fetch(`/debug/watcher-metrics`),fetch(`/debug/system`,{cache:`no-store`})]),n=null,r=e.headers.get(`content-type`)??``;if(e.ok&&r.includes(`application/json`)&&(n=await e.json()),!t.ok)throw Error(`System metrics request failed (${t.status})`);let i=await t.json();p({fileWatcher:n,system:i,lastUpdated:new Date,error:null})}catch(e){p(t=>({...t,error:e instanceof Error?e.message:d.t(`activity:debug.fetchFailed`)}))}finally{S(!1)}},[]);return(0,g.useEffect)(()=>{T();let e=setInterval(T,C);return()=>clearInterval(e)},[T,C]),(0,_.jsx)(`div`,{ref:h(`debug`),className:`h-full min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain bg-[hsl(var(--surface-2)/0.45)] p-4 sm:p-6`,children:(0,_.jsxs)(`div`,{className:`mx-auto flex max-w-7xl flex-col gap-5`,children:[(0,_.jsx)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:(0,_.jsxs)(`div`,{className:`flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between`,children:[(0,_.jsxs)(`div`,{className:`min-w-0`,children:[(0,_.jsxs)(`h1`,{className:`flex items-center gap-2 text-lg font-semibold sm:text-xl`,children:[(0,_.jsx)(t,{className:`h-5 w-5 text-primary`}),e(`activity:debug.heading`)]}),(0,_.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:e(`activity:debug.subtitle`)})]}),(0,_.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[(0,_.jsxs)(`label`,{className:`flex min-w-0 items-center gap-2 text-sm`,children:[(0,_.jsx)(f,{className:`w-4 h-4 text-muted-foreground`}),(0,_.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:e(`activity:debug.refreshLabel`)}),(0,_.jsxs)(`select`,{value:C,onChange:e=>w(Number(e.target.value)),className:`h-9 rounded-md border border-border/70 bg-background/70 px-2 text-sm`,children:[(0,_.jsx)(`option`,{value:1e3,children:`1s`}),(0,_.jsx)(`option`,{value:2e3,children:`2s`}),(0,_.jsx)(`option`,{value:5e3,children:`5s`}),(0,_.jsx)(`option`,{value:1e4,children:`10s`})]})]}),(0,_.jsxs)(`button`,{type:`button`,onClick:()=>{S(!0),T()},disabled:y,className:`inline-flex h-9 items-center justify-center gap-2 rounded-md bg-primary px-3 text-sm font-medium text-primary-foreground shadow-sm shadow-primary/15 hover:bg-primary/90 disabled:opacity-50`,children:[(0,_.jsx)(f,{className:`w-4 h-4 ${y?`animate-spin`:``}`}),e(`common:action.refresh`)]})]})]})}),s.lastUpdated&&(0,_.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-border/60 bg-card/55 px-3 py-2 text-sm text-muted-foreground`,children:[(0,_.jsx)(u,{className:`w-4 h-4`}),e(`activity:debug.lastUpdated`,{time:s.lastUpdated.toLocaleTimeString()})]}),s.error&&(0,_.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl border border-destructive/25 bg-destructive/10 p-4 text-destructive`,children:[(0,_.jsx)(o,{className:`w-5 h-5 flex-shrink-0`}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`p`,{className:`font-medium`,children:e(`activity:debug.fetchFailed`)}),(0,_.jsx)(`p`,{className:`text-sm opacity-80`,children:s.error})]})]}),(0,_.jsxs)(`section`,{children:[(0,_.jsxs)(`h2`,{className:`mb-3 flex items-center gap-2 text-sm font-semibold text-muted-foreground`,children:[(0,_.jsx)(i,{className:`h-4 w-4 text-primary`}),e(`activity:debug.fileWatcher`)]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4`,children:[(0,_.jsx)(v,{title:e(`activity:debug.watcherStatus`),value:s.fileWatcher?.watcherActive?e(`activity:debug.running`):e(`activity:debug.stopped`),icon:n,color:s.fileWatcher?.watcherActive?`text-success`:`text-destructive`}),(0,_.jsx)(v,{title:e(`activity:debug.activeProjects`),value:s.fileWatcher?.activeProjects??0,subtitle:e(`activity:debug.projectsWatched`),icon:r,color:`text-primary`}),(0,_.jsx)(v,{title:e(`activity:debug.fileChanges`),value:s.fileWatcher?.fileChangesDetected??0,subtitle:e(`activity:debug.totalDetected`),icon:a,color:`text-primary`,trend:`neutral`}),(0,_.jsx)(v,{title:e(`activity:debug.filesProcessed`),value:s.fileWatcher?.filesProcessed??0,subtitle:e(`activity:debug.afterHash`),icon:l,color:`text-success`})]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 mt-4`,children:[(0,_.jsx)(v,{title:e(`activity:debug.broadcastsSent`),value:s.fileWatcher?.broadcastsSent??0,subtitle:e(`activity:debug.toClients`),icon:m,color:`text-success`}),(0,_.jsx)(v,{title:e(`activity:debug.debounceResets`),value:s.fileWatcher?.debounceResets??0,subtitle:e(`activity:debug.rapidWrites`),icon:f,color:`text-warning`}),(0,_.jsx)(v,{title:e(`activity:debug.avgDebounce`),value:`${(s.fileWatcher?.averageDebounceDelayMs??0).toFixed(1)}ms`,subtitle:e(`activity:debug.actualDelay`),icon:u,color:`text-warning`}),(0,_.jsx)(v,{title:e(`activity:debug.totalDelay`),value:`${(s.fileWatcher?.totalDebounceDelayMs??0).toFixed(0)}ms`,subtitle:e(`activity:debug.sumDelays`),icon:t,color:`text-primary`})]})]}),(0,_.jsxs)(`section`,{children:[(0,_.jsxs)(`h2`,{className:`mb-3 flex items-center gap-2 text-sm font-semibold text-muted-foreground`,children:[(0,_.jsx)(l,{className:`h-4 w-4 text-primary`}),`WebUI Server Process`]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4`,children:[(0,_.jsx)(v,{title:`Process RAM (RSS)`,value:b(s.system?.memoryUsage?.rss??0),subtitle:s.system?`PID ${s.system.pid}`:void 0,icon:n,color:`text-primary`}),(0,_.jsx)(v,{title:e(`activity:debug.heapUsed`),value:b(s.system?.memoryUsage?.heapUsed??0),subtitle:e(`activity:debug.jsHeap`),icon:t,color:`text-primary`}),(0,_.jsx)(v,{title:e(`activity:debug.heapTotal`),value:b(s.system?.memoryUsage?.heapTotal??0),subtitle:e(`activity:debug.totalHeap`),icon:t,color:`text-success`}),(0,_.jsx)(v,{title:`V8 Heap Limit`,value:b(s.system?.heapLimit??0),subtitle:`Configured old-space ceiling`,icon:l,color:`text-warning`}),(0,_.jsx)(v,{title:`Server Uptime`,value:x(s.system?.uptime??0),subtitle:`Since process start`,icon:u,color:`text-primary`})]})]}),(0,_.jsxs)(`section`,{children:[(0,_.jsxs)(`h2`,{className:`mb-3 flex items-center gap-2 text-sm font-semibold text-muted-foreground`,children:[(0,_.jsx)(a,{className:`h-4 w-4 text-primary`}),e(`activity:debug.rawData`)]}),(0,_.jsx)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:(0,_.jsx)(`pre`,{className:`overflow-x-auto text-xs font-mono text-muted-foreground`,children:JSON.stringify({fileWatcher:s.fileWatcher,serverPid:s.system?.pid,serverMemory:s.system?.memoryUsage,serverHeapLimit:s.system?.heapLimit,serverUptime:s.system?.uptime},null,2)})})]})]})})}function b(e){if(e===0)return`0 B`;let t=1024,n=[`B`,`KB`,`MB`,`GB`],r=Math.floor(Math.log(e)/Math.log(t));return`${(e/t**r).toFixed(1)} ${n[r]}`}function x(e){return e<60?`${e.toFixed(0)}s`:e<3600?`${(e/60).toFixed(1)}m`:`${(e/3600).toFixed(1)}h`}export{y as DebugDashboard};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Bt as t,aa as n,bn as r,ea as i,ot as a,qr as o,qt as s,ra as c,tt as l,wi as u}from"./vendor-Di1mdAi5.js";import"./i18n-DaR2GB_4.js";import{t as d}from"./useWebSocket-CRYUFxmO.js";import{t as f}from"./utils-C4qVQ63O.js";import{s as p}from"./view-navigation-BbHlzAQz.js";import{g as m}from"./index-BLAy5CKD.js";var h=e(n(),1);function g(e,t,n){return e<t?t:e>n?n:e}function _(e){let t=/^oklch\(\s*([^)]+)\)$/i.exec(e.trim());if(!t?.[1])return null;let n=(t[1].split(`/`)[0]??``).trim().split(/\s+/);if(n.length<3||!n[0]||!n[1]||!n[2])return null;let r=n[0].endsWith(`%`)?Number.parseFloat(n[0])/100:Number.parseFloat(n[0]),i=n[1].endsWith(`%`)?Number.parseFloat(n[1])/100*.4:Number.parseFloat(n[1]),a=Number.parseFloat(n[2].replace(/deg$/i,``));return[r,i,a].every(Number.isFinite)?[g(r,0,1),Math.max(0,i),a]:null}function v(e){return g(e<=.0031308?12.92*e:1.055*e**(1/2.4)-.055,0,1)}function y(e){return Math.round(e*255).toString(16).padStart(2,`0`)}function b(e){let t=_(e);if(!t)return null;let[n,r,i]=t,a=i*Math.PI/180,o=r*Math.cos(a),s=r*Math.sin(a),c=n+.3963377774*o+.2158037573*s,l=n-.1055613458*o-.0638541728*s,u=n-.0894841775*o-1.291485548*s,d=c**3,f=l**3,p=u**3,m=4.0767416621*d-3.3077115913*f+.2309699292*p,h=-1.2684380046*d+2.6097574011*f-.3413193965*p,g=-.0041960863*d-.7034186147*f+1.707614701*p;return`#${y(v(m))}${y(v(h))}${y(v(g))}`}function x(e){let t=e.trim(),n=b(t);if(n)return n.toLowerCase();let r=/^#([0-9a-f]{6})([0-9a-f]{2})?$/i.exec(t);if(r?.[1])return`#${r[1].toLowerCase()}`;let i=/^#([0-9a-f]{3})$/i.exec(t);return i?.[1]?`#${i[1].split(``).map(e=>e+e).join(``).toLowerCase()}`:null}var S=l(),C=[`web`,`react-native`,`flutter`,`swiftui`,`compose`],w=[`primary`,`accent`,`bg`,`surface`,`fg`,`border`];function T(e,t,n){let r={...e};for(let[e,i]of Object.entries(t))e.startsWith(`light.`)?n===`light`&&(r[e.slice(6)]=i):e.startsWith(`dark.`)?n===`dark`&&(r[e.slice(5)]=i):r[e]=i;return r}function E({t:e,label:t}){let n=e.bg??`#fff`,r=e.surface??n,i=e.fg??`#111`,a=e.muted??i,o=e.primary??`#3b82f6`,s=e.accent??o,c=e.border??a,l=e.radius??`0.5rem`,u=e.fontSans??`system-ui, sans-serif`,d=e.fontDisplay??u,f=e.shadow&&e.shadow!==`none`?e.shadow:void 0;return(0,S.jsxs)(`div`,{style:{background:n,color:i,fontFamily:u},className:`flex min-w-0 flex-col gap-2 overflow-hidden p-3`,children:[(0,S.jsx)(`div`,{className:`text-[9px] uppercase tracking-wide`,style:{color:a},children:t}),(0,S.jsxs)(`div`,{style:{background:r,border:`1px solid ${c}`,borderRadius:l,boxShadow:f},className:`flex min-w-0 flex-col gap-2 p-3`,children:[(0,S.jsx)(`div`,{style:{fontFamily:d},className:`text-base font-bold leading-tight`,children:`Aa Heading`}),(0,S.jsx)(`div`,{className:`text-[11px] leading-snug`,style:{color:a},children:`The quick brown fox jumps over the lazy dog.`}),(0,S.jsxs)(`div`,{className:`mt-1 flex min-w-0 items-center gap-1.5`,children:[(0,S.jsx)(`span`,{style:{background:o,color:n,borderRadius:l},className:`shrink-0 px-2.5 py-1 text-[10px] font-semibold`,children:`Primary`}),(0,S.jsx)(`span`,{style:{border:`1px solid ${c}`,color:i,borderRadius:l},className:`shrink-0 px-2 py-1 text-[10px]`,children:`Ghost`}),(0,S.jsx)(`span`,{style:{background:s,color:n,borderRadius:`999px`},className:`ml-auto shrink-0 px-2 py-0.5 text-[9px] font-semibold`,children:`Badge`})]}),(0,S.jsx)(`div`,{style:{border:`1px solid ${c}`,borderRadius:l,color:a},className:`text-[10px] px-2 py-1.5 mt-1`,children:`Input field…`})]})]})}function D({kit:e,overrides:t,onSet:n}){let[r,a]=(0,h.useState)(`light`),{t:o}=i(),s=T(r===`light`?e.light:e.dark,t,r);return(0,S.jsxs)(`div`,{className:`mt-1 rounded-lg border border-border/60 p-2 bg-muted/30`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[(0,S.jsx)(`span`,{className:`text-[10px] font-semibold uppercase text-muted-foreground`,children:o(`activity:design.colors`)}),(0,S.jsx)(`div`,{className:`ml-auto inline-flex rounded border border-border/60 overflow-hidden`,children:[`light`,`dark`].map(e=>(0,S.jsx)(`button`,{type:`button`,onClick:()=>a(e),className:f(`text-[10px] px-1.5 py-0.5`,r===e?`bg-primary text-primary-foreground`:`text-muted-foreground`),children:e},e))})]}),(0,S.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:w.filter(e=>s[e]).map(e=>{let t=x(s[e]??``)??`#000000`;return(0,S.jsxs)(`label`,{className:`flex min-w-[2rem] flex-col items-center gap-0.5`,title:`${e}: ${s[e]}`,children:[(0,S.jsx)(`input`,{type:`color`,value:t,onChange:t=>n(`${r}.${e}`,t.target.value),className:`w-6 h-6 rounded cursor-pointer bg-transparent border border-border/60 p-0`}),(0,S.jsx)(`span`,{className:`text-[8px] text-muted-foreground`,children:e})]},e)})})]})}function O({className:e}){let{client:n}=d(),{t:l}=i(),[g,_]=(0,h.useState)([]),[v,y]=(0,h.useState)(null),[b,x]=(0,h.useState)({}),[w,O]=(0,h.useState)(`web`),[k,A]=(0,h.useState)(``),[j,M]=(0,h.useState)(null);(0,h.useEffect)(()=>{if(!n)return;let e=e=>{let t=e.payload;_(t?.kits??[]),y(t?.activeKit??null),x(t?.overrides??{})},t=e=>{let t=e.payload;t?.ok&&t.kit&&(y(t.kit),x(t.overrides??{}))},r=e=>{let t=e.payload;t?.ok&&t.overrides&&x(t.overrides)},i=e=>{let t=e.payload;M(t?.ok?c.t(`activity:design.wrote`,{path:t.path}):c.t(`activity:design.materializeFailed`,{error:t?.error??`error`}))},a=e=>{let t=e.payload;if(!t?.ok){M(c.t(`activity:design.verifyError`,{error:t?.error??`error`}));return}let n=Math.round((t.score??1)*100);M(t.violationCount?c.t(`activity:design.verifyOffPalette`,{pct:n,count:t.violationCount,files:t.filesScanned}):c.t(`activity:design.verifyClean`,{files:t.filesScanned}))};return n.on(`design.list`,e),n.on(`design.use`,t),n.on(`design.set`,r),n.on(`design.materialize`,i),n.on(`design.verify`,a),n.send({type:`design.list`}),()=>{n.off(`design.list`,e),n.off(`design.use`,t),n.off(`design.set`,r),n.off(`design.materialize`,i),n.off(`design.verify`,a)}},[n]);let N=(0,h.useCallback)(e=>n?.send({type:`design.use`,payload:{kit:e,stack:w}}),[n,w]),P=(0,h.useCallback)((e,t)=>{x(n=>({...n,[e]:t})),n?.send({type:`design.set`,payload:{overrides:{[e]:t}}})},[n]),F=(0,h.useCallback)(()=>{M(c.t(`activity:design.writing`)),n?.send({type:`design.materialize`,payload:{stack:w}})},[n,w]),I=(0,h.useCallback)(()=>{M(c.t(`activity:design.scanning`)),n?.send({type:`design.verify`})},[n]),L=(0,h.useMemo)(()=>{let e=k.trim().toLowerCase();return[...e?g.filter(t=>t.id.includes(e)||t.name.toLowerCase().includes(e)||t.aesthetic.toLowerCase().includes(e)||t.tags.some(t=>t.includes(e))):g].sort((e,t)=>e.name.localeCompare(t.name))},[g,k]);return(0,S.jsxs)(`div`,{className:f(`flex h-full min-h-0 min-w-0 flex-col overflow-hidden bg-[hsl(var(--surface-2)/0.45)]`,e),children:[(0,S.jsx)(`div`,{className:`border-b border-border/60 p-3`,children:(0,S.jsx)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-3 shadow-sm`,children:(0,S.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center`,children:[(0,S.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,S.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,S.jsx)(r,{className:`h-4 w-4`})}),(0,S.jsxs)(`div`,{className:`min-w-0`,children:[(0,S.jsx)(`h2`,{className:`truncate text-sm font-semibold`,children:l(`activity:design.heading`)}),(0,S.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:l(`activity:design.kitsCount`,{count:L.length})})]})]}),(0,S.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2 sm:flex-row sm:items-center lg:justify-end`,children:[(0,S.jsxs)(`label`,{className:`relative min-w-0 flex-1 sm:max-w-xs`,children:[(0,S.jsx)(s,{className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground/70`}),(0,S.jsx)(`input`,{value:k,onChange:e=>A(e.target.value),placeholder:l(`activity:design.searchPlaceholder`),className:`h-9 w-full rounded-md border border-border/70 bg-background/70 pl-8 pr-3 text-sm shadow-sm outline-none transition focus:border-primary/40 focus:ring-2 focus:ring-ring/30`})]}),(0,S.jsx)(`select`,{value:w,onChange:e=>O(e.target.value),className:`h-9 rounded-md border border-border/70 bg-background/70 px-2 text-sm shadow-sm`,title:l(`activity:design.stackTitle`),children:C.map(e=>(0,S.jsx)(`option`,{value:e,children:e},e))}),j&&(0,S.jsx)(`span`,{className:`min-w-0 truncate rounded-md border border-border/60 bg-muted/40 px-2 py-1 text-[11px] text-muted-foreground sm:max-w-56`,children:j}),(0,S.jsx)(`button`,{type:`button`,onClick:()=>p(`chat`),className:`inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,title:l(`common:action.close`),children:(0,S.jsx)(a,{className:`h-4 w-4`})})]})]})})}),(0,S.jsx)(`div`,{ref:m(`design-gallery`),className:`min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain p-3 sm:p-4`,children:L.length===0?(0,S.jsxs)(`div`,{className:`ws-surface mx-auto mt-8 flex max-w-md flex-col items-center gap-3 rounded-xl p-6 text-center text-muted-foreground`,children:[(0,S.jsx)(r,{className:`h-8 w-8 text-primary/60`}),(0,S.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:l(`activity:design.kitsCount`,{count:0})}),(0,S.jsx)(`p`,{className:`text-xs`,children:l(`activity:design.searchPlaceholder`)})]}):(0,S.jsx)(`div`,{className:`grid gap-4 [grid-template-columns:repeat(auto-fill,minmax(min(100%,20rem),1fr))]`,children:L.map(e=>{let n=v===e.id,r=n?b:{};return(0,S.jsxs)(`div`,{className:f(`flex min-w-0 flex-col overflow-hidden rounded-xl border bg-card/75 shadow-sm`,n?`border-primary/60 ring-1 ring-primary/30`:`border-border/70`),children:[(0,S.jsxs)(`div`,{className:`grid min-h-[12rem] grid-cols-1 sm:grid-cols-2`,children:[(0,S.jsx)(E,{t:T(e.light,r,`light`),label:l(`activity:designStudio.light`)}),(0,S.jsx)(E,{t:T(e.dark,r,`dark`),label:l(`activity:designStudio.dark`)})]}),(0,S.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 border-t border-border/60 bg-card p-3`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,S.jsx)(`h3`,{className:`text-sm font-semibold truncate`,children:e.name}),(0,S.jsx)(`code`,{className:`text-[10px] text-muted-foreground`,children:e.id}),n&&(0,S.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-[9px] font-semibold uppercase text-primary ml-auto`,children:[(0,S.jsx)(u,{className:`w-3 h-3`}),` `,l(`activity:design.active`)]})]}),(0,S.jsx)(`p`,{className:`text-[11px] text-muted-foreground leading-snug`,children:e.aesthetic}),(0,S.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-2`,children:[(0,S.jsx)(`button`,{type:`button`,onClick:()=>N(e.id),className:f(`rounded-md px-2.5 py-1 text-[11px] font-medium transition`,n?`bg-primary/10 text-primary`:`bg-primary text-primary-foreground hover:opacity-90`),children:l(n?`activity:design.reapply`:`activity:design.use`)}),n&&(0,S.jsxs)(`button`,{type:`button`,onClick:F,className:`inline-flex items-center gap-1 rounded-md border border-border/60 px-2 py-1 text-[11px] font-medium hover:bg-muted`,title:l(`activity:design.materializeTitle`,{stack:w}),children:[(0,S.jsx)(o,{className:`w-3 h-3`}),` `,l(`activity:design.materialize`)]}),n&&(0,S.jsxs)(`button`,{type:`button`,onClick:I,className:`inline-flex items-center gap-1 rounded-md border border-border/60 px-2 py-1 text-[11px] font-medium hover:bg-muted`,title:l(`activity:design.verifyTitle`),children:[(0,S.jsx)(t,{className:`w-3 h-3`}),` `,l(`activity:design.verify`)]}),(0,S.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[10px] text-muted-foreground`,children:e.bestFor})]}),n&&(0,S.jsx)(D,{kit:e,overrides:r,onSet:P})]})]},e.id)})})})]})}export{O as DesignGalleryView};
|