@runfusion/fusion 0.55.0 → 0.56.1

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 (127) hide show
  1. package/dist/bin.js +5829 -1357
  2. package/dist/client/.vite/manifest.json +322 -322
  3. package/dist/client/assets/{AgentDetailView-B_VfFSlt.js → AgentDetailView-BICsleMh.js} +1 -1
  4. package/dist/client/assets/{AgentPermissionPolicyEditor-QZhz41AU.js → AgentPermissionPolicyEditor-DQDzCWq_.js} +2 -2
  5. package/dist/client/assets/{AgentsView-hkhJ8SUq.js → AgentsView-DRpFG7gE.js} +6 -6
  6. package/dist/client/assets/ChatView-5vVkIiNh.js +6 -0
  7. package/dist/client/assets/{CommandCenter-B3fAajUO.js → CommandCenter-CZ856YOj.js} +1 -1
  8. package/dist/client/assets/{DevServerView-BR0ngFBw.js → DevServerView-BqsnMChS.js} +1 -1
  9. package/dist/client/assets/DirectoryPicker-cW1rnVoG.js +1 -0
  10. package/dist/client/assets/{DocumentsView-BnRvIUpa.js → DocumentsView-C6a5tuBQ.js} +1 -1
  11. package/dist/client/assets/{EvalsView-Bvx18QyC.js → EvalsView-DZd_TM3I.js} +1 -1
  12. package/dist/client/assets/{ExperimentalAgentOnboardingModal-CKGJcfXI.js → ExperimentalAgentOnboardingModal-cA-aWWsB.js} +1 -1
  13. package/dist/client/assets/{GoalsView-Bj1yVIiv.js → GoalsView-Bzvw1aDV.js} +1 -1
  14. package/dist/client/assets/{InsightsView-DBX8DI60.js → InsightsView-B3WQIXKs.js} +2 -2
  15. package/dist/client/assets/{MemoryView-CqkRH2fa.js → MemoryView-BZ2KwFO5.js} +1 -1
  16. package/dist/client/assets/{PiExtensionsManager-BMMmGWe2.js → PiExtensionsManager-D5x6GZOP.js} +2 -2
  17. package/dist/client/assets/{PluginManager-C1bdfN2W.js → PluginManager-YfHRH24B.js} +1 -1
  18. package/dist/client/assets/{PullRequestView-D0CsXWLl.js → PullRequestView-DX3J4hgm.js} +1 -1
  19. package/dist/client/assets/{ResearchView-CVgmXAlj.js → ResearchView-MZV2S2kT.js} +1 -1
  20. package/dist/client/assets/{SecretsView-Bv_gw5Ix.js → SecretsView--R3u3G4b.js} +1 -1
  21. package/dist/client/assets/SessionTerminal-BQWc1_Ty.js +2 -0
  22. package/dist/client/assets/SettingsModal-CNYosRF3.js +21 -0
  23. package/dist/client/assets/{SettingsModal-D7YgojbV.js → SettingsModal-Coqvlmud.js} +1 -1
  24. package/dist/client/assets/SettingsModal-D8AyVDar.css +1 -0
  25. package/dist/client/assets/SetupWizardModal-CoReXugb.js +2 -0
  26. package/dist/client/assets/{ShadcnColorPicker-DM2fqGwl.js → ShadcnColorPicker-D-u_ECbM.js} +1 -1
  27. package/dist/client/assets/{SkillsView-Bb-JTo99.js → SkillsView-D21ils_G.js} +1 -1
  28. package/dist/client/assets/TodoView-BFZQSkv4.js +6 -0
  29. package/dist/client/assets/WorkflowNodeEditor-E-7d5R9z.js +8 -0
  30. package/dist/client/assets/{agentSkills-DGFyuKuP.js → agentSkills-CM_yYVTx.js} +1 -1
  31. package/dist/client/assets/app-0jcSCRQr.js +13 -0
  32. package/dist/client/assets/app-BPzPEE6G.js +13 -0
  33. package/dist/client/assets/app-BSZU5Uns.js +13 -0
  34. package/dist/client/assets/app-CEtD1B9K.js +13 -0
  35. package/dist/client/assets/app-CVyRSEUX.js +13 -0
  36. package/dist/client/assets/app-DoLz_4Dg.js +13 -0
  37. package/dist/client/assets/{architectureDiagram-3BPJPVTR-DP7vOyXY.js → architectureDiagram-3BPJPVTR-DhgVYwmg.js} +1 -1
  38. package/dist/client/assets/{blockDiagram-GPEHLZMM-Di9v1pV8.js → blockDiagram-GPEHLZMM-AlG0kVWu.js} +1 -1
  39. package/dist/client/assets/{c4Diagram-AAUBKEIU-Dvb8RSfr.js → c4Diagram-AAUBKEIU-BOzpW3F7.js} +1 -1
  40. package/dist/client/assets/channel-DHSVrpL1.js +1 -0
  41. package/dist/client/assets/{chunk-2J33WTMH-gLcAuGjI.js → chunk-2J33WTMH-BAmZfsv0.js} +1 -1
  42. package/dist/client/assets/{chunk-4BX2VUAB-B-B0wjkx.js → chunk-4BX2VUAB-Cs587QhG.js} +1 -1
  43. package/dist/client/assets/{chunk-55IACEB6-XUDeC0Co.js → chunk-55IACEB6-qpIQSO06.js} +1 -1
  44. package/dist/client/assets/{chunk-727SXJPM-1eebiGA2.js → chunk-727SXJPM-DF3vZtMc.js} +1 -1
  45. package/dist/client/assets/{chunk-AQP2D5EJ-D9VOB5QS.js → chunk-AQP2D5EJ-BuETIys5.js} +1 -1
  46. package/dist/client/assets/{chunk-FMBD7UC4-EFNFEaAz.js → chunk-FMBD7UC4-B8D1TSR9.js} +1 -1
  47. package/dist/client/assets/{chunk-ND2GUHAM-CbeQailD.js → chunk-ND2GUHAM-BJv9aIQn.js} +1 -1
  48. package/dist/client/assets/{chunk-QZHKN3VN-D55N6EBz.js → chunk-QZHKN3VN-BJbK2pNR.js} +1 -1
  49. package/dist/client/assets/classDiagram-4FO5ZUOK-CTu3cN1i.js +1 -0
  50. package/dist/client/assets/classDiagram-v2-Q7XG4LA2-CTu3cN1i.js +1 -0
  51. package/dist/client/assets/{cose-bilkent-S5V4N54A-B0zbhkX3.js → cose-bilkent-S5V4N54A-BWRikddb.js} +1 -1
  52. package/dist/client/assets/{dagre-BM42HDAG-BL6peXwl.js → dagre-BM42HDAG-DpAxJj7T.js} +1 -1
  53. package/dist/client/assets/{dashboard-view-Db3n_W85.js → dashboard-view-Dw8L8k-2.js} +1 -1
  54. package/dist/client/assets/{dashboard-view-CS1H5SQN.js → dashboard-view-qq3ayA0B.js} +1 -1
  55. package/dist/client/assets/{diagram-2AECGRRQ-cYKwSHk7.js → diagram-2AECGRRQ-DRRIILsg.js} +1 -1
  56. package/dist/client/assets/{diagram-5GNKFQAL-DHIwTGuM.js → diagram-5GNKFQAL-DSOu28ss.js} +1 -1
  57. package/dist/client/assets/{diagram-KO2AKTUF-DfHBJ4aX.js → diagram-KO2AKTUF-CWzbnTBM.js} +1 -1
  58. package/dist/client/assets/{diagram-LMA3HP47-pWhYmB6Z.js → diagram-LMA3HP47-CGqf3bt6.js} +1 -1
  59. package/dist/client/assets/{diagram-OG6HWLK6-GzWqbi_m.js → diagram-OG6HWLK6-C1axXteT.js} +1 -1
  60. package/dist/client/assets/{erDiagram-TEJ5UH35-CCVm5eiR.js → erDiagram-TEJ5UH35-bBdlc4OY.js} +1 -1
  61. package/dist/client/assets/{flowDiagram-I6XJVG4X-CUTdnU6S.js → flowDiagram-I6XJVG4X-BTCJ2J3b.js} +1 -1
  62. package/dist/client/assets/{folder-open-DOCy9GVC.js → folder-open-BN3_NdbL.js} +1 -1
  63. package/dist/client/assets/{ganttDiagram-6RSMTGT7-CW4ENJaC.js → ganttDiagram-6RSMTGT7-CiFY9oBj.js} +1 -1
  64. package/dist/client/assets/{gitGraphDiagram-PVQCEYII-QXXMfSzp.js → gitGraphDiagram-PVQCEYII-CxubcP4l.js} +1 -1
  65. package/dist/client/assets/index-CbmH1ED8.css +1 -0
  66. package/dist/client/assets/index-rfsTNfpA.js +2511 -0
  67. package/dist/client/assets/{infoDiagram-5YYISTIA-CZyHbj0n.js → infoDiagram-5YYISTIA-ToDlIyOV.js} +1 -1
  68. package/dist/client/assets/{ishikawaDiagram-YF4QCWOH-Dea84lqZ.js → ishikawaDiagram-YF4QCWOH-BgO681xo.js} +1 -1
  69. package/dist/client/assets/{journeyDiagram-JHISSGLW-Db2iKGU5.js → journeyDiagram-JHISSGLW-OJZ3op9w.js} +1 -1
  70. package/dist/client/assets/{kanban-definition-UN3LZRKU-CB9loIqR.js → kanban-definition-UN3LZRKU-q2OOqX8K.js} +1 -1
  71. package/dist/client/assets/{mermaid.core-CoQ8aCb0.js → mermaid.core-BmDOYmFS.js} +4 -4
  72. package/dist/client/assets/{mindmap-definition-RKZ34NQL-JPb2wF-K.js → mindmap-definition-RKZ34NQL-Dw8JehwG.js} +1 -1
  73. package/dist/client/assets/{pieDiagram-4H26LBE5-pdZzOreP.js → pieDiagram-4H26LBE5-D5Li6GnX.js} +1 -1
  74. package/dist/client/assets/{quadrantDiagram-W4KKPZXB-Dh9Ids90.js → quadrantDiagram-W4KKPZXB-B4s-2jdZ.js} +1 -1
  75. package/dist/client/assets/{requirementDiagram-4Y6WPE33-BVPOSvHU.js → requirementDiagram-4Y6WPE33-Drc3rc_E.js} +1 -1
  76. package/dist/client/assets/{sankeyDiagram-5OEKKPKP-BqSMUpsx.js → sankeyDiagram-5OEKKPKP-C_R01GQC.js} +1 -1
  77. package/dist/client/assets/{sequenceDiagram-3UESZ5HK-B8nepQ6X.js → sequenceDiagram-3UESZ5HK-gyl7Yhgc.js} +1 -1
  78. package/dist/client/assets/{shield-alert-CtSaIQNY.js → shield-alert-DjhYmFaV.js} +1 -1
  79. package/dist/client/assets/{stateDiagram-AJRCARHV-CQv9RdRp.js → stateDiagram-AJRCARHV-BY53czZh.js} +1 -1
  80. package/dist/client/assets/stateDiagram-v2-BHNVJYJU-C53cIaWg.js +1 -0
  81. package/dist/client/assets/{timeline-definition-PNZ67QCA-CAjwM-Z5.js → timeline-definition-PNZ67QCA-BYwv2FZJ.js} +1 -1
  82. package/dist/client/assets/{upload-0_pT1euA.js → upload-BKpOp-Bn.js} +1 -1
  83. package/dist/client/assets/{users--1B6mnm8.js → users-BUMHTZuX.js} +1 -1
  84. package/dist/client/assets/{vennDiagram-CIIHVFJN-BO3Um3rH.js → vennDiagram-CIIHVFJN-Dt94bP0k.js} +1 -1
  85. package/dist/client/assets/{wardley-L42UT6IY-BzqJcqDA.js → wardley-L42UT6IY-536kdB5p.js} +1 -1
  86. package/dist/client/assets/{wardleyDiagram-YWT4CUSO-Bctxc6_5.js → wardleyDiagram-YWT4CUSO-D8iNQ_MW.js} +1 -1
  87. package/dist/client/assets/{xychartDiagram-2RQKCTM6-CgDuiMFR.js → xychartDiagram-2RQKCTM6-CXqp8mzh.js} +1 -1
  88. package/dist/client/index.html +3 -3
  89. package/dist/client/version.json +1 -1
  90. package/dist/droid-cli/package.json +1 -1
  91. package/dist/extension.js +4678 -917
  92. package/dist/pi-claude-cli/package.json +1 -1
  93. package/dist/plugin-sdk/index.d.ts +47 -3
  94. package/dist/plugins/fusion-plugin-acp-runtime/package.json +1 -1
  95. package/dist/plugins/fusion-plugin-cli-printing-press/package.json +1 -1
  96. package/dist/plugins/fusion-plugin-compound-engineering/package.json +1 -1
  97. package/dist/plugins/fusion-plugin-cursor-runtime/package.json +1 -1
  98. package/dist/plugins/fusion-plugin-dependency-graph/package.json +1 -1
  99. package/dist/plugins/fusion-plugin-droid-runtime/package.json +1 -1
  100. package/dist/plugins/fusion-plugin-hermes-runtime/package.json +1 -1
  101. package/dist/plugins/fusion-plugin-linear-import/package.json +1 -1
  102. package/dist/plugins/fusion-plugin-openclaw-runtime/package.json +1 -1
  103. package/dist/plugins/fusion-plugin-paperclip-runtime/package.json +1 -1
  104. package/dist/plugins/fusion-plugin-reports/package.json +1 -1
  105. package/dist/plugins/fusion-plugin-roadmap/package.json +1 -1
  106. package/dist/plugins/fusion-plugin-whatsapp-chat/package.json +1 -1
  107. package/package.json +1 -1
  108. package/dist/client/assets/ChatView-B4WnXLYA.js +0 -6
  109. package/dist/client/assets/DirectoryPicker-BiS41Hca.js +0 -1
  110. package/dist/client/assets/SessionTerminal-VLdVV3Ji.js +0 -2
  111. package/dist/client/assets/SettingsModal-4t8rV7rh.css +0 -1
  112. package/dist/client/assets/SettingsModal-gcrh5EOG.js +0 -21
  113. package/dist/client/assets/SetupWizardModal-DvmTlFP_.js +0 -2
  114. package/dist/client/assets/TodoView-bV-7deOh.js +0 -6
  115. package/dist/client/assets/WorkflowNodeEditor-Ui1q_fFI.js +0 -8
  116. package/dist/client/assets/app--OM-ul6R.js +0 -13
  117. package/dist/client/assets/app-BCvqf8qq.js +0 -13
  118. package/dist/client/assets/app-BZqqEiWR.js +0 -13
  119. package/dist/client/assets/app-DQeH1UDD.js +0 -13
  120. package/dist/client/assets/app-FiYwRatp.js +0 -13
  121. package/dist/client/assets/app-rGdYcsAA.js +0 -13
  122. package/dist/client/assets/channel-C5g9M3Sk.js +0 -1
  123. package/dist/client/assets/classDiagram-4FO5ZUOK-B-wdlvD6.js +0 -1
  124. package/dist/client/assets/classDiagram-v2-Q7XG4LA2-B-wdlvD6.js +0 -1
  125. package/dist/client/assets/index-B6ttSchA.js +0 -1336
  126. package/dist/client/assets/index-CPE2Kwra.css +0 -1
  127. package/dist/client/assets/stateDiagram-v2-BHNVJYJU-BZ_mlvie.js +0 -1
@@ -1 +1 @@
1
- import{r as a,j as e}from"./vendor-react-SZ_qB27O.js";import{ay as ie,az as de,aA as Be,aB as qe,aC as fe,aD as Ke,aE as ue,aF as Qe,aG as me,aH as _e,aI as Ve,V as Ge,aJ as O,D as We,F as Xe,aK as Ie,X as he,R as Je,al as J,p as Ye,s as pe,v as xe,aL as Y,aM as Ze,aN as et,aO as tt,o as je,C as st,ad as at}from"./index-B6ttSchA.js";import{u as U}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-CnI7NMXG.js";import"./vendor-xterm-BNq00GSj.js";import"./vendor-codemirror-jBKmHyH0.js";function nt(t){const{projectId:i,searchQuery:p,includeProjectFiles:d=!0}=t??{},o=i?`${Be.DOCUMENTS_PREFIX}${i}`:null,[s,c]=a.useState(()=>{if(!o)return[];const b=ie(o,{maxAgeMs:de});return Array.isArray(b)?b:[]}),[m,r]=a.useState([]),[w,u]=a.useState(()=>s.length===0),[x,k]=a.useState(null),f=a.useRef(null),v=a.useRef(s.length>0),j=a.useRef(null),P=a.useCallback(async()=>{f.current&&f.current.abort();const b=new AbortController;f.current=b;const z=!v.current;z&&u(!0),k(null);const E=qe(p?{q:p}:void 0,i),T=d?fe(i):Promise.resolve({files:[]}),[N,S]=await Promise.allSettled([E,T]);if(b.signal.aborted)return;let M=null;if(N.status==="fulfilled"){if(c(N.value),o){const L=N.value.length>500?N.value.slice(0,500):N.value;Ke(o,L,{maxBytes:5e5})}v.current=!0}else M=N.reason instanceof Error?N.reason.message:String(N.reason);if(S.status==="fulfilled"){const L=S.value.files,R=p?.trim().toLowerCase(),F=R?L.filter(H=>H.name.toLowerCase().includes(R)||H.path.toLowerCase().includes(R)):L;r(F)}k(M),z&&u(!1)},[o,d,i,p]);return a.useEffect(()=>{if(!o){v.current=!1,c([]),u(!0);return}const b=ie(o,{maxAgeMs:de});Array.isArray(b)?(c(b),v.current=!0,u(!1)):(v.current=!1,c([]),u(!0))},[o]),a.useEffect(()=>(j.current&&clearTimeout(j.current),j.current=setTimeout(()=>{P()},300),()=>{j.current&&clearTimeout(j.current)}),[P]),a.useEffect(()=>(P(),()=>{f.current&&f.current.abort()}),[]),{documents:s,projectFiles:m,loading:w,error:x,refresh:P}}function ct(t,i){const[p,d]=a.useState([]),[o,s]=a.useState(!0),[c,m]=a.useState(null),r=a.useRef(null),w=a.useRef(!1),u=i?.showHidden??!1,x=a.useCallback(async k=>{r.current&&r.current.abort();const f=new AbortController;r.current=f;const v=!w.current;v&&s(!0),m(null);try{const j=await fe(t,{showHidden:k?.showHidden??u});if(f.signal.aborted)return;d(j.files),w.current=!0}catch(j){if(f.signal.aborted)return;m(j instanceof Error?j.message:String(j))}finally{!f.signal.aborted&&v&&s(!1)}},[t,u]);return a.useEffect(()=>(w.current=!1,x({showHidden:u}),()=>{r.current&&r.current.abort()}),[x,u]),{files:p,loading:o,error:c,refresh:x}}const ot=768;function Z(t){return t?new Date(t).toLocaleString():""}function we(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(t>=10*1024?0:1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function be(t,i=200){return t.length<=i?t:`${t.substring(0,i)}…`}function rt(t){return t==="done"?"status-dot status-dot--online":t==="archived"?"status-dot status-dot--offline":t==="todo"||t==="triage"?"status-dot status-dot--pending":"status-dot status-dot--connecting"}function lt({document:t,renderMarkdown:i,onToggleMarkdown:p}){const{t:d}=U("app"),[o,s]=a.useState(!1),c=be(t.content),m=t.content.length>200;return e.jsxs("div",{className:"document-card",children:[e.jsxs("div",{className:"document-card-header",children:[e.jsxs("div",{className:"document-card-key",children:[e.jsx(O,{size:14}),e.jsx("span",{className:"document-card-key-text",children:t.key}),e.jsxs("span",{className:"document-card-revision-badge",children:["v",t.revision]})]}),e.jsx("div",{className:"document-card-actions",children:e.jsx("button",{className:"btn btn-sm document-card-expand-btn",onClick:()=>s(r=>!r),title:o?d("documents.collapse","Collapse"):d("documents.expand","Expand"),"aria-label":o?d("documents.collapseContent","Collapse content"):d("documents.expandContent","Expand content"),children:o?e.jsx(at,{size:14}):e.jsx(je,{size:14})})})]}),e.jsxs("div",{className:"document-card-meta",children:[e.jsx("span",{className:"document-card-author",children:t.author}),e.jsx("span",{className:"document-card-separator",children:"·"}),e.jsx("span",{className:"document-card-date",children:Z(t.updatedAt)})]}),e.jsxs("div",{className:`document-card-content${o?" document-card-content--expanded":""}`,children:[o?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"document-card-content-header",children:e.jsx("button",{className:"btn btn-sm document-mode-toggle",onClick:p,"aria-label":i?d("documents.switchToPlainText","Switch to plain text"):d("documents.switchToMarkdown","Switch to markdown"),"aria-pressed":i,title:i?d("documents.switchToPlainText","Switch to plain text"):d("documents.switchToMarkdown","Switch to markdown"),children:i?d("documents.markdown","Markdown"):d("documents.plain","Plain")})}),i?e.jsx("div",{className:"document-card-content-markdown",children:e.jsx("div",{className:"markdown-body",children:e.jsx(pe,{remarkPlugins:[xe],children:t.content})})}):e.jsx("pre",{className:"document-card-content-text",children:t.content})]}):e.jsx("p",{className:"document-card-preview",children:c}),m&&!o&&e.jsx("p",{className:"document-card-preview-truncated",children:"…"})]})]})}function it({taskId:t,taskTitle:i,documents:p,taskColumn:d,onOpenTask:o,renderMarkdownStates:s,onToggleMarkdown:c}){const{t:m}=U("app"),r=tt(),[w,u]=a.useState(!1),x=d?r(d):null,k=d?rt(d):"status-dot";return e.jsxs("div",{className:"documents-group",children:[e.jsxs("div",{className:"documents-group-header",children:[e.jsxs("button",{className:"documents-group-toggle-btn",onClick:()=>u(f=>!f),"aria-expanded":w,"aria-label":`${w?m("documents.collapse","Collapse"):m("documents.expand","Expand")} documents for task ${t}`,children:[e.jsx("span",{className:"documents-group-toggle","aria-hidden":"true",children:w?e.jsx(je,{size:16}):e.jsx(st,{size:16})}),e.jsx("span",{className:"documents-group-task-id",children:t}),e.jsx("span",{className:"documents-group-task-title",children:i||m("documents.untitled","Untitled")})]}),x?e.jsxs("span",{className:"documents-group-status badge","aria-label":m("documents.taskStatusAria","Task status: {{status}}",{status:x}),children:[e.jsx("span",{className:k,"aria-hidden":"true"}),e.jsx("span",{children:x})]}):null,e.jsx("span",{className:"documents-group-count",children:m("documents.docCount","{{count}} doc{{plural}}",{count:p.length,plural:p.length!==1?"s":""})}),e.jsx("button",{className:"documents-group-task-link",onClick:()=>o(t),"aria-label":m("documents.openTaskAria","Open task {{taskId}}: {{title}}",{taskId:t,title:i||m("documents.untitled","Untitled")}),children:m("documents.openTask","Open task")})]}),w&&e.jsx("div",{className:"documents-group-content",children:p.map(f=>e.jsx(lt,{document:f,renderMarkdown:s.get(f.id)??!1,onToggleMarkdown:()=>c(f.id)},f.id))})]})}function dt({artifact:t,projectId:i,onOpenTask:p,onExpandMedia:d}){const{t:o}=U("app"),s=Y(t.id,i),c=Ze(o,t.type),m=t.content?be(t.content,320):t.description,r=t.title||o("documents.untitledArtifact","Untitled artifact"),w=t.type==="image"||t.type==="video",u=a.useCallback(x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),d(t))},[t,d]);return e.jsxs("article",{className:"document-card documents-artifact-card","aria-label":o("documents.artifactCardLabel","Artifact {{title}}",{title:r}),children:[w?e.jsxs("div",{className:"documents-artifact-preview documents-artifact-preview--expandable",role:"button",tabIndex:0,"aria-label":o("documents.expandArtifact","Expand {{title}}",{title:r}),onClick:()=>d(t),onKeyDown:u,children:[t.type==="image"?e.jsx("img",{className:"documents-artifact-media",src:s,alt:r,loading:"lazy"}):e.jsx("video",{className:"documents-artifact-media",src:s,muted:!0,preload:"metadata","aria-label":o("documents.artifactVideoLabel","Video artifact: {{title}}",{title:r})}),e.jsx("span",{className:"documents-artifact-expand-hint",children:o("documents.expandArtifactHint","Click to expand")})]}):e.jsx("div",{className:"documents-artifact-preview",children:e.jsx(et,{artifact:t,mediaUrl:s,title:r,preview:m,t:o})}),e.jsxs("div",{className:"documents-artifact-body",children:[e.jsxs("div",{className:"documents-artifact-header",children:[e.jsx("span",{className:"documents-artifact-type-badge",children:c}),e.jsx("span",{className:"documents-artifact-author",children:t.authorId})]}),e.jsx("h3",{className:"documents-artifact-title",children:r}),t.description&&e.jsx("p",{className:"documents-artifact-description",children:t.description}),e.jsxs("div",{className:"documents-artifact-meta",children:[e.jsx("span",{children:Z(t.createdAt)}),t.sizeBytes!==void 0&&e.jsx("span",{children:we(t.sizeBytes)})]}),t.taskId&&e.jsx("button",{className:"documents-group-task-link documents-artifact-task-link",onClick:()=>p(t.taskId),"aria-label":o("documents.openTaskAria","Open task {{taskId}}: {{title}}",{taskId:t.taskId,title:t.taskTitle||o("documents.untitled","Untitled")}),children:o("documents.openTask","Open task")})]})]})}function jt({projectId:t,addToast:i,onOpenDetail:p,onOpenArtifactTaskDetail:d,onSendSelectionToTask:o}){const{t:s}=U("app"),[c,m]=a.useState("project"),[r,w]=a.useState(""),[u,x]=a.useState(null),[k,f]=a.useState(!1),[v,j]=a.useState(null),[P,b]=a.useState(!1),[z,E]=a.useState(null),[T,N]=a.useState(!1),S=a.useRef(0),M=a.useRef(!1),L=a.useRef(null),R=a.useRef(null),[F,H]=a.useState(!1),[ke,ee]=a.useState(new Map),[y,B]=a.useState(null),te=a.useRef(null),q=a.useRef(null),[se,ge]=a.useState(!1),ve=ue(L,{locked:se}),Ne=ue(R,{locked:se}),K=F?ve:Ne,ye=c==="tasks"?r.trim():"",Ce=c==="artifacts"?r.trim():"",{documents:D,loading:Q,error:Se,refresh:ae}=nt({projectId:t,searchQuery:ye||void 0,includeProjectFiles:!1}),{files:C,loading:_,error:Fe,refresh:ne}=ct(t,{showHidden:k}),{artifacts:A,loading:V,error:Ee,refresh:ce}=Qe({projectId:t,searchQuery:Ce||void 0});a.useEffect(()=>{const n=()=>{N(window.innerWidth<=ot)};return n(),window.addEventListener("resize",n),()=>{window.removeEventListener("resize",n)}},[]),a.useEffect(()=>{M.current=!1,m("project"),x(null),f(!1),j(null),E(null),b(!1),H(!1),ee(new Map),B(null)},[t]),a.useEffect(()=>{M.current||Q||_||V||(C.length>0?m("project"):D.length>0?m("tasks"):A.length>0&&m("artifacts"),M.current=!0)},[A.length,V,D.length,Q,C.length,_]);const G=a.useMemo(()=>{const n=new Map;for(const l of D){const h=n.get(l.taskId)||[];n.set(l.taskId,[...h,l])}return Array.from(n.entries()).map(([l,h])=>{const g=[...h].sort((I,Ue)=>Ue.updatedAt.localeCompare(I.updatedAt));return{taskId:l,taskTitle:g[0]?.taskTitle,taskColumn:g.find(I=>I.taskColumn)?.taskColumn,documents:g,latestUpdated:g[0]?.updatedAt??""}}).sort((l,h)=>h.latestUpdated.localeCompare(l.latestUpdated))},[D]),W=a.useMemo(()=>{const n=r.trim().toLowerCase();return n?C.filter(l=>{const h=l.path.toLowerCase(),g=l.name.toLowerCase();return h.includes(n)||g.includes(n)}):C},[C,r]);a.useEffect(()=>{if(!u)return;C.some(l=>l.path===u.path)||(x(null),j(null),E(null),b(!1))},[C,u]);const Te=a.useCallback(n=>{w(n.target.value)},[]),Le=a.useCallback(()=>{w("")},[]),X=a.useCallback(n=>{m(n)},[]),Ae=a.useCallback(async n=>{try{const l=await me(n,t);p(l)}catch{i(`Failed to open task ${n}`,"error")}},[t,p,i]),Pe=a.useCallback(async n=>{try{const l=await me(n,t);(d??p)(l)}catch{i(`Failed to open task ${n}`,"error")}},[t,d,p,i]),Me=a.useCallback(async n=>{x(n),b(!0),E(null),j(null);const l=S.current+1;S.current=l;try{const h=await _e("project",n.path,t);if(S.current!==l)return;j(h.content)}catch(h){if(S.current!==l)return;const g=h instanceof Error?h.message:`Failed to open ${n.path}`;E(g),i(g,"error")}finally{S.current===l&&b(!1)}},[t,i]),Re=a.useCallback(()=>{x(null),j(null),E(null),b(!1)},[]),De=a.useCallback(n=>{ee(l=>{const h=new Map(l),g=h.get(n)??!1;return h.set(n,!g),h})},[]),ze=a.useCallback(n=>{q.current=document.activeElement instanceof HTMLElement?document.activeElement:null,B(n)},[]),$=a.useCallback(()=>{B(null),q.current?.focus(),q.current=null},[]);a.useEffect(()=>{if(!y)return;const n=document.body.style.overflow;document.body.style.overflow="hidden",te.current?.focus();const l=h=>{h.key==="Escape"&&(h.preventDefault(),$())};return document.addEventListener("keydown",l),()=>{document.body.style.overflow=n,document.removeEventListener("keydown",l)}},[$,y]);const He=a.useCallback(n=>{n.target===n.currentTarget&&$()},[$]),oe=c==="project"?Fe:c==="tasks"?Se:Ee,$e=a.useCallback(async()=>{if(c==="project"){await ne();return}if(c==="tasks"){await ae();return}await ce()},[c,ce,ne,ae]),re=c==="project"?W.length:c==="tasks"?D.length:A.length,Oe=u&&o&&K?e.jsx(Ve,{selectedText:K.selectedText,anchorRect:K.anchorRect,filePath:u.path,onSubmit:o,onOpenChange:ge}):null,le=c==="project"?s("documents.searchProjectFiles","Search project markdown files…"):c==="tasks"?s("documents.searchTaskDocuments","Search task documents…"):s("documents.searchArtifacts","Search artifacts…");return e.jsxs("div",{className:"documents-view",children:[e.jsxs("div",{className:"documents-view-header",children:[e.jsx(Ge,{icon:O,title:s("documents.title","Artifacts"),actions:e.jsx("span",{className:"documents-view-count",children:s("documents.resultCount","{{count}} result{{plural}}",{count:re,plural:re!==1?"s":""})})}),e.jsxs("div",{className:"documents-controls-row",children:[e.jsxs("div",{className:"documents-tab-bar",role:"tablist","aria-label":s("documents.sectionsLabel","Documents sections"),children:[e.jsxs("button",{className:`btn documents-tab${c==="project"?" active":""}`,role:"tab","aria-selected":c==="project","aria-label":s("documents.showProjectFiles","Show project markdown files"),onClick:()=>X("project"),children:[s("documents.projectFilesTab","Project Files"),e.jsx("span",{className:"documents-tab-count",children:C.length})]}),e.jsxs("button",{className:`btn documents-tab${c==="tasks"?" active":""}`,role:"tab","aria-selected":c==="tasks","aria-label":s("documents.showTaskDocuments","Show task documents"),onClick:()=>X("tasks"),children:[s("documents.taskDocumentsTab","Task Documents"),e.jsx("span",{className:"documents-tab-count",children:G.length})]}),e.jsxs("button",{className:`btn documents-tab${c==="artifacts"?" active":""}`,role:"tab","aria-selected":c==="artifacts","aria-label":s("documents.showArtifacts","Show artifacts"),onClick:()=>X("artifacts"),children:[s("documents.artifactsTab","Artifacts"),e.jsx("span",{className:"documents-tab-count",children:A.length})]})]}),c==="project"&&e.jsxs("button",{className:"btn btn-sm documents-hidden-toggle",onClick:()=>f(n=>!n),"aria-pressed":k,"aria-label":k?s("documents.hideHidden","Hide hidden project files"):s("documents.showHidden","Show hidden project files"),title:k?s("documents.hideHiddenFiles","Hide hidden files"):s("documents.showHiddenFiles","Show hidden files"),children:[k?e.jsx(We,{size:14}):e.jsx(Xe,{size:14}),k?s("documents.hideHiddenLabel","Hide Hidden"):s("documents.showHiddenLabel","Show Hidden")]}),e.jsxs("div",{className:"documents-search",children:[e.jsx(Ie,{size:16,className:"documents-search-icon"}),e.jsx("input",{type:"text",className:"documents-search-input",placeholder:le,value:r,onChange:Te,"aria-label":le}),r&&e.jsx("button",{className:"documents-search-clear",onClick:Le,"aria-label":s("documents.clearSearch","Clear search"),children:e.jsx(he,{size:16})})]})]})]}),e.jsx("div",{className:"documents-view-content",children:oe?e.jsxs("div",{className:"documents-view-error",children:[e.jsx("p",{children:s("documents.failedToLoad","Failed to load {{type}}: {{error}}",{type:c==="project"?s("documents.projectFiles","project files"):c==="tasks"?s("documents.taskDocuments","task documents"):s("documents.artifacts","artifacts"),error:oe})}),e.jsxs("button",{className:"btn btn-primary",onClick:()=>void $e(),"aria-label":s("documents.retryLoading","Retry loading documents"),children:[e.jsx(Je,{size:16}),s("documents.retry","Retry")]})]}):c==="project"?_&&C.length===0?e.jsx("div",{className:"documents-view-loading",children:e.jsx("p",{children:e.jsx(J,{label:s("documents.loadingProjectFiles","Loading project markdown files…")})})}):W.length===0?e.jsx("div",{className:"documents-view-empty",children:r.trim()?e.jsx("p",{children:s("documents.noMatchProject",'No project markdown files match "{{query}}".',{query:r.trim()})}):e.jsxs(e.Fragment,{children:[e.jsx(O,{size:48,className:"documents-view-empty-icon"}),e.jsx("p",{children:s("documents.noMarkdownFiles","No Markdown files found in this project.")})]})}):e.jsxs("div",{className:`documents-project-layout${T?" documents-project-layout--mobile":""}`,children:[(!T||!u)&&e.jsx("aside",{className:"documents-view-sidebar","aria-label":s("documents.projectMarkdownFilesLabel","Project markdown files"),children:e.jsx("ul",{className:"markdown-file-list",children:W.map(n=>{const l=u?.path===n.path;return e.jsx("li",{className:"markdown-file-list-item",children:e.jsxs("button",{className:`markdown-file-item${l?" markdown-file-item--selected":""}`,onClick:()=>void Me(n),"aria-label":`Open ${n.path}`,"aria-current":l?"true":void 0,children:[e.jsx("span",{className:"markdown-file-item-name",children:n.name}),e.jsx("span",{className:"markdown-file-item-path",children:n.path}),e.jsxs("span",{className:"markdown-file-item-meta",children:[we(n.size)," · ",Z(n.mtime)]})]})},n.path)})})}),(!T||u)&&e.jsxs("section",{className:"documents-view-main","aria-label":s("documents.projectFilePreviewLabel","Project file content preview"),children:[T&&u&&e.jsxs("button",{className:"btn btn-sm documents-mobile-back",onClick:Re,"aria-label":s("documents.backToFilesList","Back to project files list"),children:[e.jsx(Ye,{size:14}),s("documents.backToFiles","Back to files")]}),u?e.jsxs("div",{className:"documents-content-viewer",children:[e.jsxs("div",{className:"documents-content-header",children:[e.jsx("p",{className:"documents-file-path-header",children:u.path}),e.jsx("button",{className:"btn btn-sm document-mode-toggle",onClick:()=>H(n=>!n),"aria-label":F?s("documents.switchToPlainText","Switch to plain text"):s("documents.switchToMarkdown","Switch to markdown"),"aria-pressed":F,title:F?s("documents.switchToPlainText","Switch to plain text"):s("documents.switchToMarkdown","Switch to markdown"),children:F?s("documents.markdown","Markdown"):s("documents.plain","Plain")})]}),P?e.jsx("p",{className:"documents-content-state",children:e.jsx(J,{label:s("documents.loadingFileContent","Loading file content…")})}):z?e.jsx("p",{className:"documents-content-state documents-content-state--error",children:z}):F?e.jsx("div",{ref:L,className:"documents-content-markdown",children:e.jsx("div",{className:"markdown-body",children:e.jsx(pe,{remarkPlugins:[xe],children:v??""})})}):e.jsx("pre",{ref:R,className:"document-card-content-text documents-content-viewer-text",children:v??""}),Oe]}):e.jsx("div",{className:"documents-view-empty",children:e.jsx("p",{children:s("documents.selectFile","Select a Markdown file to view its content.")})})]})]}):c==="artifacts"?V&&A.length===0?e.jsx("div",{className:"documents-view-loading",children:e.jsx("p",{children:s("documents.loadingArtifacts","Loading artifacts…")})}):A.length===0?e.jsx("div",{className:"documents-view-empty",children:r.trim()?e.jsx("p",{children:s("documents.noMatchArtifacts",'No artifacts match "{{query}}".',{query:r.trim()})}):e.jsxs(e.Fragment,{children:[e.jsx(O,{size:48,className:"documents-view-empty-icon"}),e.jsx("p",{children:s("documents.noArtifacts","No artifacts yet.")}),e.jsx("p",{className:"documents-view-empty-hint",children:s("documents.artifactsCreatedBy","Artifacts are created by agents, users, and system tools.")})]})}):e.jsx("div",{className:`documents-artifact-gallery${T?" documents-artifact-gallery--mobile":""}`,children:A.map(n=>e.jsx(dt,{artifact:n,projectId:t,onOpenTask:Pe,onExpandMedia:ze},n.id))}):Q&&D.length===0?e.jsx("div",{className:"documents-view-loading",children:e.jsx("p",{children:e.jsx(J,{label:s("documents.loadingTaskDocuments","Loading task documents…")})})}):G.length===0?e.jsx("div",{className:"documents-view-empty",children:r.trim()?e.jsx("p",{children:s("documents.noMatchTask",'No task documents match "{{query}}".',{query:r.trim()})}):e.jsxs(e.Fragment,{children:[e.jsx(O,{size:48,className:"documents-view-empty-icon"}),e.jsx("p",{children:s("documents.noTaskDocuments","No task documents yet.")}),e.jsx("p",{className:"documents-view-empty-hint",children:s("documents.documentsCreatedIn","Documents are created in task detail tabs.")})]})}):e.jsx("div",{className:"documents-task-list-wrap",children:e.jsx("div",{className:"documents-view-list",children:G.map(({taskId:n,taskTitle:l,taskColumn:h,documents:g})=>e.jsx(it,{taskId:n,taskTitle:l,taskColumn:h,documents:g,onOpenTask:Ae,renderMarkdownStates:ke,onToggleMarkdown:De},n))})})}),y&&e.jsx("div",{className:"modal-overlay open documents-artifact-lightbox-overlay",role:"dialog","aria-modal":"true","aria-label":s("documents.lightboxLabel","Artifact media preview"),onClick:He,children:e.jsxs("div",{className:"documents-artifact-lightbox",onClick:n=>n.stopPropagation(),children:[e.jsxs("div",{className:"documents-artifact-lightbox-header",children:[e.jsx("h3",{className:"documents-artifact-lightbox-title",children:y.title||s("documents.untitledArtifact","Untitled artifact")}),e.jsx("button",{ref:te,className:"modal-close",onClick:$,"aria-label":s("documents.closeLightbox","Close artifact preview"),children:e.jsx(he,{size:20})})]}),e.jsx("div",{className:"documents-artifact-lightbox-media-frame",children:y.type==="image"?e.jsx("img",{className:"documents-artifact-lightbox-media",src:Y(y.id,t),alt:y.title||s("documents.untitledArtifact","Untitled artifact")}):e.jsx("video",{className:"documents-artifact-lightbox-media",src:Y(y.id,t),controls:!0,autoPlay:!0,"aria-label":s("documents.artifactVideoLabel","Video artifact: {{title}}",{title:y.title||s("documents.untitledArtifact","Untitled artifact")})})})]})})]})}export{jt as DocumentsView};
1
+ import{r as a,j as e}from"./vendor-react-SZ_qB27O.js";import{aA as ie,aB as de,aC as Be,aD as qe,aE as fe,aF as Qe,aG as ue,aH as Ke,aI as me,aJ as _e,aK as Ve,V as Ge,aL as O,D as We,F as Xe,aM as Ie,X as he,R as Je,an as J,p as Ye,s as pe,v as xe,aN as Y,aO as Ze,aP as et,aQ as tt,o as je,C as st,af as at}from"./index-rfsTNfpA.js";import{u as U}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-CnI7NMXG.js";import"./vendor-codemirror-jBKmHyH0.js";import"./vendor-xterm-BNq00GSj.js";function nt(t){const{projectId:i,searchQuery:p,includeProjectFiles:d=!0}=t??{},o=i?`${Be.DOCUMENTS_PREFIX}${i}`:null,[s,c]=a.useState(()=>{if(!o)return[];const b=ie(o,{maxAgeMs:de});return Array.isArray(b)?b:[]}),[m,r]=a.useState([]),[w,u]=a.useState(()=>s.length===0),[x,k]=a.useState(null),f=a.useRef(null),v=a.useRef(s.length>0),j=a.useRef(null),P=a.useCallback(async()=>{f.current&&f.current.abort();const b=new AbortController;f.current=b;const z=!v.current;z&&u(!0),k(null);const E=qe(p?{q:p}:void 0,i),T=d?fe(i):Promise.resolve({files:[]}),[N,S]=await Promise.allSettled([E,T]);if(b.signal.aborted)return;let M=null;if(N.status==="fulfilled"){if(c(N.value),o){const L=N.value.length>500?N.value.slice(0,500):N.value;Qe(o,L,{maxBytes:5e5})}v.current=!0}else M=N.reason instanceof Error?N.reason.message:String(N.reason);if(S.status==="fulfilled"){const L=S.value.files,R=p?.trim().toLowerCase(),F=R?L.filter(H=>H.name.toLowerCase().includes(R)||H.path.toLowerCase().includes(R)):L;r(F)}k(M),z&&u(!1)},[o,d,i,p]);return a.useEffect(()=>{if(!o){v.current=!1,c([]),u(!0);return}const b=ie(o,{maxAgeMs:de});Array.isArray(b)?(c(b),v.current=!0,u(!1)):(v.current=!1,c([]),u(!0))},[o]),a.useEffect(()=>(j.current&&clearTimeout(j.current),j.current=setTimeout(()=>{P()},300),()=>{j.current&&clearTimeout(j.current)}),[P]),a.useEffect(()=>(P(),()=>{f.current&&f.current.abort()}),[]),{documents:s,projectFiles:m,loading:w,error:x,refresh:P}}function ct(t,i){const[p,d]=a.useState([]),[o,s]=a.useState(!0),[c,m]=a.useState(null),r=a.useRef(null),w=a.useRef(!1),u=i?.showHidden??!1,x=a.useCallback(async k=>{r.current&&r.current.abort();const f=new AbortController;r.current=f;const v=!w.current;v&&s(!0),m(null);try{const j=await fe(t,{showHidden:k?.showHidden??u});if(f.signal.aborted)return;d(j.files),w.current=!0}catch(j){if(f.signal.aborted)return;m(j instanceof Error?j.message:String(j))}finally{!f.signal.aborted&&v&&s(!1)}},[t,u]);return a.useEffect(()=>(w.current=!1,x({showHidden:u}),()=>{r.current&&r.current.abort()}),[x,u]),{files:p,loading:o,error:c,refresh:x}}const ot=768;function Z(t){return t?new Date(t).toLocaleString():""}function we(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(t>=10*1024?0:1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function be(t,i=200){return t.length<=i?t:`${t.substring(0,i)}…`}function rt(t){return t==="done"?"status-dot status-dot--online":t==="archived"?"status-dot status-dot--offline":t==="todo"||t==="triage"?"status-dot status-dot--pending":"status-dot status-dot--connecting"}function lt({document:t,renderMarkdown:i,onToggleMarkdown:p}){const{t:d}=U("app"),[o,s]=a.useState(!1),c=be(t.content),m=t.content.length>200;return e.jsxs("div",{className:"document-card",children:[e.jsxs("div",{className:"document-card-header",children:[e.jsxs("div",{className:"document-card-key",children:[e.jsx(O,{size:14}),e.jsx("span",{className:"document-card-key-text",children:t.key}),e.jsxs("span",{className:"document-card-revision-badge",children:["v",t.revision]})]}),e.jsx("div",{className:"document-card-actions",children:e.jsx("button",{className:"btn btn-sm document-card-expand-btn",onClick:()=>s(r=>!r),title:o?d("documents.collapse","Collapse"):d("documents.expand","Expand"),"aria-label":o?d("documents.collapseContent","Collapse content"):d("documents.expandContent","Expand content"),children:o?e.jsx(at,{size:14}):e.jsx(je,{size:14})})})]}),e.jsxs("div",{className:"document-card-meta",children:[e.jsx("span",{className:"document-card-author",children:t.author}),e.jsx("span",{className:"document-card-separator",children:"·"}),e.jsx("span",{className:"document-card-date",children:Z(t.updatedAt)})]}),e.jsxs("div",{className:`document-card-content${o?" document-card-content--expanded":""}`,children:[o?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"document-card-content-header",children:e.jsx("button",{className:"btn btn-sm document-mode-toggle",onClick:p,"aria-label":i?d("documents.switchToPlainText","Switch to plain text"):d("documents.switchToMarkdown","Switch to markdown"),"aria-pressed":i,title:i?d("documents.switchToPlainText","Switch to plain text"):d("documents.switchToMarkdown","Switch to markdown"),children:i?d("documents.markdown","Markdown"):d("documents.plain","Plain")})}),i?e.jsx("div",{className:"document-card-content-markdown",children:e.jsx("div",{className:"markdown-body",children:e.jsx(pe,{remarkPlugins:[xe],children:t.content})})}):e.jsx("pre",{className:"document-card-content-text",children:t.content})]}):e.jsx("p",{className:"document-card-preview",children:c}),m&&!o&&e.jsx("p",{className:"document-card-preview-truncated",children:"…"})]})]})}function it({taskId:t,taskTitle:i,documents:p,taskColumn:d,onOpenTask:o,renderMarkdownStates:s,onToggleMarkdown:c}){const{t:m}=U("app"),r=tt(),[w,u]=a.useState(!1),x=d?r(d):null,k=d?rt(d):"status-dot";return e.jsxs("div",{className:"documents-group",children:[e.jsxs("div",{className:"documents-group-header",children:[e.jsxs("button",{className:"documents-group-toggle-btn",onClick:()=>u(f=>!f),"aria-expanded":w,"aria-label":`${w?m("documents.collapse","Collapse"):m("documents.expand","Expand")} documents for task ${t}`,children:[e.jsx("span",{className:"documents-group-toggle","aria-hidden":"true",children:w?e.jsx(je,{size:16}):e.jsx(st,{size:16})}),e.jsx("span",{className:"documents-group-task-id",children:t}),e.jsx("span",{className:"documents-group-task-title",children:i||m("documents.untitled","Untitled")})]}),x?e.jsxs("span",{className:"documents-group-status badge","aria-label":m("documents.taskStatusAria","Task status: {{status}}",{status:x}),children:[e.jsx("span",{className:k,"aria-hidden":"true"}),e.jsx("span",{children:x})]}):null,e.jsx("span",{className:"documents-group-count",children:m("documents.docCount","{{count}} doc{{plural}}",{count:p.length,plural:p.length!==1?"s":""})}),e.jsx("button",{className:"documents-group-task-link",onClick:()=>o(t),"aria-label":m("documents.openTaskAria","Open task {{taskId}}: {{title}}",{taskId:t,title:i||m("documents.untitled","Untitled")}),children:m("documents.openTask","Open task")})]}),w&&e.jsx("div",{className:"documents-group-content",children:p.map(f=>e.jsx(lt,{document:f,renderMarkdown:s.get(f.id)??!1,onToggleMarkdown:()=>c(f.id)},f.id))})]})}function dt({artifact:t,projectId:i,onOpenTask:p,onExpandMedia:d}){const{t:o}=U("app"),s=Y(t.id,i),c=Ze(o,t.type),m=t.content?be(t.content,320):t.description,r=t.title||o("documents.untitledArtifact","Untitled artifact"),w=t.type==="image"||t.type==="video",u=a.useCallback(x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),d(t))},[t,d]);return e.jsxs("article",{className:"document-card documents-artifact-card","aria-label":o("documents.artifactCardLabel","Artifact {{title}}",{title:r}),children:[w?e.jsxs("div",{className:"documents-artifact-preview documents-artifact-preview--expandable",role:"button",tabIndex:0,"aria-label":o("documents.expandArtifact","Expand {{title}}",{title:r}),onClick:()=>d(t),onKeyDown:u,children:[t.type==="image"?e.jsx("img",{className:"documents-artifact-media",src:s,alt:r,loading:"lazy"}):e.jsx("video",{className:"documents-artifact-media",src:s,muted:!0,preload:"metadata","aria-label":o("documents.artifactVideoLabel","Video artifact: {{title}}",{title:r})}),e.jsx("span",{className:"documents-artifact-expand-hint",children:o("documents.expandArtifactHint","Click to expand")})]}):e.jsx("div",{className:"documents-artifact-preview",children:e.jsx(et,{artifact:t,mediaUrl:s,title:r,preview:m,t:o})}),e.jsxs("div",{className:"documents-artifact-body",children:[e.jsxs("div",{className:"documents-artifact-header",children:[e.jsx("span",{className:"documents-artifact-type-badge",children:c}),e.jsx("span",{className:"documents-artifact-author",children:t.authorId})]}),e.jsx("h3",{className:"documents-artifact-title",children:r}),t.description&&e.jsx("p",{className:"documents-artifact-description",children:t.description}),e.jsxs("div",{className:"documents-artifact-meta",children:[e.jsx("span",{children:Z(t.createdAt)}),t.sizeBytes!==void 0&&e.jsx("span",{children:we(t.sizeBytes)})]}),t.taskId&&e.jsx("button",{className:"documents-group-task-link documents-artifact-task-link",onClick:()=>p(t.taskId),"aria-label":o("documents.openTaskAria","Open task {{taskId}}: {{title}}",{taskId:t.taskId,title:t.taskTitle||o("documents.untitled","Untitled")}),children:o("documents.openTask","Open task")})]})]})}function jt({projectId:t,addToast:i,onOpenDetail:p,onOpenArtifactTaskDetail:d,onSendSelectionToTask:o}){const{t:s}=U("app"),[c,m]=a.useState("project"),[r,w]=a.useState(""),[u,x]=a.useState(null),[k,f]=a.useState(!1),[v,j]=a.useState(null),[P,b]=a.useState(!1),[z,E]=a.useState(null),[T,N]=a.useState(!1),S=a.useRef(0),M=a.useRef(!1),L=a.useRef(null),R=a.useRef(null),[F,H]=a.useState(!1),[ke,ee]=a.useState(new Map),[y,B]=a.useState(null),te=a.useRef(null),q=a.useRef(null),[se,ge]=a.useState(!1),ve=ue(L,{locked:se}),Ne=ue(R,{locked:se}),Q=F?ve:Ne,ye=c==="tasks"?r.trim():"",Ce=c==="artifacts"?r.trim():"",{documents:D,loading:K,error:Se,refresh:ae}=nt({projectId:t,searchQuery:ye||void 0,includeProjectFiles:!1}),{files:C,loading:_,error:Fe,refresh:ne}=ct(t,{showHidden:k}),{artifacts:A,loading:V,error:Ee,refresh:ce}=Ke({projectId:t,searchQuery:Ce||void 0});a.useEffect(()=>{const n=()=>{N(window.innerWidth<=ot)};return n(),window.addEventListener("resize",n),()=>{window.removeEventListener("resize",n)}},[]),a.useEffect(()=>{M.current=!1,m("project"),x(null),f(!1),j(null),E(null),b(!1),H(!1),ee(new Map),B(null)},[t]),a.useEffect(()=>{M.current||K||_||V||(C.length>0?m("project"):D.length>0?m("tasks"):A.length>0&&m("artifacts"),M.current=!0)},[A.length,V,D.length,K,C.length,_]);const G=a.useMemo(()=>{const n=new Map;for(const l of D){const h=n.get(l.taskId)||[];n.set(l.taskId,[...h,l])}return Array.from(n.entries()).map(([l,h])=>{const g=[...h].sort((I,Ue)=>Ue.updatedAt.localeCompare(I.updatedAt));return{taskId:l,taskTitle:g[0]?.taskTitle,taskColumn:g.find(I=>I.taskColumn)?.taskColumn,documents:g,latestUpdated:g[0]?.updatedAt??""}}).sort((l,h)=>h.latestUpdated.localeCompare(l.latestUpdated))},[D]),W=a.useMemo(()=>{const n=r.trim().toLowerCase();return n?C.filter(l=>{const h=l.path.toLowerCase(),g=l.name.toLowerCase();return h.includes(n)||g.includes(n)}):C},[C,r]);a.useEffect(()=>{if(!u)return;C.some(l=>l.path===u.path)||(x(null),j(null),E(null),b(!1))},[C,u]);const Te=a.useCallback(n=>{w(n.target.value)},[]),Le=a.useCallback(()=>{w("")},[]),X=a.useCallback(n=>{m(n)},[]),Ae=a.useCallback(async n=>{try{const l=await me(n,t);p(l)}catch{i(`Failed to open task ${n}`,"error")}},[t,p,i]),Pe=a.useCallback(async n=>{try{const l=await me(n,t);(d??p)(l)}catch{i(`Failed to open task ${n}`,"error")}},[t,d,p,i]),Me=a.useCallback(async n=>{x(n),b(!0),E(null),j(null);const l=S.current+1;S.current=l;try{const h=await _e("project",n.path,t);if(S.current!==l)return;j(h.content)}catch(h){if(S.current!==l)return;const g=h instanceof Error?h.message:`Failed to open ${n.path}`;E(g),i(g,"error")}finally{S.current===l&&b(!1)}},[t,i]),Re=a.useCallback(()=>{x(null),j(null),E(null),b(!1)},[]),De=a.useCallback(n=>{ee(l=>{const h=new Map(l),g=h.get(n)??!1;return h.set(n,!g),h})},[]),ze=a.useCallback(n=>{q.current=document.activeElement instanceof HTMLElement?document.activeElement:null,B(n)},[]),$=a.useCallback(()=>{B(null),q.current?.focus(),q.current=null},[]);a.useEffect(()=>{if(!y)return;const n=document.body.style.overflow;document.body.style.overflow="hidden",te.current?.focus();const l=h=>{h.key==="Escape"&&(h.preventDefault(),$())};return document.addEventListener("keydown",l),()=>{document.body.style.overflow=n,document.removeEventListener("keydown",l)}},[$,y]);const He=a.useCallback(n=>{n.target===n.currentTarget&&$()},[$]),oe=c==="project"?Fe:c==="tasks"?Se:Ee,$e=a.useCallback(async()=>{if(c==="project"){await ne();return}if(c==="tasks"){await ae();return}await ce()},[c,ce,ne,ae]),re=c==="project"?W.length:c==="tasks"?D.length:A.length,Oe=u&&o&&Q?e.jsx(Ve,{selectedText:Q.selectedText,anchorRect:Q.anchorRect,filePath:u.path,onSubmit:o,onOpenChange:ge}):null,le=c==="project"?s("documents.searchProjectFiles","Search project markdown files…"):c==="tasks"?s("documents.searchTaskDocuments","Search task documents…"):s("documents.searchArtifacts","Search artifacts…");return e.jsxs("div",{className:"documents-view",children:[e.jsxs("div",{className:"documents-view-header",children:[e.jsx(Ge,{icon:O,title:s("documents.title","Artifacts"),actions:e.jsx("span",{className:"documents-view-count",children:s("documents.resultCount","{{count}} result{{plural}}",{count:re,plural:re!==1?"s":""})})}),e.jsxs("div",{className:"documents-controls-row",children:[e.jsxs("div",{className:"documents-tab-bar",role:"tablist","aria-label":s("documents.sectionsLabel","Documents sections"),children:[e.jsxs("button",{className:`btn documents-tab${c==="project"?" active":""}`,role:"tab","aria-selected":c==="project","aria-label":s("documents.showProjectFiles","Show project markdown files"),onClick:()=>X("project"),children:[s("documents.projectFilesTab","Project Files"),e.jsx("span",{className:"documents-tab-count",children:C.length})]}),e.jsxs("button",{className:`btn documents-tab${c==="tasks"?" active":""}`,role:"tab","aria-selected":c==="tasks","aria-label":s("documents.showTaskDocuments","Show task documents"),onClick:()=>X("tasks"),children:[s("documents.taskDocumentsTab","Task Documents"),e.jsx("span",{className:"documents-tab-count",children:G.length})]}),e.jsxs("button",{className:`btn documents-tab${c==="artifacts"?" active":""}`,role:"tab","aria-selected":c==="artifacts","aria-label":s("documents.showArtifacts","Show artifacts"),onClick:()=>X("artifacts"),children:[s("documents.artifactsTab","Artifacts"),e.jsx("span",{className:"documents-tab-count",children:A.length})]})]}),c==="project"&&e.jsxs("button",{className:"btn btn-sm documents-hidden-toggle",onClick:()=>f(n=>!n),"aria-pressed":k,"aria-label":k?s("documents.hideHidden","Hide hidden project files"):s("documents.showHidden","Show hidden project files"),title:k?s("documents.hideHiddenFiles","Hide hidden files"):s("documents.showHiddenFiles","Show hidden files"),children:[k?e.jsx(We,{size:14}):e.jsx(Xe,{size:14}),k?s("documents.hideHiddenLabel","Hide Hidden"):s("documents.showHiddenLabel","Show Hidden")]}),e.jsxs("div",{className:"documents-search",children:[e.jsx(Ie,{size:16,className:"documents-search-icon"}),e.jsx("input",{type:"text",className:"documents-search-input",placeholder:le,value:r,onChange:Te,"aria-label":le}),r&&e.jsx("button",{className:"documents-search-clear",onClick:Le,"aria-label":s("documents.clearSearch","Clear search"),children:e.jsx(he,{size:16})})]})]})]}),e.jsx("div",{className:"documents-view-content",children:oe?e.jsxs("div",{className:"documents-view-error",children:[e.jsx("p",{children:s("documents.failedToLoad","Failed to load {{type}}: {{error}}",{type:c==="project"?s("documents.projectFiles","project files"):c==="tasks"?s("documents.taskDocuments","task documents"):s("documents.artifacts","artifacts"),error:oe})}),e.jsxs("button",{className:"btn btn-primary",onClick:()=>void $e(),"aria-label":s("documents.retryLoading","Retry loading documents"),children:[e.jsx(Je,{size:16}),s("documents.retry","Retry")]})]}):c==="project"?_&&C.length===0?e.jsx("div",{className:"documents-view-loading",children:e.jsx("p",{children:e.jsx(J,{label:s("documents.loadingProjectFiles","Loading project markdown files…")})})}):W.length===0?e.jsx("div",{className:"documents-view-empty",children:r.trim()?e.jsx("p",{children:s("documents.noMatchProject",'No project markdown files match "{{query}}".',{query:r.trim()})}):e.jsxs(e.Fragment,{children:[e.jsx(O,{size:48,className:"documents-view-empty-icon"}),e.jsx("p",{children:s("documents.noMarkdownFiles","No Markdown files found in this project.")})]})}):e.jsxs("div",{className:`documents-project-layout${T?" documents-project-layout--mobile":""}`,children:[(!T||!u)&&e.jsx("aside",{className:"documents-view-sidebar","aria-label":s("documents.projectMarkdownFilesLabel","Project markdown files"),children:e.jsx("ul",{className:"markdown-file-list",children:W.map(n=>{const l=u?.path===n.path;return e.jsx("li",{className:"markdown-file-list-item",children:e.jsxs("button",{className:`markdown-file-item${l?" markdown-file-item--selected":""}`,onClick:()=>void Me(n),"aria-label":`Open ${n.path}`,"aria-current":l?"true":void 0,children:[e.jsx("span",{className:"markdown-file-item-name",children:n.name}),e.jsx("span",{className:"markdown-file-item-path",children:n.path}),e.jsxs("span",{className:"markdown-file-item-meta",children:[we(n.size)," · ",Z(n.mtime)]})]})},n.path)})})}),(!T||u)&&e.jsxs("section",{className:"documents-view-main","aria-label":s("documents.projectFilePreviewLabel","Project file content preview"),children:[T&&u&&e.jsxs("button",{className:"btn btn-sm documents-mobile-back",onClick:Re,"aria-label":s("documents.backToFilesList","Back to project files list"),children:[e.jsx(Ye,{size:14}),s("documents.backToFiles","Back to files")]}),u?e.jsxs("div",{className:"documents-content-viewer",children:[e.jsxs("div",{className:"documents-content-header",children:[e.jsx("p",{className:"documents-file-path-header",children:u.path}),e.jsx("button",{className:"btn btn-sm document-mode-toggle",onClick:()=>H(n=>!n),"aria-label":F?s("documents.switchToPlainText","Switch to plain text"):s("documents.switchToMarkdown","Switch to markdown"),"aria-pressed":F,title:F?s("documents.switchToPlainText","Switch to plain text"):s("documents.switchToMarkdown","Switch to markdown"),children:F?s("documents.markdown","Markdown"):s("documents.plain","Plain")})]}),P?e.jsx("p",{className:"documents-content-state",children:e.jsx(J,{label:s("documents.loadingFileContent","Loading file content…")})}):z?e.jsx("p",{className:"documents-content-state documents-content-state--error",children:z}):F?e.jsx("div",{ref:L,className:"documents-content-markdown",children:e.jsx("div",{className:"markdown-body",children:e.jsx(pe,{remarkPlugins:[xe],children:v??""})})}):e.jsx("pre",{ref:R,className:"document-card-content-text documents-content-viewer-text",children:v??""}),Oe]}):e.jsx("div",{className:"documents-view-empty",children:e.jsx("p",{children:s("documents.selectFile","Select a Markdown file to view its content.")})})]})]}):c==="artifacts"?V&&A.length===0?e.jsx("div",{className:"documents-view-loading",children:e.jsx("p",{children:s("documents.loadingArtifacts","Loading artifacts…")})}):A.length===0?e.jsx("div",{className:"documents-view-empty",children:r.trim()?e.jsx("p",{children:s("documents.noMatchArtifacts",'No artifacts match "{{query}}".',{query:r.trim()})}):e.jsxs(e.Fragment,{children:[e.jsx(O,{size:48,className:"documents-view-empty-icon"}),e.jsx("p",{children:s("documents.noArtifacts","No artifacts yet.")}),e.jsx("p",{className:"documents-view-empty-hint",children:s("documents.artifactsCreatedBy","Artifacts are created by agents, users, and system tools.")})]})}):e.jsx("div",{className:`documents-artifact-gallery${T?" documents-artifact-gallery--mobile":""}`,children:A.map(n=>e.jsx(dt,{artifact:n,projectId:t,onOpenTask:Pe,onExpandMedia:ze},n.id))}):K&&D.length===0?e.jsx("div",{className:"documents-view-loading",children:e.jsx("p",{children:e.jsx(J,{label:s("documents.loadingTaskDocuments","Loading task documents…")})})}):G.length===0?e.jsx("div",{className:"documents-view-empty",children:r.trim()?e.jsx("p",{children:s("documents.noMatchTask",'No task documents match "{{query}}".',{query:r.trim()})}):e.jsxs(e.Fragment,{children:[e.jsx(O,{size:48,className:"documents-view-empty-icon"}),e.jsx("p",{children:s("documents.noTaskDocuments","No task documents yet.")}),e.jsx("p",{className:"documents-view-empty-hint",children:s("documents.documentsCreatedIn","Documents are created in task detail tabs.")})]})}):e.jsx("div",{className:"documents-task-list-wrap",children:e.jsx("div",{className:"documents-view-list",children:G.map(({taskId:n,taskTitle:l,taskColumn:h,documents:g})=>e.jsx(it,{taskId:n,taskTitle:l,taskColumn:h,documents:g,onOpenTask:Ae,renderMarkdownStates:ke,onToggleMarkdown:De},n))})})}),y&&e.jsx("div",{className:"modal-overlay open documents-artifact-lightbox-overlay",role:"dialog","aria-modal":"true","aria-label":s("documents.lightboxLabel","Artifact media preview"),onClick:He,children:e.jsxs("div",{className:"documents-artifact-lightbox",onClick:n=>n.stopPropagation(),children:[e.jsxs("div",{className:"documents-artifact-lightbox-header",children:[e.jsx("h3",{className:"documents-artifact-lightbox-title",children:y.title||s("documents.untitledArtifact","Untitled artifact")}),e.jsx("button",{ref:te,className:"modal-close",onClick:$,"aria-label":s("documents.closeLightbox","Close artifact preview"),children:e.jsx(he,{size:20})})]}),e.jsx("div",{className:"documents-artifact-lightbox-media-frame",children:y.type==="image"?e.jsx("img",{className:"documents-artifact-lightbox-media",src:Y(y.id,t),alt:y.title||s("documents.untitledArtifact","Untitled artifact")}):e.jsx("video",{className:"documents-artifact-lightbox-media",src:Y(y.id,t),controls:!0,autoPlay:!0,"aria-label":s("documents.artifactVideoLabel","Video artifact: {{title}}",{title:y.title||s("documents.untitledArtifact","Untitled artifact")})})})]})})]})}export{jt as DocumentsView};
@@ -1 +1 @@
1
- import{r as l,j as e}from"./vendor-react-SZ_qB27O.js";import{ay as P,az as L,aA as D,aP as Q,aQ as Y,aD as O,aR as J,aS as Z,V as H,T as B,a3 as ee,R as se,al as ae,aj as te}from"./index-B6ttSchA.js";import{u as le}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-CnI7NMXG.js";import"./vendor-xterm-BNq00GSj.js";import"./vendor-codemirror-jBKmHyH0.js";const re=300,ne=15e3;function K(r){if(!r.trim())return;const s=Number(r);return Number.isFinite(s)?s:void 0}function w(...r){for(const s of r)if(Array.isArray(s))return s;return[]}function f(r){return typeof r=="object"&&r!==null?r:{}}function X(r){const s=f(r),m=f(s.taskSnapshot);return{id:String(s.id??s.evalId??""),runId:String(s.runId??s.batchId??""),taskId:String(s.taskId??m.taskId??""),taskTitle:String(m.title??s.taskTitle??s.title??"Untitled task"),createdAt:String(s.createdAt??s.timestamp??s.updatedAt??new Date(0).toISOString()),overallScore:typeof s.overallScore=="number"?s.overallScore:null,maxScore:typeof s.maxScore=="number"?s.maxScore:null,categoryScores:w(s.categoryScores,f(s.scores).categories)}}function ce(r){const s=f(r);return{...X(s),rationale:String(s.rationale??s.summary??""),evidence:w(s.evidence,f(s.details).evidence),followUps:w(s.followUps,f(s.recommendations).followUps)}}function ie(r){const s=r?.projectId,m=s??"",t=`${D.EVALS_RUNS_PREFIX}${m}`,h=`${D.EVALS_RESULTS_PREFIX}${m}`,p=P(t,{maxAgeMs:L}),v=P(h,{maxAgeMs:L}),S=l.useRef(Array.isArray(p)&&p.length>0||Array.isArray(v)&&v.length>0),[i,g]=l.useState({q:"",runId:"",scoreMin:"",scoreMax:""}),[N,k]=l.useState(()=>Array.isArray(p)?p:[]),[o,M]=l.useState(()=>Array.isArray(v)?v:[]),[u,R]=l.useState(null),[F,b]=l.useState(null),[a,d]=l.useState(0),[y,j]=l.useState(!S.current),[W,z]=l.useState(null),C=l.useRef(0),q=l.useRef(s),_=l.useRef(u);_.current=u;const I=l.useCallback(async()=>{const n=++C.current;S.current||j(!0),z(null);try{const[c,x]=await Promise.all([Q({q:i.q||void 0,runId:i.runId||void 0,scoreMin:K(i.scoreMin),scoreMax:K(i.scoreMax),limit:100,offset:0},s),Y(s)]);if(n!==C.current)return;const E=w(c.results,c.evals,c.items).map(X);M(E),O(h,E.length>500?E.slice(0,500):E,{maxBytes:5e5}),d(typeof c.count=="number"?c.count:E.length);const V=w(x.runs,x.items).map(U=>{const A=f(U),$=f(A.counts);return{id:String(A.id??""),createdAt:String(A.createdAt??""),completedAt:typeof A.completedAt=="string"?A.completedAt:void 0,status:String(A.status??"pending"),evaluatedTaskCount:typeof $.totalTasks=="number"?$.totalTasks:0}});k(V),O(t,V,{maxBytes:5e5}),S.current=!0,_.current&&!E.some(U=>U.id===_.current)&&(R(null),b(null))}catch(c){if(n!==C.current)return;z(c instanceof Error?c.message:"Failed to load evals")}finally{n===C.current&&j(!1)}},[i.q,i.runId,i.scoreMax,i.scoreMin,s,h,t]),T=l.useCallback(async n=>{const c=await J(n,s),x=c.result??c;b(ce(x))},[s]);l.useEffect(()=>{if(q.current===s)return;q.current=s;const n=P(t,{maxAgeMs:L}),c=P(h,{maxAgeMs:L}),x=Array.isArray(n)&&n.length>0||Array.isArray(c)&&c.length>0;k(Array.isArray(n)?n:[]),M(Array.isArray(c)?c:[]),j(!x),S.current=x},[s,h,t]),l.useEffect(()=>{const n=window.setTimeout(()=>{I()},re);return()=>window.clearTimeout(n)},[I]),l.useEffect(()=>{if(!u){b(null);return}T(u)},[T,u]),l.useEffect(()=>{const n=window.setInterval(()=>{I(),u&&T(u)},ne);return()=>window.clearInterval(n)},[T,I,u]);const G=l.useCallback(n=>{_.current=n,R(n)},[]);return{loading:y,error:W,results:o,count:a,runs:N,filters:i,setFilters:g,refresh:I,selectedEvalId:u,setSelectedEvalId:G,selectedEval:F}}function xe({projectId:r,onOpenSettings:s,onOpenTaskDetail:m}){const{t}=le("app"),{loading:h,error:p,results:v,runs:S,filters:i,setFilters:g,selectedEvalId:N,setSelectedEvalId:k,selectedEval:o,refresh:M}=ie({projectId:r}),[u,R]=l.useState(!0);l.useEffect(()=>{let a=!1;return Z(r).then(d=>{if(a)return;const y=d.evalSettings?.enabled;R(y??!1)}).catch(()=>{a||R(!1)}),()=>{a=!0}},[r]);const F=v.length>0,b=l.useMemo(()=>v.find(a=>a.id===N)??null,[v,N]);return u?e.jsxs("section",{className:"evals-view","data-testid":"evals-view",children:[e.jsx(H,{icon:B,title:t("evals.title","Evals")}),e.jsxs("div",{className:"evals-view__body",children:[e.jsxs("div",{className:"evals-list card",children:[e.jsxs("div",{className:"evals-toolbar",children:[e.jsx("input",{className:"input",placeholder:t("evals.searchPlaceholder","Search task or rationale"),value:i.q,onChange:a=>g(d=>({...d,q:a.target.value}))}),e.jsxs("select",{className:"select",value:i.runId,onChange:a=>g(d=>({...d,runId:a.target.value})),children:[e.jsx("option",{value:"",children:t("evals.allRuns","All runs")}),S.map(a=>e.jsx("option",{value:a.id,children:a.id},a.id))]}),e.jsx("input",{className:"input",placeholder:t("evals.minScorePlaceholder","Min score"),value:i.scoreMin,onChange:a=>g(d=>({...d,scoreMin:a.target.value}))}),e.jsx("input",{className:"input",placeholder:t("evals.maxScorePlaceholder","Max score"),value:i.scoreMax,onChange:a=>g(d=>({...d,scoreMax:a.target.value}))}),e.jsx("button",{className:"btn btn-icon",type:"button",onClick:()=>void M(),"aria-label":t("evals.refreshAria","Refresh evals"),children:e.jsx(se,{size:16})})]}),h&&e.jsx("p",{className:"evals-state","data-testid":"evals-loading",children:e.jsx(ae,{label:t("evals.loading","Loading evals…")})}),p&&e.jsx("p",{className:"evals-state evals-state--error",children:p}),!h&&!p&&!F&&e.jsx("p",{className:"evals-state",children:t("evals.empty","No evals yet. Scheduled evals review tasks completed since the last run.")}),e.jsx("ul",{className:"evals-results","data-testid":"evals-results",children:v.map(a=>e.jsx("li",{children:e.jsxs("button",{className:`evals-result ${a.id===N?"evals-result--active":""}`,type:"button",onClick:()=>k(a.id),children:[e.jsx("span",{className:"evals-result-title",children:a.taskTitle}),e.jsxs("span",{className:"evals-result-meta",children:[a.taskId," · ",a.runId," · ",a.overallScore??t("evals.naPlaceholder","n/a")]})]})},a.id))})]}),e.jsxs("div",{className:"evals-detail card","data-testid":"evals-detail",children:[!o&&e.jsx("p",{className:"evals-state",children:t("evals.selectPrompt","Select an evaluation to inspect scores, rationale, and evidence.")}),o&&e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"evals-detail-title",children:b?.taskTitle??o.taskTitle}),e.jsxs("p",{className:"evals-result-meta",children:[o.taskId," · ",o.runId]}),e.jsx("p",{className:"evals-score",children:t("evals.overallScore","Overall score: {{score}}",{score:o.overallScore??t("evals.naPlaceholder","n/a")})}),e.jsx("ul",{className:"evals-categories",children:o.categoryScores.map(a=>e.jsxs("li",{children:[a.category,": ",a.finalScore]},a.category))}),e.jsx("p",{className:"evals-rationale",children:o.rationale||t("evals.noRationale","No rationale recorded.")}),e.jsxs("div",{children:[e.jsx("h4",{children:t("evals.evidenceHeading","Evidence")}),e.jsx("ul",{className:"evals-links",children:o.evidence.map((a,d)=>{const y=typeof a.metadata?.taskId=="string"?a.metadata.taskId:void 0,j=typeof a.metadata?.url=="string"?a.metadata.url:void 0;return e.jsx("li",{children:y?e.jsx("button",{type:"button",className:"btn",onClick:()=>m?.(y),children:a.ref}):j?e.jsxs("a",{href:j,target:"_blank",rel:"noreferrer",className:"evals-external-link",children:[a.ref,e.jsx(te,{size:14})]}):e.jsx("span",{children:a.ref})},`${a.ref}-${d}`)})})]}),e.jsxs("div",{children:[e.jsx("h4",{children:t("evals.suggestedFollowupsHeading","Suggested follow-up tasks")}),e.jsxs("ul",{className:"evals-follow-ups",children:[o.followUps.length===0&&e.jsx("li",{children:t("evals.noFollowups","None")}),o.followUps.map(a=>e.jsxs("li",{children:[e.jsx("strong",{children:a.title}),e.jsx("p",{children:a.rationale})]},a.suggestionId))]})]})]})]})]})]}):e.jsxs("section",{className:"evals-view","data-testid":"evals-disabled",children:[e.jsx(H,{icon:B,title:t("evals.title","Evals")}),e.jsxs("div",{className:"evals-view__empty",children:[e.jsx("h2",{className:"evals-title",children:t("evals.disabledTitle","Scheduled evals are disabled")}),e.jsx("p",{className:"evals-empty-copy",children:t("evals.enablePrompt","Enable Scheduled Evals to review scored tasks, evidence, and follow-up recommendations.")}),e.jsxs("button",{className:"btn btn-primary",type:"button",onClick:()=>s?.("scheduled-evals"),children:[e.jsx(ee,{size:16}),t("evals.openSettings","Open Scheduled Evals Settings")]})]})]})}export{xe as EvalsView};
1
+ import{r as l,j as e}from"./vendor-react-SZ_qB27O.js";import{aA as F,aB as L,aC as O,aR as Y,aS as J,aF as D,aT as Q,aU as Z,V as H,T as B,a4 as ee,R as se,an as ae,al as te}from"./index-rfsTNfpA.js";import{u as le}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-CnI7NMXG.js";import"./vendor-codemirror-jBKmHyH0.js";import"./vendor-xterm-BNq00GSj.js";const re=300,ne=15e3;function K(r){if(!r.trim())return;const s=Number(r);return Number.isFinite(s)?s:void 0}function w(...r){for(const s of r)if(Array.isArray(s))return s;return[]}function f(r){return typeof r=="object"&&r!==null?r:{}}function X(r){const s=f(r),m=f(s.taskSnapshot);return{id:String(s.id??s.evalId??""),runId:String(s.runId??s.batchId??""),taskId:String(s.taskId??m.taskId??""),taskTitle:String(m.title??s.taskTitle??s.title??"Untitled task"),createdAt:String(s.createdAt??s.timestamp??s.updatedAt??new Date(0).toISOString()),overallScore:typeof s.overallScore=="number"?s.overallScore:null,maxScore:typeof s.maxScore=="number"?s.maxScore:null,categoryScores:w(s.categoryScores,f(s.scores).categories)}}function ce(r){const s=f(r);return{...X(s),rationale:String(s.rationale??s.summary??""),evidence:w(s.evidence,f(s.details).evidence),followUps:w(s.followUps,f(s.recommendations).followUps)}}function ie(r){const s=r?.projectId,m=s??"",t=`${O.EVALS_RUNS_PREFIX}${m}`,h=`${O.EVALS_RESULTS_PREFIX}${m}`,p=F(t,{maxAgeMs:L}),v=F(h,{maxAgeMs:L}),S=l.useRef(Array.isArray(p)&&p.length>0||Array.isArray(v)&&v.length>0),[i,g]=l.useState({q:"",runId:"",scoreMin:"",scoreMax:""}),[N,k]=l.useState(()=>Array.isArray(p)?p:[]),[o,C]=l.useState(()=>Array.isArray(v)?v:[]),[u,R]=l.useState(null),[P,b]=l.useState(null),[a,d]=l.useState(0),[y,j]=l.useState(!S.current),[W,q]=l.useState(null),M=l.useRef(0),z=l.useRef(s),T=l.useRef(u);T.current=u;const I=l.useCallback(async()=>{const n=++M.current;S.current||j(!0),q(null);try{const[c,x]=await Promise.all([Y({q:i.q||void 0,runId:i.runId||void 0,scoreMin:K(i.scoreMin),scoreMax:K(i.scoreMax),limit:100,offset:0},s),J(s)]);if(n!==M.current)return;const E=w(c.results,c.evals,c.items).map(X);C(E),D(h,E.length>500?E.slice(0,500):E,{maxBytes:5e5}),d(typeof c.count=="number"?c.count:E.length);const V=w(x.runs,x.items).map(U=>{const A=f(U),$=f(A.counts);return{id:String(A.id??""),createdAt:String(A.createdAt??""),completedAt:typeof A.completedAt=="string"?A.completedAt:void 0,status:String(A.status??"pending"),evaluatedTaskCount:typeof $.totalTasks=="number"?$.totalTasks:0}});k(V),D(t,V,{maxBytes:5e5}),S.current=!0,T.current&&!E.some(U=>U.id===T.current)&&(R(null),b(null))}catch(c){if(n!==M.current)return;q(c instanceof Error?c.message:"Failed to load evals")}finally{n===M.current&&j(!1)}},[i.q,i.runId,i.scoreMax,i.scoreMin,s,h,t]),_=l.useCallback(async n=>{const c=await Q(n,s),x=c.result??c;b(ce(x))},[s]);l.useEffect(()=>{if(z.current===s)return;z.current=s;const n=F(t,{maxAgeMs:L}),c=F(h,{maxAgeMs:L}),x=Array.isArray(n)&&n.length>0||Array.isArray(c)&&c.length>0;k(Array.isArray(n)?n:[]),C(Array.isArray(c)?c:[]),j(!x),S.current=x},[s,h,t]),l.useEffect(()=>{const n=window.setTimeout(()=>{I()},re);return()=>window.clearTimeout(n)},[I]),l.useEffect(()=>{if(!u){b(null);return}_(u)},[_,u]),l.useEffect(()=>{const n=window.setInterval(()=>{I(),u&&_(u)},ne);return()=>window.clearInterval(n)},[_,I,u]);const G=l.useCallback(n=>{T.current=n,R(n)},[]);return{loading:y,error:W,results:o,count:a,runs:N,filters:i,setFilters:g,refresh:I,selectedEvalId:u,setSelectedEvalId:G,selectedEval:P}}function xe({projectId:r,onOpenSettings:s,onOpenTaskDetail:m}){const{t}=le("app"),{loading:h,error:p,results:v,runs:S,filters:i,setFilters:g,selectedEvalId:N,setSelectedEvalId:k,selectedEval:o,refresh:C}=ie({projectId:r}),[u,R]=l.useState(!0);l.useEffect(()=>{let a=!1;return Z(r).then(d=>{if(a)return;const y=d.evalSettings?.enabled;R(y??!1)}).catch(()=>{a||R(!1)}),()=>{a=!0}},[r]);const P=v.length>0,b=l.useMemo(()=>v.find(a=>a.id===N)??null,[v,N]);return u?e.jsxs("section",{className:"evals-view","data-testid":"evals-view",children:[e.jsx(H,{icon:B,title:t("evals.title","Evals")}),e.jsxs("div",{className:"evals-view__body",children:[e.jsxs("div",{className:"evals-list card",children:[e.jsxs("div",{className:"evals-toolbar",children:[e.jsx("input",{className:"input",placeholder:t("evals.searchPlaceholder","Search task or rationale"),value:i.q,onChange:a=>g(d=>({...d,q:a.target.value}))}),e.jsxs("select",{className:"select",value:i.runId,onChange:a=>g(d=>({...d,runId:a.target.value})),children:[e.jsx("option",{value:"",children:t("evals.allRuns","All runs")}),S.map(a=>e.jsx("option",{value:a.id,children:a.id},a.id))]}),e.jsx("input",{className:"input",placeholder:t("evals.minScorePlaceholder","Min score"),value:i.scoreMin,onChange:a=>g(d=>({...d,scoreMin:a.target.value}))}),e.jsx("input",{className:"input",placeholder:t("evals.maxScorePlaceholder","Max score"),value:i.scoreMax,onChange:a=>g(d=>({...d,scoreMax:a.target.value}))}),e.jsx("button",{className:"btn btn-icon",type:"button",onClick:()=>void C(),"aria-label":t("evals.refreshAria","Refresh evals"),children:e.jsx(se,{size:16})})]}),h&&e.jsx("p",{className:"evals-state","data-testid":"evals-loading",children:e.jsx(ae,{label:t("evals.loading","Loading evals…")})}),p&&e.jsx("p",{className:"evals-state evals-state--error",children:p}),!h&&!p&&!P&&e.jsx("p",{className:"evals-state",children:t("evals.empty","No evals yet. Scheduled evals review tasks completed since the last run.")}),e.jsx("ul",{className:"evals-results","data-testid":"evals-results",children:v.map(a=>e.jsx("li",{children:e.jsxs("button",{className:`evals-result ${a.id===N?"evals-result--active":""}`,type:"button",onClick:()=>k(a.id),children:[e.jsx("span",{className:"evals-result-title",children:a.taskTitle}),e.jsxs("span",{className:"evals-result-meta",children:[a.taskId," · ",a.runId," · ",a.overallScore??t("evals.naPlaceholder","n/a")]})]})},a.id))})]}),e.jsxs("div",{className:"evals-detail card","data-testid":"evals-detail",children:[!o&&e.jsx("p",{className:"evals-state",children:t("evals.selectPrompt","Select an evaluation to inspect scores, rationale, and evidence.")}),o&&e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"evals-detail-title",children:b?.taskTitle??o.taskTitle}),e.jsxs("p",{className:"evals-result-meta",children:[o.taskId," · ",o.runId]}),e.jsx("p",{className:"evals-score",children:t("evals.overallScore","Overall score: {{score}}",{score:o.overallScore??t("evals.naPlaceholder","n/a")})}),e.jsx("ul",{className:"evals-categories",children:o.categoryScores.map(a=>e.jsxs("li",{children:[a.category,": ",a.finalScore]},a.category))}),e.jsx("p",{className:"evals-rationale",children:o.rationale||t("evals.noRationale","No rationale recorded.")}),e.jsxs("div",{children:[e.jsx("h4",{children:t("evals.evidenceHeading","Evidence")}),e.jsx("ul",{className:"evals-links",children:o.evidence.map((a,d)=>{const y=typeof a.metadata?.taskId=="string"?a.metadata.taskId:void 0,j=typeof a.metadata?.url=="string"?a.metadata.url:void 0;return e.jsx("li",{children:y?e.jsx("button",{type:"button",className:"btn",onClick:()=>m?.(y),children:a.ref}):j?e.jsxs("a",{href:j,target:"_blank",rel:"noreferrer",className:"evals-external-link",children:[a.ref,e.jsx(te,{size:14})]}):e.jsx("span",{children:a.ref})},`${a.ref}-${d}`)})})]}),e.jsxs("div",{children:[e.jsx("h4",{children:t("evals.suggestedFollowupsHeading","Suggested follow-up tasks")}),e.jsxs("ul",{className:"evals-follow-ups",children:[o.followUps.length===0&&e.jsx("li",{children:t("evals.noFollowups","None")}),o.followUps.map(a=>e.jsxs("li",{children:[e.jsx("strong",{children:a.title}),e.jsx("p",{children:a.rationale})]},a.suggestionId))]})]})]})]})]})]}):e.jsxs("section",{className:"evals-view","data-testid":"evals-disabled",children:[e.jsx(H,{icon:B,title:t("evals.title","Evals")}),e.jsxs("div",{className:"evals-view__empty",children:[e.jsx("h2",{className:"evals-title",children:t("evals.disabledTitle","Scheduled evals are disabled")}),e.jsx("p",{className:"evals-empty-copy",children:t("evals.enablePrompt","Enable Scheduled Evals to review scored tasks, evidence, and follow-up recommendations.")}),e.jsxs("button",{className:"btn btn-primary",type:"button",onClick:()=>s?.("scheduled-evals"),children:[e.jsx(ee,{size:16}),t("evals.openSettings","Open Scheduled Evals Settings")]})]})]})}export{xe as EvalsView};
@@ -1 +1 @@
1
- import{r as s,j as n}from"./vendor-react-SZ_qB27O.js";import{A as F,K as U,N as V,O as W,Q as G,U as K}from"./index-B6ttSchA.js";import{u as z}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-CnI7NMXG.js";import"./vendor-xterm-BNq00GSj.js";import"./vendor-codemirror-jBKmHyH0.js";function en({isOpen:l,onClose:R,onUseDraft:M,projectId:x,existingAgents:P,mode:_="create",existingAgentConfig:L}){const{t:e}=z("app"),[m,d]=s.useState("initial"),[f,S]=s.useState(""),[c,k]=s.useState(null),[C,I]=s.useState(""),[w,A]=s.useState("answer"),[v,p]=s.useState(""),[t,T]=s.useState(null),[H,g]=s.useState(null),[E,y]=s.useState([]),b=_==="edit",o=s.useRef(l),N=s.useCallback(()=>{d("initial"),S(""),k(null),I(""),A("answer"),p(""),T(null),g(null),y([])},[]),Q=s.useMemo(()=>F.map(a=>({id:a.id,label:a.name,description:a.description})),[]);s.useEffect(()=>{if(o.current=l,!c)return;const a=U(c,x,{onThinking:i=>{o.current&&y($=>{const h=[...$],j=h[h.length-1];return j&&!j.question?(h[h.length-1]={...j,thinkingOutput:`${j.thinkingOutput??""}${i}`},h):[...h,{response:{},thinkingOutput:i}]})},onQuestion:i=>{o.current&&(I(i.question),A(i.id),d("question"))},onSummary:i=>{o.current&&(T(i),d("summary"))},onError:i=>{o.current&&(g(i),d("error"))}});return()=>{o.current=!1,a.close()}},[l,c,x]);const u=async()=>{o.current=!1;try{c&&await W(c,x)}catch{}finally{N(),R()}};if(s.useEffect(()=>{o.current=l,l||N()},[l,N]),!l)return null;const r=a=>a==null||a===""?n.jsx("em",{className:"experimental-agent-onboarding-modal__summary-empty",children:e("agents.onboarding.notSet","Not set")}):n.jsx("span",{children:a}),q=async()=>{d("loading"),g(null);try{const a=await G(f,{mode:_,existingAgentConfig:L,existingAgents:P.map(i=>({id:i.id,name:i.name,role:i.role})),templates:Q},x);if(!o.current)return;k(a.sessionId)}catch(a){if(!o.current)return;g(a.message),d("error")}},D=async()=>{if(c){d("loading"),g(null);try{const a={[w]:v};if(y(i=>[...i,{question:{id:w,type:"text",question:C},response:a}]),await K(c,a,x),!o.current)return;p("")}catch(a){if(!o.current)return;g(a.message),d("error")}}},O=async()=>{t&&(M(t),await u())};return n.jsx("div",{className:"modal-overlay open",role:"presentation",children:n.jsxs("div",{className:"modal modal-lg experimental-agent-onboarding-modal",role:"dialog","aria-modal":"true","aria-label":e("agents.onboarding.dialogLabel","AI Interview"),children:[n.jsxs("div",{className:"modal-header",children:[n.jsx("h3",{children:e("agents.onboarding.title","AI Interview")}),n.jsx("button",{className:"modal-close",onClick:()=>void u(),"aria-label":e("common.closeAriaLabel","Close"),children:"×"})]}),E.length>0&&n.jsx(V,{entries:E}),m==="initial"&&n.jsxs("div",{className:"form-group",children:[n.jsx("label",{htmlFor:"agent-onboarding-intent",children:b?e("agents.onboarding.intentLabelEdit","What should this agent change or improve?"):e("agents.onboarding.intentLabelCreate","What should this new agent own?")}),n.jsx("textarea",{id:"agent-onboarding-intent",className:"input experimental-agent-onboarding-modal__textarea",value:f,onChange:a=>S(a.target.value)}),n.jsxs("div",{className:"modal-actions",children:[n.jsx("button",{className:"btn",onClick:()=>void u(),children:e("common.cancel","Cancel")}),n.jsx("button",{className:"btn btn-primary",disabled:!f.trim(),onClick:()=>void q(),children:b?e("agents.onboarding.startInterview","Start interview"):e("agents.onboarding.startOnboarding","Start onboarding")})]})]}),(m==="loading"||m==="question")&&n.jsxs("div",{className:"form-group",children:[n.jsx("label",{htmlFor:"agent-onboarding-answer",children:C||e("agents.onboarding.thinking","Thinking...")}),n.jsx("textarea",{id:"agent-onboarding-answer",className:"input experimental-agent-onboarding-modal__textarea",value:v,onChange:a=>p(a.target.value)}),n.jsxs("div",{className:"modal-actions",children:[n.jsx("button",{className:"btn",onClick:()=>void u(),children:e("common.cancel","Cancel")}),n.jsx("button",{className:"btn btn-primary",disabled:m==="loading"||!v.trim(),onClick:()=>void D(),children:e("agents.onboarding.continue","Continue")})]})]}),m==="summary"&&t&&n.jsxs("div",{className:"form-group",children:[n.jsx("label",{children:b?e("agents.onboarding.updatedDraftReady","Updated draft ready for review"):e("agents.onboarding.draftReady","Draft ready for review")}),n.jsx("p",{className:"experimental-agent-onboarding-modal__summary-intro",children:e("agents.onboarding.draftIntro","Review this generated draft. Nothing is applied until you confirm.")}),n.jsxs("div",{className:"experimental-agent-onboarding-modal__summary card",children:[n.jsxs("div",{className:"experimental-agent-onboarding-modal__summary-section",children:[n.jsx("h4",{children:e("agents.onboarding.sectionIdentity","Identity")}),n.jsxs("dl",{className:"experimental-agent-onboarding-modal__summary-list",children:[n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldName","Name")}),n.jsx("dd",{children:r(t.name)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldRole","Role")}),n.jsx("dd",{children:r(t.role)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldTitle","Title")}),n.jsx("dd",{children:r(t.title)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldIcon","Icon")}),n.jsx("dd",{children:r(t.icon)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldReportsTo","Reports To")}),n.jsx("dd",{children:r(t.reportsTo)})]})]})]}),n.jsxs("div",{className:"experimental-agent-onboarding-modal__summary-section",children:[n.jsx("h4",{children:e("agents.onboarding.sectionConfiguration","Configuration")}),n.jsxs("dl",{className:"experimental-agent-onboarding-modal__summary-list",children:[n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldInlineInstructions","Inline Instructions")}),n.jsx("dd",{className:"experimental-agent-onboarding-modal__summary-block",children:r(t.instructionsText)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldSoul","Soul")}),n.jsx("dd",{className:"experimental-agent-onboarding-modal__summary-block",children:r(t.soul)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldAgentMemory","Agent Memory")}),n.jsx("dd",{className:"experimental-agent-onboarding-modal__summary-block",children:r(t.memory)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldSkills","Skills")}),n.jsx("dd",{children:r(t.skills?.join(", "))})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldThinkingLevel","Thinking Level")}),n.jsx("dd",{children:r(t.thinkingLevel)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldMaxTurns","Max Turns")}),n.jsx("dd",{children:r(t.maxTurns)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldTemplate","Template")}),n.jsx("dd",{children:r(t.templateId)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldPatternAgent","Pattern Agent")}),n.jsx("dd",{children:r(t.patternAgentId)})]})]})]}),(t.heartbeatProcedurePath||t.heartbeatIntervalMs||t.heartbeatEnabled!==void 0||t.modelHint||t.runtimeHint)&&n.jsxs("div",{className:"experimental-agent-onboarding-modal__summary-section",children:[n.jsx("h4",{children:e("agents.onboarding.sectionRuntimeHints","Runtime Hints")}),n.jsxs("dl",{className:"experimental-agent-onboarding-modal__summary-list",children:[n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldHeartbeatPath","Heartbeat Procedure Path")}),n.jsx("dd",{children:r(t.heartbeatProcedurePath)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldHeartbeatInterval","Heartbeat Interval")}),n.jsx("dd",{children:r(t.heartbeatIntervalMs?`${t.heartbeatIntervalMs}ms`:void 0)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldHeartbeatEnabled","Heartbeat Enabled")}),n.jsx("dd",{children:r(t.heartbeatEnabled===void 0?void 0:t.heartbeatEnabled?e("agents.onboarding.yes","yes"):e("agents.onboarding.no","no"))})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldModelHint","Model Hint")}),n.jsx("dd",{children:r(t.modelHint)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldRuntimeHint","Runtime Hint")}),n.jsx("dd",{children:r(t.runtimeHint)})]})]})]}),t.rationale&&n.jsxs("div",{className:"experimental-agent-onboarding-modal__summary-section",children:[n.jsx("h4",{children:e("agents.onboarding.sectionRationale","Rationale")}),n.jsx("p",{className:"experimental-agent-onboarding-modal__summary-block",children:t.rationale})]})]}),n.jsxs("div",{className:"modal-actions",children:[n.jsx("button",{className:"btn",onClick:()=>void u(),children:e("common.cancel","Cancel")}),n.jsx("button",{className:"btn btn-primary",onClick:()=>void O(),children:b?e("agents.onboarding.applyDraftSettings","Apply draft to settings form"):e("agents.onboarding.applyDraftAgent","Apply draft to agent form")})]})]}),m==="error"&&H&&n.jsxs("div",{className:"form-group",children:[n.jsx("div",{className:"form-error",children:H}),n.jsx("div",{className:"modal-actions",children:n.jsx("button",{className:"btn",onClick:()=>void u(),children:e("common.close","Close")})})]})]})})}export{en as ExperimentalAgentOnboardingModal};
1
+ import{r as s,j as n}from"./vendor-react-SZ_qB27O.js";import{A as F,K as U,N as V,O as W,Q as G,U as K}from"./index-rfsTNfpA.js";import{u as z}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-CnI7NMXG.js";import"./vendor-codemirror-jBKmHyH0.js";import"./vendor-xterm-BNq00GSj.js";function en({isOpen:l,onClose:R,onUseDraft:M,projectId:x,existingAgents:P,mode:_="create",existingAgentConfig:L}){const{t:e}=z("app"),[m,d]=s.useState("initial"),[f,S]=s.useState(""),[c,k]=s.useState(null),[C,I]=s.useState(""),[w,A]=s.useState("answer"),[v,p]=s.useState(""),[t,T]=s.useState(null),[H,g]=s.useState(null),[E,y]=s.useState([]),b=_==="edit",o=s.useRef(l),N=s.useCallback(()=>{d("initial"),S(""),k(null),I(""),A("answer"),p(""),T(null),g(null),y([])},[]),Q=s.useMemo(()=>F.map(a=>({id:a.id,label:a.name,description:a.description})),[]);s.useEffect(()=>{if(o.current=l,!c)return;const a=U(c,x,{onThinking:i=>{o.current&&y($=>{const h=[...$],j=h[h.length-1];return j&&!j.question?(h[h.length-1]={...j,thinkingOutput:`${j.thinkingOutput??""}${i}`},h):[...h,{response:{},thinkingOutput:i}]})},onQuestion:i=>{o.current&&(I(i.question),A(i.id),d("question"))},onSummary:i=>{o.current&&(T(i),d("summary"))},onError:i=>{o.current&&(g(i),d("error"))}});return()=>{o.current=!1,a.close()}},[l,c,x]);const u=async()=>{o.current=!1;try{c&&await W(c,x)}catch{}finally{N(),R()}};if(s.useEffect(()=>{o.current=l,l||N()},[l,N]),!l)return null;const r=a=>a==null||a===""?n.jsx("em",{className:"experimental-agent-onboarding-modal__summary-empty",children:e("agents.onboarding.notSet","Not set")}):n.jsx("span",{children:a}),q=async()=>{d("loading"),g(null);try{const a=await G(f,{mode:_,existingAgentConfig:L,existingAgents:P.map(i=>({id:i.id,name:i.name,role:i.role})),templates:Q},x);if(!o.current)return;k(a.sessionId)}catch(a){if(!o.current)return;g(a.message),d("error")}},D=async()=>{if(c){d("loading"),g(null);try{const a={[w]:v};if(y(i=>[...i,{question:{id:w,type:"text",question:C},response:a}]),await K(c,a,x),!o.current)return;p("")}catch(a){if(!o.current)return;g(a.message),d("error")}}},O=async()=>{t&&(M(t),await u())};return n.jsx("div",{className:"modal-overlay open",role:"presentation",children:n.jsxs("div",{className:"modal modal-lg experimental-agent-onboarding-modal",role:"dialog","aria-modal":"true","aria-label":e("agents.onboarding.dialogLabel","AI Interview"),children:[n.jsxs("div",{className:"modal-header",children:[n.jsx("h3",{children:e("agents.onboarding.title","AI Interview")}),n.jsx("button",{className:"modal-close",onClick:()=>void u(),"aria-label":e("common.closeAriaLabel","Close"),children:"×"})]}),E.length>0&&n.jsx(V,{entries:E}),m==="initial"&&n.jsxs("div",{className:"form-group",children:[n.jsx("label",{htmlFor:"agent-onboarding-intent",children:b?e("agents.onboarding.intentLabelEdit","What should this agent change or improve?"):e("agents.onboarding.intentLabelCreate","What should this new agent own?")}),n.jsx("textarea",{id:"agent-onboarding-intent",className:"input experimental-agent-onboarding-modal__textarea",value:f,onChange:a=>S(a.target.value)}),n.jsxs("div",{className:"modal-actions",children:[n.jsx("button",{className:"btn",onClick:()=>void u(),children:e("common.cancel","Cancel")}),n.jsx("button",{className:"btn btn-primary",disabled:!f.trim(),onClick:()=>void q(),children:b?e("agents.onboarding.startInterview","Start interview"):e("agents.onboarding.startOnboarding","Start onboarding")})]})]}),(m==="loading"||m==="question")&&n.jsxs("div",{className:"form-group",children:[n.jsx("label",{htmlFor:"agent-onboarding-answer",children:C||e("agents.onboarding.thinking","Thinking...")}),n.jsx("textarea",{id:"agent-onboarding-answer",className:"input experimental-agent-onboarding-modal__textarea",value:v,onChange:a=>p(a.target.value)}),n.jsxs("div",{className:"modal-actions",children:[n.jsx("button",{className:"btn",onClick:()=>void u(),children:e("common.cancel","Cancel")}),n.jsx("button",{className:"btn btn-primary",disabled:m==="loading"||!v.trim(),onClick:()=>void D(),children:e("agents.onboarding.continue","Continue")})]})]}),m==="summary"&&t&&n.jsxs("div",{className:"form-group",children:[n.jsx("label",{children:b?e("agents.onboarding.updatedDraftReady","Updated draft ready for review"):e("agents.onboarding.draftReady","Draft ready for review")}),n.jsx("p",{className:"experimental-agent-onboarding-modal__summary-intro",children:e("agents.onboarding.draftIntro","Review this generated draft. Nothing is applied until you confirm.")}),n.jsxs("div",{className:"experimental-agent-onboarding-modal__summary card",children:[n.jsxs("div",{className:"experimental-agent-onboarding-modal__summary-section",children:[n.jsx("h4",{children:e("agents.onboarding.sectionIdentity","Identity")}),n.jsxs("dl",{className:"experimental-agent-onboarding-modal__summary-list",children:[n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldName","Name")}),n.jsx("dd",{children:r(t.name)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldRole","Role")}),n.jsx("dd",{children:r(t.role)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldTitle","Title")}),n.jsx("dd",{children:r(t.title)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldIcon","Icon")}),n.jsx("dd",{children:r(t.icon)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldReportsTo","Reports To")}),n.jsx("dd",{children:r(t.reportsTo)})]})]})]}),n.jsxs("div",{className:"experimental-agent-onboarding-modal__summary-section",children:[n.jsx("h4",{children:e("agents.onboarding.sectionConfiguration","Configuration")}),n.jsxs("dl",{className:"experimental-agent-onboarding-modal__summary-list",children:[n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldInlineInstructions","Inline Instructions")}),n.jsx("dd",{className:"experimental-agent-onboarding-modal__summary-block",children:r(t.instructionsText)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldSoul","Soul")}),n.jsx("dd",{className:"experimental-agent-onboarding-modal__summary-block",children:r(t.soul)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldAgentMemory","Agent Memory")}),n.jsx("dd",{className:"experimental-agent-onboarding-modal__summary-block",children:r(t.memory)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldSkills","Skills")}),n.jsx("dd",{children:r(t.skills?.join(", "))})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldThinkingLevel","Thinking Level")}),n.jsx("dd",{children:r(t.thinkingLevel)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldMaxTurns","Max Turns")}),n.jsx("dd",{children:r(t.maxTurns)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldTemplate","Template")}),n.jsx("dd",{children:r(t.templateId)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldPatternAgent","Pattern Agent")}),n.jsx("dd",{children:r(t.patternAgentId)})]})]})]}),(t.heartbeatProcedurePath||t.heartbeatIntervalMs||t.heartbeatEnabled!==void 0||t.modelHint||t.runtimeHint)&&n.jsxs("div",{className:"experimental-agent-onboarding-modal__summary-section",children:[n.jsx("h4",{children:e("agents.onboarding.sectionRuntimeHints","Runtime Hints")}),n.jsxs("dl",{className:"experimental-agent-onboarding-modal__summary-list",children:[n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldHeartbeatPath","Heartbeat Procedure Path")}),n.jsx("dd",{children:r(t.heartbeatProcedurePath)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldHeartbeatInterval","Heartbeat Interval")}),n.jsx("dd",{children:r(t.heartbeatIntervalMs?`${t.heartbeatIntervalMs}ms`:void 0)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldHeartbeatEnabled","Heartbeat Enabled")}),n.jsx("dd",{children:r(t.heartbeatEnabled===void 0?void 0:t.heartbeatEnabled?e("agents.onboarding.yes","yes"):e("agents.onboarding.no","no"))})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldModelHint","Model Hint")}),n.jsx("dd",{children:r(t.modelHint)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldRuntimeHint","Runtime Hint")}),n.jsx("dd",{children:r(t.runtimeHint)})]})]})]}),t.rationale&&n.jsxs("div",{className:"experimental-agent-onboarding-modal__summary-section",children:[n.jsx("h4",{children:e("agents.onboarding.sectionRationale","Rationale")}),n.jsx("p",{className:"experimental-agent-onboarding-modal__summary-block",children:t.rationale})]})]}),n.jsxs("div",{className:"modal-actions",children:[n.jsx("button",{className:"btn",onClick:()=>void u(),children:e("common.cancel","Cancel")}),n.jsx("button",{className:"btn btn-primary",onClick:()=>void O(),children:b?e("agents.onboarding.applyDraftSettings","Apply draft to settings form"):e("agents.onboarding.applyDraftAgent","Apply draft to agent form")})]})]}),m==="error"&&H&&n.jsxs("div",{className:"form-group",children:[n.jsx("div",{className:"form-error",children:H}),n.jsx("div",{className:"modal-actions",children:n.jsx("button",{className:"btn",onClick:()=>void u(),children:e("common.close","Close")})})]})]})})}export{en as ExperimentalAgentOnboardingModal};
@@ -1,2 +1,2 @@
1
- import{r as n,j as t}from"./vendor-react-SZ_qB27O.js";import{V as js,T as ws,P as Ns,S as Es,s as Ss,v as $s,w as Ms,X as Cs,x as Ts,y as As}from"./index-B6ttSchA.js";import{u as Gs}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-CnI7NMXG.js";import"./vendor-xterm-BNq00GSj.js";import"./vendor-codemirror-jBKmHyH0.js";const Ls=5,Ds=3,Ps=280;function h(r,m){if(!m)return r;const d=r.includes("?")?"&":"?";return`${r}${d}projectId=${encodeURIComponent(m)}`}function is(r){return!!(r&&typeof r=="object"&&"code"in r&&r.code==="ACTIVE_GOAL_LIMIT_EXCEEDED")}function qs({initialGoals:r,anchorGoalId:m,projectId:d,onNavigateToMission:as}){const{t:a}=Gs("app"),[c,k]=n.useState(()=>r??[]),[ns,j]=n.useState(null),p=n.useRef(null),[w,L]=n.useState(r===void 0),[D,l]=n.useState(null),[os,P]=n.useState(!1),[y,F]=n.useState(""),[U,N]=n.useState(""),[R,u]=n.useState(null),[O,_]=n.useState(!1),[v,E]=n.useState(!1),[S,V]=n.useState(null),[q,$]=n.useState(""),[B,M]=n.useState(""),[H,f]=n.useState(null),[I,W]=n.useState(!1),[ls,rs]=n.useState(()=>new Set),[ds,cs]=n.useState([]),[x,C]=n.useState({}),[T,z]=n.useState({}),[A,K]=n.useState(null),[us,X]=n.useState(null);n.useEffect(()=>{if(r!==void 0)return;let s=!0;return(async()=>{try{L(!0),l(null);const i=await fetch(h("/api/goals",d));if(!i.ok)throw new Error(`Failed to load goals (${i.status})`);const o=await i.json();if(!s)return;k(Array.isArray(o.goals)?o.goals:[])}catch{if(!s)return;l(a("goals.loadError","Unable to load goals right now. Please try again."))}finally{s&&L(!1)}})(),()=>{s=!1}},[r,d]),n.useEffect(()=>{let s=!0;return(async()=>{try{const i=await fetch(h("/api/missions",d));if(!i.ok)throw new Error(`Failed to load missions (${i.status})`);const o=await i.json(),g=Array.isArray(o)?o:Array.isArray(o.missions)?o.missions:[];s&&cs(g.map(b=>({id:b.id,title:b.title,status:b.status})))}catch{s&&l(a("goals.missionsLoadError","Unable to load missions right now. Please try again."))}})(),()=>{s=!1}},[d,a]);const J=async s=>{const e=await fetch(h(`/api/goals/${encodeURIComponent(s)}/missions`,d));if(!e.ok)throw new Error(`Failed to load linked missions (${e.status})`);const i=await e.json();return Array.isArray(i.missions)?i.missions:[]};n.useEffect(()=>{let s=!0;return(async()=>{if(c.length===0){C({});return}try{const i=await Promise.all(c.map(async o=>[o.id,await J(o.id)]));s&&C(Object.fromEntries(i))}catch{s&&l(a("goals.linkedMissionsLoadError","Unable to load linked missions right now. Please try again."))}})(),()=>{s=!1}},[c,a]);const G=n.useMemo(()=>c.filter(s=>s.status==="active").length,[c]),gs=G>=Ds&&G<=Ls;n.useEffect(()=>{if(!m){j(null);return}const s=document.getElementById(`goal-card-${m}`);if(s)return j(m),typeof s.scrollIntoView=="function"&&s.scrollIntoView({behavior:"smooth",block:"center"}),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>{j(e=>e===m?null:e),p.current=null},1600),()=>{p.current&&(clearTimeout(p.current),p.current=null)}},[m,c]);function ms(){l(null),u(null),P(!0)}function hs(s){V(s.id),$(s.title),M(s.description??""),f(null)}function Q(){V(null),$(""),M(""),f(null)}function Y(){P(!1),F(""),N(""),u(null),E(!1)}async function ps(){const s=y.trim();if(!s){u(a("goals.titleRequired","Title is required."));return}try{E(!0),u(null);const e=await Ts(s,d);N(e)}catch(e){u(As(e))}finally{E(!1)}}async function fs(){const s=y.trim();if(!s){u(a("goals.titleRequired","Title is required."));return}try{_(!0),u(null),l(null);const e=await fetch(h("/api/goals",d),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({title:s,description:U})});if(e.ok){const o=await e.json();k(g=>[...g,o]),Y();return}let i=null;try{i=await e.json()}catch{i=null}if(e.status===409&&is(i)){l(a("goals.capError","Cannot activate more than 5 goals. Resolve an active goal before activating another."));return}u(a("goals.createError","Unable to create goal right now. Please try again."))}catch{u(a("goals.createError","Unable to create goal right now. Please try again."))}finally{_(!1)}}async function bs(){if(!S)return;const s=q.trim();if(!s){f(a("goals.titleRequired","Title is required."));return}try{W(!0),f(null);const e=await fetch(h(`/api/goals/${S}`,d),{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({title:s,description:B})});if(!e.ok)throw new Error(`Failed to update goal (${e.status})`);const i=await e.json();k(o=>o.map(g=>g.id===i.id?i:g)),Q()}catch{f(a("goals.saveError","Unable to save goal right now. Please try again."))}finally{W(!1)}}function ks(s){return s.length>Ps||s.includes(`
1
+ import{r as n,j as t}from"./vendor-react-SZ_qB27O.js";import{V as js,T as ws,P as Ns,S as Es,s as Ss,v as $s,w as Ms,X as Cs,x as Ts,y as As}from"./index-rfsTNfpA.js";import{u as Gs}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-CnI7NMXG.js";import"./vendor-codemirror-jBKmHyH0.js";import"./vendor-xterm-BNq00GSj.js";const Ls=5,Ds=3,Ps=280;function h(r,m){if(!m)return r;const d=r.includes("?")?"&":"?";return`${r}${d}projectId=${encodeURIComponent(m)}`}function is(r){return!!(r&&typeof r=="object"&&"code"in r&&r.code==="ACTIVE_GOAL_LIMIT_EXCEEDED")}function qs({initialGoals:r,anchorGoalId:m,projectId:d,onNavigateToMission:as}){const{t:a}=Gs("app"),[c,k]=n.useState(()=>r??[]),[ns,j]=n.useState(null),p=n.useRef(null),[w,L]=n.useState(r===void 0),[D,l]=n.useState(null),[os,P]=n.useState(!1),[y,F]=n.useState(""),[U,N]=n.useState(""),[R,u]=n.useState(null),[O,_]=n.useState(!1),[v,E]=n.useState(!1),[S,V]=n.useState(null),[q,$]=n.useState(""),[B,M]=n.useState(""),[H,f]=n.useState(null),[I,W]=n.useState(!1),[ls,rs]=n.useState(()=>new Set),[ds,cs]=n.useState([]),[x,C]=n.useState({}),[T,z]=n.useState({}),[A,K]=n.useState(null),[us,X]=n.useState(null);n.useEffect(()=>{if(r!==void 0)return;let s=!0;return(async()=>{try{L(!0),l(null);const i=await fetch(h("/api/goals",d));if(!i.ok)throw new Error(`Failed to load goals (${i.status})`);const o=await i.json();if(!s)return;k(Array.isArray(o.goals)?o.goals:[])}catch{if(!s)return;l(a("goals.loadError","Unable to load goals right now. Please try again."))}finally{s&&L(!1)}})(),()=>{s=!1}},[r,d]),n.useEffect(()=>{let s=!0;return(async()=>{try{const i=await fetch(h("/api/missions",d));if(!i.ok)throw new Error(`Failed to load missions (${i.status})`);const o=await i.json(),g=Array.isArray(o)?o:Array.isArray(o.missions)?o.missions:[];s&&cs(g.map(b=>({id:b.id,title:b.title,status:b.status})))}catch{s&&l(a("goals.missionsLoadError","Unable to load missions right now. Please try again."))}})(),()=>{s=!1}},[d,a]);const J=async s=>{const e=await fetch(h(`/api/goals/${encodeURIComponent(s)}/missions`,d));if(!e.ok)throw new Error(`Failed to load linked missions (${e.status})`);const i=await e.json();return Array.isArray(i.missions)?i.missions:[]};n.useEffect(()=>{let s=!0;return(async()=>{if(c.length===0){C({});return}try{const i=await Promise.all(c.map(async o=>[o.id,await J(o.id)]));s&&C(Object.fromEntries(i))}catch{s&&l(a("goals.linkedMissionsLoadError","Unable to load linked missions right now. Please try again."))}})(),()=>{s=!1}},[c,a]);const G=n.useMemo(()=>c.filter(s=>s.status==="active").length,[c]),gs=G>=Ds&&G<=Ls;n.useEffect(()=>{if(!m){j(null);return}const s=document.getElementById(`goal-card-${m}`);if(s)return j(m),typeof s.scrollIntoView=="function"&&s.scrollIntoView({behavior:"smooth",block:"center"}),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>{j(e=>e===m?null:e),p.current=null},1600),()=>{p.current&&(clearTimeout(p.current),p.current=null)}},[m,c]);function ms(){l(null),u(null),P(!0)}function hs(s){V(s.id),$(s.title),M(s.description??""),f(null)}function Q(){V(null),$(""),M(""),f(null)}function Y(){P(!1),F(""),N(""),u(null),E(!1)}async function ps(){const s=y.trim();if(!s){u(a("goals.titleRequired","Title is required."));return}try{E(!0),u(null);const e=await Ts(s,d);N(e)}catch(e){u(As(e))}finally{E(!1)}}async function fs(){const s=y.trim();if(!s){u(a("goals.titleRequired","Title is required."));return}try{_(!0),u(null),l(null);const e=await fetch(h("/api/goals",d),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({title:s,description:U})});if(e.ok){const o=await e.json();k(g=>[...g,o]),Y();return}let i=null;try{i=await e.json()}catch{i=null}if(e.status===409&&is(i)){l(a("goals.capError","Cannot activate more than 5 goals. Resolve an active goal before activating another."));return}u(a("goals.createError","Unable to create goal right now. Please try again."))}catch{u(a("goals.createError","Unable to create goal right now. Please try again."))}finally{_(!1)}}async function bs(){if(!S)return;const s=q.trim();if(!s){f(a("goals.titleRequired","Title is required."));return}try{W(!0),f(null);const e=await fetch(h(`/api/goals/${S}`,d),{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({title:s,description:B})});if(!e.ok)throw new Error(`Failed to update goal (${e.status})`);const i=await e.json();k(o=>o.map(g=>g.id===i.id?i:g)),Q()}catch{f(a("goals.saveError","Unable to save goal right now. Please try again."))}finally{W(!1)}}function ks(s){return s.length>Ps||s.includes(`
2
2
  `)}function ys(s){rs(e=>{const i=new Set(e);return i.has(s)?i.delete(s):i.add(s),i})}function Z(s){const e=new Set((x[s]??[]).map(i=>i.id));return ds.filter(i=>!e.has(i.id))}async function ss(s){const e=await J(s);C(i=>({...i,[s]:e})),z(i=>({...i,[s]:""}))}async function vs(s){const e=T[s];if(e)try{K(s),l(null);const i=await fetch(h(`/api/missions/${encodeURIComponent(e)}/goals/${encodeURIComponent(s)}`,d),{method:"POST"});if(!i.ok)throw new Error(`Failed to link mission (${i.status})`);await ss(s)}catch{l(a("goals.linkMissionError","Unable to link mission right now. Please try again."))}finally{K(null)}}async function xs(s,e){try{X(`${s}:${e}`),l(null);const i=await fetch(h(`/api/missions/${encodeURIComponent(e)}/goals/${encodeURIComponent(s)}`,d),{method:"DELETE"});if(!i.ok)throw new Error(`Failed to unlink mission (${i.status})`);await ss(s)}catch{l(a("goals.unlinkMissionError","Unable to unlink mission right now. Please try again."))}finally{X(null)}}async function ts(s){const e=s.status==="active"?`/api/goals/${s.id}/archive`:`/api/goals/${s.id}/unarchive`;try{l(null);const i=await fetch(h(e,d),{method:"POST"});if(i.ok){const g=await i.json();k(b=>b.map(es=>es.id===g.id?g:es));return}let o=null;try{o=await i.json()}catch{o=null}if(i.status===409&&is(o)){l(a("goals.capError","Cannot activate more than 5 goals. Resolve an active goal before activating another."));return}l(a("goals.updateError","Unable to update goal status right now. Please try again."))}catch{l(a("goals.updateError","Unable to update goal status right now. Please try again."))}}return t.jsxs("section",{className:"goals-view","data-testid":"goals-view",children:[t.jsx(js,{icon:ws,title:a("goals.title","Goals"),actions:t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"goals-count","data-testid":"goals-active-count",children:a("goals.activeCount","{{count}} active goals",{count:G})}),t.jsxs("button",{type:"button",className:"btn btn-primary goals-add-button",onClick:ms,"data-testid":"goals-add-button",children:[t.jsx(Ns,{size:18,"aria-hidden":"true"}),a("goals.addGoal","Add Goal")]})]})}),t.jsxs("div",{className:"goals-view__content",children:[os?t.jsxs("div",{className:"card goals-form","data-testid":"goals-form",children:[t.jsx("label",{className:"goals-form-label",htmlFor:"goals-form-title",children:a("goals.labelTitle","Title")}),t.jsx("input",{id:"goals-form-title",className:"input",type:"text",value:y,maxLength:200,onChange:s=>F(s.target.value),"data-testid":"goals-form-title"}),t.jsxs("div",{className:"goals-form-label-row",children:[t.jsx("label",{className:"goals-form-label",htmlFor:"goals-form-description",children:a("goals.labelDescription","Description")}),t.jsxs("button",{type:"button",className:"btn goals-form-draft-button",onClick:()=>void ps(),disabled:!y.trim()||v,"data-testid":"goals-form-draft-ai",children:[t.jsx(Es,{"aria-hidden":"true"}),v?a("goals.drafting","Drafting…"):a("goals.draftWithAi","Draft with AI")]})]}),t.jsx("textarea",{id:"goals-form-description",className:"input",value:U,maxLength:5e3,onChange:s=>N(s.target.value),"data-testid":"goals-form-description"}),R?t.jsx("p",{className:"form-error goals-error",role:"alert",children:R}):null,t.jsxs("div",{className:"goals-form-actions",children:[t.jsx("button",{type:"button",className:"btn btn-primary",onClick:()=>void fs(),disabled:O||v,"data-testid":"goals-form-submit",children:a("actions.save","Save")}),t.jsx("button",{type:"button",className:"btn",onClick:Y,disabled:O||v,"data-testid":"goals-form-cancel",children:a("actions.cancel","Cancel")})]})]}):null,gs?t.jsx("p",{className:"goals-warning",role:"status",children:a("goals.capWarning","Approaching the 5-active goal cap. Keep active goals focused.")}):null,D?t.jsx("p",{className:"form-error goals-error",role:"alert","data-testid":"goals-error",children:D}):null,w?t.jsx("p",{className:"goals-loading",role:"status","data-testid":"goals-loading",children:a("goals.loading","Loading goals…")}):null,!w&&c.length===0?t.jsx("div",{className:"goals-empty card","data-testid":"goals-empty-state",children:a("goals.emptyState","No goals yet. Add one to begin tracking strategic outcomes.")}):null,!w&&c.length>0?t.jsx("div",{className:"goals-list","data-testid":"goals-list",children:c.map(s=>t.jsxs("article",{id:`goal-card-${s.id}`,className:`card goals-card ${s.status==="archived"?"goals-card-archived":""} ${ns===s.id?"goals-card--anchored":""}`.trim(),"data-testid":`goal-card-${s.id}`,children:[S===s.id?t.jsxs("div",{className:"goals-card-main goals-card-edit",children:[t.jsx("label",{className:"goals-form-label",htmlFor:`goal-edit-title-${s.id}`,children:a("goals.labelTitle","Title")}),t.jsx("input",{id:`goal-edit-title-${s.id}`,className:"input",type:"text",value:q,maxLength:200,onChange:e=>$(e.target.value),"data-testid":`goal-edit-title-${s.id}`}),t.jsx("label",{className:"goals-form-label",htmlFor:`goal-edit-description-${s.id}`,children:a("goals.labelDescription","Description")}),t.jsx("textarea",{id:`goal-edit-description-${s.id}`,className:"input",value:B,maxLength:5e3,onChange:e=>M(e.target.value),"data-testid":`goal-edit-description-${s.id}`}),H?t.jsx("p",{className:"form-error goals-error",role:"alert",children:H}):null,t.jsxs("div",{className:"goals-card-actions",children:[t.jsx("button",{type:"button",className:"btn btn-primary",onClick:()=>void bs(),disabled:I,"data-testid":`goal-edit-save-${s.id}`,children:a("actions.save","Save")}),t.jsx("button",{type:"button",className:"btn",onClick:Q,disabled:I,"data-testid":`goal-edit-cancel-${s.id}`,children:a("actions.cancel","Cancel")})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"goals-card-main",children:[t.jsx("h3",{className:"goals-card-title",children:s.title}),s.description?(()=>{const e=ks(s.description),i=ls.has(s.id);return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`markdown-body goals-card-description ${e&&!i?"goals-card-description-collapsed":""}`.trim(),children:t.jsx(Ss,{remarkPlugins:[$s],children:s.description})}),e?t.jsx("button",{type:"button",className:"btn goals-card-description-toggle","aria-expanded":i,"data-testid":`goal-description-toggle-${s.id}`,onClick:()=>ys(s.id),children:i?a("actions.showLess","Show less"):a("actions.showMore","Show more")}):null]})})():null,t.jsxs("p",{className:"goals-card-status",children:[a("goals.status","Status"),": ",s.status]})]}),t.jsxs("div",{className:"goals-card-actions",children:[t.jsx("button",{type:"button",className:"btn",onClick:()=>hs(s),"data-testid":`goal-edit-${s.id}`,children:a("actions.edit","Edit")}),s.status==="active"?t.jsx("button",{type:"button",className:"btn goals-activate-button",onClick:()=>void ts(s),"data-testid":`goal-archive-${s.id}`,children:a("goals.archive","Archive")}):t.jsx("button",{type:"button",className:"btn goals-activate-button",onClick:()=>void ts(s),"data-testid":`goal-unarchive-${s.id}`,children:a("goals.unarchive","Unarchive")})]})]}),t.jsxs("section",{className:"goals-linked-missions","aria-label":a("goals.linkedMissions","Linked missions"),children:[t.jsxs("div",{className:"goals-linked-missions-header",children:[t.jsx("h4",{className:"goals-linked-missions-title",children:a("goals.linkedMissionsTitle","Linked Missions")}),t.jsx("span",{className:"goals-linked-missions-count",children:a("goals.linkedMissionsCount",{count:x[s.id]?.length??0,defaultValue_one:"{{count}} linked",defaultValue_other:"{{count}} linked"})})]}),t.jsxs("div",{className:"goals-linked-missions-controls",children:[t.jsxs("select",{className:"input goals-linked-missions-picker","data-testid":`goal-mission-picker-${s.id}`,value:T[s.id]??"",onChange:e=>z(i=>({...i,[s.id]:e.target.value})),"aria-label":a("goals.missionPicker","Mission to link"),disabled:A===s.id||Z(s.id).length===0,children:[t.jsx("option",{value:"",children:a("goals.selectMission","Select a mission")}),Z(s.id).map(e=>t.jsx("option",{value:e.id,children:e.title},e.id))]}),t.jsxs("button",{type:"button",className:"btn btn-primary goals-linked-missions-link-button","data-testid":`goal-mission-link-button-${s.id}`,disabled:!T[s.id]||A===s.id,onClick:()=>void vs(s.id),children:[t.jsx(Ms,{size:16,"aria-hidden":"true"}),A===s.id?a("goals.linkingMission","Linking…"):a("goals.linkMission","Link mission")]})]}),(x[s.id]?.length??0)>0?t.jsx("div",{className:"goals-linked-missions-list",children:(x[s.id]??[]).map(e=>t.jsxs("div",{className:"goals-linked-mission-chip","data-testid":`goal-linked-mission-chip-${e.id}`,children:[t.jsx("button",{type:"button",className:"btn goals-linked-mission-link",onClick:()=>as?.(e.id),children:e.title}),t.jsx("span",{className:"goals-linked-mission-status",children:e.status}),t.jsx("button",{type:"button",className:"btn-icon goals-linked-mission-unlink","data-testid":`goal-linked-mission-unlink-${e.id}`,"aria-label":a("goals.unlinkMission","Unlink mission"),disabled:us===`${s.id}:${e.id}`,onClick:()=>void xs(s.id,e.id),children:t.jsx(Cs,{size:16,"aria-hidden":"true"})})]},e.id))}):t.jsx("p",{className:"goals-linked-missions-empty",children:a("goals.noLinkedMissions","No linked missions.")})]})]},s.id))}):null]})]})}export{qs as GoalsView};
@@ -1,4 +1,4 @@
1
- import{r as c,j as e}from"./vendor-react-SZ_qB27O.js";import{c as Le,ay as ce,az as we,aA as ke,bC as Ce,bD as Ke,aD as je,bE as Ve,bF as We,bG as Ye,bH as Qe,bI as Je,bJ as Ze,bK as Me,bL as es,bM as ss,bN as Ie,V as ts,S as A,bO as is,X as Ae,bP as me,R as N,a3 as ns,bQ as as,h as ze,q as le,bR as Ne,bu as rs,P as _e,aj as cs,ba as De,bS as ls}from"./index-B6ttSchA.js";import{u as Pe}from"./vendor-i18n-GF3RlKbq.js";import{U as Ee}from"./users--1B6mnm8.js";import"./vendor-reactflow-CnI7NMXG.js";import"./vendor-xterm-BNq00GSj.js";import"./vendor-codemirror-jBKmHyH0.js";/**
1
+ import{r as c,j as e}from"./vendor-react-SZ_qB27O.js";import{c as Le,aA as ce,aB as Se,aC as ke,bE as Ce,bF as Ke,aF as je,bG as Ve,bH as We,bI as Ye,bJ as Qe,bK as Je,bL as Ze,bM as Me,bN as es,bO as ss,bP as Ie,V as ts,S as A,bQ as is,X as Ae,bR as me,R as N,a4 as ns,bS as as,h as _e,q as le,bT as Ne,bw as rs,P as ze,al as cs,bc as De,bU as ls}from"./index-rfsTNfpA.js";import{u as Pe}from"./vendor-i18n-GF3RlKbq.js";import{U as Fe}from"./users-BUMHTZuX.js";import"./vendor-reactflow-CnI7NMXG.js";import"./vendor-codemirror-jBKmHyH0.js";import"./vendor-xterm-BNq00GSj.js";/**
2
2
  * @license lucide-react v1.7.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -8,4 +8,4 @@ import{r as c,j as e}from"./vendor-react-SZ_qB27O.js";import{c as Le,ay as ce,az
8
8
  *
9
9
  * This source code is licensed under the ISC license.
10
10
  * See the LICENSE file in the root directory of this source tree.
11
- */const gs=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]],ds=Le("chart-line",gs),ue=["architecture","quality","workflow","performance","reliability","security","ux","testability","documentation","dependency","features","competitive_analysis","research","trends","other"],Fe={quality:"Quality",performance:"Performance",architecture:"Architecture",security:"Security",reliability:"Reliability",ux:"User Experience",testability:"Testability",documentation:"Documentation",dependency:"Dependencies",workflow:"Workflow",other:"Other",features:"Features",competitive_analysis:"Competitive Analysis",research:"Research",trends:"Trends"};function us(g){const{t:h}=Pe("app"),$=g??"",S=`${ke.INSIGHTS_PREFIX}${$}`,w=`${ke.INSIGHT_LATEST_RUN_PREFIX}${$}`,s=ce(S,{maxAgeMs:we}),V=ce(w,{maxAgeMs:Ce}),E=c.useRef(Array.isArray(s)&&s.length>0),G=c.useCallback(r=>h(`insights.category.${r}`,Fe[r]??r),[h]),[v,x]=c.useState(()=>Array.isArray(s)?s:[]),[T,W]=c.useState(()=>ue.map(r=>({category:r,label:Fe[r]??r,items:[],isLoading:!1,error:null}))),[Y,L]=c.useState(!(Array.isArray(s)&&s.length>0)),[Q,U]=c.useState(null),[J,z]=c.useState(V??null),[Z,H]=c.useState(!1),[ee,F]=c.useState(null),[se,_]=c.useState(new Map),[te,C]=c.useState(new Map),[u,k]=c.useState(new Map),[m,D]=c.useState(new Map),[O,j]=c.useState(!1),R=c.useCallback(async()=>{E.current||L(!0),U(null);try{const i=(await Ke({status:void 0,limit:1e3},g)).insights.filter(d=>d.status!=="dismissed");x(i),je(S,i.length>500?i.slice(0,500):i,{maxBytes:5e5});const t=await Ve(g);t.runs.length>0&&(z(t.runs[0]),je(w,t.runs[0],{maxBytes:5e5})),E.current=!0}catch(r){const i=r instanceof Error?r.message:"Failed to fetch insights";U(i)}finally{L(!1)}},[S,w,g]),y=c.useCallback(()=>{j(r=>!r)},[]),ie=c.useCallback(async(r,i)=>{H(!0),F(null);try{const t=await We("manual",void 0,g,r,i);z(t),t.status==="completed"?await R():t.status==="failed"&&t.error&&F(t.error)}catch(t){if(t instanceof Ye&&t.status===409&&t.details?.code==="ACTIVE_RUN_CONFLICT"){const f=typeof t.details.activeRunId=="string"?t.details.activeRunId:null;if(f)try{const ge=await Qe(f,g);z(ge)}catch{}throw F("Insight generation is already running"),t}const d=t instanceof Error?t.message:"Failed to generate insights";throw F(d),t}finally{H(!1)}},[g,R]),oe=c.useCallback(async r=>{_(i=>{const t=new Map(i);return t.set(r,{running:!0,error:null}),t});try{await Je(r,g),x(i=>i.filter(t=>t.id!==r)),_(i=>{const t=new Map(i);return t.set(r,{running:!1,error:null}),t})}catch(i){const t=i instanceof Error?i.message:"Failed to dismiss insight";throw _(d=>{const f=new Map(d);return f.set(r,{running:!1,error:t}),f}),i}},[g]),he=c.useCallback(async r=>{C(i=>{const t=new Map(i);return t.set(r,{running:!0,error:null}),t});try{const i=await Ze(r,g);return await Me(r,g),x(t=>t.map(d=>d.id===r?{...d,status:"archived",updatedAt:new Date().toISOString()}:d)),C(t=>{const d=new Map(t);return d.set(r,{running:!1,error:null}),d}),{title:i.suggestedTitle,description:i.suggestedDescription}}catch(i){const t=i instanceof Error?i.message:"Failed to create task";throw C(d=>{const f=new Map(d);return f.set(r,{running:!1,error:t}),f}),i}},[g]);c.useEffect(()=>{const r=new Map;for(const i of ue)r.set(i,[]);for(const i of v){if(!O&&i.status==="archived")continue;const t=r.get(i.category)??[];r.set(i.category,[...t,i])}W(ue.map(i=>({category:i,label:G(i),items:r.get(i)??[],isLoading:!1,error:null})))},[v,O,G]);const b=c.useCallback(async r=>{k(i=>{const t=new Map(i);return t.set(r,{running:!0,error:null}),t});try{await Me(r,g),x(i=>i.map(t=>t.id===r?{...t,status:"archived",updatedAt:new Date().toISOString()}:t)),k(i=>{const t=new Map(i);return t.set(r,{running:!1,error:null}),t})}catch(i){const t=i instanceof Error?i.message:"Failed to archive insight";throw k(d=>{const f=new Map(d);return f.set(r,{running:!1,error:t}),f}),i}},[g]),B=c.useCallback(async r=>{D(i=>{const t=new Map(i);return t.set(r,{running:!0,error:null}),t});try{await es(r,g),x(i=>i.map(t=>t.id===r?{...t,status:"confirmed",updatedAt:new Date().toISOString()}:t)),D(i=>{const t=new Map(i);return t.set(r,{running:!1,error:null}),t})}catch(i){const t=i instanceof Error?i.message:"Failed to unarchive insight";throw D(d=>{const f=new Map(d);return f.set(r,{running:!1,error:t}),f}),i}},[g]),p=c.useMemo(()=>T.reduce((r,i)=>r+i.items.length,0),[T]),X=c.useMemo(()=>0,[]),q=c.useMemo(()=>v.filter(r=>r.status==="archived").length,[v]);return c.useEffect(()=>{const r=ce(S,{maxAgeMs:we}),i=ce(w,{maxAgeMs:Ce}),t=Array.isArray(r)&&r.length>0;x(Array.isArray(r)?r:[]),z(i??null),L(!t),E.current=t},[S,w]),c.useEffect(()=>{R()},[R]),{sections:T,loading:Y,error:Q,latestRun:J,isRunInFlight:Z,runError:ee,refresh:R,runInsights:ie,dismiss:oe,createTask:he,archive:b,unarchive:B,toggleShowArchived:y,dismissStates:se,createTaskStates:te,archiveStates:u,unarchiveStates:m,totalCount:p,dismissedCount:X,archivedCount:q,showArchived:O}}const $e=["Backlog health:","Backlog pressure detected","Stale paused todo","Backlog health: dependency-blocked todos"];function Re(g){return $e.some(h=>g.title.startsWith(h))}const Te={architecture:hs,quality:ze,workflow:De,performance:Ne,reliability:N,security:le,ux:Ee,testability:me,documentation:cs,dependency:_e,features:rs,competitive_analysis:Ee,research:ds,trends:Ne,other:A};function Ss({projectId:g,addToast:h,onClose:$,onCreateTask:S,models:w}){const{t:s}=Pe("app"),{sections:V,loading:E,error:G,latestRun:v,isRunInFlight:x,runError:T,refresh:W,runInsights:Y,dismiss:L,createTask:Q,archive:U=async()=>{},unarchive:J=async()=>{},toggleShowArchived:z=()=>{},dismissStates:Z,createTaskStates:H,archiveStates:ee=new Map,unarchiveStates:F=new Map,totalCount:se,archivedCount:_=0,showArchived:te=!1}=us(g),[C,u]=c.useState(null),[k,m]=c.useState("info"),[D,O]=c.useState(!1),[j,R]=c.useState(!1),[y,ie]=c.useState(()=>localStorage.getItem("fusion-insight-model")??""),[oe,he]=c.useState([]),[b,B]=c.useState([]),[p,X]=c.useState([]),[q,r]=c.useState();c.useEffect(()=>{w||ss().then(n=>{he(n.models),B(n.favoriteProviders),X(n.favoriteModels),r(n.resolvedPlanningProvider);const a=localStorage.getItem("fusion-insight-model");a&&(n.models.some(o=>`${o.provider}/${o.id}`===a)||(localStorage.removeItem("fusion-insight-model"),ie("")))}).catch(()=>{})},[w]);const i=w??oe,t=c.useMemo(()=>b.length>0?b:q?[q]:[],[b,q]),d=c.useCallback(async n=>{const l=b.includes(n)?b.filter(o=>o!==n):[n,...b];B(l);try{await Ie({favoriteProviders:l,favoriteModels:p})}catch{B(b)}},[b,p]),f=c.useCallback(async n=>{const l=p.includes(n)?p.filter(o=>o!==n):[n,...p];X(l);try{await Ie({favoriteProviders:b,favoriteModels:l})}catch{X(p)}},[p,b]),ge=c.useCallback(n=>{ie(n),n?localStorage.setItem("fusion-insight-model",n):localStorage.removeItem("fusion-insight-model")},[]),K=c.useMemo(()=>V.filter(n=>n.items.length>0),[V]),fe=c.useMemo(()=>K.reduce((n,a)=>n+a.items.filter(Re).length,0),[K]),M=c.useMemo(()=>j?K.map(n=>({...n,items:n.items.filter(Re)})).filter(n=>n.items.length>0):K,[K,j]),[P,de]=c.useState(null);c.useEffect(()=>{if(M.length===0){P!==null&&de(null);return}P&&M.some(a=>a.category===P&&a.items.length>0)||de(M[0].category)},[M,P]);const I=c.useMemo(()=>M.find(n=>n.category===P)??M[0],[M,P]);c.useEffect(()=>{if(C){const n=setTimeout(()=>u(null),5e3);return()=>clearTimeout(n)}},[C]);const ve=c.useCallback(async()=>{try{u(s("insights.generatingInsights","Generating insights...")),m("info");let n,a;if(y){const l=y.indexOf("/");if(l!==-1){const o=y.slice(0,l),ne=y.slice(l+1);o&&ne&&(n=o,a=ne)}}await Y(n,a),u(s("insights.generationStarted","Insight generation started")),m("success"),h(s("insights.generationStarted","Insight generation started"),"success")}catch(n){const a=n instanceof Error?n.message:s("insights.failedToStart","Failed to start generation");if(a==="Insight generation is already running"){u(s("insights.alreadyRunning","Insight generation is already running. Showing the active run.")),m("info"),h(s("insights.alreadyRunningShort","Insight generation is already running"),"info");return}u(a),m("error"),h(a,"error")}},[Y,h,y,s]),Ge=c.useCallback(async(n,a)=>{try{u(s("insights.dismissing",'Dismissing "{{title}}"...',{title:a})),m("info"),await L(n),u(s("insights.dismissed",'Dismissed "{{title}}"',{title:a})),m("success"),h(s("insights.dismissedMsg","Insight dismissed: {{title}}",{title:a}),"success")}catch(l){const o=l instanceof Error?l.message:s("insights.failedToDismiss","Failed to dismiss insight");u(o),m("error"),h(o,"error")}},[L,h,s]),Ue=c.useCallback(async(n,a)=>{try{u(s("insights.archiving",'Archiving "{{title}}"...',{title:a})),m("info"),await U(n),u(s("insights.archived",'Archived "{{title}}"',{title:a})),m("success"),h(s("insights.archivedMsg","Insight archived: {{title}}",{title:a}),"success")}catch(l){const o=l instanceof Error?l.message:s("insights.failedToArchive","Failed to archive insight");u(o),m("error"),h(o,"error")}},[U,h,s]),He=c.useCallback(async(n,a)=>{try{u(s("insights.unarchiving",'Unarchiving "{{title}}"...',{title:a})),m("info"),await J(n),u(s("insights.unarchived",'Unarchived "{{title}}"',{title:a})),m("success"),h(s("insights.unarchivedMsg","Insight unarchived: {{title}}",{title:a}),"success")}catch(l){const o=l instanceof Error?l.message:s("insights.failedToUnarchive","Failed to unarchive insight");u(o),m("error"),h(o,"error")}},[J,h,s]),Oe=c.useCallback(async(n,a)=>{try{if(u(s("insights.creatingTask",'Creating task from "{{title}}"...',{title:a})),m("info"),!S)throw new Error(s("insights.taskCreationUnavailable","Task creation is unavailable in this view"));const l=await Q(n);if(!l)throw new Error(s("insights.failedToPreparePayload","Failed to prepare task payload from insight"));await S({insightId:n,title:l.title,description:l.description}),u(s("insights.taskCreated",'Task created from "{{title}}"',{title:a})),m("success"),h(s("insights.taskCreatedMsg","Task created: {{title}}",{title:l.title}),"success")}catch(l){const o=l instanceof Error?l.message:s("insights.failedToCreateTask","Failed to create task");u(o),m("error"),h(o,"error")}},[Q,S,h,s]),Be=n=>{const a=Te[n.category]??A,l=I?.category===n.category;return e.jsx("li",{children:e.jsxs("button",{type:"button",className:`insights-category-item${l?" insights-category-item--active":""}`,onClick:()=>de(n.category),"aria-current":l?"true":void 0,"data-testid":`insights-category-${n.category}`,children:[e.jsx(a,{size:16,className:"insights-category-icon"}),e.jsx("span",{className:"insights-category-label",children:n.label}),e.jsx("span",{className:"insights-category-count",children:n.items.length})]})},n.category)},Xe=()=>{if(!I)return null;const n=Te[I.category]??A;return e.jsxs("section",{className:"insights-section","data-testid":`insights-section-${I.category}`,children:[e.jsx("div",{className:"insights-section-header",children:e.jsxs("div",{className:"insights-section-title",children:[e.jsx(n,{size:20,className:"insights-section-icon"}),e.jsx("h3",{children:I.label}),e.jsx("span",{className:"insights-section-count",children:I.items.length})]})}),e.jsx("div",{className:"insights-section-content",children:e.jsx("ul",{className:"insights-list",children:I.items.map(a=>{const l=Z.get(a.id),o=H.get(a.id),ne=ee.get(a.id),qe=F.get(a.id),be=l?.running??!1,ye=o?.running??!1,xe=ne?.running??!1,pe=qe?.running??!1,Se=a.status==="archived",ae=I.items.some(re=>Z.get(re.id)?.running||H.get(re.id)?.running||ee.get(re.id)?.running||F.get(re.id)?.running);return e.jsxs("li",{className:`insight-item${Se?" insight-item--archived":""}`,"data-insight-id":a.id,children:[e.jsxs("div",{className:"insight-item-header",children:[e.jsx("h4",{className:"insight-item-title",children:a.title}),e.jsxs("div",{className:"insight-item-actions",children:[Se?e.jsx("button",{className:"insight-item-action-btn",onClick:()=>void He(a.id,a.title),disabled:pe||ae,title:s("insights.unarchiveTitle","Unarchive this insight"),"aria-label":s("insights.unarchiveLabel","Unarchive this insight"),"data-testid":`unarchive-${a.id}`,children:pe?e.jsx(N,{size:20,className:"spin"}):e.jsx(ls,{size:20})}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"insight-item-action-btn",onClick:()=>void Oe(a.id,a.title),disabled:ye||ae,title:s("insights.createTaskTitle","Create task from this insight"),"aria-label":s("insights.createTaskLabel","Create task from this insight"),"data-testid":`create-task-${a.id}`,children:ye?e.jsx(N,{size:20,className:"spin"}):e.jsx(_e,{size:20})}),e.jsx("button",{className:"insight-item-action-btn",onClick:()=>void Ue(a.id,a.title),disabled:xe||ae,title:s("insights.archiveTitle","Archive this insight"),"aria-label":s("insights.archiveLabel","Archive this insight"),"data-testid":`archive-${a.id}`,children:xe?e.jsx(N,{size:20,className:"spin"}):e.jsx(me,{size:20})})]}),e.jsx("button",{className:"insight-item-action-btn",onClick:()=>void Ge(a.id,a.title),disabled:be||ae,title:s("insights.dismissTitle","Dismiss this insight"),"aria-label":s("insights.dismissLabel","Dismiss this insight"),"data-testid":`dismiss-${a.id}`,children:be?e.jsx(N,{size:20,className:"spin"}):e.jsx(Ae,{size:20})})]})]}),a.content&&e.jsx("p",{className:"insight-item-content",children:a.content}),e.jsxs("div",{className:"insight-item-meta",children:[e.jsx("span",{className:`insight-item-status insight-item-status--${a.status}`,children:a.status}),a.createdAt&&e.jsxs("span",{className:"insight-item-date",children:[e.jsx(De,{size:12}),new Date(a.createdAt).toLocaleDateString()]})]})]},a.id)})})})]})};return e.jsxs("div",{className:"insights-view","data-testid":"insights-view",children:[e.jsx(ts,{icon:A,title:s("insights.title","Insights"),actions:e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"insights-view-count",children:[se," ",s("common.total","total")]}),fe>0&&e.jsxs("button",{className:`btn btn-sm insights-backlog-health-toggle${j?" btn-icon--active":""}`,onClick:()=>R(n=>!n),"aria-pressed":j,"aria-label":j?s("insights.showAllInsights","Show all insights"):s("insights.showBacklogHealth","Show only backlog health insights"),"data-testid":"toggle-backlog-health",title:$e.join(", "),children:[e.jsx(is,{size:14}),j?s("insights.allInsights","All Insights"):s("insights.backlogHealth","Backlog")," ",e.jsxs("span",{children:["(",fe,")"]})]}),$&&e.jsx("button",{className:"btn btn-sm insights-view-close",onClick:$,"aria-label":s("actions.closeInsightsView","Close insights view"),title:s("actions.close","Close"),children:e.jsx(Ae,{size:16})}),_>0&&e.jsxs("button",{className:"btn btn-sm insights-show-archived-toggle",onClick:z,"aria-label":te?s("insights.hideArchived","Hide archived insights"):s("insights.showArchived","Show archived insights"),"data-testid":"toggle-archived-insights",children:[e.jsx(me,{size:14}),te?s("insights.hideArchivedLabel","Archived"):s("insights.showArchivedLabel","Archived ({{count}})",{count:_})]}),e.jsx("button",{className:"btn btn-icon btn-sm insights-refresh-btn",onClick:()=>void W(),disabled:E,"aria-label":s("actions.refreshInsights","Refresh insights"),title:s("actions.refreshInsights","Refresh insights"),"data-testid":"refresh-insights",children:e.jsx(N,{size:14,className:E?"spin":""})}),e.jsxs("button",{className:"btn btn-sm insights-model-toggle",onClick:()=>O(n=>!n),"aria-label":s("insights.configureModel","Configure insight generation model"),"aria-expanded":D,"data-testid":"toggle-model-config",title:y?s("insights.modelConfigured","Model: {{model}}",{model:y}):s("insights.configureModelTitle","Configure model"),children:[e.jsx(ns,{size:14}),y&&e.jsx("span",{className:"insights-model-indicator"})]}),e.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>void ve(),disabled:x,"aria-label":s("insights.generateInsights","Generate new insights"),"data-testid":"run-insights",children:x?e.jsxs(e.Fragment,{children:[e.jsx(N,{size:14,className:"spin"}),s("insights.generating","Generating...")]}):e.jsxs(e.Fragment,{children:[e.jsx(A,{size:14}),s("insights.generateInsightsBtn","Generate Insights")]})})]})}),D&&e.jsxs("div",{className:"insights-model-config","data-testid":"model-config",children:[e.jsx("label",{htmlFor:"insight-model-select",className:"insights-model-label",children:s("insights.model","Model")}),e.jsx(as,{models:i,value:y,onChange:ge,placeholder:s("insights.usePlanningDefault","Use planning default"),label:s("insights.generationModel","Insight generation model"),disabled:x,id:"insight-model-select",favoriteProviders:t,favoriteModels:p,onToggleFavorite:d,onToggleModelFavorite:f})]}),e.jsx("div",{className:"insights-status-region","aria-live":"polite","data-testid":"insights-status",children:C&&e.jsxs("div",{className:`insights-status-message insights-status-message--${k}`,role:k==="error"?"alert":void 0,children:[k==="success"&&e.jsx(ze,{size:16}),k==="error"&&e.jsx(le,{size:16}),k==="info"&&e.jsx(A,{size:16}),e.jsx("span",{children:C})]})}),T&&e.jsxs("div",{className:"insights-error-callout",role:"alert","data-testid":"run-error",children:[e.jsx(le,{size:16}),e.jsx("span",{children:T})]}),v&&e.jsx("div",{className:"insights-run-info","data-testid":"latest-run",children:e.jsxs("span",{className:"insights-run-status",children:[s("insights.latestRun","Latest run:")," ",v.status,v.status==="completed"&&e.jsxs(e.Fragment,{children:[" — ",s("insights.runCompleted","{{created}} created, {{updated}} updated",{created:v.insightsCreated,updated:v.insightsUpdated})]}),v.status==="failed"&&v.error&&e.jsxs(e.Fragment,{children:[" — ",v.error]})]})}),E?e.jsxs("div",{className:"insights-loading","data-testid":"insights-loading",children:[e.jsx(N,{size:24,className:"spin"}),e.jsx("p",{children:s("insights.loading","Loading insights...")})]}):G?e.jsxs("div",{className:"insights-error","data-testid":"insights-error",children:[e.jsx(le,{size:24}),e.jsx("p",{children:G}),e.jsx("button",{className:"btn btn-sm",onClick:()=>void W(),children:s("actions.retry","Retry")})]}):se===0?e.jsxs("div",{className:"insights-empty","data-testid":"insights-empty",children:[e.jsx(A,{size:48}),e.jsx("h3",{children:s("insights.noInsightsYet","No insights yet")}),e.jsx("p",{children:s("insights.generateDescription","Generate insights to get AI-powered recommendations for your project.")}),e.jsxs("button",{className:"btn btn-primary",onClick:()=>void ve(),children:[e.jsx(A,{size:14}),s("insights.generateFirst","Generate First Insights")]})]}):e.jsxs("div",{className:"insights-body",children:[e.jsx("aside",{className:"insights-sidebar","aria-label":s("insights.categoriesLabel","Insight categories"),children:e.jsx("ul",{className:"insights-category-list",children:M.map(Be)})}),e.jsx("div",{className:"insights-detail",children:Xe()})]})]})}export{Ss as InsightsView};
11
+ */const gs=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]],ds=Le("chart-line",gs),ue=["architecture","quality","workflow","performance","reliability","security","ux","testability","documentation","dependency","features","competitive_analysis","research","trends","other"],Ee={quality:"Quality",performance:"Performance",architecture:"Architecture",security:"Security",reliability:"Reliability",ux:"User Experience",testability:"Testability",documentation:"Documentation",dependency:"Dependencies",workflow:"Workflow",other:"Other",features:"Features",competitive_analysis:"Competitive Analysis",research:"Research",trends:"Trends"};function us(g){const{t:h}=Pe("app"),U=g??"",w=`${ke.INSIGHTS_PREFIX}${U}`,S=`${ke.INSIGHT_LATEST_RUN_PREFIX}${U}`,s=ce(w,{maxAgeMs:Se}),V=ce(S,{maxAgeMs:Ce}),F=c.useRef(Array.isArray(s)&&s.length>0),$=c.useCallback(r=>h(`insights.category.${r}`,Ee[r]??r),[h]),[v,x]=c.useState(()=>Array.isArray(s)?s:[]),[T,W]=c.useState(()=>ue.map(r=>({category:r,label:Ee[r]??r,items:[],isLoading:!1,error:null}))),[Y,L]=c.useState(!(Array.isArray(s)&&s.length>0)),[Q,G]=c.useState(null),[J,_]=c.useState(V??null),[Z,H]=c.useState(!1),[ee,E]=c.useState(null),[se,z]=c.useState(new Map),[te,C]=c.useState(new Map),[u,k]=c.useState(new Map),[m,D]=c.useState(new Map),[B,j]=c.useState(!1),R=c.useCallback(async()=>{F.current||L(!0),G(null);try{const i=(await Ke({status:void 0,limit:1e3},g)).insights.filter(d=>d.status!=="dismissed");x(i),je(w,i.length>500?i.slice(0,500):i,{maxBytes:5e5});const t=await Ve(g);t.runs.length>0&&(_(t.runs[0]),je(S,t.runs[0],{maxBytes:5e5})),F.current=!0}catch(r){const i=r instanceof Error?r.message:"Failed to fetch insights";G(i)}finally{L(!1)}},[w,S,g]),y=c.useCallback(()=>{j(r=>!r)},[]),ie=c.useCallback(async(r,i)=>{H(!0),E(null);try{const t=await We("manual",void 0,g,r,i);_(t),t.status==="completed"?await R():t.status==="failed"&&t.error&&E(t.error)}catch(t){if(t instanceof Ye&&t.status===409&&t.details?.code==="ACTIVE_RUN_CONFLICT"){const f=typeof t.details.activeRunId=="string"?t.details.activeRunId:null;if(f)try{const ge=await Qe(f,g);_(ge)}catch{}throw E("Insight generation is already running"),t}const d=t instanceof Error?t.message:"Failed to generate insights";throw E(d),t}finally{H(!1)}},[g,R]),oe=c.useCallback(async r=>{z(i=>{const t=new Map(i);return t.set(r,{running:!0,error:null}),t});try{await Je(r,g),x(i=>i.filter(t=>t.id!==r)),z(i=>{const t=new Map(i);return t.set(r,{running:!1,error:null}),t})}catch(i){const t=i instanceof Error?i.message:"Failed to dismiss insight";throw z(d=>{const f=new Map(d);return f.set(r,{running:!1,error:t}),f}),i}},[g]),he=c.useCallback(async r=>{C(i=>{const t=new Map(i);return t.set(r,{running:!0,error:null}),t});try{const i=await Ze(r,g);return await Me(r,g),x(t=>t.map(d=>d.id===r?{...d,status:"archived",updatedAt:new Date().toISOString()}:d)),C(t=>{const d=new Map(t);return d.set(r,{running:!1,error:null}),d}),{title:i.suggestedTitle,description:i.suggestedDescription}}catch(i){const t=i instanceof Error?i.message:"Failed to create task";throw C(d=>{const f=new Map(d);return f.set(r,{running:!1,error:t}),f}),i}},[g]);c.useEffect(()=>{const r=new Map;for(const i of ue)r.set(i,[]);for(const i of v){if(!B&&i.status==="archived")continue;const t=r.get(i.category)??[];r.set(i.category,[...t,i])}W(ue.map(i=>({category:i,label:$(i),items:r.get(i)??[],isLoading:!1,error:null})))},[v,B,$]);const b=c.useCallback(async r=>{k(i=>{const t=new Map(i);return t.set(r,{running:!0,error:null}),t});try{await Me(r,g),x(i=>i.map(t=>t.id===r?{...t,status:"archived",updatedAt:new Date().toISOString()}:t)),k(i=>{const t=new Map(i);return t.set(r,{running:!1,error:null}),t})}catch(i){const t=i instanceof Error?i.message:"Failed to archive insight";throw k(d=>{const f=new Map(d);return f.set(r,{running:!1,error:t}),f}),i}},[g]),O=c.useCallback(async r=>{D(i=>{const t=new Map(i);return t.set(r,{running:!0,error:null}),t});try{await es(r,g),x(i=>i.map(t=>t.id===r?{...t,status:"confirmed",updatedAt:new Date().toISOString()}:t)),D(i=>{const t=new Map(i);return t.set(r,{running:!1,error:null}),t})}catch(i){const t=i instanceof Error?i.message:"Failed to unarchive insight";throw D(d=>{const f=new Map(d);return f.set(r,{running:!1,error:t}),f}),i}},[g]),p=c.useMemo(()=>T.reduce((r,i)=>r+i.items.length,0),[T]),X=c.useMemo(()=>0,[]),q=c.useMemo(()=>v.filter(r=>r.status==="archived").length,[v]);return c.useEffect(()=>{const r=ce(w,{maxAgeMs:Se}),i=ce(S,{maxAgeMs:Ce}),t=Array.isArray(r)&&r.length>0;x(Array.isArray(r)?r:[]),_(i??null),L(!t),F.current=t},[w,S]),c.useEffect(()=>{R()},[R]),{sections:T,loading:Y,error:Q,latestRun:J,isRunInFlight:Z,runError:ee,refresh:R,runInsights:ie,dismiss:oe,createTask:he,archive:b,unarchive:O,toggleShowArchived:y,dismissStates:se,createTaskStates:te,archiveStates:u,unarchiveStates:m,totalCount:p,dismissedCount:X,archivedCount:q,showArchived:B}}const Ue=["Backlog health:","Backlog pressure detected","Stale paused todo","Backlog health: dependency-blocked todos"];function Re(g){return Ue.some(h=>g.title.startsWith(h))}const Te={architecture:hs,quality:_e,workflow:De,performance:Ne,reliability:N,security:le,ux:Fe,testability:me,documentation:cs,dependency:ze,features:rs,competitive_analysis:Fe,research:ds,trends:Ne,other:A};function ws({projectId:g,addToast:h,onClose:U,onCreateTask:w,models:S}){const{t:s}=Pe("app"),{sections:V,loading:F,error:$,latestRun:v,isRunInFlight:x,runError:T,refresh:W,runInsights:Y,dismiss:L,createTask:Q,archive:G=async()=>{},unarchive:J=async()=>{},toggleShowArchived:_=()=>{},dismissStates:Z,createTaskStates:H,archiveStates:ee=new Map,unarchiveStates:E=new Map,totalCount:se,archivedCount:z=0,showArchived:te=!1}=us(g),[C,u]=c.useState(null),[k,m]=c.useState("info"),[D,B]=c.useState(!1),[j,R]=c.useState(!1),[y,ie]=c.useState(()=>localStorage.getItem("fusion-insight-model")??""),[oe,he]=c.useState([]),[b,O]=c.useState([]),[p,X]=c.useState([]),[q,r]=c.useState();c.useEffect(()=>{S||ss().then(n=>{he(n.models),O(n.favoriteProviders),X(n.favoriteModels),r(n.resolvedPlanningProvider);const a=localStorage.getItem("fusion-insight-model");a&&(n.models.some(o=>`${o.provider}/${o.id}`===a)||(localStorage.removeItem("fusion-insight-model"),ie("")))}).catch(()=>{})},[S]);const i=S??oe,t=c.useMemo(()=>b.length>0?b:q?[q]:[],[b,q]),d=c.useCallback(async n=>{const l=b.includes(n)?b.filter(o=>o!==n):[n,...b];O(l);try{await Ie({favoriteProviders:l,favoriteModels:p})}catch{O(b)}},[b,p]),f=c.useCallback(async n=>{const l=p.includes(n)?p.filter(o=>o!==n):[n,...p];X(l);try{await Ie({favoriteProviders:b,favoriteModels:l})}catch{X(p)}},[p,b]),ge=c.useCallback(n=>{ie(n),n?localStorage.setItem("fusion-insight-model",n):localStorage.removeItem("fusion-insight-model")},[]),K=c.useMemo(()=>V.filter(n=>n.items.length>0),[V]),fe=c.useMemo(()=>K.reduce((n,a)=>n+a.items.filter(Re).length,0),[K]),M=c.useMemo(()=>j?K.map(n=>({...n,items:n.items.filter(Re)})).filter(n=>n.items.length>0):K,[K,j]),[P,de]=c.useState(null);c.useEffect(()=>{if(M.length===0){P!==null&&de(null);return}P&&M.some(a=>a.category===P&&a.items.length>0)||de(M[0].category)},[M,P]);const I=c.useMemo(()=>M.find(n=>n.category===P)??M[0],[M,P]);c.useEffect(()=>{if(C){const n=setTimeout(()=>u(null),5e3);return()=>clearTimeout(n)}},[C]);const ve=c.useCallback(async()=>{try{u(s("insights.generatingInsights","Generating insights...")),m("info");let n,a;if(y){const l=y.indexOf("/");if(l!==-1){const o=y.slice(0,l),ne=y.slice(l+1);o&&ne&&(n=o,a=ne)}}await Y(n,a),u(s("insights.generationStarted","Insight generation started")),m("success"),h(s("insights.generationStarted","Insight generation started"),"success")}catch(n){const a=n instanceof Error?n.message:s("insights.failedToStart","Failed to start generation");if(a==="Insight generation is already running"){u(s("insights.alreadyRunning","Insight generation is already running. Showing the active run.")),m("info"),h(s("insights.alreadyRunningShort","Insight generation is already running"),"info");return}u(a),m("error"),h(a,"error")}},[Y,h,y,s]),$e=c.useCallback(async(n,a)=>{try{u(s("insights.dismissing",'Dismissing "{{title}}"...',{title:a})),m("info"),await L(n),u(s("insights.dismissed",'Dismissed "{{title}}"',{title:a})),m("success"),h(s("insights.dismissedMsg","Insight dismissed: {{title}}",{title:a}),"success")}catch(l){const o=l instanceof Error?l.message:s("insights.failedToDismiss","Failed to dismiss insight");u(o),m("error"),h(o,"error")}},[L,h,s]),Ge=c.useCallback(async(n,a)=>{try{u(s("insights.archiving",'Archiving "{{title}}"...',{title:a})),m("info"),await G(n),u(s("insights.archived",'Archived "{{title}}"',{title:a})),m("success"),h(s("insights.archivedMsg","Insight archived: {{title}}",{title:a}),"success")}catch(l){const o=l instanceof Error?l.message:s("insights.failedToArchive","Failed to archive insight");u(o),m("error"),h(o,"error")}},[G,h,s]),He=c.useCallback(async(n,a)=>{try{u(s("insights.unarchiving",'Unarchiving "{{title}}"...',{title:a})),m("info"),await J(n),u(s("insights.unarchived",'Unarchived "{{title}}"',{title:a})),m("success"),h(s("insights.unarchivedMsg","Insight unarchived: {{title}}",{title:a}),"success")}catch(l){const o=l instanceof Error?l.message:s("insights.failedToUnarchive","Failed to unarchive insight");u(o),m("error"),h(o,"error")}},[J,h,s]),Be=c.useCallback(async(n,a)=>{try{if(u(s("insights.creatingTask",'Creating task from "{{title}}"...',{title:a})),m("info"),!w)throw new Error(s("insights.taskCreationUnavailable","Task creation is unavailable in this view"));const l=await Q(n);if(!l)throw new Error(s("insights.failedToPreparePayload","Failed to prepare task payload from insight"));await w({insightId:n,title:l.title,description:l.description}),u(s("insights.taskCreated",'Task created from "{{title}}"',{title:a})),m("success"),h(s("insights.taskCreatedMsg","Task created: {{title}}",{title:l.title}),"success")}catch(l){const o=l instanceof Error?l.message:s("insights.failedToCreateTask","Failed to create task");u(o),m("error"),h(o,"error")}},[Q,w,h,s]),Oe=n=>{const a=Te[n.category]??A,l=I?.category===n.category;return e.jsx("li",{children:e.jsxs("button",{type:"button",className:`insights-category-item${l?" insights-category-item--active":""}`,onClick:()=>de(n.category),"aria-current":l?"true":void 0,"data-testid":`insights-category-${n.category}`,children:[e.jsx(a,{size:16,className:"insights-category-icon"}),e.jsx("span",{className:"insights-category-label",children:n.label}),e.jsx("span",{className:"insights-category-count",children:n.items.length})]})},n.category)},Xe=()=>{if(!I)return null;const n=Te[I.category]??A;return e.jsxs("section",{className:"insights-section","data-testid":`insights-section-${I.category}`,children:[e.jsx("div",{className:"insights-section-header",children:e.jsxs("div",{className:"insights-section-title",children:[e.jsx(n,{size:20,className:"insights-section-icon"}),e.jsx("h3",{children:I.label}),e.jsx("span",{className:"insights-section-count",children:I.items.length})]})}),e.jsx("div",{className:"insights-section-content",children:e.jsx("ul",{className:"insights-list",children:I.items.map(a=>{const l=Z.get(a.id),o=H.get(a.id),ne=ee.get(a.id),qe=E.get(a.id),be=l?.running??!1,ye=o?.running??!1,xe=ne?.running??!1,pe=qe?.running??!1,we=a.status==="archived",ae=I.items.some(re=>Z.get(re.id)?.running||H.get(re.id)?.running||ee.get(re.id)?.running||E.get(re.id)?.running);return e.jsxs("li",{className:`insight-item${we?" insight-item--archived":""}`,"data-insight-id":a.id,children:[e.jsxs("div",{className:"insight-item-header",children:[e.jsx("h4",{className:"insight-item-title",children:a.title}),e.jsxs("div",{className:"insight-item-actions",children:[we?e.jsx("button",{className:"insight-item-action-btn",onClick:()=>void He(a.id,a.title),disabled:pe||ae,title:s("insights.unarchiveTitle","Unarchive this insight"),"aria-label":s("insights.unarchiveLabel","Unarchive this insight"),"data-testid":`unarchive-${a.id}`,children:pe?e.jsx(N,{size:20,className:"spin"}):e.jsx(ls,{size:20})}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"insight-item-action-btn",onClick:()=>void Be(a.id,a.title),disabled:ye||ae,title:s("insights.createTaskTitle","Create task from this insight"),"aria-label":s("insights.createTaskLabel","Create task from this insight"),"data-testid":`create-task-${a.id}`,children:ye?e.jsx(N,{size:20,className:"spin"}):e.jsx(ze,{size:20})}),e.jsx("button",{className:"insight-item-action-btn",onClick:()=>void Ge(a.id,a.title),disabled:xe||ae,title:s("insights.archiveTitle","Archive this insight"),"aria-label":s("insights.archiveLabel","Archive this insight"),"data-testid":`archive-${a.id}`,children:xe?e.jsx(N,{size:20,className:"spin"}):e.jsx(me,{size:20})})]}),e.jsx("button",{className:"insight-item-action-btn",onClick:()=>void $e(a.id,a.title),disabled:be||ae,title:s("insights.dismissTitle","Dismiss this insight"),"aria-label":s("insights.dismissLabel","Dismiss this insight"),"data-testid":`dismiss-${a.id}`,children:be?e.jsx(N,{size:20,className:"spin"}):e.jsx(Ae,{size:20})})]})]}),a.content&&e.jsx("p",{className:"insight-item-content",children:a.content}),e.jsxs("div",{className:"insight-item-meta",children:[e.jsx("span",{className:`insight-item-status insight-item-status--${a.status}`,children:a.status}),a.createdAt&&e.jsxs("span",{className:"insight-item-date",children:[e.jsx(De,{size:12}),new Date(a.createdAt).toLocaleDateString()]})]})]},a.id)})})})]})};return e.jsxs("div",{className:"insights-view","data-testid":"insights-view",children:[e.jsx(ts,{icon:A,title:s("insights.title","Insights"),actions:e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"insights-view-count",children:[se," ",s("common.total","total")]}),fe>0&&e.jsxs("button",{className:`btn btn-sm insights-backlog-health-toggle${j?" btn-icon--active":""}`,onClick:()=>R(n=>!n),"aria-pressed":j,"aria-label":j?s("insights.showAllInsights","Show all insights"):s("insights.showBacklogHealth","Show only backlog health insights"),"data-testid":"toggle-backlog-health",title:Ue.join(", "),children:[e.jsx(is,{size:14}),j?s("insights.allInsights","All Insights"):s("insights.backlogHealth","Backlog")," ",e.jsxs("span",{children:["(",fe,")"]})]}),U&&e.jsx("button",{className:"btn btn-sm insights-view-close",onClick:U,"aria-label":s("actions.closeInsightsView","Close insights view"),title:s("actions.close","Close"),children:e.jsx(Ae,{size:16})}),z>0&&e.jsxs("button",{className:"btn btn-sm insights-show-archived-toggle",onClick:_,"aria-label":te?s("insights.hideArchived","Hide archived insights"):s("insights.showArchived","Show archived insights"),"data-testid":"toggle-archived-insights",children:[e.jsx(me,{size:14}),te?s("insights.hideArchivedLabel","Archived"):s("insights.showArchivedLabel","Archived ({{count}})",{count:z})]}),e.jsx("button",{className:"btn btn-icon btn-sm insights-refresh-btn",onClick:()=>void W(),disabled:F,"aria-label":s("actions.refreshInsights","Refresh insights"),title:s("actions.refreshInsights","Refresh insights"),"data-testid":"refresh-insights",children:e.jsx(N,{size:14,className:F?"spin":""})}),e.jsxs("button",{className:"btn btn-sm insights-model-toggle",onClick:()=>B(n=>!n),"aria-label":s("insights.configureModel","Configure insight generation model"),"aria-expanded":D,"data-testid":"toggle-model-config",title:y?s("insights.modelConfigured","Model: {{model}}",{model:y}):s("insights.configureModelTitle","Configure model"),children:[e.jsx(ns,{size:14}),y&&e.jsx("span",{className:"insights-model-indicator"})]}),e.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>void ve(),disabled:x,"aria-label":s("insights.generateInsights","Generate new insights"),"data-testid":"run-insights",children:x?e.jsxs(e.Fragment,{children:[e.jsx(N,{size:14,className:"spin"}),s("insights.generating","Generating...")]}):e.jsxs(e.Fragment,{children:[e.jsx(A,{size:14}),s("insights.generateInsightsBtn","Generate Insights")]})})]})}),D&&e.jsxs("div",{className:"insights-model-config","data-testid":"model-config",children:[e.jsx("label",{htmlFor:"insight-model-select",className:"insights-model-label",children:s("insights.model","Model")}),e.jsx(as,{models:i,value:y,onChange:ge,placeholder:s("insights.usePlanningDefault","Use planning default"),label:s("insights.generationModel","Insight generation model"),disabled:x,id:"insight-model-select",favoriteProviders:t,favoriteModels:p,onToggleFavorite:d,onToggleModelFavorite:f})]}),e.jsx("div",{className:"insights-status-region","aria-live":"polite","data-testid":"insights-status",children:C&&e.jsxs("div",{className:`insights-status-message insights-status-message--${k}`,role:k==="error"?"alert":void 0,children:[k==="success"&&e.jsx(_e,{size:16}),k==="error"&&e.jsx(le,{size:16}),k==="info"&&e.jsx(A,{size:16}),e.jsx("span",{children:C})]})}),T&&e.jsxs("div",{className:"insights-error-callout",role:"alert","data-testid":"run-error",children:[e.jsx(le,{size:16}),e.jsx("span",{children:T})]}),v&&e.jsx("div",{className:"insights-run-info","data-testid":"latest-run",children:e.jsxs("span",{className:"insights-run-status",children:[s("insights.latestRun","Latest run:")," ",v.status,v.status==="completed"&&e.jsxs(e.Fragment,{children:[" — ",s("insights.runCompleted","{{created}} created, {{updated}} updated",{created:v.insightsCreated,updated:v.insightsUpdated})]}),v.status==="failed"&&v.error&&e.jsxs(e.Fragment,{children:[" — ",v.error]})]})}),F?e.jsxs("div",{className:"insights-loading","data-testid":"insights-loading",children:[e.jsx(N,{size:24,className:"spin"}),e.jsx("p",{children:s("insights.loading","Loading insights...")})]}):$?e.jsxs("div",{className:"insights-error","data-testid":"insights-error",children:[e.jsx(le,{size:24}),e.jsx("p",{children:$}),e.jsx("button",{className:"btn btn-sm",onClick:()=>void W(),children:s("actions.retry","Retry")})]}):se===0?e.jsxs("div",{className:"insights-empty","data-testid":"insights-empty",children:[e.jsx(A,{size:48}),e.jsx("h3",{children:s("insights.noInsightsYet","No insights yet")}),e.jsx("p",{children:s("insights.generateDescription","Generate insights to get AI-powered recommendations for your project.")}),e.jsxs("button",{className:"btn btn-primary",onClick:()=>void ve(),children:[e.jsx(A,{size:14}),s("insights.generateFirst","Generate First Insights")]})]}):e.jsxs("div",{className:"insights-body",children:[e.jsx("aside",{className:"insights-sidebar","aria-label":s("insights.categoriesLabel","Insight categories"),children:e.jsx("ul",{className:"insights-category-list",children:M.map(Oe)})}),e.jsx("div",{className:"insights-detail",children:Xe()})]})]})}export{ws as InsightsView};
@@ -1,2 +1,2 @@
1
- import{r,j as e}from"./vendor-react-SZ_qB27O.js";import{u as Re}from"./SettingsModal-D7YgojbV.js";import{aT as Me,aU as we,aV as qe,aW as Te,aX as Pe,aY as We,aZ as He,a_ as Ae,a$ as Fe,b0 as _e,b1 as Ue,b2 as Oe,b3 as De,b4 as Qe,aS as $e,b5 as Be,V as Ve,b6 as Ye,L as F,b7 as ze}from"./index-B6ttSchA.js";import{u as Ge}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-CnI7NMXG.js";import"./vendor-xterm-BNq00GSj.js";import"./vendor-codemirror-jBKmHyH0.js";const B=".fusion/memory/MEMORY.md",Ze=5e4,Xe="0 3 * * *",Ke="0 4 * * *";function ge(i){return{memoryEnabled:i.memoryEnabled!==!1,memoryAutoSummarizeEnabled:i.memoryAutoSummarizeEnabled??!1,memoryAutoSummarizeThresholdChars:i.memoryAutoSummarizeThresholdChars??Ze,memoryAutoSummarizeSchedule:i.memoryAutoSummarizeSchedule??Xe,memoryDreamsEnabled:i.memoryDreamsEnabled??!1,memoryDreamsSchedule:i.memoryDreamsSchedule??Ke}}function Le(i,t){return i.some(h=>h.path===t)?t:i.find(h=>h.path===B)?.path??i[0]?.path??B}function Je(i={}){const{projectId:t}=i,[h,s]=r.useState(""),[u,S]=r.useState(!0),[k,I]=r.useState(!1),[D,j]=r.useState(!1),[p,E]=r.useState(null),[n,M]=r.useState(!0),[V,_]=r.useState(!1),[re,U]=r.useState(()=>ge({})),[w,Y]=r.useState(!0),[z,me]=r.useState(!1),[be,O]=r.useState([]),[d,x]=r.useState(!0),[f,A]=r.useState(B),[o,v]=r.useState(""),[ne,R]=r.useState(!1),[c,N]=r.useState(!1),[pe,G]=r.useState(!1),[ie,Z]=r.useState(!1),[le,X]=r.useState(!1),[K,Q]=r.useState(null),[L,$]=r.useState(!0),[xe,q]=r.useState(!1),[fe,J]=r.useState(!1),[oe,ee]=r.useState(null),{status:ce,loading:de,refresh:se}=Re({projectId:t}),te=r.useCallback(m=>{v(m),N(!0)},[]),g=r.useCallback(async m=>{R(!0);try{const{content:l}=await Me(m,t);A(m),v(l),N(!1)}finally{R(!1)}},[t]),T=r.useCallback(async()=>{x(!0);try{const{files:m}=await we(t);if(O(m),m.length===0){A(B),v(""),N(!1);return}const l=Le(m,f);l!==f&&await g(l)}finally{x(!1)}},[t,f,g]);r.useEffect(()=>{let m=!1;async function l(){try{const y=await Qe(t);m||(s(y.content),S(!1))}catch{m||(s(""),S(!1))}}return l(),()=>{m=!0}},[t]),r.useEffect(()=>{let m=!1;async function l(){try{const y=await Fe(t);m||(E(y.content),_(y.exists),M(!1))}catch{m||(E(null),_(!1),M(!1))}}return l(),()=>{m=!0}},[t]),r.useEffect(()=>{let m=!1;async function l(){Y(!0);try{const y=await $e(t);m||U(ge(y))}catch{m||U(ge({}))}finally{m||Y(!1)}}return l(),()=>{m=!0}},[t]),r.useEffect(()=>{let m=!1;async function l(){x(!0);try{const{files:y}=await we(t);if(m)return;if(O(y),y.length===0){A(B),v(""),N(!1);return}const H=Le(y,f),{content:a}=await Me(H,t);if(m)return;A(H),v(a),N(!1)}catch{m||(O([]),A(B),v(""),N(!1))}finally{m||x(!1)}}return l(),()=>{m=!0}},[t,f]),r.useEffect(()=>{let m=!1;async function l(){try{const y=await Ae(t);m||(Q(y),$(!1))}catch{m||(Q(null),$(!1))}}return l(),()=>{m=!0}},[t]),r.useEffect(()=>{let m=!1;async function l(){try{const y=await Be(t);m||ee(y)}catch{m||ee(null)}}return l(),()=>{m=!0}},[t]);const P=r.useCallback(m=>{s(m),I(!0)},[]),Se=r.useCallback(async()=>{if(k){j(!0);try{await qe(h,t),I(!1)}finally{j(!1)}}},[h,k,t]),ye=r.useCallback(async m=>{me(!0);try{const l=await Te(m,t);U(ge(l))}finally{me(!1)}},[t]),he=r.useCallback(async m=>{await g(m)},[g]),je=r.useCallback(async()=>{if(c){G(!0);try{await Pe(f,o,t),N(!1),await T()}finally{G(!1)}}},[o,c,f,t,T]),ve=r.useCallback(async()=>{J(!0);try{const m=await We(t);return await se(),m}finally{J(!1)}},[t,se]),Ne=r.useCallback(async m=>He(m,t),[t]),ae=r.useCallback(async()=>{try{const m=await Ae(t);Q(m)}catch{Q(null)}},[t]),W=r.useCallback(async()=>{try{const m=await Fe(t);E(m.content),_(m.exists)}catch{E(null),_(!1)}},[t]),Ce=r.useCallback(async m=>{await _e(m,t),await W()},[t,W]),ke=r.useCallback(async()=>{Z(!0);try{const m=await Ue(t);return await Promise.all([W(),ae()]),{success:m.success,summary:m.summary}}finally{Z(!1)}},[t,W,ae]),ue=r.useCallback(async()=>{X(!0);try{return await Oe(t)}finally{X(!1)}},[t]),Ee=r.useCallback(async m=>{q(!0);try{const l=m?await De(m,t):await De(t);if(m){const y=l.path??m;A(y),v(l.content),N(!1),await T();return}s(l.content),I(!0)}finally{q(!1)}},[t,T]);return{workingMemory:h,workingMemoryLoading:u,workingMemoryDirty:k,setWorkingMemory:P,saveWorkingMemory:Se,savingWorkingMemory:D,insightsContent:p,insightsLoading:n,insightsExists:V,refreshInsights:W,saveInsights:Ce,memorySettings:re,settingsLoading:w,savingMemorySettings:z,saveMemorySettings:ye,memoryFiles:be,memoryFilesLoading:d,selectedFilePath:f,selectedFileContent:o,selectedFileLoading:ne,selectedFileDirty:c,setSelectedFileContent:te,selectFile:he,saveSelectedFile:je,savingSelectedFile:pe,reloadMemoryFiles:T,backendStatus:ce,backendLoading:de,extractInsights:ke,extracting:ie,triggerDreamNow:ue,dreamRunning:le,auditReport:K,auditLoading:L,refreshAudit:ae,compactMemory:Ee,compacting:xe,installQmdAction:ve,installingQmd:fe,testRetrieval:Ne,stats:oe}}const es={Patterns:"pattern",Principles:"principle",Conventions:"convention",Pitfalls:"pitfall",Context:"context"},ss=72;function ts(i,t){if(i.length<=t)return i;const h=Math.max(1,t-1),s=Math.ceil(h/2),u=Math.floor(h/2);return`${i.slice(0,s)}…${i.slice(i.length-u)}`}function as(i){const t=`${i.label} — ${i.path}`;return ts(t,ss)}function rs(i){if(!i)return[];const t=[],h=i.split(/(?=^## )/m);for(const s of h){const u=s.trim();if(!u)continue;const S=u.match(/^##\s+(.+?)(\n|$)/);if(S){const k=S[1].trim(),I=es[k]??k.toLowerCase(),D=u.slice(S[0].length).trim(),j=D.split(`
1
+ import{r,j as e}from"./vendor-react-SZ_qB27O.js";import{u as Re}from"./SettingsModal-Coqvlmud.js";import{aV as Me,aW as we,aX as qe,aY as Te,aZ as Pe,a_ as We,a$ as He,b0 as Ae,b1 as Fe,b2 as _e,b3 as Ue,b4 as Oe,b5 as De,b6 as Qe,aU as $e,b7 as Be,V as Ve,b8 as Ye,L as F,b9 as ze}from"./index-rfsTNfpA.js";import{u as Ge}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-CnI7NMXG.js";import"./vendor-codemirror-jBKmHyH0.js";import"./vendor-xterm-BNq00GSj.js";const B=".fusion/memory/MEMORY.md",Ze=5e4,Xe="0 3 * * *",Ke="0 4 * * *";function ge(i){return{memoryEnabled:i.memoryEnabled!==!1,memoryAutoSummarizeEnabled:i.memoryAutoSummarizeEnabled??!1,memoryAutoSummarizeThresholdChars:i.memoryAutoSummarizeThresholdChars??Ze,memoryAutoSummarizeSchedule:i.memoryAutoSummarizeSchedule??Xe,memoryDreamsEnabled:i.memoryDreamsEnabled??!1,memoryDreamsSchedule:i.memoryDreamsSchedule??Ke}}function Le(i,t){return i.some(h=>h.path===t)?t:i.find(h=>h.path===B)?.path??i[0]?.path??B}function Je(i={}){const{projectId:t}=i,[h,s]=r.useState(""),[u,S]=r.useState(!0),[k,I]=r.useState(!1),[D,j]=r.useState(!1),[p,E]=r.useState(null),[n,M]=r.useState(!0),[V,_]=r.useState(!1),[re,U]=r.useState(()=>ge({})),[w,Y]=r.useState(!0),[z,me]=r.useState(!1),[be,O]=r.useState([]),[d,x]=r.useState(!0),[f,A]=r.useState(B),[o,v]=r.useState(""),[ne,R]=r.useState(!1),[c,N]=r.useState(!1),[pe,G]=r.useState(!1),[ie,Z]=r.useState(!1),[le,X]=r.useState(!1),[K,Q]=r.useState(null),[L,$]=r.useState(!0),[xe,q]=r.useState(!1),[fe,J]=r.useState(!1),[oe,ee]=r.useState(null),{status:ce,loading:de,refresh:se}=Re({projectId:t}),te=r.useCallback(m=>{v(m),N(!0)},[]),g=r.useCallback(async m=>{R(!0);try{const{content:l}=await Me(m,t);A(m),v(l),N(!1)}finally{R(!1)}},[t]),T=r.useCallback(async()=>{x(!0);try{const{files:m}=await we(t);if(O(m),m.length===0){A(B),v(""),N(!1);return}const l=Le(m,f);l!==f&&await g(l)}finally{x(!1)}},[t,f,g]);r.useEffect(()=>{let m=!1;async function l(){try{const y=await Qe(t);m||(s(y.content),S(!1))}catch{m||(s(""),S(!1))}}return l(),()=>{m=!0}},[t]),r.useEffect(()=>{let m=!1;async function l(){try{const y=await Fe(t);m||(E(y.content),_(y.exists),M(!1))}catch{m||(E(null),_(!1),M(!1))}}return l(),()=>{m=!0}},[t]),r.useEffect(()=>{let m=!1;async function l(){Y(!0);try{const y=await $e(t);m||U(ge(y))}catch{m||U(ge({}))}finally{m||Y(!1)}}return l(),()=>{m=!0}},[t]),r.useEffect(()=>{let m=!1;async function l(){x(!0);try{const{files:y}=await we(t);if(m)return;if(O(y),y.length===0){A(B),v(""),N(!1);return}const H=Le(y,f),{content:a}=await Me(H,t);if(m)return;A(H),v(a),N(!1)}catch{m||(O([]),A(B),v(""),N(!1))}finally{m||x(!1)}}return l(),()=>{m=!0}},[t,f]),r.useEffect(()=>{let m=!1;async function l(){try{const y=await Ae(t);m||(Q(y),$(!1))}catch{m||(Q(null),$(!1))}}return l(),()=>{m=!0}},[t]),r.useEffect(()=>{let m=!1;async function l(){try{const y=await Be(t);m||ee(y)}catch{m||ee(null)}}return l(),()=>{m=!0}},[t]);const P=r.useCallback(m=>{s(m),I(!0)},[]),Se=r.useCallback(async()=>{if(k){j(!0);try{await qe(h,t),I(!1)}finally{j(!1)}}},[h,k,t]),ye=r.useCallback(async m=>{me(!0);try{const l=await Te(m,t);U(ge(l))}finally{me(!1)}},[t]),he=r.useCallback(async m=>{await g(m)},[g]),je=r.useCallback(async()=>{if(c){G(!0);try{await Pe(f,o,t),N(!1),await T()}finally{G(!1)}}},[o,c,f,t,T]),ve=r.useCallback(async()=>{J(!0);try{const m=await We(t);return await se(),m}finally{J(!1)}},[t,se]),Ne=r.useCallback(async m=>He(m,t),[t]),ae=r.useCallback(async()=>{try{const m=await Ae(t);Q(m)}catch{Q(null)}},[t]),W=r.useCallback(async()=>{try{const m=await Fe(t);E(m.content),_(m.exists)}catch{E(null),_(!1)}},[t]),Ce=r.useCallback(async m=>{await _e(m,t),await W()},[t,W]),ke=r.useCallback(async()=>{Z(!0);try{const m=await Ue(t);return await Promise.all([W(),ae()]),{success:m.success,summary:m.summary}}finally{Z(!1)}},[t,W,ae]),ue=r.useCallback(async()=>{X(!0);try{return await Oe(t)}finally{X(!1)}},[t]),Ee=r.useCallback(async m=>{q(!0);try{const l=m?await De(m,t):await De(t);if(m){const y=l.path??m;A(y),v(l.content),N(!1),await T();return}s(l.content),I(!0)}finally{q(!1)}},[t,T]);return{workingMemory:h,workingMemoryLoading:u,workingMemoryDirty:k,setWorkingMemory:P,saveWorkingMemory:Se,savingWorkingMemory:D,insightsContent:p,insightsLoading:n,insightsExists:V,refreshInsights:W,saveInsights:Ce,memorySettings:re,settingsLoading:w,savingMemorySettings:z,saveMemorySettings:ye,memoryFiles:be,memoryFilesLoading:d,selectedFilePath:f,selectedFileContent:o,selectedFileLoading:ne,selectedFileDirty:c,setSelectedFileContent:te,selectFile:he,saveSelectedFile:je,savingSelectedFile:pe,reloadMemoryFiles:T,backendStatus:ce,backendLoading:de,extractInsights:ke,extracting:ie,triggerDreamNow:ue,dreamRunning:le,auditReport:K,auditLoading:L,refreshAudit:ae,compactMemory:Ee,compacting:xe,installQmdAction:ve,installingQmd:fe,testRetrieval:Ne,stats:oe}}const es={Patterns:"pattern",Principles:"principle",Conventions:"convention",Pitfalls:"pitfall",Context:"context"},ss=72;function ts(i,t){if(i.length<=t)return i;const h=Math.max(1,t-1),s=Math.ceil(h/2),u=Math.floor(h/2);return`${i.slice(0,s)}…${i.slice(i.length-u)}`}function as(i){const t=`${i.label} — ${i.path}`;return ts(t,ss)}function rs(i){if(!i)return[];const t=[],h=i.split(/(?=^## )/m);for(const s of h){const u=s.trim();if(!u)continue;const S=u.match(/^##\s+(.+?)(\n|$)/);if(S){const k=S[1].trim(),I=es[k]??k.toLowerCase(),D=u.slice(S[0].length).trim(),j=D.split(`
2
2
  `).map(p=>p.replace(/^-\s+/,"").trim()).filter(p=>p.length>0&&(p.startsWith("- ")||p.startsWith("* ")));(j.length>0||D.length>0)&&t.push({name:k,key:I,items:j.length>0?j:D.length>0?[D]:[],expanded:!0})}}return t}function ms(i){if(!i)return null;const t=i.match(/##\s+Last\s+Updated:\s*(\d{4}-\d{2}-\d{2})/i);return t?t[1]:null}function ns(i){return i.reduce((t,h)=>t+h.items.length,0)}function us({projectId:i,addToast:t,onSendSelectionToTask:h}){const{t:s}=Ge("app"),[u,S]=r.useState("working"),[k,I]=r.useState(new Set),[D,j]=r.useState(!1),[p,E]=r.useState(null),[n,M]=r.useState({memoryEnabled:!0,memoryAutoSummarizeEnabled:!1,memoryAutoSummarizeThresholdChars:5e4,memoryAutoSummarizeSchedule:"0 3 * * *",memoryDreamsEnabled:!1,memoryDreamsSchedule:"0 4 * * *"}),[V,_]=r.useState(""),[re,U]=r.useState(!1),[w,Y]=r.useState(null),{insightsContent:z,insightsLoading:me,insightsExists:be,saveInsights:O,memorySettings:d,settingsLoading:x,saveMemorySettings:f,savingMemorySettings:A,backendStatus:o,backendLoading:v,extractInsights:ne,extracting:R,auditReport:c,auditLoading:N,refreshAudit:pe,compactMemory:G,compacting:ie,installQmdAction:Z,installingQmd:le,testRetrieval:X,memoryFiles:K,memoryFilesLoading:Q,selectedFilePath:L,selectedFileContent:$,selectedFileLoading:xe,selectedFileDirty:q,setSelectedFileContent:fe,selectFile:J,saveSelectedFile:oe,savingSelectedFile:ee,reloadMemoryFiles:ce,triggerDreamNow:de,dreamRunning:se}=Je({projectId:i});r.useEffect(()=>{M(d)},[d]);const te=r.useMemo(()=>n.memoryEnabled!==d.memoryEnabled||n.memoryAutoSummarizeEnabled!==d.memoryAutoSummarizeEnabled||n.memoryAutoSummarizeThresholdChars!==d.memoryAutoSummarizeThresholdChars||n.memoryAutoSummarizeSchedule!==d.memoryAutoSummarizeSchedule||n.memoryDreamsEnabled!==d.memoryDreamsEnabled||n.memoryDreamsSchedule!==d.memoryDreamsSchedule,[n,d]),g=r.useMemo(()=>K.find(a=>a.path===L),[K,L]),T=g?g.layer==="long-term"?s("memory.layerDescLongTerm","Curated durable decisions, conventions, constraints, and pitfalls promoted from dreams."):g.layer==="daily"?s("memory.layerDescDaily","Raw daily observations, open loops, and running context for dream processing."):s("memory.layerDescDreams","Synthesized patterns and open loops promoted from daily memory."):s("memory.editorDefaultDescription","Edits the selected memory file."),P=r.useMemo(()=>rs(z),[z]),Se=r.useMemo(()=>ns(P),[P]),ye=r.useMemo(()=>ms(z),[z]),he=r.useCallback(a=>{I(b=>{const C=new Set(b);return C.has(a)?C.delete(a):C.add(a),C})},[]),je=r.useCallback(async a=>{try{await J(a)}catch{t(s("memory.loadFileFailed","Failed to load memory file"),"error")}},[J,t]),ve=r.useCallback(async()=>{try{await oe(),t(s("memory.memorySaved","Memory saved"),"success")}catch{t(s("memory.saveMemoryFailed","Failed to save memory"),"error")}},[oe,t]),Ne=r.useCallback(async()=>{if(!te)return;const a={};n.memoryEnabled!==d.memoryEnabled&&(a.memoryEnabled=n.memoryEnabled),n.memoryAutoSummarizeEnabled!==d.memoryAutoSummarizeEnabled&&(a.memoryAutoSummarizeEnabled=n.memoryAutoSummarizeEnabled),n.memoryAutoSummarizeThresholdChars!==d.memoryAutoSummarizeThresholdChars&&(a.memoryAutoSummarizeThresholdChars=n.memoryAutoSummarizeThresholdChars),n.memoryAutoSummarizeSchedule!==d.memoryAutoSummarizeSchedule&&(a.memoryAutoSummarizeSchedule=n.memoryAutoSummarizeSchedule),n.memoryDreamsEnabled!==d.memoryDreamsEnabled&&(a.memoryDreamsEnabled=n.memoryDreamsEnabled),n.memoryDreamsSchedule!==d.memoryDreamsSchedule&&(a.memoryDreamsSchedule=n.memoryDreamsSchedule);try{await f(a),t(s("memory.settingsSaved","Memory settings saved"),"success")}catch{t(s("memory.saveSettingsFailed","Failed to save memory settings"),"error")}},[te,n,d,f,t]),ae=r.useCallback(async()=>{try{const a=await Z();t(a.qmdAvailable?s("memory.qmdInstallSuccess","qmd installed successfully"):s("memory.qmdInstallUnavailable","qmd install finished, but qmd is still unavailable"),a.qmdAvailable?"success":"info")}catch{t(s("memory.installQmdFailed","Failed to install qmd"),"error")}},[Z,t]),W=r.useCallback(async()=>{U(!0),Y(null);try{const a=await X(V);Y(a),t(a.qmdAvailable?s("memory.retrievalTestComplete","Memory retrieval test complete"):s("memory.retrievalTestFallback","qmd is not installed; local fallback was used"),a.qmdAvailable?"success":"info")}catch{t(s("memory.retrievalTestFailed","Failed to test memory retrieval"),"error")}finally{U(!1)}},[V,X,t]),Ce=r.useCallback(async()=>{try{await de(),t(s("memory.dreamProcessingComplete","Dream processing completed"),"success"),await ce()}catch(a){t(a instanceof Error?a.message:s("memory.dreamProcessingFailed","Failed to run dream processing"),"error")}},[de,ce,t]),ke=r.useCallback(async()=>{try{await G(L),t(s("memory.fileCompacted","Memory file compacted"),"success")}catch{t(s("memory.compactFailed","Failed to compact memory"),"error")}},[G,L,t]),ue=r.useCallback(async()=>{try{const a=await ne();t(a.summary,"success")}catch(a){t(a instanceof Error?a.message:s("memory.extractInsightsFailed","Failed to extract insights"),"error")}},[ne,t]),Ee=r.useCallback(async()=>{if(p!==null)try{await O(p),j(!1),E(null),t(s("memory.insightsSaved","Insights saved"),"success")}catch{t(s("memory.saveInsightsFailed","Failed to save insights"),"error")}},[p,O,t]),m=r.useCallback(()=>{E(z??""),j(!0)},[z]),l=r.useCallback(()=>{j(!1),E(null)},[]),y=!v&&o!==null,H=o?.capabilities?.writable??!1;return e.jsxs("div",{className:"memory-view",children:[e.jsx(Ve,{icon:Ye,title:s("memory.title","Memory")}),e.jsxs("div",{className:"memory-view-tabs",role:"tablist",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":u==="working",className:`memory-view-tab${u==="working"?" memory-view-tab--active":""}`,onClick:()=>S("working"),"data-testid":"memory-tab-working",children:s("memory.tabWorking","Working Memory")}),e.jsx("button",{type:"button",role:"tab","aria-selected":u==="insights",className:`memory-view-tab${u==="insights"?" memory-view-tab--active":""}`,onClick:()=>S("insights"),"data-testid":"memory-tab-insights",children:s("memory.tabInsights","Insights")}),e.jsx("button",{type:"button",role:"tab","aria-selected":u==="engines",className:`memory-view-tab${u==="engines"?" memory-view-tab--active":""}`,onClick:()=>S("engines"),"data-testid":"memory-tab-engines",children:s("memory.tabEngines","Engines")})]}),e.jsxs("div",{className:"memory-view-content",children:[u==="working"&&e.jsxs("div",{className:"memory-working-tab",children:[y&&!H&&e.jsx("div",{className:"memory-readonly-banner",children:s("memory.readOnlyBanner","This memory backend is read-only. Changes cannot be saved.")}),Q||xe?e.jsxs("div",{className:"memory-empty-state",children:[e.jsx(F,{size:20,className:"animate-spin"}),e.jsx("span",{children:s("memory.loadingFile","Loading memory file…")})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"memory-editor-section",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"memoryViewFilePath",children:s("memory.fileLabel","Memory File")}),e.jsx("select",{id:"memoryViewFilePath",className:"select",value:L,onChange:a=>{je(a.target.value)},disabled:q,children:K.map(a=>e.jsx("option",{value:a.path,title:`${a.label} — ${a.path}`,children:as(a)},a.path))}),e.jsx("small",{children:q?s("memory.fileSwitchDirtyHint","Save or discard the current edits before switching files."):s("memory.fileSwitchHint","Choose any project memory file to view or edit.")})]}),g&&e.jsxs("div",{className:"memory-file-summary",children:[e.jsx("span",{children:g.layer==="long-term"?s("memory.layerLongTerm","Long-term"):g.layer==="daily"?s("memory.layerDaily","Daily"):s("memory.layerDreams","Dreams")}),e.jsx("strong",{children:g.path}),e.jsx("small",{children:s("memory.fileSummary","{{size}} bytes · updated {{updatedAt}}",{size:g.size.toLocaleString(),updatedAt:new Date(g.updatedAt).toLocaleString()})})]}),e.jsxs("div",{className:"form-group memory-editor-form-group",children:[e.jsx("label",{children:g?.label||s("memory.editorLabel","Memory Editor")}),e.jsx("small",{children:T}),e.jsx("div",{className:"memory-editor-container",children:e.jsx(ze,{content:$,onChange:fe,readOnly:!H,filePath:L,onSendSelectionToTask:h})})]})]}),e.jsxs("div",{className:"memory-action-bar",children:[e.jsx("span",{className:"memory-char-count",children:s("memory.charCount","{{count}} characters",{count:$.length})}),e.jsx("div",{className:"memory-flex-spacer"}),H&&$.length>0&&e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:ke,disabled:ie||q,children:ie?e.jsxs(e.Fragment,{children:[e.jsx(F,{size:14,className:"animate-spin"}),s("memory.compacting","Compacting…")]}):s("memory.compactSelectedFile","Compact Selected File")}),q&&H&&e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:ve,disabled:ee,children:ee?e.jsxs(e.Fragment,{children:[e.jsx(F,{size:14,className:"animate-spin"}),s("memory.saving","Saving…")]}):s("memory.save","Save")})]}),e.jsxs("div",{className:"memory-config-section",children:[e.jsxs("div",{className:"memory-settings-group",children:[e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"memoryDreamsEnabled",className:"checkbox-label",children:[e.jsx("input",{id:"memoryDreamsEnabled",type:"checkbox",checked:n.memoryDreamsEnabled,onChange:a=>{M(b=>({...b,memoryDreamsEnabled:a.target.checked}))},disabled:!n.memoryEnabled||x}),s("memory.dreamsEnabledLabel","Process dreams from daily memory")]}),e.jsx("small",{children:s("memory.dreamsEnabledHint","Turns daily notes into DREAMS.md and promotes reusable lessons into MEMORY.md.")})]}),n.memoryEnabled&&n.memoryDreamsEnabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"memoryDreamsSchedule",children:s("memory.dreamsScheduleLabel","Dream Schedule")}),e.jsx("input",{id:"memoryDreamsSchedule",type:"text",className:"input",value:n.memoryDreamsSchedule,onChange:a=>{M(b=>({...b,memoryDreamsSchedule:a.target.value}))},placeholder:"0 4 * * *",disabled:x}),e.jsx("small",{children:s("memory.dreamsScheduleHint","Cron expression for dream processing.")})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("button",{type:"button",className:"btn btn-sm",onClick:Ce,disabled:se||!n.memoryDreamsEnabled,children:se?e.jsxs(e.Fragment,{children:[e.jsx(F,{size:14,className:"animate-spin"}),s("memory.dreaming","Dreaming…")]}):s("memory.dreamNow","Dream Now")}),e.jsx("small",{children:s("memory.dreamNowHint","Manually trigger dream processing now.")})]})]})]}),e.jsxs("div",{className:"memory-settings-group",children:[e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"memoryAutoSummarizeEnabled",className:"checkbox-label",children:[e.jsx("input",{id:"memoryAutoSummarizeEnabled",type:"checkbox",checked:n.memoryAutoSummarizeEnabled,onChange:a=>{M(b=>({...b,memoryAutoSummarizeEnabled:a.target.checked}))},disabled:!n.memoryEnabled||x}),s("memory.autoSummarizeLabel","Auto-Summarize Memory")]}),e.jsx("small",{children:s("memory.autoSummarizeHint","Automatically compact memory when it exceeds the threshold on a schedule")})]}),n.memoryEnabled&&n.memoryAutoSummarizeEnabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"memoryAutoSummarizeThresholdChars",children:s("memory.compactionThresholdLabel","Compaction Threshold (chars)")}),e.jsx("input",{id:"memoryAutoSummarizeThresholdChars",type:"number",className:"input",value:n.memoryAutoSummarizeThresholdChars,onChange:a=>{M(b=>({...b,memoryAutoSummarizeThresholdChars:parseInt(a.target.value,10)||5e4}))},min:1e3,disabled:x}),e.jsx("small",{children:s("memory.compactionThresholdHint","Memory will be compacted when it exceeds this character count")})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"memoryAutoSummarizeSchedule",children:s("memory.autoSummarizeScheduleLabel","Schedule (cron)")}),e.jsx("input",{id:"memoryAutoSummarizeSchedule",type:"text",className:"input",value:n.memoryAutoSummarizeSchedule,onChange:a=>{M(b=>({...b,memoryAutoSummarizeSchedule:a.target.value}))},placeholder:"0 3 * * *",disabled:x}),e.jsx("small",{children:s("memory.autoSummarizeScheduleHint","Cron expression for auto-summarize schedule (default: daily at 3 AM)")})]})]})]}),!n.memoryEnabled&&e.jsx("div",{className:"settings-empty-state memory-status-message",children:s("memory.disabledMessage","Memory is currently disabled. Enable memory tools in Settings to edit these automations.")}),te&&e.jsx("div",{className:"memory-action-bar",children:e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:Ne,disabled:A||x,children:A?e.jsxs(e.Fragment,{children:[e.jsx(F,{size:14,className:"animate-spin"}),s("memory.saving","Saving…")]}):s("memory.saveSettings","Save Settings")})})]})]})]}),u==="insights"&&e.jsx("div",{className:"memory-insights-tab",children:me?e.jsxs("div",{className:"memory-empty-state",children:[e.jsx(F,{size:20,className:"animate-spin"}),e.jsx("span",{children:s("memory.loadingInsights","Loading insights…")})]}):D?e.jsxs("div",{className:"memory-insights-editor-layout",children:[e.jsx("div",{className:"memory-editor-container",children:e.jsx(ze,{content:p??"",onChange:E,readOnly:!1,filePath:".fusion/memory/INSIGHTS.md",onSendSelectionToTask:h})}),e.jsxs("div",{className:"memory-action-bar",children:[e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:l,children:s("memory.cancel","Cancel")}),e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:Ee,children:s("memory.saveInsights","Save Insights")})]})]}):!be||P.length===0?e.jsxs("div",{className:"memory-empty-state",children:[e.jsx("p",{children:s("memory.noInsights","No insights extracted yet.")}),e.jsx("p",{children:s("memory.noInsightsHint",'Insights are automatically extracted from working memory. Click "Extract Now" to trigger extraction manually.')}),e.jsx("button",{type:"button",className:"btn btn-primary btn-sm memory-empty-extract-button",onClick:ue,disabled:R,children:R?e.jsxs(e.Fragment,{children:[e.jsx(F,{size:14,className:"animate-spin"}),s("memory.extracting","Extracting…")]}):s("memory.extractNow","Extract Now")})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"memory-stats-row",children:[e.jsxs("div",{className:"memory-stat-card",children:[e.jsx("div",{className:"memory-stat-value",children:Se}),e.jsx("div",{className:"memory-stat-label",children:s("memory.totalInsights","Total Insights")})]}),e.jsxs("div",{className:"memory-stat-card",children:[e.jsx("div",{className:"memory-stat-value",children:P.length}),e.jsx("div",{className:"memory-stat-label",children:s("memory.categories","Categories")})]}),ye&&e.jsxs("div",{className:"memory-stat-card",children:[e.jsx("div",{className:"memory-stat-value memory-stat-value--updated",children:ye}),e.jsx("div",{className:"memory-stat-label",children:s("memory.lastUpdated","Last Updated")})]})]}),e.jsxs("div",{className:"memory-action-bar",children:[e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:ue,disabled:R,children:R?e.jsxs(e.Fragment,{children:[e.jsx(F,{size:14,className:"animate-spin"}),s("memory.extracting","Extracting…")]}):s("memory.extractNow","Extract Now")}),e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:m,children:s("memory.editRaw","Edit Raw")})]}),e.jsx("div",{className:"memory-categories-list",children:P.map(a=>{const b=!k.has(a.key);return e.jsxs("div",{className:"memory-category-section",children:[e.jsxs("div",{className:"memory-category-header",onClick:()=>he(a.key),role:"button",tabIndex:0,onKeyDown:C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),he(a.key))},children:[e.jsx("h4",{children:a.name}),e.jsx("span",{className:"memory-category-count",children:a.items.length})]}),b&&e.jsx("div",{className:"memory-category-items",children:a.items.map((C,Ie)=>e.jsx("div",{className:"memory-insight-item",children:C.replace(/^-\s+/,"").replace(/^\*\s+/,"")},Ie))})]},a.key)})})]})}),u==="engines"&&e.jsx("div",{className:"memory-engines-tab",children:v||N?e.jsxs("div",{className:"memory-empty-state",children:[e.jsx(F,{size:20,className:"animate-spin"}),e.jsx("span",{children:s("memory.loadingEngineStatus","Loading engine status…")})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"memory-engine-card memory-qmd-card",children:[e.jsx("h3",{children:s("memory.qmdIntegrationTitle","QMD Integration")}),o?.qmdAvailable===!0?e.jsxs("div",{className:"memory-engine-status",children:[e.jsx("span",{className:"memory-health-badge memory-health-badge--healthy",children:s("memory.qmdInstalled","Installed")}),e.jsx("span",{className:"memory-char-count",children:s("memory.qmdAvailableOnPath","qmd is available on PATH.")})]}):o?.qmdAvailable===!1?e.jsxs("div",{className:"settings-empty-state memory-status-message",children:[e.jsxs("span",{children:[s("memory.qmdNotInstalled","qmd is not installed. Search will use local files. Install indexed retrieval:")," ",e.jsx("code",{children:o.qmdInstallCommand||"bun install -g @tobilu/qmd"})]}),e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:ae,disabled:le,children:le?s("memory.installing","Installing…"):s("memory.installQmd","Install qmd")})]}):e.jsxs("div",{className:"memory-engine-status",children:[e.jsx("span",{className:"memory-health-badge",children:s("memory.qmdChecking","Checking")}),e.jsx("span",{className:"memory-char-count",children:s("memory.qmdCheckingAvailability","Checking qmd availability…")})]}),e.jsxs("div",{className:"memory-capability-row",children:[o?.capabilities?.readable&&e.jsx("span",{className:"memory-capability-badge",children:s("memory.capReadable","Readable")}),o?.capabilities?.writable&&e.jsx("span",{className:"memory-capability-badge",children:s("memory.capWritable","Writable")}),o?.capabilities?.supportsAtomicWrite&&e.jsx("span",{className:"memory-capability-badge",children:s("memory.capAtomicWrites","Atomic Writes")}),o?.capabilities?.persistent&&e.jsx("span",{className:"memory-capability-badge",children:s("memory.capPersistent","Persistent")})]})]}),e.jsxs("div",{className:"memory-engine-card memory-retrieval-card",children:[e.jsx("h3",{children:s("memory.testMemorySearchTitle","Test Memory Search")}),e.jsxs("div",{className:"memory-retrieval-input-row",children:[e.jsx("input",{type:"text",className:"input",value:V,onChange:a=>_(a.target.value),placeholder:s("memory.searchPlaceholder","Search memory with qmd")}),e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:W,disabled:re,children:re?s("memory.testing","Testing…"):s("memory.testRetrieval","Test Retrieval")})]}),e.jsx("small",{className:"settings-muted",children:s("memory.testSearchHint","Runs the same qmd-backed memory_search path agents use.")}),w&&e.jsxs("div",{className:"memory-test-result",children:[e.jsx("strong",{children:s("memory.testResultCount",'{{count}} result for "{{query}}"',{count:w.results.length,query:w.query,defaultValue_one:'{{count}} result for "{{query}}"',defaultValue_other:'{{count}} results for "{{query}}"'})}),e.jsx("small",{children:s("memory.testResultStatus","qmd {{qmdStatus}} · {{fallbackStatus}}",{qmdStatus:w.qmdAvailable?s("memory.qmdStatusAvailable","available"):s("memory.qmdStatusMissing","missing"),fallbackStatus:w.usedFallback?s("memory.localFallbackUsed","local fallback used"):s("memory.qmdPathUsed","qmd path used")})}),w.results.length>0?e.jsx("ul",{children:w.results.map((a,b)=>e.jsxs("li",{children:[e.jsxs("span",{children:[a.path,":",a.lineStart]}),e.jsx("p",{children:a.snippet})]},`${a.path}-${a.lineStart}-${b}`))}):e.jsx("small",{children:s("memory.noMatchingMemory","No matching memory found.")})]})]}),e.jsxs("div",{className:"memory-engine-card",children:[e.jsx("h3",{children:s("memory.currentBackendTitle","Current Backend")}),e.jsx("div",{className:"memory-engine-status",children:e.jsx("span",{className:"memory-emphasis-text",children:o?.currentBackend==="file"?s("memory.backendFile","File (.fusion/memory/, agent/<agent-name>/memory/)"):o?.currentBackend==="readonly"?s("memory.backendReadonly","Read-Only"):o?.currentBackend==="qmd"?s("memory.backendQmd","QMD (Quantized Memory Distillation)"):o?.currentBackend??"unknown"})}),e.jsxs("div",{className:"memory-capability-row",children:[o?.capabilities?.readable&&e.jsx("span",{className:"memory-capability-badge",children:s("memory.capReadable","Readable")}),o?.capabilities?.writable&&e.jsx("span",{className:"memory-capability-badge",children:s("memory.capWritable","Writable")}),o?.capabilities?.supportsAtomicWrite&&e.jsx("span",{className:"memory-capability-badge",children:s("memory.capAtomicWrites","Atomic Writes")}),o?.capabilities?.persistent&&e.jsx("span",{className:"memory-capability-badge",children:s("memory.capPersistent","Persistent")})]})]}),c&&e.jsxs("div",{className:"memory-engine-card",children:[e.jsxs("div",{className:"memory-health-header",children:[e.jsx("h3",{children:s("memory.healthStatusTitle","Health Status")}),e.jsx("span",{className:`memory-health-badge memory-health-badge--${c.health}`,children:c.health==="healthy"?s("memory.healthHealthy","Healthy"):c.health==="warning"?s("memory.healthWarning","Warning"):s("memory.healthIssues","Issues Found")})]}),e.jsxs("div",{className:"memory-health-grid",children:[e.jsxs("div",{children:[e.jsx("div",{className:"memory-health-label",children:s("memory.workingMemoryLabel","Working Memory")}),e.jsx("div",{className:"memory-emphasis-text",children:s("memory.sizeChars","{{size}} chars",{size:c.workingMemory.size})}),e.jsx("div",{className:"memory-health-detail",children:s("memory.sectionCount","{{count}} sections",{count:c.workingMemory.sectionCount})})]}),e.jsxs("div",{children:[e.jsx("div",{className:"memory-health-label",children:s("memory.insightsMemoryLabel","Insights Memory")}),e.jsx("div",{className:"memory-emphasis-text",children:s("memory.sizeChars","{{size}} chars",{size:c.insightsMemory.size})}),e.jsx("div",{className:"memory-health-detail",children:s("memory.insightCount","{{count}} insights",{count:c.insightsMemory.insightCount})})]})]}),e.jsxs("div",{className:"memory-health-section",children:[e.jsx("div",{className:"memory-health-label",children:s("memory.lastExtractionLabel","Last Extraction")}),e.jsx("div",{className:"memory-emphasis-text",children:c.extraction.success?e.jsx("span",{className:"memory-status-text memory-status-text--success",children:s("memory.extractionSuccess","Success")}):e.jsx("span",{className:"memory-status-text memory-status-text--error",children:s("memory.extractionFailed","Failed")})}),e.jsx("div",{className:"memory-health-detail",children:c.extraction.summary||s("memory.insightsExtracted","{{count}} insights extracted",{count:c.extraction.insightCount})})]}),e.jsxs("div",{className:"memory-health-section",children:[e.jsx("div",{className:"memory-health-label",children:s("memory.pruningLabel","Pruning")}),e.jsx("div",{className:"memory-emphasis-text",children:c.pruning.applied?e.jsx("span",{className:"memory-status-text memory-status-text--warning",children:s("memory.pruningApplied","Applied")}):e.jsx("span",{className:"memory-status-text memory-status-text--muted",children:s("memory.pruningNotNeeded","Not needed")})}),c.pruning.applied&&e.jsx("div",{className:"memory-health-detail",children:c.pruning.reason})]})]}),c&&c.checks.length>0&&e.jsxs("div",{className:"memory-engine-card",children:[e.jsx("h3",{children:s("memory.auditChecksTitle","Audit Checks")}),e.jsx("div",{children:c.checks.map(a=>e.jsxs("div",{className:"memory-audit-check",children:[e.jsx("span",{className:a.passed?"memory-audit-check-passed":"memory-audit-check-failed",children:a.passed?"✓":"✗"}),e.jsxs("div",{className:"memory-audit-check-content",children:[e.jsx("div",{className:"memory-emphasis-text",children:a.name}),e.jsx("div",{className:"memory-health-detail",children:a.details})]})]},a.id))})]}),e.jsx("div",{className:"memory-action-bar",children:e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:()=>pe(),children:s("memory.runAudit","Run Audit")})}),e.jsxs("div",{className:"memory-settings-note",children:[e.jsx("span",{children:s("memory.settingsNote","Note: Change backend type in")}),e.jsx("button",{type:"button",className:"memory-settings-note-button",onClick:()=>{t(s("memory.settingsNoteToast","Open Settings → Memory to change backend type"),"info")},children:s("memory.settingsNoteLink","Settings → Memory")})]})]})})]})]})}export{us as MemoryView};