@runfusion/fusion 0.76.0-beta.2 → 0.76.0-beta.3

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 (144) hide show
  1. package/dist/bin.js +323 -59
  2. package/dist/child-process-worker.js +274 -42
  3. package/dist/client/.vite/manifest.json +273 -273
  4. package/dist/client/assets/{AgentDetailView-gak4EWTI.js → AgentDetailView-T767kKTg.js} +1 -1
  5. package/dist/client/assets/{AgentPermissionPolicyEditor-DP1QbZL-.js → AgentPermissionPolicyEditor--u9jyUf2.js} +1 -1
  6. package/dist/client/assets/{AgentsView-DAMRTKzI.js → AgentsView-6Ifu7qDr.js} +5 -5
  7. package/dist/client/assets/{ChatView-iE-2gf5P.js → ChatView-BV3lixQi.js} +1 -1
  8. package/dist/client/assets/{CommandCenter-B6RnkLYm.js → CommandCenter-CSRYoveB.js} +1 -1
  9. package/dist/client/assets/{DevServerView-DcFL_LzK.js → DevServerView-B9So_oYx.js} +1 -1
  10. package/dist/client/assets/{DirectoryPicker-CtjqrYoO.js → DirectoryPicker-BhyDL_2m.js} +1 -1
  11. package/dist/client/assets/{DocumentsView-BkAe2S4H.js → DocumentsView-pbERA7O-.js} +1 -1
  12. package/dist/client/assets/{EvalsView-CbGA9dMn.js → EvalsView-DJQ4ltCg.js} +1 -1
  13. package/dist/client/assets/{ExperimentalAgentOnboardingModal-CMgO_S8T.js → ExperimentalAgentOnboardingModal-BwJuzkzB.js} +1 -1
  14. package/dist/client/assets/{GoalsView-_3P9J5sf.js → GoalsView-B6X5_0Ve.js} +1 -1
  15. package/dist/client/assets/InsightsView-CJgI0J7S.js +11 -0
  16. package/dist/client/assets/{InsightsView-Gn5lOBA0.css → InsightsView-DAAXuX4v.css} +1 -1
  17. package/dist/client/assets/{MemoryView-DwJas8vi.js → MemoryView-BHq1AHPu.js} +1 -1
  18. package/dist/client/assets/{PiExtensionsManager-B_LiW_e9.js → PiExtensionsManager-B8At6fO8.js} +1 -1
  19. package/dist/client/assets/{PluginManager-BkB6WLQc.js → PluginManager-k7hV7_9e.js} +1 -1
  20. package/dist/client/assets/{PullRequestView-DcH5tmYc.js → PullRequestView-B1hZFrWo.js} +1 -1
  21. package/dist/client/assets/{ReportModal-BOEbqtqG.js → ReportModal-C46V_zEa.js} +1 -1
  22. package/dist/client/assets/{ResearchView-Dp6V42pI.js → ResearchView-D8G85BYN.js} +2 -2
  23. package/dist/client/assets/{SecretsView-BCqXHB2L.js → SecretsView-CTri9LRK.js} +1 -1
  24. package/dist/client/assets/{SessionTerminal-CkdoQv4y.js → SessionTerminal-BRf6r4Vp.js} +1 -1
  25. package/dist/client/assets/SettingsModal-D0RBeZik.js +21 -0
  26. package/dist/client/assets/{SettingsModal-Dc7YG6KB.js → SettingsModal-rUQcSTJp.js} +1 -1
  27. package/dist/client/assets/{SettingsTextareaRow-WSkBoAOO.js → SettingsTextareaRow-BirlBcem.js} +1 -1
  28. package/dist/client/assets/{SetupWizardModal-VTrJAsKd.js → SetupWizardModal-xnCBM9EL.js} +2 -2
  29. package/dist/client/assets/{SkillsView-CXeXOxfF.js → SkillsView-O5U0ep50.js} +1 -1
  30. package/dist/client/assets/{WorkflowNodeEditor-DoxLGPRF.js → WorkflowNodeEditor-BX4d2qqF.js} +3 -3
  31. package/dist/client/assets/{agent-import-generation-upc0yw-M.js → agent-import-generation-DnqVkPkz.js} +1 -1
  32. package/dist/client/assets/{agentsOrgChartLayout-C3iumMrW.js → agentsOrgChartLayout-CKuzbhFf.js} +1 -1
  33. package/dist/client/assets/app-B2FwULu2.js +5 -0
  34. package/dist/client/assets/{app-BA9gw9hx.js → app-B6nJaqAl.js} +2 -2
  35. package/dist/client/assets/{app-B_lScKc1.js → app-CGXZeIRc.js} +2 -2
  36. package/dist/client/assets/{app-DG_vjDw5.js → app-CGtkeBF5.js} +3 -3
  37. package/dist/client/assets/{app-GBgoY-oh.js → app-CNzN1Plu.js} +2 -2
  38. package/dist/client/assets/{app-B0KFGP8D.js → app-DLs-f5yM.js} +3 -3
  39. package/dist/client/assets/{app-DeHIOCEP.js → app-DsvtcRUG.js} +2 -2
  40. package/dist/client/assets/{architectureDiagram-3BPJPVTR-D6jqc3fJ.js → architectureDiagram-3BPJPVTR-gi467xY0.js} +1 -1
  41. package/dist/client/assets/{blockDiagram-GPEHLZMM-DY3AKuPD.js → blockDiagram-GPEHLZMM-B_gpcYiR.js} +1 -1
  42. package/dist/client/assets/{c4Diagram-AAUBKEIU-CpD52V4g.js → c4Diagram-AAUBKEIU-DeylEYsQ.js} +1 -1
  43. package/dist/client/assets/channel-BoE8DeM4.js +1 -0
  44. package/dist/client/assets/{chunk-2J33WTMH-CPeIHyAX.js → chunk-2J33WTMH-BL2WY0HN.js} +1 -1
  45. package/dist/client/assets/{chunk-4BX2VUAB-ivAwI4xM.js → chunk-4BX2VUAB-BkLExGMe.js} +1 -1
  46. package/dist/client/assets/{chunk-55IACEB6-BtVQ5XaZ.js → chunk-55IACEB6-CSTvCF5T.js} +1 -1
  47. package/dist/client/assets/{chunk-727SXJPM-1eap1vDU.js → chunk-727SXJPM-9J8pKk4x.js} +1 -1
  48. package/dist/client/assets/{chunk-AQP2D5EJ-B2NB3BW9.js → chunk-AQP2D5EJ-DXC1vPWr.js} +1 -1
  49. package/dist/client/assets/{chunk-FMBD7UC4-Hk_smNYv.js → chunk-FMBD7UC4-CFRUb-zD.js} +1 -1
  50. package/dist/client/assets/{chunk-ND2GUHAM-BmGCAojk.js → chunk-ND2GUHAM-B87HFYS8.js} +1 -1
  51. package/dist/client/assets/{chunk-QZHKN3VN-D0aXZ8CV.js → chunk-QZHKN3VN-CTjHiGbd.js} +1 -1
  52. package/dist/client/assets/classDiagram-4FO5ZUOK-qnbLX_9_.js +1 -0
  53. package/dist/client/assets/classDiagram-v2-Q7XG4LA2-qnbLX_9_.js +1 -0
  54. package/dist/client/assets/{cose-bilkent-S5V4N54A-DAbu_gnF.js → cose-bilkent-S5V4N54A-D3Edq3L9.js} +1 -1
  55. package/dist/client/assets/{dagre-BM42HDAG-BdmLlrDJ.js → dagre-BM42HDAG-CwwbeQfN.js} +1 -1
  56. package/dist/client/assets/{dashboard-view-CULL1yhL.js → dashboard-view-BLAoW3D4.js} +1 -1
  57. package/dist/client/assets/{dashboard-view-PRCWCSLm.js → dashboard-view-DAlJxqiJ.js} +1 -1
  58. package/dist/client/assets/{dashboard-view-BoFBSXUn.js → dashboard-view-QxQwJFLz.js} +1 -1
  59. package/dist/client/assets/{dashboard-view-CxXMDfNY.js → dashboard-view-aPzfv99T.js} +1 -1
  60. package/dist/client/assets/{diagram-2AECGRRQ-PpqLbVUA.js → diagram-2AECGRRQ-koJWWXE4.js} +1 -1
  61. package/dist/client/assets/{diagram-5GNKFQAL-9rkGmTwh.js → diagram-5GNKFQAL-Yob5cOKT.js} +1 -1
  62. package/dist/client/assets/{diagram-KO2AKTUF-BT-efOMo.js → diagram-KO2AKTUF-DelvFSkK.js} +1 -1
  63. package/dist/client/assets/{diagram-LMA3HP47-w79OWFxg.js → diagram-LMA3HP47-CMput2h2.js} +1 -1
  64. package/dist/client/assets/{diagram-OG6HWLK6-Bye9I5IO.js → diagram-OG6HWLK6-04VXDl79.js} +1 -1
  65. package/dist/client/assets/{erDiagram-TEJ5UH35-aodREgDf.js → erDiagram-TEJ5UH35-C9iP8Uyp.js} +1 -1
  66. package/dist/client/assets/{flowDiagram-I6XJVG4X-D0DKItY3.js → flowDiagram-I6XJVG4X-DENQvu_t.js} +1 -1
  67. package/dist/client/assets/{folder-open-CqvaMJvx.js → folder-open-D-554oji.js} +1 -1
  68. package/dist/client/assets/{ganttDiagram-6RSMTGT7-CZVApkvw.js → ganttDiagram-6RSMTGT7-BqOttZAT.js} +1 -1
  69. package/dist/client/assets/{gitGraphDiagram-PVQCEYII-D_ynwJ4p.js → gitGraphDiagram-PVQCEYII-CDcydi-5.js} +1 -1
  70. package/dist/client/assets/{index-BzAldNrK.css → index-CXTd3LAB.css} +1 -1
  71. package/dist/client/assets/{index-DWRJyaa3.js → index-CtYRoouR.js} +264 -264
  72. package/dist/client/assets/{infoDiagram-5YYISTIA-pJG6zxjk.js → infoDiagram-5YYISTIA-B5LQQnxt.js} +1 -1
  73. package/dist/client/assets/{ishikawaDiagram-YF4QCWOH-nFZ5laUo.js → ishikawaDiagram-YF4QCWOH-DpFEt7D2.js} +1 -1
  74. package/dist/client/assets/{journeyDiagram-JHISSGLW-CWpCaAIe.js → journeyDiagram-JHISSGLW-MELtgu22.js} +1 -1
  75. package/dist/client/assets/{kanban-definition-UN3LZRKU-ATkPspKa.js → kanban-definition-UN3LZRKU-h33PLATd.js} +1 -1
  76. package/dist/client/assets/{mermaid.core-CDXPNs7a.js → mermaid.core-Dk2mUPOq.js} +4 -4
  77. package/dist/client/assets/{mindmap-definition-RKZ34NQL-BkqS9tpe.js → mindmap-definition-RKZ34NQL-B_T4O2-B.js} +1 -1
  78. package/dist/client/assets/{pieDiagram-4H26LBE5-DEUyVLs-.js → pieDiagram-4H26LBE5-B1YIFkRl.js} +1 -1
  79. package/dist/client/assets/{puzzle-DQ0y1-XK.js → puzzle-hvecxlpJ.js} +1 -1
  80. package/dist/client/assets/{quadrantDiagram-W4KKPZXB-ESBJNK5c.js → quadrantDiagram-W4KKPZXB-BoGQR_hO.js} +1 -1
  81. package/dist/client/assets/{requirementDiagram-4Y6WPE33-CqPs7zcv.js → requirementDiagram-4Y6WPE33-BSDmUBIx.js} +1 -1
  82. package/dist/client/assets/{sankeyDiagram-5OEKKPKP-CkFN0m14.js → sankeyDiagram-5OEKKPKP-Dz_GqOa5.js} +1 -1
  83. package/dist/client/assets/{sequenceDiagram-3UESZ5HK-Dx2nDuMO.js → sequenceDiagram-3UESZ5HK-B6twjYUH.js} +1 -1
  84. package/dist/client/assets/{shield-alert-BS05s4RM.js → shield-alert-BX4WRJOv.js} +1 -1
  85. package/dist/client/assets/{standing-instructions-template-xprxYNHm.js → standing-instructions-template-BJY317CC.js} +1 -1
  86. package/dist/client/assets/{stateDiagram-AJRCARHV-EUPmRFGd.js → stateDiagram-AJRCARHV-DuwqWLx-.js} +1 -1
  87. package/dist/client/assets/{stateDiagram-v2-BHNVJYJU-DcQ2mhi5.js → stateDiagram-v2-BHNVJYJU-Bu8Sk187.js} +1 -1
  88. package/dist/client/assets/{timeline-definition-PNZ67QCA-D4YO_3V-.js → timeline-definition-PNZ67QCA-BS6VnqSI.js} +1 -1
  89. package/dist/client/assets/{upload-BjyBtxo7.js → upload-CaDoyaMW.js} +1 -1
  90. package/dist/client/assets/{users-D5ogZ7WQ.js → users-C5uCLwVM.js} +1 -1
  91. package/dist/client/assets/{vennDiagram-CIIHVFJN-BT5_XuQL.js → vennDiagram-CIIHVFJN-CUbzqT5Y.js} +1 -1
  92. package/dist/client/assets/{wardley-L42UT6IY-X_ZMW457.js → wardley-L42UT6IY-Mv-NotFS.js} +1 -1
  93. package/dist/client/assets/{wardleyDiagram-YWT4CUSO-GK9nONHU.js → wardleyDiagram-YWT4CUSO-DuYpvLZX.js} +1 -1
  94. package/dist/client/assets/{xychartDiagram-2RQKCTM6-Dw3zXHAq.js → xychartDiagram-2RQKCTM6-24_7QXdw.js} +1 -1
  95. package/dist/client/index.html +2 -2
  96. package/dist/client/version.json +1 -1
  97. package/dist/droid-cli/package.json +1 -1
  98. package/dist/extension.js +285 -47
  99. package/dist/pi-claude-cli/package.json +1 -1
  100. package/dist/plugin-sdk/index.d.ts +23 -0
  101. package/dist/plugin-sdk/index.js +2 -0
  102. package/dist/plugins/fusion-plugin-acp-runtime/bundled.js +2 -0
  103. package/dist/plugins/fusion-plugin-acp-runtime/package.json +1 -1
  104. package/dist/plugins/fusion-plugin-claude-runtime/bundled.js +2 -0
  105. package/dist/plugins/fusion-plugin-claude-runtime/package.json +1 -1
  106. package/dist/plugins/fusion-plugin-cli-printing-press/bundled.js +2 -0
  107. package/dist/plugins/fusion-plugin-cli-printing-press/package.json +1 -1
  108. package/dist/plugins/fusion-plugin-compound-engineering/bundled.js +2 -0
  109. package/dist/plugins/fusion-plugin-compound-engineering/package.json +1 -1
  110. package/dist/plugins/fusion-plugin-cursor-runtime/bundled.js +2 -0
  111. package/dist/plugins/fusion-plugin-cursor-runtime/package.json +1 -1
  112. package/dist/plugins/fusion-plugin-dependency-graph/bundled.js +2 -0
  113. package/dist/plugins/fusion-plugin-dependency-graph/package.json +1 -1
  114. package/dist/plugins/fusion-plugin-droid-runtime/bundled.js +2 -0
  115. package/dist/plugins/fusion-plugin-droid-runtime/package.json +1 -1
  116. package/dist/plugins/fusion-plugin-grok-runtime/bundled.js +2 -0
  117. package/dist/plugins/fusion-plugin-grok-runtime/package.json +1 -1
  118. package/dist/plugins/fusion-plugin-hermes-runtime/bundled.js +2 -0
  119. package/dist/plugins/fusion-plugin-hermes-runtime/package.json +1 -1
  120. package/dist/plugins/fusion-plugin-linear-import/bundled.js +2 -0
  121. package/dist/plugins/fusion-plugin-linear-import/package.json +1 -1
  122. package/dist/plugins/fusion-plugin-omp-runtime/bundled.js +2 -0
  123. package/dist/plugins/fusion-plugin-omp-runtime/package.json +1 -1
  124. package/dist/plugins/fusion-plugin-openclaw-runtime/bundled.js +2 -0
  125. package/dist/plugins/fusion-plugin-openclaw-runtime/package.json +1 -1
  126. package/dist/plugins/fusion-plugin-paperclip-runtime/bundled.js +2 -0
  127. package/dist/plugins/fusion-plugin-paperclip-runtime/package.json +1 -1
  128. package/dist/plugins/fusion-plugin-quality/bundled.js +2 -0
  129. package/dist/plugins/fusion-plugin-quality/package.json +1 -1
  130. package/dist/plugins/fusion-plugin-reports/bundled.js +2 -0
  131. package/dist/plugins/fusion-plugin-reports/package.json +1 -1
  132. package/dist/plugins/fusion-plugin-roadmap/bundled.js +2 -0
  133. package/dist/plugins/fusion-plugin-roadmap/package.json +1 -1
  134. package/dist/plugins/fusion-plugin-todos/bundled.js +2 -0
  135. package/dist/plugins/fusion-plugin-todos/package.json +1 -1
  136. package/dist/plugins/fusion-plugin-whatsapp-chat/bundled.js +2 -0
  137. package/dist/plugins/fusion-plugin-whatsapp-chat/package.json +1 -1
  138. package/package.json +1 -1
  139. package/dist/client/assets/InsightsView-DOhO7xH5.js +0 -11
  140. package/dist/client/assets/SettingsModal-D4Fn4GlS.js +0 -21
  141. package/dist/client/assets/app-DBCGrz-f.js +0 -5
  142. package/dist/client/assets/channel-CaxOu15c.js +0 -1
  143. package/dist/client/assets/classDiagram-4FO5ZUOK-DXIkGbsl.js +0 -1
  144. package/dist/client/assets/classDiagram-v2-Q7XG4LA2-DXIkGbsl.js +0 -1
@@ -1 +1 @@
1
- import{r as l,j as e}from"./vendor-react-SZ_qB27O.js";import{ap as P,aq as L,ar as $,aT as Y,aU as Q,av as O,aV as Z,aW as ee,aX as se,V as H,T as X,_ as ae,R as te,aJ as le,s as re,l as ne,aR as ie}from"./index-DWRJyaa3.js";import{u as ce}from"./vendor-i18n-Duky4gdQ.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";const oe=300,de=15e3;function B(r){if(!r.trim())return;const a=Number(r);return Number.isFinite(a)?a:void 0}function I(...r){for(const a of r)if(Array.isArray(a))return a;return[]}function f(r){return typeof r=="object"&&r!==null?r:{}}function K(r){const a=f(r),m=f(a.taskSnapshot);return{id:String(a.id??a.evalId??""),runId:String(a.runId??a.batchId??""),taskId:String(a.taskId??m.taskId??""),taskTitle:String(m.title??a.taskTitle??a.title??"Untitled task"),createdAt:String(a.createdAt??a.timestamp??a.updatedAt??new Date(0).toISOString()),overallScore:typeof a.overallScore=="number"?a.overallScore:null,maxScore:typeof a.maxScore=="number"?a.maxScore:null,categoryScores:I(a.categoryScores,f(a.scores).categories)}}function ue(r){const a=f(r);return{...K(a),rationale:String(a.rationale??a.summary??""),evidence:I(a.evidence,f(a.details).evidence),followUps:I(a.followUps,f(a.recommendations).followUps)}}function ve(r){const a=r?.projectId,m=a??"",t=`${$.EVALS_RUNS_PREFIX}${m}`,h=`${$.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),[o,g]=l.useState({q:"",runId:"",scoreMin:"",scoreMax:""}),[N,w]=l.useState(()=>Array.isArray(p)?p:[]),[d,C]=l.useState(()=>Array.isArray(v)?v:[]),[u,R]=l.useState(null),[F,A]=l.useState(null),[s,i]=l.useState(0),[y,j]=l.useState(!S.current),[W,V]=l.useState(null),M=l.useRef(0),q=l.useRef(a),T=l.useRef(u);T.current=u;const k=l.useCallback(async()=>{const c=++M.current;S.current||j(!0),V(null);try{const[n,x]=await Promise.all([Y({q:o.q||void 0,runId:o.runId||void 0,scoreMin:B(o.scoreMin),scoreMax:B(o.scoreMax),limit:100,offset:0},a),Q(a)]);if(c!==M.current)return;const E=I(n.results,n.evals,n.items).map(K);C(E),O(h,E.length>500?E.slice(0,500):E,{maxBytes:5e5}),i(typeof n.count=="number"?n.count:E.length);const z=I(x.runs,x.items).map(U=>{const b=f(U),D=f(b.counts);return{id:String(b.id??""),createdAt:String(b.createdAt??""),completedAt:typeof b.completedAt=="string"?b.completedAt:void 0,status:String(b.status??"pending"),evaluatedTaskCount:typeof D.totalTasks=="number"?D.totalTasks:0}});w(z),O(t,z,{maxBytes:5e5}),S.current=!0,T.current&&!E.some(U=>U.id===T.current)&&(R(null),A(null))}catch(n){if(c!==M.current)return;V(n instanceof Error?n.message:"Failed to load evals")}finally{c===M.current&&j(!1)}},[o.q,o.runId,o.scoreMax,o.scoreMin,a,h,t]),_=l.useCallback(async c=>{const n=await Z(c,a),x=n.result??n;A(ue(x))},[a]);l.useEffect(()=>{if(q.current===a)return;q.current=a;const c=P(t,{maxAgeMs:L}),n=P(h,{maxAgeMs:L}),x=Array.isArray(c)&&c.length>0||Array.isArray(n)&&n.length>0;w(Array.isArray(c)?c:[]),C(Array.isArray(n)?n:[]),j(!x),S.current=x},[a,h,t]),l.useEffect(()=>{const c=window.setTimeout(()=>{k()},oe);return()=>window.clearTimeout(c)},[k]),l.useEffect(()=>{if(!u){A(null);return}_(u)},[_,u]);const G=l.useCallback(()=>{k(),u&&_(u)},[_,k,u]);ee(G,de);const J=l.useCallback(c=>{T.current=c,R(c)},[]);return{loading:y,error:W,results:d,count:s,runs:N,filters:o,setFilters:g,refresh:k,selectedEvalId:u,setSelectedEvalId:J,selectedEval:F}}function je({projectId:r,onOpenSettings:a,onOpenTaskDetail:m}){const{t}=ce("app"),{loading:h,error:p,results:v,runs:S,filters:o,setFilters:g,selectedEvalId:N,setSelectedEvalId:w,selectedEval:d,refresh:C}=ve({projectId:r}),[u,R]=l.useState(!0);l.useEffect(()=>{let s=!1;return se(r).then(i=>{if(s)return;const y=i.evalSettings?.enabled;R(y??!1)}).catch(()=>{s||R(!1)}),()=>{s=!0}},[r]);const F=v.length>0,A=l.useMemo(()=>v.find(s=>s.id===N)??null,[v,N]);return u?e.jsxs("section",{className:"evals-view","data-testid":"evals-view",children:[e.jsx(H,{icon:X,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:o.q,onChange:s=>g(i=>({...i,q:s.target.value}))}),e.jsxs("select",{className:"select",value:o.runId,onChange:s=>g(i=>({...i,runId:s.target.value})),children:[e.jsx("option",{value:"",children:t("evals.allRuns","All runs")}),S.map(s=>e.jsx("option",{value:s.id,children:s.id},s.id))]}),e.jsx("input",{className:"input",placeholder:t("evals.minScorePlaceholder","Min score"),value:o.scoreMin,onChange:s=>g(i=>({...i,scoreMin:s.target.value}))}),e.jsx("input",{className:"input",placeholder:t("evals.maxScorePlaceholder","Max score"),value:o.scoreMax,onChange:s=>g(i=>({...i,scoreMax:s.target.value}))}),e.jsx("button",{className:"btn btn-icon",type:"button",onClick:()=>void C(),"aria-label":t("evals.refreshAria","Refresh evals"),children:e.jsx(te,{size:16})})]}),h&&e.jsx("p",{className:"evals-state","data-testid":"evals-loading",children:e.jsx(le,{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(s=>e.jsx("li",{children:e.jsxs("button",{className:`evals-result ${s.id===N?"evals-result--active":""}`,type:"button",onClick:()=>w(s.id),draggable:ne(),onDragStart:i=>{re(i.dataTransfer,{kind:"eval-result",id:s.id,projectId:r})},children:[e.jsx("span",{className:"evals-result-title",children:s.taskTitle}),e.jsxs("span",{className:"evals-result-meta",children:[s.taskId," · ",s.runId," · ",s.overallScore??t("evals.naPlaceholder","n/a")]})]})},s.id))})]}),e.jsxs("div",{className:"evals-detail card","data-testid":"evals-detail",children:[!d&&e.jsx("p",{className:"evals-state",children:t("evals.selectPrompt","Select an evaluation to inspect scores, rationale, and evidence.")}),d&&e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"evals-detail-title",children:A?.taskTitle??d.taskTitle}),e.jsxs("p",{className:"evals-result-meta",children:[d.taskId," · ",d.runId]}),e.jsx("p",{className:"evals-score",children:t("evals.overallScore","Overall score: {{score}}",{score:d.overallScore??t("evals.naPlaceholder","n/a")})}),e.jsx("ul",{className:"evals-categories",children:d.categoryScores.map(s=>e.jsxs("li",{children:[s.category,": ",s.finalScore]},s.category))}),e.jsx("p",{className:"evals-rationale",children:d.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:d.evidence.map((s,i)=>{const y=typeof s.metadata?.taskId=="string"?s.metadata.taskId:void 0,j=typeof s.metadata?.url=="string"?s.metadata.url:void 0;return e.jsx("li",{children:y?e.jsx("button",{type:"button",className:"btn",onClick:()=>m?.(y),children:s.ref}):j?e.jsxs("a",{href:j,target:"_blank",rel:"noreferrer",className:"evals-external-link",children:[s.ref,e.jsx(ie,{size:14})]}):e.jsx("span",{children:s.ref})},`${s.ref}-${i}`)})})]}),e.jsxs("div",{children:[e.jsx("h4",{children:t("evals.suggestedFollowupsHeading","Suggested follow-up tasks")}),e.jsxs("ul",{className:"evals-follow-ups",children:[d.followUps.length===0&&e.jsx("li",{children:t("evals.noFollowups","None")}),d.followUps.map(s=>e.jsxs("li",{children:[e.jsx("strong",{children:s.title}),e.jsx("p",{children:s.rationale})]},s.suggestionId))]})]})]})]})]})]}):e.jsxs("section",{className:"evals-view","data-testid":"evals-disabled",children:[e.jsx(H,{icon:X,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:()=>a?.("scheduled-evals"),children:[e.jsx(ae,{size:16}),t("evals.openSettings","Open Scheduled Evals Settings")]})]})]})}export{je as EvalsView};
1
+ import{r as l,j as e}from"./vendor-react-SZ_qB27O.js";import{ap as P,aq as L,ar as $,aT as Y,aU as Q,av as O,aV as Z,aW as ee,aX as se,V as H,T as X,_ as ae,R as te,aJ as le,s as re,l as ne,aR as ie}from"./index-CtYRoouR.js";import{u as ce}from"./vendor-i18n-Duky4gdQ.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";const oe=300,de=15e3;function B(r){if(!r.trim())return;const a=Number(r);return Number.isFinite(a)?a:void 0}function I(...r){for(const a of r)if(Array.isArray(a))return a;return[]}function f(r){return typeof r=="object"&&r!==null?r:{}}function K(r){const a=f(r),m=f(a.taskSnapshot);return{id:String(a.id??a.evalId??""),runId:String(a.runId??a.batchId??""),taskId:String(a.taskId??m.taskId??""),taskTitle:String(m.title??a.taskTitle??a.title??"Untitled task"),createdAt:String(a.createdAt??a.timestamp??a.updatedAt??new Date(0).toISOString()),overallScore:typeof a.overallScore=="number"?a.overallScore:null,maxScore:typeof a.maxScore=="number"?a.maxScore:null,categoryScores:I(a.categoryScores,f(a.scores).categories)}}function ue(r){const a=f(r);return{...K(a),rationale:String(a.rationale??a.summary??""),evidence:I(a.evidence,f(a.details).evidence),followUps:I(a.followUps,f(a.recommendations).followUps)}}function ve(r){const a=r?.projectId,m=a??"",t=`${$.EVALS_RUNS_PREFIX}${m}`,h=`${$.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),[o,g]=l.useState({q:"",runId:"",scoreMin:"",scoreMax:""}),[N,w]=l.useState(()=>Array.isArray(p)?p:[]),[d,C]=l.useState(()=>Array.isArray(v)?v:[]),[u,R]=l.useState(null),[F,A]=l.useState(null),[s,i]=l.useState(0),[y,j]=l.useState(!S.current),[W,V]=l.useState(null),M=l.useRef(0),q=l.useRef(a),T=l.useRef(u);T.current=u;const k=l.useCallback(async()=>{const c=++M.current;S.current||j(!0),V(null);try{const[n,x]=await Promise.all([Y({q:o.q||void 0,runId:o.runId||void 0,scoreMin:B(o.scoreMin),scoreMax:B(o.scoreMax),limit:100,offset:0},a),Q(a)]);if(c!==M.current)return;const E=I(n.results,n.evals,n.items).map(K);C(E),O(h,E.length>500?E.slice(0,500):E,{maxBytes:5e5}),i(typeof n.count=="number"?n.count:E.length);const z=I(x.runs,x.items).map(U=>{const b=f(U),D=f(b.counts);return{id:String(b.id??""),createdAt:String(b.createdAt??""),completedAt:typeof b.completedAt=="string"?b.completedAt:void 0,status:String(b.status??"pending"),evaluatedTaskCount:typeof D.totalTasks=="number"?D.totalTasks:0}});w(z),O(t,z,{maxBytes:5e5}),S.current=!0,T.current&&!E.some(U=>U.id===T.current)&&(R(null),A(null))}catch(n){if(c!==M.current)return;V(n instanceof Error?n.message:"Failed to load evals")}finally{c===M.current&&j(!1)}},[o.q,o.runId,o.scoreMax,o.scoreMin,a,h,t]),_=l.useCallback(async c=>{const n=await Z(c,a),x=n.result??n;A(ue(x))},[a]);l.useEffect(()=>{if(q.current===a)return;q.current=a;const c=P(t,{maxAgeMs:L}),n=P(h,{maxAgeMs:L}),x=Array.isArray(c)&&c.length>0||Array.isArray(n)&&n.length>0;w(Array.isArray(c)?c:[]),C(Array.isArray(n)?n:[]),j(!x),S.current=x},[a,h,t]),l.useEffect(()=>{const c=window.setTimeout(()=>{k()},oe);return()=>window.clearTimeout(c)},[k]),l.useEffect(()=>{if(!u){A(null);return}_(u)},[_,u]);const G=l.useCallback(()=>{k(),u&&_(u)},[_,k,u]);ee(G,de);const J=l.useCallback(c=>{T.current=c,R(c)},[]);return{loading:y,error:W,results:d,count:s,runs:N,filters:o,setFilters:g,refresh:k,selectedEvalId:u,setSelectedEvalId:J,selectedEval:F}}function je({projectId:r,onOpenSettings:a,onOpenTaskDetail:m}){const{t}=ce("app"),{loading:h,error:p,results:v,runs:S,filters:o,setFilters:g,selectedEvalId:N,setSelectedEvalId:w,selectedEval:d,refresh:C}=ve({projectId:r}),[u,R]=l.useState(!0);l.useEffect(()=>{let s=!1;return se(r).then(i=>{if(s)return;const y=i.evalSettings?.enabled;R(y??!1)}).catch(()=>{s||R(!1)}),()=>{s=!0}},[r]);const F=v.length>0,A=l.useMemo(()=>v.find(s=>s.id===N)??null,[v,N]);return u?e.jsxs("section",{className:"evals-view","data-testid":"evals-view",children:[e.jsx(H,{icon:X,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:o.q,onChange:s=>g(i=>({...i,q:s.target.value}))}),e.jsxs("select",{className:"select",value:o.runId,onChange:s=>g(i=>({...i,runId:s.target.value})),children:[e.jsx("option",{value:"",children:t("evals.allRuns","All runs")}),S.map(s=>e.jsx("option",{value:s.id,children:s.id},s.id))]}),e.jsx("input",{className:"input",placeholder:t("evals.minScorePlaceholder","Min score"),value:o.scoreMin,onChange:s=>g(i=>({...i,scoreMin:s.target.value}))}),e.jsx("input",{className:"input",placeholder:t("evals.maxScorePlaceholder","Max score"),value:o.scoreMax,onChange:s=>g(i=>({...i,scoreMax:s.target.value}))}),e.jsx("button",{className:"btn btn-icon",type:"button",onClick:()=>void C(),"aria-label":t("evals.refreshAria","Refresh evals"),children:e.jsx(te,{size:16})})]}),h&&e.jsx("p",{className:"evals-state","data-testid":"evals-loading",children:e.jsx(le,{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(s=>e.jsx("li",{children:e.jsxs("button",{className:`evals-result ${s.id===N?"evals-result--active":""}`,type:"button",onClick:()=>w(s.id),draggable:ne(),onDragStart:i=>{re(i.dataTransfer,{kind:"eval-result",id:s.id,projectId:r})},children:[e.jsx("span",{className:"evals-result-title",children:s.taskTitle}),e.jsxs("span",{className:"evals-result-meta",children:[s.taskId," · ",s.runId," · ",s.overallScore??t("evals.naPlaceholder","n/a")]})]})},s.id))})]}),e.jsxs("div",{className:"evals-detail card","data-testid":"evals-detail",children:[!d&&e.jsx("p",{className:"evals-state",children:t("evals.selectPrompt","Select an evaluation to inspect scores, rationale, and evidence.")}),d&&e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"evals-detail-title",children:A?.taskTitle??d.taskTitle}),e.jsxs("p",{className:"evals-result-meta",children:[d.taskId," · ",d.runId]}),e.jsx("p",{className:"evals-score",children:t("evals.overallScore","Overall score: {{score}}",{score:d.overallScore??t("evals.naPlaceholder","n/a")})}),e.jsx("ul",{className:"evals-categories",children:d.categoryScores.map(s=>e.jsxs("li",{children:[s.category,": ",s.finalScore]},s.category))}),e.jsx("p",{className:"evals-rationale",children:d.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:d.evidence.map((s,i)=>{const y=typeof s.metadata?.taskId=="string"?s.metadata.taskId:void 0,j=typeof s.metadata?.url=="string"?s.metadata.url:void 0;return e.jsx("li",{children:y?e.jsx("button",{type:"button",className:"btn",onClick:()=>m?.(y),children:s.ref}):j?e.jsxs("a",{href:j,target:"_blank",rel:"noreferrer",className:"evals-external-link",children:[s.ref,e.jsx(ie,{size:14})]}):e.jsx("span",{children:s.ref})},`${s.ref}-${i}`)})})]}),e.jsxs("div",{children:[e.jsx("h4",{children:t("evals.suggestedFollowupsHeading","Suggested follow-up tasks")}),e.jsxs("ul",{className:"evals-follow-ups",children:[d.followUps.length===0&&e.jsx("li",{children:t("evals.noFollowups","None")}),d.followUps.map(s=>e.jsxs("li",{children:[e.jsx("strong",{children:s.title}),e.jsx("p",{children:s.rationale})]},s.suggestionId))]})]})]})]})]})]}):e.jsxs("section",{className:"evals-view","data-testid":"evals-disabled",children:[e.jsx(H,{icon:X,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:()=>a?.("scheduled-evals"),children:[e.jsx(ae,{size:16}),t("evals.openSettings","Open Scheduled Evals Settings")]})]})]})}export{je as EvalsView};
@@ -1 +1 @@
1
- import{r as s,j as e}from"./vendor-react-SZ_qB27O.js";import{B as F,D as V,F as W,G as $,H as z,I as K,J as B}from"./index-DWRJyaa3.js";import{u as J}from"./vendor-i18n-Duky4gdQ.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";function te({isOpen:l,onClose:R,onUseDraft:M,projectId:x,existingAgents:P,mode:w="create",existingAgentConfig:L}){const{t:n}=J("app"),[g,d]=s.useState("initial"),[f,_]=s.useState(""),[c,S]=s.useState(null),[C,I]=s.useState(""),[k,A]=s.useState("answer"),[p,v]=s.useState(""),[t,H]=s.useState(null),[T,h]=s.useState(null),[E,y]=s.useState([]),b=w==="edit",o=s.useRef(l),N=s.useCallback(()=>{d("initial"),_(""),S(null),I(""),A("answer"),v(""),H(null),h(null),y([])},[]),D=s.useMemo(()=>F.map(a=>({id:a.id,label:a.name,description:a.description})),[]);s.useEffect(()=>{if(o.current=l,!c)return;const a=V(c,x,{onThinking:r=>{o.current&&y(Q=>{const u=[...Q],j=u[u.length-1];return j&&!j.question?(u[u.length-1]={...j,thinkingOutput:`${j.thinkingOutput??""}${r}`},u):[...u,{response:{},thinkingOutput:r}]})},onQuestion:r=>{o.current&&(I(r.question),A(r.id),d("question"))},onSummary:r=>{o.current&&(H(r),d("summary"))},onError:r=>{o.current&&(h(r),d("error"))}});return()=>{o.current=!1,a.close()}},[l,c,x]);const m=async()=>{o.current=!1;try{c&&await z(c,x)}catch{}finally{N(),R()}};if(s.useEffect(()=>{o.current=l,l||N()},[l,N]),!l)return null;const i=a=>a==null||a===""?e.jsx("em",{className:"experimental-agent-onboarding-modal__summary-empty",children:n("agents.onboarding.notSet","Not set")}):e.jsx("span",{children:a}),O=async()=>{d("loading"),h(null);try{const a=await K(f,{mode:w,existingAgentConfig:L,existingAgents:P.map(r=>({id:r.id,name:r.name,role:r.role})),templates:D},x);if(!o.current)return;S(a.sessionId)}catch(a){if(!o.current)return;h(a.message),d("error")}},q=async()=>{if(c){d("loading"),h(null);try{const a={[k]:p};if(y(r=>[...r,{question:{id:k,type:"text",question:C},response:a}]),await B(c,a,x),!o.current)return;v("")}catch(a){if(!o.current)return;h(a.message),d("error")}}},G=async()=>{t&&(M(t),await m())};return e.jsx(W,{windowKey:"experimental-agent-onboarding",modal:!0,title:n("agents.onboarding.title","AI Interview"),ariaLabel:n("agents.onboarding.dialogLabel","AI Interview"),onClose:()=>void m(),hideHeader:!0,dragHandleSelector:".experimental-agent-onboarding-modal .modal-header",className:"floating-window--experimental-agent-onboarding",defaultSize:{width:720,height:620},minSize:{width:420,height:320},persistGeometryKey:"floating-window:experimental-agent-onboarding",suspendGeometryPersistenceOnMobile:!0,suspendGeometryPersistenceOnShortViewport:!0,children:e.jsxs("div",{className:"modal modal-lg experimental-agent-onboarding-modal",children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:n("agents.onboarding.title","AI Interview")}),e.jsx("button",{className:"modal-close",onClick:()=>void m(),"aria-label":n("common.closeAriaLabel","Close"),children:"×"})]}),E.length>0&&e.jsx($,{entries:E}),g==="initial"&&e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"agent-onboarding-intent",children:b?n("agents.onboarding.intentLabelEdit","What should this agent change or improve?"):n("agents.onboarding.intentLabelCreate","What should this new agent own?")}),e.jsx("textarea",{id:"agent-onboarding-intent",className:"input experimental-agent-onboarding-modal__textarea",value:f,onChange:a=>_(a.target.value)}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{className:"btn",onClick:()=>void m(),children:n("common.cancel","Cancel")}),e.jsx("button",{className:"btn btn-primary",disabled:!f.trim(),onClick:()=>void O(),children:b?n("agents.onboarding.startInterview","Start interview"):n("agents.onboarding.startOnboarding","Start onboarding")})]})]}),(g==="loading"||g==="question")&&e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"agent-onboarding-answer",children:C||n("agents.onboarding.thinking","Thinking...")}),e.jsx("textarea",{id:"agent-onboarding-answer",className:"input experimental-agent-onboarding-modal__textarea",value:p,onChange:a=>v(a.target.value)}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{className:"btn",onClick:()=>void m(),children:n("common.cancel","Cancel")}),e.jsx("button",{className:"btn btn-primary",disabled:g==="loading"||!p.trim(),onClick:()=>void q(),children:n("agents.onboarding.continue","Continue")})]})]}),g==="summary"&&t&&e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:b?n("agents.onboarding.updatedDraftReady","Updated draft ready for review"):n("agents.onboarding.draftReady","Draft ready for review")}),e.jsx("p",{className:"experimental-agent-onboarding-modal__summary-intro",children:n("agents.onboarding.draftIntro","Review this generated draft. Nothing is applied until you confirm.")}),e.jsxs("div",{className:"experimental-agent-onboarding-modal__summary card",children:[e.jsxs("div",{className:"experimental-agent-onboarding-modal__summary-section",children:[e.jsx("h4",{children:n("agents.onboarding.sectionIdentity","Identity")}),e.jsxs("dl",{className:"experimental-agent-onboarding-modal__summary-list",children:[e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldName","Name")}),e.jsx("dd",{children:i(t.name)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldRole","Role")}),e.jsx("dd",{children:i(t.role)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldTitle","Title")}),e.jsx("dd",{children:i(t.title)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldIcon","Icon")}),e.jsx("dd",{children:i(t.icon)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldReportsTo","Reports To")}),e.jsx("dd",{children:i(t.reportsTo)})]})]})]}),e.jsxs("div",{className:"experimental-agent-onboarding-modal__summary-section",children:[e.jsx("h4",{children:n("agents.onboarding.sectionConfiguration","Configuration")}),e.jsxs("dl",{className:"experimental-agent-onboarding-modal__summary-list",children:[e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldInlineInstructions","Inline Instructions")}),e.jsx("dd",{className:"experimental-agent-onboarding-modal__summary-block",children:i(t.instructionsText)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldSoul","Soul")}),e.jsx("dd",{className:"experimental-agent-onboarding-modal__summary-block",children:i(t.soul)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldAgentMemory","Agent Memory")}),e.jsx("dd",{className:"experimental-agent-onboarding-modal__summary-block",children:i(t.memory)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldSkills","Skills")}),e.jsx("dd",{children:i(t.skills?.join(", "))})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldThinkingLevel","Thinking Level")}),e.jsx("dd",{children:i(t.thinkingLevel)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldMaxTurns","Max Turns")}),e.jsx("dd",{children:i(t.maxTurns)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldTemplate","Template")}),e.jsx("dd",{children:i(t.templateId)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldPatternAgent","Pattern Agent")}),e.jsx("dd",{children:i(t.patternAgentId)})]})]})]}),(t.heartbeatProcedurePath||t.heartbeatIntervalMs||t.heartbeatEnabled!==void 0||t.modelHint||t.runtimeHint)&&e.jsxs("div",{className:"experimental-agent-onboarding-modal__summary-section",children:[e.jsx("h4",{children:n("agents.onboarding.sectionRuntimeHints","Runtime Hints")}),e.jsxs("dl",{className:"experimental-agent-onboarding-modal__summary-list",children:[e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldHeartbeatPath","Heartbeat Procedure Path")}),e.jsx("dd",{children:i(t.heartbeatProcedurePath)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldHeartbeatInterval","Heartbeat Interval")}),e.jsx("dd",{children:i(t.heartbeatIntervalMs?`${t.heartbeatIntervalMs}ms`:void 0)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldHeartbeatEnabled","Heartbeat Enabled")}),e.jsx("dd",{children:i(t.heartbeatEnabled===void 0?void 0:t.heartbeatEnabled?n("agents.onboarding.yes","yes"):n("agents.onboarding.no","no"))})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldModelHint","Model Hint")}),e.jsx("dd",{children:i(t.modelHint)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldRuntimeHint","Runtime Hint")}),e.jsx("dd",{children:i(t.runtimeHint)})]})]})]}),t.rationale&&e.jsxs("div",{className:"experimental-agent-onboarding-modal__summary-section",children:[e.jsx("h4",{children:n("agents.onboarding.sectionRationale","Rationale")}),e.jsx("p",{className:"experimental-agent-onboarding-modal__summary-block",children:t.rationale})]})]}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{className:"btn",onClick:()=>void m(),children:n("common.cancel","Cancel")}),e.jsx("button",{className:"btn btn-primary",onClick:()=>void G(),children:b?n("agents.onboarding.applyDraftSettings","Apply draft to settings form"):n("agents.onboarding.applyDraftAgent","Apply draft to agent form")})]})]}),g==="error"&&T&&e.jsxs("div",{className:"form-group",children:[e.jsx("div",{className:"form-error",children:T}),e.jsx("div",{className:"modal-actions",children:e.jsx("button",{className:"btn",onClick:()=>void m(),children:n("common.close","Close")})})]})]})})}export{te as ExperimentalAgentOnboardingModal};
1
+ import{r as s,j as e}from"./vendor-react-SZ_qB27O.js";import{B as F,D as V,F as W,G as $,H as z,I as K,J as B}from"./index-CtYRoouR.js";import{u as J}from"./vendor-i18n-Duky4gdQ.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";function te({isOpen:l,onClose:R,onUseDraft:M,projectId:x,existingAgents:P,mode:w="create",existingAgentConfig:L}){const{t:n}=J("app"),[g,d]=s.useState("initial"),[f,_]=s.useState(""),[c,S]=s.useState(null),[C,I]=s.useState(""),[k,A]=s.useState("answer"),[p,v]=s.useState(""),[t,H]=s.useState(null),[T,h]=s.useState(null),[E,y]=s.useState([]),b=w==="edit",o=s.useRef(l),N=s.useCallback(()=>{d("initial"),_(""),S(null),I(""),A("answer"),v(""),H(null),h(null),y([])},[]),D=s.useMemo(()=>F.map(a=>({id:a.id,label:a.name,description:a.description})),[]);s.useEffect(()=>{if(o.current=l,!c)return;const a=V(c,x,{onThinking:r=>{o.current&&y(Q=>{const u=[...Q],j=u[u.length-1];return j&&!j.question?(u[u.length-1]={...j,thinkingOutput:`${j.thinkingOutput??""}${r}`},u):[...u,{response:{},thinkingOutput:r}]})},onQuestion:r=>{o.current&&(I(r.question),A(r.id),d("question"))},onSummary:r=>{o.current&&(H(r),d("summary"))},onError:r=>{o.current&&(h(r),d("error"))}});return()=>{o.current=!1,a.close()}},[l,c,x]);const m=async()=>{o.current=!1;try{c&&await z(c,x)}catch{}finally{N(),R()}};if(s.useEffect(()=>{o.current=l,l||N()},[l,N]),!l)return null;const i=a=>a==null||a===""?e.jsx("em",{className:"experimental-agent-onboarding-modal__summary-empty",children:n("agents.onboarding.notSet","Not set")}):e.jsx("span",{children:a}),O=async()=>{d("loading"),h(null);try{const a=await K(f,{mode:w,existingAgentConfig:L,existingAgents:P.map(r=>({id:r.id,name:r.name,role:r.role})),templates:D},x);if(!o.current)return;S(a.sessionId)}catch(a){if(!o.current)return;h(a.message),d("error")}},q=async()=>{if(c){d("loading"),h(null);try{const a={[k]:p};if(y(r=>[...r,{question:{id:k,type:"text",question:C},response:a}]),await B(c,a,x),!o.current)return;v("")}catch(a){if(!o.current)return;h(a.message),d("error")}}},G=async()=>{t&&(M(t),await m())};return e.jsx(W,{windowKey:"experimental-agent-onboarding",modal:!0,title:n("agents.onboarding.title","AI Interview"),ariaLabel:n("agents.onboarding.dialogLabel","AI Interview"),onClose:()=>void m(),hideHeader:!0,dragHandleSelector:".experimental-agent-onboarding-modal .modal-header",className:"floating-window--experimental-agent-onboarding",defaultSize:{width:720,height:620},minSize:{width:420,height:320},persistGeometryKey:"floating-window:experimental-agent-onboarding",suspendGeometryPersistenceOnMobile:!0,suspendGeometryPersistenceOnShortViewport:!0,children:e.jsxs("div",{className:"modal modal-lg experimental-agent-onboarding-modal",children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:n("agents.onboarding.title","AI Interview")}),e.jsx("button",{className:"modal-close",onClick:()=>void m(),"aria-label":n("common.closeAriaLabel","Close"),children:"×"})]}),E.length>0&&e.jsx($,{entries:E}),g==="initial"&&e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"agent-onboarding-intent",children:b?n("agents.onboarding.intentLabelEdit","What should this agent change or improve?"):n("agents.onboarding.intentLabelCreate","What should this new agent own?")}),e.jsx("textarea",{id:"agent-onboarding-intent",className:"input experimental-agent-onboarding-modal__textarea",value:f,onChange:a=>_(a.target.value)}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{className:"btn",onClick:()=>void m(),children:n("common.cancel","Cancel")}),e.jsx("button",{className:"btn btn-primary",disabled:!f.trim(),onClick:()=>void O(),children:b?n("agents.onboarding.startInterview","Start interview"):n("agents.onboarding.startOnboarding","Start onboarding")})]})]}),(g==="loading"||g==="question")&&e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"agent-onboarding-answer",children:C||n("agents.onboarding.thinking","Thinking...")}),e.jsx("textarea",{id:"agent-onboarding-answer",className:"input experimental-agent-onboarding-modal__textarea",value:p,onChange:a=>v(a.target.value)}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{className:"btn",onClick:()=>void m(),children:n("common.cancel","Cancel")}),e.jsx("button",{className:"btn btn-primary",disabled:g==="loading"||!p.trim(),onClick:()=>void q(),children:n("agents.onboarding.continue","Continue")})]})]}),g==="summary"&&t&&e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:b?n("agents.onboarding.updatedDraftReady","Updated draft ready for review"):n("agents.onboarding.draftReady","Draft ready for review")}),e.jsx("p",{className:"experimental-agent-onboarding-modal__summary-intro",children:n("agents.onboarding.draftIntro","Review this generated draft. Nothing is applied until you confirm.")}),e.jsxs("div",{className:"experimental-agent-onboarding-modal__summary card",children:[e.jsxs("div",{className:"experimental-agent-onboarding-modal__summary-section",children:[e.jsx("h4",{children:n("agents.onboarding.sectionIdentity","Identity")}),e.jsxs("dl",{className:"experimental-agent-onboarding-modal__summary-list",children:[e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldName","Name")}),e.jsx("dd",{children:i(t.name)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldRole","Role")}),e.jsx("dd",{children:i(t.role)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldTitle","Title")}),e.jsx("dd",{children:i(t.title)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldIcon","Icon")}),e.jsx("dd",{children:i(t.icon)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldReportsTo","Reports To")}),e.jsx("dd",{children:i(t.reportsTo)})]})]})]}),e.jsxs("div",{className:"experimental-agent-onboarding-modal__summary-section",children:[e.jsx("h4",{children:n("agents.onboarding.sectionConfiguration","Configuration")}),e.jsxs("dl",{className:"experimental-agent-onboarding-modal__summary-list",children:[e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldInlineInstructions","Inline Instructions")}),e.jsx("dd",{className:"experimental-agent-onboarding-modal__summary-block",children:i(t.instructionsText)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldSoul","Soul")}),e.jsx("dd",{className:"experimental-agent-onboarding-modal__summary-block",children:i(t.soul)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldAgentMemory","Agent Memory")}),e.jsx("dd",{className:"experimental-agent-onboarding-modal__summary-block",children:i(t.memory)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldSkills","Skills")}),e.jsx("dd",{children:i(t.skills?.join(", "))})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldThinkingLevel","Thinking Level")}),e.jsx("dd",{children:i(t.thinkingLevel)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldMaxTurns","Max Turns")}),e.jsx("dd",{children:i(t.maxTurns)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldTemplate","Template")}),e.jsx("dd",{children:i(t.templateId)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldPatternAgent","Pattern Agent")}),e.jsx("dd",{children:i(t.patternAgentId)})]})]})]}),(t.heartbeatProcedurePath||t.heartbeatIntervalMs||t.heartbeatEnabled!==void 0||t.modelHint||t.runtimeHint)&&e.jsxs("div",{className:"experimental-agent-onboarding-modal__summary-section",children:[e.jsx("h4",{children:n("agents.onboarding.sectionRuntimeHints","Runtime Hints")}),e.jsxs("dl",{className:"experimental-agent-onboarding-modal__summary-list",children:[e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldHeartbeatPath","Heartbeat Procedure Path")}),e.jsx("dd",{children:i(t.heartbeatProcedurePath)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldHeartbeatInterval","Heartbeat Interval")}),e.jsx("dd",{children:i(t.heartbeatIntervalMs?`${t.heartbeatIntervalMs}ms`:void 0)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldHeartbeatEnabled","Heartbeat Enabled")}),e.jsx("dd",{children:i(t.heartbeatEnabled===void 0?void 0:t.heartbeatEnabled?n("agents.onboarding.yes","yes"):n("agents.onboarding.no","no"))})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldModelHint","Model Hint")}),e.jsx("dd",{children:i(t.modelHint)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldRuntimeHint","Runtime Hint")}),e.jsx("dd",{children:i(t.runtimeHint)})]})]})]}),t.rationale&&e.jsxs("div",{className:"experimental-agent-onboarding-modal__summary-section",children:[e.jsx("h4",{children:n("agents.onboarding.sectionRationale","Rationale")}),e.jsx("p",{className:"experimental-agent-onboarding-modal__summary-block",children:t.rationale})]})]}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{className:"btn",onClick:()=>void m(),children:n("common.cancel","Cancel")}),e.jsx("button",{className:"btn btn-primary",onClick:()=>void G(),children:b?n("agents.onboarding.applyDraftSettings","Apply draft to settings form"):n("agents.onboarding.applyDraftAgent","Apply draft to agent form")})]})]}),g==="error"&&T&&e.jsxs("div",{className:"form-group",children:[e.jsx("div",{className:"form-error",children:T}),e.jsx("div",{className:"modal-actions",children:e.jsx("button",{className:"btn",onClick:()=>void m(),children:n("common.close","Close")})})]})]})})}export{te 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,j as Ss,r as $s,k as Ms,X as Cs,s as Ts,l as As,m as Gs,n as Ls}from"./index-DWRJyaa3.js";import{u as Ds}from"./vendor-i18n-Duky4gdQ.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";const Ps=5,Fs=3,Rs=280;function h(d,m){if(!m)return d;const r=d.includes("?")?"&":"?";return`${d}${r}projectId=${encodeURIComponent(m)}`}function is(d){return!!(d&&typeof d=="object"&&"code"in d&&d.code==="ACTIVE_GOAL_LIMIT_EXCEEDED")}function Hs({initialGoals:d,anchorGoalId:m,projectId:r,onNavigateToMission:as}){const{t:a}=Ds("app"),[c,k]=n.useState(()=>d??[]),[ns,j]=n.useState(null),p=n.useRef(null),[w,L]=n.useState(d===void 0),[D,l]=n.useState(null),[os,P]=n.useState(!1),[v,F]=n.useState(""),[R,N]=n.useState(""),[U,u]=n.useState(null),[O,_]=n.useState(!1),[y,E]=n.useState(!1),[S,V]=n.useState(null),[q,$]=n.useState(""),[B,M]=n.useState(""),[H,f]=n.useState(null),[I,z]=n.useState(!1),[ls,rs]=n.useState(()=>new Set),[ds,cs]=n.useState([]),[x,C]=n.useState({}),[T,W]=n.useState({}),[A,K]=n.useState(null),[us,X]=n.useState(null);n.useEffect(()=>{if(d!==void 0)return;let s=!0;return(async()=>{try{L(!0),l(null);const i=await fetch(h("/api/goals",r));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}},[d,r]),n.useEffect(()=>{let s=!0;return(async()=>{try{const i=await fetch(h("/api/missions",r));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}},[r,a]);const J=async s=>{const e=await fetch(h(`/api/goals/${encodeURIComponent(s)}/missions`,r));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>=Fs&&G<=Ps;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=v.trim();if(!s){u(a("goals.titleRequired","Title is required."));return}try{E(!0),u(null);const e=await Gs(s,r);N(e)}catch(e){u(Ls(e))}finally{E(!1)}}async function fs(){const s=v.trim();if(!s){u(a("goals.titleRequired","Title is required."));return}try{_(!0),u(null),l(null);const e=await fetch(h("/api/goals",r),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({title:s,description:R})});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{z(!0),f(null);const e=await fetch(h(`/api/goals/${S}`,r),{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{z(!1)}}function ks(s){return s.length>Rs||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,j as Ss,r as $s,k as Ms,X as Cs,s as Ts,l as As,m as Gs,n as Ls}from"./index-CtYRoouR.js";import{u as Ds}from"./vendor-i18n-Duky4gdQ.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";const Ps=5,Fs=3,Rs=280;function h(d,m){if(!m)return d;const r=d.includes("?")?"&":"?";return`${d}${r}projectId=${encodeURIComponent(m)}`}function is(d){return!!(d&&typeof d=="object"&&"code"in d&&d.code==="ACTIVE_GOAL_LIMIT_EXCEEDED")}function Hs({initialGoals:d,anchorGoalId:m,projectId:r,onNavigateToMission:as}){const{t:a}=Ds("app"),[c,k]=n.useState(()=>d??[]),[ns,j]=n.useState(null),p=n.useRef(null),[w,L]=n.useState(d===void 0),[D,l]=n.useState(null),[os,P]=n.useState(!1),[v,F]=n.useState(""),[R,N]=n.useState(""),[U,u]=n.useState(null),[O,_]=n.useState(!1),[y,E]=n.useState(!1),[S,V]=n.useState(null),[q,$]=n.useState(""),[B,M]=n.useState(""),[H,f]=n.useState(null),[I,z]=n.useState(!1),[ls,rs]=n.useState(()=>new Set),[ds,cs]=n.useState([]),[x,C]=n.useState({}),[T,W]=n.useState({}),[A,K]=n.useState(null),[us,X]=n.useState(null);n.useEffect(()=>{if(d!==void 0)return;let s=!0;return(async()=>{try{L(!0),l(null);const i=await fetch(h("/api/goals",r));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}},[d,r]),n.useEffect(()=>{let s=!0;return(async()=>{try{const i=await fetch(h("/api/missions",r));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}},[r,a]);const J=async s=>{const e=await fetch(h(`/api/goals/${encodeURIComponent(s)}/missions`,r));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>=Fs&&G<=Ps;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=v.trim();if(!s){u(a("goals.titleRequired","Title is required."));return}try{E(!0),u(null);const e=await Gs(s,r);N(e)}catch(e){u(Ls(e))}finally{E(!1)}}async function fs(){const s=v.trim();if(!s){u(a("goals.titleRequired","Title is required."));return}try{_(!0),u(null),l(null);const e=await fetch(h("/api/goals",r),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({title:s,description:R})});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{z(!0),f(null);const e=await fetch(h(`/api/goals/${S}`,r),{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{z(!1)}}function ks(s){return s.length>Rs||s.includes(`
2
2
  `)}function vs(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})),W(i=>({...i,[s]:""}))}async function ys(s){const e=T[s];if(e)try{K(s),l(null);const i=await fetch(h(`/api/missions/${encodeURIComponent(e)}/goals/${encodeURIComponent(s)}`,r),{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)}`,r),{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,r),{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:v,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:!v.trim()||y,"data-testid":"goals-form-draft-ai",children:[t.jsx(Es,{"aria-hidden":"true"}),y?a("goals.drafting","Drafting…"):a("goals.draftWithAi","Draft with AI")]})]}),t.jsx("textarea",{id:"goals-form-description",className:"input",value:R,maxLength:5e3,onChange:s=>N(s.target.value),"data-testid":"goals-form-description"}),U?t.jsx("p",{className:"form-error goals-error",role:"alert",children:U}):null,t.jsxs("div",{className:"goals-form-actions",children:[t.jsx("button",{type:"button",className:"btn btn-primary",onClick:()=>void fs(),disabled:O||y,"data-testid":"goals-form-submit",children:a("actions.save","Save")}),t.jsx("button",{type:"button",className:"btn",onClick:Y,disabled:O||y,"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}`,draggable:As(),onDragStart:e=>{Ts(e.dataTransfer,{kind:"goal",id:s.id,projectId:r})},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:()=>vs(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=>W(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 ys(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{Hs as GoalsView};
@@ -0,0 +1,11 @@
1
+ import{r as i,j as e}from"./vendor-react-SZ_qB27O.js";import{c as ze,ap as le,aq as Ce,ar as je,cK as Me,cL as Je,av as Ne,cM as es,cN as ss,cO as ts,cP as is,cQ as ns,cR as as,cS as Re,cT as rs,cU as os,cV as cs,cr as ls,cW as Ie,V as hs,S as q,bW as ds,X as Ae,cX as fe,R as K,_ as gs,cw as us,an as $e,h as ae,bF as ve,bE as Te,P as De,aR as ms,b0 as Pe,cY as fs,s as vs,l as ys}from"./index-CtYRoouR.js";import{u as Ge}from"./vendor-i18n-Duky4gdQ.js";import{U as Ee}from"./users-C5uCLwVM.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";/**
2
+ * @license lucide-react v1.7.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const xs=[["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M12 6h.01",key:"1vi96p"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M16 6h.01",key:"1x0f13"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M8 6h.01",key:"1dz90k"}],["path",{d:"M9 22v-3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v3",key:"cabbwy"}],["rect",{x:"4",y:"2",width:"16",height:"20",rx:"2",key:"1uxh74"}]],ps=ze("building",xs);/**
7
+ * @license lucide-react v1.7.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const ks=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]],bs=ze("chart-line",ks),me=["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 Ss(u){const{t:f}=Ge("app"),D=u??"",I=`${je.INSIGHTS_PREFIX}${D}`,j=`${je.INSIGHT_LATEST_RUN_PREFIX}${D}`,s=le(I,{maxAgeMs:Ce}),Y=le(j,{maxAgeMs:Me}),P=i.useRef(Array.isArray(s)&&s.length>0),U=i.useCallback(r=>f(`insights.category.${r}`,Fe[r]??r),[f]),[y,C]=i.useState(()=>Array.isArray(s)?s:[]),[O,Q]=i.useState(()=>me.map(r=>({category:r,label:Fe[r]??r,items:[],isLoading:!1,error:null}))),[H,T]=i.useState(!(Array.isArray(s)&&s.length>0)),[Z,E]=i.useState(null),[G,M]=i.useState(Y??null),[F,_]=i.useState(!1),[b,L]=i.useState(null),[A,B]=i.useState(new Map),[J,l]=i.useState(new Map),[p,g]=i.useState(new Map),[x,h]=i.useState(new Map),[S,N]=i.useState(!1),v=i.useCallback(async()=>{P.current||T(!0),E(null);try{const n=(await Je({status:void 0,limit:1e3},u)).insights.filter(d=>d.status!=="dismissed");C(n),Ne(I,n.length>500?n.slice(0,500):n,{maxBytes:5e5});const o=await es(u);o.runs.length>0&&(M(o.runs[0]),Ne(j,o.runs[0],{maxBytes:5e5})),P.current=!0}catch(r){const n=r instanceof Error?r.message:"Failed to fetch insights";E(n)}finally{T(!1)}},[I,j,u]),ee=i.useCallback(()=>{N(r=>!r)},[]),w=i.useCallback(async(r,n,o)=>{_(!0),L(null);try{const d=await ss("manual",void 0,u,r,n,o);M(d),d.status==="completed"?await v():d.status==="failed"&&d.error&&L(d.error)}catch(d){if(d instanceof ts&&d.status===409&&d.details?.code==="ACTIVE_RUN_CONFLICT"){const re=typeof d.details.activeRunId=="string"?d.details.activeRunId:null;if(re)try{const ue=await is(re,u);M(ue)}catch{}throw L("Insight generation is already running"),d}const k=d instanceof Error?d.message:"Failed to generate insights";throw L(k),d}finally{_(!1)}},[u,v]),z=i.useCallback(async r=>{B(n=>{const o=new Map(n);return o.set(r,{running:!0,error:null}),o});try{await ns(r,u),C(n=>n.filter(o=>o.id!==r)),B(n=>{const o=new Map(n);return o.set(r,{running:!1,error:null}),o})}catch(n){const o=n instanceof Error?n.message:"Failed to dismiss insight";throw B(d=>{const k=new Map(d);return k.set(r,{running:!1,error:o}),k}),n}},[u]),X=i.useCallback(async r=>{l(n=>{const o=new Map(n);return o.set(r,{running:!0,error:null}),o});try{const n=await as(r,u);return await Re(r,u),C(o=>o.map(d=>d.id===r?{...d,status:"archived",updatedAt:new Date().toISOString()}:d)),l(o=>{const d=new Map(o);return d.set(r,{running:!1,error:null}),d}),{title:n.suggestedTitle,description:n.suggestedDescription}}catch(n){const o=n instanceof Error?n.message:"Failed to create task";throw l(d=>{const k=new Map(d);return k.set(r,{running:!1,error:o}),k}),n}},[u]);i.useEffect(()=>{const r=new Map;for(const n of me)r.set(n,[]);for(const n of y){if(!S&&n.status==="archived")continue;const o=r.get(n.category)??[];r.set(n.category,[...o,n])}Q(me.map(n=>({category:n,label:U(n),items:r.get(n)??[],isLoading:!1,error:null})))},[y,S,U]);const he=i.useCallback(async r=>{g(n=>{const o=new Map(n);return o.set(r,{running:!0,error:null}),o});try{await Re(r,u),C(n=>n.map(o=>o.id===r?{...o,status:"archived",updatedAt:new Date().toISOString()}:o)),g(n=>{const o=new Map(n);return o.set(r,{running:!1,error:null}),o})}catch(n){const o=n instanceof Error?n.message:"Failed to archive insight";throw g(d=>{const k=new Map(d);return k.set(r,{running:!1,error:o}),k}),n}},[u]),de=i.useCallback(async r=>{h(n=>{const o=new Map(n);return o.set(r,{running:!0,error:null}),o});try{await rs(r,u),C(n=>n.map(o=>o.id===r?{...o,status:"confirmed",updatedAt:new Date().toISOString()}:o)),h(n=>{const o=new Map(n);return o.set(r,{running:!1,error:null}),o})}catch(n){const o=n instanceof Error?n.message:"Failed to unarchive insight";throw h(d=>{const k=new Map(d);return k.set(r,{running:!1,error:o}),k}),n}},[u]),ge=i.useMemo(()=>O.reduce((r,n)=>r+n.items.length,0),[O]),R=i.useMemo(()=>0,[]),te=i.useMemo(()=>y.filter(r=>r.status==="archived").length,[y]);return i.useEffect(()=>{const r=le(I,{maxAgeMs:Ce}),n=le(j,{maxAgeMs:Me}),o=Array.isArray(r)&&r.length>0;C(Array.isArray(r)?r:[]),M(n??null),T(!o),P.current=o},[I,j]),i.useEffect(()=>{v()},[v]),{sections:O,loading:H,error:Z,latestRun:G,isRunInFlight:F,runError:b,refresh:v,runInsights:w,dismiss:z,createTask:X,archive:he,unarchive:de,toggleShowArchived:ee,dismissStates:A,createTaskStates:J,archiveStates:p,unarchiveStates:x,totalCount:ge,dismissedCount:R,archivedCount:te,showArchived:S}}const ws=20,Cs=50;function js(u){const[f,D]=i.useState([]),[I,j]=i.useState(!0),[s,Y]=i.useState(!1),[P,U]=i.useState(null),[y,C]=i.useState(!1),[O,Q]=i.useState(0),[H,T]=i.useState(!1),[Z,E]=i.useState(new Map),G=i.useRef(0),M=i.useRef(0),F=i.useRef(!1),_=i.useRef(new Set),b=i.useRef(0),L=i.useRef(u),A=i.useCallback(async p=>{if(F.current)return;F.current=!0;const g=b.current,x=p?0:G.current;p?j(!0):Y(!0),U(null);try{const h=await os(u,{limit:Cs,offset:x});if(g!==b.current)return;D(v=>{const ee=p?[]:v,w=new Set(ee.map(z=>`${z.taskId}:${z.recommendation.id}`));return[...ee,...h.items.filter(z=>{const X=`${z.taskId}:${z.recommendation.id}`;return w.has(X)?!1:(w.add(X),!0)})]}),G.current=h.rowOffset+h.returnedRowCount,M.current=p?1:M.current+1,Q(h.totalRowCount);const N=M.current>=ws&&h.hasMore;T(N),C(N?!1:h.hasMore)}catch(h){g===b.current&&U(h instanceof Error?h.message:"Failed to fetch task recommendations")}finally{g===b.current&&(j(!1),Y(!1)),F.current=!1}},[u]),B=i.useCallback(async()=>{G.current=0,M.current=0,T(!1),await A(!0)},[A]);i.useEffect(()=>{L.current=u,b.current+=1,F.current=!1,_.current.clear(),G.current=0,M.current=0,D([]),C(!1),Q(0),T(!1),E(new Map),A(!0)},[A,u]);const J=i.useCallback(async()=>{!y||H||F.current||await A(!1)},[A,y,H]),l=i.useCallback(async(p,g)=>{const x=`${p}:${g}`;if(_.current.has(x))return;_.current.add(x);const h=b.current;E(S=>new Map(S).set(x,{running:!0,error:null}));try{const S=await cs(p,g,L.current);if(h!==b.current)return;D(N=>N.map(v=>v.taskId===p&&v.recommendation.id===g?{...v,recommendation:{...v.recommendation,createdTaskId:S.task.id}}:v)),E(N=>new Map(N).set(x,{running:!1,error:null}))}catch(S){h===b.current&&E(N=>new Map(N).set(x,{running:!1,error:S instanceof Error?S.message:"Could not create task"}))}finally{h===b.current&&_.current.delete(x)}},[]);return{items:f,loading:I,loadingMore:s,error:P,hasMore:y,totalRowCount:O,truncated:H,refresh:B,loadMore:J,createTask:l,createStates:Z}}const Ue=["Backlog health:","Backlog pressure detected","Stale paused todo","Backlog health: dependency-blocked todos"];function _e(u){return Ue.some(f=>u.title.startsWith(f))}const Le={architecture:ps,quality:$e,workflow:Pe,performance:Te,reliability:K,security:ae,ux:Ee,testability:fe,documentation:ms,dependency:De,features:ve,competitive_analysis:Ee,research:bs,trends:Te,other:q};function Fs({projectId:u,addToast:f,onClose:D,onCreateTask:I,models:j}){const{t:s}=Ge("app"),{sections:Y,loading:P,error:U,latestRun:y,isRunInFlight:C,runError:O,refresh:Q,runInsights:H,dismiss:T,createTask:Z,archive:E=async()=>{},unarchive:G=async()=>{},toggleShowArchived:M=()=>{},dismissStates:F,createTaskStates:_,archiveStates:b=new Map,unarchiveStates:L=new Map,totalCount:A,archivedCount:B=0,showArchived:J=!1}=Ss(u),l=js(u),[p,g]=i.useState(null),[x,h]=i.useState("info"),[S,N]=i.useState(!1),[v,ee]=i.useState(!1),[w,z]=i.useState(()=>localStorage.getItem("fusion-insight-model")??""),[X,he]=i.useState(()=>localStorage.getItem("fusion-insight-thinking")??""),[de,ge]=i.useState([]),[R,te]=i.useState([]),[r,n]=i.useState([]),[o,d]=i.useState();i.useEffect(()=>{j||ls().then(t=>{ge(t.models),te(t.favoriteProviders),n(t.favoriteModels),d(t.resolvedPlanningProvider);const a=localStorage.getItem("fusion-insight-model");a&&(t.models.some(m=>`${m.provider}/${m.id}`===a)||(localStorage.removeItem("fusion-insight-model"),z("")))}).catch(()=>{})},[j]);const k=j??de,re=i.useMemo(()=>R.length>0?R:o?[o]:[],[R,o]),ue=i.useCallback(async t=>{const c=R.includes(t)?R.filter(m=>m!==t):[t,...R];te(c);try{await Ie({favoriteProviders:c,favoriteModels:r})}catch{te(R)}},[R,r]),Oe=i.useCallback(async t=>{const c=r.includes(t)?r.filter(m=>m!==t):[t,...r];n(c);try{await Ie({favoriteProviders:R,favoriteModels:c})}catch{n(r)}},[r,R]),He=i.useCallback(t=>{z(t),t?localStorage.setItem("fusion-insight-model",t):localStorage.removeItem("fusion-insight-model")},[]),Be=i.useCallback(t=>{he(t),t?localStorage.setItem("fusion-insight-thinking",t):localStorage.removeItem("fusion-insight-thinking")},[]),ie=i.useMemo(()=>Y.filter(t=>t.items.length>0),[Y]),ye=i.useMemo(()=>ie.reduce((t,a)=>t+a.items.filter(_e).length,0),[ie]),W=i.useMemo(()=>v?ie.map(t=>({...t,items:t.items.filter(_e)})).filter(t=>t.items.length>0):ie,[ie,v]),[$,ne]=i.useState(null);i.useEffect(()=>{if($==="recommendations"&&l.items.length>0)return;if(W.length===0){l.items.length>0?ne("recommendations"):$!==null&&ne(null);return}$&&W.some(a=>a.category===$&&a.items.length>0)||ne(W[0]?.category??(l.items.length>0?"recommendations":null))},[W,$,l.items.length]);const V=i.useMemo(()=>$==="recommendations"?void 0:W.find(t=>t.category===$)??W[0],[W,$]);i.useEffect(()=>{if(p){const t=setTimeout(()=>g(null),5e3);return()=>clearTimeout(t)}},[p]);const xe=i.useCallback(async()=>{try{g(s("insights.generatingInsights","Generating insights...")),h("info");let t,a;if(w){const c=w.indexOf("/");if(c!==-1){const m=w.slice(0,c),oe=w.slice(c+1);m&&oe&&(t=m,a=oe)}}await H(t,a,X||void 0),g(s("insights.generationStarted","Insight generation started")),h("success"),f(s("insights.generationStarted","Insight generation started"),"success")}catch(t){const a=t instanceof Error?t.message:s("insights.failedToStart","Failed to start generation");if(a==="Insight generation is already running"){g(s("insights.alreadyRunning","Insight generation is already running. Showing the active run.")),h("info"),f(s("insights.alreadyRunningShort","Insight generation is already running"),"info");return}g(a),h("error"),f(a,"error")}},[H,f,w,X,s]),Xe=i.useCallback(async(t,a)=>{try{g(s("insights.dismissing",'Dismissing "{{title}}"...',{title:a})),h("info"),await T(t),g(s("insights.dismissed",'Dismissed "{{title}}"',{title:a})),h("success"),f(s("insights.dismissedMsg","Insight dismissed: {{title}}",{title:a}),"success")}catch(c){const m=c instanceof Error?c.message:s("insights.failedToDismiss","Failed to dismiss insight");g(m),h("error"),f(m,"error")}},[T,f,s]),We=i.useCallback(async(t,a)=>{try{g(s("insights.archiving",'Archiving "{{title}}"...',{title:a})),h("info"),await E(t),g(s("insights.archived",'Archived "{{title}}"',{title:a})),h("success"),f(s("insights.archivedMsg","Insight archived: {{title}}",{title:a}),"success")}catch(c){const m=c instanceof Error?c.message:s("insights.failedToArchive","Failed to archive insight");g(m),h("error"),f(m,"error")}},[E,f,s]),Ve=i.useCallback(async(t,a)=>{try{g(s("insights.unarchiving",'Unarchiving "{{title}}"...',{title:a})),h("info"),await G(t),g(s("insights.unarchived",'Unarchived "{{title}}"',{title:a})),h("success"),f(s("insights.unarchivedMsg","Insight unarchived: {{title}}",{title:a}),"success")}catch(c){const m=c instanceof Error?c.message:s("insights.failedToUnarchive","Failed to unarchive insight");g(m),h("error"),f(m,"error")}},[G,f,s]),qe=i.useCallback(async(t,a)=>{try{if(g(s("insights.creatingTask",'Creating task from "{{title}}"...',{title:a})),h("info"),!I)throw new Error(s("insights.taskCreationUnavailable","Task creation is unavailable in this view"));const c=await Z(t);if(!c)throw new Error(s("insights.failedToPreparePayload","Failed to prepare task payload from insight"));await I({insightId:t,title:c.title,description:c.description}),g(s("insights.taskCreated",'Task created from "{{title}}"',{title:a})),h("success"),f(s("insights.taskCreatedMsg","Task created: {{title}}",{title:c.title}),"success")}catch(c){const m=c instanceof Error?c.message:s("insights.failedToCreateTask","Failed to create task");g(m),h("error"),f(m,"error")}},[Z,I,f,s]),Ke=t=>{const a=Le[t.category]??q,c=V?.category===t.category;return e.jsx("li",{children:e.jsxs("button",{type:"button",className:`insights-category-item${c?" insights-category-item--active":""}`,onClick:()=>ne(t.category),"aria-current":c?"true":void 0,"data-testid":`insights-category-${t.category}`,children:[e.jsx(a,{size:16,className:"insights-category-icon"}),e.jsx("span",{className:"insights-category-label",children:t.label}),e.jsx("span",{className:"insights-category-count",children:t.items.length})]})},t.category)},Ye=()=>e.jsxs("section",{className:"insights-section insights-recommendations","data-testid":"insights-section-recommendations",children:[e.jsx("div",{className:"insights-section-header",children:e.jsxs("div",{className:"insights-section-title",children:[e.jsx(ve,{size:18,className:"insights-section-icon"}),e.jsx("h3",{children:s("insights.recommendations.title","Task Recommendations")}),e.jsx("span",{className:"insights-section-count",children:l.items.length})]})}),e.jsx("p",{className:"insights-recommendations__count",children:s("insights.recommendations.count","Showing {{shown}} of {{total}} source tasks",{shown:l.items.length,total:l.totalRowCount})}),e.jsx("ul",{className:"insights-list",children:l.items.map(t=>{const a=`${t.taskId}:${t.recommendation.id}`,c=l.createStates.get(a),m=t.recommendation.createdTaskId;return e.jsxs("li",{className:"insight-item insights-recommendations__item","data-testid":`task-recommendation-${a}`,children:[e.jsxs("div",{className:"insight-item-header",children:[e.jsx("h4",{className:"insight-item-title",children:t.recommendation.title}),e.jsx("span",{className:"insights-category-count",children:t.recommendation.category})]}),e.jsx("p",{children:t.recommendation.description}),e.jsx("p",{className:"insights-recommendations__source",children:s("insights.recommendations.source","Source: {{task}}",{task:t.taskTitle?`${t.taskId} — ${t.taskTitle}`:t.taskId})}),m?e.jsx("span",{role:"status",children:s("taskDetail.recommendations.created","Created {{taskId}}",{taskId:m})}):e.jsxs("div",{children:[e.jsx("button",{className:"btn btn-primary",type:"button",disabled:c?.running,onClick:()=>void l.createTask(t.taskId,t.recommendation.id),children:c?.running?s("taskDetail.recommendations.creating","Creating…"):c?.error?s("taskDetail.recommendations.retry","Retry creating task"):s("taskDetail.recommendations.create","Create task")}),c?.error&&e.jsx("span",{role:"status",children:s("taskDetail.recommendations.error","Could not create task. Try again.")})]})]},a)})}),l.truncated?e.jsx("p",{role:"status",children:s("insights.recommendations.truncated","Showing the first 20 pages. Refresh to see the latest recommendations.")}):l.hasMore?e.jsx("button",{className:"btn",type:"button",disabled:l.loadingMore,onClick:()=>void l.loadMore(),children:l.loadingMore?s("insights.recommendations.loadingMore","Loading more…"):s("insights.recommendations.loadMore","Load more")}):null,l.error&&!l.loading&&e.jsxs("div",{role:"status",children:[e.jsx("span",{children:s("insights.recommendations.loadMoreFailed","Could not load more recommendations.")}),e.jsx("button",{className:"btn",type:"button",onClick:()=>void(l.hasMore?l.loadMore():l.refresh()),children:s("actions.retry","Retry")})]})]}),Qe=()=>{if(!V)return null;const t=Le[V.category]??q;return e.jsxs("section",{className:"insights-section","data-testid":`insights-section-${V.category}`,children:[e.jsx("div",{className:"insights-section-header",children:e.jsxs("div",{className:"insights-section-title",children:[e.jsx(t,{size:18,className:"insights-section-icon"}),e.jsx("h3",{children:V.label}),e.jsx("span",{className:"insights-section-count",children:V.items.length})]})}),e.jsx("div",{className:"insights-section-content",children:e.jsx("ul",{className:"insights-list",children:V.items.map(a=>{const c=F.get(a.id),m=_.get(a.id),oe=b.get(a.id),Ze=L.get(a.id),pe=c?.running??!1,ke=m?.running??!1,be=oe?.running??!1,Se=Ze?.running??!1,we=a.status==="archived",ce=V.items.some(se=>F.get(se.id)?.running||_.get(se.id)?.running||b.get(se.id)?.running||L.get(se.id)?.running);return e.jsxs("li",{className:`insight-item${we?" insight-item--archived":""}`,"data-insight-id":a.id,draggable:ys(),onDragStart:se=>{vs(se.dataTransfer,{kind:"research-finding",id:a.id,projectId:u})},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 Ve(a.id,a.title),disabled:Se||ce,title:s("insights.unarchiveTitle","Unarchive this insight"),"aria-label":s("insights.unarchiveLabel","Unarchive this insight"),"data-testid":`unarchive-${a.id}`,children:Se?e.jsx(K,{size:16,className:"spin"}):e.jsx(fs,{size:16})}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"insight-item-action-btn",onClick:()=>void qe(a.id,a.title),disabled:ke||ce,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:ke?e.jsx(K,{size:16,className:"spin"}):e.jsx(De,{size:16})}),e.jsx("button",{className:"insight-item-action-btn",onClick:()=>void We(a.id,a.title),disabled:be||ce,title:s("insights.archiveTitle","Archive this insight"),"aria-label":s("insights.archiveLabel","Archive this insight"),"data-testid":`archive-${a.id}`,children:be?e.jsx(K,{size:16,className:"spin"}):e.jsx(fe,{size:16})})]}),e.jsx("button",{className:"insight-item-action-btn",onClick:()=>void Xe(a.id,a.title),disabled:pe||ce,title:s("insights.dismissTitle","Dismiss this insight"),"aria-label":s("insights.dismissLabel","Dismiss this insight"),"data-testid":`dismiss-${a.id}`,children:pe?e.jsx(K,{size:16,className:"spin"}):e.jsx(Ae,{size:16})})]})]}),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(Pe,{size:12}),new Date(a.createdAt).toLocaleDateString()]})]})]},a.id)})})})]})};return e.jsxs("div",{className:"insights-view","data-testid":"insights-view",children:[e.jsx(hs,{icon:q,title:s("insights.title","Insights"),actions:e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"insights-view-count",children:[A," ",s("common.total","total")]}),ye>0&&e.jsxs("button",{className:`btn btn-sm insights-backlog-health-toggle${v?" btn-icon--active":""}`,onClick:()=>ee(t=>!t),"aria-pressed":v,"aria-label":v?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(ds,{size:14}),v?s("insights.allInsights","All Insights"):s("insights.backlogHealth","Backlog")," ",e.jsxs("span",{children:["(",ye,")"]})]}),D&&e.jsx("button",{className:"btn btn-sm insights-view-close",onClick:D,"aria-label":s("actions.closeInsightsView","Close insights view"),title:s("actions.close","Close"),children:e.jsx(Ae,{size:16})}),B>0&&e.jsxs("button",{className:"btn btn-sm insights-show-archived-toggle",onClick:M,"aria-label":J?s("insights.hideArchived","Hide archived insights"):s("insights.showArchived","Show archived insights"),"data-testid":"toggle-archived-insights",children:[e.jsx(fe,{size:14}),J?s("insights.hideArchivedLabel","Archived"):s("insights.showArchivedLabel","Archived ({{count}})",{count:B})]}),e.jsx("button",{className:"btn btn-icon btn-sm insights-refresh-btn",onClick:()=>void Q(),disabled:P,"aria-label":s("actions.refreshInsights","Refresh insights"),title:s("actions.refreshInsights","Refresh insights"),"data-testid":"refresh-insights",children:e.jsx(K,{size:14,className:P?"spin":""})}),e.jsxs("button",{className:"btn btn-sm insights-model-toggle",onClick:()=>N(t=>!t),"aria-label":s("insights.configureModel","Configure insight generation model"),"aria-expanded":S,"data-testid":"toggle-model-config",title:w?s("insights.modelConfigured","Model: {{model}}",{model:w}):s("insights.configureModelTitle","Configure model"),children:[e.jsx(gs,{size:14}),w&&e.jsx("span",{className:"insights-model-indicator"})]}),e.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>void xe(),disabled:C,"aria-label":s("insights.generateInsights","Generate new insights"),"data-testid":"run-insights",children:C?e.jsxs(e.Fragment,{children:[e.jsx(K,{size:14,className:"spin"}),s("insights.generating","Generating...")]}):e.jsxs(e.Fragment,{children:[e.jsx(q,{size:14}),s("insights.generateInsightsBtn","Generate Insights")]})})]})}),S&&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(us,{models:k,value:w,onChange:He,placeholder:s("insights.usePlanningDefault","Use planning default"),label:s("insights.generationModel","Insight generation model"),disabled:C,id:"insight-model-select",favoriteProviders:re,favoriteModels:r,onToggleFavorite:ue,onToggleModelFavorite:Oe,showThinkingLevel:!0,thinkingLevel:X,onThinkingLevelChange:Be,defaultThinkingLevel:"off"})]}),e.jsx("div",{className:"insights-status-region","aria-live":"polite","data-testid":"insights-status",children:p&&e.jsxs("div",{className:`insights-status-message insights-status-message--${x}`,role:x==="error"?"alert":void 0,children:[x==="success"&&e.jsx($e,{size:16}),x==="error"&&e.jsx(ae,{size:16}),x==="info"&&e.jsx(q,{size:16}),e.jsx("span",{children:p})]})}),O&&e.jsxs("div",{className:"insights-error-callout",role:"alert","data-testid":"run-error",children:[e.jsx(ae,{size:16}),e.jsx("span",{children:O})]}),y&&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:")," ",y.status,y.status==="completed"&&e.jsxs(e.Fragment,{children:[" — ",s("insights.runCompleted","{{created}} created, {{updated}} updated",{created:y.insightsCreated,updated:y.insightsUpdated})]}),y.status==="failed"&&y.error&&e.jsxs(e.Fragment,{children:[" — ",y.error]})]})}),l.error&&!l.loading&&l.items.length===0&&e.jsxs("div",{className:"insights-error-callout",role:"status","data-testid":"task-recommendations-error",children:[e.jsx(ae,{size:16}),e.jsx("span",{children:s("insights.recommendations.loadMoreFailed","Could not load more recommendations.")}),e.jsx("button",{className:"btn btn-sm",type:"button",onClick:()=>void l.refresh(),children:s("actions.retry","Retry")})]}),P?e.jsxs("div",{className:"insights-loading","data-testid":"insights-loading",children:[e.jsx(K,{size:24,className:"spin"}),e.jsx("p",{children:s("insights.loading","Loading insights...")})]}):U?e.jsxs("div",{className:"insights-error","data-testid":"insights-error",children:[e.jsx(ae,{size:24}),e.jsx("p",{children:U}),e.jsx("button",{className:"btn btn-sm",onClick:()=>void Q(),children:s("actions.retry","Retry")})]}):A===0&&l.items.length===0?e.jsxs("div",{className:"insights-empty","data-testid":"insights-empty",children:[e.jsx(q,{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 xe(),children:[e.jsx(q,{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.jsxs("ul",{className:"insights-category-list",children:[W.map(Ke),l.items.length>0&&e.jsx("li",{children:e.jsxs("button",{type:"button",className:`insights-category-item${$==="recommendations"?" insights-category-item--active":""}`,onClick:()=>ne("recommendations"),"data-testid":"insights-category-recommendations",children:[e.jsx(ve,{size:16,className:"insights-category-icon"}),e.jsx("span",{className:"insights-category-label",children:s("insights.recommendations.title","Task Recommendations")}),e.jsxs("span",{className:"insights-category-count",children:[l.items.length,l.hasMore?`/${l.totalRowCount}`:""]})]})})]})}),e.jsx("div",{className:"insights-detail",children:$==="recommendations"?Ye():Qe()})]})]})}export{Fs as InsightsView};
@@ -1 +1 @@
1
- .insights-view{--insights-divider-color: var(--chrome-divider-color, transparent);display:flex;flex-direction:column;height:100%;min-height:0;overflow:hidden}.insights-view-count{font-size:.8125rem;color:var(--text-muted);font-weight:400}.insights-model-config{display:flex;align-items:center;gap:var(--space-sm);padding:var(--space-sm) var(--space-lg);border-bottom:var(--chrome-divider-width, 1px) solid var(--insights-divider-color);background:var(--surface-subtle)}.insights-model-label{font-size:.8125rem;color:var(--text-muted);white-space:nowrap;flex-shrink:0}.insights-model-config .model-combobox{max-width:320px}.insights-model-toggle{position:relative}.insights-model-indicator{position:absolute;top:2px;right:2px;width:6px;height:6px;border-radius:50%;background:var(--todo, #f59e0b)}.insights-view-close{color:var(--text-muted)}.insights-view-close:hover{color:var(--text)}.insights-refresh-btn{flex:0 0 auto}.insights-status-region{padding:var(--space-md) var(--space-lg);flex-shrink:0}.insights-status-region:empty{padding:0}.insights-status-message{display:flex;align-items:center;gap:var(--space-sm);padding:var(--space-sm) var(--space-md);border-radius:var(--radius-md);font-size:.8125rem}.insights-status-message--success{background:color-mix(in srgb,var(--color-success) 10%,transparent);color:var(--color-success)}.insights-status-message--error{background:color-mix(in srgb,var(--color-error) 10%,transparent);color:var(--color-error)}.insights-status-message--info{background:color-mix(in srgb,var(--accent) 10%,transparent);color:var(--accent)}.insights-error-callout{display:flex;align-items:center;gap:var(--space-sm);margin:0 var(--space-lg) var(--space-md);padding:var(--space-md);background:color-mix(in srgb,var(--color-error) 10%,transparent);border:1px solid color-mix(in srgb,var(--color-error) 30%,transparent);border-radius:var(--radius-md);color:var(--color-error);font-size:.8125rem;flex-shrink:0}.insights-run-info{padding:0 var(--space-lg) var(--space-md);flex-shrink:0}.insights-run-status{font-size:.75rem;color:var(--text-muted)}.insights-loading{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--space-md);padding:var(--space-2xl);color:var(--text-muted)}.insights-error{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--space-md);padding:var(--space-2xl);text-align:center}.insights-error p{color:var(--text-muted);margin:0}.insights-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--space-md);padding:var(--space-2xl);text-align:center;flex:1}.insights-empty h3{margin:0;font-size:1.125rem;color:var(--text)}.insights-empty p{color:var(--text-muted);margin:0;max-width:calc(var(--space-2xl) * 12 + var(--space-lg))}.insights-body{flex:1;min-height:0;display:flex;overflow:hidden}.insights-sidebar{width:calc(var(--space-2xl) * 7 + var(--space-lg));flex-shrink:0;border-right:1px solid var(--border);background:var(--surface);overflow-y:auto;min-height:0}.insights-category-list{list-style:none;margin:0;padding:var(--space-sm);display:flex;flex-direction:column;gap:var(--space-xs)}.insights-category-item{width:100%;display:flex;align-items:center;gap:var(--space-sm);padding:var(--space-sm) var(--space-md);background:transparent;border:1px solid transparent;border-radius:var(--radius-md);color:var(--text);font:inherit;font-size:.8125rem;text-align:left;cursor:pointer;transition:background var(--transition-fast),border-color var(--transition-fast)}.insights-category-item:hover{background:var(--surface-1)}.insights-category-item--active{background:color-mix(in srgb,var(--accent) 12%,transparent);border-color:color-mix(in srgb,var(--accent) 35%,transparent);color:var(--accent)}.insights-category-icon{flex-shrink:0;color:var(--accent)}.insights-category-label{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:500}.insights-category-count{flex-shrink:0;font-size:.75rem;color:var(--text-muted);background:var(--surface-1);padding:var(--space-xs) var(--space-sm);border-radius:var(--radius-pill);border:1px solid var(--border)}.insights-category-item--active .insights-category-count{background:var(--surface);color:var(--accent);border-color:color-mix(in srgb,var(--accent) 30%,transparent)}.insights-detail{flex:1;min-width:0;min-height:0;overflow-y:auto;padding:var(--space-lg)}.insights-section{background:transparent;border:none;border-radius:0;overflow:visible}.insights-section-header{display:flex;align-items:center;justify-content:space-between;padding:0 0 var(--space-md);background:transparent;border-bottom:none}.insights-section-title{display:flex;align-items:center;gap:var(--space-sm)}.insights-section-title h3{margin:0;font-size:.9375rem;font-weight:600}.insights-section-icon{color:var(--accent)}.insights-section-count{font-size:.75rem;color:var(--text-muted);background:var(--surface-1);padding:var(--space-xs) var(--space-sm);border-radius:var(--radius-pill);border:1px solid var(--border)}.insights-section-content{padding:0}.insights-list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:var(--space-sm)}.insight-item{padding:var(--space-md) var(--space-lg);background:var(--card);border:1px solid var(--border);border-left:3px solid color-mix(in srgb,var(--accent) 55%,transparent);border-radius:var(--radius-md);transition:border-color var(--transition-fast),background var(--transition-fast)}.insight-item:hover{background:var(--surface);border-left-color:var(--accent)}.insight-item-header{display:flex;align-items:flex-start;justify-content:space-between;gap:var(--space-sm)}.insight-item-title{margin:0;font-size:.875rem;font-weight:600;color:var(--text);line-height:1.4}.insight-item-actions{display:flex;align-items:center;gap:var(--space-xs);flex-shrink:0}.insight-item-action-btn{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;background:transparent;border:none;border-radius:var(--radius-sm);color:var(--text-muted);cursor:pointer;opacity:.65;transition:background var(--transition-fast),color var(--transition-fast),opacity var(--transition-fast)}.insight-item:hover .insight-item-action-btn,.insight-item:focus-within .insight-item-action-btn{opacity:1}.insight-item-action-btn:hover:not(:disabled){background:var(--surface-1);color:var(--accent)}.insight-item-action-btn:focus-visible{outline:none;box-shadow:var(--focus-ring-strong)}.insight-item-action-btn:disabled{opacity:.5;cursor:not-allowed}.insight-item-content{margin:var(--space-sm) 0 0;font-size:.8125rem;color:var(--text-muted);line-height:1.5;white-space:pre-wrap;word-break:break-word}.insight-item-meta{display:flex;align-items:center;gap:var(--space-md);margin-top:var(--space-sm);font-size:.75rem;color:var(--text-muted)}.insight-item-status{padding:var(--space-xs) var(--space-sm);border-radius:var(--radius-sm);text-transform:capitalize;font-weight:500}.insight-item-status--generated{background:color-mix(in srgb,var(--accent) 15%,transparent);color:var(--accent)}.insight-item-status--confirmed{background:color-mix(in srgb,var(--color-success) 15%,transparent);color:var(--color-success)}.insight-item-status--stale{background:color-mix(in srgb,var(--color-warning) 15%,transparent);color:var(--color-warning)}.insight-item-status--dismissed,.insight-item-status--archived{background:color-mix(in srgb,var(--text-dim) 15%,transparent);color:var(--text-dim)}.insight-item--archived{opacity:.6;border-left-color:var(--text-dim)}.insight-item--archived .insight-item-title{text-decoration:line-through;color:var(--text-muted)}.insight-item--archived .insight-item-content{text-decoration:line-through}.insight-item-date{display:flex;align-items:center;gap:var(--space-xs)}@media(max-width:768px),(max-height:480px){.insights-view .view-header{align-items:flex-start;flex-wrap:wrap;gap:var(--space-sm) var(--space-md)}.insights-view .view-header__title{flex:1 0 100%;min-width:100%}.insights-view .view-header__title span{overflow:visible;text-overflow:clip}.insights-view .view-header__actions{justify-content:flex-start;width:100%;max-width:100%;margin-left:0}.insights-body{flex-direction:column}.insights-sidebar{width:100%;border-right:none;border-bottom:var(--chrome-divider-width, 1px) solid var(--insights-divider-color);overflow-x:auto;overflow-y:hidden;flex-shrink:0}.insights-category-list{flex-direction:row;flex-wrap:nowrap;padding:var(--space-sm);gap:var(--space-xs)}.insights-category-list>li{flex-shrink:0}.insights-category-item{white-space:nowrap;padding:var(--space-xs) var(--space-sm)}.insights-category-label{overflow:visible;text-overflow:clip}.insights-detail{padding:var(--space-md)}.insights-section-header{padding:var(--space-sm) var(--space-md)}.insights-section-content,.insight-item{padding:var(--space-sm)}.insight-item-title{word-break:break-word}.insight-item-header{flex-direction:column;gap:var(--space-sm)}.insight-item-meta{flex-wrap:wrap;gap:var(--space-sm)}.insight-item-actions{align-self:flex-end}.insight-item-action-btn{width:calc(var(--space-2xl) + var(--space-sm));height:calc(var(--space-2xl) + var(--space-sm))}.view-header__actions .insights-view-actions-btn{min-height:calc(var(--space-2xl) + var(--space-xs))}.insights-show-archived-toggle{max-width:calc(var(--space-2xl) * 5 + var(--space-md));white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.insights-view-close{min-height:calc(var(--space-2xl) + var(--space-xs));min-width:calc(var(--space-2xl) + var(--space-xs))}.insights-view-count{font-size:.75rem}.insights-model-config{padding:var(--space-xs) var(--space-md)}.insights-model-config .model-combobox{max-width:200px}}@media(min-width:769px)and (max-width:1024px){.insights-view{flex:1;inline-size:100%;min-inline-size:0;min-block-size:0;overflow:hidden}.insights-body{flex-direction:column;inline-size:100%;min-width:0;min-inline-size:0;min-block-size:0;overflow:hidden}.insights-sidebar{width:100%;min-width:0;min-inline-size:0;border-right:none;border-bottom:var(--chrome-divider-width, 1px) solid var(--insights-divider-color);overflow-x:auto;overflow-y:hidden}.insights-category-list{flex-direction:row;flex-wrap:nowrap}.insights-category-list>li{flex-shrink:0}.insights-category-item{white-space:nowrap}.insights-detail{flex:1 1 0;min-width:0;min-inline-size:0;min-block-size:0;overflow-y:auto}}
1
+ .insights-view{--insights-divider-color: var(--chrome-divider-color, transparent);display:flex;flex-direction:column;height:100%;min-height:0;overflow:hidden}.insights-view-count{font-size:.8125rem;color:var(--text-muted);font-weight:400}.insights-model-config{display:flex;align-items:center;gap:var(--space-sm);padding:var(--space-sm) var(--space-lg);border-bottom:var(--chrome-divider-width, 1px) solid var(--insights-divider-color);background:var(--surface-subtle)}.insights-model-label{font-size:.8125rem;color:var(--text-muted);white-space:nowrap;flex-shrink:0}.insights-model-config .model-combobox{max-width:320px}.insights-model-toggle{position:relative}.insights-model-indicator{position:absolute;top:2px;right:2px;width:6px;height:6px;border-radius:50%;background:var(--todo, #f59e0b)}.insights-view-close{color:var(--text-muted)}.insights-view-close:hover{color:var(--text)}.insights-refresh-btn{flex:0 0 auto}.insights-status-region{padding:var(--space-md) var(--space-lg);flex-shrink:0}.insights-status-region:empty{padding:0}.insights-status-message{display:flex;align-items:center;gap:var(--space-sm);padding:var(--space-sm) var(--space-md);border-radius:var(--radius-md);font-size:.8125rem}.insights-status-message--success{background:color-mix(in srgb,var(--color-success) 10%,transparent);color:var(--color-success)}.insights-status-message--error{background:color-mix(in srgb,var(--color-error) 10%,transparent);color:var(--color-error)}.insights-status-message--info{background:color-mix(in srgb,var(--accent) 10%,transparent);color:var(--accent)}.insights-error-callout{display:flex;align-items:center;gap:var(--space-sm);margin:0 var(--space-lg) var(--space-md);padding:var(--space-md);background:color-mix(in srgb,var(--color-error) 10%,transparent);border:1px solid color-mix(in srgb,var(--color-error) 30%,transparent);border-radius:var(--radius-md);color:var(--color-error);font-size:.8125rem;flex-shrink:0}.insights-run-info{padding:0 var(--space-lg) var(--space-md);flex-shrink:0}.insights-run-status{font-size:.75rem;color:var(--text-muted)}.insights-loading{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--space-md);padding:var(--space-2xl);color:var(--text-muted)}.insights-error{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--space-md);padding:var(--space-2xl);text-align:center}.insights-error p{color:var(--text-muted);margin:0}.insights-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--space-md);padding:var(--space-2xl);text-align:center;flex:1}.insights-empty h3{margin:0;font-size:1.125rem;color:var(--text)}.insights-empty p{color:var(--text-muted);margin:0;max-width:calc(var(--space-2xl) * 12 + var(--space-lg))}.insights-body{flex:1;min-height:0;display:flex;overflow:hidden}.insights-sidebar{width:calc(var(--space-2xl) * 7 + var(--space-lg));flex-shrink:0;border-right:1px solid var(--border);background:var(--surface);overflow-y:auto;min-height:0}.insights-category-list{list-style:none;margin:0;padding:var(--space-sm);display:flex;flex-direction:column;gap:var(--space-xs)}.insights-category-item{width:100%;display:flex;align-items:center;gap:var(--space-sm);padding:var(--space-sm) var(--space-md);background:transparent;border:1px solid transparent;border-radius:var(--radius-md);color:var(--text);font:inherit;font-size:.8125rem;text-align:left;cursor:pointer;transition:background var(--transition-fast),border-color var(--transition-fast)}.insights-category-item:hover{background:var(--surface-1)}.insights-category-item--active{background:color-mix(in srgb,var(--accent) 12%,transparent);border-color:color-mix(in srgb,var(--accent) 35%,transparent);color:var(--accent)}.insights-category-icon{flex-shrink:0;color:var(--accent)}.insights-category-label{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:500}.insights-category-count{flex-shrink:0;font-size:.75rem;color:var(--text-muted);background:var(--surface-1);padding:var(--space-xs) var(--space-sm);border-radius:var(--radius-pill);border:1px solid var(--border)}.insights-category-item--active .insights-category-count{background:var(--surface);color:var(--accent);border-color:color-mix(in srgb,var(--accent) 30%,transparent)}.insights-detail{flex:1;min-width:0;min-height:0;overflow-y:auto;padding:var(--space-lg)}.insights-section{background:transparent;border:none;border-radius:0;overflow:visible}.insights-section-header{display:flex;align-items:center;justify-content:space-between;padding:0 0 var(--space-md);background:transparent;border-bottom:none}.insights-section-title{display:flex;align-items:center;gap:var(--space-sm)}.insights-section-title h3{margin:0;font-size:.9375rem;font-weight:600}.insights-section-icon{color:var(--accent)}.insights-section-count{font-size:.75rem;color:var(--text-muted);background:var(--surface-1);padding:var(--space-xs) var(--space-sm);border-radius:var(--radius-pill);border:1px solid var(--border)}.insights-section-content{padding:0}.insights-list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:var(--space-sm)}.insight-item{padding:var(--space-md) var(--space-lg);background:var(--card);border:1px solid var(--border);border-left:3px solid color-mix(in srgb,var(--accent) 55%,transparent);border-radius:var(--radius-md);transition:border-color var(--transition-fast),background var(--transition-fast)}.insight-item:hover{background:var(--surface);border-left-color:var(--accent)}.insight-item-header{display:flex;align-items:flex-start;justify-content:space-between;gap:var(--space-sm)}.insight-item-title{margin:0;font-size:.875rem;font-weight:600;color:var(--text);line-height:1.4}.insight-item-actions{display:flex;align-items:center;gap:var(--space-xs);flex-shrink:0}.insight-item-action-btn{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;background:transparent;border:none;border-radius:var(--radius-sm);color:var(--text-muted);cursor:pointer;opacity:.65;transition:background var(--transition-fast),color var(--transition-fast),opacity var(--transition-fast)}.insight-item:hover .insight-item-action-btn,.insight-item:focus-within .insight-item-action-btn{opacity:1}.insight-item-action-btn:hover:not(:disabled){background:var(--surface-1);color:var(--accent)}.insight-item-action-btn:focus-visible{outline:none;box-shadow:var(--focus-ring-strong)}.insight-item-action-btn:disabled{opacity:.5;cursor:not-allowed}.insight-item-content{margin:var(--space-sm) 0 0;font-size:.8125rem;color:var(--text-muted);line-height:1.5;white-space:pre-wrap;word-break:break-word}.insight-item-meta{display:flex;align-items:center;gap:var(--space-md);margin-top:var(--space-sm);font-size:.75rem;color:var(--text-muted)}.insight-item-status{padding:var(--space-xs) var(--space-sm);border-radius:var(--radius-sm);text-transform:capitalize;font-weight:500}.insight-item-status--generated{background:color-mix(in srgb,var(--accent) 15%,transparent);color:var(--accent)}.insight-item-status--confirmed{background:color-mix(in srgb,var(--color-success) 15%,transparent);color:var(--color-success)}.insight-item-status--stale{background:color-mix(in srgb,var(--color-warning) 15%,transparent);color:var(--color-warning)}.insight-item-status--dismissed,.insight-item-status--archived{background:color-mix(in srgb,var(--text-dim) 15%,transparent);color:var(--text-dim)}.insight-item--archived{opacity:.6;border-left-color:var(--text-dim)}.insight-item--archived .insight-item-title{text-decoration:line-through;color:var(--text-muted)}.insight-item--archived .insight-item-content{text-decoration:line-through}.insight-item-date{display:flex;align-items:center;gap:var(--space-xs)}@media(max-width:768px),(max-height:480px){.insights-view .view-header{align-items:flex-start;flex-wrap:wrap;gap:var(--space-sm) var(--space-md)}.insights-view .view-header__title{flex:1 0 100%;min-width:100%}.insights-view .view-header__title span{overflow:visible;text-overflow:clip}.insights-view .view-header__actions{justify-content:flex-start;width:100%;max-width:100%;margin-left:0}.insights-body{flex-direction:column}.insights-sidebar{width:100%;border-right:none;border-bottom:var(--chrome-divider-width, 1px) solid var(--insights-divider-color);overflow-x:auto;overflow-y:hidden;flex-shrink:0}.insights-category-list{flex-direction:row;flex-wrap:nowrap;padding:var(--space-sm);gap:var(--space-xs)}.insights-category-list>li{flex-shrink:0}.insights-category-item{white-space:nowrap;padding:var(--space-xs) var(--space-sm)}.insights-category-label{overflow:visible;text-overflow:clip}.insights-detail{padding:var(--space-md)}.insights-section-header{padding:var(--space-sm) var(--space-md)}.insights-section-content,.insight-item{padding:var(--space-sm)}.insight-item-title{word-break:break-word}.insight-item-header{flex-direction:column;gap:var(--space-sm)}.insight-item-meta{flex-wrap:wrap;gap:var(--space-sm)}.insight-item-actions{align-self:flex-end}.insight-item-action-btn{width:calc(var(--space-2xl) + var(--space-sm));height:calc(var(--space-2xl) + var(--space-sm))}.view-header__actions .insights-view-actions-btn{min-height:calc(var(--space-2xl) + var(--space-xs))}.insights-show-archived-toggle{max-width:calc(var(--space-2xl) * 5 + var(--space-md));white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.insights-view-close{min-height:calc(var(--space-2xl) + var(--space-xs));min-width:calc(var(--space-2xl) + var(--space-xs))}.insights-view-count{font-size:.75rem}.insights-model-config{padding:var(--space-xs) var(--space-md)}.insights-model-config .model-combobox{max-width:200px}}@media(min-width:769px)and (max-width:1024px){.insights-view{flex:1;inline-size:100%;min-inline-size:0;min-block-size:0;overflow:hidden}.insights-body{flex-direction:column;inline-size:100%;min-width:0;min-inline-size:0;min-block-size:0;overflow:hidden}.insights-sidebar{width:100%;min-width:0;min-inline-size:0;border-right:none;border-bottom:var(--chrome-divider-width, 1px) solid var(--insights-divider-color);overflow-x:auto;overflow-y:hidden}.insights-category-list{flex-direction:row;flex-wrap:nowrap}.insights-category-list>li{flex-shrink:0}.insights-category-item{white-space:nowrap}.insights-detail{flex:1 1 0;min-width:0;min-inline-size:0;min-block-size:0;overflow-y:auto}}.insights-recommendations__count,.insights-recommendations__source{color:var(--color-text-muted);font-size:var(--font-size-sm)}.insights-recommendations__item{overflow-wrap:anywhere}@media(max-width:768px),(max-height:480px){.insights-recommendations .btn{inline-size:100%}}@media(min-width:769px)and (max-width:1024px){.insights-recommendations__item{min-inline-size:0}}
@@ -1,3 +1,3 @@
1
- import{r,j as e}from"./vendor-react-SZ_qB27O.js";import{u as Le,f as fe,a as Se,s as Re,i as qe,t as Te,b as je,c as ve,d as Pe,e as He,g as _e,h as Oe}from"./SettingsModal-Dc7YG6KB.js";import{aY as Ue,aX as $e,V as Qe,aZ as Be,L as D,aK as Ne}from"./index-DWRJyaa3.js";import{u as We}from"./vendor-i18n-Duky4gdQ.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";const O=".fusion/memory/MEMORY.md",Ve=5e4,Ye="0 3 * * *",Ze="0 4 * * *";function de(i){return{memoryEnabled:i.memoryEnabled!==!1,memoryAutoSummarizeEnabled:i.memoryAutoSummarizeEnabled??!1,memoryAutoSummarizeThresholdChars:i.memoryAutoSummarizeThresholdChars??Ve,memoryAutoSummarizeSchedule:i.memoryAutoSummarizeSchedule??Ye,memoryDreamsEnabled:i.memoryDreamsEnabled??!1,memoryDreamsSchedule:i.memoryDreamsSchedule??Ze}}function Ce(i,t){return i.some(h=>h.path===t)?t:i.find(h=>h.path===O)?.path??i[0]?.path??O}function Ge(i={}){const{projectId:t}=i,[h,s]=r.useState(null),[d,v]=r.useState(!0),[L,z]=r.useState(!1),[I,S]=r.useState(()=>de({})),[x,j]=r.useState(!0),[n,k]=r.useState(!1),[U,$]=r.useState([]),[X,R]=r.useState(!0),[y,M]=r.useState(O),[N,w]=r.useState(""),[ye,Q]=r.useState(!1),[l,u]=r.useState(!1),[J,B]=r.useState(!1),[g,W]=r.useState(!1),[ee,q]=r.useState(!1),[c,P]=r.useState(null),[he,V]=r.useState(!0),[se,Y]=r.useState(!1),[te,Z]=r.useState(!1),{status:G,loading:ue,refresh:A}=Le({projectId:t}),K=r.useCallback(m=>{w(m),u(!0)},[]),H=r.useCallback(async m=>{Q(!0);try{const{content:o}=await fe(m,t);M(m),w(o),u(!1)}finally{Q(!1)}},[t]),C=r.useCallback(async()=>{R(!0);try{const{files:m}=await Se(t);if($(m),m.length===0){M(O),w(""),u(!1);return}const o=Ce(m,y);o!==y&&await H(o)}finally{R(!1)}},[t,y,H]);r.useEffect(()=>{let m=!1;async function o(){try{const p=await ve(t);m||(s(p.content),z(p.exists),v(!1))}catch{m||(s(null),z(!1),v(!1))}}return o(),()=>{m=!0}},[t]),r.useEffect(()=>{let m=!1;async function o(){j(!0);try{const p=await $e(t);m||S(de(p))}catch{m||S(de({}))}finally{m||j(!1)}}return o(),()=>{m=!0}},[t]);const ae=r.useRef(y);r.useEffect(()=>{ae.current=y},[y]),r.useEffect(()=>{let m=!1;async function o(){R(!0);try{const{files:p}=await Se(t);if(m)return;if($(p),p.length===0){M(O),w(""),u(!1);return}const oe=Ce(p,ae.current),{content:xe}=await fe(oe,t);if(m)return;M(oe),w(xe),u(!1)}catch{m||($([]),M(O),w(""),u(!1))}finally{m||R(!1)}}return o(),()=>{m=!0}},[t]),r.useEffect(()=>{let m=!1;async function o(){try{const p=await je(t);m||(P(p),V(!1))}catch{m||(P(null),V(!1))}}return o(),()=>{m=!0}},[t]);const re=r.useCallback(async m=>{k(!0);try{const o=await Ue(m,t);S(de(o))}finally{k(!1)}},[t]),me=r.useCallback(async m=>{await H(m)},[H]),ne=r.useCallback(async()=>{if(l){B(!0);try{await Re(y,N,t),u(!1),await C()}finally{B(!1)}}},[N,l,y,t,C]),ie=r.useCallback(async()=>{Z(!0);try{const m=await qe(t);return await A(),m}finally{Z(!1)}},[t,A]),le=r.useCallback(async m=>Te(m,t),[t]),_=r.useCallback(async()=>{try{const m=await je(t);P(m)}catch{P(null)}},[t]),F=r.useCallback(async()=>{try{const m=await ve(t);s(m.content),z(m.exists)}catch{s(null),z(!1)}},[t]),f=r.useCallback(async m=>{await Pe(m,t),await F()},[t,F]),ge=r.useCallback(async()=>{W(!0);try{const m=await He(t);return await Promise.all([F(),_()]),{success:m.success,summary:m.summary}}finally{W(!1)}},[t,F,_]),T=r.useCallback(async()=>{q(!0);try{return await _e(t)}finally{q(!1)}},[t]),be=r.useCallback(async m=>{Y(!0);try{const o=await Oe(m,t),p=o.path??m;M(p),w(o.content),u(!1),await C()}finally{Y(!1)}},[t,C]);return{insightsContent:h,insightsLoading:d,insightsExists:L,refreshInsights:F,saveInsights:f,memorySettings:I,settingsLoading:x,savingMemorySettings:n,saveMemorySettings:re,memoryFiles:U,memoryFilesLoading:X,selectedFilePath:y,selectedFileContent:N,selectedFileLoading:ye,selectedFileDirty:l,setSelectedFileContent:K,selectFile:me,saveSelectedFile:ne,savingSelectedFile:J,reloadMemoryFiles:C,backendStatus:G,backendLoading:ue,extractInsights:ge,extracting:g,triggerDreamNow:T,dreamRunning:ee,auditReport:c,auditLoading:he,refreshAudit:_,compactMemory:be,compacting:se,installQmdAction:ie,installingQmd:te,testRetrieval:le}}const Ke={Patterns:"pattern",Principles:"principle",Conventions:"convention",Pitfalls:"pitfall",Context:"context"},Xe=72;function Je(i,t){if(i.length<=t)return i;const h=Math.max(1,t-1),s=Math.ceil(h/2),d=Math.floor(h/2);return`${i.slice(0,s)}…${i.slice(i.length-d)}`}function es(i){const t=`${i.label} — ${i.path}`;return Je(t,Xe)}function ss(i){if(!i)return[];const t=[],h=i.split(/(?=^## )/m);for(const s of h){const d=s.trim();if(!d)continue;const v=d.match(/^##\s+(.+?)(\n|$)/);if(v){const L=v[1].trim(),z=Ke[L]??L.toLowerCase(),I=d.slice(v[0].length).replace(/<!--[\s\S]*?-->/g,"").trim(),S=I.split(`
1
+ import{r,j as e}from"./vendor-react-SZ_qB27O.js";import{u as Le,f as fe,a as Se,s as Re,i as qe,t as Te,b as je,c as ve,d as Pe,e as He,g as _e,h as Oe}from"./SettingsModal-rUQcSTJp.js";import{aY as Ue,aX as $e,V as Qe,aZ as Be,L as D,aK as Ne}from"./index-CtYRoouR.js";import{u as We}from"./vendor-i18n-Duky4gdQ.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";const O=".fusion/memory/MEMORY.md",Ve=5e4,Ye="0 3 * * *",Ze="0 4 * * *";function de(i){return{memoryEnabled:i.memoryEnabled!==!1,memoryAutoSummarizeEnabled:i.memoryAutoSummarizeEnabled??!1,memoryAutoSummarizeThresholdChars:i.memoryAutoSummarizeThresholdChars??Ve,memoryAutoSummarizeSchedule:i.memoryAutoSummarizeSchedule??Ye,memoryDreamsEnabled:i.memoryDreamsEnabled??!1,memoryDreamsSchedule:i.memoryDreamsSchedule??Ze}}function Ce(i,t){return i.some(h=>h.path===t)?t:i.find(h=>h.path===O)?.path??i[0]?.path??O}function Ge(i={}){const{projectId:t}=i,[h,s]=r.useState(null),[d,v]=r.useState(!0),[L,z]=r.useState(!1),[I,S]=r.useState(()=>de({})),[x,j]=r.useState(!0),[n,k]=r.useState(!1),[U,$]=r.useState([]),[X,R]=r.useState(!0),[y,M]=r.useState(O),[N,w]=r.useState(""),[ye,Q]=r.useState(!1),[l,u]=r.useState(!1),[J,B]=r.useState(!1),[g,W]=r.useState(!1),[ee,q]=r.useState(!1),[c,P]=r.useState(null),[he,V]=r.useState(!0),[se,Y]=r.useState(!1),[te,Z]=r.useState(!1),{status:G,loading:ue,refresh:A}=Le({projectId:t}),K=r.useCallback(m=>{w(m),u(!0)},[]),H=r.useCallback(async m=>{Q(!0);try{const{content:o}=await fe(m,t);M(m),w(o),u(!1)}finally{Q(!1)}},[t]),C=r.useCallback(async()=>{R(!0);try{const{files:m}=await Se(t);if($(m),m.length===0){M(O),w(""),u(!1);return}const o=Ce(m,y);o!==y&&await H(o)}finally{R(!1)}},[t,y,H]);r.useEffect(()=>{let m=!1;async function o(){try{const p=await ve(t);m||(s(p.content),z(p.exists),v(!1))}catch{m||(s(null),z(!1),v(!1))}}return o(),()=>{m=!0}},[t]),r.useEffect(()=>{let m=!1;async function o(){j(!0);try{const p=await $e(t);m||S(de(p))}catch{m||S(de({}))}finally{m||j(!1)}}return o(),()=>{m=!0}},[t]);const ae=r.useRef(y);r.useEffect(()=>{ae.current=y},[y]),r.useEffect(()=>{let m=!1;async function o(){R(!0);try{const{files:p}=await Se(t);if(m)return;if($(p),p.length===0){M(O),w(""),u(!1);return}const oe=Ce(p,ae.current),{content:xe}=await fe(oe,t);if(m)return;M(oe),w(xe),u(!1)}catch{m||($([]),M(O),w(""),u(!1))}finally{m||R(!1)}}return o(),()=>{m=!0}},[t]),r.useEffect(()=>{let m=!1;async function o(){try{const p=await je(t);m||(P(p),V(!1))}catch{m||(P(null),V(!1))}}return o(),()=>{m=!0}},[t]);const re=r.useCallback(async m=>{k(!0);try{const o=await Ue(m,t);S(de(o))}finally{k(!1)}},[t]),me=r.useCallback(async m=>{await H(m)},[H]),ne=r.useCallback(async()=>{if(l){B(!0);try{await Re(y,N,t),u(!1),await C()}finally{B(!1)}}},[N,l,y,t,C]),ie=r.useCallback(async()=>{Z(!0);try{const m=await qe(t);return await A(),m}finally{Z(!1)}},[t,A]),le=r.useCallback(async m=>Te(m,t),[t]),_=r.useCallback(async()=>{try{const m=await je(t);P(m)}catch{P(null)}},[t]),F=r.useCallback(async()=>{try{const m=await ve(t);s(m.content),z(m.exists)}catch{s(null),z(!1)}},[t]),f=r.useCallback(async m=>{await Pe(m,t),await F()},[t,F]),ge=r.useCallback(async()=>{W(!0);try{const m=await He(t);return await Promise.all([F(),_()]),{success:m.success,summary:m.summary}}finally{W(!1)}},[t,F,_]),T=r.useCallback(async()=>{q(!0);try{return await _e(t)}finally{q(!1)}},[t]),be=r.useCallback(async m=>{Y(!0);try{const o=await Oe(m,t),p=o.path??m;M(p),w(o.content),u(!1),await C()}finally{Y(!1)}},[t,C]);return{insightsContent:h,insightsLoading:d,insightsExists:L,refreshInsights:F,saveInsights:f,memorySettings:I,settingsLoading:x,savingMemorySettings:n,saveMemorySettings:re,memoryFiles:U,memoryFilesLoading:X,selectedFilePath:y,selectedFileContent:N,selectedFileLoading:ye,selectedFileDirty:l,setSelectedFileContent:K,selectFile:me,saveSelectedFile:ne,savingSelectedFile:J,reloadMemoryFiles:C,backendStatus:G,backendLoading:ue,extractInsights:ge,extracting:g,triggerDreamNow:T,dreamRunning:ee,auditReport:c,auditLoading:he,refreshAudit:_,compactMemory:be,compacting:se,installQmdAction:ie,installingQmd:te,testRetrieval:le}}const Ke={Patterns:"pattern",Principles:"principle",Conventions:"convention",Pitfalls:"pitfall",Context:"context"},Xe=72;function Je(i,t){if(i.length<=t)return i;const h=Math.max(1,t-1),s=Math.ceil(h/2),d=Math.floor(h/2);return`${i.slice(0,s)}…${i.slice(i.length-d)}`}function es(i){const t=`${i.label} — ${i.path}`;return Je(t,Xe)}function ss(i){if(!i)return[];const t=[],h=i.split(/(?=^## )/m);for(const s of h){const d=s.trim();if(!d)continue;const v=d.match(/^##\s+(.+?)(\n|$)/);if(v){const L=v[1].trim(),z=Ke[L]??L.toLowerCase(),I=d.slice(v[0].length).replace(/<!--[\s\S]*?-->/g,"").trim(),S=I.split(`
2
2
  `).reduce((x,j)=>{const n=j.trim();return/^[-*]\s+/.test(j)?x.push(n.replace(/^[-*]\s+/,"")):n.length>0&&x.length>0&&(x[x.length-1]=`${x[x.length-1]}
3
3
  ${j.trimEnd()}`),x},[]);(S.length>0||I.length>0)&&t.push({name:L,key:z,items:S.length>0?S:I.length>0?[I]:[],expanded:!0})}}return t}function ts(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 as(i){return i.reduce((t,h)=>t+h.items.length,0)}function ds({projectId:i,addToast:t,onSendSelectionToTask:h}){const{t:s}=We("app"),[d,v]=r.useState("working"),[L,z]=r.useState(new Set),[I,S]=r.useState(!1),[x,j]=r.useState(null),[n,k]=r.useState({memoryEnabled:!0,memoryAutoSummarizeEnabled:!1,memoryAutoSummarizeThresholdChars:5e4,memoryAutoSummarizeSchedule:"0 3 * * *",memoryDreamsEnabled:!1,memoryDreamsSchedule:"0 4 * * *"}),[U,$]=r.useState(""),[X,R]=r.useState(!1),[y,M]=r.useState(null),{insightsContent:N,insightsLoading:w,insightsExists:ye,saveInsights:Q,memorySettings:l,settingsLoading:u,saveMemorySettings:J,savingMemorySettings:B,backendStatus:g,backendLoading:W,extractInsights:ee,extracting:q,auditReport:c,auditLoading:P,refreshAudit:he,compactMemory:V,compacting:se,installQmdAction:Y,installingQmd:te,testRetrieval:Z,memoryFiles:G,memoryFilesLoading:ue,selectedFilePath:A,selectedFileContent:K,selectedFileLoading:H,selectedFileDirty:C,setSelectedFileContent:ae,selectFile:re,saveSelectedFile:me,savingSelectedFile:ne,reloadMemoryFiles:ie,triggerDreamNow:le,dreamRunning:_}=Ge({projectId:i});r.useEffect(()=>{k(l)},[l]);const F=r.useMemo(()=>n.memoryEnabled!==l.memoryEnabled||n.memoryAutoSummarizeEnabled!==l.memoryAutoSummarizeEnabled||n.memoryAutoSummarizeThresholdChars!==l.memoryAutoSummarizeThresholdChars||n.memoryAutoSummarizeSchedule!==l.memoryAutoSummarizeSchedule||n.memoryDreamsEnabled!==l.memoryDreamsEnabled||n.memoryDreamsSchedule!==l.memoryDreamsSchedule,[n,l]),f=r.useMemo(()=>G.find(a=>a.path===A),[G,A]),ge=f?f.layer==="long-term"?s("memory.layerDescLongTerm","Curated durable decisions, conventions, constraints, and pitfalls promoted from dreams."):f.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."),T=r.useMemo(()=>ss(N),[N]),be=r.useMemo(()=>as(T),[T]),m=r.useMemo(()=>ts(N),[N]),o=r.useCallback(a=>{z(b=>{const E=new Set(b);return E.has(a)?E.delete(a):E.add(a),E})},[]),p=r.useCallback(async a=>{try{await re(a)}catch{t(s("memory.loadFileFailed","Failed to load memory file"),"error")}},[re,t]),oe=r.useCallback(async()=>{try{await me(),t(s("memory.memorySaved","Memory saved"),"success")}catch{t(s("memory.saveMemoryFailed","Failed to save memory"),"error")}},[me,t]),xe=r.useCallback(async()=>{if(!F)return;const a={};n.memoryEnabled!==l.memoryEnabled&&(a.memoryEnabled=n.memoryEnabled),n.memoryAutoSummarizeEnabled!==l.memoryAutoSummarizeEnabled&&(a.memoryAutoSummarizeEnabled=n.memoryAutoSummarizeEnabled),n.memoryAutoSummarizeThresholdChars!==l.memoryAutoSummarizeThresholdChars&&(a.memoryAutoSummarizeThresholdChars=n.memoryAutoSummarizeThresholdChars),n.memoryAutoSummarizeSchedule!==l.memoryAutoSummarizeSchedule&&(a.memoryAutoSummarizeSchedule=n.memoryAutoSummarizeSchedule),n.memoryDreamsEnabled!==l.memoryDreamsEnabled&&(a.memoryDreamsEnabled=n.memoryDreamsEnabled),n.memoryDreamsSchedule!==l.memoryDreamsSchedule&&(a.memoryDreamsSchedule=n.memoryDreamsSchedule);try{await J(a),t(s("memory.settingsSaved","Memory settings saved"),"success")}catch{t(s("memory.saveSettingsFailed","Failed to save memory settings"),"error")}},[F,n,l,J,t]),Ee=r.useCallback(async()=>{try{const a=await Y();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")}},[Y,t]),ke=r.useCallback(async()=>{R(!0),M(null);try{const a=await Z(U);M(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{R(!1)}},[U,Z,t]),Me=r.useCallback(async()=>{try{await le(),t(s("memory.dreamProcessingComplete","Dream processing completed"),"success"),await ie()}catch(a){t(a instanceof Error?a.message:s("memory.dreamProcessingFailed","Failed to run dream processing"),"error")}},[le,ie,t]),we=r.useCallback(async()=>{try{await V(A),t(s("memory.fileCompacted","Memory file compacted"),"success")}catch{t(s("memory.compactFailed","Failed to compact memory"),"error")}},[V,A,t]),pe=r.useCallback(async()=>{try{const a=await ee();t(a.summary,"success")}catch(a){t(a instanceof Error?a.message:s("memory.extractInsightsFailed","Failed to extract insights"),"error")}},[ee,t]),Ae=r.useCallback(async()=>{if(x!==null)try{await Q(x),S(!1),j(null),t(s("memory.insightsSaved","Insights saved"),"success")}catch{t(s("memory.saveInsightsFailed","Failed to save insights"),"error")}},[x,Q,t]),Fe=r.useCallback(()=>{j(N??""),S(!0)},[N]),De=r.useCallback(()=>{S(!1),j(null)},[]),ze=!W&&g!==null,ce=g?.capabilities?.writable??!1;return e.jsxs("div",{className:"memory-view",children:[e.jsx(Qe,{icon:Be,title:s("memory.title","Memory")}),e.jsxs("div",{className:"memory-view-tabs",role:"tablist",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":d==="working",className:`memory-view-tab${d==="working"?" memory-view-tab--active":""}`,onClick:()=>v("working"),"data-testid":"memory-tab-working",children:s("memory.tabWorking","Working Memory")}),e.jsx("button",{type:"button",role:"tab","aria-selected":d==="insights",className:`memory-view-tab${d==="insights"?" memory-view-tab--active":""}`,onClick:()=>v("insights"),"data-testid":"memory-tab-insights",children:s("memory.tabInsights","Insights")}),e.jsx("button",{type:"button",role:"tab","aria-selected":d==="engines",className:`memory-view-tab${d==="engines"?" memory-view-tab--active":""}`,onClick:()=>v("engines"),"data-testid":"memory-tab-engines",children:s("memory.tabEngines","Engines")})]}),e.jsxs("div",{className:"memory-view-content",children:[d==="working"&&e.jsxs("div",{className:"memory-working-tab",children:[ze&&!ce&&e.jsx("div",{className:"memory-readonly-banner",children:s("memory.readOnlyBanner","This memory backend is read-only. Changes cannot be saved.")}),ue||H?e.jsxs("div",{className:"memory-empty-state",children:[e.jsx(D,{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:A,onChange:a=>{p(a.target.value)},disabled:C,children:G.map(a=>e.jsx("option",{value:a.path,title:`${a.label} — ${a.path}`,children:es(a)},a.path))}),e.jsx("small",{children:C?s("memory.fileSwitchDirtyHint","Save or discard the current edits before switching files."):s("memory.fileSwitchHint","Choose any project memory file to view or edit.")})]}),f&&e.jsxs("div",{className:"memory-file-summary",children:[e.jsx("span",{children:f.layer==="long-term"?s("memory.layerLongTerm","Long-term"):f.layer==="daily"?s("memory.layerDaily","Daily"):s("memory.layerDreams","Dreams")}),e.jsx("strong",{children:f.path}),e.jsx("small",{children:s("memory.fileSummary","{{size}} bytes · updated {{updatedAt}}",{size:f.size.toLocaleString(),updatedAt:new Date(f.updatedAt).toLocaleString()})})]}),e.jsxs("div",{className:"form-group memory-editor-form-group",children:[e.jsx("label",{children:f?.label||s("memory.editorLabel","Memory Editor")}),e.jsx("small",{children:ge}),e.jsx("div",{className:"memory-editor-container",children:e.jsx(Ne,{content:K,onChange:ae,readOnly:!ce,filePath:A,forceToolbarActionsVisible:!0,onSendSelectionToTask:h})})]})]}),e.jsxs("div",{className:"memory-action-bar",children:[e.jsx("span",{className:"memory-char-count",children:s("memory.charCount","{{count}} characters",{count:K.length})}),e.jsx("div",{className:"memory-flex-spacer"}),ce&&K.length>0&&e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:we,disabled:se||C,children:se?e.jsxs(e.Fragment,{children:[e.jsx(D,{size:14,className:"animate-spin"}),s("memory.compacting","Compacting…")]}):s("memory.compactSelectedFile","Compact Selected File")}),C&&ce&&e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:oe,disabled:ne,children:ne?e.jsxs(e.Fragment,{children:[e.jsx(D,{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 memory-toggle-row",children:[e.jsxs("label",{htmlFor:"memoryDreamsEnabled",className:"checkbox-label",title:s("memory.dreamsEnabledTooltip","Daily notes are distilled into DREAMS.md and reusable lessons are promoted into MEMORY.md."),children:[e.jsx("input",{id:"memoryDreamsEnabled",type:"checkbox",checked:n.memoryDreamsEnabled,onChange:a=>{k(b=>({...b,memoryDreamsEnabled:a.target.checked}))},disabled:!n.memoryEnabled||u}),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=>{k(b=>({...b,memoryDreamsSchedule:a.target.value}))},placeholder:"0 4 * * *",disabled:u}),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:Me,disabled:_||!n.memoryDreamsEnabled,children:_?e.jsxs(e.Fragment,{children:[e.jsx(D,{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 memory-toggle-row",children:[e.jsxs("label",{htmlFor:"memoryAutoSummarizeEnabled",className:"checkbox-label",children:[e.jsx("input",{id:"memoryAutoSummarizeEnabled",type:"checkbox",checked:n.memoryAutoSummarizeEnabled,onChange:a=>{k(b=>({...b,memoryAutoSummarizeEnabled:a.target.checked}))},disabled:!n.memoryEnabled||u}),s("memory.autoSummarizeLabel","Auto-summarize memory")]}),e.jsx("small",{children:s("memory.autoSummarizeHint","Automatically compacts 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=>{k(b=>({...b,memoryAutoSummarizeThresholdChars:parseInt(a.target.value,10)||5e4}))},min:1e3,disabled:u}),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=>{k(b=>({...b,memoryAutoSummarizeSchedule:a.target.value}))},placeholder:"0 3 * * *",disabled:u}),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.")}),F&&e.jsx("div",{className:"memory-action-bar",children:e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:xe,disabled:B||u,children:B?e.jsxs(e.Fragment,{children:[e.jsx(D,{size:14,className:"animate-spin"}),s("memory.saving","Saving…")]}):s("memory.saveSettings","Save Settings")})})]})]})]}),d==="insights"&&e.jsx("div",{className:"memory-insights-tab",children:w?e.jsxs("div",{className:"memory-empty-state",children:[e.jsx(D,{size:20,className:"animate-spin"}),e.jsx("span",{children:s("memory.loadingInsights","Loading insights…")})]}):I?e.jsxs("div",{className:"memory-insights-editor-layout",children:[e.jsx("div",{className:"memory-editor-container",children:e.jsx(Ne,{content:x??"",onChange:j,readOnly:!1,filePath:".fusion/memory/memory-insights.md",forceToolbarActionsVisible:!0,onSendSelectionToTask:h})}),e.jsxs("div",{className:"memory-action-bar",children:[e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:De,children:s("memory.cancel","Cancel")}),e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:Ae,children:s("memory.saveInsights","Save Insights")})]})]}):!ye||T.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:pe,disabled:q,children:q?e.jsxs(e.Fragment,{children:[e.jsx(D,{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:be}),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:T.length}),e.jsx("div",{className:"memory-stat-label",children:s("memory.categories","Categories")})]}),m&&e.jsxs("div",{className:"memory-stat-card",children:[e.jsx("div",{className:"memory-stat-value memory-stat-value--updated",children:m}),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:pe,disabled:q,children:q?e.jsxs(e.Fragment,{children:[e.jsx(D,{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:Fe,children:s("memory.editRaw","Edit Raw")})]}),e.jsx("div",{className:"memory-categories-list",children:T.map(a=>{const b=!L.has(a.key);return e.jsxs("div",{className:"memory-category-section",children:[e.jsxs("div",{className:"memory-category-header",onClick:()=>o(a.key),role:"button",tabIndex:0,onKeyDown:E=>{(E.key==="Enter"||E.key===" ")&&(E.preventDefault(),o(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((E,Ie)=>e.jsx("div",{className:"memory-insight-item",children:E.replace(/^-\s+/,"").replace(/^\*\s+/,"")},Ie))})]},a.key)})})]})}),d==="engines"&&e.jsx("div",{className:"memory-engines-tab",children:W||P?e.jsxs("div",{className:"memory-empty-state",children:[e.jsx(D,{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")}),g?.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.")})]}):g?.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:g.qmdInstallCommand||"bun install -g @tobilu/qmd"})]}),e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:Ee,disabled:te,children:te?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-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:U,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:ke,disabled:X,children:X?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.")}),y&&e.jsxs("div",{className:"memory-test-result",children:[e.jsx("strong",{children:s("memory.testResultCount",'{{count}} result for "{{query}}"',{count:y.results.length,query:y.query,defaultValue_one:'{{count}} result for "{{query}}"',defaultValue_other:'{{count}} results for "{{query}}"'})}),e.jsx("small",{children:s("memory.testResultStatus","qmd {{qmdStatus}} · {{fallbackStatus}}",{qmdStatus:y.qmdAvailable?s("memory.qmdStatusAvailable","available"):s("memory.qmdStatusMissing","missing"),fallbackStatus:y.usedFallback?s("memory.localFallbackUsed","local fallback used"):s("memory.qmdPathUsed","qmd path used")})}),y.results.length>0?e.jsx("ul",{children:y.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:g?.currentBackend==="file"?s("memory.backendFile","File (.fusion/memory/, agent/<agent-name>/memory/)"):g?.currentBackend==="readonly"?s("memory.backendReadonly","Read-Only"):g?.currentBackend==="qmd"?s("memory.backendQmd","QMD (Quantized Memory Distillation)"):g?.currentBackend??"unknown"})}),e.jsxs("div",{className:"memory-capability-row",children:[g?.capabilities?.readable&&e.jsx("span",{className:"memory-capability-badge",children:s("memory.capReadable","Readable")}),g?.capabilities?.writable&&e.jsx("span",{className:"memory-capability-badge",children:s("memory.capWritable","Writable")}),g?.capabilities?.supportsAtomicWrite&&e.jsx("span",{className:"memory-capability-badge",children:s("memory.capAtomicWrites","Atomic Writes")}),g?.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:()=>he(),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{ds as MemoryView};
@@ -1,4 +1,4 @@
1
- import{r as l,j as e}from"./vendor-react-SZ_qB27O.js";import{c as V,b8 as Y,b9 as Z,ba as T,R as L,aJ as D,aM as P,P as ee,C as se,g as ae,x as ie,aH as B,bb as ne,bc as te,bd as H,X as re}from"./index-DWRJyaa3.js";import{u as le}from"./vendor-i18n-Duky4gdQ.js";import{P as $}from"./puzzle-DQ0y1-XK.js";import{B as A}from"./AgentPermissionPolicyEditor-DP1QbZL-.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";/**
1
+ import{r as l,j as e}from"./vendor-react-SZ_qB27O.js";import{c as V,b8 as Y,b9 as Z,ba as T,R as L,aJ as D,aM as P,P as ee,C as se,g as ae,x as ie,aH as B,bb as ne,bc as te,bd as H,X as re}from"./index-CtYRoouR.js";import{u as le}from"./vendor-i18n-Duky4gdQ.js";import{P as $}from"./puzzle-hvecxlpJ.js";import{B as A}from"./AgentPermissionPolicyEditor--u9jyUf2.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.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.