@wrongstack/webui 0.299.0 → 0.300.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/AgentRosterView-wkALMOGD.js +9 -0
- package/dist/assets/{AnalyticsDashboard-D58kSekC.js → AnalyticsDashboard-CIN35A_u.js} +1 -1
- package/dist/assets/AudienceMemoryPanel-BAY2Bh8z.js +3 -0
- package/dist/assets/ChangesView-CVWSTGmX.js +1 -0
- package/dist/assets/ChronicleDashboard-Bg3W7C9U.js +1 -0
- package/dist/assets/CodeEditor-CWY_6cQD.js +1 -0
- package/dist/assets/CodeMap-CjmKO0lB.js +1 -0
- package/dist/assets/CronJobsPanel-BinzTWNs.js +1 -0
- package/dist/assets/DeadCodeScanPanel-C3CgaNVv.js +2 -0
- package/dist/assets/DebugDashboard-BqUghn06.js +1 -0
- package/dist/assets/DesignGalleryView-CuWWQAlD.js +1 -0
- package/dist/assets/GoalView-2weuLiPM.js +1 -0
- package/dist/assets/KanbanView-DXYRrshJ.js +3 -0
- package/dist/assets/{MailboxDetailView-ZcKcOEAe.js → MailboxDetailView-aaHx9Nma.js} +1 -1
- package/dist/assets/MemoryManager-BgcicCyg.js +1 -0
- package/dist/assets/{ModelPicker-DvNLZzkm.js → ModelPicker-B3BqjJnT.js} +1 -1
- package/dist/assets/OfficeMapPanel-Ck8NUOEs.js +4 -0
- package/dist/assets/OfficeMapPanel-CpexsBed.css +1 -0
- package/dist/assets/{ProcessMonitor-2nSk6sXA.js → ProcessMonitor-CoMYZcdS.js} +1 -1
- package/dist/assets/{QueuePanel-4KBBWFxj.js → QueuePanel-CA3CVCO_.js} +1 -1
- package/dist/assets/{RefreshDebugView-D3XnE53y.js → RefreshDebugView-cqBtyNna.js} +1 -1
- package/dist/assets/RequirementIntakeView-BBtUk8mC.js +1 -0
- package/dist/assets/SageTabs-Di49i4Yu.js +2 -0
- package/dist/assets/SddHub-D8iV6l9A.js +2 -0
- package/dist/assets/SessionInspectView-DHC_xTzG.js +1 -0
- package/dist/assets/{SessionList-BeinIC-h.js → SessionList-DH-ZsHmv.js} +1 -1
- package/dist/assets/{SessionsDashboard-DEG_BylE.js → SessionsDashboard-Coi6htwg.js} +1 -1
- package/dist/assets/SetupScreen-CD2Sx4n9.js +1 -0
- package/dist/assets/{SkillDetailView-D7EQ2XtV.js → SkillDetailView-D7wSJWUX.js} +1 -1
- package/dist/assets/SpecsView-BRWSI1iV.js +1 -0
- package/dist/assets/TechStackView-BOjkuJLe.js +1 -0
- package/dist/assets/{TerminalPanel-BL9ZPGJt.js → TerminalPanel-Dg8WR5Un.js} +1 -1
- package/dist/assets/{Toaster-CJI70aa-.js → Toaster-DSKFSuK3.js} +1 -1
- package/dist/assets/activity-BWbV0byu.js +9 -0
- package/dist/assets/activity-Bjb_mil3.js +9 -0
- package/dist/assets/activity-Bze6njDy.js +9 -0
- package/dist/assets/activity-Ciqcr7Ps.js +9 -0
- package/dist/assets/activity-DA9hmVZV.js +9 -0
- package/dist/assets/activity-GdnS66AB.js +9 -0
- package/dist/assets/activity-eawh_OWs.js +9 -0
- package/dist/assets/{chat-DzPxYALH.js → chat-4NEOESoU.js} +1 -1
- package/dist/assets/{chat-DLn1hY01.js → chat-BSg62iwX.js} +1 -1
- package/dist/assets/{chat-OunddzYy.js → chat-Bb1TpPfJ.js} +1 -1
- package/dist/assets/{chat-DxLD17ER.js → chat-COLKjtcx.js} +1 -1
- package/dist/assets/{chat-DSEq1Bdz.js → chat-CfRKV9iX.js} +1 -1
- package/dist/assets/{chat-CwnuX7tG.js → chat-EbeT4kiS.js} +1 -1
- package/dist/assets/{chat-CRmMDzCb.js → chat-ux_gymOJ.js} +1 -1
- package/dist/assets/{common-DMM-xyW3.js → common-BXJbu5Y-.js} +1 -1
- package/dist/assets/{common-C9ikgX7d.js → common-BiNu_WzQ.js} +1 -1
- package/dist/assets/common-COVxQ0FV.js +1 -0
- package/dist/assets/{common-D29Zdkxb.js → common-Ch7JihXD.js} +1 -1
- package/dist/assets/{common-DoUBSHRY.js → common-DPaTeTls.js} +1 -1
- package/dist/assets/{common-vdwxzODB.js → common-DdGpRh8j.js} +1 -1
- package/dist/assets/{common-C5hY-d_0.js → common-pI6fYZW3.js} +1 -1
- package/dist/assets/i18n-C31PI0Up.js +2 -0
- package/dist/assets/index-5IWUhPO4.css +1 -0
- package/dist/assets/index-D1izXztg.js +132 -0
- package/dist/assets/{mailbox-store-D8TvJsuk.js → mailbox-store-Bc9ER3Ph.js} +1 -1
- package/dist/assets/{progress-ring-61A-xUEl.js → progress-ring-D_d6hn_4.js} +1 -1
- package/dist/assets/{roster-ws-Dfg_187V.js → roster-ws-D6dGRfC5.js} +1 -1
- package/dist/assets/settings-BKuhxUSF.js +1 -0
- package/dist/assets/settings-CeK0doV7.js +1 -0
- package/dist/assets/settings-DZ-H89lu.js +1 -0
- package/dist/assets/settings-DvrdpSdA.js +1 -0
- package/dist/assets/settings-SBUqq0ll.js +1 -0
- package/dist/assets/settings-W8t1ZrxM.js +1 -0
- package/dist/assets/settings-tOqZkk9R.js +1 -0
- package/dist/assets/stores-OBoFiAKe.js +7 -0
- package/dist/assets/ui-store-CE4-TlwB.js +1 -0
- package/dist/assets/useWebSocket-DuLtH2jI.js +29 -0
- package/dist/assets/{view-navigation-DxfiZrXS.js → view-navigation-DIDEcp4V.js} +1 -1
- package/dist/assets/ws-client-Bw1ixxwI.js +1 -0
- package/dist/components/AutonomyPicker.d.ts +1 -1
- package/dist/components/ChatView/auto-collapse.d.ts +42 -0
- package/dist/components/FallbackModal.d.ts +2 -0
- package/dist/components/KanbanVerificationDashboard.d.ts +0 -6
- package/dist/components/SettingsPanel/PluginToggleList.d.ts +11 -3
- package/dist/components/SettingsPanel/brain-section-options.d.ts +25 -55
- package/dist/components/TaskCard.d.ts +0 -1
- package/dist/components/TaskRiskPanel.d.ts +10 -3
- package/dist/components/TechStackView/shared.d.ts +11 -6
- package/dist/components/ThemeProvider.d.ts +6 -1
- package/dist/components/agent-roster-data.d.ts +2 -1
- package/dist/hooks/ws-handlers/files-mailbox-handlers.d.ts +1 -0
- package/dist/hooks/ws-handlers/misc-handlers.d.ts +13 -0
- package/dist/hooks/ws-handlers/session-handlers.d.ts +1 -0
- package/dist/index.css +30 -0
- package/dist/index.html +15 -15
- package/dist/index.js +25202 -11602
- package/dist/lib/file-icons.d.ts +3 -3
- package/dist/lib/palettes.d.ts +37 -0
- package/dist/lib/ws-client.d.ts +3 -3
- package/dist/providers.json +7 -7
- package/dist/stores/config-store.d.ts +9 -1
- package/dist/stores/context-editor-store.d.ts +9 -1
- package/dist/stores/fallback-store.d.ts +30 -0
- package/dist/stores/fleet-store.d.ts +13 -0
- package/dist/stores/index.d.ts +2 -0
- package/dist/stores/local-prefs.d.ts +4 -0
- package/dist/stores/mailbox-store.d.ts +2 -0
- package/dist/types/client-message.d.ts +12 -1
- package/dist/types/protocol-core.d.ts +19 -0
- package/dist/types/runtime.d.ts +8 -0
- package/dist/types/server-message.d.ts +13 -2
- package/package.json +9 -9
- package/dist/assets/AgentRosterView-BqojERFR.js +0 -11
- package/dist/assets/AudienceMemoryPanel-Cc1UkbDl.js +0 -3
- package/dist/assets/ChangesView-BKU80ANq.js +0 -1
- package/dist/assets/ChronicleDashboard-CvCS1Dj1.js +0 -1
- package/dist/assets/CodeEditor-BHZQhx_8.js +0 -1
- package/dist/assets/CodeMap-qllGEFLB.js +0 -1
- package/dist/assets/CronJobsPanel-DD5mhZ4Q.js +0 -1
- package/dist/assets/DeadCodeScanPanel-PB-c8et_.js +0 -2
- package/dist/assets/DebugDashboard-Q8QiVflQ.js +0 -1
- package/dist/assets/DesignGalleryView-CGOtWO7s.js +0 -1
- package/dist/assets/GoalView-Dlk42vW7.js +0 -1
- package/dist/assets/KanbanView-DIP6kKmU.js +0 -3
- package/dist/assets/MemoryManager-B7620q_K.js +0 -1
- package/dist/assets/OfficeMapPanel-BFIF-EMt.css +0 -1
- package/dist/assets/OfficeMapPanel-DKJNTtOZ.js +0 -4
- package/dist/assets/RequirementIntakeView-BMxlf8bt.js +0 -1
- package/dist/assets/SageTabs-g1hO2hJ0.js +0 -2
- package/dist/assets/SddHub-Kv_TbTgT.js +0 -2
- package/dist/assets/SessionInspectView-PnKTvyvP.js +0 -1
- package/dist/assets/SetupScreen-DxJwZ1OZ.js +0 -1
- package/dist/assets/SpecsView-Fm7pYYcj.js +0 -1
- package/dist/assets/TechStackView-Bo_UenRF.js +0 -1
- package/dist/assets/activity-BCgOEWgR.js +0 -5
- package/dist/assets/activity-BQ0zqkw2.js +0 -5
- package/dist/assets/activity-CAovbq3e.js +0 -5
- package/dist/assets/activity-CFQyCvgu.js +0 -5
- package/dist/assets/activity-CdQf7zRK.js +0 -5
- package/dist/assets/activity-DACvyn2-.js +0 -5
- package/dist/assets/activity-DOwYydU-.js +0 -5
- package/dist/assets/common-BfVFjVhf.js +0 -1
- package/dist/assets/i18n-B0hsnanh.js +0 -2
- package/dist/assets/index-DHdO0CRE.js +0 -132
- package/dist/assets/index-DKrFQ76m.css +0 -1
- package/dist/assets/settings-B5xal2R3.js +0 -1
- package/dist/assets/settings-BHtFy8EG.js +0 -1
- package/dist/assets/settings-Bss5hBla.js +0 -1
- package/dist/assets/settings-BzrLCVRP.js +0 -1
- package/dist/assets/settings-C7RdvmLZ.js +0 -1
- package/dist/assets/settings-Dd94HoV6.js +0 -1
- package/dist/assets/settings-Dm9THFe8.js +0 -1
- package/dist/assets/stores-BptlyD_v.js +0 -7
- package/dist/assets/ui-store-BsBnjO3w.js +0 -1
- package/dist/assets/useWebSocket-Bc4S0N4r.js +0 -29
- package/dist/assets/ws-client-DqFoX4jJ.js +0 -1
- package/dist/lib/accent-colors.d.ts +0 -136
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Cn as t,Ft as n,Rr as r,Tt as i,Xt as a,an as o,dt as s,gi as c,jt as l,lt as u,vn as d,za as f}from"./vendor-BuarzSSb.js";import{t as p}from"./useWebSocket-Bc4S0N4r.js";import{t as m}from"./utils-B-9lSDIn.js";import{a as h,i as g,n as _,o as v,r as y,t as b}from"./dialog-ftgTihmF.js";import{t as x}from"./button-Dcy288Mc.js";import{t as S}from"./input-fo9-BPBC.js";import{C,S as w}from"./index-DHdO0CRE.js";import{g as T,i as E,r as D,y as O}from"./shared-KAzksK0C.js";var k=e(f(),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(),[a,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.listSageMemories({echoToChat:!1})},[e.listSageMemories]);(0,k.useEffect)(()=>{let t=e.client,n=t.on(`memory.sage.list`,e=>{let t=e.payload;t.error?O({tone:`error`,text:t.error}):u(t.memories??[]),E(!1)}),r=t.on(`memory.sage.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.sage.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.sage.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)(()=>a.filter(e=>{let t=e.audience;return!!(t&&(t.roles?.length||t.taskTypes?.length||t.modes?.length))}),[a]),Z=j.trim(),Q=(0,k.useMemo)(()=>X.filter(e=>N(e,Z)),[Z,X]),$=C(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.updateSage(t,{audience:void 0},{echoToChat:!1})},ce=()=>{H&&(J.current=H,q(!0),O(null),e.deleteSage(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)(t,{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)(o,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,A.jsx)(S,{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)(s,{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)(d,{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)(i,{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)(c,{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)(s,{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)(r,{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)(o,{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)(w,{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.rememberSage({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.rememberSage(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(a.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)(l,{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:t,onClearScope:n,onDelete:r}){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:t}),(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:n,"aria-label":`Remove audience scope from ${T(e.text,42)}`,title:`Make general memory`,children:(0,A.jsx)(a,{className:`size-3`})}),(0,A.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-6 text-destructive hover:text-destructive`,onClick:r,"aria-label":`Delete ${T(e.text,42)}`,title:`Delete`,children:(0,A.jsx)(l,{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)(t,{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)(S,{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,a]=(0,k.useState)(``);return(0,k.useEffect)(()=>{e||a(``)},[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=>a(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)(i,{className:`size-4`}),`Import memories`]})]})]})})}export{F as AudienceMemoryPanel};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{$i as t,Ei as n,Pa as r,b as i,dn as a,ir as o,lt as s,ri as c,un as l,vn as u,za as d}from"./vendor-BuarzSSb.js";import"./i18n-B0hsnanh.js";import{a as f,n as p,t as m}from"./monaco-BLUV5g0U.js";import{t as h}from"./ws-client-DqFoX4jJ.js";import{t as g}from"./utils-B-9lSDIn.js";import{P as _,v}from"./stores-BptlyD_v.js";import{b as y}from"./index-DHdO0CRE.js";import{t as b}from"./empty-state-RRSqQaCk.js";import{t as x}from"./monaco-theme-DSeCDzQy.js";var S=e(d(),1),C=s();p.config({monaco:m});var w={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 T(e){return w[e.split(`.`).pop()?.toLowerCase()??``]??`plaintext`}function E({path:e,oldText:n,newText:a}){let{t:s}=r(),c=(0,S.useRef)(null),[u,d]=(0,S.useState)(!1),[p,m]=(0,S.useState)(!1),[g,v]=(0,S.useState)(null);(0,S.useEffect)(()=>{d(!1),m(!1),v(null)},[]);let y=(0,S.useCallback)(e=>{c.current=e,f.setTheme(x()),e.getModifiedEditor().onDidChangeModelContent(()=>d(!0))},[]),b=(0,S.useCallback)(()=>{let t=c.current?.getModifiedEditor().getValue();if(t==null)return;m(!0);let n=h(_.getState().wsUrl),r=n.on(`files.written`,t=>{t.type===`files.written`&&t.payload.filePath===e&&(r(),clearTimeout(i),m(!1),t.payload.success&&(d(!1),v(Date.now())))}),i=setTimeout(()=>{r(),m(!1)},5e3);n.send({type:`files.write`,payload:{filePath:e,content:t}})},[e]),w=T(e);return(0,C.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,C.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,C.jsx)(`span`,{className:`text-xs font-mono text-muted-foreground truncate`,children:e}),(0,C.jsxs)(`button`,{type:`button`,onClick:b,disabled:!u||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:s(`activity:monacoDiff.applyTitle`),children:[p?(0,C.jsx)(o,{className:`h-3.5 w-3.5 animate-spin`}):g&&!u?(0,C.jsx)(t,{className:`h-3.5 w-3.5 text-success`}):(0,C.jsx)(l,{className:`h-3.5 w-3.5`}),s(p?`activity:monacoDiff.applying`:g&&!u?`activity:monacoDiff.applied`:`activity:monacoDiff.apply`)]})]}),(0,C.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-hidden`,children:(0,C.jsx)(i,{original:n,modified:a,language:w,theme:x(),onMount:y,options:{renderSideBySide:!0,readOnly:!1,originalEditable:!1,minimap:{enabled:!1},fontSize:13,scrollBeyondLastLine:!1,automaticLayout:!0}})})]})}var D=1e4;function O({className:e}){let{t}=r(),i=v(e=>e.selectedPath),s=v(e=>e.diff),l=v(e=>e.loadingDiff),[d,f]=(0,S.useState)(`unified`),[p,m]=(0,S.useState)(!1),x=!!i&&(l||!s);(0,S.useEffect)(()=>{if(m(!1),!x)return;let e=setTimeout(()=>m(!0),D);return()=>clearTimeout(e)},[x,i]);let w=()=>{i&&(m(!1),v.getState().setDiffLoading(!0),h(_.getState().wsUrl).getGitDiff?.(i))};if(!i)return(0,C.jsx)(b,{icon:(0,C.jsx)(c,{className:`h-6 w-6`}),title:`Source changes`,description:t(`activity:changes.selectPrompt`),className:e});let T=s&&!s.error&&!s.binary&&!s.tooLarge;return(0,C.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,C.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,C.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,C.jsxs)(`div`,{className:`min-w-0`,children:[(0,C.jsx)(`div`,{className:`text-[10px] font-semibold uppercase text-muted-foreground`,children:`Source control`}),(0,C.jsx)(`div`,{className:`truncate font-mono text-xs text-foreground`,title:i,children:i})]}),T&&(0,C.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,C.jsxs)(`button`,{type:`button`,onClick:()=>f(`unified`),title:t(`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,C.jsx)(a,{className:`h-3.5 w-3.5`}),` `,t(`activity:changes.unified`)]}),(0,C.jsxs)(`button`,{type:`button`,onClick:()=>f(`edit`),title:t(`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,C.jsx)(n,{className:`h-3.5 w-3.5`}),` `,t(`activity:changes.edit`)]})]})]}),(0,C.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:l||!s?p?(0,C.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center gap-3 p-4 text-center`,children:[(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`activity:changes.diffTimeout`)}),(0,C.jsxs)(`button`,{type:`button`,onClick:w,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,C.jsx)(u,{className:`h-3.5 w-3.5`}),` `,t(`common:action.retry`)]})]}):(0,C.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,C.jsx)(o,{className:`h-4 w-4 animate-spin`}),` `,t(`activity:changes.loadingDiff`)]}):s.error?(0,C.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-sm text-destructive`,children:s.error}):s.binary?(0,C.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-sm text-muted-foreground`,children:t(`activity:changes.binary`)}):s.tooLarge?(0,C.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-sm text-muted-foreground`,children:t(`activity:changes.tooLarge`)}):d===`edit`?(0,C.jsx)(E,{path:s.path,oldText:s.oldText??``,newText:s.newText??``},s.path):(0,C.jsx)(y,{oldText:s.oldText,newText:s.newText,caption:s.path,fill:!0})})]})})}export{O as ChangesView};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Nr as t,Oa as n,Ot as r,Rr as i,Vt as a,Xi as o,Zt as s,an as c,dt as l,ji as ee,la as u,lt as d,mn as te,oa as f,oi as p,ur as ne,vi as m,vn as re,za as h}from"./vendor-BuarzSSb.js";import{t as ie}from"./ws-client-DqFoX4jJ.js";import{t as g}from"./utils-B-9lSDIn.js";import{C as ae,S as oe}from"./index-DHdO0CRE.js";var _=e(h(),1),v=d();function se({status:e}){return(0,v.jsxs)(`section`,{className:`flex flex-wrap gap-x-5 gap-y-1 border-b border-border/60 bg-primary/[0.025] px-4 py-1.5 font-mono text-[9px] text-muted-foreground`,title:e.chronicleDirectory,children:[(0,v.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-primary`,children:`Chronicle ownership`}),(0,v.jsxs)(`span`,{children:[`collect `,(0,v.jsx)(`b`,{className:`text-foreground`,children:e.pipeline.collection})]}),(0,v.jsxs)(`span`,{children:[`process `,(0,v.jsx)(`b`,{className:`text-foreground`,children:e.pipeline.processing})]}),(0,v.jsxs)(`span`,{children:[`serve `,(0,v.jsx)(`b`,{className:`text-foreground`,children:e.pipeline.serving})]}),(0,v.jsxs)(`span`,{children:[`PID `,(0,v.jsx)(`b`,{className:`text-foreground`,children:e.pid}),` · `,e.clients,` clients`]}),(0,v.jsxs)(`span`,{children:[`watcher`,` `,(0,v.jsx)(`b`,{className:g(e.watcher.active?`text-success`:`text-warning`),children:e.watcher.active?`active`:`inactive`}),` `,`· `,e.watcher.watchedFiles,` files`]}),(0,v.jsxs)(`span`,{children:[`store `,(0,v.jsx)(`b`,{className:`text-foreground`,children:y(e.pipeline.storage)})]}),e.mode===`inline`&&(0,v.jsx)(`span`,{className:`font-sans font-semibold text-warning`,children:`INLINE FALLBACK`})]})}function y(e){return e.replaceAll(`\\`,`/`).split(`/`).filter(Boolean).slice(-3).join(`/`)}var b=[`eventType`,`providerId`,`modelId`,`outcome`,`resourceKind`],x=1440*60*1e3;function S(){return{limit:300,order:`desc`,from:new Date(Date.now()-x).toISOString()}}var ce=[{id:`all`,label:`All signals`,icon:(0,v.jsx)(n,{})},{id:`llm`,label:`LLM`,icon:(0,v.jsx)(f,{})},{id:`agents`,label:`Agents`,icon:(0,v.jsx)(u,{})},{id:`tools`,label:`Tools`,icon:(0,v.jsx)(a,{})},{id:`files`,label:`Files`,icon:(0,v.jsx)(p,{})},{id:`failures`,label:`Failures`,icon:(0,v.jsx)(r,{})}];function C(){let e=ie(),[t,n]=(0,_.useState)([]),[r,o]=(0,_.useState)(null),[s,d]=(0,_.useState)({}),[m,h]=(0,_.useState)(S()),[y,x]=(0,_.useState)({text:``,path:``,providerId:``,modelId:``,sessionId:``}),[C,w]=(0,_.useState)(`all`),[k,P]=(0,_.useState)({total:0,scannedEvents:0,sourceFiles:0,invalidLines:0}),[I,de]=(0,_.useState)(T),[L,R]=(0,_.useState)(!0),[z,B]=(0,_.useState)(null),[V,H]=(0,_.useState)(null),[U,fe]=(0,_.useState)([]),[W,pe]=(0,_.useState)([]),[G,me]=(0,_.useState)(null),K=(0,_.useCallback)(t=>{if(!e.supportsCapability(`chronicle.query`)){R(!1),B(`Restart the backend once to activate Chronicle protocol support.`);return}if(R(!0),B(null),h(t),d({}),e.send({type:`chronicle.query`,payload:{query:t}}),e.supportsCapability(`chronicle.facets`))e.send({type:`chronicle.facets`,payload:{fields:[...b],query:t,limit:12}});else for(let n of b)e.send({type:`chronicle.facet`,payload:{field:n,query:t,limit:12}})},[e]),q=(0,_.useCallback)(()=>{e.supportsCapability(`chronicle.metrics`)&&(e.send({type:`chronicle.metrics`,payload:{view:`providers`}}),e.send({type:`chronicle.metrics`,payload:{view:`tasks`,limit:200}}))},[e]),J=(0,_.useCallback)(()=>{e.supportsCapability(`chronicle.status`)&&e.send({type:`chronicle.status`})},[e]);(0,_.useEffect)(()=>{let t=e.on(`chronicle.query_result`,e=>{e.type===`chronicle.query_result`&&(n(e.payload.events),P(e.payload),de(e.payload.summary??T),R(!1))}),r=e.on(`chronicle.facet_result`,e=>{e.type===`chronicle.facet_result`&&d(t=>({...t,[e.payload.field]:e.payload.values}))}),i=e.on(`chronicle.facets_result`,e=>{e.type===`chronicle.facets_result`&&d(e.payload.values)}),a=e.on(`chronicle.error`,e=>{e.type===`chronicle.error`&&(B(e.payload.message),R(!1))}),o=e.on(`chronicle.graph_result`,e=>{e.type===`chronicle.graph_result`&&H(e.payload)}),s=e.on(`chronicle.metrics_result`,e=>{e.type===`chronicle.metrics_result`&&(e.payload.view===`providers`?fe(e.payload.data):e.payload.view===`tasks`&&pe(e.payload.data))}),c=e.on(`chronicle.status_result`,e=>{e.type===`chronicle.status_result`&&me(e.payload)});return K(S()),q(),J(),()=>{t(),r(),i(),a(),o(),s(),c()}},[e,K,q,J]);let Y=(0,_.useMemo)(()=>t.filter(e=>O(e,C)),[t,C]),X=ae(Y,25,C),Z=(0,_.useMemo)(()=>{let e=t.find(e=>e.eventType===`metrics.rollup`&&e.attributes?.signal===`runtime.health`)?.attributes?.stats;if(!e)return;let n=t=>e[t]?.last;return{eventLoop:{utilization:n(`eventLoop.utilization`),delayP95Ms:n(`eventLoop.delayP95Ms`)},memory:{heapUsedBytes:n(`memory.heapUsedBytes`)},chronicle:{pendingEvents:n(`chronicle.pendingEvents`),rejectedEvents:n(`chronicle.rejectedEvents`)}}},[t]),Q=(0,_.useMemo)(()=>{let e={};for(let t of W)e[t.status]=(e[t.status]??0)+1;let t=(e.completed??0)+(e.merged??0)+(e.failed??0)+(e.conflict??0),n=(e.completed??0)+(e.merged??0),r=[...W].sort((e,t)=>(t.endedAt??t.startedAt??``).localeCompare(e.endedAt??e.startedAt??``)).slice(0,8);return{counts:e,total:W.length,terminal:t,successRate:t>0?n/t*100:100,recent:r}},[W]),$=()=>K({...S(),...y.text?{text:y.text}:{},...y.path?{path:y.path}:{},...y.providerId?{providerId:y.providerId}:{},...y.modelId?{modelId:y.modelId}:{},...y.sessionId?{sessionId:y.sessionId}:{}}),he=()=>{x({text:``,path:``,providerId:``,modelId:``,sessionId:``}),w(`all`),K(S())},ge=t=>{o(t),H(null),e.supportsCapability(`chronicle.graph`)&&e.send({type:`chronicle.graph`,payload:{seed:{eventId:t.eventId},hops:2,maxNodes:250}})};return(0,v.jsxs)(`div`,{className:`flex h-full min-h-0 bg-background`,"data-testid":`chronicle-dashboard`,children:[(0,v.jsxs)(`main`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,v.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,v.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,v.jsxs)(`div`,{children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(f,{className:`h-5 w-5 text-primary`}),(0,v.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight`,children:`Coding Intelligence`}),(0,v.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,v.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`LLM, agent, tool and file evidence — connected from decision to code change.`})]}),(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(`span`,{className:g(`h-2 w-2 rounded-full`,z?`bg-destructive`:L?`animate-pulse bg-warning`:`bg-success`)}),(0,v.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:L?`Reading journal`:z?`Unavailable`:`Live evidence`}),(0,v.jsx)(`button`,{type:`button`,onClick:()=>{K(m),q(),J()},className:`ml-2 rounded-md border border-border bg-card p-2 hover:bg-muted`,title:`Refresh evidence`,children:(0,v.jsx)(re,{className:g(`h-4 w-4`,L&&`animate-spin`)})})]})]})}),(0,v.jsxs)(`section`,{className:`grid grid-cols-2 border-b border-border/70 xl:grid-cols-6`,children:[(0,v.jsx)(M,{icon:(0,v.jsx)(f,{}),label:`LLM requests`,value:I.logicalRequests,detail:`${I.modelAttempts} attempts · ${I.providers} providers · ${I.models} models`}),(0,v.jsx)(M,{icon:(0,v.jsx)(u,{}),label:`Agent work`,value:I.agentEvents,detail:`${I.uniqueAgents} correlated agents · ${I.decisions} decisions`}),(0,v.jsx)(M,{icon:(0,v.jsx)(a,{}),label:`Tool calls`,value:I.toolCalls,detail:`${I.failedTools} failed · ${I.processes} processes`}),(0,v.jsx)(M,{icon:(0,v.jsx)(p,{}),label:`File evidence`,value:I.fileEvents,detail:`${I.uniqueFiles} unique paths`}),(0,v.jsx)(M,{icon:(0,v.jsx)(te,{}),label:`Retries`,value:I.scheduledRetries,detail:`${I.failures} failures · ${I.fallbacks} fallbacks`,tone:I.failures?`danger`:`normal`}),(0,v.jsx)(M,{icon:(0,v.jsx)(ee,{}),label:`Provider p95`,value:A(I.providerP95DurationMs),detail:`${A(I.providerAvgDurationMs)} average · all matches`})]}),(0,v.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,v.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-primary`,children:`Token economics`}),(0,v.jsxs)(`span`,{children:[`fresh input `,(0,v.jsx)(`b`,{className:`text-foreground`,children:I.inputTokens.toLocaleString()})]}),(0,v.jsxs)(`span`,{children:[`output `,(0,v.jsx)(`b`,{className:`text-foreground`,children:I.outputTokens.toLocaleString()})]}),(0,v.jsxs)(`span`,{children:[`cache read `,(0,v.jsx)(`b`,{className:`text-foreground`,children:I.cacheReadTokens.toLocaleString()})]}),(0,v.jsxs)(`span`,{children:[`cache write`,` `,(0,v.jsx)(`b`,{className:`text-foreground`,children:I.cacheWriteTokens.toLocaleString()})]}),(0,v.jsxs)(`span`,{children:[`cache hit `,(0,v.jsxs)(`b`,{className:`text-foreground`,children:[D(I).toFixed(1),`%`]})]}),(0,v.jsxs)(`span`,{children:[`estimated cost `,(0,v.jsxs)(`b`,{className:`text-foreground`,children:[`$`,I.estimatedCostUsd.toFixed(4)]})]})]}),U.length>0&&(0,v.jsxs)(`section`,{className:`flex items-center gap-3 overflow-x-auto border-b border-border/60 bg-muted/[0.14] px-4 py-1.5`,children:[(0,v.jsx)(`span`,{className:`shrink-0 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:`Model reliability`}),U.slice(0,6).map(e=>{let t=e.completed+e.failed,n=t>0?e.completed/t*100:100;return(0,v.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 rounded-full border border-border bg-card px-2.5 py-0.5 font-mono text-[9px]`,title:`${e.day} · ${e.attempts} attempts · avg ${A(e.avgDurationMs)} · ${e.inputTokens.toLocaleString()} in / ${e.outputTokens.toLocaleString()} out`,children:[(0,v.jsx)(`span`,{className:g(`h-1.5 w-1.5 rounded-full`,n>=99?`bg-success`:n>=90?`bg-warning`:`bg-destructive`)}),(0,v.jsxs)(`span`,{className:`max-w-[180px] truncate`,children:[e.providerId,`/`,e.modelId]}),(0,v.jsxs)(`b`,{className:`text-foreground`,children:[n.toFixed(0),`%`]}),(0,v.jsx)(`span`,{className:`text-muted-foreground`,children:e.day.slice(5)})]},`${e.day}-${e.providerId}-${e.modelId}`)})]}),Q.total>0&&(0,v.jsxs)(`section`,{className:`flex items-center gap-3 overflow-x-auto border-b border-border/60 bg-muted/[0.10] px-4 py-1.5`,children:[(0,v.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,v.jsx)(ne,{className:`h-3 w-3`}),`Task outcomes`]}),(0,v.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 rounded-full border border-border bg-card px-2.5 py-0.5 font-mono text-[9px]`,title:`${Q.total} tasks tracked · ${Q.terminal} finished`,children:[(0,v.jsx)(`span`,{className:g(`h-1.5 w-1.5 rounded-full`,Q.successRate>=90?`bg-success`:Q.successRate>=60?`bg-warning`:`bg-destructive`)}),(0,v.jsxs)(`b`,{className:`text-foreground`,children:[Q.successRate.toFixed(0),`%`]}),(0,v.jsxs)(`span`,{className:`text-muted-foreground`,children:[`success · `,Q.total,` tasks`]})]}),[`completed`,`merged`,`failed`,`conflict`,`started`].filter(e=>Q.counts[e]).map(e=>(0,v.jsxs)(`span`,{className:`shrink-0 font-mono text-[9px] text-muted-foreground`,children:[e,` `,(0,v.jsx)(`b`,{className:g(e===`failed`||e===`conflict`?`text-destructive`:`text-foreground`),children:Q.counts[e]})]},e)),(0,v.jsx)(`span`,{className:`mx-1 h-3 w-px shrink-0 bg-border`}),Q.recent.map(e=>(0,v.jsxs)(`button`,{type:`button`,onClick:()=>K({limit:300,order:`desc`,taskId:e.taskId}),className:`flex shrink-0 items-center gap-1.5 rounded-full border border-border bg-card px-2 py-0.5 font-mono text-[9px] hover:border-primary/50`,title:`${e.taskId}${e.boardId?` · board ${e.boardId}`:``}${e.sessionId?` · ${e.sessionId}`:``} · ${e.filesTouched} files${e.retries?` · ${e.retries} retries`:``}${e.verificationFailures?` · ${e.verificationFailures} verify-fails`:``}`,children:[(0,v.jsx)(`span`,{className:g(`h-1.5 w-1.5 rounded-full`,e.status===`completed`||e.status===`merged`?`bg-success`:e.status===`failed`||e.status===`conflict`?`bg-destructive`:`bg-primary`)}),(0,v.jsx)(`span`,{className:`max-w-[84px] truncate`,children:e.taskId}),e.durationMs!==null&&(0,v.jsx)(`span`,{className:`text-muted-foreground`,children:A(e.durationMs)}),e.filesTouched>0&&(0,v.jsxs)(`span`,{className:`flex items-center gap-0.5 text-muted-foreground`,children:[(0,v.jsx)(p,{className:`h-2.5 w-2.5`}),e.filesTouched]})]},e.taskId))]}),(0,v.jsx)(`section`,{className:`border-b border-border/70 px-4 py-3`,children:(0,v.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 xl:grid-cols-[1.35fr_1fr_1fr_1fr_1fr_auto]`,children:[(0,v.jsx)(j,{icon:(0,v.jsx)(c,{}),placeholder:`Search event evidence`,value:y.text,onChange:e=>x(t=>({...t,text:e})),onEnter:$}),(0,v.jsx)(j,{placeholder:`File or directory`,value:y.path,onChange:e=>x(t=>({...t,path:e})),onEnter:$}),(0,v.jsx)(j,{placeholder:`Provider`,value:y.providerId,onChange:e=>x(t=>({...t,providerId:e})),onEnter:$}),(0,v.jsx)(j,{placeholder:`Model`,value:y.modelId,onChange:e=>x(t=>({...t,modelId:e})),onEnter:$}),(0,v.jsx)(j,{placeholder:`Session`,value:y.sessionId,onChange:e=>x(t=>({...t,sessionId:e})),onEnter:$}),(0,v.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,v.jsxs)(`button`,{type:`button`,onClick:$,className:`rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground`,children:[(0,v.jsx)(i,{className:`mr-1 inline h-3 w-3`}),`Apply`]}),(0,v.jsx)(`button`,{type:`button`,onClick:he,className:`rounded-md border border-border px-2.5 text-xs hover:bg-muted`,children:`Clear`})]})]})}),(0,v.jsxs)(`section`,{className:`flex items-center gap-1 overflow-x-auto border-b border-border/70 px-4 py-2`,children:[ce.map(e=>(0,v.jsxs)(`button`,{type:`button`,onClick:()=>w(e.id),className:g(`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`,C===e.id?`bg-primary/10 font-medium text-primary`:`text-muted-foreground hover:bg-muted hover:text-foreground`),children:[e.icon,e.label,(0,v.jsx)(`span`,{className:`ml-1 rounded bg-background/70 px-1 font-mono text-[9px]`,children:E(I,e.id,k.total)})]},e.id)),(0,v.jsxs)(`div`,{className:`ml-auto hidden items-center gap-3 pl-4 text-[9px] text-muted-foreground lg:flex`,children:[(0,v.jsxs)(`span`,{children:[k.total.toLocaleString(),` matched`]}),(0,v.jsxs)(`span`,{children:[k.sourceFiles,` journal files`]}),k.invalidLines>0&&(0,v.jsxs)(`span`,{className:`text-warning`,children:[k.invalidLines,` invalid lines`]})]})]}),G&&(0,v.jsx)(se,{status:G}),Z&&(0,v.jsx)(le,{health:Z}),(0,v.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,v.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,v.jsx)(`span`,{className:`mr-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e.replace(`Id`,``)}),(s[e]??[]).slice(0,4).map(t=>(0,v.jsxs)(`button`,{type:`button`,onClick:()=>K({...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,v.jsx)(`b`,{children:t.count})]},t.value))]},e))}),(0,v.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,v.jsx)(`span`,{children:`Time`}),(0,v.jsx)(`span`,{children:`Signal`}),(0,v.jsx)(`span`,{children:`Outcome`}),(0,v.jsx)(`span`,{children:`Model / agent`}),(0,v.jsx)(`span`,{children:`Resource`}),(0,v.jsx)(`span`,{})]}),(0,v.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:z?(0,v.jsx)(F,{text:z}):!L&&Y.length===0?(0,v.jsx)(F,{text:`No coding evidence matches these filters.`}):(0,v.jsx)(`div`,{className:`divide-y divide-border/40`,children:X.pageItems.map(e=>(0,v.jsx)(ue,{event:e,active:r?.eventId===e.eventId,onClick:()=>ge(e)},e.eventId))})}),(0,v.jsx)(oe,{page:X.page,pageSize:X.pageSize,totalItems:X.totalItems,onPageChange:X.setPage,itemLabel:`events`})]}),r&&(0,v.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,v.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,v.jsxs)(`div`,{children:[(0,v.jsx)(`div`,{className:`text-xs font-semibold`,children:`Evidence & lineage`}),(0,v.jsxs)(`div`,{className:`mt-0.5 font-mono text-[9px] text-muted-foreground`,children:[`#`,r.sequence,` · `,r.eventId]})]}),(0,v.jsx)(`button`,{type:`button`,onClick:()=>o(null),className:`rounded p-1 hover:bg-muted`,children:(0,v.jsx)(l,{className:`h-4 w-4`})})]}),(0,v.jsx)(N,{event:r,graph:V})]})]})}var w={llm:0,agent:0,tool:0,file:0,memory:0,task:0,decision:0,runtime:0},T={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:{...w},failuresByFamily:{...w}};function E(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 D(e){let t=e.inputTokens+e.cacheReadTokens;return t?e.cacheReadTokens/t*100:0}function O(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 k(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 A(e){return e?e<1?`${(e*1e3).toFixed(0)}µs`:e<1e3?`${e.toFixed(1)}ms`:`${(e/1e3).toFixed(1)}s`:`—`}function j({placeholder:e,value:t,onChange:n,onEnter:r,icon:i}){return(0,v.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,v.jsx)(`span`,{className:`text-muted-foreground [&>svg]:h-3.5 [&>svg]:w-3.5`,children:i}),(0,v.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 M({icon:e,label:t,value:n,detail:r,tone:i=`normal`}){return(0,v.jsxs)(`div`,{className:`min-w-0 border-r border-border/60 px-4 py-3`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,v.jsx)(`span`,{className:`text-primary [&>svg]:h-3.5 [&>svg]:w-3.5`,children:e}),t]}),(0,v.jsx)(`div`,{className:g(`mt-1 text-xl font-semibold tabular-nums`,i===`danger`&&`text-destructive`),children:typeof n==`number`?n.toLocaleString():n}),(0,v.jsx)(`div`,{className:`mt-0.5 truncate text-[9px] text-muted-foreground`,children:r})]})}function le({health:e}){return(0,v.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,v.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-success`,children:`Collector healthy`}),(0,v.jsxs)(`span`,{children:[`ELU`,` `,(0,v.jsxs)(`b`,{className:`text-foreground`,children:[((e.eventLoop?.utilization??0)*100).toFixed(1),`%`]})]}),(0,v.jsxs)(`span`,{children:[`p95 `,(0,v.jsxs)(`b`,{className:`text-foreground`,children:[(e.eventLoop?.delayP95Ms??0).toFixed(1),`ms`]})]}),(0,v.jsxs)(`span`,{children:[`heap`,` `,(0,v.jsxs)(`b`,{className:`text-foreground`,children:[((e.memory?.heapUsedBytes??0)/1048576).toFixed(0),`MB`]})]}),(0,v.jsxs)(`span`,{children:[`queue `,(0,v.jsx)(`b`,{className:`text-foreground`,children:e.chronicle?.pendingEvents??0})]}),(0,v.jsxs)(`span`,{children:[`dropped`,` `,(0,v.jsx)(`b`,{className:g((e.chronicle?.rejectedEvents??0)>0&&`text-destructive`),children:e.chronicle?.rejectedEvents??0})]})]})}function ue({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,v.jsxs)(`button`,{type:`button`,onClick:n,className:g(`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,v.jsx)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:new Date(r).toLocaleTimeString()}),(0,v.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,v.jsx)(`span`,{className:g(`h-1.5 w-1.5 shrink-0 rounded-full`,e.outcome===`failure`?`bg-destructive`:e.outcome===`success`?`bg-success`:`bg-primary`)}),(0,v.jsx)(`span`,{className:`truncate font-mono text-[11px] font-medium`,children:e.eventType})]}),(0,v.jsx)(`span`,{className:g(`w-fit rounded px-1.5 py-0.5 text-[9px]`,I(e.outcome)),children:e.outcome??`unknown`}),(0,v.jsx)(`span`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:i}),(0,v.jsx)(`span`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:a}),(0,v.jsx)(o,{className:`h-3.5 w-3.5 text-muted-foreground`})]})}function N({event:e,graph:n}){let r=(0,_.useMemo)(()=>[[`Scope`,e.scope],[`Correlation`,e.correlation],[`Runtime`,e.runtime],[`Resource`,e.resource],[`Attributes`,e.attributes],[`Tags`,e.tags]],[e]);return(0,v.jsxs)(`div`,{className:`p-4`,children:[(0,v.jsxs)(`div`,{className:`mb-4 rounded-lg border border-border bg-background/60 p-3`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(`span`,{className:g(`h-2 w-2 rounded-full`,e.outcome===`failure`?`bg-destructive`:e.outcome===`success`?`bg-success`:`bg-primary`)}),(0,v.jsx)(`span`,{className:`font-mono text-xs font-semibold`,children:e.eventType})]}),(0,v.jsxs)(`div`,{className:`mt-2 flex gap-4 text-[9px] text-muted-foreground`,children:[(0,v.jsx)(`span`,{children:new Date(e.occurredAt??e.observedAt).toLocaleString()}),(0,v.jsx)(`span`,{children:k(Number(e.durationNs??0))})]})]}),(0,v.jsxs)(`div`,{className:`mb-4 grid grid-cols-2 gap-2`,children:[(0,v.jsx)(P,{icon:(0,v.jsx)(s,{}),label:`Evidence hash`,value:e.hash.slice(0,16)}),(0,v.jsx)(P,{icon:(0,v.jsx)(m,{}),label:`Sequence`,value:String(e.sequence)})]}),n&&(0,v.jsxs)(`section`,{className:`mb-4`,children:[(0,v.jsxs)(`h3`,{className:`mb-1.5 flex items-center gap-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,v.jsx)(t,{className:`h-3 w-3`}),`Lineage · `,n.nodes.length,` nodes · `,n.edges.length,` edges`]}),(0,v.jsx)(`div`,{className:`space-y-1 rounded-md border border-border bg-background/70 p-2`,children:n.edges.slice(0,40).map((e,t)=>(0,v.jsxs)(`div`,{className:`flex items-center gap-2 font-mono text-[9px]`,children:[(0,v.jsx)(`span`,{className:g(`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,v.jsx)(`span`,{className:`text-muted-foreground`,children:e.kind}),(0,v.jsxs)(`span`,{className:`truncate`,children:[n.nodes.find(t=>t.eventId===e.from)?.eventType,` →`,` `,n.nodes.find(t=>t.eventId===e.to)?.eventType]})]},`${e.from}-${e.to}-${e.kind}-${t}`))}),n.truncated&&(0,v.jsx)(`p`,{className:`mt-1 text-[9px] text-warning`,children:`Lineage truncated at safety limit.`})]}),r.map(([e,t])=>t&&(0,v.jsxs)(`section`,{className:`mb-4`,children:[(0,v.jsx)(`h3`,{className:`mb-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e}),(0,v.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 P({icon:e,label:t,value:n}){return(0,v.jsxs)(`div`,{className:`rounded-md border border-border p-2`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-1 text-[8px] uppercase text-muted-foreground`,children:[(0,v.jsx)(`span`,{className:`[&>svg]:h-3 [&>svg]:w-3`,children:e}),t]}),(0,v.jsx)(`div`,{className:`mt-1 truncate font-mono text-[9px]`,children:n})]})}function F({text:e}){return(0,v.jsx)(`div`,{className:`flex h-48 items-center justify-center text-sm text-muted-foreground`,children:e})}function I(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{C as ChronicleDashboard};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Fi as t,Nr as n,Oa as r,Pa as i,Qi as a,Qt as o,Ui as s,Vt as c,Xr as l,Yi as u,ar as d,dt as f,in as p,ir as m,la as h,lt as g,ri as _,si as v,vn as y,y as b,yt as x,za as S}from"./vendor-BuarzSSb.js";import"./i18n-B0hsnanh.js";import{a as C,i as w,n as T,o as E,r as D,t as O}from"./monaco-BLUV5g0U.js";import{t as ee}from"./ws-client-DqFoX4jJ.js";import{t as k}from"./utils-B-9lSDIn.js";import{i as te}from"./codemap-activity-store-DQfjo7-j.js";import{P as ne,c as re,f as ie,j as A,k as j}from"./stores-BptlyD_v.js";import{o as M}from"./view-navigation-DxfiZrXS.js";import{A as N,b as ae,x as P}from"./index-DHdO0CRE.js";import{t as F}from"./empty-state-RRSqQaCk.js";import{t as I}from"./monaco-theme-DSeCDzQy.js";var L={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`},R=Array.from(new Set(Object.values(L))).filter(e=>e!==`plaintext`),z=12e3,B=4e3,oe=5e3,V=1e4;function H(e){return L[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 K(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 q=e(S(),1),J=g();function se(e){let t=new Set,n=new Set,r=new Set,i=new Set,a=new Set,o,s;for(let c of e)c.sessionId&&t.add(c.sessionId),c.taskId&&n.add(c.taskId),c.boardId&&r.add(c.boardId),c.toolName&&i.add(c.toolName),c.modelId&&a.add(c.modelId),(!o||c.occurredAt<o)&&(o=c.occurredAt),(!s||c.occurredAt>s)&&(s=c.occurredAt);return{mutations:e.length,sessions:t.size,tasks:n.size,boards:r.size,tools:[...i],models:[...a],firstAt:o,lastAt:s}}var Y=150,ce=224,le=38,X=/(write|edit|update|create|delete|rename|modified|changed)/i;function Z(e){return e.replace(/\\/g,`/`).replace(/^\.\//,``).replace(/\/{2,}/g,`/`).toLowerCase()}function Q(e,t){let n=Z(e),r=Z(t);return n===r||n.endsWith(`/${r}`)||r.endsWith(`/${n}`)}function ue(e,t=Date.now()){let n=e.filter(e=>t-e.at<=30*6e4),r=n.filter(e=>X.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 $(e){return typeof e==`string`&&e.length>0?e:void 0}function de(e){let t=Date.parse(e.occurredAt??e.observedAt);return Number.isFinite(t)?t:Date.now()}function fe(e){let t=e.attributes??{},n=$(t.operation)??e.eventType,r=e.scope.agentId,i=e.runtime?.providerId,a=e.runtime?.modelId;return{id:e.eventId,at:de(e),action:n,actor:r??i??$(t.actor)??`external`,source:$(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??$(t.taskId),boardId:$(t.boardId)??e.scope.boardId,tool:$(t.toolName),status:e.outcome,raw:e}}function pe(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 me(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 he(e){return e?e.split(/\r?\n/).length:0}function ge(e){return new TextEncoder().encode(e).length}function _e(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function ve(e){return e.length>18?`${e.slice(0,8)}…${e.slice(-6)}`:e}function ye(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 be({file:e}){let{t}=i(),[o,l]=(0,q.useState)(!0),[f,p]=(0,q.useState)(ce),[m,h]=(0,q.useState)(`overview`),[g,b]=(0,q.useState)([]),[x,S]=(0,q.useState)([]),[C,w]=(0,q.useState)(!1),[T,E]=(0,q.useState)(null),[D,O]=(0,q.useState)(null),A=(0,q.useRef)(null),j=ne(e=>e.wsUrl),M=te(e=>e.history),N=te(e=>e.activeOperations),P=ie(e=>e.activeBoard),F=re(e=>e.snapshot),I=(0,q.useMemo)(()=>ee(j),[j]),L=(0,q.useCallback)(()=>{E(null),w(!0),typeof I.getGitDiff==`function`&&I.getGitDiff(e.path);let t=typeof I.supportsCapability==`function`?I.supportsCapability.bind(I):null;t?.(`chronicle.query`)?I.send({type:`chronicle.query`,payload:{query:{path:e.path,resourceKind:`file`,order:`desc`,limit:150}}}):w(!1),t?.(`chronicle.metrics`)&&I.send({type:`chronicle.metrics`,payload:{view:`files`,path:e.path,limit:1e3}})},[I,e.path]);(0,q.useEffect)(()=>{b([]),S([]),O(null);let t=I.on(`chronicle.query_result`,t=>{if(t.type!==`chronicle.query_result`)return;let n=t.payload.events.filter(t=>t.resource?.path&&Q(t.resource.path,e.path));t.payload.events.length>0&&n.length===0||(b(n),w(!1))}),n=I.on(`chronicle.metrics_result`,t=>{t.type!==`chronicle.metrics_result`||t.payload.view!==`files`||S(t.payload.data.filter(t=>Q(t.path,e.path)))}),r=I.on(`chronicle.error`,e=>{e.type===`chronicle.error`&&(E(e.payload.message),w(!1))}),i=I.on(`git.diff`,t=>{if(t.type!==`git.diff`||!Q(t.payload.path,e.path))return;let n=t.payload;if(n.error||n.binary||n.tooLarge){O({text:e.savedContent,available:!1,error:n.error});return}O({text:n.oldText??``,available:!0})});return L(),()=>{t(),n(),r(),i()}},[I,e.path,e.savedContent,L]),(0,q.useEffect)(()=>{let e=e=>{if(!A.current)return;let t=A.current.startY-e.clientY,n=Math.max(Y,Math.floor(window.innerHeight*.62));p(Math.min(n,Math.max(Y,A.current.startHeight+t)))},t=()=>{A.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 R=(0,q.useMemo)(()=>{let t=[];for(let[n,r]of M)Q(n,e.path)&&t.push(...r);for(let n of N.values())t.push(...n.filter(t=>Q(t.filePath,e.path)));return t},[N,e.path,M]),z=(0,q.useMemo)(()=>me([...R.map(pe),...g.map(fe)]),[g,R]),B=(0,q.useMemo)(()=>ue(z),[z]),oe=(0,q.useMemo)(()=>se(x),[x]),V=D?.text??e.savedContent,H=(0,q.useMemo)(()=>ye(V,e.content),[V,e.content]),U=(0,q.useMemo)(()=>[...new Set(z.map(e=>e.sessionId).filter(e=>!!e))],[z]),W=(0,q.useMemo)(()=>[...new Set(z.map(e=>e.actor).filter(Boolean))],[z]),G=(0,q.useMemo)(()=>[...new Set(z.map(e=>e.taskId).filter(e=>!!e))],[z]),K=(0,q.useCallback)(e=>{let t=P?.tasks.find(t=>t.id===e),n=F?.tasks.find(t=>t.id===e||t.shortId===e);return t?.title??n?.title??e},[P,F]),X=e=>{o||l(!0),A.current={startY:e.clientY,startHeight:o?f:Y},document.body.style.cursor=`ns-resize`,document.body.style.userSelect=`none`},Z=[{id:`overview`,label:t(`activity:fileActivity.overview`),icon:(0,J.jsx)(r,{})},{id:`changes`,label:t(`activity:fileActivity.changes`),icon:(0,J.jsx)(_,{})},{id:`context`,label:t(`activity:fileActivity.context`),icon:(0,J.jsx)(d,{})},{id:`logs`,label:t(`activity:fileActivity.logs`),icon:(0,J.jsx)(c,{})}];return(0,J.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:o?f:le},"data-testid":`file-activity-drawer`,children:[(0,J.jsx)(`button`,{type:`button`,"aria-label":t(`activity:fileActivity.resizeHint`),className:`group relative block h-2 w-full cursor-ns-resize touch-none`,onPointerDown:X,onDoubleClick:()=>{l(!0),p(ce)},title:t(`activity:fileActivity.resizeHint`),children:(0,J.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,J.jsxs)(`header`,{className:`flex h-[30px] min-w-0 items-center gap-2 border-b border-border/70 px-2.5`,children:[(0,J.jsxs)(`button`,{type:`button`,onClick:()=>l(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":o,children:[(0,J.jsx)(v,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,J.jsx)(`span`,{className:`truncate`,children:t(`activity:fileActivity.title`)}),o?(0,J.jsx)(a,{className:`h-3 w-3`}):(0,J.jsx)(u,{className:`h-3 w-3`})]}),(0,J.jsx)(`span`,{className:`hidden h-3 w-px bg-border sm:block`}),(0,J.jsx)(xe,{label:`${he(e.content)} ${t(`activity:fileActivity.lines`)}`}),(0,J.jsx)(xe,{label:_e(ge(e.content))}),!H.large&&(H.added>0||H.removed>0)&&(0,J.jsxs)(`span`,{className:`hidden items-center gap-1 font-mono text-[10px] md:flex`,children:[(0,J.jsxs)(`span`,{className:`text-success`,children:[`+`,H.added]}),(0,J.jsxs)(`span`,{className:`text-destructive`,children:[`−`,H.removed]})]}),(0,J.jsxs)(`span`,{className:k(`ml-auto inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[9px] font-semibold uppercase tracking-wide`,B.level===`churn`&&`bg-destructive/10 text-destructive`,B.level===`active`&&`bg-warning/10 text-warning`,B.level===`quiet`&&`bg-success/10 text-success`),children:[(0,J.jsx)(s,{className:`h-2.5 w-2.5`}),t(`activity:fileActivity.level.${B.level}`)]}),(0,J.jsx)(`span`,{className:`hidden text-[9px] text-muted-foreground lg:inline`,children:t(`activity:fileActivity.evidenceCount`,{count:z.length})}),o&&(0,J.jsx)(`button`,{type:`button`,onClick:L,className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,title:t(`activity:fileActivity.refresh`),children:(0,J.jsx)(y,{className:k(`h-3.5 w-3.5`,C&&`animate-spin`)})})]}),o&&(0,J.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,J.jsxs)(`nav`,{className:`flex shrink-0 items-center gap-0.5 border-b border-border/60 bg-muted/20 px-2`,children:[Z.map(e=>(0,J.jsxs)(`button`,{type:`button`,onClick:()=>h(e.id),className:k(`inline-flex h-7 items-center gap-1.5 border-b-2 px-2 text-[10px] transition-colors [&>svg]:h-3 [&>svg]:w-3`,m===e.id?`border-primary font-medium text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`),children:[e.icon,e.label]},e.id)),T&&(0,J.jsx)(`span`,{className:`ml-auto truncate px-2 text-[9px] text-warning`,children:T})]}),(0,J.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[m===`overview`&&(0,J.jsx)(Se,{analysis:B,lifetime:oe,records:z,sessions:U,agents:W,tasks:G,taskLabel:K}),m===`changes`&&(0,J.jsxs)(`div`,{className:`h-full min-h-[120px] p-2`,children:[(0,J.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2 text-[9px] text-muted-foreground`,children:[(0,J.jsx)(n,{className:`h-3 w-3`}),(0,J.jsx)(`span`,{children:D?.available?t(`activity:fileActivity.gitToBuffer`):t(`activity:fileActivity.savedToBuffer`)}),e.dirty&&(0,J.jsx)(`span`,{className:`rounded bg-warning/10 px-1.5 py-0.5 text-warning`,children:t(`activity:fileActivity.unsaved`)}),D?.error&&(0,J.jsx)(`span`,{className:`truncate text-warning`,children:D.error})]}),(0,J.jsx)(`div`,{className:`h-[calc(100%-24px)] min-h-[90px]`,children:(0,J.jsx)(ae,{oldText:V,newText:e.content,caption:e.path,fill:!0})})]}),m===`context`&&(0,J.jsx)(we,{sessions:U,agents:W,tasks:G,records:z,taskLabel:K,boardTitle:P?.title??F?.title}),m===`logs`&&(0,J.jsx)(De,{records:z,loading:C})]})]})]})}function xe({label:e}){return(0,J.jsx)(`span`,{className:`hidden whitespace-nowrap font-mono text-[9px] text-muted-foreground sm:inline`,children:e})}function Se({analysis:e,lifetime:t,records:n,sessions:r,agents:a,tasks:s,taskLabel:c}){let{t:l}=i();return(0,J.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,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(`div`,{className:`grid grid-cols-4 gap-1.5`,children:[{label:l(`activity:fileActivity.mutations30m`),value:e.mutationCount,icon:(0,J.jsx)(_,{})},{label:l(`activity:fileActivity.sessions`),value:r.length,icon:(0,J.jsx)(x,{})},{label:l(`activity:fileActivity.actors`),value:a.length,icon:(0,J.jsx)(h,{})},{label:l(`activity:fileActivity.linkedWork`),value:s.length,icon:(0,J.jsx)(d,{})}].map(e=>(0,J.jsxs)(`div`,{className:`rounded-md border border-border/70 bg-background/45 px-2 py-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1 text-[9px] text-muted-foreground [&>svg]:h-3 [&>svg]:w-3`,children:[e.icon,(0,J.jsx)(`span`,{className:`truncate`,children:e.label})]}),(0,J.jsx)(`div`,{className:`mt-0.5 font-mono text-sm font-semibold`,children:e.value})]},e.label))}),t.mutations>0&&(0,J.jsx)(Ce,{lifetime:t}),(0,J.jsxs)(`div`,{className:k(`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,J.jsx)(o,{className:k(`mt-0.5 h-3.5 w-3.5 shrink-0`,e.level===`churn`?`text-destructive`:`text-primary`)}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`font-semibold`,children:l(`activity:fileActivity.analysisTitle.${e.level}`)}),(0,J.jsx)(`p`,{className:`mt-0.5 text-muted-foreground`,children:l(`activity:fileActivity.analysisBody.${e.level}`,{mutations:e.mutationCount,actors:e.actorCount,sessions:e.sessionCount})})]})]}),s.length>0&&(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 text-[9px]`,children:[(0,J.jsxs)(`span`,{className:`text-muted-foreground`,children:[l(`activity:fileActivity.workLinks`),`:`]}),s.slice(0,4).map(e=>(0,J.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:c(e)},e))]})]}),(0,J.jsxs)(`div`,{className:`min-w-0 rounded-md border border-border/70 bg-background/35`,children:[(0,J.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:l(`activity:fileActivity.recentActivity`)}),(0,J.jsx)(`div`,{className:`divide-y divide-border/40`,children:n.length===0?(0,J.jsx)(ke,{text:l(`activity:fileActivity.noEvidence`)}):n.slice(0,5).map(e=>(0,J.jsx)(Oe,{record:e},`${e.id}:${e.at}`))})]})]})}function Ce({lifetime:e}){let{t}=i(),n=[{value:e.mutations,label:t(`activity:fileActivity.lifetimeChanges`)},{value:e.sessions,label:t(`activity:fileActivity.lifetimeSessions`)},{value:e.tasks,label:t(`activity:fileActivity.lifetimeTasks`)},{value:e.boards,label:t(`activity:fileActivity.lifetimeBoards`)}],r=e.firstAt?new Date(e.firstAt).toLocaleDateString():void 0;return(0,J.jsxs)(`div`,{className:`rounded-md border border-primary/15 bg-primary/[0.03] px-2.5 py-2`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[9px] font-semibold uppercase tracking-wider text-primary [&>svg]:h-3 [&>svg]:w-3`,children:[(0,J.jsx)(v,{}),t(`activity:fileActivity.lifetimeTitle`)]}),(0,J.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1 font-mono text-[9px] text-muted-foreground`,children:[n.map(e=>(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`b`,{className:`text-foreground`,children:e.value.toLocaleString()}),` `,e.label]},e.label)),r&&(0,J.jsx)(`span`,{children:t(`activity:fileActivity.lifetimeSince`,{date:r})})]}),e.tools.length>0&&(0,J.jsx)(`div`,{className:`mt-1 truncate font-mono text-[8px] text-muted-foreground`,title:e.tools.join(`, `),children:t(`activity:fileActivity.lifetimeTools`,{tools:e.tools.slice(0,6).join(`, `)})})]})}function we({sessions:e,agents:t,tasks:n,records:r,taskLabel:a,boardTitle:o}){let{t:s}=i();return(0,J.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,J.jsx)(Te,{icon:(0,J.jsx)(x,{}),title:s(`activity:fileActivity.sessions`),empty:s(`activity:fileActivity.noSessions`),children:e.map(e=>(0,J.jsx)(Ee,{title:ve(e),subtitle:`${r.filter(t=>t.sessionId===e).length} ${s(`activity:fileActivity.events`)}`,raw:e},e))}),(0,J.jsx)(Te,{icon:(0,J.jsx)(h,{}),title:s(`activity:fileActivity.actors`),empty:s(`activity:fileActivity.noActors`),children:t.map(e=>(0,J.jsx)(Ee,{title:e,subtitle:`${r.filter(t=>t.actor===e).length} ${s(`activity:fileActivity.events`)}`},e))}),(0,J.jsx)(Te,{icon:(0,J.jsx)(d,{}),title:s(`activity:fileActivity.workLinks`),empty:s(`activity:fileActivity.noWorkLinks`),children:n.map(e=>(0,J.jsx)(Ee,{title:a(e),subtitle:o??s(`activity:fileActivity.taskOrTodo`),raw:e},e))})]})}function Te({icon:e,title:t,empty:n,children:r}){let i=Array.isArray(r)?r.length>0:!!r;return(0,J.jsxs)(`section`,{className:`min-w-0 p-2`,children:[(0,J.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,J.jsx)(`div`,{className:`space-y-1`,children:i?r:(0,J.jsx)(ke,{text:n})})]})}function Ee({title:e,subtitle:t,raw:n}){return(0,J.jsxs)(`div`,{className:`rounded-md border border-border/60 bg-background/45 px-2 py-1.5`,title:n,children:[(0,J.jsx)(`div`,{className:`truncate text-[10px] font-medium`,children:e}),(0,J.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[8px] text-muted-foreground`,children:t})]})}function De({records:e,loading:t}){let{t:n}=i();return t&&e.length===0?(0,J.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-[10px] text-muted-foreground`,children:[(0,J.jsx)(m,{className:`h-3.5 w-3.5 animate-spin`}),n(`activity:fileActivity.loadingEvidence`)]}):e.length===0?(0,J.jsx)(ke,{text:n(`activity:fileActivity.noEvidence`)}):(0,J.jsx)(`div`,{className:`divide-y divide-border/40`,children:e.map(e=>(0,J.jsx)(Oe,{record:e,raw:!0},`${e.id}:${e.at}`))})}function Oe({record:e,raw:t=!1}){let n=(0,J.jsxs)(`div`,{className:`grid grid-cols-[62px_74px_minmax(90px,.7fr)_minmax(160px,1.5fr)] items-center gap-2 text-[9px]`,children:[(0,J.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:new Date(e.at).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}),(0,J.jsx)(`span`,{className:k(`w-fit rounded px-1.5 py-0.5 font-mono`,X.test(e.action)?`bg-warning/10 text-warning`:`bg-primary/10 text-primary`),children:e.action}),(0,J.jsx)(`span`,{className:`truncate`,title:e.agentId,children:e.actor}),(0,J.jsx)(`span`,{className:`truncate text-muted-foreground`,title:e.summary,children:e.summary})]});return t?(0,J.jsxs)(`details`,{className:`group cursor-pointer px-2.5 py-1.5`,children:[(0,J.jsx)(`summary`,{className:`list-none [&::-webkit-details-marker]:hidden`,children:n}),(0,J.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,J.jsx)(`div`,{className:`px-2.5 py-1.5`,children:n})}function ke({text:e}){return(0,J.jsx)(`div`,{className:`px-3 py-3 text-center text-[10px] text-muted-foreground`,children:e})}T.config({monaco:O});function Ae(e){switch(e){case`method`:return E.CompletionItemKind.Method;case`function`:return E.CompletionItemKind.Function;case`constructor`:return E.CompletionItemKind.Constructor;case`field`:return E.CompletionItemKind.Field;case`variable`:return E.CompletionItemKind.Variable;case`class`:return E.CompletionItemKind.Class;case`interface`:return E.CompletionItemKind.Interface;case`module`:return E.CompletionItemKind.Module;case`property`:return E.CompletionItemKind.Property;case`unit`:return E.CompletionItemKind.Unit;case`value`:return E.CompletionItemKind.Value;case`enum`:return E.CompletionItemKind.Enum;case`keyword`:return E.CompletionItemKind.Keyword;case`snippet`:return E.CompletionItemKind.Snippet;case`file`:return E.CompletionItemKind.File;case`reference`:return E.CompletionItemKind.Reference;default:return E.CompletionItemKind.Text}}function je(){let e=j(e=>e.openFiles),n=j(e=>e.activeFilePath),r=j(e=>e.setActiveFile),i=j(e=>e.closeFile);return e.length===0?null:(0,J.jsx)(`div`,{className:`flex items-center border-b bg-muted/40 overflow-x-auto shrink-0`,children:e.map(e=>{let a=e.path===n,o=e.path.split(`/`).pop()??e.path;return(0,J.jsxs)(`button`,{type:`button`,onClick:()=>r(e.path),onMouseDown:t=>{t.button===1&&(t.preventDefault(),i(e.path))},className:k(`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`,a?`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,J.jsx)(t,{className:`h-2 w-2 fill-current text-primary shrink-0`}),(0,J.jsx)(`span`,{className:`truncate`,children:o}),(0,J.jsx)(f,{className:k(`h-3 w-3 shrink-0 rounded-sm hover:bg-muted-foreground/20 opacity-0 group-hover:opacity-100 transition-opacity`,a&&`opacity-100`),onClick:t=>{t.stopPropagation(),i(e.path)}})]},e.path)})})}function Me(){let{t:e}=i(),t=j(e=>e.openFiles),n=j(e=>e.activeFilePath),r=j(e=>e.updateContent),{theme:a}=N(),o=(0,q.useRef)(null),s=(0,q.useRef)(n),c=(0,q.useRef)(new Map),u=(0,q.useMemo)(()=>t.find(e=>e.path===n)??null,[t,n]),d=n?H(n):`plaintext`,f=I(),[m,h]=(0,q.useState)(!1);(0,q.useEffect)(()=>{s.current=n},[n]),(0,q.useEffect)(()=>{let e=I();C.setTheme(e)},[a]),(0,q.useEffect)(()=>{let e=R.map(e=>E.registerCompletionItemProvider(e,{triggerCharacters:[`.`,`_`],provideCompletionItems:async(e,t,n,r)=>{let i=s.current;if(!i)return{suggestions:[]};let a=e.getOffsetAt(t),o=e.getValue(),l=o.slice(Math.max(0,a-z),a),u=o.slice(a,a+B),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},_=ee(ne.getState().wsUrl),v=e=>e.map((e,t)=>({label:e.label,kind:Ae(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`?E.CompletionItemInsertTextRule.InsertAsSnippet:void 0})),y=K({filePath:i,language:e.getLanguageId(),lineNumber:t.lineNumber,column:t.column,versionId:e.getVersionId(),triggerCharacter:n.triggerCharacter,linePrefix:d,suffix:u}),b=c.current.get(y);return b&&b.expiresAt>Date.now()?{suggestions:v(b.items)}:await new Promise(a=>{let s=!1,d=()=>{},h=null,g,b=e=>{s||(s=!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&&(c.current.set(y,{expiresAt:Date.now()+V,items:t.payload.items}),b(v(t.payload.items)))}),g=window.setTimeout(()=>b([]),oe),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:l,suffix:u,triggerCharacter:n.triggerCharacter,triggerKind:n.triggerKind,allowLlm:G(p,f)})})}}));return()=>{e.forEach(e=>{e.dispose()})}},[]);let g=(0,q.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,q.useCallback)(()=>{M(`chat`),requestAnimationFrame(()=>{document.querySelector(`[data-chat-textarea]`)?.focus()})},[]),v=(0,q.useCallback)(()=>{let e=s.current;if(!e)return;let t=g();t&&(A.getState().addRef({kind:`snippet`,path:e,startLine:t.startLine,endLine:t.endLine,content:t.content}),_())},[g,_]),y=(0,q.useCallback)(()=>{let e=s.current;e&&(A.getState().addRef({kind:`file`,path:e}),_())},[_]),x=(0,q.useCallback)(t=>{o.current=t,C.setTheme(I()),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:[w.CtrlCmd|w.Shift|D.KeyL],run:e=>{let t=e.getSelection();t&&!t.isEmpty()?v():y()}})},[v,y]),S=(0,q.useCallback)(e=>{n&&e!==void 0&&r(n,e)},[n,r]);return(0,q.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&&j.getState().closeFile(n)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),t.length===0?(0,J.jsx)(F,{title:e(`activity:codeEditor.noFilesOpen`),description:e(`activity:codeEditor.selectToEdit`)}):(0,J.jsxs)(`div`,{className:`flex h-full min-w-0 flex-col overflow-hidden`,children:[(0,J.jsx)(je,{}),(0,J.jsxs)(`div`,{className:`relative min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(m||u)&&(0,J.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,J.jsxs)(`button`,{type:`button`,onClick:m?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(m?`activity:codeEditor.sendSelectedTitle`:`activity:codeEditor.mentionFileTitle`),children:[m?(0,J.jsx)(p,{className:`h-3 w-3`}):(0,J.jsx)(l,{className:`h-3 w-3`}),(0,J.jsx)(`span`,{children:e(m?`activity:codeEditor.sendToChat`:`activity:codeEditor.mentionFile`)})]})}),u?(0,J.jsx)(b,{language:d,value:u.content,onChange:S,theme:f,onMount:x,loading:(0,J.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,J.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,J.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,J.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e(`activity:codeEditor.selectTab`)})})]}),u&&(0,J.jsx)(be,{file:u})]})}export{Me as CodeEditor};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ln as t,Nr as n,Oa as r,Pt as i,Qi as a,Rn as o,Tr as s,Vr as c,Wr as l,Xi as u,Zt as d,_ as f,a as p,ai as m,an as h,c as ee,ca as g,di as _,dt as v,f as y,g as b,gr as x,h as te,i as S,ir as ne,ja as re,kn as C,lt as w,m as ie,n as ae,p as oe,r as se,s as T,u as ce,wn as le,xa as ue,yn as E,za as de,zn as D}from"./vendor-BuarzSSb.js";import{t as O}from"./utils-B-9lSDIn.js";import{i as fe,r as pe,t as me}from"./codemap-activity-store-DQfjo7-j.js";import{t as he}from"./codemap-index-store-COStDU-8.js";var k=e(de(),1),A=4096,j=new Map;function M(e){let t=j.get(e);if(t!==void 0)return t;let n=e.replace(/\\/g,`/`).replace(/^\.\//,``).toLocaleLowerCase();for(;j.size>=A;){let e=j.keys().next().value;if(e===void 0)break;j.delete(e)}return j.set(e,n),n}function N(e){return e.level===`packages`?`packages`:e.level===`files`?`files:${e.package}`:`symbols:${e.file}`}function ge(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 _e(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 ve(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 P(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 ye(e){let t=new Set(e.nodes.map(e=>e.id)),n=P(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 d=Math.max(1,...[...u.values()].map(e=>e.length))*160,f=[];for(let[e,t]of[...u.entries()].sort(([e],[t])=>e-t)){let n=(d-t.length*160)/2;t.forEach((t,r)=>{f.push({node:t,position:{x:e*386,y:n+r*160}})})}return f}function F(e,t){if(e.nodes.length===0)return[];let n=P(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=ve(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 be(e,t,n){return t===`orbit`?F(e,n):ye(e)}function xe(e,t,n){if(e.length<=n)return e;let r=t?e.filter(e=>e.source===t||e.target===t):[],i=e.filter(e=>!t||e.source!==t&&e.target!==t).sort((e,t)=>t.weight-e.weight||e.source.localeCompare(t.source)||e.target.localeCompare(t.target)),a=Math.max(0,n-r.length);return[...r,...i.slice(0,a)]}function Se(e,t,n){if(n===`all`)return e;let r=e.nodes;if(e.nodes.length>96){let n=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=>{n.has(e)&&o.size<96&&o.add(e)};if(t&&n.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,72),t=a.filter(e=>e.external).slice(0,24);for(let n of[...e,...t])s(n.id)}for(let e of a)s(e.id);r=e.nodes.filter(e=>o.has(e.id))}let i=new Set(r.map(e=>e.id)),a=e.edges.filter(e=>i.has(e.source)&&i.has(e.target));return{nodes:r,edges:xe(a,t,180)}}function I(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 Ce=new WeakMap;function we(e){let t=Ce.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=I(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),Ce.set(e,n),n}function Te(e){let t=2166136261,n=e=>{for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619)};for(let t of e.nodes)n(t.id);for(let r of e.edges)n(r.source),n(r.target),n(r.refType),t^=r.weight|0,t=Math.imul(t,16777619);return`${e.nodes.length}:${e.edges.length}:${t>>>0}`}function Ee(e,t,n,r){for(e.has(t)&&e.delete(t),e.set(t,n);e.size>r;){let t=e.keys().next().value;if(t===void 0)break;e.delete(t)}}function De(e,t){if(!e||!t)return!1;let n=M(e),r=M(t);return n===r||n.endsWith(`/${r}`)||r.endsWith(`/${n}`)}function Oe(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 ke(e,t){return t.kind===`package`?Oe(e.filePath)===(t.package??t.label):De(e.filePath,t.file)?t.kind!==`symbol`||e.symbol?.id===t.id:!1}function Ae(e){let t=new Map;for(let n of e){let e=M(n.filePath),r=t.get(e);r?r.push(n):t.set(e,[n])}return t}function je(e,t){let n=new Map;if(t.length===0||e.length===0)return n;let r=Ae(t),i=new Map;for(let a of e){let e;if(a.kind===`package`){let n=a.package??a.label,r=i.get(n);r||(r=t.filter(e=>Oe(e.filePath)===n),i.set(n,r)),e=r}else if(a.file){let t=M(a.file),n=r.get(t);if(!n){n=[];for(let[e,i]of r)(e.endsWith(`/${t}`)||t.endsWith(`/${e}`))&&n.push(...i)}e=a.kind===`symbol`?n.filter(e=>e.symbol?.id===a.id):n}else e=[];e.length>0&&n.set(a.id,e)}return n}function Me(e){if(e.length===0)return``;let t=`${e.length}`;for(let n=0;n<e.length;n++){let r=e[n];t+=`|${r.id??``}:${r.toolUseId??``}:${r.filePath}:${r.type}:${r.status??``}:${r.symbol?.id??``}:${r.timestamp}`}return t}function Ne(e,t){let n=t.filter(t=>t.kind===`symbol`&&!t.external&&De(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 L=w();function Pe({historyFile:e,fileHistory:t,onClose:n}){return(0,L.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,L.jsxs)(`div`,{className:`flex h-12 items-center justify-between border-b px-4`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,L.jsx)(r,{className:`h-4 w-4 shrink-0 text-warning`}),(0,L.jsx)(`span`,{className:`truncate font-mono text-[11px] font-semibold`,title:e,children:e})]}),(0,L.jsx)(`button`,{type:`button`,onClick:n,className:`flex h-7 w-7 items-center justify-center border text-muted-foreground hover:bg-muted`,"aria-label":`Close activity`,children:(0,L.jsx)(v,{className:`h-3.5 w-3.5`})})]}),(0,L.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-3`,children:t.length===0?(0,L.jsx)(`p`,{className:`py-12 text-center text-[10px] text-muted-foreground`,children:`No activity recorded for this file yet.`}):t.map((e,t)=>(0,L.jsxs)(`div`,{className:`mb-1 flex items-start gap-2 border p-2 text-[10px]`,children:[(0,L.jsx)(`span`,{className:O(`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,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`div`,{className:`font-mono text-[9px] text-muted-foreground`,children:new Date(e.timestamp).toLocaleTimeString()}),e.toolName&&(0,L.jsxs)(`div`,{className:`mt-1`,children:[`via `,e.toolName]}),e.agent&&(0,L.jsx)(`div`,{className:`text-muted-foreground`,children:e.agent}),e.summary&&(0,L.jsx)(`div`,{className:`mt-1 text-muted-foreground`,children:e.summary}),e.change&&(0,L.jsxs)(`div`,{className:`mt-1 flex items-center gap-1 font-mono text-[8px]`,children:[(0,L.jsxs)(`span`,{className:`border border-success/40 bg-success/10 px-1 text-success`,children:[`+`,e.change.added]}),(0,L.jsxs)(`span`,{className:`border border-destructive/40 bg-destructive/10 px-1 text-destructive`,children:[`−`,e.change.removed]}),e.change.before&&(0,L.jsx)(`span`,{className:`ml-1 truncate text-destructive/80`,title:e.change.before,children:e.change.before}),e.change.after&&(0,L.jsxs)(`span`,{className:`truncate text-success/80`,title:e.change.after,children:[`→ `,e.change.after]})]}),(0,L.jsxs)(`div`,{className:`mt-1 flex gap-2 font-mono text-[8px] uppercase text-muted-foreground`,children:[(0,L.jsx)(`span`,{children:e.status??`observed`}),(0,L.jsx)(`span`,{children:e.source??`legacy`}),e.durationMs!==void 0&&(0,L.jsxs)(`span`,{children:[e.durationMs,`ms`]}),e.watcherConfirmed&&(0,L.jsx)(`span`,{className:`text-success`,children:`fs verified`})]})]})]},`${e.timestamp}-${t}`))}),(0,L.jsxs)(`div`,{className:`border-t px-4 py-2 font-mono text-[9px] text-muted-foreground`,children:[t.length,` events · newest first`]})]})}var R={package:{icon:t,accent:`border-l-primary`,iconStyle:`bg-primary/12 text-primary`},file:{icon:m,accent:`border-l-info`,iconStyle:`bg-info/12 text-info`},symbol:{icon:g,accent:`border-l-success`,iconStyle:`bg-success/12 text-success`}},Fe={call:`hsl(var(--primary))`,import:`hsl(var(--info))`,type_ref:`hsl(var(--success))`,inherit:`hsl(var(--warning))`,implement:`hsl(var(--destructive))`},Ie={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`},Le=[`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 Re(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 z(e){let t=0;for(let n of e)t=t*31+n.charCodeAt(0)|0;return Le[Math.abs(t)%Le.length]??Le[0]}function ze(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 B(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 V(e){return[e.symbol?.name,e.line?`L${e.line}`:void 0].filter(Boolean).join(` · `)}function Be({data:e}){let{graphNode:t,selected:n,dimmed:r,incoming:i,outgoing:a,isActive:o,activityType:s,activeOperations:c}=e,l=R[t.kind],u=l.icon,d=t.kind!==`symbol`,p=t.kind===`symbol`?`${t.symbolKind??`symbol`}${t.line?` · L${t.line}`:``}`:t.kind===`file`?I(t):`${t.fileCount??0} files · ${t.symbolCount??0} symbols`;return(0,L.jsxs)(`div`,{className:O(`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,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&&Ie[s]),children:[c.length>0&&(0,L.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,L.jsxs)(`span`,{className:O(`flex h-6 items-center gap-1 border-2 border-background px-1.5 font-mono text-[8px] font-bold shadow-md`,z(n)),title:`${t} · ${e.type} ${V(e)}`,children:[(0,L.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse bg-current`}),Re(t),e.symbol&&(0,L.jsx)(`span`,{className:`max-w-[80px] truncate`,children:e.symbol.name})]},e.id??`${n}:${e.filePath}`)}),c.length>4&&(0,L.jsxs)(`span`,{className:`border bg-card px-1 font-mono text-[8px] shadow`,children:[`+`,c.length-4]})]}),(0,L.jsx)(T,{type:`target`,position:f.Left,className:`!h-2.5 !w-2.5 !border-2 !border-card !bg-muted-foreground`}),(0,L.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,L.jsxs)(`div`,{className:`flex items-start gap-3 p-3 pr-10`,children:[(0,L.jsx)(`span`,{className:O(`flex h-8 w-8 shrink-0 items-center justify-center border`,l.iconStyle),children:(0,L.jsx)(u,{className:`h-4 w-4`})}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[9px] font-bold uppercase tracking-[0.18em] text-muted-foreground`,children:[(0,L.jsx)(`span`,{children:t.kind}),t.external&&(0,L.jsx)(`span`,{className:`border border-border px-1 py-0.5 text-[8px] text-warning`,children:`external`}),t.lang&&(0,L.jsx)(`span`,{className:`ml-auto font-mono normal-case tracking-normal`,children:t.lang})]}),(0,L.jsx)(`div`,{className:`truncate font-mono text-[13px] font-semibold`,title:t.label,children:t.label}),(0,L.jsx)(`div`,{className:`mt-1 truncate text-[10px] text-muted-foreground`,title:p,children:p})]})]}),(0,L.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,L.jsxs)(`span`,{title:`Incoming relationships`,children:[`← `,i]}),(0,L.jsxs)(`span`,{title:`Outgoing relationships`,children:[`→ `,a]}),t.symbolCount!==void 0&&t.kind===`file`&&(0,L.jsxs)(`span`,{className:`ml-auto`,children:[t.symbolCount,` sym`]}),o&&(0,L.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 font-bold text-warning`,children:[(0,L.jsx)(E,{className:`h-2.5 w-2.5 animate-pulse`}),` LIVE`]})]})]}),d&&(0,L.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,L.jsx)(_,{className:`h-3.5 w-3.5`})}),(0,L.jsx)(T,{type:`source`,position:f.Right,className:`!h-2.5 !w-2.5 !border-2 !border-card !bg-muted-foreground`})]})}function Ve(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function H(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&&Ve(e.activeOperations,t.activeOperations)}var He={codemap:(0,k.memo)(Be,(e,t)=>H(e.data,t.data))},Ue={nodes:[],edges:[]};function We({loading:e,error:t,graph:n,canvasNodeCount:r,flowNodes:i,flowEdges:a,onNodesChange:o,onEdgesChange:s,agentTrailCount:c}){return(0,L.jsxs)(L.Fragment,{children:[e&&(0,L.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,L.jsx)(ne,{className:`h-7 w-7 animate-spin text-primary`}),(0,L.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-widest text-muted-foreground`,children:`Mapping relationships`})]}),t&&!e&&(0,L.jsxs)(`div`,{className:`absolute inset-0 z-20 flex flex-col items-center justify-center gap-3 p-8 text-center`,children:[(0,L.jsx)(D,{className:`h-10 w-10 text-destructive`}),(0,L.jsx)(`p`,{className:`font-mono text-sm text-destructive`,children:t}),(0,L.jsxs)(`p`,{className:`max-w-md text-xs text-muted-foreground`,children:[`The map needs a codebase index. Run`,` `,(0,L.jsx)(`code`,{className:`border bg-muted px-1.5 py-0.5`,children:`codebase-index`}),` once, then reopen this view.`]})]}),!e&&!t&&n.nodes.length===0&&(0,L.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-2 text-muted-foreground`,children:[(0,L.jsx)(D,{className:`h-8 w-8 opacity-40`}),(0,L.jsx)(`p`,{className:`text-xs`,children:`No indexed nodes at this level.`})]}),!e&&!t&&n.nodes.length>1&&n.edges.length===0&&(0,L.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,L.jsx)(`div`,{className:`font-mono text-[9px] font-bold uppercase tracking-wider text-warning`,children:`No resolved relations in this scope`}),(0,L.jsx)(`div`,{className:`mt-0.5 text-[8px] text-muted-foreground`,children:`The upgraded index will rebuild and resolve call/import/type links automatically.`})]}),!t&&n.nodes.length>0&&(0,L.jsxs)(y,{nodes:i,edges:a,onNodesChange:o,onEdgesChange:s,nodeTypes:He,nodesConnectable:!1,nodesDraggable:!1,edgesFocusable:!1,elementsSelectable:!1,onlyRenderVisibleElements:!0,minZoom:.08,maxZoom:2.2,proOptions:{hideAttribution:!0},children:[(0,L.jsx)(se,{variant:S.Dots,gap:r>60?32:22,size:1,color:`hsl(var(--muted-foreground))`,className:`!opacity-25`}),(0,L.jsx)(p,{position:`bottom-left`,showInteractive:!1,className:`!border !border-border !bg-card !shadow-md [&>button]:!border-border [&>button]:!bg-card [&>button]:!fill-foreground`}),r<=48&&(0,L.jsx)(ee,{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,L.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(Fe).map(([e,t])=>(0,L.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,L.jsx)(`span`,{className:`h-0.5 w-3`,style:{backgroundColor:t}}),e.replace(`_`,` `)]},e)),(0,L.jsxs)(`span`,{className:`flex items-center gap-1 text-primary`,"data-testid":`agent-trail-count`,children:[(0,L.jsx)(`span`,{className:`w-4 border-t-2 border-dashed border-primary`}),`agent trail`,c>0?` ×${c}`:``]})]})]})}function Ge({layout:e,canvasMode:t,edgeFilter:n,canvasNodeCount:r,graphNodeCount:i,onLayoutChange:a,onCanvasModeChange:s,onEdgeFilterChange:c}){return(0,L.jsxs)(`div`,{className:`pointer-events-none absolute left-3 right-3 top-3 z-10 flex items-center gap-2`,children:[(0,L.jsxs)(`div`,{className:`pointer-events-auto flex border bg-card/95 shadow-md backdrop-blur`,children:[(0,L.jsxs)(`button`,{type:`button`,className:O(`flex h-8 items-center gap-1.5 border-r px-2.5 text-[9px] font-semibold uppercase tracking-wider`,e===`layers`?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-muted`),onClick:()=>a(`layers`),children:[(0,L.jsx)(x,{className:`h-3 w-3`}),` Layers`]}),(0,L.jsxs)(`button`,{type:`button`,className:O(`flex h-8 items-center gap-1.5 px-2.5 text-[9px] font-semibold uppercase tracking-wider`,e===`orbit`?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-muted`),onClick:()=>a(`orbit`),children:[(0,L.jsx)(o,{className:`h-3 w-3`}),` Relations`]})]}),(0,L.jsxs)(`div`,{className:`pointer-events-auto flex border bg-card/95 shadow-md backdrop-blur`,children:[(0,L.jsxs)(`button`,{type:`button`,className:O(`h-8 border-r px-2.5 font-mono text-[9px] font-bold`,t===`smart`?`bg-success text-success-foreground`:`text-muted-foreground hover:bg-muted`),onClick:()=>s(`smart`),title:`Keep the full tree, show the strongest relations and selected neighbourhood`,children:[`SMART `,r,`/`,i]}),(0,L.jsx)(`button`,{type:`button`,className:O(`h-8 px-2.5 font-mono text-[9px] font-bold`,t===`all`?`bg-foreground text-background`:`text-muted-foreground hover:bg-muted`),onClick:()=>s(`all`),title:`Render every node and relation in this scope`,children:`ALL`})]}),(0,L.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,L.jsx)(`button`,{type:`button`,className:O(`h-8 whitespace-nowrap border-r px-2.5 font-mono text-[9px] last:border-r-0`,n===e?`bg-foreground text-background`:`text-muted-foreground hover:bg-muted`),onClick:()=>c(e),children:e===`all`?`ALL LINKS`:e.replace(`_`,` `).toUpperCase()},e))})]})}function Ke({scope:e,graph:t,agentPresences:n,edgeWeight:r,connectedNodeCount:i,navigate:a}){return(0,L.jsxs)(`header`,{className:`flex h-[62px] shrink-0 items-center gap-4 border-b bg-card px-4`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-[220px] items-center gap-3`,children:[(0,L.jsx)(`span`,{className:`flex h-9 w-9 items-center justify-center border border-primary bg-primary/10 text-primary`,children:(0,L.jsx)(D,{className:`h-4 w-4`})}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`font-display text-sm font-semibold tracking-tight`,children:`Code Atlas`}),(0,L.jsx)(`p`,{className:`text-[9px] uppercase tracking-[0.18em] text-muted-foreground`,children:`Architecture intelligence`})]})]}),(0,L.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,L.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`?a({level:`files`,package:e.package??`(root)`}):a({level:`packages`})},"aria-label":`Back`,children:(0,L.jsx)(ue,{className:`h-3.5 w-3.5`})}),(0,L.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1.5 px-1.5 py-1 text-muted-foreground hover:text-foreground`,onClick:()=>a({level:`packages`}),children:[(0,L.jsx)(s,{className:`h-3 w-3`}),` workspace`]}),e.level!==`packages`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(u,{className:`h-3 w-3 text-muted-foreground`}),(0,L.jsx)(`button`,{type:`button`,className:`max-w-[220px] truncate px-1.5 py-1 hover:text-primary`,onClick:()=>a({level:`files`,package:e.package??`(root)`}),children:e.package??`(root)`})]}),e.level===`symbols`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(u,{className:`h-3 w-3 text-muted-foreground`}),(0,L.jsx)(`span`,{className:`truncate px-1.5 py-1 text-primary`,children:I({id:``,label:e.file,kind:`file`,file:e.file,package:e.package})})]})]}),(0,L.jsxs)(`div`,{className:`hidden items-center gap-5 xl:flex`,children:[(0,L.jsxs)(`div`,{className:O(`flex h-8 items-center gap-2 border px-2.5`,n.length>0?`border-success/50 bg-success/10 text-success`:`text-muted-foreground`),children:[(0,L.jsx)(E,{className:O(`h-3 w-3`,n.length>0&&`animate-pulse`)}),(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`font-mono text-[10px] font-bold`,children:[n.length,` LIVE`]}),(0,L.jsx)(`div`,{className:`text-[7px] uppercase tracking-wider`,children:`agents`})]})]}),(0,L.jsxs)(`div`,{className:`text-right`,children:[(0,L.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:t.nodes.length}),(0,L.jsx)(`div`,{className:`text-[8px] uppercase tracking-wider text-muted-foreground`,children:`nodes`})]}),(0,L.jsxs)(`div`,{className:`text-right`,children:[(0,L.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:t.edges.length}),(0,L.jsx)(`div`,{className:`text-[8px] uppercase tracking-wider text-muted-foreground`,children:`links`})]}),(0,L.jsxs)(`div`,{className:`text-right`,children:[(0,L.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:r}),(0,L.jsx)(`div`,{className:`text-[8px] uppercase tracking-wider text-muted-foreground`,children:`references`})]}),(0,L.jsxs)(`div`,{className:`text-right`,children:[(0,L.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:i}),(0,L.jsx)(`div`,{className:`text-[8px] uppercase tracking-wider text-muted-foreground`,children:`connected`})]})]})]})}function U({activity:e}){return(0,L.jsx)(`span`,{className:O(`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 W({activity:e,onLocate:t,showAgent:n=!1}){let r=e.agentName??e.agent??`External process`,a=`${e.sessionId??`none`}:${e.agentId??r}`;return(0,L.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:[n&&(0,L.jsx)(`span`,{className:O(`mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center font-mono text-[8px] font-black`,z(a)),children:Re(r)}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,L.jsx)(U,{activity:e}),n&&(0,L.jsx)(`span`,{className:`truncate text-[9px] font-semibold`,children:r}),e.status===`active`&&(0,L.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 font-mono text-[8px] font-bold text-success`,children:[(0,L.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse bg-success`}),` LIVE`]}),e.watcherConfirmed&&(0,L.jsx)(d,{className:`ml-auto h-3 w-3 text-success`,"aria-label":`Filesystem confirmed`}),e.attribution===`correlated`&&!e.watcherConfirmed&&(0,L.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,L.jsx)(`span`,{className:`ml-auto font-mono text-[7px] uppercase text-destructive`,children:`external`})]}),(0,L.jsx)(`div`,{className:`mt-1 truncate font-mono text-[9px] font-semibold`,title:e.filePath,children:B(e.filePath)}),(e.symbol||e.line)&&(0,L.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-1 truncate font-mono text-[8px] text-success`,children:[(0,L.jsx)(i,{className:`h-2.5 w-2.5 shrink-0`}),e.symbol?.name??`line ${e.line}`,e.symbol?.kind&&(0,L.jsxs)(`span`,{className:`text-muted-foreground`,children:[`· `,e.symbol.kind]})]}),e.change&&(0,L.jsxs)(`div`,{className:`mt-1 flex items-center gap-1 font-mono text-[8px]`,children:[(0,L.jsxs)(`span`,{className:`border border-success/40 bg-success/10 px-1 text-success`,children:[`+`,e.change.added]}),(0,L.jsxs)(`span`,{className:`border border-destructive/40 bg-destructive/10 px-1 text-destructive`,children:[`−`,e.change.removed]}),e.durationMs!==void 0&&(0,L.jsxs)(`span`,{className:`ml-auto text-muted-foreground`,children:[e.durationMs,`ms`]})]}),e.summary&&e.summary!==e.toolName&&(0,L.jsx)(`div`,{className:`mt-1 line-clamp-2 text-[8px] leading-3 text-muted-foreground`,children:e.summary})]}),!e.filePath.startsWith(`(`)&&(0,L.jsx)(_,{className:`mt-1 h-3 w-3 shrink-0 text-muted-foreground opacity-0 group-hover:opacity-100`})]})}function qe({presences:e,onLocate:t}){return e.length===0?null:(0,L.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,L.jsxs)(`div`,{className:`flex h-9 items-center gap-2 border-b px-3`,children:[(0,L.jsx)(E,{className:`h-3.5 w-3.5 animate-pulse text-success`}),(0,L.jsx)(`h2`,{className:`text-[9px] font-black uppercase tracking-[0.18em]`,children:`Live agent operations`}),(0,L.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,L.jsx)(`div`,{className:`max-h-[330px] overflow-y-auto`,children:e.map(e=>(0,L.jsxs)(`div`,{className:`border-b last:border-b-0`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 bg-muted/35 px-3 py-1.5`,children:[(0,L.jsx)(`span`,{className:O(`flex h-6 w-6 items-center justify-center font-mono text-[8px] font-black`,z(e.key)),children:Re(e.agentName)}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`div`,{className:`truncate text-[9px] font-bold`,children:e.agentName}),(0,L.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,L.jsxs)(`span`,{className:`font-mono text-[8px] text-success`,children:[e.operations.length,` op`]})]}),e.operations.map(e=>(0,L.jsx)(W,{activity:e,onLocate:t},e.id??`${e.toolUseId}:${e.filePath}`))]},e.key))})]})}function Je({paused:e,followLive:t,agentFilter:n,agents:r,onTogglePaused:a,onToggleFollow:o,onAgentFilter:s}){return(0,L.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,L.jsxs)(`button`,{type:`button`,className:O(`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,L.jsx)(i,{className:`h-3 w-3`}),` Follow`]}),(0,L.jsxs)(`button`,{type:`button`,className:O(`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:a,title:e?`Resume the live telemetry stream`:`Freeze the current telemetry frame`,children:[e?(0,L.jsx)(le,{className:`h-3 w-3`}):(0,L.jsx)(C,{className:`h-3 w-3`}),e?`Resume`:`Live`]}),(0,L.jsxs)(`label`,{className:`flex h-full items-center gap-1.5 px-2 text-[8px] uppercase text-muted-foreground`,children:[`Agent`,(0,L.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,L.jsx)(`option`,{value:`all`,children:`ALL AGENTS`}),r.map(e=>(0,L.jsxs)(`option`,{value:e.key,children:[e.agentName,` · `,e.sessionId.slice(0,10)]},e.key))]})]})]})}function Ye({activeOperations:e,recentActivities:t,activityTotalCount:i,onLocate:a}){return(0,L.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[e.length>0&&(0,L.jsxs)(`section`,{className:`border-b`,children:[(0,L.jsxs)(`div`,{className:`flex h-9 items-center gap-2 border-b bg-success/5 px-3`,children:[(0,L.jsx)(E,{className:`h-3 w-3 animate-pulse text-success`}),(0,L.jsx)(`h3`,{className:`text-[9px] font-bold uppercase tracking-[0.16em]`,children:`Active now`}),(0,L.jsx)(`span`,{className:`ml-auto font-mono text-[9px] text-success`,children:e.length})]}),e.map(e=>(0,L.jsx)(W,{activity:e,onLocate:a,showAgent:!0},e.id??`${e.toolUseId}:${e.filePath}`))]}),(0,L.jsxs)(`section`,{children:[(0,L.jsxs)(`div`,{className:`flex h-9 items-center gap-2 border-b px-3`,children:[(0,L.jsx)(r,{className:`h-3 w-3 text-muted-foreground`}),(0,L.jsx)(`h3`,{className:`text-[9px] font-bold uppercase tracking-[0.16em]`,children:`Event stream`}),(0,L.jsxs)(`span`,{className:`ml-auto font-mono text-[8px] text-muted-foreground`,children:[i,` total`]})]}),t.length>0?t.map((e,t)=>(0,L.jsx)(W,{activity:e,onLocate:a,showAgent:!0},e.id??`${e.timestamp}:${t}`)):(0,L.jsxs)(`div`,{className:`flex flex-col items-center justify-center px-7 py-16 text-center`,children:[(0,L.jsx)(`span`,{className:`mb-4 flex h-12 w-12 items-center justify-center border bg-muted text-muted-foreground`,children:(0,L.jsx)(n,{className:`h-5 w-5`})}),(0,L.jsx)(`h3`,{className:`text-xs font-semibold`,children:`Select a node or wait for an agent`}),(0,L.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.`})]})]})]})}function Xe({node:e,incomingCount:t,outgoingCount:n,onOpenNode:i,onOpenActivity:a}){let o=R[e.kind].icon;return(0,L.jsxs)(`div`,{className:`border-b bg-muted/25 p-3`,children:[(0,L.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:O(`flex h-8 w-8 items-center justify-center border`,R[e.kind].iconStyle),children:(0,L.jsx)(o,{className:`h-4 w-4`})}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsxs)(`div`,{className:`text-[8px] font-bold uppercase tracking-[0.18em] text-muted-foreground`,children:[e.external?`external `:``,e.kind]}),(0,L.jsx)(`div`,{className:`truncate font-mono text-xs font-semibold`,title:e.label,children:e.label})]})]}),(0,L.jsx)(`div`,{className:`break-all font-mono text-[9px] leading-relaxed text-muted-foreground`,children:e.file?I(e):e.package}),e.signature&&(0,L.jsx)(`pre`,{className:`mt-3 overflow-x-auto border bg-background p-2 font-mono text-[9px] leading-relaxed text-foreground`,children:e.signature}),(0,L.jsxs)(`div`,{className:`mt-3 grid grid-cols-3 border`,children:[(0,L.jsx)(Ze,{value:t,label:`incoming`,className:`border-r text-info`}),(0,L.jsx)(Ze,{value:n,label:`outgoing`,className:`border-r text-primary`}),(0,L.jsx)(Ze,{value:e.symbolCount??e.fileCount??e.line??`—`,label:e.kind===`package`?`files`:e.kind===`file`?`symbols`:`line`})]}),(0,L.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[e.kind!==`symbol`&&(0,L.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:()=>i(e),children:[(0,L.jsx)(_,{className:`h-3 w-3`}),` Open `,e.kind===`package`?`files`:`symbols`]}),e.file&&(0,L.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:()=>a(e.file),children:[(0,L.jsx)(r,{className:`h-3 w-3`}),` Activity`]})]})]})}function Ze({value:e,label:t,className:n}){return(0,L.jsxs)(`div`,{className:O(`p-2 text-center`,n),children:[(0,L.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:e}),(0,L.jsx)(`div`,{className:`text-[8px] uppercase text-muted-foreground`,children:t})]})}function Qe(e){let{title:t,subtitle:r,items:i,graph:o,selectedId:s,expanded:c,onToggle:l,onSelect:d}=e;return(0,L.jsxs)(`section`,{className:`border-b py-3`,children:[(0,L.jsxs)(`div`,{className:`mb-2 flex items-end justify-between px-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`text-[10px] font-bold uppercase tracking-[0.16em]`,children:t}),(0,L.jsx)(`p`,{className:`mt-0.5 text-[9px] text-muted-foreground`,children:r})]}),(0,L.jsx)(`span`,{className:`border bg-muted px-1.5 py-0.5 font-mono text-[9px]`,children:i.length})]}),i.length===0?(0,L.jsx)(`p`,{className:`px-3 py-2 text-[10px] text-muted-foreground`,children:`No relationships in this view.`}):i.map(e=>{let r=`${t}:${e.node.id}`,i=c.has(r),f=[..._e(o,e.node.id,`incoming`),..._e(o,e.node.id,`outgoing`)].filter((e,t,n)=>e.node.id!==s&&n.findIndex(t=>t.node.id===e.node.id)===t).slice(0,8);return(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`group flex min-h-9 items-center gap-1 px-2 hover:bg-muted/70`,children:[(0,L.jsx)(`button`,{type:`button`,className:`flex h-6 w-5 shrink-0 items-center justify-center text-muted-foreground`,onClick:()=>f.length>0&&l(r),"aria-label":`${i?`Collapse`:`Expand`} relation ${e.node.label}`,children:f.length>0?i?(0,L.jsx)(a,{className:`h-3 w-3`}):(0,L.jsx)(u,{className:`h-3 w-3`}):(0,L.jsx)(`span`,{className:`h-px w-2 bg-border`})}),(0,L.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 py-1 text-left`,onClick:()=>d(e.node),children:[(0,L.jsx)(`span`,{className:`block truncate font-mono text-[10px] font-semibold`,title:e.node.label,children:e.node.label}),(0,L.jsx)(`span`,{className:`block truncate text-[9px] text-muted-foreground`,children:e.node.package??e.node.symbolKind??e.node.kind})]}),(0,L.jsx)(`span`,{className:`border px-1 py-0.5 font-mono text-[8px] text-muted-foreground`,children:e.edge.refType}),(0,L.jsxs)(`span`,{className:`w-5 text-right font-mono text-[9px] text-muted-foreground`,children:[`×`,e.edge.weight]})]}),i&&f.map(e=>(0,L.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:()=>d(e.node),children:[(0,L.jsx)(`span`,{className:`absolute left-7 top-1/2 h-px w-3 bg-border`}),(0,L.jsx)(n,{className:`h-3 w-3 shrink-0`}),(0,L.jsx)(`span`,{className:`truncate font-mono`,children:e.node.label}),(0,L.jsx)(`span`,{className:`ml-auto font-mono opacity-70`,children:e.edge.refType})]},`${r}:${e.node.id}`))]},r)})]})}function $e({selectedNode:e,incoming:t,outgoing:n,filteredGraph:r,expandedRelations:i,activeOperations:a,recentActivities:o,activityTotalCount:s,selectedActivities:c,onClearSelection:l,onOpenNode:u,onOpenActivity:d,onLocateActivity:f,onToggleRelation:p,onSelectNode:m}){return(0,L.jsxs)(`aside`,{className:`flex w-[326px] shrink-0 flex-col border-l bg-card/80`,children:[(0,L.jsxs)(`div`,{className:`flex h-10 items-center justify-between border-b px-3`,children:[(0,L.jsx)(`h2`,{className:`text-[10px] font-bold uppercase tracking-[0.18em]`,children:`Relation inspector`}),e&&(0,L.jsx)(`button`,{type:`button`,className:`text-muted-foreground hover:text-foreground`,onClick:l,"aria-label":`Clear selection`,children:(0,L.jsx)(v,{className:`h-3.5 w-3.5`})})]}),e?(0,L.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[(0,L.jsx)(Xe,{node:e,incomingCount:t.length,outgoingCount:n.length,onOpenNode:u,onOpenActivity:d}),c.length>0&&(0,L.jsxs)(`section`,{className:`border-b bg-success/5 py-2`,children:[(0,L.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 px-3`,children:[(0,L.jsx)(E,{className:`h-3 w-3 animate-pulse text-success`}),(0,L.jsx)(`h3`,{className:`text-[9px] font-bold uppercase tracking-[0.16em]`,children:`Agents on this node`}),(0,L.jsx)(`span`,{className:`ml-auto font-mono text-[9px] text-success`,children:c.length})]}),c.map(e=>(0,L.jsx)(W,{activity:e,onLocate:f,showAgent:!0},e.id??`${e.toolUseId}:${e.filePath}`))]}),(0,L.jsx)(Qe,{title:`Incoming`,subtitle:`Who depends on this`,items:t,graph:r,selectedId:e.id,expanded:i,onToggle:p,onSelect:m}),(0,L.jsx)(Qe,{title:`Outgoing`,subtitle:`What this depends on`,items:n,graph:r,selectedId:e.id,expanded:i,onToggle:p,onSelect:m})]}):(0,L.jsx)(Ye,{activeOperations:a,recentActivities:o,activityTotalCount:s,onLocate:f})]})}function et({node:e,onSelect:t,virtual:n}){let r=R[e.kind].icon;return(0,L.jsxs)(`button`,{type:`button`,"data-index":n?.index,ref:n?e=>n.measureElement(e):void 0,className:O(`min-h-8 items-center gap-2 px-3 py-1 text-left hover:bg-muted`,n?`absolute left-0 flex w-full`:`flex w-full`),style:n?{transform:`translateY(${n.start}px)`}:void 0,onClick:()=>t(e),children:[(0,L.jsx)(r,{className:O(`h-3.5 w-3.5 shrink-0`,e.kind===`package`?`text-primary`:e.kind===`file`?`text-info`:`text-success`)}),(0,L.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`span`,{className:`block truncate font-mono text-[10px]`,children:e.label}),(0,L.jsx)(`span`,{className:`block truncate text-[8px] text-muted-foreground`,children:e.file??e.package??e.symbolKind})]}),(0,L.jsx)(`span`,{className:`text-[8px] uppercase text-muted-foreground`,children:e.kind.slice(0,3)})]},e.id)}var G=80,tt=40;function K(e,t){if(!e||t.size===0)return!1;let n=M(e);if(t.has(n))return!0;for(let e of t)if(e.endsWith(`/${n}`)||n.endsWith(`/${e}`))return!0;return!1}var nt=(0,k.memo)(function e(t){let{directory:n,packageName:r,depth:i,expandedDirectories:o,expandedFiles:s,loadingBranches:d,graphForFile:f,onToggleDirectory:p,onToggleFile:h,onSelectFile:ee,onOpenFile:v,onSelectSymbol:y,selectedId:b,activeFileNorms:x,activeSymbolIds:te,revealAllKeys:S,onRevealAll:re}=t,C=`files:${r}:${n.path||`.`}`,w=S.has(C)?n.files:n.files.slice(0,G),ie=n.files.length-w.length;return(0,L.jsxs)(L.Fragment,{children:[n.directories.map(n=>{let s=`${r}:${n.path}`,d=o.has(s);return(0,L.jsxs)(`div`,{children:[(0,L.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+i*12},onClick:()=>p(s),children:[d?(0,L.jsx)(a,{className:`h-3 w-3`}):(0,L.jsx)(u,{className:`h-3 w-3`}),d?(0,L.jsx)(l,{className:`h-3.5 w-3.5 text-warning`}):(0,L.jsx)(c,{className:`h-3.5 w-3.5 text-warning`}),(0,L.jsx)(`span`,{className:`truncate`,children:n.name})]}),d&&(0,L.jsx)(e,{...t,directory:n,depth:i+1})]},s)}),w.map(e=>{let t=s.has(e.file??e.id),n=N({level:`symbols`,file:e.file??e.label}),r=(e.file?f(e.file):void 0)?.nodes.filter(t=>t.kind===`symbol`&&t.file===e.file&&!t.external)??[],o=`symbols:${e.file??e.id}`,c=S.has(o)?r:r.slice(0,tt),l=r.length-c.length,p=K(e.file,x);return(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:O(`group flex h-7 items-center pr-1 text-[11px] hover:bg-muted`,b===e.id&&`bg-primary/10 text-primary`),style:{paddingLeft:8+i*12},children:[(0,L.jsx)(`button`,{type:`button`,className:`flex h-6 w-4 shrink-0 items-center justify-center text-muted-foreground`,onClick:()=>h(e),"aria-label":`${t?`Collapse`:`Expand`} ${e.label}`,children:d.has(n)?(0,L.jsx)(ne,{className:`h-3 w-3 animate-spin`}):t?(0,L.jsx)(a,{className:`h-3 w-3`}):(0,L.jsx)(u,{className:`h-3 w-3`})}),(0,L.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left`,onClick:()=>ee(e),onDoubleClick:()=>v(e),children:[(0,L.jsx)(m,{className:`h-3.5 w-3.5 shrink-0 text-info`}),p&&(0,L.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 animate-pulse bg-success`,title:`Live operation`}),(0,L.jsx)(`span`,{className:`truncate font-mono`,title:e.file,children:e.label}),(0,L.jsx)(`span`,{className:`ml-auto text-[9px] text-muted-foreground`,children:e.symbolCount??0})]}),(0,L.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:()=>v(e),title:`Open symbol map`,"aria-label":`Open ${e.label} map`,children:(0,L.jsx)(_,{className:`h-3 w-3`})})]}),t&&c.map(e=>(0,L.jsxs)(`button`,{type:`button`,className:O(`flex h-7 w-full items-center gap-1.5 pr-2 text-left text-[10px] hover:bg-muted`,b===e.id?`bg-primary/10 text-primary`:`text-muted-foreground`),style:{paddingLeft:38+i*12},onClick:()=>y(e),children:[(0,L.jsx)(g,{className:`h-3 w-3 shrink-0 text-success`}),te.has(e.id)&&(0,L.jsx)(E,{className:`h-3 w-3 shrink-0 animate-pulse text-success`}),(0,L.jsx)(`span`,{className:`truncate font-mono`,children:e.label}),e.line&&(0,L.jsxs)(`span`,{className:`ml-auto font-mono text-[8px] opacity-60`,children:[`:`,e.line]})]},e.id)),t&&l>0&&(0,L.jsxs)(`button`,{type:`button`,className:`flex h-7 w-full items-center text-left font-mono text-[9px] text-primary hover:bg-muted`,style:{paddingLeft:38+i*12},onClick:()=>re(o),children:[`Show `,l,` more symbols`]})]},e.id)}),ie>0&&(0,L.jsxs)(`button`,{type:`button`,className:`flex h-7 w-full items-center text-left font-mono text-[9px] text-primary hover:bg-muted`,style:{paddingLeft:8+i*12},onClick:()=>re(C),children:[`Show `,ie,` more files`]})]})});function rt({rootGraph:e,search:n,searchInput:r,searchResults:i,virtualizeSearch:o,searchVirtualizer:s,treeScrollRef:c,selectedId:l,expandedPackages:d,expandedDirectories:f,expandedFiles:p,loadingBranches:m,activeFileNorms:ee,activeSymbolIds:g,revealAllKeys:y,packageGraph:b,graphForFile:x,navigate:te,togglePackage:S,toggleDirectory:re,toggleFile:C,revealAllTree:w,selectFileFromTree:ie,selectSymbolFromTree:ae,selectSearchResult:oe,handleOpenNode:se,onSearchInputChange:T,onSearchChange:ce}){return(0,L.jsxs)(`aside`,{className:`flex w-[286px] shrink-0 flex-col border-r bg-card/70`,children:[(0,L.jsxs)(`div`,{className:`border-b p-3`,children:[(0,L.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,L.jsx)(`h2`,{className:`text-[10px] font-bold uppercase tracking-[0.18em]`,children:`Code tree`}),(0,L.jsxs)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:[e.nodes.length,` roots`]})]}),(0,L.jsxs)(`label`,{className:`flex h-8 items-center gap-2 border bg-background px-2 focus-within:border-primary`,children:[(0,L.jsx)(h,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,L.jsx)(`input`,{className:`min-w-0 flex-1 bg-transparent font-mono text-[10px] outline-none placeholder:text-muted-foreground`,value:r,onChange:e=>T(e.target.value),placeholder:`Find package, file, symbol…`}),r&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>{T(``),ce(``)},"aria-label":`Clear search`,children:(0,L.jsx)(v,{className:`h-3 w-3 text-muted-foreground`})})]})]}),(0,L.jsx)(`div`,{ref:c,className:`min-h-0 flex-1 overflow-y-auto py-2`,children:n.trim()?(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`px-3 pb-2 text-[9px] text-muted-foreground`,children:[i.length,` loaded-map results`]}),i.length===0?(0,L.jsxs)(`p`,{className:`px-3 py-8 text-center text-[10px] text-muted-foreground`,children:[`No match in loaded branches.`,(0,L.jsx)(`br`,{}),`Expand a package to search its files.`]}):o?(0,L.jsx)(`div`,{style:{height:`${s.getTotalSize()}px`,width:`100%`,position:`relative`},children:s.getVirtualItems().map(e=>{let t=i[e.index];return t?(0,L.jsx)(et,{node:t,onSelect:oe,virtual:{index:e.index,start:e.start,measureElement:s.measureElement}},t.id):null})}):i.map(e=>(0,L.jsx)(et,{node:e,onSelect:oe},e.id))]}):e.nodes.map(e=>{let n=e.package??e.label,r=d.has(n),i=N({level:`files`,package:n}),o=b(n),s=o?we(o.nodes):void 0;return(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:O(`group flex h-8 items-center px-2 hover:bg-muted`,l===e.id&&`bg-primary/10 text-primary`),children:[(0,L.jsx)(`button`,{type:`button`,className:`flex h-6 w-5 items-center justify-center text-muted-foreground`,onClick:()=>S(e),"aria-label":`${r?`Collapse`:`Expand`} ${n}`,children:m.has(i)?(0,L.jsx)(ne,{className:`h-3 w-3 animate-spin`}):r?(0,L.jsx)(a,{className:`h-3 w-3`}):(0,L.jsx)(u,{className:`h-3 w-3`})}),(0,L.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-2 text-left`,onClick:()=>te({level:`packages`},e.id),onDoubleClick:()=>te({level:`files`,package:n}),children:[(0,L.jsx)(t,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,L.jsx)(`span`,{className:`truncate font-mono text-[10px] font-semibold`,children:e.label}),(0,L.jsx)(`span`,{className:`ml-auto text-[9px] text-muted-foreground`,children:e.fileCount??0})]}),(0,L.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:()=>te({level:`files`,package:n}),title:`Open file map`,"aria-label":`Open ${n} map`,children:(0,L.jsx)(_,{className:`h-3 w-3`})})]}),r&&s&&(0,L.jsx)(nt,{directory:s,packageName:n,depth:1,expandedDirectories:f,expandedFiles:p,loadingBranches:m,graphForFile:x,onToggleDirectory:re,onToggleFile:C,onSelectFile:ie,onOpenFile:se,onSelectSymbol:ae,selectedId:l,activeFileNorms:ee,activeSymbolIds:g,revealAllKeys:y,onRevealAll:w})]},e.id)})}),(0,L.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,L.jsx)(`br`,{}),`Branches stay open while the map changes`]})]})}function it(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&&H(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 q(e){return e.data?.renderKey}function at(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&&q(a)===q(t)?(e[i]!==a&&(r=!0),a):(r=!0,t)});return r?i:e}function ot(){let[e,t]=(0,k.useState)({level:`packages`}),n=N(e),[r,i]=(0,k.useState)(Ue),[a,o]=(0,k.useState)(!0),[s,c]=(0,k.useState)(null),[l,u]=(0,k.useState)(null),[d,f]=(0,k.useState)(`layers`),[p,m]=(0,k.useState)(`smart`),[h,ee]=(0,k.useState)(`all`),[g,_]=(0,k.useState)(``),[v,y]=(0,k.useState)(``),[x,S]=(0,k.useState)(new Set),[ne,C]=(0,k.useState)(new Set),[w,se]=(0,k.useState)(new Set),[T,ce]=(0,k.useState)(new Set),[le,ue]=(0,k.useState)(new Set),[E,de]=(0,k.useState)(new Set),[D,O]=(0,k.useState)(0),[A,j]=(0,k.useState)(null),[P,ye]=(0,k.useState)(!1),[F,xe]=(0,k.useState)(`all`),[I,Ce]=(0,k.useState)(null),[Ae,R]=(0,k.useState)(null),[Ie,Le]=(0,k.useState)(0),z=(0,k.useRef)(new Map),B=(0,k.useRef)(null),V=(0,k.useRef)(null),Be=(0,k.useRef)(``),Ve=(0,k.useRef)(``),H=(0,k.useRef)(null),He=(0,k.useRef)(new Set),{history:U,pulses:W,activeOperationsMap:Ye,activityTotalCount:Xe,resolveActivitySymbol:Ze,getActivityForFile:Qe,sweepActivity:et}=fe(re(e=>({history:e.history,pulses:e.pulses,activeOperationsMap:e.activeOperations,activityTotalCount:e.totalCount,resolveActivitySymbol:e.resolveActivitySymbol,getActivityForFile:e.getActivityForFile,sweepActivity:e._sweep}))),G=(0,k.useMemo)(()=>[...Ye.values()].flat(),[Ye]),tt=(0,k.useMemo)(()=>[...W.keys()].map(e=>U.get(e)?.[0]).filter(e=>!!e),[U,W]),K=(0,k.useMemo)(()=>{let e=[];for(let t of U.values())e.push(...t.slice(0,16));return e.sort((e,t)=>t.timestamp-e.timestamp).slice(0,16)},[U]),nt=(0,k.useMemo)(()=>pe([...G,...K]),[G,K]),q=(0,k.useMemo)(()=>{let e=I??G;return F===`all`?e:e.filter(e=>me(e)===F)},[G,F,I]),ot=(0,k.useMemo)(()=>{let e=Ae??K;return F===`all`?e:e.filter(e=>me(e)===F)},[F,Ae,K]),J=(0,k.useDeferredValue)(q),st=(0,k.useDeferredValue)(ot),ct=(0,k.useDeferredValue)(tt),lt=(0,k.useMemo)(()=>pe(q),[q]),[ut,dt,ft]=ie([]),[pt,mt,ht]=oe([]),{fitView:gt}=te(),Y=(0,k.useCallback)(async(e,t=!1)=>{let n=N(e),r=z.current.get(n);if(r&&!t)return Ee(z.current,n,r,48),r;let i=await fetch(ge(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 Ee(z.current,n,a,48),O(e=>e+1),a},[]);(0,k.useEffect)(()=>{let e=window.setTimeout(()=>y(g),150);return()=>window.clearTimeout(e)},[g]);let _t=he(e=>e.generation),vt=(0,k.useRef)(0),yt=(0,k.useRef)(null);(0,k.useEffect)(()=>{let t=!1,n=_t>vt.current;return n&&(vt.current=_t,z.current.clear(),O(e=>e+1),S(new Set),C(new Set),se(new Set),ue(new Set)),o(!0),c(null),Y(e,n).then(e=>{if(!t){if(i(e),!n){let t=B.current;B.current=null,u(t&&e.nodes.some(e=>e.id===t)?t:null)}o(!1)}}).catch(e=>{t||(c(e instanceof Error?e.message:String(e)),i(Ue),o(!1))}),()=>{t=!0}},[n,Y,_t,e]);let X=(0,k.useCallback)((e,r)=>{if(B.current=r??null,N(e)===n){u(r??null),B.current=null;return}t(e)},[n]),bt=(0,k.useCallback)(async e=>{let t=N(e);if(!(z.current.has(t)||E.has(t))){de(e=>new Set(e).add(t));try{await Y(e)}finally{de(e=>{let n=new Set(e);return n.delete(t),n})}}},[Y,E]);(0,k.useEffect)(()=>{let e=!1,t=0;for(let n of G){if(t>=2)break;if(n.symbol||!n.toolUseId||n.filePath.startsWith(`(`))continue;let r=n.filePath;He.current.has(r)||(He.current.add(r),t+=1,Y({level:`symbols`,file:r}).then(t=>{if(e)return;let i=Ne(n,t.nodes);i&&Ze(n.toolUseId,r,{id:i.id,name:i.label,...i.symbolKind?{kind:i.symbolKind}:{},...i.line?{line:i.line}:{}})}).catch(()=>void 0).finally(()=>{He.current.delete(r)}))}return()=>{e=!0}},[G,Y,Ze]);let Z=(0,k.useMemo)(()=>({nodes:r.nodes,edges:h===`all`?r.edges:r.edges.filter(e=>e.refType===h)}),[r,h]),Q=r.nodes.find(e=>e.id===l),$=(0,k.useMemo)(()=>Se(Z,l,p),[p,Z,l]),xt=(0,k.useMemo)(()=>l?ve(Z,l):new Set,[Z,l]),{incomingCounts:St,outgoingCounts:Ct}=(0,k.useMemo)(()=>{let e=new Map,t=new Map;for(let n of Z.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}},[Z]),wt=d===`orbit`?l??void 0:void 0,Tt=(0,k.useMemo)(()=>be($,d,wt),[$,d,wt]),Et=(0,k.useMemo)(()=>[n,d,d===`orbit`?l??``:``,Te($)].join(``),[$,n,d,l]),Dt=(0,k.useCallback)(e=>{u(e.id),ce(new Set)},[]),Ot=(0,k.useCallback)(e=>{e.kind===`package`&&X({level:`files`,package:e.package??e.label}),e.kind===`file`&&e.file&&X({level:`symbols`,file:e.file,package:e.package})},[X]),kt=(0,k.useMemo)(()=>[Me(J),Me(ct),Me(st)].join(``),[J,ct,st]),At=(0,k.useMemo)(()=>{let e=new Set;for(let t of q)e.add(M(t.filePath));return e},[q]),jt=(0,k.useMemo)(()=>{let e=new Set;for(let t of q)t.symbol?.id&&e.add(t.symbol.id);return e},[q]);(0,k.useEffect)(()=>{let e=()=>{let e=Tt.map(({node:e})=>e),t=je(e,J),n=je(e,ct),r=new Set(t.keys()),i=Tt.map(({node:e,position:r})=>{let i=t.get(e.id)??[],a=i[0]??n.get(e.id)?.[0];return{id:e.id,type:`codemap`,position:r,data:{graphNode:e,selected:e.id===l,dimmed:!!l&&!xt.has(e.id),incoming:St.get(e.id)??0,outgoing:Ct.get(e.id)??0,isActive:!!a,...a?{activityType:a.type}:{},activeOperations:i,onSelect:Dt,onOpen:Ot,onShowHistory:j}}});dt(e=>it(e,i));let a=6,o=$.edges.map((e,t)=>{let n=!!l&&(e.source===l||e.target===l),i=r.has(e.source)||r.has(e.target),o=i&&(n||a>0);o&&--a;let s=Fe[e.refType]??`hsl(var(--muted-foreground))`,c=n||i?`smoothstep`:`default`;return{id:`edge:${e.source}:${e.target}:${t}`,source:e.source,target:e.target,type:c,animated:o,label:n?`${e.refType}${e.weight>1?` ×${e.weight}`:``}`:void 0,markerEnd:{type:b.ArrowClosed,color:s,width:14,height:14},style:{stroke:s,strokeWidth:i?Math.min(2.5+Math.log2(e.weight+1)*.65,5):n?Math.min(1.25+Math.log2(e.weight+1)*.65,4):1,opacity:i?1:l?n?.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:n?2:0,data:{renderKey:`${e.refType}:${e.weight}:${l?n?`focused`:`dimmed`:`idle`}:${i?`live`:`still`}:${o?`anim`:`still`}:${c}`}}}),s=new Map,c=new Set(J.map(me));for(let e of[...st].sort((e,t)=>e.timestamp-t.timestamp)){let t=me(e),n=s.get(t);n?n.push(e):s.set(t,[e])}let u=[...s.entries()].map(([e,t])=>({agentKey:e,activities:t,live:c.has(e),latest:t[t.length-1]?.timestamp??0})).sort((e,t)=>Number(t.live)-Number(e.live)||t.latest-e.latest).slice(0,4),d=[];for(let{agentKey:e,activities:t,live:n}of u){let r=t.slice(-7).map(e=>({activity:e,node:$.nodes.find(t=>ke(e,t))})).filter(e=>!!e.node).filter((e,t,n)=>t===0||e.node.id!==n[t-1]?.node.id),i=ze(e);for(let t=1;t<r.length;t++){let o=r[t-1],s=r[t],c=n&&a>0;c&&--a,d.push({id:`trail:${e}:${o.activity.timestamp}:${s.activity.timestamp}`,source:o.node.id,target:s.node.id,type:`smoothstep`,animated:c,label:t===r.length-1?`${Re(s.activity.agentName??s.activity.agent??`agent`)} TRAIL`:void 0,markerEnd:{type:b.ArrowClosed,color:i,width:13,height:13},style:{stroke:i,strokeWidth:2.5,strokeDasharray:`7 5`,opacity:.9},labelStyle:{fontSize:8,fontWeight:700,fill:i},labelBgStyle:{fill:`hsl(var(--card))`,fillOpacity:.94},labelBgPadding:[4,2],zIndex:6,data:{renderKey:`${i}:${t===r.length-1?`label`:`plain`}:${n?`live`:`still`}:${c?`anim`:`still`}`}})}}Le(d.length),mt(e=>at(e,[...o,...d]))},t=Et,n=Ve.current!==t;Ve.current=t,H.current!==null&&(window.clearTimeout(H.current),H.current=null),n?e():H.current=window.setTimeout(()=>{H.current=null,e()},120);let r;return Be.current!==Et&&(r=window.setTimeout(()=>{Be.current=Et;let e=$.nodes.length>48?0:240;gt({padding:.2,duration:e,maxZoom:1.25})},20)),()=>{H.current!==null&&(window.clearTimeout(H.current),H.current=null),r!==void 0&&window.clearTimeout(r)}},[kt,$,l,J,st,ct,Et,xt,gt,Ot,Dt,St,Ct,Tt,mt,dt]),(0,k.useEffect)(()=>{let e=window.setInterval(()=>{et()},2e3);return()=>window.clearInterval(e)},[et]);let Mt=z.current.get(`packages`)??(e.level===`packages`?r:Ue),Nt=(0,k.useCallback)(e=>z.current.get(N({level:`files`,package:e})),[D]),Pt=(0,k.useCallback)(e=>z.current.get(N({level:`symbols`,file:e})),[D]),Ft=(0,k.useCallback)(e=>{let t=e.filePath,n=Oe(e.filePath),r=`file:${e.filePath}`;for(let i of z.current.values()){let a=i.nodes.find(t=>t.kind===`file`&&!t.external&&De(t.file,e.filePath));if(a){t=a.file??t,n=a.package??n,r=a.id;break}}if(e.symbol){X({level:`symbols`,file:t,package:n},e.symbol.id);return}X({level:`files`,package:n},r)},[X]);(0,k.useEffect)(()=>{if(!P||I)return;let e=[...q].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`}`;V.current!==t&&(V.current=t,Ft(e))},[q,P,Ft,I]);let It=(0,k.useCallback)(()=>{if(I){Ce(null),R(null);return}Ce([...G]),R([...K])},[G,I,K]),Lt=(0,k.useCallback)(e=>{let t=e.package??e.label,n=!x.has(t);S(e=>{let r=new Set(e);return n?r.add(t):r.delete(t),r}),n&&bt({level:`files`,package:t}).then(()=>{let e=z.current.get(N({level:`files`,package:t})),n=e?we(e.nodes):void 0;n?.directories.length===1&&n.directories[0]&&C(e=>new Set(e).add(`${t}:${n.directories[0].path}`))}).catch(()=>void 0)},[bt,x]),Rt=(0,k.useCallback)(e=>{if(!e.file)return;let t=!w.has(e.file);se(n=>{let r=new Set(n);return t?r.add(e.file):r.delete(e.file),r}),t&&bt({level:`symbols`,file:e.file,package:e.package}).catch(()=>void 0)},[bt,w]),zt=(0,k.useCallback)(e=>{C(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Bt=(0,k.useCallback)(e=>{ue(t=>new Set(t).add(e))},[]),Vt=(0,k.useCallback)(e=>{X({level:`files`,package:e.package??`(root)`},e.id)},[X]),Ht=(0,k.useCallback)(e=>{e.file&&X({level:`symbols`,file:e.file,package:e.package},e.id)},[X]),Ut=(0,k.useMemo)(()=>{let e=v.trim().toLocaleLowerCase();if(!e)return[];let t=new Map;for(let n of z.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)},[v,D]),Wt=Ut.length>40,Gt=ae({count:Ut.length,getScrollElement:()=>yt.current,estimateSize:()=>40,overscan:8,enabled:Wt}),Kt=(0,k.useCallback)(e=>{e.kind===`package`?X({level:`packages`},e.id):e.kind===`file`?X({level:`files`,package:e.package??`(root)`},e.id):e.file&&X({level:`symbols`,file:e.file,package:e.package},e.id)},[X]),{incoming:qt,outgoing:Jt}=(0,k.useMemo)(()=>({incoming:Q?_e(Z,Q.id,`incoming`):[],outgoing:Q?_e(Z,Q.id,`outgoing`):[]}),[Z,Q]),{edgeWeight:Yt,connectedNodeCount:Xt}=(0,k.useMemo)(()=>{let e=0,t=new Set;for(let n of Z.edges)e+=n.weight,t.add(n.source),t.add(n.target);return{edgeWeight:e,connectedNodeCount:t.size}},[Z]),Zt=Q?q.filter(e=>ke(e,Q)):[],Qt=A?Qe(A):[];return(0,L.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-background`,children:[(0,L.jsx)(Ke,{scope:e,graph:r,agentPresences:lt,edgeWeight:Yt,connectedNodeCount:Xt,navigate:X}),(0,L.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,L.jsx)(rt,{rootGraph:Mt,search:v,searchInput:g,searchResults:Ut,virtualizeSearch:Wt,searchVirtualizer:Gt,treeScrollRef:yt,selectedId:l,expandedPackages:x,expandedDirectories:ne,expandedFiles:w,loadingBranches:E,activeFileNorms:At,activeSymbolIds:jt,revealAllKeys:le,packageGraph:Nt,graphForFile:Pt,navigate:X,togglePackage:Lt,toggleDirectory:zt,toggleFile:Rt,revealAllTree:Bt,selectFileFromTree:Vt,selectSymbolFromTree:Ht,selectSearchResult:Kt,handleOpenNode:Ot,onSearchInputChange:_,onSearchChange:y}),(0,L.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,L.jsx)(Ge,{layout:d,canvasMode:p,edgeFilter:h,canvasNodeCount:$.nodes.length,graphNodeCount:r.nodes.length,onLayoutChange:f,onCanvasModeChange:m,onEdgeFilterChange:ee}),(0,L.jsx)(qe,{presences:lt,onLocate:Ft}),(0,L.jsx)(Je,{paused:I!==null,followLive:P,agentFilter:F,agents:nt,onTogglePaused:It,onToggleFollow:()=>{V.current=null,ye(e=>!e)},onAgentFilter:e=>{V.current=null,xe(e)}}),(0,L.jsx)(We,{loading:a,error:s,graph:r,canvasNodeCount:$.nodes.length,flowNodes:ut,flowEdges:pt,onNodesChange:ft,onEdgesChange:ht,agentTrailCount:Ie})]}),(0,L.jsx)($e,{selectedNode:Q,incoming:qt,outgoing:Jt,filteredGraph:Z,expandedRelations:T,activeOperations:q,recentActivities:ot,activityTotalCount:Xe,selectedActivities:Zt,onClearSelection:()=>u(null),onOpenNode:Ot,onOpenActivity:j,onLocateActivity:Ft,onToggleRelation:e=>ce(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),onSelectNode:Dt})]}),A&&(0,L.jsx)(Pe,{historyFile:A,fileHistory:Qt,onClose:()=>j(null)})]})}function J(){return(0,L.jsx)(ce,{children:(0,L.jsx)(ot,{})})}export{J as CodeMap};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ai as t,Bi as n,Vi as r,lt as i,pn as a,za as o}from"./vendor-BuarzSSb.js";import{M as s}from"./stores-BptlyD_v.js";import{a as c,n as l,o as u,r as d,t as f}from"./dialog-ftgTihmF.js";import{k as p,o as m}from"./index-DHdO0CRE.js";var h=e(o(),1),g=i();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:i}){return e?i?(0,g.jsxs)(m,{variant:`destructive`,className:`gap-1`,children:[(0,g.jsx)(t,{className:`h-3 w-3`}),`Overdue`]}):(0,g.jsxs)(m,{variant:`default`,className:`gap-1 bg-emerald-600 hover:bg-emerald-600`,children:[(0,g.jsx)(n,{className:`h-3 w-3`}),`Active`]}):(0,g.jsxs)(m,{variant:`secondary`,className:`gap-1`,children:[(0,g.jsx)(r,{className:`h-3 w-3`}),`Disabled`]})}function b({open:e,onClose:n}){let r=s(e=>e.snapshot),i=s(e=>e.lastFiredAt);s(e=>e.revision);let o=r?.jobs??[],m=r?.count??0,b=r?.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)(a,{className:`h-5 w-5`}),`Cron Jobs`]}),(0,g.jsx)(d,{children:`Scheduled recurring tasks managed by the cron plugin.`})]}),m>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:[m,` job`,m===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`]})]}),m===0&&(0,g.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-12 text-muted-foreground`,children:[(0,g.jsx)(t,{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.`]})]}),m>0&&(0,g.jsx)(p,{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,i[e.name]&&(0,g.jsx)(`span`,{className:`ml-1 text-emerald-500`,title:`Last fired at ${i[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))})]})}),m>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,2 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{lt as t,za as n}from"./vendor-BuarzSSb.js";var r=e(n(),1),i=t(),a={0:`P0 Dead Package`,1:`P1 Dead File`,2:`P2 Dead Symbol`},o={0:`hsl(var(--destructive))`,1:`hsl(var(--warning))`,2:`hsl(var(--info))`};async function s(e){let t=await e.text();try{return JSON.parse(t)}catch{let e=t.length>300?`${t.slice(0,300)}…`:t;throw console.warn(JSON.stringify({level:`warn`,event:`deadcode_parse_error`,preview:e,timestamp:new Date().toISOString()})),Error(`The server returned a non-JSON response (possibly an HTML error page). Check that the backend is running and the /api/deadcode/* routes are wired.`)}}function c(){let[e,t]=(0,r.useState)(`idle`),[n,c]=(0,r.useState)(`idle`),[l,p]=(0,r.useState)(null),[m,h]=(0,r.useState)(null),[g,_]=(0,r.useState)(null),v=(0,r.useCallback)(async()=>{t(`scanning`),_(null),p(null),h(null),c(`idle`);try{let e=await fetch(`/api/deadcode/scan`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})});if(!e.ok){let t=await s(e);throw Error(t.detail??t.error??`HTTP ${e.status}`)}let n=await s(e);p(n),t(`done`)}catch(e){_(e instanceof Error?e.message:String(e)),t(`error`)}},[]),y=(0,r.useCallback)(async()=>{if(l){c(`generating`),_(null);try{let e=await fetch(`/api/deadcode/action-plan`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(l)});if(!e.ok){let t=await s(e);throw Error(t.detail??t.error??`HTTP ${e.status}`)}let t=await s(e);h(t),c(`ready`)}catch(e){_(e instanceof Error?e.message:String(e)),c(`idle`)}}},[l]),b=(0,r.useCallback)(()=>{if(!m)return;c(`executing`);let e=[`# Dead-Code Cleanup Plan`,``,m.summary,``,`## Files to address (in priority order)`,...m.files.map((e,t)=>`${t+1}. [${a[e.priority]}] ${e.file} — ${e.symbolCount} symbol(s) to remove`+(e.symbols.length>0?`\n Symbols: ${e.symbols.slice(0,5).join(`, `)}${e.symbols.length>5?` and ${e.symbols.length-5} more`:``}`:``))].join(`
|
|
2
|
-
`),t=window.__WS;t&&t.readyState===WebSocket.OPEN?t.send(JSON.stringify({type:`user.message`,payload:{text:e,action:`send`}})):(navigator.clipboard.writeText(e),_(`Agent not connected. Plan copied to clipboard — paste it into the chat.`)),c(`idle`)},[m]);return(0,i.jsxs)(`div`,{style:{padding:`16px`,fontFamily:`var(--font-sans, system-ui, sans-serif)`,color:`hsl(var(--foreground))`,background:`hsl(var(--background))`},children:[(0,i.jsx)(`h2`,{style:{margin:`0 0 16px`,fontSize:`18px`,fontWeight:600,color:`hsl(var(--foreground))`},children:`🔍 Dead-Code Scan`}),(0,i.jsx)(`button`,{type:`button`,onClick:v,disabled:e===`scanning`,style:{padding:`8px 16px`,fontSize:`14px`,fontWeight:500,background:e===`scanning`?`hsl(var(--muted))`:`hsl(var(--primary))`,color:e===`scanning`?`hsl(var(--muted-foreground))`:`hsl(var(--primary-foreground))`,border:`1px solid hsl(var(--border))`,borderRadius:`0`,cursor:e===`scanning`?`not-allowed`:`pointer`},children:e===`scanning`?`Scanning…`:`Scan for Dead Code`}),g&&(0,i.jsxs)(`div`,{style:{marginTop:`12px`,padding:`8px 12px`,background:`hsl(var(--destructive) / 0.1)`,color:`hsl(var(--destructive))`,border:`1px solid hsl(var(--destructive) / 0.3)`,borderRadius:`0`,fontSize:`13px`},children:[g,(0,i.jsx)(`button`,{type:`button`,onClick:()=>_(null),style:{marginLeft:`12px`,background:`none`,border:`none`,cursor:`pointer`,fontWeight:600,color:`hsl(var(--destructive))`},children:`✕`})]}),l&&(0,i.jsxs)(`div`,{style:{marginTop:`16px`},children:[(0,i.jsxs)(`div`,{style:{display:`flex`,gap:`12px`,marginBottom:`12px`},children:[(0,i.jsx)(u,{label:`Total Symbols`,value:l.stats.totalSymbols,token:`info`}),(0,i.jsx)(u,{label:`Alive`,value:l.stats.alive,token:`success`}),(0,i.jsx)(u,{label:`Dead`,value:l.stats.dead,token:`destructive`})]}),l.deadPackages.length>0&&(0,i.jsx)(d,{title:`Dead Packages (${l.deadPackages.length})`,token:`destructive`,children:l.deadPackages.map(e=>(0,i.jsx)(f,{columns:[e.package,e.path,`${e.fileCount} file(s)`]},e.package))}),l.deadFiles.length>0&&(0,i.jsx)(d,{title:`Dead Files (${l.deadFiles.length})`,token:`warning`,children:l.deadFiles.map(e=>(0,i.jsx)(f,{columns:[e.file,`${e.symbolCount} symbol(s)`,e.lang]},e.file))}),l.deadSymbols.length>0&&(0,i.jsxs)(d,{title:`Dead Symbols (${l.deadSymbols.length})`,token:`info`,children:[l.deadSymbols.slice(0,50).map(e=>(0,i.jsx)(f,{columns:[e.name,e.kind,e.file.split(`/`).pop()??e.file,`line ${e.line}`]},`${e.file}:${e.line}:${e.name}`)),l.deadSymbols.length>50&&(0,i.jsxs)(`div`,{style:{padding:`6px 8px`,color:`hsl(var(--muted-foreground))`,fontSize:`12px`},children:[`… and `,l.deadSymbols.length-50,` more`]})]}),e===`done`&&(0,i.jsx)(`button`,{type:`button`,onClick:y,disabled:n===`generating`,style:{marginTop:`12px`,padding:`8px 16px`,fontSize:`14px`,fontWeight:500,background:n===`generating`?`hsl(var(--muted))`:`hsl(var(--accent))`,color:n===`generating`?`hsl(var(--muted-foreground))`:`hsl(var(--accent-foreground))`,border:`1px solid hsl(var(--border))`,borderRadius:`0`,cursor:n===`generating`?`not-allowed`:`pointer`},children:n===`generating`?`Generating…`:`Generate Action Plan`})]}),m&&(0,i.jsxs)(`div`,{style:{marginTop:`16px`,border:`1px solid hsl(var(--border))`,borderRadius:`0`,padding:`12px`,background:`hsl(var(--card))`},children:[(0,i.jsx)(`h3`,{style:{margin:`0 0 8px`,fontSize:`15px`,fontWeight:600,color:`hsl(var(--card-foreground))`},children:`📋 Action Plan`}),(0,i.jsx)(`p`,{style:{fontSize:`13px`,color:`hsl(var(--muted-foreground))`,margin:`0 0 12px`},children:m.summary}),m.files.map((e,t)=>(0,i.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:`8px`,padding:`6px 0`,borderBottom:t<m.files.length-1?`1px solid hsl(var(--border))`:`none`,fontSize:`13px`},children:[(0,i.jsx)(`span`,{style:{background:o[e.priority]??`hsl(var(--muted-foreground))`,color:`hsl(var(--primary-foreground))`,borderRadius:`0`,padding:`2px 6px`,fontSize:`11px`,fontWeight:600,whiteSpace:`nowrap`,flexShrink:0},children:a[e.priority]??`P${e.priority}`}),(0,i.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,i.jsx)(`div`,{style:{fontWeight:500,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,color:`hsl(var(--foreground))`},children:e.file}),(0,i.jsxs)(`div`,{style:{color:`hsl(var(--muted-foreground))`,fontSize:`12px`},children:[e.symbolCount,` symbol(s)`,e.symbols.length>0&&` · ${e.symbols.slice(0,2).join(`, `)}${e.symbols.length>2?`…`:``}`]})]})]},e.file)),(0,i.jsx)(`button`,{type:`button`,onClick:b,disabled:n===`executing`,style:{marginTop:`12px`,padding:`8px 16px`,fontSize:`14px`,fontWeight:500,background:n===`executing`?`hsl(var(--muted))`:`hsl(var(--success))`,color:`hsl(var(--primary-foreground))`,border:`1px solid hsl(var(--border))`,borderRadius:`0`,cursor:n===`executing`?`not-allowed`:`pointer`},children:n===`executing`?`Sending…`:`Execute Plan via Agent`})]})]})}var l={success:`hsl(var(--success))`,warning:`hsl(var(--warning))`,info:`hsl(var(--info))`,destructive:`hsl(var(--destructive))`,primary:`hsl(var(--primary))`};function u({label:e,value:t,token:n}){let r=l[n];return(0,i.jsxs)(`div`,{style:{flex:1,padding:`10px`,borderRadius:`0`,border:`1px solid hsl(var(--border))`,background:`hsl(var(--card))`,textAlign:`center`},children:[(0,i.jsx)(`div`,{style:{fontSize:`24px`,fontWeight:700,color:r},children:t}),(0,i.jsx)(`div`,{style:{fontSize:`12px`,color:`hsl(var(--muted-foreground))`,marginTop:`2px`},children:e})]})}function d({title:e,token:t,children:n}){let r=l[t];return(0,i.jsxs)(`div`,{style:{marginBottom:`12px`},children:[(0,i.jsx)(`h3`,{style:{margin:`0 0 6px`,fontSize:`14px`,fontWeight:600,color:r,borderLeft:`3px solid ${r}`,paddingLeft:`8px`},children:e}),(0,i.jsx)(`div`,{style:{border:`1px solid hsl(var(--border))`,borderRadius:`0`,overflow:`hidden`,fontSize:`13px`},children:n})]})}function f({columns:e}){return(0,i.jsx)(`div`,{style:{display:`flex`,gap:`8px`,padding:`5px 8px`,borderBottom:`1px solid hsl(var(--border))`,fontSize:`13px`,fontFamily:`var(--font-mono, monospace)`,background:`hsl(var(--card))`,color:`hsl(var(--card-foreground))`},children:e.map((e,t)=>(0,i.jsx)(`span`,{style:{flex:t===0?2:1,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e},t))})}export{c as DeadCodeScanPanel};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ai as t,Ki as n,La as r,Lr as i,Oa as a,Pa as o,kt as s,li as c,lt as l,ni as u,rn as d,ta as f,vn as p,za as m}from"./vendor-BuarzSSb.js";import"./i18n-B0hsnanh.js";import{c as h}from"./index-DHdO0CRE.js";var g=e(m(),1),_=l();function v({title:e,value:t,subtitle:n,icon:r,color:i=`text-primary`,trend:a}){let{t:c}=o();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)(s,{className:`w-3 h-3 text-success`}),a===`down`&&(0,_.jsx)(s,{className:`w-3 h-3 rotate-180 text-destructive`}),(0,_.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:c(a===`up`?`activity:debug.trendUp`:a===`down`?`activity:debug.trendDown`:`activity:debug.trendStable`)})]})]})}function y(){let{t:e}=o(),[l,m]=(0,g.useState)({fileWatcher:null,system:null,lastUpdated:null,error:null}),[y,C]=(0,g.useState)(!0),[w,T]=(0,g.useState)(2e3),E=(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();m({fileWatcher:n,system:i,lastUpdated:new Date,error:null})}catch(e){m(t=>({...t,error:e instanceof Error?e.message:r.t(`activity:debug.fetchFailed`)}))}finally{C(!1)}},[]);return(0,g.useEffect)(()=>{E();let e=setInterval(E,w);return()=>clearInterval(e)},[E,w]),(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)(f,{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)(p,{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:w,onChange:e=>T(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:()=>{C(!0),E()},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)(p,{className:`w-4 h-4 ${y?`animate-spin`:``}`}),e(`common:action.refresh`)]})]})]})}),l.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)(t,{className:`w-4 h-4`}),e(`activity:debug.lastUpdated`,{time:l.lastUpdated.toLocaleTimeString()})]}),l.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)(n,{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:l.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)(c,{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:l.fileWatcher?.watcherActive?e(`activity:debug.running`):e(`activity:debug.stopped`),icon:d,color:l.fileWatcher?.watcherActive?`text-success`:`text-destructive`}),(0,_.jsx)(v,{title:e(`activity:debug.activeProjects`),value:l.fileWatcher?.activeProjects??0,subtitle:e(`activity:debug.projectsWatched`),icon:u,color:`text-primary`}),(0,_.jsx)(v,{title:e(`activity:debug.fileChanges`),value:l.fileWatcher?.fileChangesDetected??0,subtitle:e(`activity:debug.totalDetected`),icon:a,color:`text-primary`,trend:`neutral`}),(0,_.jsx)(v,{title:e(`activity:debug.filesProcessed`),value:l.fileWatcher?.filesProcessed??0,subtitle:e(`activity:debug.afterHash`),icon:i,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:l.fileWatcher?.broadcastsSent??0,subtitle:e(`activity:debug.toClients`),icon:s,color:`text-success`}),(0,_.jsx)(v,{title:e(`activity:debug.debounceResets`),value:l.fileWatcher?.debounceResets??0,subtitle:e(`activity:debug.rapidWrites`),icon:p,color:`text-warning`}),(0,_.jsx)(v,{title:e(`activity:debug.avgDebounce`),value:`${(l.fileWatcher?.averageDebounceDelayMs??0).toFixed(1)}ms`,subtitle:e(`activity:debug.actualDelay`),icon:t,color:`text-warning`}),(0,_.jsx)(v,{title:e(`activity:debug.totalDelay`),value:`${(l.fileWatcher?.totalDebounceDelayMs??0).toFixed(0)}ms`,subtitle:e(`activity:debug.sumDelays`),icon:f,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)(i,{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(l.system?.memoryUsage?.rss??0),subtitle:l.system?`PID ${l.system.pid}`:void 0,icon:d,color:`text-primary`}),(0,_.jsx)(v,{title:e(`activity:debug.heapUsed`),value:b(l.system?.memoryUsage?.heapUsed??0),subtitle:e(`activity:debug.jsHeap`),icon:f,color:`text-primary`}),(0,_.jsx)(v,{title:e(`activity:debug.heapTotal`),value:b(l.system?.memoryUsage?.heapTotal??0),subtitle:e(`activity:debug.totalHeap`),icon:f,color:`text-success`}),(0,_.jsx)(v,{title:`V8 Heap Limit`,value:b(l.system?.heapLimit??0),subtitle:`Configured old-space ceiling`,icon:i,color:`text-warning`}),(0,_.jsx)(v,{title:`Server Uptime`,value:S(l.system?.uptime??0),subtitle:`Since process start`,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)(a,{className:`h-4 w-4 text-primary`}),`Live WrongStack Processes`]}),(0,_.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-border/70 bg-card/75 shadow-sm`,children:(0,_.jsxs)(`table`,{className:`w-full min-w-[980px] text-left text-xs`,children:[(0,_.jsx)(`thead`,{className:`border-b border-border/70 bg-muted/35 text-muted-foreground`,children:(0,_.jsxs)(`tr`,{children:[(0,_.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:`Surface`}),(0,_.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:`Memory`}),(0,_.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:`Growth / signal`}),(0,_.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:`Workload`}),(0,_.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:`HQ offline queue`}),(0,_.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:`Resources / hotspot`})]})}),(0,_.jsxs)(`tbody`,{children:[(l.system?.processes??[]).map(e=>{let t=[e.workload.messages===void 0?void 0:`${e.workload.messages} msgs`,e.workload.messageEstimatedTokens===void 0?void 0:`${e.workload.messageEstimatedTokens.toLocaleString()} ctx tokens`,e.workload.historyEntries===void 0?void 0:`${e.workload.historyMountedEntries??0}/${e.workload.historyEntries} history mounted`,e.workload.appRenders===void 0?void 0:`${e.workload.appRenders} renders`,e.workload.metricsDroppedObservations?`${e.workload.metricsDroppedObservations} metric drops`:void 0,e.workload.kanbanSyncActive?`kanban sync active`:void 0,e.workload.kanbanSyncPendingBoards?`${e.workload.kanbanSyncPendingBoards} kanban pending`:void 0,e.workload.kanbanSyncFullRescanPending?`kanban full rescan pending`:void 0,e.workload.kanbanSyncRemoteApplyQueued?`${e.workload.kanbanSyncPendingRemoteBoards??0} remote boards queued`:void 0,e.workload.kanbanSyncCoalescedRefreshes?`${e.workload.kanbanSyncCoalescedRefreshes} kanban coalesced`:void 0,e.workload.kanbanSupervisorSnapshots?`${e.workload.kanbanSupervisorSnapshots} supervised boards`:void 0,e.workload.kanbanSupervisorScheduledBoards?`${e.workload.kanbanSupervisorScheduledBoards} supervisor schedules`:void 0].filter(Boolean).join(` · `);return(0,_.jsxs)(`tr`,{className:`border-b border-border/50 align-top last:border-b-0`,children:[(0,_.jsxs)(`td`,{className:`px-3 py-3`,children:[(0,_.jsx)(`div`,{className:`font-medium text-foreground`,children:e.surface}),(0,_.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[`PID `,e.pid]}),(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:new Date(e.ts).toLocaleTimeString()})]}),(0,_.jsxs)(`td`,{className:`px-3 py-3 tabular-nums`,children:[(0,_.jsxs)(`div`,{children:[`RSS `,b(e.memory.rss)]}),(0,_.jsxs)(`div`,{className:`text-muted-foreground`,children:[`heap `,b(e.memory.heapUsed),e.memory.retainedHeapUsed===void 0?``:` · retained ${b(e.memory.retainedHeapUsed)}`]}),e.memory.nativeResidual===void 0?null:(0,_.jsxs)(`div`,{className:`text-muted-foreground`,children:[`native `,b(e.memory.nativeResidual)]}),e.memory.external===void 0?null:(0,_.jsxs)(`div`,{className:`text-muted-foreground`,children:[`external `,b(e.memory.external),e.memory.arrayBuffers===void 0?``:` · buffers ${b(e.memory.arrayBuffers)}`]})]}),(0,_.jsxs)(`td`,{className:`px-3 py-3 tabular-nums`,children:[(0,_.jsx)(`div`,{className:e.signal===`stable`?`text-success`:e.signal?`text-warning`:`text-muted-foreground`,children:e.signal??`sampling`}),(0,_.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[`heap `,x(e.heapGrowthBytesPerHour)]}),(0,_.jsxs)(`div`,{className:`text-muted-foreground`,children:[`RSS `,x(e.rssGrowthBytesPerHour)]})]}),(0,_.jsx)(`td`,{className:`px-3 py-3 text-muted-foreground`,children:t||`—`}),(0,_.jsx)(`td`,{className:`px-3 py-3 tabular-nums`,children:e.hqQueue?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`div`,{children:[e.hqQueue.entries,` frames ·`,` `,b(e.hqQueue.bytes),` /`,` `,b(e.hqQueue.maxBytes)]}),(0,_.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[e.hqQueue.coalescedFrames,` coalesced ·`,` `,e.hqQueue.droppedFrames,` dropped`]}),e.hqSnapshot?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`div`,{className:`text-muted-foreground`,children:[`snapshot`,` `,e.hqSnapshot.inFlight?`in-flight`:e.hqSnapshot.pending?`pending`:e.hqSnapshot.timerScheduled?`scheduled`:`idle`]}),(0,_.jsxs)(`div`,{className:`text-muted-foreground`,children:[`events`,` `,e.hqSnapshot.eventInFlight?`in-flight`:`idle`,` ·`,` `,e.hqSnapshot.pendingEvents,` pending ·`,` `,e.hqSnapshot.coalescedEvents,` coalesced ·`,` `,e.hqSnapshot.droppedEvents,` dropped`]})]}):null]}):(0,_.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}),(0,_.jsxs)(`td`,{className:`max-w-[360px] px-3 py-3 text-muted-foreground`,children:[(0,_.jsxs)(`div`,{children:[e.resources.active??0,` active`,e.resources.types?` · ${e.resources.types}`:``]}),e.profileTopStack?(0,_.jsxs)(`div`,{className:`mt-1 truncate`,title:e.profileTopStack,children:[e.profileTopStackBytes===void 0?``:`${b(e.profileTopStackBytes)} · `,e.profileTopStack]}):null]})]},e.pid)}),(l.system?.processes?.length??0)===0?(0,_.jsx)(`tr`,{children:(0,_.jsx)(`td`,{className:`px-3 py-5 text-muted-foreground`,colSpan:6,children:`Waiting for heap flight-recorder samples…`})}):null]})]})})]}),(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)(d,{className:`h-4 w-4 text-primary`}),`Codebase Index Server`]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4`,children:[(0,_.jsx)(v,{title:`Connection`,value:l.system?.codebaseIndexServer?.health?.status??l.system?.codebaseIndexServer?.status??`unknown`,subtitle:l.system?.codebaseIndexServer?.pid?`PID ${l.system.codebaseIndexServer.pid} · RTT ${l.system.codebaseIndexServer.health?.latencyMs??`—`}ms`:`No connected project server`,icon:a,color:l.system?.codebaseIndexServer?.health?.status===`healthy`?`text-success`:l.system?.codebaseIndexServer?.status===`unresponsive`||l.system?.codebaseIndexServer?.status===`error`?`text-destructive`:`text-warning`}),(0,_.jsx)(v,{title:`Index RAM (RSS)`,value:b(l.system?.codebaseIndexServer?.health?.server?.memory.rss??0),subtitle:`Heap ${b(l.system?.codebaseIndexServer?.health?.server?.memory.heapUsed??0)} / ${b(l.system?.codebaseIndexServer?.health?.server?.memory.heapTotal??0)}`,icon:f,color:`text-primary`}),(0,_.jsx)(v,{title:`Index Workload`,value:`${l.system?.codebaseIndexServer?.health?.server?.activeRequests??0} requests`,subtitle:`${l.system?.codebaseIndexServer?.health?.server?.activeWrites??0} writes · ${l.system?.codebaseIndexServer?.health?.server?.queuedWrites??0} queued`,icon:i,color:`text-primary`}),(0,_.jsx)(v,{title:`Index Watcher`,value:l.system?.codebaseIndexServer?.health?.server?.watchingExternal?`Active`:`Off`,subtitle:`${l.system?.codebaseIndexServer?.health?.server?.watchingClients??0} owners · ${l.system?.codebaseIndexServer?.health?.server?.pendingExternalFiles??0} pending`,icon:c,color:l.system?.codebaseIndexServer?.health?.server?.watchingExternal?`text-success`:`text-muted-foreground`})]})]}),(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:l.fileWatcher,serverPid:l.system?.pid,serverMemory:l.system?.memoryUsage,serverHeapLimit:l.system?.heapLimit,serverUptime:l.system?.uptime,processes:l.system?.processes,codebaseIndexServer:l.system?.codebaseIndexServer},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===void 0?`—`:`${e>0?`+`:e<0?`−`:``}${b(Math.abs(e))}/h`}function S(e){return e<60?`${e.toFixed(0)}s`:e<3600?`${(e/60).toFixed(1)}m`:`${(e/3600).toFixed(1)}h`}export{y as DebugDashboard};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{$i as t,In as n,La as r,Pa as i,Zt as a,an as o,dt as s,gi as c,lt as l,za as u}from"./vendor-BuarzSSb.js";import"./i18n-B0hsnanh.js";import{t as d}from"./useWebSocket-Bc4S0N4r.js";import{t as f}from"./utils-B-9lSDIn.js";import{o as p}from"./view-navigation-DxfiZrXS.js";import{c as m}from"./index-DHdO0CRE.js";var h=e(u(),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-md`]??e.radius??`0.5rem`,u=e[`font-sans`]??e.fontSans??`system-ui, sans-serif`,d=e[`font-display`]??e.fontDisplay??u,f=e[`shadow-2`]??(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({onTune:e}){let[t,n]=(0,h.useState)(``),r=({label:t,knob:n,values:r})=>(0,S.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,S.jsx)(`span`,{className:`w-16 shrink-0 text-[9px] uppercase text-muted-foreground`,children:t}),(0,S.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:r.map(t=>(0,S.jsx)(`button`,{type:`button`,onClick:()=>e({[n]:t}),className:`rounded border border-border/60 px-1.5 py-0.5 text-[10px] hover:bg-primary hover:text-primary-foreground`,children:t},t))})]});return(0,S.jsxs)(`div`,{className:`mt-1 flex flex-col gap-1.5 rounded-lg border border-border/60 bg-muted/30 p-2`,children:[(0,S.jsx)(`span`,{className:`text-[10px] font-semibold uppercase text-muted-foreground`,children:`Tune`}),(0,S.jsx)(r,{label:`Radius`,knob:`radius`,values:[`none`,`sm`,`md`,`lg`,`xl`,`full`]}),(0,S.jsx)(r,{label:`Density`,knob:`density`,values:[`compact`,`cozy`,`comfortable`]}),(0,S.jsx)(r,{label:`Motion`,knob:`motion`,values:[`snappy`,`smooth`,`none`]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,S.jsx)(`span`,{className:`w-16 shrink-0 text-[9px] uppercase text-muted-foreground`,children:`Font`}),(0,S.jsx)(`input`,{value:t,onChange:e=>n(e.target.value),onKeyDown:n=>{n.key===`Enter`&&t.trim()&&e({font:t.trim()})},placeholder:`Space Grotesk…`,className:`h-6 min-w-0 flex-1 rounded border border-border/60 bg-background/70 px-1.5 text-[10px]`}),(0,S.jsx)(`button`,{type:`button`,onClick:()=>t.trim()&&e({font:t.trim()}),className:`rounded border border-border/60 px-1.5 py-0.5 text-[10px] hover:bg-muted`,children:`Set`})]})]})}function k({className:e}){let{client:l}=d(),{t:u}=i(),[g,_]=(0,h.useState)([]),[v,y]=(0,h.useState)(null),[b,x]=(0,h.useState)({}),[w,k]=(0,h.useState)(`web`),[A,j]=(0,h.useState)(``),[M,N]=(0,h.useState)(null);(0,h.useEffect)(()=>{if(!l)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??{}))},n=e=>{let t=e.payload;t?.ok&&t.overrides&&x(t.overrides)},i=e=>{let t=e.payload;t?.ok&&t.overrides?(x(t.overrides),N(`Tuned`)):t?.error&&N(`Tune failed: ${t.error}`)},a=e=>{let t=e.payload;t?.ok&&t.kit&&(y(t.kit),x(t.overrides??{}),N(`Swapped to ${t.kit}`))},o=e=>{let t=e.payload;N(t?.ok?r.t(`activity:design.wrote`,{path:t.path}):r.t(`activity:design.materializeFailed`,{error:t?.error??`error`}))},s=e=>{let t=e.payload;if(!t?.ok){N(r.t(`activity:design.verifyError`,{error:t?.error??`error`}));return}let n=Math.round((t.score??1)*100);N(t.violationCount?r.t(`activity:design.verifyOffPalette`,{pct:n,count:t.violationCount,files:t.filesScanned}):r.t(`activity:design.verifyClean`,{files:t.filesScanned}))};return l.on(`design.list`,e),l.on(`design.use`,t),l.on(`design.set`,n),l.on(`design.tune`,i),l.on(`design.swap`,a),l.on(`design.materialize`,o),l.on(`design.verify`,s),l.send({type:`design.list`}),()=>{l.off(`design.list`,e),l.off(`design.use`,t),l.off(`design.set`,n),l.off(`design.tune`,i),l.off(`design.swap`,a),l.off(`design.materialize`,o),l.off(`design.verify`,s)}},[l]);let P=(0,h.useCallback)(e=>l?.send({type:`design.use`,payload:{kit:e,stack:w}}),[l,w]),F=(0,h.useCallback)((e,t)=>{x(n=>({...n,[e]:t})),l?.send({type:`design.set`,payload:{overrides:{[e]:t}}})},[l]),I=(0,h.useCallback)(e=>l?.send({type:`design.tune`,payload:{tune:e}}),[l]),L=(0,h.useCallback)(()=>{N(r.t(`activity:design.writing`)),l?.send({type:`design.materialize`,payload:{stack:w}})},[l,w]),R=(0,h.useCallback)(()=>{N(r.t(`activity:design.scanning`)),l?.send({type:`design.verify`})},[l]),z=(0,h.useMemo)(()=>{let e=A.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,A]);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)(n,{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:u(`activity:design.heading`)}),(0,S.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`activity:design.kitsCount`,{count:z.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)(o,{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:A,onChange:e=>j(e.target.value),placeholder:u(`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=>k(e.target.value),className:`h-9 rounded-md border border-border/70 bg-background/70 px-2 text-sm shadow-sm`,title:u(`activity:design.stackTitle`),children:C.map(e=>(0,S.jsx)(`option`,{value:e,children:e},e))}),M&&(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:M}),(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:u(`common:action.close`),children:(0,S.jsx)(s,{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:z.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)(n,{className:`h-8 w-8 text-primary/60`}),(0,S.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:u(`activity:design.kitsCount`,{count:0})}),(0,S.jsx)(`p`,{className:`text-xs`,children:u(`activity:design.searchPlaceholder`)})]}):(0,S.jsx)(`div`,{className:`grid gap-4 [grid-template-columns:repeat(auto-fill,minmax(min(100%,20rem),1fr))]`,children:z.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:u(`activity:designStudio.light`)}),(0,S.jsx)(E,{t:T(e.dark,r,`dark`),label:u(`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)(t,{className:`w-3 h-3`}),` `,u(`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:()=>P(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:u(n?`activity:design.reapply`:`activity:design.use`)}),n&&(0,S.jsxs)(`button`,{type:`button`,onClick:L,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:u(`activity:design.materializeTitle`,{stack:w}),children:[(0,S.jsx)(c,{className:`w-3 h-3`}),` `,u(`activity:design.materialize`)]}),n&&(0,S.jsxs)(`button`,{type:`button`,onClick:R,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:u(`activity:design.verifyTitle`),children:[(0,S.jsx)(a,{className:`w-3 h-3`}),` `,u(`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:F}),n&&(0,S.jsx)(O,{onTune:I})]})]},e.id)})})})]})}export{k as DesignGalleryView};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./chat-store-CtOyUCdF.js";import{Ai as n,Bt as r,Cn as i,Ct as a,Et as o,Fi as s,Ii as c,La as l,Pa as u,Ti as d,Wi as f,dn as p,dt as m,gr as h,hn as g,ir as _,kn as v,lt as y,mn as b,ut as x,wn as S,za as C}from"./vendor-BuarzSSb.js";import"./i18n-B0hsnanh.js";import{t as ee}from"./useWebSocket-Bc4S0N4r.js";import{t as w}from"./utils-B-9lSDIn.js";import{g as T,h as E,t as D}from"./stores-BptlyD_v.js";import{o as O}from"./view-navigation-DxfiZrXS.js";import{t as k}from"./button-Dcy288Mc.js";import{h as A,m as te,p as ne,y as j}from"./index-DHdO0CRE.js";var M=e(C(),1),N=y(),P={pending:{icon:(0,N.jsx)(s,{className:`w-4 h-4`}),color:`text-muted-foreground`,label:`Pending`},in_progress:{icon:(0,N.jsx)(n,{className:`w-4 h-4 animate-spin`}),color:`text-primary`,label:`In Progress`},blocked:{icon:(0,N.jsx)(v,{className:`w-4 h-4`}),color:`text-warning`,label:`Blocked`},failed:{icon:(0,N.jsx)(c,{className:`w-4 h-4`}),color:`text-destructive`,label:`Failed`},review:{icon:(0,N.jsx)(b,{className:`w-4 h-4`}),color:`text-info`,label:`Review`},completed:{icon:(0,N.jsx)(f,{className:`w-4 h-4`}),color:`text-success`,label:`Done`}},F={critical:`bg-destructive/15 text-destructive`,high:`bg-warning/15 text-warning`,medium:`bg-info/15 text-info`,low:`bg-muted text-muted-foreground`},I={feature:`bg-success/15 text-success`,bugfix:`bg-destructive/15 text-destructive`,refactor:`bg-primary/15 text-primary`,docs:`bg-info/15 text-info`,test:`bg-primary/15 text-primary`,chore:`bg-muted text-muted-foreground`};function L(e){if(!e)return``;let t=Math.floor(e/6e4);if(t<60)return`${t}m`;let n=Math.floor(t/60),r=t%60;return r>0?`${n}h ${r}m`:`${n}h`}function R({task:e,onStatusChange:t,onRetry:r,agents:i,onAssign:o,compact:s,className:c}){let{t:l}=u(),d=P[e.status],[f,p]=(0,M.useState)(!1),m=e.status===`in_progress`;return(0,N.jsxs)(`div`,{className:w(`w-full text-left rounded-lg border p-3 transition-all hover:shadow-sm`,m?`border-primary/40 bg-primary/5`:e.status===`completed`?`border-success/35 bg-success/6`:e.status===`failed`?`border-destructive/40 bg-destructive/5`:`border-border bg-card`,c),children:[(0,N.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,N.jsx)(`span`,{className:w(`mt-0.5`,d.color),role:`img`,"aria-label":m?l(`common:status.inProgress`):void 0,children:d.icon}),(0,N.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,N.jsx)(`span`,{className:`text-sm font-medium`,children:e.title}),(0,N.jsx)(`span`,{className:w(`px-1.5 py-0.5 rounded text-[10px] font-medium`,F[e.priority]),children:e.priority}),(0,N.jsx)(`span`,{className:w(`px-1.5 py-0.5 rounded text-[10px] font-medium`,I[e.type]),children:e.type})]}),e.description&&(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1 line-clamp-2`,children:e.description})]})]}),e.assignee&&(0,N.jsxs)(`div`,{className:w(`mt-2 inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-[10px] font-medium`,m?`bg-primary/15 text-primary`:`bg-muted text-muted-foreground`),children:[m&&(0,N.jsx)(n,{className:`w-3 h-3 animate-spin`,"aria-label":l(`common:status.working`)}),(0,N.jsx)(`span`,{children:e.assignee})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-3 mt-2 text-xs text-muted-foreground`,children:[e.estimateHours?(0,N.jsxs)(`span`,{children:[`~`,e.estimateHours,`h`]}):null,e.actualHours?(0,N.jsxs)(`span`,{children:[`• `,e.actualHours,`h`]}):null,e.startedAt?(0,N.jsxs)(`span`,{children:[`• `,L(Date.now()-e.startedAt)]}):null]}),e.tags.length>0&&(0,N.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-2`,children:e.tags.map(e=>(0,N.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] bg-muted text-muted-foreground`,children:e},e))}),!s&&(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 mt-2`,children:[t&&e.status!==`in_progress`&&e.status!==`completed`&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>t(e.id,`in_progress`),className:`px-2 py-0.5 text-[10px] rounded bg-primary/15 text-primary hover:bg-primary/25 transition-colors`,children:l(`activity:task.start`)}),t&&e.status===`in_progress`&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>t(e.id,`completed`),className:`px-2 py-0.5 text-[10px] rounded bg-success/15 text-success hover:bg-success/25 transition-colors`,children:l(`activity:task.complete`)}),r&&(e.status===`failed`||e.status===`completed`)&&(0,N.jsxs)(`button`,{type:`button`,onClick:()=>r(e.id),className:`px-2 py-0.5 text-[10px] rounded bg-muted text-muted-foreground hover:bg-muted/70 transition-colors inline-flex items-center gap-1`,children:[(0,N.jsx)(b,{className:`w-3 h-3`}),` `,l(`activity:task.retry`)]}),o&&i&&i.length>0&&(f?(0,N.jsxs)(`select`,{defaultValue:e.assignee??``,onChange:t=>{o(e.id,t.target.value),p(!1)},onBlur:()=>p(!1),className:`px-1 py-0.5 text-[10px] rounded border border-border bg-card`,children:[(0,N.jsx)(`option`,{value:``,children:l(`activity:task.unassigned`)}),i.map(e=>(0,N.jsx)(`option`,{value:e,children:e},e))]}):(0,N.jsxs)(`button`,{type:`button`,onClick:()=>p(!0),className:`px-2 py-0.5 text-[10px] rounded bg-muted text-muted-foreground hover:bg-muted/70 transition-colors inline-flex items-center gap-1`,title:l(`activity:task.assignTitle`),children:[(0,N.jsx)(a,{className:`w-3 h-3`}),` `,l(`activity:task.assign`)]}))]})]})}var z=[{key:`pending`,label:`Pending`,match:[`pending`,`blocked`]},{key:`in_progress`,label:`In Progress`,match:[`in_progress`]},{key:`review`,label:`Review`,match:[`review`]},{key:`failed`,label:`Failed`,match:[`failed`]},{key:`completed`,label:`Done`,match:[`completed`]}],B={pending:`bg-muted text-muted-foreground`,ready:`bg-info/15 text-info`,running:`bg-primary/15 text-primary`,paused:`bg-warning/15 text-warning`,completed:`bg-success/15 text-success`,failed:`bg-destructive/15 text-destructive`,skipped:`bg-muted text-muted-foreground`};function re(){let{client:e}=ee(),{t}=u(),n=E(e=>e.phases),r=E(e=>e.multiBoard),[i,a]=(0,M.useState)(`phase`),[o,s]=(0,M.useState)(null),[c,l]=(0,M.useState)(null),[f,m]=(0,M.useState)(0),h=Math.min(f,Math.max(0,n.length-1)),g=r?n[h]:void 0,_=(0,M.useMemo)(()=>n.flatMap(e=>(e.tasks??[]).map(t=>({...t,phaseId:e.id}))),[n]),v=(0,M.useMemo)(()=>[...new Set(_.map(e=>e.assignee).filter(e=>!!e))],[_]),y=(0,M.useCallback)(t=>e?.send?.(t),[e]),b=(0,M.useCallback)((e,t)=>y({type:`goal.taskStatus`,payload:{taskId:e,status:t}}),[y]),x=(0,M.useCallback)(e=>y({type:`goal.retryTask`,payload:{taskId:e}}),[y]),S=(0,M.useCallback)((e,t)=>y({type:`goal.assignTask`,payload:{taskId:e,agentName:t||void 0}}),[y]),C=(0,M.useCallback)(e=>{j({title:t(`activity:board.newTaskTitle`),placeholder:t(`activity:board.newTaskPlaceholder`),confirmLabel:t(`activity:board.addTask`)}).then(t=>{t&&y({type:`goal.addTask`,payload:{phaseId:e,title:t}})})},[y]),T=(0,M.useCallback)(e=>{o&&y({type:`goal.moveTask`,payload:{taskId:o,toPhaseId:e}}),s(null),l(null)},[o,y]),D=(0,M.useCallback)(e=>{o&&y({type:`goal.taskStatus`,payload:{taskId:o,status:e}}),s(null),l(null)},[o,y]),O={onStatusChange:b,onRetry:x,agents:v,onAssign:S};function k(e){return{draggable:!0,onDragStart:t=>{s(e),t.dataTransfer.effectAllowed=`move`},onDragEnd:()=>{s(null),l(null)}}}function A(e,t){return{onDragOver:t=>{t.preventDefault(),t.dataTransfer.dropEffect=`move`,c!==e&&l(e)},onDragLeave:()=>l(t=>t===e?null:t),onDrop:e=>{e.preventDefault(),t()},"data-hover":c===e||void 0}}return n.length===0?(0,N.jsx)(`div`,{className:`flex h-full min-h-0 min-w-0 items-center justify-center text-muted-foreground`,children:(0,N.jsx)(`p`,{className:`text-sm`,children:t(`activity:board.empty`)})}):(0,N.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border px-4 py-2`,children:[(0,N.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t(`activity:board.summary`,{phases:n.length,tasks:_.length})}),(0,N.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-border p-0.5`,children:[(0,N.jsxs)(`button`,{type:`button`,onClick:()=>a(`phase`),className:w(`inline-flex items-center gap-1 rounded px-2 py-1 text-xs transition-colors`,i===`phase`?`bg-primary/15 text-primary`:`text-muted-foreground hover:text-foreground`),children:[(0,N.jsx)(d,{className:`h-3.5 w-3.5`}),` `,t(`activity:board.phases`)]}),(0,N.jsxs)(`button`,{type:`button`,onClick:()=>a(`status`),className:w(`inline-flex items-center gap-1 rounded px-2 py-1 text-xs transition-colors`,i===`status`?`bg-primary/15 text-primary`:`text-muted-foreground hover:text-foreground`),children:[(0,N.jsx)(p,{className:`h-3.5 w-3.5`}),` `,t(`activity:board.statusTab`)]})]})]}),r&&g?(0,N.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,N.jsx)(`div`,{className:`flex shrink-0 gap-1 overflow-x-auto border-b border-border px-3 py-1.5`,children:n.map((e,t)=>(0,N.jsxs)(`button`,{type:`button`,onClick:()=>m(t),className:w(`shrink-0 rounded-t px-3 py-1.5 text-xs font-medium transition-colors`,t===h?`border-primary/40 bg-primary/10 text-primary`:`text-muted-foreground hover:bg-muted hover:text-foreground`),children:[(0,N.jsx)(`span`,{className:`truncate`,children:e.name}),(0,N.jsxs)(`span`,{className:`ml-1.5 text-[10px] text-muted-foreground`,children:[e.completedTasks,`/`,e.taskCount]})]},e.id))}),(0,N.jsx)(U,{phase:g,allTasks:_,layout:i,dragId:o,hoverKey:c,callbacks:O,draggable:k,dropZone:A,dropToPhase:T,dropToStatus:D,onAddTask:C})]}):(0,N.jsx)(H,{phases:n,allTasks:_,layout:i,dragId:o,hoverKey:c,callbacks:O,draggable:k,dropZone:A,dropToPhase:T,dropToStatus:D,onAddTask:C})]})}function V({phase:e,phaseTasks:t,callbacks:n,draggable:r,dropZone:a,dropToPhase:o,onAddTask:s,dragId:c,hoverKey:l}){let{t:d}=u();return(0,N.jsxs)(`div`,{...a(`phase:${e.id}`,()=>o(e.id)),className:w(`flex min-h-0 w-80 shrink-0 flex-col rounded-lg border bg-muted/30 transition-colors`,l===`phase:${e.id}`?`border-primary/60 bg-primary/5`:`border-border`),children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border px-3 py-2`,children:[(0,N.jsxs)(`div`,{className:`min-w-0`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`span`,{className:`truncate text-sm font-semibold`,children:e.name}),(0,N.jsx)(`span`,{className:w(`rounded px-1.5 py-0.5 text-[10px] font-medium capitalize`,B[e.status]),children:e.status})]}),(0,N.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[e.completedTasks,`/`,e.taskCount,` · `,e.progressPercent,`%`]})]}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>s(e.id),title:d(`activity:board.addTask`),className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,N.jsx)(i,{className:`h-4 w-4`})})]}),(0,N.jsx)(`div`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto overscroll-contain p-2`,children:t.length===0?(0,N.jsx)(`p`,{className:`px-1 py-4 text-center text-[11px] text-muted-foreground`,children:d(`activity:board.dropHere`)}):t.map(e=>(0,N.jsx)(`div`,{...r(e.id),className:w(c===e.id&&`opacity-50`),children:(0,N.jsx)(R,{task:e,...n})},e.id))})]})}function H({phases:e,allTasks:t,layout:n,dragId:r,hoverKey:i,callbacks:a,draggable:o,dropZone:s,dropToPhase:c,dropToStatus:l,onAddTask:u}){return(0,N.jsx)(N.Fragment,{children:n===`phase`?(0,N.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 gap-3 overflow-x-auto p-3`,children:e.map(e=>(0,N.jsx)(V,{phase:e,phaseTasks:t.filter(t=>t.phaseId===e.id),callbacks:a,draggable:o,dropZone:s,dropToPhase:c,onAddTask:u,dragId:r,hoverKey:i},e.id))}):(0,N.jsx)(W,{phases:e,allTasks:t,dragId:r,hoverKey:i,callbacks:a,draggable:o,dropZone:s,dropToStatus:l})})}function U({phase:e,allTasks:t,layout:n,dragId:r,hoverKey:i,callbacks:a,draggable:o,dropZone:s,dropToPhase:c,dropToStatus:l,onAddTask:d}){let f=t.filter(t=>t.phaseId===e.id),{t:p}=u();return n===`phase`?(0,N.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 gap-3 overflow-x-auto p-3`,children:(0,N.jsx)(V,{phase:e,phaseTasks:f,callbacks:a,draggable:o,dropZone:s,dropToPhase:c,onAddTask:d,dragId:r,hoverKey:i})}):(0,N.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-auto overscroll-contain p-3`,children:(0,N.jsxs)(`div`,{className:`grid min-w-[900px] gap-2`,style:{gridTemplateColumns:`9rem repeat(${z.length}, minmax(0, 1fr))`},children:[(0,N.jsx)(`div`,{}),z.map(e=>(0,N.jsx)(`div`,{className:`px-2 pb-1 text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:p(`activity:board.status.${e.key}`)},e.key)),(0,N.jsxs)(G,{children:[(0,N.jsx)(`div`,{className:`flex items-center pr-2`,children:(0,N.jsxs)(`div`,{className:`min-w-0`,children:[(0,N.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.name}),(0,N.jsx)(`span`,{className:w(`mt-0.5 inline-block rounded px-1.5 py-0.5 text-[10px] capitalize`,B[e.status]),children:e.status})]})}),z.map(t=>{let n=f.filter(e=>t.match.includes(e.status)),c=`cell:${e.id}:${t.key}`;return(0,N.jsx)(`div`,{...s(c,()=>l(t.key)),className:w(`min-h-[4rem] space-y-2 rounded-md border p-1.5 transition-colors`,i===c?`border-primary/60 bg-primary/5`:`border-border bg-muted/20`),children:n.map(e=>(0,N.jsx)(`div`,{...o(e.id),className:w(r===e.id&&`opacity-50`),children:(0,N.jsx)(R,{task:e,compact:!0,...a})},e.id))},t.key)})]},e.id)]})})}function W({phases:e,allTasks:t,dragId:n,hoverKey:r,callbacks:i,draggable:a,dropZone:o,dropToStatus:s}){let{t:c}=u();return(0,N.jsxs)(`div`,{className:`grid min-w-[900px] gap-2`,style:{gridTemplateColumns:`9rem repeat(${z.length}, minmax(0, 1fr))`},children:[(0,N.jsx)(`div`,{}),z.map(e=>(0,N.jsx)(`div`,{className:`px-2 pb-1 text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:c(`activity:board.status.${e.key}`)},e.key)),e.map(e=>(0,N.jsxs)(G,{children:[(0,N.jsx)(`div`,{className:`flex items-center pr-2`,children:(0,N.jsxs)(`div`,{className:`min-w-0`,children:[(0,N.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.name}),(0,N.jsx)(`span`,{className:w(`mt-0.5 inline-block rounded px-1.5 py-0.5 text-[10px] capitalize`,B[e.status]),children:e.status})]})}),z.map(c=>{let l=t.filter(t=>t.phaseId===e.id&&c.match.includes(t.status)),u=`cell:${e.id}:${c.key}`;return(0,N.jsx)(`div`,{...o(u,()=>s(c.key)),className:w(`min-h-[4rem] space-y-2 rounded-md border p-1.5 transition-colors`,r===u?`border-primary/60 bg-primary/5`:`border-border bg-muted/20`),children:l.map(e=>(0,N.jsx)(`div`,{...a(e.id),className:w(n===e.id&&`opacity-50`),children:(0,N.jsx)(R,{task:e,compact:!0,...i})},e.id))},c.key)})]},e.id))]})}function G({children:e}){return(0,N.jsx)(N.Fragment,{children:e})}function K({onClose:e}){let{client:n}=ee(),{t:a}=u(),s=E(e=>e.phases),c=E(e=>e.overallPercent),d=E(e=>e.autonomous),f=E(e=>e.title),p=E(e=>e.goal),y=E(e=>e.status),b=E(e=>e.lastError),C=E(e=>e.graphs);(0,M.useEffect)(()=>{n?.send?.({type:`goal.list`}),n?.send?.({type:`goal.state`})},[n]);let j=D(e=>e.worktrees),P=D(e=>e.baseBranch),[F,I]=(0,M.useState)(``),[L,R]=(0,M.useState)(null),[z,B]=(0,M.useState)(!1),[V,H]=(0,M.useState)(!0),[U,W]=(0,M.useState)(!1),[G,K]=(0,M.useState)(!1),[q,ie]=(0,M.useState)(!1),J=T(e=>e.result),Y=T(e=>e.loading),X=(0,M.useRef)(null);(0,M.useEffect)(()=>{if(X.current&&clearTimeout(X.current),!F.trim()){T.getState().clear();return}return X.current=setTimeout(()=>{T.getState().setLoading();let e=T.getState().nextSeq();n?.send?.({type:`goal.assess`,payload:{goal:F,seq:e}})},800),()=>{X.current&&clearTimeout(X.current)}},[F,n]),(0,M.useEffect)(()=>{!F.trim()&&!L&&T.getState().clear()},[F,L]);let Z=s.length>0,ae=L!=null&&!Z;(0,M.useEffect)(()=>{Z&&R(null)},[Z]);let Q=(0,M.useCallback)(()=>{let e=F.trim();if(!e||L!=null)return;let r=t.getState();r.addMessage({role:`user`,content:e}),r.addMessage({role:`assistant`,content:l.t(`activity:goalRun.planningAck`)}),R(e),I(``),n?.send?.({type:`goal.start`,payload:{title:e,autonomous:!0,worktrees:V,multiBoard:U,verifyTasks:G,chimeraReview:q}}),O(`chat`)},[F,L,n,V]),oe=(0,M.useCallback)(()=>{n?.send?.({type:`goal.stop`,payload:{}}),R(null)},[n]),se=(0,M.useCallback)(()=>{n?.send?.({type:`goal.toggleAutonomous`,payload:{}})},[n]),ce=(0,M.useCallback)(()=>{n?.send?.(y===`paused`?{type:`goal.resume`,payload:{}}:{type:`goal.pause`,payload:{}})},[n,y]),le=(0,M.useCallback)(()=>{n?.send?.({type:`goal.stop`,payload:{}})},[n]),ue=(0,M.useCallback)(()=>{n?.send?.({type:`goal.clear`,payload:{}}),E.getState().clear(),R(null),I(``)},[n]),[de,$]=(0,M.useState)(!1),fe=(0,M.useCallback)(()=>{n?.send?.({type:`goal.revert`,payload:{}}),$(!1)},[n]),pe=y===`running`||y===`paused`,me=y===`stopped`||y===`completed`||y===`failed`,he=(0,M.useCallback)(e=>{e&&n?.send?.({type:`goal.load`,payload:{graphId:e}})},[n]);return(0,N.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-background`,children:[(0,N.jsxs)(`header`,{className:`flex shrink-0 flex-col gap-2 border-b bg-card px-4 py-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,N.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,N.jsx)(h,{className:`h-5 w-5 text-muted-foreground`}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h1`,{className:`text-lg font-semibold`,children:Z&&f||`Goal`}),Z&&(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`activity:goalRun.summary`,{count:s.length,pct:c})})]}),Z&&(0,N.jsx)(`span`,{className:w(`rounded border px-2 py-0.5 text-[11px] font-medium capitalize`,y===`failed`?`border-destructive/40 bg-destructive/10 text-destructive`:y===`paused`||y===`stopped`?`border-warning/40 bg-warning/10 text-warning`:y===`completed`?`border-success/40 bg-success/10 text-success`:`border-primary/30 bg-primary/10 text-primary`),title:b??void 0,children:y})]}),(0,N.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2 sm:justify-end`,children:[C.length>0&&(0,N.jsxs)(`select`,{value:Z?C.find(e=>e.title===f)?.id??``:``,onChange:e=>he(e.target.value),title:a(`activity:goalRun.switchBoard`),className:`min-w-0 flex-1 rounded border border-border bg-card px-2 py-1 text-xs text-foreground sm:w-72 sm:flex-none`,children:[(0,N.jsx)(`option`,{value:``,disabled:!0,children:a(`activity:goalRun.boardsCount`,{count:C.length})}),C.map(e=>(0,N.jsxs)(`option`,{value:e.id,children:[e.title,` · `,e.status]},e.id))]}),Z&&(0,N.jsxs)(`button`,{type:`button`,onClick:se,title:a(`activity:goalRun.toggleAutonomousTitle`),className:w(`inline-flex items-center gap-1 rounded border px-2 py-1 text-xs transition-colors`,d?`border-primary/30 bg-primary/10 text-primary`:`border-border text-muted-foreground hover:text-foreground`),children:[(0,N.jsx)(x,{className:`h-3.5 w-3.5`}),` `,a(d?`activity:goalRun.autonomous`:`activity:goalRun.manual`)]}),pe&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`button`,{type:`button`,onClick:ce,title:a(y===`paused`?`activity:goalRun.resumeTitle`:`activity:goalRun.pauseTitle`),className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-xs text-muted-foreground transition-colors hover:text-foreground`,children:[y===`paused`?(0,N.jsx)(S,{className:`h-3.5 w-3.5`}):(0,N.jsx)(v,{className:`h-3.5 w-3.5`}),a(y===`paused`?`activity:goalRun.resume`:`activity:goalRun.pause`)]}),(0,N.jsxs)(`button`,{type:`button`,onClick:le,title:a(`activity:goalRun.stopTitle`),className:`inline-flex items-center gap-1 rounded border border-destructive/40 bg-destructive/10 px-2 py-1 text-xs font-medium text-destructive transition-colors hover:bg-destructive/20`,children:[(0,N.jsx)(r,{className:`h-3.5 w-3.5 fill-current`}),` `,a(`activity:goalRun.stop`)]})]}),Z&&me&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`button`,{type:`button`,onClick:ue,title:a(`activity:goalRun.newTitle`),className:`inline-flex items-center gap-1 rounded border border-primary/30 bg-primary/10 px-2 py-1 text-xs font-medium text-primary transition-colors hover:bg-primary/20`,children:[(0,N.jsx)(i,{className:`h-3.5 w-3.5`}),` `,a(`activity:goalRun.newLabel`)]}),de?(0,N.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border border-warning/40 bg-warning/10 px-1.5 py-0.5 text-xs`,children:[(0,N.jsx)(`span`,{className:`text-warning`,children:a(`activity:goalRun.revertConfirm`)}),(0,N.jsx)(`button`,{type:`button`,onClick:fe,className:`rounded bg-destructive/15 px-1.5 py-0.5 font-medium text-destructive hover:bg-destructive/25`,children:a(`common:action.yes`)}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>$(!1),className:`rounded px-1.5 py-0.5 text-muted-foreground hover:text-foreground`,children:a(`common:action.no`)})]}):(0,N.jsxs)(`button`,{type:`button`,onClick:()=>$(!0),title:a(`activity:goalRun.revertTitle`),className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-xs text-muted-foreground transition-colors hover:text-foreground`,children:[(0,N.jsx)(o,{className:`h-3.5 w-3.5`}),` `,a(`activity:goalRun.revert`)]})]}),(0,N.jsx)(k,{variant:`ghost`,size:`icon`,onClick:e,children:(0,N.jsx)(m,{className:`h-4 w-4`})})]})]}),Z&&p&&(0,N.jsxs)(`div`,{className:`shrink-0 border-b border-border/60 bg-muted/20 px-4 py-2.5`,children:[(0,N.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,N.jsx)(g,{className:`h-3 w-3`}),` `,a(`activity:goalRun.goal`)]}),(0,N.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-foreground/90`,children:p})]}),Z?(0,N.jsx)(`div`,{className:`flex min-h-0 flex-1`,children:(0,N.jsx)(re,{})}):ae?(0,N.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-8`,children:(0,N.jsxs)(`div`,{className:`max-w-lg w-full space-y-5 text-center`,children:[(0,N.jsx)(_,{className:`h-10 w-10 mx-auto animate-spin text-primary/70`}),(0,N.jsxs)(`div`,{className:`space-y-1`,children:[(0,N.jsx)(`h2`,{className:`text-xl font-semibold`,children:a(`activity:goalRun.planning`)}),(0,N.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:a(`activity:goalRun.planningBody`)})]}),(0,N.jsxs)(`div`,{className:`rounded-lg border border-border bg-card px-4 py-3 text-left`,children:[(0,N.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[(0,N.jsx)(g,{className:`h-3 w-3`}),` `,a(`activity:goalRun.goal`)]}),(0,N.jsx)(`p`,{className:`whitespace-pre-wrap text-sm leading-relaxed text-foreground/90`,children:L})]}),(0,N.jsxs)(k,{variant:`outline`,onClick:oe,className:`gap-2`,children:[(0,N.jsx)(r,{className:`h-4 w-4 fill-current`}),` `,a(`common:action.cancel`)]})]})}):(0,N.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-8`,children:(0,N.jsxs)(`div`,{className:`max-w-lg w-full space-y-6`,children:[(0,N.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,N.jsx)(g,{className:`h-10 w-10 mx-auto text-primary/60`}),(0,N.jsx)(`h2`,{className:`text-xl font-semibold`,children:a(`activity:goalRun.startHeading`)}),(0,N.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:a(`activity:goalRun.startBody`)})]}),(0,N.jsx)(`textarea`,{value:F,onChange:e=>I(e.target.value),placeholder:a(`activity:goalRun.startPlaceholder`),rows:5,className:`w-full rounded-lg border border-border bg-card px-4 py-3 text-sm resize-none focus:outline-none focus:ring-2 focus:ring-primary/30 placeholder:text-muted-foreground/70`,onKeyDown:e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),Q())}}),Y&&(0,N.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,N.jsx)(_,{className:`h-3 w-3 animate-spin`}),a(`activity:goalRun.assess.analyzing`)]}),!Y&&J&&!J.parseFailed&&(0,N.jsxs)(`div`,{className:w(`rounded-lg border px-3 py-2 text-xs space-y-1.5`,J.realistic?`border-success/40 bg-success/10`:`border-warning/40 bg-warning/10`),children:[(0,N.jsx)(`div`,{className:`flex items-center gap-1.5 font-medium`,children:J.realistic?(0,N.jsx)(`span`,{className:`text-success`,children:a(`activity:goalRun.assess.realistic`)}):(0,N.jsx)(`span`,{className:`text-warning`,children:a(`activity:goalRun.assess.durationConcern`)})}),J.durationClaimed&&(0,N.jsx)(`p`,{className:`text-muted-foreground`,children:a(`activity:goalRun.assess.durationClaimed`,{duration:J.durationClaimed})}),(0,N.jsx)(`p`,{className:`text-muted-foreground`,children:J.explanation}),J.recommendedDuration&&(0,N.jsx)(`p`,{className:`text-muted-foreground`,children:a(`activity:goalRun.assess.recommendation`,{duration:J.recommendedDuration})}),J.concerns.length>0&&(0,N.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,N.jsx)(`p`,{className:`font-medium text-foreground/80`,children:a(`activity:goalRun.assess.concerns`)}),(0,N.jsx)(`ul`,{className:`list-disc pl-4 space-y-0.5 text-muted-foreground`,children:J.concerns.map((e,t)=>(0,N.jsx)(`li`,{children:e},t))})]})]}),!Y&&J?.parseFailed&&(0,N.jsx)(`div`,{className:`rounded-lg border border-border/40 bg-muted/20 px-3 py-2 text-xs text-muted-foreground`,children:a(`activity:goalRun.assess.analysisFailed`)}),(0,N.jsxs)(`label`,{className:`flex cursor-pointer items-center justify-center gap-2 text-xs text-muted-foreground`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:V,onChange:e=>H(e.target.checked),className:`h-3.5 w-3.5 accent-primary`}),a(`activity:goalRun.isolateLabel`)]}),(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-3 text-xs text-muted-foreground`,children:[(0,N.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:U,onChange:e=>W(e.target.checked),className:`h-3.5 w-3.5 accent-primary`}),a(`activity:goalRun.multiBoardLabel`)]}),(0,N.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:G,onChange:e=>K(e.target.checked),className:`h-3.5 w-3.5 accent-primary`}),a(`activity:goalRun.verifyTasksLabel`)]}),(0,N.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:q,onChange:e=>ie(e.target.checked),className:`h-3.5 w-3.5 accent-primary`}),a(`activity:goalRun.chimeraReviewLabel`)]})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,children:[!Y&&J&&!J.realistic&&!J.parseFailed&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>T.getState().clear(),className:`shrink-0 rounded border border-border px-2 py-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,title:a(`activity:goalRun.assess.overrideTitle`),children:a(`activity:goalRun.assess.override`)}),(0,N.jsxs)(k,{onClick:Q,disabled:!F.trim()||L!=null||Y||!Y&&J!=null&&!J.parseFailed&&!J.realistic,className:`flex-1 gap-2`,title:F.trim()&&!Y&&J&&!J.parseFailed&&!J.realistic?a(`activity:goalRun.assess.disableTitle`):``,children:[(0,N.jsx)(S,{className:`h-4 w-4`}),a(`activity:goalRun.startButton`)]})]}),(0,N.jsxs)(`p`,{className:`text-xs text-muted-foreground text-center`,children:[a(`activity:goalRun.ctrlHint`),` ·`,` `,a(V?`activity:goalRun.isolateOn`:`activity:goalRun.isolateOff`)]})]})}),j.length>0&&(0,N.jsxs)(`div`,{className:`border-t bg-card/50 shrink-0`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-end gap-2 px-4 pt-2 text-xs`,children:[(0,N.jsx)(`button`,{type:`button`,onClick:()=>B(!1),className:w(`rounded px-2 py-0.5 border transition-colors`,z?`border-border text-muted-foreground hover:text-foreground`:`bg-primary/10 border-primary/30 text-primary`),children:a(`activity:goalRun.lanes`)}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>B(!0),className:w(`rounded px-2 py-0.5 border transition-colors`,z?`bg-primary/10 border-primary/30 text-primary`:`border-border text-muted-foreground hover:text-foreground`),children:a(`activity:goalRun.graph`)})]}),(0,N.jsxs)(`div`,{className:`space-y-2 px-4 pb-3`,children:[(0,N.jsx)(ne,{}),z?(0,N.jsx)(A,{worktrees:j,baseBranch:P}):(0,N.jsx)(te,{worktrees:j,baseBranch:P})]})]})]})}export{K as GoalView};
|