@wrongstack/webui 1.0.7 → 1.0.9

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.
Files changed (76) hide show
  1. package/dist/assets/AgentRosterView-CtUX-VHJ.js +12 -0
  2. package/dist/assets/{AnalyticsDashboard-tA_UUQWD.js → AnalyticsDashboard-fPe6DYsh.js} +1 -1
  3. package/dist/assets/{AudienceMemoryPanel-DNopUX7m.js → AudienceMemoryPanel-i53Y5nRR.js} +1 -1
  4. package/dist/assets/{ChangesView-Cij-BSUX.js → ChangesView-CFOQZBoO.js} +1 -1
  5. package/dist/assets/{ChimeraReviewsView-1TlYFUrk.js → ChimeraReviewsView-BQe81cSZ.js} +1 -1
  6. package/dist/assets/{ChronicleDashboard-mZgdM2It.js → ChronicleDashboard-Dc2rEfEh.js} +1 -1
  7. package/dist/assets/{CodeEditor-CXf7lq5W.js → CodeEditor-DhA63AyO.js} +2 -2
  8. package/dist/assets/{CodeMap-CoQQ76zV.js → CodeMap-6sHlGgjj.js} +1 -1
  9. package/dist/assets/{CronJobsPanel-CL4m2QgQ.js → CronJobsPanel-C30TtTM7.js} +1 -1
  10. package/dist/assets/{DeadCodeScanPanel-DxCRT8rV.js → DeadCodeScanPanel-j3n15R1p.js} +1 -1
  11. package/dist/assets/{DebugDashboard-CMbbIq8d.js → DebugDashboard-jJxP9Qek.js} +1 -1
  12. package/dist/assets/{DesignGalleryView-CcX5u8rA.js → DesignGalleryView-tw6AdJGD.js} +1 -1
  13. package/dist/assets/{GoalView-CVjWpHkb.js → GoalView-DsGdbElx.js} +1 -1
  14. package/dist/assets/{KanbanView-DQmHGtH3.js → KanbanView-B8USJasA.js} +1 -1
  15. package/dist/assets/{MailboxDetailView-CfJjqySh.js → MailboxDetailView-jsHPTvQO.js} +1 -1
  16. package/dist/assets/{MemoryDrawer-C72rzAy0.js → MemoryDrawer-BdcWptmP.js} +1 -1
  17. package/dist/assets/{MemoryManager-DOZYeDYO.js → MemoryManager-Cawc6tAj.js} +1 -1
  18. package/dist/assets/{ProcessMonitor-C7h419Eb.js → ProcessMonitor-Bvgcuk_7.js} +1 -1
  19. package/dist/assets/{PromptJournalView-UkyefQGK.js → PromptJournalView-BUgpBI3V.js} +1 -1
  20. package/dist/assets/{ProviderTestView-B74V32hh.js → ProviderTestView-CztiodHF.js} +1 -1
  21. package/dist/assets/{QueuePanel-CW3iERCF.js → QueuePanel-BQQfIbGH.js} +1 -1
  22. package/dist/assets/{RefreshDebugView-CDfO7Uid.js → RefreshDebugView-CCk1X8Hz.js} +1 -1
  23. package/dist/assets/{RepositoryHistoryView-DnJ5jcgB.js → RepositoryHistoryView-BFiEVjF-.js} +1 -1
  24. package/dist/assets/{RequirementIntakeView-CSTVrB4Y.js → RequirementIntakeView-ByVm-u0p.js} +1 -1
  25. package/dist/assets/{SageTabs-DMFqP3JS.js → SageTabs-BnjtZSVk.js} +2 -2
  26. package/dist/assets/{SddFlowGraph-hmWEIf45.js → SddFlowGraph-CZQxxeJv.js} +1 -1
  27. package/dist/assets/SddHub-CimqjJhd.js +2 -0
  28. package/dist/assets/{SessionInspectView-DA0kAM4e.js → SessionInspectView-DnzU3hjG.js} +1 -1
  29. package/dist/assets/{SessionList-17tCMc4D.js → SessionList-DBcHNwcc.js} +1 -1
  30. package/dist/assets/{SessionsDashboard-CvrLsLGL.js → SessionsDashboard-DofL975M.js} +1 -1
  31. package/dist/assets/{SetupScreen-BHcAa0VI.js → SetupScreen-DQAqt8Dn.js} +1 -1
  32. package/dist/assets/{SkillDetailView-BODqDrPU.js → SkillDetailView-BcG2XIwr.js} +2 -2
  33. package/dist/assets/{TechStackView-DjP_PhtH.js → TechStackView-Ce3WNG85.js} +1 -1
  34. package/dist/assets/{TerminalPanel-perOinUJ.js → TerminalPanel-B3SOIzJY.js} +1 -1
  35. package/dist/assets/{activity-DThW4oMo.js → activity-BGw29FDK.js} +1 -1
  36. package/dist/assets/{activity-DZ2z6LSR.js → activity-CbWiifO9.js} +1 -1
  37. package/dist/assets/{activity-oY2h83Fp.js → activity-D8n7MaKo.js} +1 -1
  38. package/dist/assets/{activity-EReqzYpW.js → activity-DYH5K2cA.js} +1 -1
  39. package/dist/assets/{activity-CHP09wRx.js → activity-DdvIZYux.js} +1 -1
  40. package/dist/assets/{activity-DDfoWJrR.js → activity-S9f20P0d.js} +1 -1
  41. package/dist/assets/{activity-BKJV5XjX.js → activity-pDZp_UqI.js} +1 -1
  42. package/dist/assets/{button-CN_h6kNT.js → button-h7DHXgna.js} +1 -1
  43. package/dist/assets/{chat-store-BVz6zQLP.js → chat-store-DpI9nO_z.js} +1 -1
  44. package/dist/assets/{codemap-activity-store-RqE4L9Os.js → codemap-activity-store-5hcdmofR.js} +1 -1
  45. package/dist/assets/config-store-D7yrCV2X.js +22 -0
  46. package/dist/assets/{dialog-DNsBc-EF.js → dialog-CTmNJKRN.js} +1 -1
  47. package/dist/assets/{empty-state-BFPCt03_.js → empty-state-Dl66htl_.js} +1 -1
  48. package/dist/assets/{i18n-BwptPW9U.js → i18n-B_njdXiH.js} +2 -2
  49. package/dist/assets/index-CfREDCPe.js +170 -0
  50. package/dist/assets/{input-BnTFqRjn.js → input-DAvKojvP.js} +1 -1
  51. package/dist/assets/{mailbox-store-CV5--Nmh.js → mailbox-store-5Dizermg.js} +1 -1
  52. package/dist/assets/{markdown-BzOXYqOo.js → markdown-CXRzjX3p.js} +1 -1
  53. package/dist/assets/{monaco-COtIgMfE.js → monaco-CbI7qrVD.js} +1 -1
  54. package/dist/assets/{monaco-theme-ruX2YdTu.js → monaco-theme-Dr3-rSid.js} +1 -1
  55. package/dist/assets/{roster-ws-Cx9Bzoh0.js → roster-ws-CSbZSs3G.js} +1 -1
  56. package/dist/assets/{shared-h0I65HLY.js → shared-BirfDJmq.js} +1 -1
  57. package/dist/assets/{stores-Bt7wAdGA.js → stores-COxKgvNx.js} +1 -1
  58. package/dist/assets/{ui-store-CMdVzHOn.js → ui-store-BROszDxo.js} +1 -1
  59. package/dist/assets/{utils-sO9lidp6.js → utils-DQbrPaAM.js} +1 -1
  60. package/dist/assets/{vector-memory-panel-BtQElVO4.js → vector-memory-panel-fEdfCaDJ.js} +1 -1
  61. package/dist/assets/vendor-BO-lHyIr.js +116 -0
  62. package/dist/assets/{view-navigation-BDsXeQ5i.js → view-navigation-CVnKqjL2.js} +1 -1
  63. package/dist/assets/{vite-preload-Czpn1I53.js → vite-preload-BZ1Pz5am.js} +1 -1
  64. package/dist/components/ChatInput/subagent-model-picker-dialog.d.ts +43 -0
  65. package/dist/components/SettingsPanel/SubagentModelsSection.d.ts +6 -9
  66. package/dist/hooks/ws-handlers/session-execution-handlers.d.ts +10 -0
  67. package/dist/index.html +16 -16
  68. package/dist/index.js +10429 -9956
  69. package/dist/types/runtime.d.ts +25 -0
  70. package/dist/types/server-message.d.ts +2 -2
  71. package/package.json +26 -26
  72. package/dist/assets/AgentRosterView-C2PmzJWn.js +0 -12
  73. package/dist/assets/SddHub-BedY4SV-.js +0 -2
  74. package/dist/assets/config-store-CZdk-vPj.js +0 -22
  75. package/dist/assets/index-BYBlSXtn.js +0 -170
  76. package/dist/assets/vendor-Cvuk-OYN.js +0 -125
@@ -1,3 +1,3 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-core-wiHys0m2.js";import{J as r,La as i,Pt as a,Ut as o,ct as s,kr as c,li as l,ln as u,mt as d,rn as f,yt as p}from"./vendor-Cvuk-OYN.js";import"./i18n-BwptPW9U.js";import{t as m}from"./utils-sO9lidp6.js";import{a as h,i as g,n as _,o as v,r as y,t as b}from"./dialog-DNsBc-EF.js";import{t as x}from"./button-CN_h6kNT.js";import{t as S}from"./input-BnTFqRjn.js";import{I as C,T as w,w as T}from"./index-BYBlSXtn.js";import{g as E,i as D,r as O,y as k}from"./shared-h0I65HLY.js";var A=e(t(),1),j=n();function M(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 N(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e,n={roles:M(t.roles),taskTypes:M(t.taskTypes),modes:M(t.modes)};return n.roles||n.taskTypes||n.modes?n:void 0}function P(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=N(t.audience);if(!n||!a){i++;continue}let o=typeof t.kind==`string`&&D.some(e=>e===t.kind)?t.kind:void 0,s=M(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 F(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 I(e,t){return[...new Set(e.flatMap(e=>e.audience?.[t]??[]).filter(e=>e.length>0))].sort((e,t)=>e.localeCompare(t))}function L(){let{t:e}=i(),t=C(),[n,a]=(0,A.useState)([]),[D,O]=(0,A.useState)(!0),[k,M]=(0,A.useState)(null),[N,L]=(0,A.useState)(``),[z,B]=(0,A.useState)(!1),[ae,V]=(0,A.useState)(!1),[H,U]=(0,A.useState)(null),[W,G]=(0,A.useState)(!1),[K,q]=(0,A.useState)(!1),J=(0,A.useRef)(null),Y=(0,A.useCallback)(()=>{O(!0),M(null),t.listSageMemories({echoToChat:!1})},[t.listSageMemories]);(0,A.useEffect)(()=>{let n=t.client,r=n.on(`memory.sage.list`,e=>{let t=e.payload;t.error?M({tone:`error`,text:t.error}):a(t.memories??[]),O(!1)}),i=n.on(`memory.sage.remember`,e=>{let t=e.payload;if(G(!1),t.error){M({tone:`error`,text:t.error});return}t.memory&&(a(e=>[t.memory,...e.filter(e=>e.id!==t.memory.id)]),B(!1))}),o=n.on(`memory.sage.update`,t=>{let n=t.payload;n.error?M({tone:`error`,text:n.error}):n.memory&&(a(e=>e.map(e=>e.id===n.memory.id?n.memory:e)),n.memory.audience||M({tone:`success`,text:e(`activity:audienceMem.scopeRemoved`)}))}),s=n.on(`memory.sage.delete`,t=>{let n=t.payload,r=J.current;n.success&&r?(a(e=>e.filter(e=>e.id!==r)),M({tone:`success`,text:e(`activity:audienceMem.deleted`)}),U(null),q(!1),J.current=null):n.success?Y():(M({tone:`error`,text:n.message??`Could not delete the memory.`}),q(!1),J.current=null)});return Y(),()=>{r(),i(),o(),s()}},[Y,t.client]);let X=(0,A.useMemo)(()=>n.filter(e=>{let t=e.audience;return!!(t&&(t.roles?.length||t.taskTypes?.length||t.modes?.length))}),[n]),Z=N.trim(),Q=(0,A.useMemo)(()=>X.filter(e=>F(e,Z)),[Z,X]),$=w(Q,16,Z),oe=(0,A.useMemo)(()=>I(X,`roles`),[X]),se=(0,A.useMemo)(()=>I(X,`taskTypes`),[X]),ce=(0,A.useMemo)(()=>I(X,`modes`),[X]),le=e=>{M(null),t.updateSage(e,{audience:void 0},{echoToChat:!1})},ue=()=>{H&&(J.current=H,q(!0),M(null),t.deleteSage(H,`Removed from the audience memory panel.`))},de=async()=>{let t=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(t,null,2)),M({tone:`success`,text:e(`activity:audienceMem.copiedAsJson`,{count:t.length})})}catch(t){M({tone:`error`,text:t instanceof Error?t.message:e(`activity:audienceMem.copyFailed`)})}};return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col bg-card/20`,"aria-labelledby":`audience-memory-title`,children:[(0,j.jsxs)(`div`,{className:`shrink-0 border-b border-border/60 p-3`,children:[(0,j.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,j.jsx)(`div`,{className:`min-w-0`,children:(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.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,j.jsx)(p,{className:`size-3.5`})}),(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`h2`,{id:`audience-memory-title`,className:`truncate text-sm font-semibold`,children:e(`activity:audienceMem.heading`)}),(0,j.jsx)(`p`,{className:`truncate text-[10px] text-muted-foreground`,children:e(`activity:audienceMem.subheading`)})]})]})}),(0,j.jsxs)(x,{variant:`default`,size:`sm`,className:`h-7 shrink-0 gap-1 px-2 text-xs`,onClick:()=>B(!0),children:[(0,j.jsx)(u,{className:`size-3`}),e(`common:action.add`)]})]}),(0,j.jsxs)(`div`,{className:`mt-3 grid grid-cols-4 gap-px overflow-hidden rounded-md border border-border/60 bg-border/60`,children:[(0,j.jsx)(R,{value:X.length,label:e(`activity:audienceMem.statMemories`)}),(0,j.jsx)(R,{value:oe.length,label:e(`activity:audienceMem.statRoles`)}),(0,j.jsx)(R,{value:se.length,label:e(`activity:audienceMem.statTasks`)}),(0,j.jsx)(R,{value:ce.length,label:e(`activity:audienceMem.statModes`)})]}),(0,j.jsxs)(`div`,{className:`mt-3 flex items-center gap-1.5`,children:[(0,j.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,j.jsx)(o,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,j.jsx)(S,{value:N,onChange:e=>L(e.target.value),placeholder:e(`activity:audienceMem.searchTextRoleTaskOrMode`),"aria-label":e(`activity:audienceMem.searchAudienceMemories`),className:`h-8 pl-8 pr-8 text-xs`}),N&&(0,j.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:()=>L(``),"aria-label":e(`activity:audienceMem.clearAudienceMemorySearch`),children:(0,j.jsx)(r,{className:`size-3`})})]}),(0,j.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-8 shrink-0`,onClick:Y,"aria-label":e(`activity:audienceMem.refreshAudienceMemories`),title:e(`activity:audienceMem.refresh`),children:(0,j.jsx)(f,{className:m(`size-3.5`,D&&`animate-spin`)})}),(0,j.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-8 shrink-0`,onClick:()=>V(!0),"aria-label":e(`activity:audienceMem.importAudienceMemories`),title:e(`activity:audienceMem.importJson`),children:(0,j.jsx)(s,{className:`size-3.5`})}),(0,j.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-8 shrink-0`,onClick:()=>void de(),"aria-label":e(`activity:audienceMem.copyAudienceMemoriesAsJson`),title:e(`activity:audienceMem.copyJson`),disabled:X.length===0,children:(0,j.jsx)(l,{className:`size-3.5`})})]})]}),k&&(0,j.jsxs)(`div`,{role:k.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]`,k.tone===`error`?`border-destructive/30 bg-destructive/5 text-destructive`:`border-success/30 bg-success/5 text-success`),children:[(0,j.jsx)(`span`,{children:k.text}),(0,j.jsx)(`button`,{type:`button`,onClick:()=>M(null),className:`shrink-0 rounded-sm opacity-70 hover:opacity-100`,"aria-label":e(`activity:audienceMem.dismissMessage`),children:(0,j.jsx)(r,{className:`size-3`})})]}),(0,j.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[!D&&X.length>0&&(0,j.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between px-3 pb-1.5 pt-3 text-[10px] text-muted-foreground`,children:[(0,j.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,j.jsx)(c,{className:`size-3`}),Z?`${Q.length} of ${X.length}`:`${X.length} scoped`]}),Z&&(0,j.jsx)(`button`,{type:`button`,className:`hover:text-foreground`,onClick:()=>L(``),children:e(`activity:audienceMem.clearFilter`)})]}),(0,j.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3`,children:[D?(0,j.jsx)(te,{}):X.length===0?(0,j.jsx)(ne,{onAdd:()=>B(!0)}):Q.length===0?(0,j.jsxs)(`div`,{className:`flex h-full min-h-32 flex-col items-center justify-center px-4 text-center`,children:[(0,j.jsx)(o,{className:`mb-2 size-5 text-muted-foreground/60`}),(0,j.jsx)(`p`,{className:`text-xs font-medium`,children:e(`activity:audienceMem.noMatching`)}),(0,j.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:e(`activity:audienceMem.noMatchingHint`)}),(0,j.jsx)(x,{variant:`ghost`,size:`sm`,className:`mt-2 h-7 text-xs`,onClick:()=>L(``),children:e(`activity:audienceMemoryPanel.clearSearch`)})]}):(0,j.jsx)(`ul`,{className:`space-y-2`,children:$.pageItems.map(e=>(0,j.jsx)(ee,{memory:e,onFilter:L,onClearScope:()=>le(e.id),onDelete:()=>U(e.id)},e.id))}),(0,j.jsx)(T,{page:$.page,pageSize:$.pageSize,totalItems:$.totalItems,onPageChange:$.setPage,compact:!0,itemLabel:`memories`})]})]})]}),(0,j.jsx)(re,{open:z,busy:W,onOpenChange:e=>{W||B(e)},onCreate:e=>{M(null),G(!0),t.rememberSage({text:e.text,kind:e.kind,audience:{roles:e.roles.length>0?e.roles:void 0,taskTypes:e.taskTypes.length>0?e.taskTypes:void 0,modes:e.modes.length>0?e.modes:void 0}},{echoToChat:!1})}}),(0,j.jsx)(ie,{open:ae,onOpenChange:V,onImport:n=>{try{let{entries:r,skipped:i}=P(n);if(r.length===0)return M({tone:`error`,text:e(`activity:audienceMem.noValidInJson`)}),!1;for(let e of r)t.rememberSage(e,{echoToChat:!1});return M({tone:`success`,text:e(`activity:audienceMem.queuedForImport`,{count:r.length})+(i?e(`activity:audienceMem.skippedSuffix`,{count:i}):`.`)}),V(!1),!0}catch(t){return M({tone:`error`,text:t instanceof Error?t.message:e(`activity:customRoster.invalidJson`)}),!1}}}),(0,j.jsx)(b,{open:!!H,onOpenChange:e=>{!e&&!K&&U(null)},children:(0,j.jsxs)(_,{className:`max-w-md`,children:[(0,j.jsxs)(h,{children:[(0,j.jsx)(v,{children:e(`activity:audienceMem.deleteTitle`)}),(0,j.jsx)(y,{children:e(`activity:audienceMem.deleteBody`)})]}),(0,j.jsx)(`div`,{className:`rounded-md border border-border/70 bg-background/45 p-3 text-xs text-muted-foreground`,children:E(n.find(e=>e.id===H)?.text??``,180)}),(0,j.jsxs)(g,{children:[(0,j.jsx)(x,{variant:`outline`,onClick:()=>U(null),disabled:K,children:`Cancel`}),(0,j.jsxs)(x,{variant:`destructive`,onClick:ue,disabled:K,children:[(0,j.jsx)(d,{className:`size-4`}),K?`Deleting…`:`Delete memory`]})]})]})})]})}function R({value:e,label:t}){return(0,j.jsxs)(`div`,{className:`bg-card/95 px-1.5 py-2 text-center`,children:[(0,j.jsx)(`p`,{className:`text-sm font-semibold tabular-nums`,children:e}),(0,j.jsx)(`p`,{className:`truncate text-[9px] uppercase tracking-wide text-muted-foreground`,children:t})]})}function ee({memory:e,onFilter:t,onClearScope:n,onDelete:r}){let{t:o}=i();return(0,j.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,j.jsx)(`p`,{className:`break-words text-xs leading-5`,children:e.text}),e.audience&&(0,j.jsx)(z,{audience:e.audience,onFilter:t}),(0,j.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2 border-t border-border/45 pt-2`,children:[(0,j.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-[9px] uppercase tracking-wide text-muted-foreground`,children:[(0,j.jsx)(`span`,{className:`truncate`,children:O[e.kind]??e.kind}),(0,j.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,j.jsx)(`span`,{children:e.status})]}),(0,j.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[(0,j.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-6`,onClick:n,"aria-label":`Remove audience scope from ${E(e.text,42)}`,title:o(`activity:audienceMem.makeGeneralMemory`),children:(0,j.jsx)(a,{className:`size-3`})}),(0,j.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-6 text-destructive hover:text-destructive`,onClick:r,"aria-label":`Delete ${E(e.text,42)}`,title:o(`activity:audienceMem.delete`),children:(0,j.jsx)(d,{className:`size-3`})})]})]})]})}function z({audience:e,onFilter:t}){let n=[...(e.roles??[]).map(e=>({label:`role`,value:e})),...(e.taskTypes??[]).map(e=>({label:`task`,value:e})),...(e.modes??[]).map(e=>({label:`mode`,value:e}))];return(0,j.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:n.map(({label:e,value:n})=>(0,j.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 te(){let{t:e}=i();return(0,j.jsx)(`div`,{className:`space-y-2 pt-3`,role:`status`,"aria-label":e(`activity:audienceMem.loadingAudienceMemories`),children:[0,1,2].map(e=>(0,j.jsxs)(`div`,{className:`animate-pulse rounded-md border border-border/50 p-3`,children:[(0,j.jsx)(`div`,{className:`h-2.5 w-full rounded bg-muted`}),(0,j.jsx)(`div`,{className:`mt-2 h-2.5 w-2/3 rounded bg-muted`}),(0,j.jsx)(`div`,{className:`mt-3 h-4 w-24 rounded bg-muted`})]},e))})}function ne({onAdd:e}){let{t}=i();return(0,j.jsxs)(`div`,{className:`flex h-full min-h-44 flex-col items-center justify-center px-5 text-center`,children:[(0,j.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,j.jsx)(p,{className:`size-4`})}),(0,j.jsx)(`p`,{className:`text-xs font-medium`,children:t(`activity:audienceMem.emptyTitle`)}),(0,j.jsx)(`p`,{className:`mt-1 max-w-52 text-[10px] leading-4 text-muted-foreground`,children:t(`activity:audienceMem.emptyBody`)}),(0,j.jsxs)(x,{variant:`outline`,size:`sm`,className:`mt-3 h-7 gap-1 text-xs`,onClick:e,children:[(0,j.jsx)(u,{className:`size-3`}),t(`activity:audienceMem.addScoped`)]})]})}function re({open:e,busy:t,onOpenChange:n,onCreate:r}){let{t:a}=i(),[o,s]=(0,A.useState)(``),[c,l]=(0,A.useState)(`workflow`),[u,d]=(0,A.useState)(``),[f,p]=(0,A.useState)(``),[m,S]=(0,A.useState)(``);(0,A.useEffect)(()=>{e||(s(``),l(`workflow`),d(``),p(``),S(``))},[e]);let C=k(u),w=k(f),T=k(m),E=o.trim().length>0&&(C.length>0||w.length>0||T.length>0);return(0,j.jsx)(b,{open:e,onOpenChange:n,children:(0,j.jsxs)(_,{className:`max-w-xl`,children:[(0,j.jsxs)(h,{children:[(0,j.jsx)(v,{children:a(`activity:audienceMem.createTitle`)}),(0,j.jsx)(y,{children:a(`activity:audienceMem.createBody`)})]}),(0,j.jsxs)(`div`,{className:`space-y-4`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{htmlFor:`audience-memory-text`,className:`mb-1.5 block text-xs font-medium`,children:a(`activity:audienceMem.fieldMemory`)}),(0,j.jsx)(`textarea`,{id:`audience-memory-text`,value:o,onChange:e=>s(e.target.value),placeholder:a(`activity:audienceMem.whatShouldMatchingAgentsRemember`),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,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{htmlFor:`audience-memory-kind`,className:`mb-1.5 block text-xs font-medium`,children:a(`activity:audienceMem.fieldKind`)}),(0,j.jsx)(`select`,{id:`audience-memory-kind`,value:c,onChange:e=>l(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:D.map(e=>(0,j.jsx)(`option`,{value:e,children:O[e]??e},e))})]}),(0,j.jsxs)(`fieldset`,{className:`space-y-3 rounded-md border border-border/70 bg-background/35 p-3`,children:[(0,j.jsx)(`legend`,{className:`px-1 text-xs font-medium`,children:a(`activity:audienceMem.selectors`)}),(0,j.jsx)(B,{id:`audience-memory-roles`,label:a(`activity:audienceMem.statRoles`),value:u,onChange:d,placeholder:a(`activity:audienceMem.reviewerRefactorPlanner`)}),(0,j.jsx)(B,{id:`audience-memory-task-types`,label:a(`activity:audienceMem.fieldTaskTypes`),value:f,onChange:p,placeholder:a(`activity:audienceMem.reviewRefactorBugfix`)}),(0,j.jsx)(B,{id:`audience-memory-modes`,label:a(`activity:audienceMem.statModes`),value:m,onChange:S,placeholder:a(`activity:audienceMem.teachCodeReview`)}),(0,j.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:a(`activity:audienceMem.selectorsHint`)})]})]}),(0,j.jsxs)(g,{children:[(0,j.jsx)(x,{variant:`outline`,onClick:()=>n(!1),disabled:t,children:a(`common:action.cancel`)}),(0,j.jsx)(x,{onClick:()=>r({text:o.trim(),kind:c,roles:C,taskTypes:w,modes:T}),disabled:!E||t,children:t?`Remembering…`:`Remember`})]})]})})}function B({id:e,label:t,value:n,placeholder:r,onChange:i}){return(0,j.jsxs)(`div`,{className:`grid gap-1.5 sm:grid-cols-[6rem_1fr] sm:items-center`,children:[(0,j.jsx)(`label`,{htmlFor:e,className:`text-[11px] font-medium text-muted-foreground`,children:t}),(0,j.jsx)(S,{id:e,value:n,onChange:e=>i(e.target.value),placeholder:r,className:`h-8 font-mono text-xs`})]})}function ie({open:e,onOpenChange:t,onImport:n}){let{t:r}=i(),[a,o]=(0,A.useState)(``);return(0,A.useEffect)(()=>{e||o(``)},[e]),(0,j.jsx)(b,{open:e,onOpenChange:t,children:(0,j.jsxs)(_,{className:`max-w-xl`,children:[(0,j.jsxs)(h,{children:[(0,j.jsx)(v,{children:r(`activity:audienceMem.importTitle`)}),(0,j.jsxs)(y,{children:[r(`activity:audienceMem.importBodyBefore`),` `,(0,j.jsx)(`code`,{children:r(`activity:audienceMemoryPanel.memoryAudienceExport`)}),`.`,` `,r(`activity:audienceMem.importBodyAfter`)]})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{htmlFor:`audience-memory-import`,className:`mb-1.5 block text-xs font-medium`,children:r(`activity:audienceMem.jsonArray`)}),(0,j.jsx)(`textarea`,{id:`audience-memory-import`,value:a,onChange:e=>o(e.target.value),placeholder:`[
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-core-wiHys0m2.js";import{J as r,La as i,Pt as a,Ut as o,ct as s,kr as c,li as l,ln as u,mt as d,rn as f,yt as p}from"./vendor-BO-lHyIr.js";import"./i18n-B_njdXiH.js";import{t as m}from"./utils-DQbrPaAM.js";import{a as h,i as g,n as _,o as v,r as y,t as b}from"./dialog-CTmNJKRN.js";import{t as x}from"./button-h7DHXgna.js";import{t as S}from"./input-DAvKojvP.js";import{I as C,T as w,w as T}from"./index-CfREDCPe.js";import{g as E,i as D,r as O,y as k}from"./shared-BirfDJmq.js";var A=e(t(),1),j=n();function M(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 N(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e,n={roles:M(t.roles),taskTypes:M(t.taskTypes),modes:M(t.modes)};return n.roles||n.taskTypes||n.modes?n:void 0}function P(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=N(t.audience);if(!n||!a){i++;continue}let o=typeof t.kind==`string`&&D.some(e=>e===t.kind)?t.kind:void 0,s=M(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 F(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 I(e,t){return[...new Set(e.flatMap(e=>e.audience?.[t]??[]).filter(e=>e.length>0))].sort((e,t)=>e.localeCompare(t))}function L(){let{t:e}=i(),t=C(),[n,a]=(0,A.useState)([]),[D,O]=(0,A.useState)(!0),[k,M]=(0,A.useState)(null),[N,L]=(0,A.useState)(``),[z,B]=(0,A.useState)(!1),[ae,V]=(0,A.useState)(!1),[H,U]=(0,A.useState)(null),[W,G]=(0,A.useState)(!1),[K,q]=(0,A.useState)(!1),J=(0,A.useRef)(null),Y=(0,A.useCallback)(()=>{O(!0),M(null),t.listSageMemories({echoToChat:!1})},[t.listSageMemories]);(0,A.useEffect)(()=>{let n=t.client,r=n.on(`memory.sage.list`,e=>{let t=e.payload;t.error?M({tone:`error`,text:t.error}):a(t.memories??[]),O(!1)}),i=n.on(`memory.sage.remember`,e=>{let t=e.payload;if(G(!1),t.error){M({tone:`error`,text:t.error});return}t.memory&&(a(e=>[t.memory,...e.filter(e=>e.id!==t.memory.id)]),B(!1))}),o=n.on(`memory.sage.update`,t=>{let n=t.payload;n.error?M({tone:`error`,text:n.error}):n.memory&&(a(e=>e.map(e=>e.id===n.memory.id?n.memory:e)),n.memory.audience||M({tone:`success`,text:e(`activity:audienceMem.scopeRemoved`)}))}),s=n.on(`memory.sage.delete`,t=>{let n=t.payload,r=J.current;n.success&&r?(a(e=>e.filter(e=>e.id!==r)),M({tone:`success`,text:e(`activity:audienceMem.deleted`)}),U(null),q(!1),J.current=null):n.success?Y():(M({tone:`error`,text:n.message??`Could not delete the memory.`}),q(!1),J.current=null)});return Y(),()=>{r(),i(),o(),s()}},[Y,t.client]);let X=(0,A.useMemo)(()=>n.filter(e=>{let t=e.audience;return!!(t&&(t.roles?.length||t.taskTypes?.length||t.modes?.length))}),[n]),Z=N.trim(),Q=(0,A.useMemo)(()=>X.filter(e=>F(e,Z)),[Z,X]),$=w(Q,16,Z),oe=(0,A.useMemo)(()=>I(X,`roles`),[X]),se=(0,A.useMemo)(()=>I(X,`taskTypes`),[X]),ce=(0,A.useMemo)(()=>I(X,`modes`),[X]),le=e=>{M(null),t.updateSage(e,{audience:void 0},{echoToChat:!1})},ue=()=>{H&&(J.current=H,q(!0),M(null),t.deleteSage(H,`Removed from the audience memory panel.`))},de=async()=>{let t=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(t,null,2)),M({tone:`success`,text:e(`activity:audienceMem.copiedAsJson`,{count:t.length})})}catch(t){M({tone:`error`,text:t instanceof Error?t.message:e(`activity:audienceMem.copyFailed`)})}};return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col bg-card/20`,"aria-labelledby":`audience-memory-title`,children:[(0,j.jsxs)(`div`,{className:`shrink-0 border-b border-border/60 p-3`,children:[(0,j.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,j.jsx)(`div`,{className:`min-w-0`,children:(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.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,j.jsx)(p,{className:`size-3.5`})}),(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`h2`,{id:`audience-memory-title`,className:`truncate text-sm font-semibold`,children:e(`activity:audienceMem.heading`)}),(0,j.jsx)(`p`,{className:`truncate text-[10px] text-muted-foreground`,children:e(`activity:audienceMem.subheading`)})]})]})}),(0,j.jsxs)(x,{variant:`default`,size:`sm`,className:`h-7 shrink-0 gap-1 px-2 text-xs`,onClick:()=>B(!0),children:[(0,j.jsx)(u,{className:`size-3`}),e(`common:action.add`)]})]}),(0,j.jsxs)(`div`,{className:`mt-3 grid grid-cols-4 gap-px overflow-hidden rounded-md border border-border/60 bg-border/60`,children:[(0,j.jsx)(R,{value:X.length,label:e(`activity:audienceMem.statMemories`)}),(0,j.jsx)(R,{value:oe.length,label:e(`activity:audienceMem.statRoles`)}),(0,j.jsx)(R,{value:se.length,label:e(`activity:audienceMem.statTasks`)}),(0,j.jsx)(R,{value:ce.length,label:e(`activity:audienceMem.statModes`)})]}),(0,j.jsxs)(`div`,{className:`mt-3 flex items-center gap-1.5`,children:[(0,j.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,j.jsx)(o,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,j.jsx)(S,{value:N,onChange:e=>L(e.target.value),placeholder:e(`activity:audienceMem.searchTextRoleTaskOrMode`),"aria-label":e(`activity:audienceMem.searchAudienceMemories`),className:`h-8 pl-8 pr-8 text-xs`}),N&&(0,j.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:()=>L(``),"aria-label":e(`activity:audienceMem.clearAudienceMemorySearch`),children:(0,j.jsx)(r,{className:`size-3`})})]}),(0,j.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-8 shrink-0`,onClick:Y,"aria-label":e(`activity:audienceMem.refreshAudienceMemories`),title:e(`activity:audienceMem.refresh`),children:(0,j.jsx)(f,{className:m(`size-3.5`,D&&`animate-spin`)})}),(0,j.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-8 shrink-0`,onClick:()=>V(!0),"aria-label":e(`activity:audienceMem.importAudienceMemories`),title:e(`activity:audienceMem.importJson`),children:(0,j.jsx)(s,{className:`size-3.5`})}),(0,j.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-8 shrink-0`,onClick:()=>void de(),"aria-label":e(`activity:audienceMem.copyAudienceMemoriesAsJson`),title:e(`activity:audienceMem.copyJson`),disabled:X.length===0,children:(0,j.jsx)(l,{className:`size-3.5`})})]})]}),k&&(0,j.jsxs)(`div`,{role:k.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]`,k.tone===`error`?`border-destructive/30 bg-destructive/5 text-destructive`:`border-success/30 bg-success/5 text-success`),children:[(0,j.jsx)(`span`,{children:k.text}),(0,j.jsx)(`button`,{type:`button`,onClick:()=>M(null),className:`shrink-0 rounded-sm opacity-70 hover:opacity-100`,"aria-label":e(`activity:audienceMem.dismissMessage`),children:(0,j.jsx)(r,{className:`size-3`})})]}),(0,j.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[!D&&X.length>0&&(0,j.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between px-3 pb-1.5 pt-3 text-[10px] text-muted-foreground`,children:[(0,j.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,j.jsx)(c,{className:`size-3`}),Z?`${Q.length} of ${X.length}`:`${X.length} scoped`]}),Z&&(0,j.jsx)(`button`,{type:`button`,className:`hover:text-foreground`,onClick:()=>L(``),children:e(`activity:audienceMem.clearFilter`)})]}),(0,j.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3`,children:[D?(0,j.jsx)(te,{}):X.length===0?(0,j.jsx)(ne,{onAdd:()=>B(!0)}):Q.length===0?(0,j.jsxs)(`div`,{className:`flex h-full min-h-32 flex-col items-center justify-center px-4 text-center`,children:[(0,j.jsx)(o,{className:`mb-2 size-5 text-muted-foreground/60`}),(0,j.jsx)(`p`,{className:`text-xs font-medium`,children:e(`activity:audienceMem.noMatching`)}),(0,j.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:e(`activity:audienceMem.noMatchingHint`)}),(0,j.jsx)(x,{variant:`ghost`,size:`sm`,className:`mt-2 h-7 text-xs`,onClick:()=>L(``),children:e(`activity:audienceMemoryPanel.clearSearch`)})]}):(0,j.jsx)(`ul`,{className:`space-y-2`,children:$.pageItems.map(e=>(0,j.jsx)(ee,{memory:e,onFilter:L,onClearScope:()=>le(e.id),onDelete:()=>U(e.id)},e.id))}),(0,j.jsx)(T,{page:$.page,pageSize:$.pageSize,totalItems:$.totalItems,onPageChange:$.setPage,compact:!0,itemLabel:`memories`})]})]})]}),(0,j.jsx)(re,{open:z,busy:W,onOpenChange:e=>{W||B(e)},onCreate:e=>{M(null),G(!0),t.rememberSage({text:e.text,kind:e.kind,audience:{roles:e.roles.length>0?e.roles:void 0,taskTypes:e.taskTypes.length>0?e.taskTypes:void 0,modes:e.modes.length>0?e.modes:void 0}},{echoToChat:!1})}}),(0,j.jsx)(ie,{open:ae,onOpenChange:V,onImport:n=>{try{let{entries:r,skipped:i}=P(n);if(r.length===0)return M({tone:`error`,text:e(`activity:audienceMem.noValidInJson`)}),!1;for(let e of r)t.rememberSage(e,{echoToChat:!1});return M({tone:`success`,text:e(`activity:audienceMem.queuedForImport`,{count:r.length})+(i?e(`activity:audienceMem.skippedSuffix`,{count:i}):`.`)}),V(!1),!0}catch(t){return M({tone:`error`,text:t instanceof Error?t.message:e(`activity:customRoster.invalidJson`)}),!1}}}),(0,j.jsx)(b,{open:!!H,onOpenChange:e=>{!e&&!K&&U(null)},children:(0,j.jsxs)(_,{className:`max-w-md`,children:[(0,j.jsxs)(h,{children:[(0,j.jsx)(v,{children:e(`activity:audienceMem.deleteTitle`)}),(0,j.jsx)(y,{children:e(`activity:audienceMem.deleteBody`)})]}),(0,j.jsx)(`div`,{className:`rounded-md border border-border/70 bg-background/45 p-3 text-xs text-muted-foreground`,children:E(n.find(e=>e.id===H)?.text??``,180)}),(0,j.jsxs)(g,{children:[(0,j.jsx)(x,{variant:`outline`,onClick:()=>U(null),disabled:K,children:`Cancel`}),(0,j.jsxs)(x,{variant:`destructive`,onClick:ue,disabled:K,children:[(0,j.jsx)(d,{className:`size-4`}),K?`Deleting…`:`Delete memory`]})]})]})})]})}function R({value:e,label:t}){return(0,j.jsxs)(`div`,{className:`bg-card/95 px-1.5 py-2 text-center`,children:[(0,j.jsx)(`p`,{className:`text-sm font-semibold tabular-nums`,children:e}),(0,j.jsx)(`p`,{className:`truncate text-[9px] uppercase tracking-wide text-muted-foreground`,children:t})]})}function ee({memory:e,onFilter:t,onClearScope:n,onDelete:r}){let{t:o}=i();return(0,j.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,j.jsx)(`p`,{className:`break-words text-xs leading-5`,children:e.text}),e.audience&&(0,j.jsx)(z,{audience:e.audience,onFilter:t}),(0,j.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2 border-t border-border/45 pt-2`,children:[(0,j.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-[9px] uppercase tracking-wide text-muted-foreground`,children:[(0,j.jsx)(`span`,{className:`truncate`,children:O[e.kind]??e.kind}),(0,j.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,j.jsx)(`span`,{children:e.status})]}),(0,j.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[(0,j.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-6`,onClick:n,"aria-label":`Remove audience scope from ${E(e.text,42)}`,title:o(`activity:audienceMem.makeGeneralMemory`),children:(0,j.jsx)(a,{className:`size-3`})}),(0,j.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-6 text-destructive hover:text-destructive`,onClick:r,"aria-label":`Delete ${E(e.text,42)}`,title:o(`activity:audienceMem.delete`),children:(0,j.jsx)(d,{className:`size-3`})})]})]})]})}function z({audience:e,onFilter:t}){let n=[...(e.roles??[]).map(e=>({label:`role`,value:e})),...(e.taskTypes??[]).map(e=>({label:`task`,value:e})),...(e.modes??[]).map(e=>({label:`mode`,value:e}))];return(0,j.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:n.map(({label:e,value:n})=>(0,j.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 te(){let{t:e}=i();return(0,j.jsx)(`div`,{className:`space-y-2 pt-3`,role:`status`,"aria-label":e(`activity:audienceMem.loadingAudienceMemories`),children:[0,1,2].map(e=>(0,j.jsxs)(`div`,{className:`animate-pulse rounded-md border border-border/50 p-3`,children:[(0,j.jsx)(`div`,{className:`h-2.5 w-full rounded bg-muted`}),(0,j.jsx)(`div`,{className:`mt-2 h-2.5 w-2/3 rounded bg-muted`}),(0,j.jsx)(`div`,{className:`mt-3 h-4 w-24 rounded bg-muted`})]},e))})}function ne({onAdd:e}){let{t}=i();return(0,j.jsxs)(`div`,{className:`flex h-full min-h-44 flex-col items-center justify-center px-5 text-center`,children:[(0,j.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,j.jsx)(p,{className:`size-4`})}),(0,j.jsx)(`p`,{className:`text-xs font-medium`,children:t(`activity:audienceMem.emptyTitle`)}),(0,j.jsx)(`p`,{className:`mt-1 max-w-52 text-[10px] leading-4 text-muted-foreground`,children:t(`activity:audienceMem.emptyBody`)}),(0,j.jsxs)(x,{variant:`outline`,size:`sm`,className:`mt-3 h-7 gap-1 text-xs`,onClick:e,children:[(0,j.jsx)(u,{className:`size-3`}),t(`activity:audienceMem.addScoped`)]})]})}function re({open:e,busy:t,onOpenChange:n,onCreate:r}){let{t:a}=i(),[o,s]=(0,A.useState)(``),[c,l]=(0,A.useState)(`workflow`),[u,d]=(0,A.useState)(``),[f,p]=(0,A.useState)(``),[m,S]=(0,A.useState)(``);(0,A.useEffect)(()=>{e||(s(``),l(`workflow`),d(``),p(``),S(``))},[e]);let C=k(u),w=k(f),T=k(m),E=o.trim().length>0&&(C.length>0||w.length>0||T.length>0);return(0,j.jsx)(b,{open:e,onOpenChange:n,children:(0,j.jsxs)(_,{className:`max-w-xl`,children:[(0,j.jsxs)(h,{children:[(0,j.jsx)(v,{children:a(`activity:audienceMem.createTitle`)}),(0,j.jsx)(y,{children:a(`activity:audienceMem.createBody`)})]}),(0,j.jsxs)(`div`,{className:`space-y-4`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{htmlFor:`audience-memory-text`,className:`mb-1.5 block text-xs font-medium`,children:a(`activity:audienceMem.fieldMemory`)}),(0,j.jsx)(`textarea`,{id:`audience-memory-text`,value:o,onChange:e=>s(e.target.value),placeholder:a(`activity:audienceMem.whatShouldMatchingAgentsRemember`),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,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{htmlFor:`audience-memory-kind`,className:`mb-1.5 block text-xs font-medium`,children:a(`activity:audienceMem.fieldKind`)}),(0,j.jsx)(`select`,{id:`audience-memory-kind`,value:c,onChange:e=>l(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:D.map(e=>(0,j.jsx)(`option`,{value:e,children:O[e]??e},e))})]}),(0,j.jsxs)(`fieldset`,{className:`space-y-3 rounded-md border border-border/70 bg-background/35 p-3`,children:[(0,j.jsx)(`legend`,{className:`px-1 text-xs font-medium`,children:a(`activity:audienceMem.selectors`)}),(0,j.jsx)(B,{id:`audience-memory-roles`,label:a(`activity:audienceMem.statRoles`),value:u,onChange:d,placeholder:a(`activity:audienceMem.reviewerRefactorPlanner`)}),(0,j.jsx)(B,{id:`audience-memory-task-types`,label:a(`activity:audienceMem.fieldTaskTypes`),value:f,onChange:p,placeholder:a(`activity:audienceMem.reviewRefactorBugfix`)}),(0,j.jsx)(B,{id:`audience-memory-modes`,label:a(`activity:audienceMem.statModes`),value:m,onChange:S,placeholder:a(`activity:audienceMem.teachCodeReview`)}),(0,j.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:a(`activity:audienceMem.selectorsHint`)})]})]}),(0,j.jsxs)(g,{children:[(0,j.jsx)(x,{variant:`outline`,onClick:()=>n(!1),disabled:t,children:a(`common:action.cancel`)}),(0,j.jsx)(x,{onClick:()=>r({text:o.trim(),kind:c,roles:C,taskTypes:w,modes:T}),disabled:!E||t,children:t?`Remembering…`:`Remember`})]})]})})}function B({id:e,label:t,value:n,placeholder:r,onChange:i}){return(0,j.jsxs)(`div`,{className:`grid gap-1.5 sm:grid-cols-[6rem_1fr] sm:items-center`,children:[(0,j.jsx)(`label`,{htmlFor:e,className:`text-[11px] font-medium text-muted-foreground`,children:t}),(0,j.jsx)(S,{id:e,value:n,onChange:e=>i(e.target.value),placeholder:r,className:`h-8 font-mono text-xs`})]})}function ie({open:e,onOpenChange:t,onImport:n}){let{t:r}=i(),[a,o]=(0,A.useState)(``);return(0,A.useEffect)(()=>{e||o(``)},[e]),(0,j.jsx)(b,{open:e,onOpenChange:t,children:(0,j.jsxs)(_,{className:`max-w-xl`,children:[(0,j.jsxs)(h,{children:[(0,j.jsx)(v,{children:r(`activity:audienceMem.importTitle`)}),(0,j.jsxs)(y,{children:[r(`activity:audienceMem.importBodyBefore`),` `,(0,j.jsx)(`code`,{children:r(`activity:audienceMemoryPanel.memoryAudienceExport`)}),`.`,` `,r(`activity:audienceMem.importBodyAfter`)]})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{htmlFor:`audience-memory-import`,className:`mb-1.5 block text-xs font-medium`,children:r(`activity:audienceMem.jsonArray`)}),(0,j.jsx)(`textarea`,{id:`audience-memory-import`,value:a,onChange:e=>o(e.target.value),placeholder:`[
2
2
  { "text": "…", "audience": { "roles": ["reviewer"] } }
3
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,j.jsxs)(g,{children:[(0,j.jsx)(x,{variant:`outline`,onClick:()=>t(!1),children:r(`common:action.cancel`)}),(0,j.jsxs)(x,{onClick:()=>n(a),disabled:!a.trim(),children:[(0,j.jsx)(s,{className:`size-4`}),r(`activity:audienceMem.importAction`)]})]})]})})}export{L as AudienceMemoryPanel};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{K as t,nt as n,t as r}from"./config-store-CZdk-vPj.js";import{i,t as a}from"./react-core-wiHys0m2.js";import{Jn as o,Jt as s,La as c,Xi as l,Yr as u,Yt as d,jn as f,ln as p,lt as m,rn as h,xi as g}from"./vendor-Cvuk-OYN.js";import"./i18n-BwptPW9U.js";import{t as _}from"./utils-sO9lidp6.js";import"./stores-Bt7wAdGA.js";import{I as v,P as y}from"./index-BYBlSXtn.js";import{i as b,r as x,s as S,t as C}from"./monaco-COtIgMfE.js";import{t as w}from"./empty-state-BFPCt03_.js";import{t as T}from"./monaco-theme-ruX2YdTu.js";var E=e(i(),1),D=a();b.config({monaco:C});var O={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 k(e){return O[e.split(`.`).pop()?.toLowerCase()??``]??`plaintext`}function A({path:e,oldText:n,newText:i}){let{t:a}=c(),u=(0,E.useRef)(null),[d,f]=(0,E.useState)(!1),[p,m]=(0,E.useState)(!1),[h,g]=(0,E.useState)(null);(0,E.useEffect)(()=>{f(!1),m(!1),g(null)},[]);let _=(0,E.useCallback)(e=>{u.current=e,S.setTheme(T()),e.getModifiedEditor().onDidChangeModelContent(()=>f(!0))},[]),v=(0,E.useCallback)(()=>{let n=u.current?.getModifiedEditor().getValue();if(n==null)return;m(!0);let i=t(r.getState().wsUrl),a=i.on(`files.written`,t=>{t.type===`files.written`&&t.payload.filePath===e&&(a(),clearTimeout(o),m(!1),t.payload.success&&(f(!1),g(Date.now())))}),o=setTimeout(()=>{a(),m(!1)},5e3);i.send({type:`files.write`,payload:i.withSession({filePath:e,content:n})})},[e]),y=k(e);return(0,D.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,D.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,D.jsx)(`span`,{className:`text-xs font-mono text-muted-foreground truncate`,children:e}),(0,D.jsxs)(`button`,{type:`button`,onClick:v,disabled:!d||p,className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-md border border-border text-xs font-medium disabled:opacity-40 enabled:hover:bg-muted transition-colors`,title:a(`activity:monacoDiff.applyTitle`),children:[p?(0,D.jsx)(o,{className:`h-3.5 w-3.5 animate-spin`}):h&&!d?(0,D.jsx)(l,{className:`h-3.5 w-3.5 text-success`}):(0,D.jsx)(s,{className:`h-3.5 w-3.5`}),a(p?`activity:monacoDiff.applying`:h&&!d?`activity:monacoDiff.applied`:`activity:monacoDiff.apply`)]})]}),(0,D.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-hidden`,children:(0,D.jsx)(x,{original:n,modified:i,language:y,theme:T(),onMount:_,options:{renderSideBySide:!0,readOnly:!1,originalEditable:!1,minimap:{enabled:!1},fontSize:13,scrollBeyondLastLine:!1,automaticLayout:!0}})})]})}var j=1e4;function M({className:e}){let{t:i}=c(),{stageGit:a,unstageGit:s,discardGit:l}=v(),b=n(e=>e.selectedPath),x=n(e=>e.files),S=n(e=>e.diff),C=n(e=>e.loadingDiff),T=x.find(e=>e.path===b),[O,k]=(0,E.useState)(`unified`),[M,N]=(0,E.useState)(!1),P=!!b&&(C||!S);(0,E.useEffect)(()=>{if(N(!1),!P)return;let e=setTimeout(()=>N(!0),j);return()=>clearTimeout(e)},[P,b]);let F=()=>{b&&(N(!1),n.getState().setDiffLoading(!0),t(r.getState().wsUrl).getGitDiff?.(b))};if(!b)return(0,D.jsx)(w,{icon:(0,D.jsx)(u,{className:`h-6 w-6`}),title:i(`activity:changesView.sourceChanges`),description:i(`activity:changes.selectPrompt`),className:e});let I=S&&!S.error&&!S.binary&&!S.tooLarge;return(0,D.jsx)(`div`,{className:_(`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,D.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,D.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,D.jsxs)(`div`,{className:`min-w-0 flex items-center gap-2`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`text-[10px] font-semibold uppercase text-muted-foreground`,children:i(`activity:changesView.sourceControl`)}),(0,D.jsx)(`div`,{className:`truncate font-mono text-xs text-foreground`,title:b,children:b})]}),T?.staged&&(0,D.jsx)(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary uppercase`,children:`Staged`})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`div`,{className:`flex items-center gap-1 border-r border-border/70 pr-2`,children:T?.staged?(0,D.jsxs)(`button`,{type:`button`,onClick:()=>s?.(b),title:`Unstage this file`,className:`inline-flex h-8 items-center gap-1 rounded-md border border-border px-2 text-xs text-muted-foreground hover:bg-muted hover:text-foreground transition-colors`,children:[(0,D.jsx)(f,{className:`h-3.5 w-3.5`}),` Unstage`]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`button`,{type:`button`,onClick:()=>a?.(b),title:`Stage this file`,className:`inline-flex h-8 items-center gap-1 rounded-md border border-border px-2 text-xs text-muted-foreground hover:bg-muted hover:text-foreground transition-colors`,children:[(0,D.jsx)(p,{className:`h-3.5 w-3.5`}),` Stage`]}),(0,D.jsxs)(`button`,{type:`button`,onClick:()=>{window.confirm(`Discard changes in ${b}? This cannot be undone.`)&&l?.(b)},title:`Discard changes in this file`,className:`inline-flex h-8 items-center gap-1 rounded-md border border-border px-2 text-xs text-muted-foreground hover:bg-destructive/10 hover:text-destructive transition-colors`,children:[(0,D.jsx)(m,{className:`h-3.5 w-3.5`}),` Discard`]})]})}),I&&(0,D.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,D.jsxs)(`button`,{type:`button`,onClick:()=>k(`unified`),title:i(`activity:changes.unifiedTitle`),className:_(`inline-flex h-8 items-center gap-1 rounded-md border px-2 text-xs transition-colors`,O===`unified`?`border-primary/40 bg-primary/10 text-primary`:`border-border text-muted-foreground hover:bg-muted`),children:[(0,D.jsx)(d,{className:`h-3.5 w-3.5`}),` `,i(`activity:changes.unified`)]}),(0,D.jsxs)(`button`,{type:`button`,onClick:()=>k(`edit`),title:i(`activity:changes.editTitle`),className:_(`inline-flex h-8 items-center gap-1 rounded-md border px-2 text-xs transition-colors`,O===`edit`?`border-primary/40 bg-primary/10 text-primary`:`border-border text-muted-foreground hover:bg-muted`),children:[(0,D.jsx)(g,{className:`h-3.5 w-3.5`}),` `,i(`activity:changes.edit`)]})]})]})]}),(0,D.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:C||!S?M?(0,D.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center gap-3 p-4 text-center`,children:[(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i(`activity:changes.diffTimeout`)}),(0,D.jsxs)(`button`,{type:`button`,onClick:F,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,D.jsx)(h,{className:`h-3.5 w-3.5`}),` `,i(`common:action.retry`)]})]}):(0,D.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,D.jsx)(o,{className:`h-4 w-4 animate-spin`}),` `,i(`activity:changes.loadingDiff`)]}):S.error?(0,D.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-sm text-destructive`,children:S.error}):S.binary?(0,D.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-sm text-muted-foreground`,children:i(`activity:changes.binary`)}):S.tooLarge?(0,D.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-sm text-muted-foreground`,children:i(`activity:changes.tooLarge`)}):O===`edit`?(0,D.jsx)(A,{path:S.path,oldText:S.oldText??``,newText:S.newText??``},S.path):(0,D.jsx)(y,{oldText:S.oldText,newText:S.newText,caption:S.path,fill:!0})})]})})}export{M as ChangesView};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{K as t,nt as n,t as r}from"./config-store-D7yrCV2X.js";import{i,t as a}from"./react-core-wiHys0m2.js";import{Jn as o,Jt as s,La as c,Xi as l,Yr as u,Yt as d,jn as f,ln as p,lt as m,rn as h,xi as g}from"./vendor-BO-lHyIr.js";import"./i18n-B_njdXiH.js";import{t as _}from"./utils-DQbrPaAM.js";import"./stores-COxKgvNx.js";import{I as v,P as y}from"./index-CfREDCPe.js";import{i as b,r as x,s as S,t as C}from"./monaco-CbI7qrVD.js";import{t as w}from"./empty-state-Dl66htl_.js";import{t as T}from"./monaco-theme-Dr3-rSid.js";var E=e(i(),1),D=a();b.config({monaco:C});var O={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 k(e){return O[e.split(`.`).pop()?.toLowerCase()??``]??`plaintext`}function A({path:e,oldText:n,newText:i}){let{t:a}=c(),u=(0,E.useRef)(null),[d,f]=(0,E.useState)(!1),[p,m]=(0,E.useState)(!1),[h,g]=(0,E.useState)(null);(0,E.useEffect)(()=>{f(!1),m(!1),g(null)},[]);let _=(0,E.useCallback)(e=>{u.current=e,S.setTheme(T()),e.getModifiedEditor().onDidChangeModelContent(()=>f(!0))},[]),v=(0,E.useCallback)(()=>{let n=u.current?.getModifiedEditor().getValue();if(n==null)return;m(!0);let i=t(r.getState().wsUrl),a=i.on(`files.written`,t=>{t.type===`files.written`&&t.payload.filePath===e&&(a(),clearTimeout(o),m(!1),t.payload.success&&(f(!1),g(Date.now())))}),o=setTimeout(()=>{a(),m(!1)},5e3);i.send({type:`files.write`,payload:i.withSession({filePath:e,content:n})})},[e]),y=k(e);return(0,D.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,D.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,D.jsx)(`span`,{className:`text-xs font-mono text-muted-foreground truncate`,children:e}),(0,D.jsxs)(`button`,{type:`button`,onClick:v,disabled:!d||p,className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-md border border-border text-xs font-medium disabled:opacity-40 enabled:hover:bg-muted transition-colors`,title:a(`activity:monacoDiff.applyTitle`),children:[p?(0,D.jsx)(o,{className:`h-3.5 w-3.5 animate-spin`}):h&&!d?(0,D.jsx)(l,{className:`h-3.5 w-3.5 text-success`}):(0,D.jsx)(s,{className:`h-3.5 w-3.5`}),a(p?`activity:monacoDiff.applying`:h&&!d?`activity:monacoDiff.applied`:`activity:monacoDiff.apply`)]})]}),(0,D.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-hidden`,children:(0,D.jsx)(x,{original:n,modified:i,language:y,theme:T(),onMount:_,options:{renderSideBySide:!0,readOnly:!1,originalEditable:!1,minimap:{enabled:!1},fontSize:13,scrollBeyondLastLine:!1,automaticLayout:!0}})})]})}var j=1e4;function M({className:e}){let{t:i}=c(),{stageGit:a,unstageGit:s,discardGit:l}=v(),b=n(e=>e.selectedPath),x=n(e=>e.files),S=n(e=>e.diff),C=n(e=>e.loadingDiff),T=x.find(e=>e.path===b),[O,k]=(0,E.useState)(`unified`),[M,N]=(0,E.useState)(!1),P=!!b&&(C||!S);(0,E.useEffect)(()=>{if(N(!1),!P)return;let e=setTimeout(()=>N(!0),j);return()=>clearTimeout(e)},[P,b]);let F=()=>{b&&(N(!1),n.getState().setDiffLoading(!0),t(r.getState().wsUrl).getGitDiff?.(b))};if(!b)return(0,D.jsx)(w,{icon:(0,D.jsx)(u,{className:`h-6 w-6`}),title:i(`activity:changesView.sourceChanges`),description:i(`activity:changes.selectPrompt`),className:e});let I=S&&!S.error&&!S.binary&&!S.tooLarge;return(0,D.jsx)(`div`,{className:_(`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,D.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,D.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,D.jsxs)(`div`,{className:`min-w-0 flex items-center gap-2`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`text-[10px] font-semibold uppercase text-muted-foreground`,children:i(`activity:changesView.sourceControl`)}),(0,D.jsx)(`div`,{className:`truncate font-mono text-xs text-foreground`,title:b,children:b})]}),T?.staged&&(0,D.jsx)(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary uppercase`,children:`Staged`})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(`div`,{className:`flex items-center gap-1 border-r border-border/70 pr-2`,children:T?.staged?(0,D.jsxs)(`button`,{type:`button`,onClick:()=>s?.(b),title:`Unstage this file`,className:`inline-flex h-8 items-center gap-1 rounded-md border border-border px-2 text-xs text-muted-foreground hover:bg-muted hover:text-foreground transition-colors`,children:[(0,D.jsx)(f,{className:`h-3.5 w-3.5`}),` Unstage`]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`button`,{type:`button`,onClick:()=>a?.(b),title:`Stage this file`,className:`inline-flex h-8 items-center gap-1 rounded-md border border-border px-2 text-xs text-muted-foreground hover:bg-muted hover:text-foreground transition-colors`,children:[(0,D.jsx)(p,{className:`h-3.5 w-3.5`}),` Stage`]}),(0,D.jsxs)(`button`,{type:`button`,onClick:()=>{window.confirm(`Discard changes in ${b}? This cannot be undone.`)&&l?.(b)},title:`Discard changes in this file`,className:`inline-flex h-8 items-center gap-1 rounded-md border border-border px-2 text-xs text-muted-foreground hover:bg-destructive/10 hover:text-destructive transition-colors`,children:[(0,D.jsx)(m,{className:`h-3.5 w-3.5`}),` Discard`]})]})}),I&&(0,D.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,D.jsxs)(`button`,{type:`button`,onClick:()=>k(`unified`),title:i(`activity:changes.unifiedTitle`),className:_(`inline-flex h-8 items-center gap-1 rounded-md border px-2 text-xs transition-colors`,O===`unified`?`border-primary/40 bg-primary/10 text-primary`:`border-border text-muted-foreground hover:bg-muted`),children:[(0,D.jsx)(d,{className:`h-3.5 w-3.5`}),` `,i(`activity:changes.unified`)]}),(0,D.jsxs)(`button`,{type:`button`,onClick:()=>k(`edit`),title:i(`activity:changes.editTitle`),className:_(`inline-flex h-8 items-center gap-1 rounded-md border px-2 text-xs transition-colors`,O===`edit`?`border-primary/40 bg-primary/10 text-primary`:`border-border text-muted-foreground hover:bg-muted`),children:[(0,D.jsx)(g,{className:`h-3.5 w-3.5`}),` `,i(`activity:changes.edit`)]})]})]})]}),(0,D.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:C||!S?M?(0,D.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center gap-3 p-4 text-center`,children:[(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i(`activity:changes.diffTimeout`)}),(0,D.jsxs)(`button`,{type:`button`,onClick:F,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,D.jsx)(h,{className:`h-3.5 w-3.5`}),` `,i(`common:action.retry`)]})]}):(0,D.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,D.jsx)(o,{className:`h-4 w-4 animate-spin`}),` `,i(`activity:changes.loadingDiff`)]}):S.error?(0,D.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-sm text-destructive`,children:S.error}):S.binary?(0,D.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-sm text-muted-foreground`,children:i(`activity:changes.binary`)}):S.tooLarge?(0,D.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-sm text-muted-foreground`,children:i(`activity:changes.tooLarge`)}):O===`edit`?(0,D.jsx)(A,{path:S.path,oldText:S.oldText??``,newText:S.newText??``},S.path):(0,D.jsx)(y,{oldText:S.oldText,newText:S.newText,caption:S.path,fill:!0})})]})})}export{M as ChangesView};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{K as t,kt as n}from"./config-store-CZdk-vPj.js";import{i as r,t as i}from"./react-core-wiHys0m2.js";import{$t as a,Ht as o,It as s,Jn as c,La as l,Mi as u,Qr as d,Ui as f,Ut as p,Vi as m,Xi as h,Yi as g,Zt as _,ln as v,qi as y,rn as b}from"./vendor-Cvuk-OYN.js";import"./i18n-BwptPW9U.js";import{t as x}from"./utils-sO9lidp6.js";import{i as S}from"./index-BYBlSXtn.js";import{t as C}from"./empty-state-BFPCt03_.js";var w=e(r(),1),T=i();function E(e){try{return new Date(e).toLocaleString()}catch{return e}}function D(e){try{let t=new Date(e),n=Date.now()-t.getTime();return n<6e4?`Just now`:n<36e5?`${Math.round(n/6e4)}m ago`:n<864e5?`${Math.round(n/36e5)}h ago`:n<6048e5?`${Math.round(n/864e5)}d ago`:t.toLocaleDateString()}catch{return e}}var O={open:{label:`Open`,cls:`border-primary/30 bg-primary/10 text-primary`,icon:f},actioned:{label:`Actioned`,cls:`border-warning/30 bg-warning/10 text-warning`,icon:_},completed:{label:`Completed`,cls:`border-success/30 bg-success/10 text-success`,icon:m},skipped:{label:`Skipped`,cls:`border-border bg-muted text-muted-foreground`,icon:u}},k={critical:{bg:`bg-destructive/10 border-destructive/30`,text:`text-destructive`,dot:`bg-destructive`},high:{bg:`bg-warning/15 border-warning/40`,text:`text-warning`,dot:`bg-warning`},medium:{bg:`bg-warning/10 border-warning/30`,text:`text-warning`,dot:`bg-warning`},low:{bg:`bg-muted border-border`,text:`text-muted-foreground`,dot:`bg-muted-foreground`}};function A(){let{t:e}=l(),{reports:r,selectedReportId:i,detail:f,loading:A,detailLoading:j,error:M,filterSessionId:N,filterLifecycle:P,searchQuery:F,fetchReports:I,selectReport:L,setFilterSessionId:R,setFilterLifecycle:z,setSearchQuery:B,transitionReport:V,addReportNote:H,transitionFinding:U}=S(),[W,G]=(0,w.useState)(``),[K,q]=(0,w.useState)(!1);(0,w.useEffect)(()=>{I()},[I]);let J=(0,w.useMemo)(()=>{let e=new Set;for(let t of r)t.sessionId&&e.add(t.sessionId);return Array.from(e)},[r]),Y=(0,w.useMemo)(()=>{let e=F.trim().toLowerCase();return r.filter(t=>{if(N&&t.sessionId!==N||P&&t.lifecycleStatus!==P)return!1;if(e){let n=t.reportId.toLowerCase().includes(e),r=t.sessionId.toLowerCase().includes(e),i=(t.reviewerModel??``).toLowerCase().includes(e);if(!n&&!r&&!i)return!1}return!0})},[r,N,P,F]);return(0,T.jsxs)(`div`,{className:`flex h-full w-full flex-col overflow-hidden bg-background text-foreground`,children:[(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-border bg-card/40 px-4 py-3 sm:px-6`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`span`,{className:`text-xl`,"aria-hidden":!0,children:`🦂`}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`h1`,{className:`text-base font-semibold leading-none`,children:`Chimera Review Hub & Journal`}),(0,T.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:`Track agent code reviews, findings, session lineage, and audit event timeline`})]})]}),(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,T.jsxs)(`select`,{value:N,onChange:e=>R(e.target.value),className:`rounded-lg border border-border bg-background px-2.5 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`,"aria-label":`Filter by session`,children:[(0,T.jsxs)(`option`,{value:``,children:[`All Sessions (`,J.length,`)`]}),J.map(e=>(0,T.jsxs)(`option`,{value:e,children:[`Session: `,e.length>16?`${e.slice(0,16)}…`:e]},e))]}),(0,T.jsxs)(`select`,{value:P,onChange:e=>z(e.target.value),className:`rounded-lg border border-border bg-background px-2.5 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`,"aria-label":`Filter by status`,children:[(0,T.jsx)(`option`,{value:``,children:`All Statuses`}),(0,T.jsx)(`option`,{value:`open`,children:`Open`}),(0,T.jsx)(`option`,{value:`actioned`,children:`Actioned`}),(0,T.jsx)(`option`,{value:`completed`,children:`Completed`}),(0,T.jsx)(`option`,{value:`skipped`,children:`Skipped`})]}),(0,T.jsxs)(`div`,{className:`relative`,children:[(0,T.jsx)(p,{className:`absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,T.jsx)(`input`,{type:`text`,placeholder:`Search reports...`,value:F,onChange:e=>B(e.target.value),className:`rounded-lg border border-border bg-background pl-8 pr-3 py-1.5 text-xs placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary w-40 sm:w-52`})]}),(0,T.jsxs)(`button`,{type:`button`,onClick:()=>I(),disabled:A,className:`inline-flex items-center gap-1 rounded-lg border border-border bg-background px-2.5 py-1.5 text-xs font-medium hover:bg-muted transition-colors disabled:opacity-50`,title:`Refresh reports`,children:[(0,T.jsx)(b,{className:x(`h-3.5 w-3.5`,A&&`animate-spin`)}),(0,T.jsx)(`span`,{className:`hidden sm:inline`,children:`Refresh`})]})]})]}),(0,T.jsxs)(`div`,{className:`flex flex-1 min-h-0 min-w-0`,children:[(0,T.jsxs)(`div`,{className:`flex w-72 sm:w-80 flex-col border-r border-border bg-card/20 shrink-0 overflow-y-auto`,children:[(0,T.jsxs)(`div`,{className:`border-b border-border px-3 py-2 text-xs font-semibold text-muted-foreground uppercase tracking-wider flex items-center justify-between`,children:[(0,T.jsxs)(`span`,{children:[`Reports (`,Y.length,`)`]}),A&&(0,T.jsx)(c,{className:`h-3 w-3 animate-spin`})]}),Y.length===0?(0,T.jsx)(`div`,{className:`p-6 text-center text-xs text-muted-foreground`,children:A?`Loading review reports…`:`No review reports match your filter.`}):(0,T.jsx)(`div`,{className:`divide-y divide-border/60`,children:Y.map(e=>{let t=e.reportId===i,n=O[e.lifecycleStatus]??O.open,r=n.icon,a=e.totalFindings;return(0,T.jsxs)(`button`,{type:`button`,onClick:()=>L(e.reportId),className:x(`flex w-full flex-col gap-1.5 px-3.5 py-3 text-left transition-colors hover:bg-muted/60`,t&&`bg-primary/10 border-l-2 border-primary`),children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,T.jsxs)(`span`,{className:`text-xs font-semibold truncate font-mono text-foreground`,children:[e.reportId.slice(0,12),`…`]}),(0,T.jsxs)(`span`,{className:x(`inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium leading-none`,n.cls),children:[(0,T.jsx)(r,{className:`h-2.5 w-2.5`}),n.label]})]}),(0,T.jsxs)(`div`,{className:`flex items-center justify-between text-[11px] text-muted-foreground`,children:[(0,T.jsxs)(`span`,{className:`truncate`,children:[`Sess: `,e.sessionId.slice(0,10),`…`]}),(0,T.jsx)(`span`,{children:D(e.reviewedAt)})]}),(0,T.jsxs)(`div`,{className:`flex items-center justify-between text-[11px]`,children:[(0,T.jsx)(`span`,{className:`text-muted-foreground`,children:a===0?(0,T.jsx)(`span`,{className:`text-success font-medium`,children:`All clear ✓`}):`${a} finding(s)`}),e.counts&&a>0&&(0,T.jsxs)(`div`,{className:`flex items-center gap-1 font-mono text-[10px]`,children:[e.counts.critical>0&&(0,T.jsxs)(`span`,{className:`text-destructive font-semibold`,children:[e.counts.critical,` critical`]}),e.counts.high>0&&(0,T.jsxs)(`span`,{className:`text-warning`,children:[e.counts.high,` high`]}),e.counts.medium>0&&(0,T.jsxs)(`span`,{className:`text-warning`,children:[e.counts.medium,` med`]}),e.counts.low>0&&(0,T.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.counts.low,` low`]})]})]})]},e.reportId)})})]}),i&&f?.report?(0,T.jsxs)(`div`,{className:`flex flex-1 min-h-0 min-w-0 flex-col lg:flex-row overflow-hidden`,children:[(0,T.jsxs)(`div`,{className:`flex flex-1 min-h-0 min-w-0 flex-col overflow-y-auto p-4 sm:p-6 space-y-6`,children:[(0,T.jsxs)(`div`,{className:`rounded-xl border border-border bg-card p-5 space-y-4 shadow-sm`,children:[(0,T.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,T.jsxs)(`h2`,{className:`text-lg font-bold`,children:[`Review Report`,` `,(0,T.jsxs)(`span`,{className:`font-mono text-sm text-muted-foreground`,children:[`(`,f.report.id,`)`]})]})}),(0,T.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:[`Session`,` `,(0,T.jsx)(`span`,{className:`font-mono font-medium text-foreground`,children:f.report.sessionId}),` `,`• Reviewed at `,E(f.report.reviewedAt)]})]}),(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,T.jsxs)(`button`,{type:`button`,onClick:()=>V(f.report.id,`actioned`,`Manual action status`),disabled:f.report.lifecycle===`actioned`,className:`inline-flex items-center gap-1 rounded-lg border border-warning/30 bg-warning/10 px-2.5 py-1 text-xs font-medium text-warning hover:bg-warning/20 disabled:opacity-40 transition-colors`,children:[(0,T.jsx)(_,{className:`h-3.5 w-3.5`}),`Mark Actioned`]}),(0,T.jsxs)(`button`,{type:`button`,onClick:()=>V(f.report.id,`completed`,`Manual completion`),disabled:f.report.lifecycle===`completed`,className:`inline-flex items-center gap-1 rounded-lg border border-success/30 bg-success/10 px-2.5 py-1 text-xs font-medium text-success hover:bg-success/20 disabled:opacity-40 transition-colors`,children:[(0,T.jsx)(h,{className:`h-3.5 w-3.5`}),`Mark Completed`]}),(0,T.jsxs)(`button`,{type:`button`,onClick:()=>V(f.report.id,`skipped`,`Manual skip`),disabled:f.report.lifecycle===`skipped`,className:`inline-flex items-center gap-1 rounded-lg border border-border bg-muted px-2.5 py-1 text-xs font-medium text-muted-foreground hover:bg-muted/80 disabled:opacity-40 transition-colors`,children:[(0,T.jsx)(u,{className:`h-3.5 w-3.5`}),`Skip`]})]})]}),(0,T.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-3 pt-2 border-t border-border/60 text-xs`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`span`,{className:`text-muted-foreground block text-[11px]`,children:`Reviewer Model`}),(0,T.jsx)(`span`,{className:`font-mono font-medium text-foreground`,children:f.report.reviewerModel||`default`})]}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`span`,{className:`text-muted-foreground block text-[11px]`,children:`Reviewed Files`}),(0,T.jsxs)(`span`,{className:`font-medium text-foreground`,children:[f.report.files.length,` file(s)`]})]}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`span`,{className:`text-muted-foreground block text-[11px]`,children:`Total Findings`}),(0,T.jsx)(`span`,{className:`font-semibold text-foreground`,children:f.report.totalFindings})]}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`span`,{className:`text-muted-foreground block text-[11px]`,children:`Cascade Depth`}),(0,T.jsx)(`span`,{className:`font-medium text-foreground`,children:f.report.cascadeDepth??0})]})]}),f.report.evidenceStatus&&(0,T.jsxs)(`div`,{className:`rounded-lg bg-muted/40 p-3 border border-border/80 text-xs space-y-2`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[(0,T.jsx)(`span`,{children:`Machine Evidence Verification:`}),(0,T.jsx)(`span`,{className:x(`px-1.5 py-0.5 rounded text-[10px] font-semibold uppercase border`,f.report.evidenceStatus===`verified`?`bg-success/10 text-success border-success/30`:f.report.evidenceStatus===`failed`?`bg-destructive/10 text-destructive border-destructive/30`:`bg-warning/10 text-warning border-warning/30`),children:f.report.evidenceStatus})]}),f.report.evidenceChecks&&f.report.evidenceChecks.length>0&&(0,T.jsx)(`div`,{className:`space-y-1 font-mono text-[11px] text-muted-foreground`,children:f.report.evidenceChecks.map((e,t)=>(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`span`,{children:e.ok?`✓`:`✗`}),(0,T.jsxs)(`span`,{className:`font-semibold text-foreground`,children:[e.name,`:`]}),(0,T.jsx)(`span`,{className:`truncate`,children:e.command})]},t))})]}),(0,T.jsx)(`div`,{className:`pt-2`,children:(0,T.jsxs)(`button`,{type:`button`,onClick:()=>{if(!f?.report)return;let e=f.report,r=`Take a look at the tasks mentioned in Chimera report (${e.id}) for session ${e.sessionId} — review the ${e.totalFindings} finding(s) it flagged and address them.`,i=n(e.sessionId);i.addMessage({role:`user`,content:r}),i.patch({isLoading:!0}),t().sendMessage(r,void 0,!1,e.sessionId===`__unbound__`?void 0:e.sessionId),V(e.id,`actioned`,`Prompt dispatched to leader`)},className:`inline-flex items-center gap-2 rounded-lg bg-primary px-4 py-2 text-xs font-semibold text-primary-foreground hover:bg-primary/90 transition-colors shadow-sm`,children:[(0,T.jsx)(o,{className:`h-3.5 w-3.5`}),`Dispatch Follow-up Task to Session Leader`]})})]}),(0,T.jsxs)(`div`,{className:`space-y-4`,children:[(0,T.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,T.jsxs)(`h3`,{className:`text-sm font-bold uppercase tracking-wider text-muted-foreground`,children:[`Findings (`,f.findings.length,`)`]})}),f.findings.length===0?(0,T.jsxs)(`div`,{className:`rounded-xl border border-border/80 bg-card/40 p-8 text-center text-xs text-muted-foreground`,children:[(0,T.jsx)(m,{className:`mx-auto h-8 w-8 text-success/60 mb-2`}),`No actionable findings were discovered in this review run.`]}):(0,T.jsx)(`div`,{className:`space-y-3`,children:f.findings.map(({finding:e})=>{let t=k[e.severity]??k.low;return(0,T.jsxs)(`div`,{className:`rounded-xl border border-border bg-card p-4 space-y-3 shadow-sm transition-all hover:border-border/80`,children:[(0,T.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsxs)(`span`,{className:x(`inline-flex items-center gap-1 rounded-md px-2 py-0.5 text-xs font-semibold uppercase border`,t.bg,t.text),children:[(0,T.jsx)(`span`,{className:x(`h-1.5 w-1.5 rounded-full`,t.dot)}),e.severity]}),e.category&&(0,T.jsx)(`span`,{className:`rounded-md bg-muted px-2 py-0.5 text-[11px] font-medium text-muted-foreground`,children:e.category}),e.location?.file&&(0,T.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-mono text-xs text-foreground bg-muted/60 px-2 py-0.5 rounded`,children:[(0,T.jsx)(d,{className:`h-3 w-3 text-muted-foreground`}),e.location.file,e.location.line?`:${e.location.line}`:``]})]}),(0,T.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,T.jsx)(`span`,{className:`font-semibold text-muted-foreground mr-1`,children:`Status:`}),(0,T.jsx)(`span`,{className:x(`px-2 py-0.5 rounded-full text-[11px] font-medium capitalize border`,e.status===`resolved`?`bg-success/10 text-success border-success/30`:e.status===`ignored`?`bg-muted text-muted-foreground border-border`:`bg-primary/10 text-primary border-primary/30`),children:e.status}),e.status!==`resolved`&&(0,T.jsx)(`button`,{type:`button`,onClick:()=>U(e.id,`resolved`,`fixed`,`Resolved by operator in WebUI`),className:`ml-2 rounded px-2 py-0.5 text-[11px] font-medium bg-success/10 text-success hover:bg-success/20 border border-success/30`,children:`Resolve (Fixed)`}),e.status!==`ignored`&&e.status!==`resolved`&&(0,T.jsx)(`button`,{type:`button`,onClick:()=>U(e.id,`ignored`,void 0,`Ignored by operator`),className:`rounded px-2 py-0.5 text-[11px] font-medium bg-muted text-muted-foreground hover:bg-muted/80 border border-border`,children:`Ignore`}),(e.status===`resolved`||e.status===`ignored`)&&(0,T.jsx)(`button`,{type:`button`,onClick:()=>U(e.id,`active`,void 0,`Reopened in WebUI`),className:`rounded px-2 py-0.5 text-[11px] font-medium bg-primary/10 text-primary hover:bg-primary/20 border border-primary/30`,children:`Reopen`})]})]}),(0,T.jsx)(`h4`,{className:`text-sm font-semibold text-foreground`,children:e.title}),(0,T.jsx)(`p`,{className:`text-xs text-muted-foreground whitespace-pre-wrap`,children:e.description}),e.suggestedFix&&(0,T.jsxs)(`div`,{className:`rounded-lg bg-muted/40 border border-border/80 p-3 space-y-1 text-xs`,children:[(0,T.jsx)(`span`,{className:`font-semibold text-primary block`,children:`Suggested Fix:`}),(0,T.jsx)(`pre`,{className:`font-mono text-[11px] text-foreground overflow-x-auto whitespace-pre-wrap`,children:e.suggestedFix})]}),e.verification&&(0,T.jsxs)(`div`,{className:`text-[11px] text-muted-foreground flex items-center gap-2`,children:[(0,T.jsx)(`span`,{children:`Disk check:`}),(0,T.jsxs)(`span`,{className:x(`font-semibold`,e.verification.status===`verified`?`text-success`:e.verification.status===`failed`?`text-destructive`:`text-warning`),children:[e.verification.status,` (`,e.verification.reason,`)`]}),e.verification.evidence&&(0,T.jsxs)(`span`,{className:`font-mono text-muted-foreground truncate max-w-xs`,children:[`"`,e.verification.evidence,`"`]})]})]},e.id)})})]}),f.report.rawText&&(0,T.jsxs)(`div`,{className:`rounded-xl border border-border bg-card overflow-hidden`,children:[(0,T.jsxs)(`button`,{type:`button`,onClick:()=>q(e=>!e),className:`flex w-full items-center justify-between px-4 py-3 text-xs font-semibold text-muted-foreground hover:bg-muted/50 transition-colors`,children:[(0,T.jsx)(`span`,{children:`Raw Report Markdown`}),K?(0,T.jsx)(g,{className:`h-4 w-4`}):(0,T.jsx)(y,{className:`h-4 w-4`})]}),K&&(0,T.jsx)(`div`,{className:`border-t border-border p-4 bg-muted/20`,children:(0,T.jsx)(`pre`,{className:`text-xs font-mono whitespace-pre-wrap break-words text-muted-foreground`,children:f.report.rawText})})]})]}),(0,T.jsxs)(`div`,{className:`w-full lg:w-80 border-t lg:border-t-0 lg:border-l border-border bg-card/30 flex flex-col shrink-0 overflow-y-auto p-4 space-y-4`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border pb-3`,children:[(0,T.jsx)(a,{className:`h-4 w-4 text-primary`}),(0,T.jsx)(`h3`,{className:`text-sm font-bold`,children:`Activity Journal`})]}),(0,T.jsx)(`div`,{className:`space-y-3 flex-1 overflow-y-auto`,children:f.events.length===0?(0,T.jsx)(`p`,{className:`text-xs text-muted-foreground italic`,children:`No journal events recorded yet.`}):(0,T.jsx)(`div`,{className:`relative pl-4 space-y-4 before:absolute before:left-1.5 before:top-2 before:bottom-2 before:w-0.5 before:bg-border`,children:f.events.map(e=>(0,T.jsxs)(`div`,{className:`relative space-y-1 text-xs`,children:[(0,T.jsx)(`div`,{className:`absolute -left-4 top-1 h-2 w-2 rounded-full bg-primary ring-4 ring-card`}),(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-1 text-[11px] text-muted-foreground`,children:[(0,T.jsx)(`span`,{className:`font-semibold text-foreground capitalize`,children:e.eventType.replace(`_`,` `)}),(0,T.jsx)(`span`,{children:D(e.timestamp)})]}),(0,T.jsxs)(`div`,{className:`text-[11px] text-muted-foreground`,children:[`Actor: `,(0,T.jsx)(`span`,{className:`font-medium text-foreground`,children:e.actorId}),` (`,e.actorKind,`)`]}),e.fromLifecycle&&e.toLifecycle&&(0,T.jsxs)(`div`,{className:`text-[11px] text-muted-foreground`,children:[`Status:`,` `,(0,T.jsxs)(`span`,{className:`text-foreground`,children:[e.fromLifecycle,` ➔ `,e.toLifecycle]})]}),e.reason&&(0,T.jsxs)(`p`,{className:`rounded bg-muted/60 p-1.5 text-[11px] text-foreground/90 italic`,children:[`"`,e.reason,`"`]})]},e.id))})}),(0,T.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),i&&W.trim()&&(H(i,W.trim()),G(``))},className:`pt-3 border-t border-border space-y-2`,children:[(0,T.jsx)(`label`,{className:`text-xs font-semibold text-muted-foreground block`,children:`Add Journal Note / Inote:`}),(0,T.jsx)(`textarea`,{rows:3,value:W,onChange:e=>G(e.target.value),placeholder:`Record an observation, fix PR link, or triage note...`,className:`w-full rounded-lg border border-border bg-background p-2 text-xs placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary`}),(0,T.jsxs)(`button`,{type:`submit`,disabled:!W.trim(),className:`inline-flex w-full items-center justify-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 transition-colors disabled:opacity-50`,children:[(0,T.jsx)(v,{className:`h-3.5 w-3.5`}),`Append to Journal`]})]})]})]}):(0,T.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8`,children:(0,T.jsx)(C,{icon:(0,T.jsx)(s,{className:`h-12 w-12 text-muted-foreground/40`}),title:`Select a Chimera Review Report`,description:`Choose a review report from the left pane to view structured findings, disk verification proofs, and the activity journal.`})})]})]})}export{A as ChimeraReviewsView};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{K as t,kt as n}from"./config-store-D7yrCV2X.js";import{i as r,t as i}from"./react-core-wiHys0m2.js";import{$t as a,Ht as o,It as s,Jn as c,La as l,Mi as u,Qr as d,Ui as f,Ut as p,Vi as m,Xi as h,Yi as g,Zt as _,ln as v,qi as y,rn as b}from"./vendor-BO-lHyIr.js";import"./i18n-B_njdXiH.js";import{t as x}from"./utils-DQbrPaAM.js";import{i as S}from"./index-CfREDCPe.js";import{t as C}from"./empty-state-Dl66htl_.js";var w=e(r(),1),T=i();function E(e){try{return new Date(e).toLocaleString()}catch{return e}}function D(e){try{let t=new Date(e),n=Date.now()-t.getTime();return n<6e4?`Just now`:n<36e5?`${Math.round(n/6e4)}m ago`:n<864e5?`${Math.round(n/36e5)}h ago`:n<6048e5?`${Math.round(n/864e5)}d ago`:t.toLocaleDateString()}catch{return e}}var O={open:{label:`Open`,cls:`border-primary/30 bg-primary/10 text-primary`,icon:f},actioned:{label:`Actioned`,cls:`border-warning/30 bg-warning/10 text-warning`,icon:_},completed:{label:`Completed`,cls:`border-success/30 bg-success/10 text-success`,icon:m},skipped:{label:`Skipped`,cls:`border-border bg-muted text-muted-foreground`,icon:u}},k={critical:{bg:`bg-destructive/10 border-destructive/30`,text:`text-destructive`,dot:`bg-destructive`},high:{bg:`bg-warning/15 border-warning/40`,text:`text-warning`,dot:`bg-warning`},medium:{bg:`bg-warning/10 border-warning/30`,text:`text-warning`,dot:`bg-warning`},low:{bg:`bg-muted border-border`,text:`text-muted-foreground`,dot:`bg-muted-foreground`}};function A(){let{t:e}=l(),{reports:r,selectedReportId:i,detail:f,loading:A,detailLoading:j,error:M,filterSessionId:N,filterLifecycle:P,searchQuery:F,fetchReports:I,selectReport:L,setFilterSessionId:R,setFilterLifecycle:z,setSearchQuery:B,transitionReport:V,addReportNote:H,transitionFinding:U}=S(),[W,G]=(0,w.useState)(``),[K,q]=(0,w.useState)(!1);(0,w.useEffect)(()=>{I()},[I]);let J=(0,w.useMemo)(()=>{let e=new Set;for(let t of r)t.sessionId&&e.add(t.sessionId);return Array.from(e)},[r]),Y=(0,w.useMemo)(()=>{let e=F.trim().toLowerCase();return r.filter(t=>{if(N&&t.sessionId!==N||P&&t.lifecycleStatus!==P)return!1;if(e){let n=t.reportId.toLowerCase().includes(e),r=t.sessionId.toLowerCase().includes(e),i=(t.reviewerModel??``).toLowerCase().includes(e);if(!n&&!r&&!i)return!1}return!0})},[r,N,P,F]);return(0,T.jsxs)(`div`,{className:`flex h-full w-full flex-col overflow-hidden bg-background text-foreground`,children:[(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-border bg-card/40 px-4 py-3 sm:px-6`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`span`,{className:`text-xl`,"aria-hidden":!0,children:`🦂`}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`h1`,{className:`text-base font-semibold leading-none`,children:`Chimera Review Hub & Journal`}),(0,T.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:`Track agent code reviews, findings, session lineage, and audit event timeline`})]})]}),(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,T.jsxs)(`select`,{value:N,onChange:e=>R(e.target.value),className:`rounded-lg border border-border bg-background px-2.5 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`,"aria-label":`Filter by session`,children:[(0,T.jsxs)(`option`,{value:``,children:[`All Sessions (`,J.length,`)`]}),J.map(e=>(0,T.jsxs)(`option`,{value:e,children:[`Session: `,e.length>16?`${e.slice(0,16)}…`:e]},e))]}),(0,T.jsxs)(`select`,{value:P,onChange:e=>z(e.target.value),className:`rounded-lg border border-border bg-background px-2.5 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`,"aria-label":`Filter by status`,children:[(0,T.jsx)(`option`,{value:``,children:`All Statuses`}),(0,T.jsx)(`option`,{value:`open`,children:`Open`}),(0,T.jsx)(`option`,{value:`actioned`,children:`Actioned`}),(0,T.jsx)(`option`,{value:`completed`,children:`Completed`}),(0,T.jsx)(`option`,{value:`skipped`,children:`Skipped`})]}),(0,T.jsxs)(`div`,{className:`relative`,children:[(0,T.jsx)(p,{className:`absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,T.jsx)(`input`,{type:`text`,placeholder:`Search reports...`,value:F,onChange:e=>B(e.target.value),className:`rounded-lg border border-border bg-background pl-8 pr-3 py-1.5 text-xs placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary w-40 sm:w-52`})]}),(0,T.jsxs)(`button`,{type:`button`,onClick:()=>I(),disabled:A,className:`inline-flex items-center gap-1 rounded-lg border border-border bg-background px-2.5 py-1.5 text-xs font-medium hover:bg-muted transition-colors disabled:opacity-50`,title:`Refresh reports`,children:[(0,T.jsx)(b,{className:x(`h-3.5 w-3.5`,A&&`animate-spin`)}),(0,T.jsx)(`span`,{className:`hidden sm:inline`,children:`Refresh`})]})]})]}),(0,T.jsxs)(`div`,{className:`flex flex-1 min-h-0 min-w-0`,children:[(0,T.jsxs)(`div`,{className:`flex w-72 sm:w-80 flex-col border-r border-border bg-card/20 shrink-0 overflow-y-auto`,children:[(0,T.jsxs)(`div`,{className:`border-b border-border px-3 py-2 text-xs font-semibold text-muted-foreground uppercase tracking-wider flex items-center justify-between`,children:[(0,T.jsxs)(`span`,{children:[`Reports (`,Y.length,`)`]}),A&&(0,T.jsx)(c,{className:`h-3 w-3 animate-spin`})]}),Y.length===0?(0,T.jsx)(`div`,{className:`p-6 text-center text-xs text-muted-foreground`,children:A?`Loading review reports…`:`No review reports match your filter.`}):(0,T.jsx)(`div`,{className:`divide-y divide-border/60`,children:Y.map(e=>{let t=e.reportId===i,n=O[e.lifecycleStatus]??O.open,r=n.icon,a=e.totalFindings;return(0,T.jsxs)(`button`,{type:`button`,onClick:()=>L(e.reportId),className:x(`flex w-full flex-col gap-1.5 px-3.5 py-3 text-left transition-colors hover:bg-muted/60`,t&&`bg-primary/10 border-l-2 border-primary`),children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,T.jsxs)(`span`,{className:`text-xs font-semibold truncate font-mono text-foreground`,children:[e.reportId.slice(0,12),`…`]}),(0,T.jsxs)(`span`,{className:x(`inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium leading-none`,n.cls),children:[(0,T.jsx)(r,{className:`h-2.5 w-2.5`}),n.label]})]}),(0,T.jsxs)(`div`,{className:`flex items-center justify-between text-[11px] text-muted-foreground`,children:[(0,T.jsxs)(`span`,{className:`truncate`,children:[`Sess: `,e.sessionId.slice(0,10),`…`]}),(0,T.jsx)(`span`,{children:D(e.reviewedAt)})]}),(0,T.jsxs)(`div`,{className:`flex items-center justify-between text-[11px]`,children:[(0,T.jsx)(`span`,{className:`text-muted-foreground`,children:a===0?(0,T.jsx)(`span`,{className:`text-success font-medium`,children:`All clear ✓`}):`${a} finding(s)`}),e.counts&&a>0&&(0,T.jsxs)(`div`,{className:`flex items-center gap-1 font-mono text-[10px]`,children:[e.counts.critical>0&&(0,T.jsxs)(`span`,{className:`text-destructive font-semibold`,children:[e.counts.critical,` critical`]}),e.counts.high>0&&(0,T.jsxs)(`span`,{className:`text-warning`,children:[e.counts.high,` high`]}),e.counts.medium>0&&(0,T.jsxs)(`span`,{className:`text-warning`,children:[e.counts.medium,` med`]}),e.counts.low>0&&(0,T.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.counts.low,` low`]})]})]})]},e.reportId)})})]}),i&&f?.report?(0,T.jsxs)(`div`,{className:`flex flex-1 min-h-0 min-w-0 flex-col lg:flex-row overflow-hidden`,children:[(0,T.jsxs)(`div`,{className:`flex flex-1 min-h-0 min-w-0 flex-col overflow-y-auto p-4 sm:p-6 space-y-6`,children:[(0,T.jsxs)(`div`,{className:`rounded-xl border border-border bg-card p-5 space-y-4 shadow-sm`,children:[(0,T.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,T.jsxs)(`h2`,{className:`text-lg font-bold`,children:[`Review Report`,` `,(0,T.jsxs)(`span`,{className:`font-mono text-sm text-muted-foreground`,children:[`(`,f.report.id,`)`]})]})}),(0,T.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:[`Session`,` `,(0,T.jsx)(`span`,{className:`font-mono font-medium text-foreground`,children:f.report.sessionId}),` `,`• Reviewed at `,E(f.report.reviewedAt)]})]}),(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,T.jsxs)(`button`,{type:`button`,onClick:()=>V(f.report.id,`actioned`,`Manual action status`),disabled:f.report.lifecycle===`actioned`,className:`inline-flex items-center gap-1 rounded-lg border border-warning/30 bg-warning/10 px-2.5 py-1 text-xs font-medium text-warning hover:bg-warning/20 disabled:opacity-40 transition-colors`,children:[(0,T.jsx)(_,{className:`h-3.5 w-3.5`}),`Mark Actioned`]}),(0,T.jsxs)(`button`,{type:`button`,onClick:()=>V(f.report.id,`completed`,`Manual completion`),disabled:f.report.lifecycle===`completed`,className:`inline-flex items-center gap-1 rounded-lg border border-success/30 bg-success/10 px-2.5 py-1 text-xs font-medium text-success hover:bg-success/20 disabled:opacity-40 transition-colors`,children:[(0,T.jsx)(h,{className:`h-3.5 w-3.5`}),`Mark Completed`]}),(0,T.jsxs)(`button`,{type:`button`,onClick:()=>V(f.report.id,`skipped`,`Manual skip`),disabled:f.report.lifecycle===`skipped`,className:`inline-flex items-center gap-1 rounded-lg border border-border bg-muted px-2.5 py-1 text-xs font-medium text-muted-foreground hover:bg-muted/80 disabled:opacity-40 transition-colors`,children:[(0,T.jsx)(u,{className:`h-3.5 w-3.5`}),`Skip`]})]})]}),(0,T.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-3 pt-2 border-t border-border/60 text-xs`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`span`,{className:`text-muted-foreground block text-[11px]`,children:`Reviewer Model`}),(0,T.jsx)(`span`,{className:`font-mono font-medium text-foreground`,children:f.report.reviewerModel||`default`})]}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`span`,{className:`text-muted-foreground block text-[11px]`,children:`Reviewed Files`}),(0,T.jsxs)(`span`,{className:`font-medium text-foreground`,children:[f.report.files.length,` file(s)`]})]}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`span`,{className:`text-muted-foreground block text-[11px]`,children:`Total Findings`}),(0,T.jsx)(`span`,{className:`font-semibold text-foreground`,children:f.report.totalFindings})]}),(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`span`,{className:`text-muted-foreground block text-[11px]`,children:`Cascade Depth`}),(0,T.jsx)(`span`,{className:`font-medium text-foreground`,children:f.report.cascadeDepth??0})]})]}),f.report.evidenceStatus&&(0,T.jsxs)(`div`,{className:`rounded-lg bg-muted/40 p-3 border border-border/80 text-xs space-y-2`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[(0,T.jsx)(`span`,{children:`Machine Evidence Verification:`}),(0,T.jsx)(`span`,{className:x(`px-1.5 py-0.5 rounded text-[10px] font-semibold uppercase border`,f.report.evidenceStatus===`verified`?`bg-success/10 text-success border-success/30`:f.report.evidenceStatus===`failed`?`bg-destructive/10 text-destructive border-destructive/30`:`bg-warning/10 text-warning border-warning/30`),children:f.report.evidenceStatus})]}),f.report.evidenceChecks&&f.report.evidenceChecks.length>0&&(0,T.jsx)(`div`,{className:`space-y-1 font-mono text-[11px] text-muted-foreground`,children:f.report.evidenceChecks.map((e,t)=>(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`span`,{children:e.ok?`✓`:`✗`}),(0,T.jsxs)(`span`,{className:`font-semibold text-foreground`,children:[e.name,`:`]}),(0,T.jsx)(`span`,{className:`truncate`,children:e.command})]},t))})]}),(0,T.jsx)(`div`,{className:`pt-2`,children:(0,T.jsxs)(`button`,{type:`button`,onClick:()=>{if(!f?.report)return;let e=f.report,r=`Take a look at the tasks mentioned in Chimera report (${e.id}) for session ${e.sessionId} — review the ${e.totalFindings} finding(s) it flagged and address them.`,i=n(e.sessionId);i.addMessage({role:`user`,content:r}),i.patch({isLoading:!0}),t().sendMessage(r,void 0,!1,e.sessionId===`__unbound__`?void 0:e.sessionId),V(e.id,`actioned`,`Prompt dispatched to leader`)},className:`inline-flex items-center gap-2 rounded-lg bg-primary px-4 py-2 text-xs font-semibold text-primary-foreground hover:bg-primary/90 transition-colors shadow-sm`,children:[(0,T.jsx)(o,{className:`h-3.5 w-3.5`}),`Dispatch Follow-up Task to Session Leader`]})})]}),(0,T.jsxs)(`div`,{className:`space-y-4`,children:[(0,T.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,T.jsxs)(`h3`,{className:`text-sm font-bold uppercase tracking-wider text-muted-foreground`,children:[`Findings (`,f.findings.length,`)`]})}),f.findings.length===0?(0,T.jsxs)(`div`,{className:`rounded-xl border border-border/80 bg-card/40 p-8 text-center text-xs text-muted-foreground`,children:[(0,T.jsx)(m,{className:`mx-auto h-8 w-8 text-success/60 mb-2`}),`No actionable findings were discovered in this review run.`]}):(0,T.jsx)(`div`,{className:`space-y-3`,children:f.findings.map(({finding:e})=>{let t=k[e.severity]??k.low;return(0,T.jsxs)(`div`,{className:`rounded-xl border border-border bg-card p-4 space-y-3 shadow-sm transition-all hover:border-border/80`,children:[(0,T.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsxs)(`span`,{className:x(`inline-flex items-center gap-1 rounded-md px-2 py-0.5 text-xs font-semibold uppercase border`,t.bg,t.text),children:[(0,T.jsx)(`span`,{className:x(`h-1.5 w-1.5 rounded-full`,t.dot)}),e.severity]}),e.category&&(0,T.jsx)(`span`,{className:`rounded-md bg-muted px-2 py-0.5 text-[11px] font-medium text-muted-foreground`,children:e.category}),e.location?.file&&(0,T.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-mono text-xs text-foreground bg-muted/60 px-2 py-0.5 rounded`,children:[(0,T.jsx)(d,{className:`h-3 w-3 text-muted-foreground`}),e.location.file,e.location.line?`:${e.location.line}`:``]})]}),(0,T.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,T.jsx)(`span`,{className:`font-semibold text-muted-foreground mr-1`,children:`Status:`}),(0,T.jsx)(`span`,{className:x(`px-2 py-0.5 rounded-full text-[11px] font-medium capitalize border`,e.status===`resolved`?`bg-success/10 text-success border-success/30`:e.status===`ignored`?`bg-muted text-muted-foreground border-border`:`bg-primary/10 text-primary border-primary/30`),children:e.status}),e.status!==`resolved`&&(0,T.jsx)(`button`,{type:`button`,onClick:()=>U(e.id,`resolved`,`fixed`,`Resolved by operator in WebUI`),className:`ml-2 rounded px-2 py-0.5 text-[11px] font-medium bg-success/10 text-success hover:bg-success/20 border border-success/30`,children:`Resolve (Fixed)`}),e.status!==`ignored`&&e.status!==`resolved`&&(0,T.jsx)(`button`,{type:`button`,onClick:()=>U(e.id,`ignored`,void 0,`Ignored by operator`),className:`rounded px-2 py-0.5 text-[11px] font-medium bg-muted text-muted-foreground hover:bg-muted/80 border border-border`,children:`Ignore`}),(e.status===`resolved`||e.status===`ignored`)&&(0,T.jsx)(`button`,{type:`button`,onClick:()=>U(e.id,`active`,void 0,`Reopened in WebUI`),className:`rounded px-2 py-0.5 text-[11px] font-medium bg-primary/10 text-primary hover:bg-primary/20 border border-primary/30`,children:`Reopen`})]})]}),(0,T.jsx)(`h4`,{className:`text-sm font-semibold text-foreground`,children:e.title}),(0,T.jsx)(`p`,{className:`text-xs text-muted-foreground whitespace-pre-wrap`,children:e.description}),e.suggestedFix&&(0,T.jsxs)(`div`,{className:`rounded-lg bg-muted/40 border border-border/80 p-3 space-y-1 text-xs`,children:[(0,T.jsx)(`span`,{className:`font-semibold text-primary block`,children:`Suggested Fix:`}),(0,T.jsx)(`pre`,{className:`font-mono text-[11px] text-foreground overflow-x-auto whitespace-pre-wrap`,children:e.suggestedFix})]}),e.verification&&(0,T.jsxs)(`div`,{className:`text-[11px] text-muted-foreground flex items-center gap-2`,children:[(0,T.jsx)(`span`,{children:`Disk check:`}),(0,T.jsxs)(`span`,{className:x(`font-semibold`,e.verification.status===`verified`?`text-success`:e.verification.status===`failed`?`text-destructive`:`text-warning`),children:[e.verification.status,` (`,e.verification.reason,`)`]}),e.verification.evidence&&(0,T.jsxs)(`span`,{className:`font-mono text-muted-foreground truncate max-w-xs`,children:[`"`,e.verification.evidence,`"`]})]})]},e.id)})})]}),f.report.rawText&&(0,T.jsxs)(`div`,{className:`rounded-xl border border-border bg-card overflow-hidden`,children:[(0,T.jsxs)(`button`,{type:`button`,onClick:()=>q(e=>!e),className:`flex w-full items-center justify-between px-4 py-3 text-xs font-semibold text-muted-foreground hover:bg-muted/50 transition-colors`,children:[(0,T.jsx)(`span`,{children:`Raw Report Markdown`}),K?(0,T.jsx)(g,{className:`h-4 w-4`}):(0,T.jsx)(y,{className:`h-4 w-4`})]}),K&&(0,T.jsx)(`div`,{className:`border-t border-border p-4 bg-muted/20`,children:(0,T.jsx)(`pre`,{className:`text-xs font-mono whitespace-pre-wrap break-words text-muted-foreground`,children:f.report.rawText})})]})]}),(0,T.jsxs)(`div`,{className:`w-full lg:w-80 border-t lg:border-t-0 lg:border-l border-border bg-card/30 flex flex-col shrink-0 overflow-y-auto p-4 space-y-4`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border pb-3`,children:[(0,T.jsx)(a,{className:`h-4 w-4 text-primary`}),(0,T.jsx)(`h3`,{className:`text-sm font-bold`,children:`Activity Journal`})]}),(0,T.jsx)(`div`,{className:`space-y-3 flex-1 overflow-y-auto`,children:f.events.length===0?(0,T.jsx)(`p`,{className:`text-xs text-muted-foreground italic`,children:`No journal events recorded yet.`}):(0,T.jsx)(`div`,{className:`relative pl-4 space-y-4 before:absolute before:left-1.5 before:top-2 before:bottom-2 before:w-0.5 before:bg-border`,children:f.events.map(e=>(0,T.jsxs)(`div`,{className:`relative space-y-1 text-xs`,children:[(0,T.jsx)(`div`,{className:`absolute -left-4 top-1 h-2 w-2 rounded-full bg-primary ring-4 ring-card`}),(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-1 text-[11px] text-muted-foreground`,children:[(0,T.jsx)(`span`,{className:`font-semibold text-foreground capitalize`,children:e.eventType.replace(`_`,` `)}),(0,T.jsx)(`span`,{children:D(e.timestamp)})]}),(0,T.jsxs)(`div`,{className:`text-[11px] text-muted-foreground`,children:[`Actor: `,(0,T.jsx)(`span`,{className:`font-medium text-foreground`,children:e.actorId}),` (`,e.actorKind,`)`]}),e.fromLifecycle&&e.toLifecycle&&(0,T.jsxs)(`div`,{className:`text-[11px] text-muted-foreground`,children:[`Status:`,` `,(0,T.jsxs)(`span`,{className:`text-foreground`,children:[e.fromLifecycle,` ➔ `,e.toLifecycle]})]}),e.reason&&(0,T.jsxs)(`p`,{className:`rounded bg-muted/60 p-1.5 text-[11px] text-foreground/90 italic`,children:[`"`,e.reason,`"`]})]},e.id))})}),(0,T.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),i&&W.trim()&&(H(i,W.trim()),G(``))},className:`pt-3 border-t border-border space-y-2`,children:[(0,T.jsx)(`label`,{className:`text-xs font-semibold text-muted-foreground block`,children:`Add Journal Note / Inote:`}),(0,T.jsx)(`textarea`,{rows:3,value:W,onChange:e=>G(e.target.value),placeholder:`Record an observation, fix PR link, or triage note...`,className:`w-full rounded-lg border border-border bg-background p-2 text-xs placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary`}),(0,T.jsxs)(`button`,{type:`submit`,disabled:!W.trim(),className:`inline-flex w-full items-center justify-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 transition-colors disabled:opacity-50`,children:[(0,T.jsx)(v,{className:`h-3.5 w-3.5`}),`Append to Journal`]})]})]})]}):(0,T.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8`,children:(0,T.jsx)(C,{icon:(0,T.jsx)(s,{className:`h-12 w-12 text-muted-foreground/40`}),title:`Select a Chimera Review Report`,description:`Choose a review report from the left pane to view structured findings, disk verification proofs, and the activity journal.`})})]})]})}export{A as ChimeraReviewsView};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{K as t}from"./config-store-CZdk-vPj.js";import{i as n,t as r}from"./react-core-wiHys0m2.js";import{Di as i,Ft as a,J as o,La as s,Qr as c,Qt as ee,Tt as l,Ut as te,ca as u,di as d,dt as f,er as ne,ia as p,ja as m,kr as h,qi as g,rn as _,wr as v}from"./vendor-Cvuk-OYN.js";import"./i18n-BwptPW9U.js";import{t as y}from"./utils-sO9lidp6.js";import{T as re,w as ie}from"./index-BYBlSXtn.js";var b=e(n(),1),x=r();function ae({status:e}){let{t}=s();return(0,x.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,x.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-primary`,children:t(`activity:chroniclePipelineStrip.chronicleOwnership`)}),(0,x.jsxs)(`span`,{children:[`collect `,(0,x.jsx)(`b`,{className:`text-foreground`,children:e.pipeline.collection})]}),(0,x.jsxs)(`span`,{children:[`process `,(0,x.jsx)(`b`,{className:`text-foreground`,children:e.pipeline.processing})]}),(0,x.jsxs)(`span`,{children:[`serve `,(0,x.jsx)(`b`,{className:`text-foreground`,children:e.pipeline.serving})]}),(0,x.jsxs)(`span`,{children:[`PID `,(0,x.jsx)(`b`,{className:`text-foreground`,children:e.pid}),` · `,e.clients,` clients`]}),(0,x.jsxs)(`span`,{children:[`watcher`,` `,(0,x.jsx)(`b`,{className:y(e.watcher.active?`text-success`:`text-warning`),children:e.watcher.active?`active`:`inactive`}),` `,`· `,e.watcher.watchedFiles,` files`]}),(0,x.jsxs)(`span`,{children:[`store `,(0,x.jsx)(`b`,{className:`text-foreground`,children:S(e.pipeline.storage)})]}),e.mode===`inline`&&(0,x.jsx)(`span`,{className:`font-sans font-semibold text-warning`,children:t(`activity:chroniclePipelineStrip.inlineFallback`)})]})}function S(e){return e.replaceAll(`\\`,`/`).split(`/`).filter(Boolean).slice(-3).join(`/`)}var C=[`eventType`,`providerId`,`modelId`,`outcome`,`resourceKind`],w=864e5;function T(){return{limit:300,order:`desc`,from:new Date(Date.now()-w).toISOString()}}var oe=[{id:`all`,labelKey:`activity:chronicle.signalAllSignals`,icon:(0,x.jsx)(m,{})},{id:`llm`,labelKey:`activity:chronicle.signalLlm`,icon:(0,x.jsx)(p,{})},{id:`agents`,labelKey:`activity:chronicle.signalAgents`,icon:(0,x.jsx)(u,{})},{id:`tools`,labelKey:`activity:chronicle.signalTools`,icon:(0,x.jsx)(l,{})},{id:`files`,labelKey:`activity:chronicle.signalFiles`,icon:(0,x.jsx)(c,{})},{id:`failures`,labelKey:`activity:chronicle.signalFailures`,icon:(0,x.jsx)(f,{})}];function E(){let{t:e}=s(),n=t(),[r,a]=(0,b.useState)([]),[d,f]=(0,b.useState)(null),[m,g]=(0,b.useState)({}),[v,S]=(0,b.useState)(T()),[w,E]=(0,b.useState)({text:``,path:``,providerId:``,modelId:``,sessionId:``}),[D,k]=(0,b.useState)(`all`),[N,F]=(0,b.useState)({total:0,scannedEvents:0,sourceFiles:0,invalidLines:0}),[I,pe]=(0,b.useState)(O),[L,R]=(0,b.useState)(!0),[z,B]=(0,b.useState)(null),[me,V]=(0,b.useState)(null),[H,he]=(0,b.useState)([]),[U,ge]=(0,b.useState)([]),[W,_e]=(0,b.useState)(null),G=(0,b.useRef)(v);G.current=v;let K=(0,b.useCallback)(e=>{if(!n.supportsCapability(`chronicle.query`)){R(!1),B(`Restart the backend once to activate Chronicle protocol support.`);return}if(R(!0),B(null),S(e),g({}),n.send({type:`chronicle.query`,payload:{query:e}}),n.supportsCapability(`chronicle.facets`))n.send({type:`chronicle.facets`,payload:{fields:[...C],query:e,limit:12}});else for(let t of C)n.send({type:`chronicle.facet`,payload:{field:t,query:e,limit:12}})},[n]),q=(0,b.useCallback)(()=>{n.supportsCapability(`chronicle.metrics`)&&(n.send({type:`chronicle.metrics`,payload:{view:`providers`}}),n.send({type:`chronicle.metrics`,payload:{view:`tasks`,limit:200}}))},[n]),J=(0,b.useCallback)(()=>{n.supportsCapability(`chronicle.status`)&&n.send({type:`chronicle.status`})},[n]);(0,b.useEffect)(()=>{let e=n.on(`chronicle.query_result`,e=>{e.type===`chronicle.query_result`&&(a(e.payload.events),F(e.payload),pe(e.payload.summary??O),R(!1))}),t=n.on(`chronicle.facet_result`,e=>{e.type===`chronicle.facet_result`&&g(t=>({...t,[e.payload.field]:e.payload.values}))}),r=n.on(`chronicle.facets_result`,e=>{e.type===`chronicle.facets_result`&&g(e.payload.values)}),i=n.on(`chronicle.error`,e=>{e.type===`chronicle.error`&&(B(e.payload.message),R(!1))}),o=n.on(`chronicle.graph_result`,e=>{e.type===`chronicle.graph_result`&&V(e.payload)}),s=n.on(`chronicle.metrics_result`,e=>{e.type===`chronicle.metrics_result`&&(e.payload.view===`providers`?he(e.payload.data):e.payload.view===`tasks`&&ge(e.payload.data))}),c=n.on(`chronicle.status_result`,e=>{e.type===`chronicle.status_result`&&_e(e.payload)});return K(G.current),q(),J(),()=>{e(),t(),r(),i(),o(),s(),c()}},[n,K,q,J]);let Y=(0,b.useMemo)(()=>r.filter(e=>le(e,D)),[r,D]),X=re(Y,25,D),Z=(0,b.useMemo)(()=>{let e=r.find(e=>e.eventType===`metrics.rollup`&&e.attributes?.signal===`runtime.health`)?.attributes?.stats;if(!e)return;let t=t=>e[t]?.last;return{eventLoop:{utilization:t(`eventLoop.utilization`),delayP95Ms:t(`eventLoop.delayP95Ms`)},memory:{heapUsedBytes:t(`memory.heapUsedBytes`)},chronicle:{pendingEvents:t(`chronicle.pendingEvents`),rejectedEvents:t(`chronicle.rejectedEvents`)}}},[r]),Q=(0,b.useMemo)(()=>{let e={};for(let t of U)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=[...U].sort((e,t)=>(t.endedAt??t.startedAt??``).localeCompare(e.endedAt??e.startedAt??``)).slice(0,8);return{counts:e,total:U.length,terminal:t,successRate:t>0?n/t*100:100,recent:r}},[U]),$=()=>K({...T(),...w.text?{text:w.text}:{},...w.path?{path:w.path}:{},...w.providerId?{providerId:w.providerId}:{},...w.modelId?{modelId:w.modelId}:{},...w.sessionId?{sessionId:w.sessionId}:{}}),ve=()=>{E({text:``,path:``,providerId:``,modelId:``,sessionId:``}),k(`all`),K(T())},ye=e=>{f(e),V(null),n.supportsCapability(`chronicle.graph`)&&n.send({type:`chronicle.graph`,payload:{seed:{eventId:e.eventId},hops:2,maxNodes:250}})};return(0,x.jsxs)(`div`,{className:`flex h-full min-h-0 bg-background`,"data-testid":`chronicle-dashboard`,children:[(0,x.jsxs)(`main`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,x.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,x.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(p,{className:`h-5 w-5 text-primary`}),(0,x.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight`,children:e(`activity:chronicle.codingIntelligence`)}),(0,x.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:e(`activity:chronicle.chronicle`)})]}),(0,x.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:e(`activity:chronicle.llmAgentToolAndFileEvidence`)})]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(`span`,{className:y(`h-2 w-2 rounded-full`,z?`bg-destructive`:L?`animate-pulse bg-warning`:`bg-success`)}),(0,x.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:L?`Reading journal`:z?`Unavailable`:`Live evidence`}),(0,x.jsx)(`button`,{type:`button`,onClick:()=>{K(v),q(),J()},className:`ml-2 rounded-md border border-border bg-card p-2 hover:bg-muted`,title:e(`activity:chronicle.refreshEvidence`),children:(0,x.jsx)(_,{className:y(`h-4 w-4`,L&&`animate-spin`)})})]})]})}),(0,x.jsxs)(`section`,{className:`grid grid-cols-2 border-b border-border/70 xl:grid-cols-6`,children:[(0,x.jsx)(M,{icon:(0,x.jsx)(p,{}),label:e(`activity:chronicle.llmRequests`),value:I.logicalRequests,detail:`${I.modelAttempts} attempts · ${I.providers} providers · ${I.models} models`}),(0,x.jsx)(M,{icon:(0,x.jsx)(u,{}),label:e(`activity:chronicle.agentWork`),value:I.agentEvents,detail:`${I.uniqueAgents} correlated agents · ${I.decisions} decisions`}),(0,x.jsx)(M,{icon:(0,x.jsx)(l,{}),label:e(`activity:chronicle.toolCalls`),value:I.toolCalls,detail:`${I.failedTools} failed · ${I.processes} processes`}),(0,x.jsx)(M,{icon:(0,x.jsx)(c,{}),label:e(`activity:chronicle.fileEvidence`),value:I.fileEvents,detail:`${I.uniqueFiles} unique paths`}),(0,x.jsx)(M,{icon:(0,x.jsx)(ee,{}),label:e(`activity:chronicle.retries`),value:I.scheduledRetries,detail:`${I.failures} failures · ${I.fallbacks} fallbacks`,tone:I.failures?`danger`:`normal`}),(0,x.jsx)(M,{icon:(0,x.jsx)(i,{}),label:e(`activity:chronicle.providerP95`),value:A(I.providerP95DurationMs),detail:`${A(I.providerAvgDurationMs)} average · all matches`})]}),(0,x.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,x.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-primary`,children:e(`activity:chronicle.tokenEconomics`)}),(0,x.jsxs)(`span`,{children:[e(`activity:chronicle.freshInput`),` `,(0,x.jsx)(`b`,{className:`text-foreground`,children:I.inputTokens.toLocaleString()})]}),(0,x.jsxs)(`span`,{children:[`output `,(0,x.jsx)(`b`,{className:`text-foreground`,children:I.outputTokens.toLocaleString()})]}),(0,x.jsxs)(`span`,{children:[e(`activity:chronicle.cacheRead`),` `,(0,x.jsx)(`b`,{className:`text-foreground`,children:I.cacheReadTokens.toLocaleString()})]}),(0,x.jsxs)(`span`,{children:[`cache write`,` `,(0,x.jsx)(`b`,{className:`text-foreground`,children:I.cacheWriteTokens.toLocaleString()})]}),(0,x.jsxs)(`span`,{children:[e(`activity:chronicle.cacheHit`),` `,(0,x.jsxs)(`b`,{className:`text-foreground`,children:[ce(I).toFixed(1),`%`]})]}),(0,x.jsxs)(`span`,{children:[e(`activity:chronicle.estimatedCost`),` `,(0,x.jsxs)(`b`,{className:`text-foreground`,children:[`$`,I.estimatedCostUsd.toFixed(4)]})]})]}),H.length>0&&(0,x.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,x.jsx)(`span`,{className:`shrink-0 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e(`activity:chronicle.modelReliability`)}),H.slice(0,6).map(e=>{let t=e.completed+e.failed,n=t>0?e.completed/t*100:100;return(0,x.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,x.jsx)(`span`,{className:y(`h-1.5 w-1.5 rounded-full`,n>=99?`bg-success`:n>=90?`bg-warning`:`bg-destructive`)}),(0,x.jsxs)(`span`,{className:`max-w-[180px] truncate`,children:[e.providerId,`/`,e.modelId]}),(0,x.jsxs)(`b`,{className:`text-foreground`,children:[n.toFixed(0),`%`]}),(0,x.jsx)(`span`,{className:`text-muted-foreground`,children:e.day.slice(5)})]},`${e.day}-${e.providerId}-${e.modelId}`)})]}),Q.total>0&&(0,x.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,x.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,x.jsx)(ne,{className:`h-3 w-3`}),e(`activity:chronicle.taskOutcomes`)]}),(0,x.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,x.jsx)(`span`,{className:y(`h-1.5 w-1.5 rounded-full`,Q.successRate>=90?`bg-success`:Q.successRate>=60?`bg-warning`:`bg-destructive`)}),(0,x.jsxs)(`b`,{className:`text-foreground`,children:[Q.successRate.toFixed(0),`%`]}),(0,x.jsxs)(`span`,{className:`text-muted-foreground`,children:[`success · `,Q.total,` tasks`]})]}),[`completed`,`merged`,`failed`,`conflict`,`started`].filter(e=>Q.counts[e]).map(e=>(0,x.jsxs)(`span`,{className:`shrink-0 font-mono text-[9px] text-muted-foreground`,children:[e,` `,(0,x.jsx)(`b`,{className:y(e===`failed`||e===`conflict`?`text-destructive`:`text-foreground`),children:Q.counts[e]})]},e)),(0,x.jsx)(`span`,{className:`mx-1 h-3 w-px shrink-0 bg-border`}),Q.recent.map(e=>(0,x.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,x.jsx)(`span`,{className:y(`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,x.jsx)(`span`,{className:`max-w-[84px] truncate`,children:e.taskId}),e.durationMs!==null&&(0,x.jsx)(`span`,{className:`text-muted-foreground`,children:A(e.durationMs)}),e.filesTouched>0&&(0,x.jsxs)(`span`,{className:`flex items-center gap-0.5 text-muted-foreground`,children:[(0,x.jsx)(c,{className:`h-2.5 w-2.5`}),e.filesTouched]})]},e.taskId))]}),(0,x.jsx)(`section`,{className:`border-b border-border/70 px-4 py-3`,children:(0,x.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 xl:grid-cols-[1.35fr_1fr_1fr_1fr_1fr_auto]`,children:[(0,x.jsx)(j,{icon:(0,x.jsx)(te,{}),placeholder:e(`activity:chronicle.searchEventEvidence`),value:w.text,onChange:e=>E(t=>({...t,text:e})),onEnter:$}),(0,x.jsx)(j,{placeholder:e(`activity:chronicle.fileOrDirectory`),value:w.path,onChange:e=>E(t=>({...t,path:e})),onEnter:$}),(0,x.jsx)(j,{placeholder:e(`activity:chronicle.provider`),value:w.providerId,onChange:e=>E(t=>({...t,providerId:e})),onEnter:$}),(0,x.jsx)(j,{placeholder:e(`activity:chronicle.model`),value:w.modelId,onChange:e=>E(t=>({...t,modelId:e})),onEnter:$}),(0,x.jsx)(j,{placeholder:e(`activity:chronicle.session`),value:w.sessionId,onChange:e=>E(t=>({...t,sessionId:e})),onEnter:$}),(0,x.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,x.jsxs)(`button`,{type:`button`,onClick:$,className:`rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground`,children:[(0,x.jsx)(h,{className:`mr-1 inline h-3 w-3`}),e(`activity:chronicle.apply`)]}),(0,x.jsx)(`button`,{type:`button`,onClick:ve,className:`rounded-md border border-border px-2.5 text-xs hover:bg-muted`,children:e(`activity:chronicle.clear`)})]})]})}),(0,x.jsxs)(`section`,{className:`flex items-center gap-1 overflow-x-auto border-b border-border/70 px-4 py-2`,children:[oe.map(t=>(0,x.jsxs)(`button`,{type:`button`,onClick:()=>k(t.id),className:y(`flex shrink-0 items-center gap-1.5 rounded-md px-2.5 py-1.5 text-[11px] transition-colors [&>svg]:h-3.5 [&>svg]:w-3.5`,D===t.id?`bg-primary/10 font-medium text-primary`:`text-muted-foreground hover:bg-muted hover:text-foreground`),children:[t.icon,e(t.labelKey),(0,x.jsx)(`span`,{className:`ml-1 rounded bg-background/70 px-1 font-mono text-[9px]`,children:se(I,t.id,N.total)})]},t.id)),(0,x.jsxs)(`div`,{className:`ml-auto hidden items-center gap-3 pl-4 text-[9px] text-muted-foreground lg:flex`,children:[(0,x.jsxs)(`span`,{children:[N.total.toLocaleString(),` matched`]}),(0,x.jsxs)(`span`,{children:[N.sourceFiles,` journal files`]}),N.invalidLines>0&&(0,x.jsxs)(`span`,{className:`text-warning`,children:[N.invalidLines,` invalid lines`]})]})]}),W&&(0,x.jsx)(ae,{status:W}),Z&&(0,x.jsx)(ue,{health:Z}),(0,x.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,x.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,x.jsx)(`span`,{className:`mr-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e.replace(`Id`,``)}),(m[e]??[]).slice(0,4).map(t=>(0,x.jsxs)(`button`,{type:`button`,onClick:()=>K({...v,[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,x.jsx)(`b`,{children:t.count})]},t.value))]},e))}),(0,x.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,x.jsx)(`span`,{children:e(`activity:chronicle.time`)}),(0,x.jsx)(`span`,{children:e(`activity:chronicle.signal`)}),(0,x.jsx)(`span`,{children:e(`activity:chronicle.outcome`)}),(0,x.jsx)(`span`,{children:e(`activity:chronicle.modelAgent`)}),(0,x.jsx)(`span`,{children:e(`activity:chronicle.resource`)}),(0,x.jsx)(`span`,{})]}),(0,x.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:z?(0,x.jsx)(P,{text:z}):!L&&Y.length===0?(0,x.jsx)(P,{text:`No coding evidence matches these filters.`}):(0,x.jsx)(`div`,{className:`divide-y divide-border/40`,children:X.pageItems.map(e=>(0,x.jsx)(de,{event:e,active:d?.eventId===e.eventId,onClick:()=>ye(e)},e.eventId))})}),(0,x.jsx)(ie,{page:X.page,pageSize:X.pageSize,totalItems:X.totalItems,onPageChange:X.setPage,itemLabel:`events`})]}),d&&(0,x.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,x.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,x.jsxs)(`div`,{children:[(0,x.jsx)(`div`,{className:`text-xs font-semibold`,children:e(`activity:chronicle.evidenceLineage`)}),(0,x.jsxs)(`div`,{className:`mt-0.5 font-mono text-[9px] text-muted-foreground`,children:[`#`,d.sequence,` · `,d.eventId]})]}),(0,x.jsx)(`button`,{type:`button`,onClick:()=>f(null),className:`rounded p-1 hover:bg-muted`,children:(0,x.jsx)(o,{className:`h-4 w-4`})})]}),(0,x.jsx)(fe,{event:d,graph:me})]})]})}var D={llm:0,agent:0,tool:0,file:0,memory:0,task:0,decision:0,runtime:0},O={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:{...D},failuresByFamily:{...D}};function se(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 ce(e){let t=e.inputTokens+e.cacheReadTokens;return t?e.cacheReadTokens/t*100:0}function le(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,x.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,x.jsx)(`span`,{className:`text-muted-foreground [&>svg]:h-3.5 [&>svg]:w-3.5`,children:i}),(0,x.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,x.jsxs)(`div`,{className:`min-w-0 border-r border-border/60 px-4 py-3`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,x.jsx)(`span`,{className:`text-primary [&>svg]:h-3.5 [&>svg]:w-3.5`,children:e}),t]}),(0,x.jsx)(`div`,{className:y(`mt-1 text-xl font-semibold tabular-nums`,i===`danger`&&`text-destructive`),children:typeof n==`number`?n.toLocaleString():n}),(0,x.jsx)(`div`,{className:`mt-0.5 truncate text-[9px] text-muted-foreground`,children:r})]})}function ue({health:e}){let{t}=s();return(0,x.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,x.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-success`,children:t(`activity:chronicle.collectorHealthy`)}),(0,x.jsxs)(`span`,{children:[`ELU`,` `,(0,x.jsxs)(`b`,{className:`text-foreground`,children:[((e.eventLoop?.utilization??0)*100).toFixed(1),`%`]})]}),(0,x.jsxs)(`span`,{children:[`p95 `,(0,x.jsxs)(`b`,{className:`text-foreground`,children:[(e.eventLoop?.delayP95Ms??0).toFixed(1),`ms`]})]}),(0,x.jsxs)(`span`,{children:[`heap`,` `,(0,x.jsxs)(`b`,{className:`text-foreground`,children:[((e.memory?.heapUsedBytes??0)/1048576).toFixed(0),`MB`]})]}),(0,x.jsxs)(`span`,{children:[`queue `,(0,x.jsx)(`b`,{className:`text-foreground`,children:e.chronicle?.pendingEvents??0})]}),(0,x.jsxs)(`span`,{children:[`dropped`,` `,(0,x.jsx)(`b`,{className:y((e.chronicle?.rejectedEvents??0)>0&&`text-destructive`),children:e.chronicle?.rejectedEvents??0})]})]})}function de({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,x.jsxs)(`button`,{type:`button`,onClick:n,className:y(`grid w-full grid-cols-[92px_minmax(190px,1.25fr)_110px_minmax(180px,1fr)_minmax(140px,.8fr)_24px] items-center gap-3 px-4 py-2.5 text-left hover:bg-muted/45`,t&&`bg-primary/[0.07]`),children:[(0,x.jsx)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:new Date(r).toLocaleTimeString()}),(0,x.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,x.jsx)(`span`,{className:y(`h-1.5 w-1.5 shrink-0 rounded-full`,e.outcome===`failure`?`bg-destructive`:e.outcome===`success`?`bg-success`:`bg-primary`)}),(0,x.jsx)(`span`,{className:`truncate font-mono text-[11px] font-medium`,children:e.eventType})]}),(0,x.jsx)(`span`,{className:y(`w-fit rounded px-1.5 py-0.5 text-[9px]`,F(e.outcome)),children:e.outcome??`unknown`}),(0,x.jsx)(`span`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:i}),(0,x.jsx)(`span`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:a}),(0,x.jsx)(g,{className:`h-3.5 w-3.5 text-muted-foreground`})]})}function fe({event:e,graph:t}){let{t:n}=s(),r=(0,b.useMemo)(()=>[[`Scope`,e.scope],[`Correlation`,e.correlation],[`Runtime`,e.runtime],[`Resource`,e.resource],[`Attributes`,e.attributes],[`Tags`,e.tags]],[e]);return(0,x.jsxs)(`div`,{className:`p-4`,children:[(0,x.jsxs)(`div`,{className:`mb-4 rounded-lg border border-border bg-background/60 p-3`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(`span`,{className:y(`h-2 w-2 rounded-full`,e.outcome===`failure`?`bg-destructive`:e.outcome===`success`?`bg-success`:`bg-primary`)}),(0,x.jsx)(`span`,{className:`font-mono text-xs font-semibold`,children:e.eventType})]}),(0,x.jsxs)(`div`,{className:`mt-2 flex gap-4 text-[9px] text-muted-foreground`,children:[(0,x.jsx)(`span`,{children:new Date(e.occurredAt??e.observedAt).toLocaleString()}),(0,x.jsx)(`span`,{children:k(Number(e.durationNs??0))})]})]}),(0,x.jsxs)(`div`,{className:`mb-4 grid grid-cols-2 gap-2`,children:[(0,x.jsx)(N,{icon:(0,x.jsx)(a,{}),label:n(`activity:chronicle.evidenceHash`),value:e.hash.slice(0,16)}),(0,x.jsx)(N,{icon:(0,x.jsx)(d,{}),label:n(`activity:chronicle.sequence`),value:String(e.sequence)})]}),t&&(0,x.jsxs)(`section`,{className:`mb-4`,children:[(0,x.jsxs)(`h3`,{className:`mb-1.5 flex items-center gap-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,x.jsx)(v,{className:`h-3 w-3`}),`Lineage · `,t.nodes.length,` nodes · `,t.edges.length,` edges`]}),(0,x.jsx)(`div`,{className:`space-y-1 rounded-md border border-border bg-background/70 p-2`,children:t.edges.slice(0,40).map((e,n)=>(0,x.jsxs)(`div`,{className:`flex items-center gap-2 font-mono text-[9px]`,children:[(0,x.jsx)(`span`,{className:y(`rounded px-1`,e.confidence===`explicit`?`bg-success/10 text-success`:e.confidence===`inferred`?`bg-warning/10 text-warning`:`bg-primary/10 text-primary`),children:e.confidence}),(0,x.jsx)(`span`,{className:`text-muted-foreground`,children:e.kind}),(0,x.jsxs)(`span`,{className:`truncate`,children:[t.nodes.find(t=>t.eventId===e.from)?.eventType,` →`,` `,t.nodes.find(t=>t.eventId===e.to)?.eventType]})]},`${e.from}-${e.to}-${e.kind}-${n}`))}),t.truncated&&(0,x.jsx)(`p`,{className:`mt-1 text-[9px] text-warning`,children:n(`activity:chronicle.lineageTruncatedAtSafetyLimit`)})]}),r.map(([e,t])=>t&&(0,x.jsxs)(`section`,{className:`mb-4`,children:[(0,x.jsx)(`h3`,{className:`mb-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e}),(0,x.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 N({icon:e,label:t,value:n}){return(0,x.jsxs)(`div`,{className:`rounded-md border border-border p-2`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-1 text-[8px] uppercase text-muted-foreground`,children:[(0,x.jsx)(`span`,{className:`[&>svg]:h-3 [&>svg]:w-3`,children:e}),t]}),(0,x.jsx)(`div`,{className:`mt-1 truncate font-mono text-[9px]`,children:n})]})}function P({text:e}){return(0,x.jsx)(`div`,{className:`flex h-48 items-center justify-center text-sm text-muted-foreground`,children:e})}function F(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{E as ChronicleDashboard};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{K as t}from"./config-store-D7yrCV2X.js";import{i as n,t as r}from"./react-core-wiHys0m2.js";import{Di as i,Ft as a,J as o,La as s,Qr as c,Qt as ee,Tt as l,Ut as te,ca as u,di as d,dt as f,er as ne,ia as p,ja as m,kr as h,qi as g,rn as _,wr as v}from"./vendor-BO-lHyIr.js";import"./i18n-B_njdXiH.js";import{t as y}from"./utils-DQbrPaAM.js";import{T as re,w as ie}from"./index-CfREDCPe.js";var b=e(n(),1),x=r();function ae({status:e}){let{t}=s();return(0,x.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,x.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-primary`,children:t(`activity:chroniclePipelineStrip.chronicleOwnership`)}),(0,x.jsxs)(`span`,{children:[`collect `,(0,x.jsx)(`b`,{className:`text-foreground`,children:e.pipeline.collection})]}),(0,x.jsxs)(`span`,{children:[`process `,(0,x.jsx)(`b`,{className:`text-foreground`,children:e.pipeline.processing})]}),(0,x.jsxs)(`span`,{children:[`serve `,(0,x.jsx)(`b`,{className:`text-foreground`,children:e.pipeline.serving})]}),(0,x.jsxs)(`span`,{children:[`PID `,(0,x.jsx)(`b`,{className:`text-foreground`,children:e.pid}),` · `,e.clients,` clients`]}),(0,x.jsxs)(`span`,{children:[`watcher`,` `,(0,x.jsx)(`b`,{className:y(e.watcher.active?`text-success`:`text-warning`),children:e.watcher.active?`active`:`inactive`}),` `,`· `,e.watcher.watchedFiles,` files`]}),(0,x.jsxs)(`span`,{children:[`store `,(0,x.jsx)(`b`,{className:`text-foreground`,children:S(e.pipeline.storage)})]}),e.mode===`inline`&&(0,x.jsx)(`span`,{className:`font-sans font-semibold text-warning`,children:t(`activity:chroniclePipelineStrip.inlineFallback`)})]})}function S(e){return e.replaceAll(`\\`,`/`).split(`/`).filter(Boolean).slice(-3).join(`/`)}var C=[`eventType`,`providerId`,`modelId`,`outcome`,`resourceKind`],w=864e5;function T(){return{limit:300,order:`desc`,from:new Date(Date.now()-w).toISOString()}}var oe=[{id:`all`,labelKey:`activity:chronicle.signalAllSignals`,icon:(0,x.jsx)(m,{})},{id:`llm`,labelKey:`activity:chronicle.signalLlm`,icon:(0,x.jsx)(p,{})},{id:`agents`,labelKey:`activity:chronicle.signalAgents`,icon:(0,x.jsx)(u,{})},{id:`tools`,labelKey:`activity:chronicle.signalTools`,icon:(0,x.jsx)(l,{})},{id:`files`,labelKey:`activity:chronicle.signalFiles`,icon:(0,x.jsx)(c,{})},{id:`failures`,labelKey:`activity:chronicle.signalFailures`,icon:(0,x.jsx)(f,{})}];function E(){let{t:e}=s(),n=t(),[r,a]=(0,b.useState)([]),[d,f]=(0,b.useState)(null),[m,g]=(0,b.useState)({}),[v,S]=(0,b.useState)(T()),[w,E]=(0,b.useState)({text:``,path:``,providerId:``,modelId:``,sessionId:``}),[D,k]=(0,b.useState)(`all`),[N,F]=(0,b.useState)({total:0,scannedEvents:0,sourceFiles:0,invalidLines:0}),[I,pe]=(0,b.useState)(O),[L,R]=(0,b.useState)(!0),[z,B]=(0,b.useState)(null),[me,V]=(0,b.useState)(null),[H,he]=(0,b.useState)([]),[U,ge]=(0,b.useState)([]),[W,_e]=(0,b.useState)(null),G=(0,b.useRef)(v);G.current=v;let K=(0,b.useCallback)(e=>{if(!n.supportsCapability(`chronicle.query`)){R(!1),B(`Restart the backend once to activate Chronicle protocol support.`);return}if(R(!0),B(null),S(e),g({}),n.send({type:`chronicle.query`,payload:{query:e}}),n.supportsCapability(`chronicle.facets`))n.send({type:`chronicle.facets`,payload:{fields:[...C],query:e,limit:12}});else for(let t of C)n.send({type:`chronicle.facet`,payload:{field:t,query:e,limit:12}})},[n]),q=(0,b.useCallback)(()=>{n.supportsCapability(`chronicle.metrics`)&&(n.send({type:`chronicle.metrics`,payload:{view:`providers`}}),n.send({type:`chronicle.metrics`,payload:{view:`tasks`,limit:200}}))},[n]),J=(0,b.useCallback)(()=>{n.supportsCapability(`chronicle.status`)&&n.send({type:`chronicle.status`})},[n]);(0,b.useEffect)(()=>{let e=n.on(`chronicle.query_result`,e=>{e.type===`chronicle.query_result`&&(a(e.payload.events),F(e.payload),pe(e.payload.summary??O),R(!1))}),t=n.on(`chronicle.facet_result`,e=>{e.type===`chronicle.facet_result`&&g(t=>({...t,[e.payload.field]:e.payload.values}))}),r=n.on(`chronicle.facets_result`,e=>{e.type===`chronicle.facets_result`&&g(e.payload.values)}),i=n.on(`chronicle.error`,e=>{e.type===`chronicle.error`&&(B(e.payload.message),R(!1))}),o=n.on(`chronicle.graph_result`,e=>{e.type===`chronicle.graph_result`&&V(e.payload)}),s=n.on(`chronicle.metrics_result`,e=>{e.type===`chronicle.metrics_result`&&(e.payload.view===`providers`?he(e.payload.data):e.payload.view===`tasks`&&ge(e.payload.data))}),c=n.on(`chronicle.status_result`,e=>{e.type===`chronicle.status_result`&&_e(e.payload)});return K(G.current),q(),J(),()=>{e(),t(),r(),i(),o(),s(),c()}},[n,K,q,J]);let Y=(0,b.useMemo)(()=>r.filter(e=>le(e,D)),[r,D]),X=re(Y,25,D),Z=(0,b.useMemo)(()=>{let e=r.find(e=>e.eventType===`metrics.rollup`&&e.attributes?.signal===`runtime.health`)?.attributes?.stats;if(!e)return;let t=t=>e[t]?.last;return{eventLoop:{utilization:t(`eventLoop.utilization`),delayP95Ms:t(`eventLoop.delayP95Ms`)},memory:{heapUsedBytes:t(`memory.heapUsedBytes`)},chronicle:{pendingEvents:t(`chronicle.pendingEvents`),rejectedEvents:t(`chronicle.rejectedEvents`)}}},[r]),Q=(0,b.useMemo)(()=>{let e={};for(let t of U)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=[...U].sort((e,t)=>(t.endedAt??t.startedAt??``).localeCompare(e.endedAt??e.startedAt??``)).slice(0,8);return{counts:e,total:U.length,terminal:t,successRate:t>0?n/t*100:100,recent:r}},[U]),$=()=>K({...T(),...w.text?{text:w.text}:{},...w.path?{path:w.path}:{},...w.providerId?{providerId:w.providerId}:{},...w.modelId?{modelId:w.modelId}:{},...w.sessionId?{sessionId:w.sessionId}:{}}),ve=()=>{E({text:``,path:``,providerId:``,modelId:``,sessionId:``}),k(`all`),K(T())},ye=e=>{f(e),V(null),n.supportsCapability(`chronicle.graph`)&&n.send({type:`chronicle.graph`,payload:{seed:{eventId:e.eventId},hops:2,maxNodes:250}})};return(0,x.jsxs)(`div`,{className:`flex h-full min-h-0 bg-background`,"data-testid":`chronicle-dashboard`,children:[(0,x.jsxs)(`main`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,x.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,x.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(p,{className:`h-5 w-5 text-primary`}),(0,x.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight`,children:e(`activity:chronicle.codingIntelligence`)}),(0,x.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:e(`activity:chronicle.chronicle`)})]}),(0,x.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:e(`activity:chronicle.llmAgentToolAndFileEvidence`)})]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(`span`,{className:y(`h-2 w-2 rounded-full`,z?`bg-destructive`:L?`animate-pulse bg-warning`:`bg-success`)}),(0,x.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:L?`Reading journal`:z?`Unavailable`:`Live evidence`}),(0,x.jsx)(`button`,{type:`button`,onClick:()=>{K(v),q(),J()},className:`ml-2 rounded-md border border-border bg-card p-2 hover:bg-muted`,title:e(`activity:chronicle.refreshEvidence`),children:(0,x.jsx)(_,{className:y(`h-4 w-4`,L&&`animate-spin`)})})]})]})}),(0,x.jsxs)(`section`,{className:`grid grid-cols-2 border-b border-border/70 xl:grid-cols-6`,children:[(0,x.jsx)(M,{icon:(0,x.jsx)(p,{}),label:e(`activity:chronicle.llmRequests`),value:I.logicalRequests,detail:`${I.modelAttempts} attempts · ${I.providers} providers · ${I.models} models`}),(0,x.jsx)(M,{icon:(0,x.jsx)(u,{}),label:e(`activity:chronicle.agentWork`),value:I.agentEvents,detail:`${I.uniqueAgents} correlated agents · ${I.decisions} decisions`}),(0,x.jsx)(M,{icon:(0,x.jsx)(l,{}),label:e(`activity:chronicle.toolCalls`),value:I.toolCalls,detail:`${I.failedTools} failed · ${I.processes} processes`}),(0,x.jsx)(M,{icon:(0,x.jsx)(c,{}),label:e(`activity:chronicle.fileEvidence`),value:I.fileEvents,detail:`${I.uniqueFiles} unique paths`}),(0,x.jsx)(M,{icon:(0,x.jsx)(ee,{}),label:e(`activity:chronicle.retries`),value:I.scheduledRetries,detail:`${I.failures} failures · ${I.fallbacks} fallbacks`,tone:I.failures?`danger`:`normal`}),(0,x.jsx)(M,{icon:(0,x.jsx)(i,{}),label:e(`activity:chronicle.providerP95`),value:A(I.providerP95DurationMs),detail:`${A(I.providerAvgDurationMs)} average · all matches`})]}),(0,x.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,x.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-primary`,children:e(`activity:chronicle.tokenEconomics`)}),(0,x.jsxs)(`span`,{children:[e(`activity:chronicle.freshInput`),` `,(0,x.jsx)(`b`,{className:`text-foreground`,children:I.inputTokens.toLocaleString()})]}),(0,x.jsxs)(`span`,{children:[`output `,(0,x.jsx)(`b`,{className:`text-foreground`,children:I.outputTokens.toLocaleString()})]}),(0,x.jsxs)(`span`,{children:[e(`activity:chronicle.cacheRead`),` `,(0,x.jsx)(`b`,{className:`text-foreground`,children:I.cacheReadTokens.toLocaleString()})]}),(0,x.jsxs)(`span`,{children:[`cache write`,` `,(0,x.jsx)(`b`,{className:`text-foreground`,children:I.cacheWriteTokens.toLocaleString()})]}),(0,x.jsxs)(`span`,{children:[e(`activity:chronicle.cacheHit`),` `,(0,x.jsxs)(`b`,{className:`text-foreground`,children:[ce(I).toFixed(1),`%`]})]}),(0,x.jsxs)(`span`,{children:[e(`activity:chronicle.estimatedCost`),` `,(0,x.jsxs)(`b`,{className:`text-foreground`,children:[`$`,I.estimatedCostUsd.toFixed(4)]})]})]}),H.length>0&&(0,x.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,x.jsx)(`span`,{className:`shrink-0 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e(`activity:chronicle.modelReliability`)}),H.slice(0,6).map(e=>{let t=e.completed+e.failed,n=t>0?e.completed/t*100:100;return(0,x.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,x.jsx)(`span`,{className:y(`h-1.5 w-1.5 rounded-full`,n>=99?`bg-success`:n>=90?`bg-warning`:`bg-destructive`)}),(0,x.jsxs)(`span`,{className:`max-w-[180px] truncate`,children:[e.providerId,`/`,e.modelId]}),(0,x.jsxs)(`b`,{className:`text-foreground`,children:[n.toFixed(0),`%`]}),(0,x.jsx)(`span`,{className:`text-muted-foreground`,children:e.day.slice(5)})]},`${e.day}-${e.providerId}-${e.modelId}`)})]}),Q.total>0&&(0,x.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,x.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,x.jsx)(ne,{className:`h-3 w-3`}),e(`activity:chronicle.taskOutcomes`)]}),(0,x.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,x.jsx)(`span`,{className:y(`h-1.5 w-1.5 rounded-full`,Q.successRate>=90?`bg-success`:Q.successRate>=60?`bg-warning`:`bg-destructive`)}),(0,x.jsxs)(`b`,{className:`text-foreground`,children:[Q.successRate.toFixed(0),`%`]}),(0,x.jsxs)(`span`,{className:`text-muted-foreground`,children:[`success · `,Q.total,` tasks`]})]}),[`completed`,`merged`,`failed`,`conflict`,`started`].filter(e=>Q.counts[e]).map(e=>(0,x.jsxs)(`span`,{className:`shrink-0 font-mono text-[9px] text-muted-foreground`,children:[e,` `,(0,x.jsx)(`b`,{className:y(e===`failed`||e===`conflict`?`text-destructive`:`text-foreground`),children:Q.counts[e]})]},e)),(0,x.jsx)(`span`,{className:`mx-1 h-3 w-px shrink-0 bg-border`}),Q.recent.map(e=>(0,x.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,x.jsx)(`span`,{className:y(`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,x.jsx)(`span`,{className:`max-w-[84px] truncate`,children:e.taskId}),e.durationMs!==null&&(0,x.jsx)(`span`,{className:`text-muted-foreground`,children:A(e.durationMs)}),e.filesTouched>0&&(0,x.jsxs)(`span`,{className:`flex items-center gap-0.5 text-muted-foreground`,children:[(0,x.jsx)(c,{className:`h-2.5 w-2.5`}),e.filesTouched]})]},e.taskId))]}),(0,x.jsx)(`section`,{className:`border-b border-border/70 px-4 py-3`,children:(0,x.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 xl:grid-cols-[1.35fr_1fr_1fr_1fr_1fr_auto]`,children:[(0,x.jsx)(j,{icon:(0,x.jsx)(te,{}),placeholder:e(`activity:chronicle.searchEventEvidence`),value:w.text,onChange:e=>E(t=>({...t,text:e})),onEnter:$}),(0,x.jsx)(j,{placeholder:e(`activity:chronicle.fileOrDirectory`),value:w.path,onChange:e=>E(t=>({...t,path:e})),onEnter:$}),(0,x.jsx)(j,{placeholder:e(`activity:chronicle.provider`),value:w.providerId,onChange:e=>E(t=>({...t,providerId:e})),onEnter:$}),(0,x.jsx)(j,{placeholder:e(`activity:chronicle.model`),value:w.modelId,onChange:e=>E(t=>({...t,modelId:e})),onEnter:$}),(0,x.jsx)(j,{placeholder:e(`activity:chronicle.session`),value:w.sessionId,onChange:e=>E(t=>({...t,sessionId:e})),onEnter:$}),(0,x.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,x.jsxs)(`button`,{type:`button`,onClick:$,className:`rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground`,children:[(0,x.jsx)(h,{className:`mr-1 inline h-3 w-3`}),e(`activity:chronicle.apply`)]}),(0,x.jsx)(`button`,{type:`button`,onClick:ve,className:`rounded-md border border-border px-2.5 text-xs hover:bg-muted`,children:e(`activity:chronicle.clear`)})]})]})}),(0,x.jsxs)(`section`,{className:`flex items-center gap-1 overflow-x-auto border-b border-border/70 px-4 py-2`,children:[oe.map(t=>(0,x.jsxs)(`button`,{type:`button`,onClick:()=>k(t.id),className:y(`flex shrink-0 items-center gap-1.5 rounded-md px-2.5 py-1.5 text-[11px] transition-colors [&>svg]:h-3.5 [&>svg]:w-3.5`,D===t.id?`bg-primary/10 font-medium text-primary`:`text-muted-foreground hover:bg-muted hover:text-foreground`),children:[t.icon,e(t.labelKey),(0,x.jsx)(`span`,{className:`ml-1 rounded bg-background/70 px-1 font-mono text-[9px]`,children:se(I,t.id,N.total)})]},t.id)),(0,x.jsxs)(`div`,{className:`ml-auto hidden items-center gap-3 pl-4 text-[9px] text-muted-foreground lg:flex`,children:[(0,x.jsxs)(`span`,{children:[N.total.toLocaleString(),` matched`]}),(0,x.jsxs)(`span`,{children:[N.sourceFiles,` journal files`]}),N.invalidLines>0&&(0,x.jsxs)(`span`,{className:`text-warning`,children:[N.invalidLines,` invalid lines`]})]})]}),W&&(0,x.jsx)(ae,{status:W}),Z&&(0,x.jsx)(ue,{health:Z}),(0,x.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,x.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,x.jsx)(`span`,{className:`mr-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e.replace(`Id`,``)}),(m[e]??[]).slice(0,4).map(t=>(0,x.jsxs)(`button`,{type:`button`,onClick:()=>K({...v,[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,x.jsx)(`b`,{children:t.count})]},t.value))]},e))}),(0,x.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,x.jsx)(`span`,{children:e(`activity:chronicle.time`)}),(0,x.jsx)(`span`,{children:e(`activity:chronicle.signal`)}),(0,x.jsx)(`span`,{children:e(`activity:chronicle.outcome`)}),(0,x.jsx)(`span`,{children:e(`activity:chronicle.modelAgent`)}),(0,x.jsx)(`span`,{children:e(`activity:chronicle.resource`)}),(0,x.jsx)(`span`,{})]}),(0,x.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:z?(0,x.jsx)(P,{text:z}):!L&&Y.length===0?(0,x.jsx)(P,{text:`No coding evidence matches these filters.`}):(0,x.jsx)(`div`,{className:`divide-y divide-border/40`,children:X.pageItems.map(e=>(0,x.jsx)(de,{event:e,active:d?.eventId===e.eventId,onClick:()=>ye(e)},e.eventId))})}),(0,x.jsx)(ie,{page:X.page,pageSize:X.pageSize,totalItems:X.totalItems,onPageChange:X.setPage,itemLabel:`events`})]}),d&&(0,x.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,x.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,x.jsxs)(`div`,{children:[(0,x.jsx)(`div`,{className:`text-xs font-semibold`,children:e(`activity:chronicle.evidenceLineage`)}),(0,x.jsxs)(`div`,{className:`mt-0.5 font-mono text-[9px] text-muted-foreground`,children:[`#`,d.sequence,` · `,d.eventId]})]}),(0,x.jsx)(`button`,{type:`button`,onClick:()=>f(null),className:`rounded p-1 hover:bg-muted`,children:(0,x.jsx)(o,{className:`h-4 w-4`})})]}),(0,x.jsx)(fe,{event:d,graph:me})]})]})}var D={llm:0,agent:0,tool:0,file:0,memory:0,task:0,decision:0,runtime:0},O={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:{...D},failuresByFamily:{...D}};function se(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 ce(e){let t=e.inputTokens+e.cacheReadTokens;return t?e.cacheReadTokens/t*100:0}function le(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,x.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,x.jsx)(`span`,{className:`text-muted-foreground [&>svg]:h-3.5 [&>svg]:w-3.5`,children:i}),(0,x.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,x.jsxs)(`div`,{className:`min-w-0 border-r border-border/60 px-4 py-3`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,x.jsx)(`span`,{className:`text-primary [&>svg]:h-3.5 [&>svg]:w-3.5`,children:e}),t]}),(0,x.jsx)(`div`,{className:y(`mt-1 text-xl font-semibold tabular-nums`,i===`danger`&&`text-destructive`),children:typeof n==`number`?n.toLocaleString():n}),(0,x.jsx)(`div`,{className:`mt-0.5 truncate text-[9px] text-muted-foreground`,children:r})]})}function ue({health:e}){let{t}=s();return(0,x.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,x.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-success`,children:t(`activity:chronicle.collectorHealthy`)}),(0,x.jsxs)(`span`,{children:[`ELU`,` `,(0,x.jsxs)(`b`,{className:`text-foreground`,children:[((e.eventLoop?.utilization??0)*100).toFixed(1),`%`]})]}),(0,x.jsxs)(`span`,{children:[`p95 `,(0,x.jsxs)(`b`,{className:`text-foreground`,children:[(e.eventLoop?.delayP95Ms??0).toFixed(1),`ms`]})]}),(0,x.jsxs)(`span`,{children:[`heap`,` `,(0,x.jsxs)(`b`,{className:`text-foreground`,children:[((e.memory?.heapUsedBytes??0)/1048576).toFixed(0),`MB`]})]}),(0,x.jsxs)(`span`,{children:[`queue `,(0,x.jsx)(`b`,{className:`text-foreground`,children:e.chronicle?.pendingEvents??0})]}),(0,x.jsxs)(`span`,{children:[`dropped`,` `,(0,x.jsx)(`b`,{className:y((e.chronicle?.rejectedEvents??0)>0&&`text-destructive`),children:e.chronicle?.rejectedEvents??0})]})]})}function de({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,x.jsxs)(`button`,{type:`button`,onClick:n,className:y(`grid w-full grid-cols-[92px_minmax(190px,1.25fr)_110px_minmax(180px,1fr)_minmax(140px,.8fr)_24px] items-center gap-3 px-4 py-2.5 text-left hover:bg-muted/45`,t&&`bg-primary/[0.07]`),children:[(0,x.jsx)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:new Date(r).toLocaleTimeString()}),(0,x.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,x.jsx)(`span`,{className:y(`h-1.5 w-1.5 shrink-0 rounded-full`,e.outcome===`failure`?`bg-destructive`:e.outcome===`success`?`bg-success`:`bg-primary`)}),(0,x.jsx)(`span`,{className:`truncate font-mono text-[11px] font-medium`,children:e.eventType})]}),(0,x.jsx)(`span`,{className:y(`w-fit rounded px-1.5 py-0.5 text-[9px]`,F(e.outcome)),children:e.outcome??`unknown`}),(0,x.jsx)(`span`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:i}),(0,x.jsx)(`span`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:a}),(0,x.jsx)(g,{className:`h-3.5 w-3.5 text-muted-foreground`})]})}function fe({event:e,graph:t}){let{t:n}=s(),r=(0,b.useMemo)(()=>[[`Scope`,e.scope],[`Correlation`,e.correlation],[`Runtime`,e.runtime],[`Resource`,e.resource],[`Attributes`,e.attributes],[`Tags`,e.tags]],[e]);return(0,x.jsxs)(`div`,{className:`p-4`,children:[(0,x.jsxs)(`div`,{className:`mb-4 rounded-lg border border-border bg-background/60 p-3`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(`span`,{className:y(`h-2 w-2 rounded-full`,e.outcome===`failure`?`bg-destructive`:e.outcome===`success`?`bg-success`:`bg-primary`)}),(0,x.jsx)(`span`,{className:`font-mono text-xs font-semibold`,children:e.eventType})]}),(0,x.jsxs)(`div`,{className:`mt-2 flex gap-4 text-[9px] text-muted-foreground`,children:[(0,x.jsx)(`span`,{children:new Date(e.occurredAt??e.observedAt).toLocaleString()}),(0,x.jsx)(`span`,{children:k(Number(e.durationNs??0))})]})]}),(0,x.jsxs)(`div`,{className:`mb-4 grid grid-cols-2 gap-2`,children:[(0,x.jsx)(N,{icon:(0,x.jsx)(a,{}),label:n(`activity:chronicle.evidenceHash`),value:e.hash.slice(0,16)}),(0,x.jsx)(N,{icon:(0,x.jsx)(d,{}),label:n(`activity:chronicle.sequence`),value:String(e.sequence)})]}),t&&(0,x.jsxs)(`section`,{className:`mb-4`,children:[(0,x.jsxs)(`h3`,{className:`mb-1.5 flex items-center gap-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,x.jsx)(v,{className:`h-3 w-3`}),`Lineage · `,t.nodes.length,` nodes · `,t.edges.length,` edges`]}),(0,x.jsx)(`div`,{className:`space-y-1 rounded-md border border-border bg-background/70 p-2`,children:t.edges.slice(0,40).map((e,n)=>(0,x.jsxs)(`div`,{className:`flex items-center gap-2 font-mono text-[9px]`,children:[(0,x.jsx)(`span`,{className:y(`rounded px-1`,e.confidence===`explicit`?`bg-success/10 text-success`:e.confidence===`inferred`?`bg-warning/10 text-warning`:`bg-primary/10 text-primary`),children:e.confidence}),(0,x.jsx)(`span`,{className:`text-muted-foreground`,children:e.kind}),(0,x.jsxs)(`span`,{className:`truncate`,children:[t.nodes.find(t=>t.eventId===e.from)?.eventType,` →`,` `,t.nodes.find(t=>t.eventId===e.to)?.eventType]})]},`${e.from}-${e.to}-${e.kind}-${n}`))}),t.truncated&&(0,x.jsx)(`p`,{className:`mt-1 text-[9px] text-warning`,children:n(`activity:chronicle.lineageTruncatedAtSafetyLimit`)})]}),r.map(([e,t])=>t&&(0,x.jsxs)(`section`,{className:`mb-4`,children:[(0,x.jsx)(`h3`,{className:`mb-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e}),(0,x.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 N({icon:e,label:t,value:n}){return(0,x.jsxs)(`div`,{className:`rounded-md border border-border p-2`,children:[(0,x.jsxs)(`div`,{className:`flex items-center gap-1 text-[8px] uppercase text-muted-foreground`,children:[(0,x.jsx)(`span`,{className:`[&>svg]:h-3 [&>svg]:w-3`,children:e}),t]}),(0,x.jsx)(`div`,{className:`mt-1 truncate font-mono text-[9px]`,children:n})]})}function P({text:e}){return(0,x.jsx)(`div`,{className:`flex h-48 items-center justify-center text-sm text-muted-foreground`,children:e})}function F(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{E as ChronicleDashboard};
@@ -1,2 +1,2 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{K as t,rt as n,t as r}from"./config-store-CZdk-vPj.js";import{i,t as a}from"./react-core-wiHys0m2.js";import{$r as o,Bi as s,Ht as c,It as l,J as u,Jn as d,Ki as f,La as p,Tt as m,Vn as h,Vr as g,Xi as _,Xr as v,Yi as y,Yn as b,Yr as x,ca as S,gi as C,gt as w,ia as T,ja as E,ji as D,nt as O,rn as k,wr as ee}from"./vendor-Cvuk-OYN.js";import"./i18n-BwptPW9U.js";import{t as A}from"./utils-sO9lidp6.js";import{o as j}from"./view-navigation-BDsXeQ5i.js";import{S as M,b as N,h as P,o as F}from"./stores-Bt7wAdGA.js";import{i as I}from"./codemap-activity-store-RqE4L9Os.js";import{F as L,P as te,y as R}from"./index-BYBlSXtn.js";import{a as z,c as B,i as V,n as H,o as U,s as W,t as G}from"./monaco-COtIgMfE.js";import{t as K}from"./empty-state-BFPCt03_.js";import{t as q}from"./monaco-theme-ruX2YdTu.js";import{t as ne}from"./MemoryDrawer-C72rzAy0.js";var J={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`},Y=Array.from(new Set(Object.values(J))).filter(e=>e!==`plaintext`),re=12e3,ie=4e3,ae=5e3,oe=1e4;function se(e){return J[e.split(`.`).pop()?.toLowerCase()??``]??`plaintext`}function ce(e){return e.match(/([A-Za-z_$][\w$]*)$/)?.[1]??``}function le(e,t){return e.triggerCharacter?!0:t.length>=3}function ue(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 de(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 X=e(i(),1);function fe(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 pe=/(write|edit|update|create|delete|rename|modified|changed)/i;function me(e){return e.replace(/\\/g,`/`).replace(/^\.\//,``).replace(/\/{2,}/g,`/`).toLowerCase()}function Z(e,t){let n=me(e),r=me(t);return n===r||n.endsWith(`/${r}`)||r.endsWith(`/${n}`)}function he(e,t=Date.now()){let n=e.filter(e=>t-e.at<=18e5),r=n.filter(e=>pe.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 Q(e){return typeof e==`string`&&e.length>0?e:void 0}function ge(e){let t=Date.parse(e.occurredAt??e.observedAt);return Number.isFinite(t)?t:Date.now()}function _e(e){let t=e.attributes??{},n=Q(t.operation)??e.eventType,r=e.scope.agentId,i=e.runtime?.providerId,a=e.runtime?.modelId;return{id:e.eventId,at:ge(e),action:n,actor:r??i??Q(t.actor)??`external`,source:Q(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??Q(t.taskId),boardId:Q(t.boardId)??e.scope.boardId,tool:Q(t.toolName),status:e.outcome,raw:e}}function ve(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 ye(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)&&(t.add(n),!0)})}function be(e){return e?e.split(/\r?\n/).length:0}function xe(e){return new TextEncoder().encode(e).length}function Se(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function Ce(e){return e.length>18?`${e.slice(0,8)}…${e.slice(-6)}`:e}function we(e,t){let n=L(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}}var $=a();function Te({text:e}){return(0,$.jsx)(`div`,{className:`px-3 py-3 text-center text-[10px] text-muted-foreground`,children:e})}function Ee({record:e,raw:t=!1}){let n=new Date(e.at).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}),r=(0,$.jsxs)(`div`,{className:`grid grid-cols-[62px_74px_minmax(90px,.7fr)_minmax(160px,1.5fr)] items-center gap-2 text-[9px]`,children:[(0,$.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:n}),(0,$.jsx)(`span`,{className:A(`w-fit rounded px-1.5 py-0.5 font-mono`,pe.test(e.action)?`bg-warning/10 text-warning`:`bg-primary/10 text-primary`),children:e.action}),(0,$.jsx)(`span`,{className:`truncate`,title:e.agentId,children:e.actor}),(0,$.jsx)(`span`,{className:`truncate text-muted-foreground`,title:e.summary,children:e.summary})]});return t?(0,$.jsxs)(`details`,{className:`group cursor-pointer px-2.5 py-1.5`,children:[(0,$.jsx)(`summary`,{className:`list-none [&::-webkit-details-marker]:hidden`,children:r}),(0,$.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,$.jsx)(`div`,{className:`px-2.5 py-1.5`,children:r})}function De({records:e,loading:t}){let{t:n}=p();return t&&e.length===0?(0,$.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-[10px] text-muted-foreground`,children:[(0,$.jsx)(d,{className:`h-3.5 w-3.5 animate-spin`}),n(`activity:fileActivity.loadingEvidence`)]}):e.length===0?(0,$.jsx)(Te,{text:n(`activity:fileActivity.noEvidence`)}):(0,$.jsx)(`div`,{className:`divide-y divide-border/40`,children:e.map(e=>(0,$.jsx)(Ee,{record:e,raw:!0},`${e.id}:${e.at}`))})}function Oe({title:e,subtitle:t,raw:n}){return(0,$.jsxs)(`div`,{className:`rounded-md border border-border/60 bg-background/45 px-2 py-1.5`,title:n,children:[(0,$.jsx)(`div`,{className:`truncate text-[10px] font-medium`,children:e}),(0,$.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[8px] text-muted-foreground`,children:t})]})}function ke({icon:e,title:t,empty:n,children:r}){let i=Array.isArray(r)?r.length>0:!!r;return(0,$.jsxs)(`section`,{className:`min-w-0 p-2`,children:[(0,$.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,$.jsx)(`div`,{className:`space-y-1`,children:i?r:(0,$.jsx)(Te,{text:n})})]})}function Ae({sessions:e,agents:t,tasks:n,records:r,taskLabel:i,boardTitle:a}){let{t:o}=p();return(0,$.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,$.jsx)(ke,{icon:(0,$.jsx)(O,{}),title:o(`activity:fileActivity.sessions`),empty:o(`activity:fileActivity.noSessions`),children:e.map(e=>(0,$.jsx)(Oe,{title:Ce(e),subtitle:`${r.filter(t=>t.sessionId===e).length} ${o(`activity:fileActivity.events`)}`,raw:e},e))}),(0,$.jsx)(ke,{icon:(0,$.jsx)(S,{}),title:o(`activity:fileActivity.actors`),empty:o(`activity:fileActivity.noActors`),children:t.map(e=>(0,$.jsx)(Oe,{title:e,subtitle:`${r.filter(t=>t.actor===e).length} ${o(`activity:fileActivity.events`)}`},e))}),(0,$.jsx)(ke,{icon:(0,$.jsx)(b,{}),title:o(`activity:fileActivity.workLinks`),empty:o(`activity:fileActivity.noWorkLinks`),children:n.map(e=>(0,$.jsx)(Oe,{title:i(e),subtitle:a??o(`activity:fileActivity.taskOrTodo`),raw:e},e))})]})}function je({lifetime:e}){let{t}=p(),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,$.jsxs)(`div`,{className:`rounded-md border border-primary/15 bg-primary/[0.03] px-2.5 py-2`,children:[(0,$.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,$.jsx)(o,{}),t(`activity:fileActivity.lifetimeTitle`)]}),(0,$.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,$.jsxs)(`span`,{children:[(0,$.jsx)(`b`,{className:`text-foreground`,children:e.value.toLocaleString()}),` `,e.label]},e.label)),r&&(0,$.jsx)(`span`,{children:t(`activity:fileActivity.lifetimeSince`,{date:r})})]}),e.tools.length>0&&(0,$.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 Me({analysis:e,lifetime:t,records:n,sessions:r,agents:i,tasks:a,taskLabel:o}){let{t:s}=p(),c=[{label:s(`activity:fileActivity.mutations30m`),value:e.mutationCount,icon:(0,$.jsx)(x,{})},{label:s(`activity:fileActivity.sessions`),value:r.length,icon:(0,$.jsx)(O,{})},{label:s(`activity:fileActivity.actors`),value:i.length,icon:(0,$.jsx)(S,{})},{label:s(`activity:fileActivity.linkedWork`),value:a.length,icon:(0,$.jsx)(b,{})}];return(0,$.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,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:`grid grid-cols-4 gap-1.5`,children:c.map(e=>(0,$.jsxs)(`div`,{className:`rounded-md border border-border/70 bg-background/45 px-2 py-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 text-[9px] text-muted-foreground [&>svg]:h-3 [&>svg]:w-3`,children:[e.icon,(0,$.jsx)(`span`,{className:`truncate`,children:e.label})]}),(0,$.jsx)(`div`,{className:`mt-0.5 font-mono text-sm font-semibold`,children:e.value})]},e.label))}),t.mutations>0&&(0,$.jsx)(je,{lifetime:t}),(0,$.jsxs)(`div`,{className:A(`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,$.jsx)(l,{className:A(`mt-0.5 h-3.5 w-3.5 shrink-0`,e.level===`churn`?`text-destructive`:`text-primary`)}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`font-semibold`,children:s(`activity:fileActivity.analysisTitle.${e.level}`)}),(0,$.jsx)(`p`,{className:`mt-0.5 text-muted-foreground`,children:s(`activity:fileActivity.analysisBody.${e.level}`,{mutations:e.mutationCount,actors:e.actorCount,sessions:e.sessionCount})})]})]}),a.length>0&&(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 text-[9px]`,children:[(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[s(`activity:fileActivity.workLinks`),`:`]}),a.slice(0,4).map(e=>(0,$.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:o(e)},e))]})]}),(0,$.jsxs)(`div`,{className:`min-w-0 rounded-md border border-border/70 bg-background/35`,children:[(0,$.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:s(`activity:fileActivity.recentActivity`)}),(0,$.jsx)(`div`,{className:`divide-y divide-border/40`,children:n.length===0?(0,$.jsx)(Te,{text:s(`activity:fileActivity.noEvidence`)}):n.slice(0,5).map(e=>(0,$.jsx)(Ee,{record:e},`${e.id}:${e.at}`))})]})]})}function Ne({file:e}){let i=r(e=>e.wsUrl),a=n(e=>e.jumpToLine),o=(0,X.useMemo)(()=>t(i),[i]),[s,c]=(0,X.useState)(``),[l,u]=(0,X.useState)(null),[f,p]=(0,X.useState)(``),[m,h]=(0,X.useState)(!0),[g,y]=(0,X.useState)(null),[b,x]=(0,X.useState)(!1),[S,w]=(0,X.useState)(!1),[T,E]=(0,X.useState)(!0),D=(0,X.useCallback)(()=>{h(!0),y(null),o.send({type:`files.skeleton`,payload:{filePath:e.path,content:e.content,options:{collapseImports:S,includeDocs:T}}})},[o,e.path,e.content,S,T]);(0,X.useEffect)(()=>{let t=o.on(`files.skeleton_result`,t=>{if(t.type===`files.skeleton_result`&&t.payload.filePath===e.path){if(h(!1),t.payload.error){y(t.payload.error);return}c(t.payload.skeleton),t.payload.stats&&u(t.payload.stats),t.payload.lang&&p(t.payload.lang)}});return D(),()=>{t()}},[o,e.path,D]);let O=async()=>{if(s)try{await navigator.clipboard.writeText(s),x(!0),setTimeout(()=>x(!1),2e3)}catch{}},ee=(e,t)=>{let n=e.match(/(?:\/\*\s*L(\d+)(?:-L\d+)?\s*\*\/|#\s*L(\d+)(?:-L\d+)?)/),r=n?parseInt(n[1]||n[2]||`0`,10):null;return r&&r>0?(0,$.jsxs)(`div`,{className:`group flex items-center justify-between gap-2 rounded px-1.5 py-0.5 hover:bg-primary/10 transition-colors`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:e}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>a(r),className:`shrink-0 cursor-pointer rounded bg-primary/20 px-1.5 py-0.5 font-mono text-[9px] font-semibold text-primary opacity-75 group-hover:opacity-100 hover:bg-primary hover:text-primary-foreground transition-all`,title:`Jump to line ${r} in editor`,children:[`Jump to L`,r,` →`]})]},t):(0,$.jsx)(`div`,{className:`px-1.5 py-0.5 whitespace-pre`,children:e},t)};return(0,$.jsxs)(`div`,{className:`flex h-full min-h-[140px] flex-col p-2`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center justify-between gap-2 border-b border-border/50 pb-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-primary/10 px-2 py-0.5 font-mono text-[10px] font-semibold uppercase text-primary`,children:[(0,$.jsx)(v,{className:`h-3 w-3`}),f||`AST`]}),l&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`span`,{className:`rounded bg-success/10 px-1.5 py-0.5 font-mono text-[10px] font-medium text-success`,children:[`-`,l.tokenSavingsPercent,`% Tokens`]}),(0,$.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[l.originalLines,` → `,l.skeletonLines,` lines`]}),(0,$.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`(`,l.symbolCount,` symbols)`]})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px]`,children:[(0,$.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-1 text-muted-foreground hover:text-foreground`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:S,onChange:e=>w(e.target.checked),className:`rounded border-border`}),(0,$.jsx)(`span`,{children:`Collapse imports`})]}),(0,$.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-1 text-muted-foreground hover:text-foreground`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:T,onChange:e=>E(e.target.checked),className:`rounded border-border`}),(0,$.jsx)(`span`,{children:`Include docs`})]}),(0,$.jsx)(`button`,{type:`button`,onClick:D,className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,title:`Refresh Skeleton`,children:(0,$.jsx)(k,{className:A(`h-3.5 w-3.5`,m&&`animate-spin`)})}),(0,$.jsxs)(`button`,{type:`button`,onClick:O,disabled:!s,className:`inline-flex items-center gap-1 rounded bg-secondary px-2 py-1 text-[10px] font-medium text-secondary-foreground hover:bg-secondary/80 disabled:opacity-50`,children:[b?(0,$.jsx)(_,{className:`h-3 w-3 text-success`}):(0,$.jsx)(C,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{children:b?`Copied`:`Copy`})]})]})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto rounded border border-border/60 bg-muted/20 p-2 font-mono text-[11px] leading-relaxed`,children:m&&!s?(0,$.jsxs)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:[(0,$.jsx)(d,{className:`mr-2 h-4 w-4 animate-spin text-primary`}),(0,$.jsx)(`span`,{children:`Extracting AST Skeleton…`})]}):g?(0,$.jsx)(`div`,{className:`p-4 text-warning`,children:g}):(0,$.jsx)(`div`,{className:`font-mono select-text`,children:s.split(`
2
- `).map((e,t)=>ee(e,t))})})]})}function Pe({label:e}){return(0,$.jsx)(`span`,{className:`hidden whitespace-nowrap font-mono text-[9px] text-muted-foreground sm:inline`,children:e})}function Fe({file:e}){let{t:n}=p(),[i,a]=(0,X.useState)(!0),[c,l]=(0,X.useState)(224),[u,d]=(0,X.useState)(`overview`),[h,g]=(0,X.useState)([]),[_,S]=(0,X.useState)([]),[C,w]=(0,X.useState)(!1),[D,O]=(0,X.useState)(null),[j,M]=(0,X.useState)(null),N=(0,X.useRef)(null),L=r(e=>e.wsUrl),R=I(e=>e.history),z=I(e=>e.activeOperations),B=P(e=>e.activeBoard),V=F(e=>e.snapshot),H=(0,X.useMemo)(()=>t(L),[L]),U=(0,X.useCallback)(()=>{O(null),w(!0),typeof H.getGitDiff==`function`&&H.getGitDiff(e.path);let t=typeof H.supportsCapability==`function`?H.supportsCapability.bind(H):null;t?.(`chronicle.query`)?H.send({type:`chronicle.query`,payload:{query:{path:e.path,resourceKind:`file`,order:`desc`,limit:150}}}):w(!1),t?.(`chronicle.metrics`)&&H.send({type:`chronicle.metrics`,payload:{view:`files`,path:e.path,limit:1e3}})},[H,e.path]);(0,X.useEffect)(()=>{g([]),S([]),M(null);let t=H.on(`chronicle.query_result`,t=>{if(t.type!==`chronicle.query_result`)return;let n=t.payload.events.filter(t=>t.resource?.path&&Z(t.resource.path,e.path));t.payload.events.length>0&&n.length===0||(g(n),w(!1))}),n=H.on(`chronicle.metrics_result`,t=>{t.type===`chronicle.metrics_result`&&t.payload.view===`files`&&S(t.payload.data.filter(t=>Z(t.path,e.path)))}),r=H.on(`chronicle.error`,e=>{e.type===`chronicle.error`&&(O(e.payload.message),w(!1))}),i=H.on(`git.diff`,t=>{if(t.type!==`git.diff`||!Z(t.payload.path,e.path))return;let n=t.payload;if(n.error||n.binary||n.tooLarge){M({text:e.savedContent,available:!1,error:n.error});return}M({text:n.oldText??``,available:!0})});return U(),()=>{t(),n(),r(),i()}},[H,e.path,e.savedContent,U]),(0,X.useEffect)(()=>{let e=e=>{if(!N.current)return;let t=N.current.startY-e.clientY,n=Math.max(150,Math.floor(window.innerHeight*.62));l(Math.min(n,Math.max(150,N.current.startHeight+t)))},t=()=>{N.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 W=(0,X.useMemo)(()=>{let t=[];for(let[n,r]of R)Z(n,e.path)&&t.push(...r);for(let n of z.values())t.push(...n.filter(t=>Z(t.filePath,e.path)));return t},[z,e.path,R]),G=(0,X.useMemo)(()=>ye([...W.map(ve),...h.map(_e)]),[h,W]),K=(0,X.useMemo)(()=>he(G),[G]),q=(0,X.useMemo)(()=>fe(_),[_]),J=j?.text??e.savedContent,Y=(0,X.useMemo)(()=>we(J,e.content),[J,e.content]),re=(0,X.useMemo)(()=>[...new Set(G.map(e=>e.sessionId).filter(e=>!!e))],[G]),ie=(0,X.useMemo)(()=>[...new Set(G.map(e=>e.actor).filter(Boolean))],[G]),ae=(0,X.useMemo)(()=>[...new Set(G.map(e=>e.taskId).filter(e=>!!e))],[G]),oe=(0,X.useCallback)(e=>{let t=B?.tasks.find(t=>t.id===e),n=V?.tasks.find(t=>t.id===e||t.shortId===e);return t?.title??n?.title??e},[B,V]),se=e=>{i||a(!0),N.current={startY:e.clientY,startHeight:i?c:150},document.body.style.cursor=`ns-resize`,document.body.style.userSelect=`none`},ce=[{id:`overview`,label:n(`activity:fileActivity.overview`),icon:(0,$.jsx)(E,{})},{id:`changes`,label:n(`activity:fileActivity.changes`),icon:(0,$.jsx)(x,{})},{id:`skeleton`,label:`Skeleton`,icon:(0,$.jsx)(v,{})},{id:`context`,label:n(`activity:fileActivity.context`),icon:(0,$.jsx)(b,{})},{id:`logs`,label:n(`activity:fileActivity.logs`),icon:(0,$.jsx)(m,{})},{id:`memory`,label:n(`activity:fileActivity.memory`),icon:(0,$.jsx)(T,{})}];return(0,$.jsxs)(`section`,{className:`flex shrink-0 flex-col overflow-hidden border-t border-border bg-card/95 shadow-[0_-10px_30px_hsl(var(--background)/0.24)] backdrop-blur`,style:{height:i?c:38},"data-testid":`file-activity-drawer`,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":n(`activity:fileActivity.resizeHint`),className:`group relative block h-2 w-full cursor-ns-resize touch-none`,onPointerDown:se,onDoubleClick:()=>{a(!0),l(224)},title:n(`activity:fileActivity.resizeHint`),children:(0,$.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,$.jsxs)(`header`,{className:`flex h-[30px] min-w-0 items-center gap-2 border-b border-border/70 px-2.5`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`inline-flex min-w-0 items-center gap-1.5 rounded px-1.5 py-1 text-[11px] font-semibold hover:bg-muted`,"aria-expanded":i,children:[(0,$.jsx)(o,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,$.jsx)(`span`,{className:`truncate`,children:n(`activity:fileActivity.title`)}),i?(0,$.jsx)(y,{className:`h-3 w-3`}):(0,$.jsx)(f,{className:`h-3 w-3`})]}),(0,$.jsx)(`span`,{className:`hidden h-3 w-px bg-border sm:block`}),(0,$.jsx)(Pe,{label:`${be(e.content)} ${n(`activity:fileActivity.lines`)}`}),(0,$.jsx)(Pe,{label:Se(xe(e.content))}),!Y.large&&(Y.added>0||Y.removed>0)&&(0,$.jsxs)(`span`,{className:`hidden items-center gap-1 font-mono text-[10px] md:flex`,children:[(0,$.jsxs)(`span`,{className:`text-success`,children:[`+`,Y.added]}),(0,$.jsxs)(`span`,{className:`text-destructive`,children:[`−`,Y.removed]})]}),(0,$.jsxs)(`span`,{className:A(`ml-auto inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[9px] font-semibold uppercase tracking-wide`,K.level===`churn`&&`bg-destructive/10 text-destructive`,K.level===`active`&&`bg-warning/10 text-warning`,K.level===`quiet`&&`bg-success/10 text-success`),children:[(0,$.jsx)(s,{className:`h-2.5 w-2.5`}),n(`activity:fileActivity.level.${K.level}`)]}),(0,$.jsx)(`span`,{className:`hidden text-[9px] text-muted-foreground lg:inline`,children:n(`activity:fileActivity.evidenceCount`,{count:G.length})}),i&&(0,$.jsx)(`button`,{type:`button`,onClick:U,className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,title:n(`activity:fileActivity.refresh`),children:(0,$.jsx)(k,{className:A(`h-3.5 w-3.5`,C&&`animate-spin`)})})]}),i&&(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,$.jsxs)(`nav`,{className:`flex shrink-0 items-center gap-0.5 border-b border-border/60 bg-muted/20 px-2`,children:[ce.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>d(e.id),className:A(`inline-flex h-7 items-center gap-1.5 border-b-2 px-2 text-[10px] transition-colors [&>svg]:h-3 [&>svg]:w-3`,u===e.id?`border-primary font-medium text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`),children:[e.icon,e.label]},e.id)),D&&(0,$.jsx)(`span`,{className:`ml-auto truncate px-2 text-[9px] text-warning`,children:D})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[u===`overview`&&(0,$.jsx)(Me,{analysis:K,lifetime:q,records:G,sessions:re,agents:ie,tasks:ae,taskLabel:oe}),u===`changes`&&(0,$.jsxs)(`div`,{className:`h-full min-h-[120px] p-2`,children:[(0,$.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2 text-[9px] text-muted-foreground`,children:[(0,$.jsx)(ee,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{children:j?.available?n(`activity:fileActivity.gitToBuffer`):n(`activity:fileActivity.savedToBuffer`)}),e.dirty&&(0,$.jsx)(`span`,{className:`rounded bg-warning/10 px-1.5 py-0.5 text-warning`,children:n(`activity:fileActivity.unsaved`)}),j?.error&&(0,$.jsx)(`span`,{className:`truncate text-warning`,children:j.error})]}),(0,$.jsx)(`div`,{className:`h-[calc(100%-24px)] min-h-[90px]`,children:(0,$.jsx)(te,{oldText:J,newText:e.content,caption:e.path,fill:!0})})]}),u===`skeleton`&&(0,$.jsx)(Ne,{file:e}),u===`context`&&(0,$.jsx)(Ae,{sessions:re,agents:ie,tasks:ae,records:G,taskLabel:oe,boardTitle:B?.title??V?.title}),u===`logs`&&(0,$.jsx)(De,{records:G,loading:C}),u===`memory`&&(0,$.jsx)(`div`,{className:`h-full min-h-[120px]`,children:(0,$.jsx)(ne,{filePath:e.path,open:!0,onClose:()=>d(`overview`)})})]})]})]})}V.config({monaco:G});function Ie(e){switch(e){case`method`:return B.CompletionItemKind.Method;case`function`:return B.CompletionItemKind.Function;case`constructor`:return B.CompletionItemKind.Constructor;case`field`:return B.CompletionItemKind.Field;case`variable`:return B.CompletionItemKind.Variable;case`class`:return B.CompletionItemKind.Class;case`interface`:return B.CompletionItemKind.Interface;case`module`:return B.CompletionItemKind.Module;case`property`:return B.CompletionItemKind.Property;case`unit`:return B.CompletionItemKind.Unit;case`value`:return B.CompletionItemKind.Value;case`enum`:return B.CompletionItemKind.Enum;case`keyword`:return B.CompletionItemKind.Keyword;case`snippet`:return B.CompletionItemKind.Snippet;case`file`:return B.CompletionItemKind.File;case`reference`:return B.CompletionItemKind.Reference;default:return B.CompletionItemKind.Text}}function Le(){let e=n(e=>e.openFiles),t=n(e=>e.activeFilePath),r=n(e=>e.setActiveFile),i=n(e=>e.closeFile);return e.length===0?null:(0,$.jsx)(`div`,{className:`flex items-center border-b bg-muted/40 overflow-x-auto shrink-0`,children:e.map(e=>{let n=e.path===t,a=e.path.split(`/`).pop()??e.path;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>r(e.path),onMouseDown:t=>{t.button===1&&(t.preventDefault(),i(e.path))},className:A(`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`,n?`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,$.jsx)(D,{className:`h-2 w-2 fill-current text-primary shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:a}),(0,$.jsx)(u,{className:A(`h-3 w-3 shrink-0 rounded-sm hover:bg-muted-foreground/20 opacity-0 group-hover:opacity-100 transition-opacity`,n&&`opacity-100`),onClick:t=>{t.stopPropagation(),i(e.path)}})]},e.path)})})}function Re(){let{t:e}=p(),i=n(e=>e.openFiles),a=n(e=>e.activeFilePath),o=n(e=>e.updateContent),{theme:s}=R(),l=(0,X.useRef)(null),u=(0,X.useRef)(a),d=(0,X.useRef)(new Map),f=(0,X.useMemo)(()=>i.find(e=>e.path===a)??null,[i,a]),m=a?se(a):`plaintext`,_=q(),[v,y]=(0,X.useState)(!1),[b,x]=(0,X.useState)({line:1,col:1}),[S,C]=(0,X.useState)(!1),[T,E]=(0,X.useState)(!1),D=N(e=>e.info?.branch);(0,X.useEffect)(()=>{u.current=a},[a]),(0,X.useEffect)(()=>{let e=q();W.setTheme(e)},[s]);let O=n(e=>e.targetLine),k=n(e=>e.clearTargetLine);(0,X.useEffect)(()=>{O&&l.current&&(l.current.revealLineInCenter(O.line),l.current.setPosition({lineNumber:O.line,column:O.col??1}),l.current.focus(),k())},[O,k]),(0,X.useEffect)(()=>{let e=Y.map(e=>B.registerCompletionItemProvider(e,{triggerCharacters:[`.`,`_`],provideCompletionItems:async(e,n,i,a)=>{let o=u.current;if(!o)return{suggestions:[]};let s=e.getOffsetAt(n),c=e.getValue(),l=c.slice(Math.max(0,s-re),s),f=c.slice(s,s+ie),p=e.getLineContent(n.lineNumber).slice(0,Math.max(0,n.column-1)),m=ce(p),h={triggerCharacter:i.triggerCharacter,triggerKind:i.triggerKind};if(!le(h,m))return{suggestions:[]};let g=`cmp_${Date.now()}_${Math.random().toString(36).slice(2)}`,_=e.getWordUntilPosition(n),v={startLineNumber:n.lineNumber,endLineNumber:n.lineNumber,startColumn:_.startColumn,endColumn:n.column},y=t(r.getState().wsUrl),b=e=>e.map((e,t)=>({label:e.label,kind:Ie(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:v,insertTextRules:e.kind===`snippet`?B.CompletionItemInsertTextRule.InsertAsSnippet:void 0})),x=de({filePath:o,language:e.getLanguageId(),lineNumber:n.lineNumber,column:n.column,versionId:e.getVersionId(),triggerCharacter:i.triggerCharacter,linePrefix:p,suffix:f}),S=d.current.get(x);return S&&S.expiresAt>Date.now()?{suggestions:b(S.items)}:await new Promise(t=>{let r=!1,s=()=>{},u=null,p,_=e=>{r||(r=!0,s(),p!==void 0&&window.clearTimeout(p),u?.dispose(),t({suggestions:e}))};s=y.on(`completion.result`,e=>{let t=e;t.payload.requestId===g&&(d.current.set(x,{expiresAt:Date.now()+oe,items:t.payload.items}),_(b(t.payload.items)))}),p=window.setTimeout(()=>_([]),ae),u=a.onCancellationRequested(()=>_([])),y.requestCompletion({requestId:g,filePath:o,language:e.getLanguageId(),lineNumber:n.lineNumber,column:n.column,content:c.length<=5e5?c:void 0,prefix:l,suffix:f,triggerCharacter:i.triggerCharacter,triggerKind:i.triggerKind,allowLlm:ue(h,m)})})}}));return()=>{e.forEach(e=>{e.dispose()})}},[]);let P=(0,X.useCallback)(()=>{let e=l.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},[]),F=(0,X.useCallback)(()=>{j(`chat`),requestAnimationFrame(()=>{document.querySelector(`[data-chat-textarea]`)?.focus()})},[]),I=(0,X.useCallback)(()=>{let e=u.current;if(!e)return;let t=P();t&&(M.getState().addRef({kind:`snippet`,path:e,startLine:t.startLine,endLine:t.endLine,content:t.content}),F())},[P,F]),L=(0,X.useCallback)(()=>{let e=u.current;e&&(M.getState().addRef({kind:`file`,path:e}),F())},[F]),te=(0,X.useCallback)(t=>{l.current=t,W.setTheme(q()),t.onDidChangeCursorSelection?.(()=>{let e=t.getSelection();y(!!e&&!e.isEmpty())}),t.onDidChangeCursorPosition?.(e=>{e?.position&&x({line:e.position.lineNumber,col:e.position.column})}),t.addAction({id:`wrongstack-send-to-chat`,label:e(`activity:codeEditor.sendSelectionAction`),contextMenuGroupId:`wrongstack`,contextMenuOrder:0,precondition:void 0,keybindings:[U.CtrlCmd|U.Shift|z.KeyL],run:e=>{let t=e.getSelection();t&&!t.isEmpty()?I():L()}})},[I,L]),V=(0,X.useCallback)(e=>{a&&e!==void 0&&o(a,e)},[a,o]);return(0,X.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:a}}))),e.key.toLowerCase()===`w`&&(e.preventDefault(),a&&n.getState().closeFile(a)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[a]),i.length===0?(0,$.jsx)(K,{title:e(`activity:codeEditor.noFilesOpen`),description:e(`activity:codeEditor.selectToEdit`)}):(0,$.jsxs)(`div`,{className:`flex h-full min-w-0 flex-col overflow-hidden`,children:[(0,$.jsx)(Le,{}),(0,$.jsxs)(`div`,{className:`relative min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(v||f)&&(0,$.jsxs)(`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,$.jsxs)(`button`,{type:`button`,onClick:()=>C(e=>!e),className:A(`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[11px] transition-colors`,S?`bg-primary/20 text-primary font-medium`:`text-muted-foreground hover:text-foreground hover:bg-accent`),title:S?`Disable word wrap`:`Enable word wrap`,children:[(0,$.jsx)(w,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{children:`Wrap`})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>E(e=>!e),className:A(`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[11px] transition-colors`,T?`bg-primary/20 text-primary font-medium`:`text-muted-foreground hover:text-foreground hover:bg-accent`),title:T?`Hide minimap`:`Show minimap`,children:[(0,$.jsx)(h,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{children:`Map`})]}),(0,$.jsx)(`div`,{className:`h-3.5 w-px bg-border/80 mx-0.5`}),(0,$.jsxs)(`button`,{type:`button`,onClick:v?I:L,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(v?`activity:codeEditor.sendSelectedTitle`:`activity:codeEditor.mentionFileTitle`),children:[v?(0,$.jsx)(c,{className:`h-3 w-3`}):(0,$.jsx)(g,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{children:e(v?`activity:codeEditor.sendToChat`:`activity:codeEditor.mentionFile`)})]})]}),f?(0,$.jsx)(H,{language:m,value:f.content,onChange:V,theme:_,onMount:te,loading:(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground animate-pulse`,children:e(`activity:codeEditor.loadingEditor`)})}),options:{minimap:{enabled:T},fontSize:13,fontFamily:`'IBM Plex Mono', 'Cascadia Code', 'Fira Code', 'JetBrains Mono', monospace`,lineNumbers:`on`,renderWhitespace:`selection`,scrollBeyondLastLine:!1,wordWrap:S?`on`:`off`,tabSize:2,smoothScrolling:!0,cursorBlinking:`smooth`,cursorSmoothCaretAnimation:`on`,bracketPairColorization:{enabled:!0},"semanticHighlighting.enabled":!0,automaticLayout:!0,padding:{top:8}}},f.path):(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e(`activity:codeEditor.selectTab`)})})]}),f&&(0,$.jsxs)(`div`,{className:`flex h-6 shrink-0 items-center justify-between border-t border-border/70 bg-muted/30 px-3 text-[11px] text-muted-foreground font-mono select-none`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[D&&(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-foreground/80 font-medium`,children:[(0,$.jsx)(ee,{className:`h-3 w-3 text-primary shrink-0`}),(0,$.jsx)(`span`,{className:`truncate max-w-[140px]`,children:D})]}),(0,$.jsx)(`span`,{className:`truncate max-w-[320px] text-muted-foreground`,children:f.path})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,$.jsxs)(`span`,{children:[`Ln `,b.line,`, Col `,b.col]}),(0,$.jsx)(`span`,{children:`UTF-8`}),(0,$.jsx)(`span`,{className:`uppercase text-[10px] font-semibold text-primary`,children:m})]})]}),f&&(0,$.jsx)(Fe,{file:f})]})}export{Re as CodeEditor};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{K as t,rt as n,t as r}from"./config-store-D7yrCV2X.js";import{i,t as a}from"./react-core-wiHys0m2.js";import{$r as o,Bi as s,Ht as c,It as l,J as u,Jn as d,Ki as f,La as p,Tt as m,Vn as h,Vr as g,Xi as _,Yi as v,Yn as y,Yr as b,Zr as x,ca as S,gi as C,gt as w,ia as T,ja as E,ji as D,nt as O,rn as k,wr as ee}from"./vendor-BO-lHyIr.js";import"./i18n-B_njdXiH.js";import{t as A}from"./utils-DQbrPaAM.js";import{o as j}from"./view-navigation-CVnKqjL2.js";import{S as M,b as N,h as P,o as F}from"./stores-COxKgvNx.js";import{i as I}from"./codemap-activity-store-5hcdmofR.js";import{F as L,P as te,y as R}from"./index-CfREDCPe.js";import{a as z,c as B,i as V,n as H,o as U,s as W,t as G}from"./monaco-CbI7qrVD.js";import{t as K}from"./empty-state-Dl66htl_.js";import{t as q}from"./monaco-theme-Dr3-rSid.js";import{t as ne}from"./MemoryDrawer-BdcWptmP.js";var J={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`},Y=Array.from(new Set(Object.values(J))).filter(e=>e!==`plaintext`),re=12e3,ie=4e3,ae=5e3,oe=1e4;function se(e){return J[e.split(`.`).pop()?.toLowerCase()??``]??`plaintext`}function ce(e){return e.match(/([A-Za-z_$][\w$]*)$/)?.[1]??``}function le(e,t){return e.triggerCharacter?!0:t.length>=3}function ue(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 de(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 X=e(i(),1);function fe(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 pe=/(write|edit|update|create|delete|rename|modified|changed)/i;function me(e){return e.replace(/\\/g,`/`).replace(/^\.\//,``).replace(/\/{2,}/g,`/`).toLowerCase()}function Z(e,t){let n=me(e),r=me(t);return n===r||n.endsWith(`/${r}`)||r.endsWith(`/${n}`)}function he(e,t=Date.now()){let n=e.filter(e=>t-e.at<=18e5),r=n.filter(e=>pe.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 Q(e){return typeof e==`string`&&e.length>0?e:void 0}function ge(e){let t=Date.parse(e.occurredAt??e.observedAt);return Number.isFinite(t)?t:Date.now()}function _e(e){let t=e.attributes??{},n=Q(t.operation)??e.eventType,r=e.scope.agentId,i=e.runtime?.providerId,a=e.runtime?.modelId;return{id:e.eventId,at:ge(e),action:n,actor:r??i??Q(t.actor)??`external`,source:Q(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??Q(t.taskId),boardId:Q(t.boardId)??e.scope.boardId,tool:Q(t.toolName),status:e.outcome,raw:e}}function ve(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 ye(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)&&(t.add(n),!0)})}function be(e){return e?e.split(/\r?\n/).length:0}function xe(e){return new TextEncoder().encode(e).length}function Se(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function Ce(e){return e.length>18?`${e.slice(0,8)}…${e.slice(-6)}`:e}function we(e,t){let n=L(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}}var $=a();function Te({text:e}){return(0,$.jsx)(`div`,{className:`px-3 py-3 text-center text-[10px] text-muted-foreground`,children:e})}function Ee({record:e,raw:t=!1}){let n=new Date(e.at).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`}),r=(0,$.jsxs)(`div`,{className:`grid grid-cols-[62px_74px_minmax(90px,.7fr)_minmax(160px,1.5fr)] items-center gap-2 text-[9px]`,children:[(0,$.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:n}),(0,$.jsx)(`span`,{className:A(`w-fit rounded px-1.5 py-0.5 font-mono`,pe.test(e.action)?`bg-warning/10 text-warning`:`bg-primary/10 text-primary`),children:e.action}),(0,$.jsx)(`span`,{className:`truncate`,title:e.agentId,children:e.actor}),(0,$.jsx)(`span`,{className:`truncate text-muted-foreground`,title:e.summary,children:e.summary})]});return t?(0,$.jsxs)(`details`,{className:`group cursor-pointer px-2.5 py-1.5`,children:[(0,$.jsx)(`summary`,{className:`list-none [&::-webkit-details-marker]:hidden`,children:r}),(0,$.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,$.jsx)(`div`,{className:`px-2.5 py-1.5`,children:r})}function De({records:e,loading:t}){let{t:n}=p();return t&&e.length===0?(0,$.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-[10px] text-muted-foreground`,children:[(0,$.jsx)(d,{className:`h-3.5 w-3.5 animate-spin`}),n(`activity:fileActivity.loadingEvidence`)]}):e.length===0?(0,$.jsx)(Te,{text:n(`activity:fileActivity.noEvidence`)}):(0,$.jsx)(`div`,{className:`divide-y divide-border/40`,children:e.map(e=>(0,$.jsx)(Ee,{record:e,raw:!0},`${e.id}:${e.at}`))})}function Oe({title:e,subtitle:t,raw:n}){return(0,$.jsxs)(`div`,{className:`rounded-md border border-border/60 bg-background/45 px-2 py-1.5`,title:n,children:[(0,$.jsx)(`div`,{className:`truncate text-[10px] font-medium`,children:e}),(0,$.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[8px] text-muted-foreground`,children:t})]})}function ke({icon:e,title:t,empty:n,children:r}){let i=Array.isArray(r)?r.length>0:!!r;return(0,$.jsxs)(`section`,{className:`min-w-0 p-2`,children:[(0,$.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,$.jsx)(`div`,{className:`space-y-1`,children:i?r:(0,$.jsx)(Te,{text:n})})]})}function Ae({sessions:e,agents:t,tasks:n,records:r,taskLabel:i,boardTitle:a}){let{t:o}=p();return(0,$.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,$.jsx)(ke,{icon:(0,$.jsx)(O,{}),title:o(`activity:fileActivity.sessions`),empty:o(`activity:fileActivity.noSessions`),children:e.map(e=>(0,$.jsx)(Oe,{title:Ce(e),subtitle:`${r.filter(t=>t.sessionId===e).length} ${o(`activity:fileActivity.events`)}`,raw:e},e))}),(0,$.jsx)(ke,{icon:(0,$.jsx)(S,{}),title:o(`activity:fileActivity.actors`),empty:o(`activity:fileActivity.noActors`),children:t.map(e=>(0,$.jsx)(Oe,{title:e,subtitle:`${r.filter(t=>t.actor===e).length} ${o(`activity:fileActivity.events`)}`},e))}),(0,$.jsx)(ke,{icon:(0,$.jsx)(y,{}),title:o(`activity:fileActivity.workLinks`),empty:o(`activity:fileActivity.noWorkLinks`),children:n.map(e=>(0,$.jsx)(Oe,{title:i(e),subtitle:a??o(`activity:fileActivity.taskOrTodo`),raw:e},e))})]})}function je({lifetime:e}){let{t}=p(),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,$.jsxs)(`div`,{className:`rounded-md border border-primary/15 bg-primary/[0.03] px-2.5 py-2`,children:[(0,$.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,$.jsx)(o,{}),t(`activity:fileActivity.lifetimeTitle`)]}),(0,$.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,$.jsxs)(`span`,{children:[(0,$.jsx)(`b`,{className:`text-foreground`,children:e.value.toLocaleString()}),` `,e.label]},e.label)),r&&(0,$.jsx)(`span`,{children:t(`activity:fileActivity.lifetimeSince`,{date:r})})]}),e.tools.length>0&&(0,$.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 Me({analysis:e,lifetime:t,records:n,sessions:r,agents:i,tasks:a,taskLabel:o}){let{t:s}=p(),c=[{label:s(`activity:fileActivity.mutations30m`),value:e.mutationCount,icon:(0,$.jsx)(b,{})},{label:s(`activity:fileActivity.sessions`),value:r.length,icon:(0,$.jsx)(O,{})},{label:s(`activity:fileActivity.actors`),value:i.length,icon:(0,$.jsx)(S,{})},{label:s(`activity:fileActivity.linkedWork`),value:a.length,icon:(0,$.jsx)(y,{})}];return(0,$.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,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:`grid grid-cols-4 gap-1.5`,children:c.map(e=>(0,$.jsxs)(`div`,{className:`rounded-md border border-border/70 bg-background/45 px-2 py-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 text-[9px] text-muted-foreground [&>svg]:h-3 [&>svg]:w-3`,children:[e.icon,(0,$.jsx)(`span`,{className:`truncate`,children:e.label})]}),(0,$.jsx)(`div`,{className:`mt-0.5 font-mono text-sm font-semibold`,children:e.value})]},e.label))}),t.mutations>0&&(0,$.jsx)(je,{lifetime:t}),(0,$.jsxs)(`div`,{className:A(`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,$.jsx)(l,{className:A(`mt-0.5 h-3.5 w-3.5 shrink-0`,e.level===`churn`?`text-destructive`:`text-primary`)}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`font-semibold`,children:s(`activity:fileActivity.analysisTitle.${e.level}`)}),(0,$.jsx)(`p`,{className:`mt-0.5 text-muted-foreground`,children:s(`activity:fileActivity.analysisBody.${e.level}`,{mutations:e.mutationCount,actors:e.actorCount,sessions:e.sessionCount})})]})]}),a.length>0&&(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 text-[9px]`,children:[(0,$.jsxs)(`span`,{className:`text-muted-foreground`,children:[s(`activity:fileActivity.workLinks`),`:`]}),a.slice(0,4).map(e=>(0,$.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:o(e)},e))]})]}),(0,$.jsxs)(`div`,{className:`min-w-0 rounded-md border border-border/70 bg-background/35`,children:[(0,$.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:s(`activity:fileActivity.recentActivity`)}),(0,$.jsx)(`div`,{className:`divide-y divide-border/40`,children:n.length===0?(0,$.jsx)(Te,{text:s(`activity:fileActivity.noEvidence`)}):n.slice(0,5).map(e=>(0,$.jsx)(Ee,{record:e},`${e.id}:${e.at}`))})]})]})}function Ne({file:e}){let i=r(e=>e.wsUrl),a=n(e=>e.jumpToLine),o=(0,X.useMemo)(()=>t(i),[i]),[s,c]=(0,X.useState)(``),[l,u]=(0,X.useState)(null),[f,p]=(0,X.useState)(``),[m,h]=(0,X.useState)(!0),[g,v]=(0,X.useState)(null),[y,b]=(0,X.useState)(!1),[S,w]=(0,X.useState)(!1),[T,E]=(0,X.useState)(!0),D=(0,X.useCallback)(()=>{h(!0),v(null),o.send({type:`files.skeleton`,payload:{filePath:e.path,content:e.content,options:{collapseImports:S,includeDocs:T}}})},[o,e.path,e.content,S,T]);(0,X.useEffect)(()=>{let t=o.on(`files.skeleton_result`,t=>{if(t.type===`files.skeleton_result`&&t.payload.filePath===e.path){if(h(!1),t.payload.error){v(t.payload.error);return}c(t.payload.skeleton),t.payload.stats&&u(t.payload.stats),t.payload.lang&&p(t.payload.lang)}});return D(),()=>{t()}},[o,e.path,D]);let O=async()=>{if(s)try{await navigator.clipboard.writeText(s),b(!0),setTimeout(()=>b(!1),2e3)}catch{}},ee=(e,t)=>{let n=e.match(/(?:\/\*\s*L(\d+)(?:-L\d+)?\s*\*\/|#\s*L(\d+)(?:-L\d+)?)/),r=n?parseInt(n[1]||n[2]||`0`,10):null;return r&&r>0?(0,$.jsxs)(`div`,{className:`group flex items-center justify-between gap-2 rounded px-1.5 py-0.5 hover:bg-primary/10 transition-colors`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:e}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>a(r),className:`shrink-0 cursor-pointer rounded bg-primary/20 px-1.5 py-0.5 font-mono text-[9px] font-semibold text-primary opacity-75 group-hover:opacity-100 hover:bg-primary hover:text-primary-foreground transition-all`,title:`Jump to line ${r} in editor`,children:[`Jump to L`,r,` →`]})]},t):(0,$.jsx)(`div`,{className:`px-1.5 py-0.5 whitespace-pre`,children:e},t)};return(0,$.jsxs)(`div`,{className:`flex h-full min-h-[140px] flex-col p-2`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center justify-between gap-2 border-b border-border/50 pb-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-primary/10 px-2 py-0.5 font-mono text-[10px] font-semibold uppercase text-primary`,children:[(0,$.jsx)(x,{className:`h-3 w-3`}),f||`AST`]}),l&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`span`,{className:`rounded bg-success/10 px-1.5 py-0.5 font-mono text-[10px] font-medium text-success`,children:[`-`,l.tokenSavingsPercent,`% Tokens`]}),(0,$.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[l.originalLines,` → `,l.skeletonLines,` lines`]}),(0,$.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`(`,l.symbolCount,` symbols)`]})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px]`,children:[(0,$.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-1 text-muted-foreground hover:text-foreground`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:S,onChange:e=>w(e.target.checked),className:`rounded border-border`}),(0,$.jsx)(`span`,{children:`Collapse imports`})]}),(0,$.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-1 text-muted-foreground hover:text-foreground`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:T,onChange:e=>E(e.target.checked),className:`rounded border-border`}),(0,$.jsx)(`span`,{children:`Include docs`})]}),(0,$.jsx)(`button`,{type:`button`,onClick:D,className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,title:`Refresh Skeleton`,children:(0,$.jsx)(k,{className:A(`h-3.5 w-3.5`,m&&`animate-spin`)})}),(0,$.jsxs)(`button`,{type:`button`,onClick:O,disabled:!s,className:`inline-flex items-center gap-1 rounded bg-secondary px-2 py-1 text-[10px] font-medium text-secondary-foreground hover:bg-secondary/80 disabled:opacity-50`,children:[y?(0,$.jsx)(_,{className:`h-3 w-3 text-success`}):(0,$.jsx)(C,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{children:y?`Copied`:`Copy`})]})]})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto rounded border border-border/60 bg-muted/20 p-2 font-mono text-[11px] leading-relaxed`,children:m&&!s?(0,$.jsxs)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:[(0,$.jsx)(d,{className:`mr-2 h-4 w-4 animate-spin text-primary`}),(0,$.jsx)(`span`,{children:`Extracting AST Skeleton…`})]}):g?(0,$.jsx)(`div`,{className:`p-4 text-warning`,children:g}):(0,$.jsx)(`div`,{className:`font-mono select-text`,children:s.split(`
2
+ `).map((e,t)=>ee(e,t))})})]})}function Pe({label:e}){return(0,$.jsx)(`span`,{className:`hidden whitespace-nowrap font-mono text-[9px] text-muted-foreground sm:inline`,children:e})}function Fe({file:e}){let{t:n}=p(),[i,a]=(0,X.useState)(!0),[c,l]=(0,X.useState)(224),[u,d]=(0,X.useState)(`overview`),[h,g]=(0,X.useState)([]),[_,S]=(0,X.useState)([]),[C,w]=(0,X.useState)(!1),[D,O]=(0,X.useState)(null),[j,M]=(0,X.useState)(null),N=(0,X.useRef)(null),L=r(e=>e.wsUrl),R=I(e=>e.history),z=I(e=>e.activeOperations),B=P(e=>e.activeBoard),V=F(e=>e.snapshot),H=(0,X.useMemo)(()=>t(L),[L]),U=(0,X.useCallback)(()=>{O(null),w(!0),typeof H.getGitDiff==`function`&&H.getGitDiff(e.path);let t=typeof H.supportsCapability==`function`?H.supportsCapability.bind(H):null;t?.(`chronicle.query`)?H.send({type:`chronicle.query`,payload:{query:{path:e.path,resourceKind:`file`,order:`desc`,limit:150}}}):w(!1),t?.(`chronicle.metrics`)&&H.send({type:`chronicle.metrics`,payload:{view:`files`,path:e.path,limit:1e3}})},[H,e.path]);(0,X.useEffect)(()=>{g([]),S([]),M(null);let t=H.on(`chronicle.query_result`,t=>{if(t.type!==`chronicle.query_result`)return;let n=t.payload.events.filter(t=>t.resource?.path&&Z(t.resource.path,e.path));t.payload.events.length>0&&n.length===0||(g(n),w(!1))}),n=H.on(`chronicle.metrics_result`,t=>{t.type===`chronicle.metrics_result`&&t.payload.view===`files`&&S(t.payload.data.filter(t=>Z(t.path,e.path)))}),r=H.on(`chronicle.error`,e=>{e.type===`chronicle.error`&&(O(e.payload.message),w(!1))}),i=H.on(`git.diff`,t=>{if(t.type!==`git.diff`||!Z(t.payload.path,e.path))return;let n=t.payload;if(n.error||n.binary||n.tooLarge){M({text:e.savedContent,available:!1,error:n.error});return}M({text:n.oldText??``,available:!0})});return U(),()=>{t(),n(),r(),i()}},[H,e.path,e.savedContent,U]),(0,X.useEffect)(()=>{let e=e=>{if(!N.current)return;let t=N.current.startY-e.clientY,n=Math.max(150,Math.floor(window.innerHeight*.62));l(Math.min(n,Math.max(150,N.current.startHeight+t)))},t=()=>{N.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 W=(0,X.useMemo)(()=>{let t=[];for(let[n,r]of R)Z(n,e.path)&&t.push(...r);for(let n of z.values())t.push(...n.filter(t=>Z(t.filePath,e.path)));return t},[z,e.path,R]),G=(0,X.useMemo)(()=>ye([...W.map(ve),...h.map(_e)]),[h,W]),K=(0,X.useMemo)(()=>he(G),[G]),q=(0,X.useMemo)(()=>fe(_),[_]),J=j?.text??e.savedContent,Y=(0,X.useMemo)(()=>we(J,e.content),[J,e.content]),re=(0,X.useMemo)(()=>[...new Set(G.map(e=>e.sessionId).filter(e=>!!e))],[G]),ie=(0,X.useMemo)(()=>[...new Set(G.map(e=>e.actor).filter(Boolean))],[G]),ae=(0,X.useMemo)(()=>[...new Set(G.map(e=>e.taskId).filter(e=>!!e))],[G]),oe=(0,X.useCallback)(e=>{let t=B?.tasks.find(t=>t.id===e),n=V?.tasks.find(t=>t.id===e||t.shortId===e);return t?.title??n?.title??e},[B,V]),se=e=>{i||a(!0),N.current={startY:e.clientY,startHeight:i?c:150},document.body.style.cursor=`ns-resize`,document.body.style.userSelect=`none`},ce=[{id:`overview`,label:n(`activity:fileActivity.overview`),icon:(0,$.jsx)(E,{})},{id:`changes`,label:n(`activity:fileActivity.changes`),icon:(0,$.jsx)(b,{})},{id:`skeleton`,label:`Skeleton`,icon:(0,$.jsx)(x,{})},{id:`context`,label:n(`activity:fileActivity.context`),icon:(0,$.jsx)(y,{})},{id:`logs`,label:n(`activity:fileActivity.logs`),icon:(0,$.jsx)(m,{})},{id:`memory`,label:n(`activity:fileActivity.memory`),icon:(0,$.jsx)(T,{})}];return(0,$.jsxs)(`section`,{className:`flex shrink-0 flex-col overflow-hidden border-t border-border bg-card/95 shadow-[0_-10px_30px_hsl(var(--background)/0.24)] backdrop-blur`,style:{height:i?c:38},"data-testid":`file-activity-drawer`,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":n(`activity:fileActivity.resizeHint`),className:`group relative block h-2 w-full cursor-ns-resize touch-none`,onPointerDown:se,onDoubleClick:()=>{a(!0),l(224)},title:n(`activity:fileActivity.resizeHint`),children:(0,$.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,$.jsxs)(`header`,{className:`flex h-[30px] min-w-0 items-center gap-2 border-b border-border/70 px-2.5`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`inline-flex min-w-0 items-center gap-1.5 rounded px-1.5 py-1 text-[11px] font-semibold hover:bg-muted`,"aria-expanded":i,children:[(0,$.jsx)(o,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,$.jsx)(`span`,{className:`truncate`,children:n(`activity:fileActivity.title`)}),i?(0,$.jsx)(v,{className:`h-3 w-3`}):(0,$.jsx)(f,{className:`h-3 w-3`})]}),(0,$.jsx)(`span`,{className:`hidden h-3 w-px bg-border sm:block`}),(0,$.jsx)(Pe,{label:`${be(e.content)} ${n(`activity:fileActivity.lines`)}`}),(0,$.jsx)(Pe,{label:Se(xe(e.content))}),!Y.large&&(Y.added>0||Y.removed>0)&&(0,$.jsxs)(`span`,{className:`hidden items-center gap-1 font-mono text-[10px] md:flex`,children:[(0,$.jsxs)(`span`,{className:`text-success`,children:[`+`,Y.added]}),(0,$.jsxs)(`span`,{className:`text-destructive`,children:[`−`,Y.removed]})]}),(0,$.jsxs)(`span`,{className:A(`ml-auto inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[9px] font-semibold uppercase tracking-wide`,K.level===`churn`&&`bg-destructive/10 text-destructive`,K.level===`active`&&`bg-warning/10 text-warning`,K.level===`quiet`&&`bg-success/10 text-success`),children:[(0,$.jsx)(s,{className:`h-2.5 w-2.5`}),n(`activity:fileActivity.level.${K.level}`)]}),(0,$.jsx)(`span`,{className:`hidden text-[9px] text-muted-foreground lg:inline`,children:n(`activity:fileActivity.evidenceCount`,{count:G.length})}),i&&(0,$.jsx)(`button`,{type:`button`,onClick:U,className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,title:n(`activity:fileActivity.refresh`),children:(0,$.jsx)(k,{className:A(`h-3.5 w-3.5`,C&&`animate-spin`)})})]}),i&&(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,$.jsxs)(`nav`,{className:`flex shrink-0 items-center gap-0.5 border-b border-border/60 bg-muted/20 px-2`,children:[ce.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>d(e.id),className:A(`inline-flex h-7 items-center gap-1.5 border-b-2 px-2 text-[10px] transition-colors [&>svg]:h-3 [&>svg]:w-3`,u===e.id?`border-primary font-medium text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`),children:[e.icon,e.label]},e.id)),D&&(0,$.jsx)(`span`,{className:`ml-auto truncate px-2 text-[9px] text-warning`,children:D})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[u===`overview`&&(0,$.jsx)(Me,{analysis:K,lifetime:q,records:G,sessions:re,agents:ie,tasks:ae,taskLabel:oe}),u===`changes`&&(0,$.jsxs)(`div`,{className:`h-full min-h-[120px] p-2`,children:[(0,$.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2 text-[9px] text-muted-foreground`,children:[(0,$.jsx)(ee,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{children:j?.available?n(`activity:fileActivity.gitToBuffer`):n(`activity:fileActivity.savedToBuffer`)}),e.dirty&&(0,$.jsx)(`span`,{className:`rounded bg-warning/10 px-1.5 py-0.5 text-warning`,children:n(`activity:fileActivity.unsaved`)}),j?.error&&(0,$.jsx)(`span`,{className:`truncate text-warning`,children:j.error})]}),(0,$.jsx)(`div`,{className:`h-[calc(100%-24px)] min-h-[90px]`,children:(0,$.jsx)(te,{oldText:J,newText:e.content,caption:e.path,fill:!0})})]}),u===`skeleton`&&(0,$.jsx)(Ne,{file:e}),u===`context`&&(0,$.jsx)(Ae,{sessions:re,agents:ie,tasks:ae,records:G,taskLabel:oe,boardTitle:B?.title??V?.title}),u===`logs`&&(0,$.jsx)(De,{records:G,loading:C}),u===`memory`&&(0,$.jsx)(`div`,{className:`h-full min-h-[120px]`,children:(0,$.jsx)(ne,{filePath:e.path,open:!0,onClose:()=>d(`overview`)})})]})]})]})}V.config({monaco:G});function Ie(e){switch(e){case`method`:return B.CompletionItemKind.Method;case`function`:return B.CompletionItemKind.Function;case`constructor`:return B.CompletionItemKind.Constructor;case`field`:return B.CompletionItemKind.Field;case`variable`:return B.CompletionItemKind.Variable;case`class`:return B.CompletionItemKind.Class;case`interface`:return B.CompletionItemKind.Interface;case`module`:return B.CompletionItemKind.Module;case`property`:return B.CompletionItemKind.Property;case`unit`:return B.CompletionItemKind.Unit;case`value`:return B.CompletionItemKind.Value;case`enum`:return B.CompletionItemKind.Enum;case`keyword`:return B.CompletionItemKind.Keyword;case`snippet`:return B.CompletionItemKind.Snippet;case`file`:return B.CompletionItemKind.File;case`reference`:return B.CompletionItemKind.Reference;default:return B.CompletionItemKind.Text}}function Le(){let e=n(e=>e.openFiles),t=n(e=>e.activeFilePath),r=n(e=>e.setActiveFile),i=n(e=>e.closeFile);return e.length===0?null:(0,$.jsx)(`div`,{className:`flex items-center border-b bg-muted/40 overflow-x-auto shrink-0`,children:e.map(e=>{let n=e.path===t,a=e.path.split(`/`).pop()??e.path;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>r(e.path),onMouseDown:t=>{t.button===1&&(t.preventDefault(),i(e.path))},className:A(`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`,n?`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,$.jsx)(D,{className:`h-2 w-2 fill-current text-primary shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:a}),(0,$.jsx)(u,{className:A(`h-3 w-3 shrink-0 rounded-sm hover:bg-muted-foreground/20 opacity-0 group-hover:opacity-100 transition-opacity`,n&&`opacity-100`),onClick:t=>{t.stopPropagation(),i(e.path)}})]},e.path)})})}function Re(){let{t:e}=p(),i=n(e=>e.openFiles),a=n(e=>e.activeFilePath),o=n(e=>e.updateContent),{theme:s}=R(),l=(0,X.useRef)(null),u=(0,X.useRef)(a),d=(0,X.useRef)(new Map),f=(0,X.useMemo)(()=>i.find(e=>e.path===a)??null,[i,a]),m=a?se(a):`plaintext`,_=q(),[v,y]=(0,X.useState)(!1),[b,x]=(0,X.useState)({line:1,col:1}),[S,C]=(0,X.useState)(!1),[T,E]=(0,X.useState)(!1),D=N(e=>e.info?.branch);(0,X.useEffect)(()=>{u.current=a},[a]),(0,X.useEffect)(()=>{let e=q();W.setTheme(e)},[s]);let O=n(e=>e.targetLine),k=n(e=>e.clearTargetLine);(0,X.useEffect)(()=>{O&&l.current&&(l.current.revealLineInCenter(O.line),l.current.setPosition({lineNumber:O.line,column:O.col??1}),l.current.focus(),k())},[O,k]),(0,X.useEffect)(()=>{let e=Y.map(e=>B.registerCompletionItemProvider(e,{triggerCharacters:[`.`,`_`],provideCompletionItems:async(e,n,i,a)=>{let o=u.current;if(!o)return{suggestions:[]};let s=e.getOffsetAt(n),c=e.getValue(),l=c.slice(Math.max(0,s-re),s),f=c.slice(s,s+ie),p=e.getLineContent(n.lineNumber).slice(0,Math.max(0,n.column-1)),m=ce(p),h={triggerCharacter:i.triggerCharacter,triggerKind:i.triggerKind};if(!le(h,m))return{suggestions:[]};let g=`cmp_${Date.now()}_${Math.random().toString(36).slice(2)}`,_=e.getWordUntilPosition(n),v={startLineNumber:n.lineNumber,endLineNumber:n.lineNumber,startColumn:_.startColumn,endColumn:n.column},y=t(r.getState().wsUrl),b=e=>e.map((e,t)=>({label:e.label,kind:Ie(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:v,insertTextRules:e.kind===`snippet`?B.CompletionItemInsertTextRule.InsertAsSnippet:void 0})),x=de({filePath:o,language:e.getLanguageId(),lineNumber:n.lineNumber,column:n.column,versionId:e.getVersionId(),triggerCharacter:i.triggerCharacter,linePrefix:p,suffix:f}),S=d.current.get(x);return S&&S.expiresAt>Date.now()?{suggestions:b(S.items)}:await new Promise(t=>{let r=!1,s=()=>{},u=null,p,_=e=>{r||(r=!0,s(),p!==void 0&&window.clearTimeout(p),u?.dispose(),t({suggestions:e}))};s=y.on(`completion.result`,e=>{let t=e;t.payload.requestId===g&&(d.current.set(x,{expiresAt:Date.now()+oe,items:t.payload.items}),_(b(t.payload.items)))}),p=window.setTimeout(()=>_([]),ae),u=a.onCancellationRequested(()=>_([])),y.requestCompletion({requestId:g,filePath:o,language:e.getLanguageId(),lineNumber:n.lineNumber,column:n.column,content:c.length<=5e5?c:void 0,prefix:l,suffix:f,triggerCharacter:i.triggerCharacter,triggerKind:i.triggerKind,allowLlm:ue(h,m)})})}}));return()=>{e.forEach(e=>{e.dispose()})}},[]);let P=(0,X.useCallback)(()=>{let e=l.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},[]),F=(0,X.useCallback)(()=>{j(`chat`),requestAnimationFrame(()=>{document.querySelector(`[data-chat-textarea]`)?.focus()})},[]),I=(0,X.useCallback)(()=>{let e=u.current;if(!e)return;let t=P();t&&(M.getState().addRef({kind:`snippet`,path:e,startLine:t.startLine,endLine:t.endLine,content:t.content}),F())},[P,F]),L=(0,X.useCallback)(()=>{let e=u.current;e&&(M.getState().addRef({kind:`file`,path:e}),F())},[F]),te=(0,X.useCallback)(t=>{l.current=t,W.setTheme(q()),t.onDidChangeCursorSelection?.(()=>{let e=t.getSelection();y(!!e&&!e.isEmpty())}),t.onDidChangeCursorPosition?.(e=>{e?.position&&x({line:e.position.lineNumber,col:e.position.column})}),t.addAction({id:`wrongstack-send-to-chat`,label:e(`activity:codeEditor.sendSelectionAction`),contextMenuGroupId:`wrongstack`,contextMenuOrder:0,precondition:void 0,keybindings:[U.CtrlCmd|U.Shift|z.KeyL],run:e=>{let t=e.getSelection();t&&!t.isEmpty()?I():L()}})},[I,L]),V=(0,X.useCallback)(e=>{a&&e!==void 0&&o(a,e)},[a,o]);return(0,X.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:a}}))),e.key.toLowerCase()===`w`&&(e.preventDefault(),a&&n.getState().closeFile(a)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[a]),i.length===0?(0,$.jsx)(K,{title:e(`activity:codeEditor.noFilesOpen`),description:e(`activity:codeEditor.selectToEdit`)}):(0,$.jsxs)(`div`,{className:`flex h-full min-w-0 flex-col overflow-hidden`,children:[(0,$.jsx)(Le,{}),(0,$.jsxs)(`div`,{className:`relative min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(v||f)&&(0,$.jsxs)(`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,$.jsxs)(`button`,{type:`button`,onClick:()=>C(e=>!e),className:A(`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[11px] transition-colors`,S?`bg-primary/20 text-primary font-medium`:`text-muted-foreground hover:text-foreground hover:bg-accent`),title:S?`Disable word wrap`:`Enable word wrap`,children:[(0,$.jsx)(w,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{children:`Wrap`})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>E(e=>!e),className:A(`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[11px] transition-colors`,T?`bg-primary/20 text-primary font-medium`:`text-muted-foreground hover:text-foreground hover:bg-accent`),title:T?`Hide minimap`:`Show minimap`,children:[(0,$.jsx)(h,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{children:`Map`})]}),(0,$.jsx)(`div`,{className:`h-3.5 w-px bg-border/80 mx-0.5`}),(0,$.jsxs)(`button`,{type:`button`,onClick:v?I:L,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(v?`activity:codeEditor.sendSelectedTitle`:`activity:codeEditor.mentionFileTitle`),children:[v?(0,$.jsx)(c,{className:`h-3 w-3`}):(0,$.jsx)(g,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{children:e(v?`activity:codeEditor.sendToChat`:`activity:codeEditor.mentionFile`)})]})]}),f?(0,$.jsx)(H,{language:m,value:f.content,onChange:V,theme:_,onMount:te,loading:(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground animate-pulse`,children:e(`activity:codeEditor.loadingEditor`)})}),options:{minimap:{enabled:T},fontSize:13,fontFamily:`'IBM Plex Mono', 'Cascadia Code', 'Fira Code', 'JetBrains Mono', monospace`,lineNumbers:`on`,renderWhitespace:`selection`,scrollBeyondLastLine:!1,wordWrap:S?`on`:`off`,tabSize:2,smoothScrolling:!0,cursorBlinking:`smooth`,cursorSmoothCaretAnimation:`on`,bracketPairColorization:{enabled:!0},"semanticHighlighting.enabled":!0,automaticLayout:!0,padding:{top:8}}},f.path):(0,$.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,$.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e(`activity:codeEditor.selectTab`)})})]}),f&&(0,$.jsxs)(`div`,{className:`flex h-6 shrink-0 items-center justify-between border-t border-border/70 bg-muted/30 px-3 text-[11px] text-muted-foreground font-mono select-none`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[D&&(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-foreground/80 font-medium`,children:[(0,$.jsx)(ee,{className:`h-3 w-3 text-primary shrink-0`}),(0,$.jsx)(`span`,{className:`truncate max-w-[140px]`,children:D})]}),(0,$.jsx)(`span`,{className:`truncate max-w-[320px] text-muted-foreground`,children:f.path})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,$.jsxs)(`span`,{children:[`Ln `,b.line,`, Col `,b.col]}),(0,$.jsx)(`span`,{children:`UTF-8`}),(0,$.jsx)(`span`,{className:`uppercase text-[10px] font-semibold text-primary`,children:m})]})]}),f&&(0,$.jsx)(Fe,{file:f})]})}export{Re as CodeEditor};